VirtualBox

Ignore:
Timestamp:
Feb 24, 2015 4:50:08 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
98565
Message:

PDM/Audio: AudioMixBuffer.cpp: Bugfixes, logging, fixed testcase.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp

    r53945 r54460  
    55
    66/*
    7  * Copyright (C) 2014 Oracle Corporation
     7 * Copyright (C) 2014-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    133133static int tstParentChild(RTTEST hTest)
    134134{
    135     RTTestSubF(hTest, "Child<->Parent");
     135    RTTestSubF(hTest, "2 Children -> Parent");
    136136
    137137    uint32_t cBufSize = _1K;
    138138
    139     PDMAUDIOSTREAMCFG cp =
     139    PDMAUDIOSTREAMCFG cfg_p =
    140140    {
    141141        44100,                   /* Hz */
     
    146146    PDMPCMPROPS props;
    147147
    148     int rc = drvAudioStreamCfgToProps(&cp, &props);
     148    int rc = drvAudioStreamCfgToProps(&cfg_p, &props);
    149149    AssertRC(rc);
    150150
     
    152152    RTTESTI_CHECK_RC_OK(audioMixBufInit(&parent, "Parent", &props, cBufSize));
    153153
    154     PDMAUDIOSTREAMCFG cc =
     154    PDMAUDIOSTREAMCFG cfg_c1 = /* Downmixing */
    155155    {
    156156        22100,                   /* Hz */
     
    160160    };
    161161
    162     rc = drvAudioStreamCfgToProps(&cc, &props);
     162    rc = drvAudioStreamCfgToProps(&cfg_c1, &props);
    163163    AssertRC(rc);
    164164
     
    167167    RTTESTI_CHECK_RC_OK(audioMixBufLinkTo(&child1, &parent));
    168168
     169    PDMAUDIOSTREAMCFG cfg_c2 = /* Upmixing */
     170    {
     171        48000,                   /* Hz */
     172        2                        /* Channels */,
     173        AUD_FMT_S16              /* Format */,
     174        PDMAUDIOENDIANESS_LITTLE /* Endianess */
     175    };
     176
     177    rc = drvAudioStreamCfgToProps(&cfg_c2, &props);
     178    AssertRC(rc);
     179
    169180    PDMAUDIOMIXBUF child2;
    170181    RTTESTI_CHECK_RC_OK(audioMixBufInit(&child2, "Child2", &props, cBufSize));
     
    172183
    173184    /*
    174      * Writing + mixing from child(s) -> parent, sequential.
    175      */
    176     int16_t samples16[2] = { 0xAA, 0xBB };
    177     uint32_t read = 0, written = 0, proc, mixed = 0;
    178 
    179     RTTESTI_CHECK_RC_OK(audioMixBufWriteAt(&child1, 0, &samples16, sizeof(samples16),
    180                                            &written));
    181     RTTESTI_CHECK_RC_OK(audioMixBufMixToParent(&child1, written, &mixed));
    182     RTTESTI_CHECK(mixed == 1);
    183     RTTESTI_CHECK(audioMixBufMixed(&child1) == mixed);
    184 
    185     RTTESTI_CHECK_RC_OK(audioMixBufWriteAt(&child2, 0, &samples16, sizeof(samples16),
    186                                            &written));
    187     RTTESTI_CHECK_RC_OK(audioMixBufMixToParent(&child2, written, &mixed));
    188     RTTESTI_CHECK(mixed == 1);
    189     RTTESTI_CHECK(audioMixBufMixed(&child2) == mixed);
     185     * Writing + mixing from child/children -> parent, sequential.
     186     */
     187    size_t cbBuf = _1K;
     188    char pvBuf[_1K];
     189    int16_t samples16[32] = { 0xAA, 0xBB };
     190    uint32_t read , written, proc, mixed;
     191
     192    uint32_t cSamplesParent1 = 16;
     193    uint32_t cSamplesChild1  = 16;
     194    uint32_t cSamplesParent2 = 32;
     195    uint32_t cSamplesChild2  = 16;
     196
     197    for (int i = 0; i < 32; i++)
     198    {
     199        RTTESTI_CHECK_RC_OK(audioMixBufWriteAt(&child1, 0, &samples16, sizeof(samples16), &written));
     200        RTTESTI_CHECK(written == cSamplesChild1);
     201        RTTESTI_CHECK_RC_OK(audioMixBufMixToParent(&child1, written, &mixed));
     202        RTTESTI_CHECK(mixed == cSamplesChild1);
     203
     204        RTTESTI_CHECK_RC_OK(audioMixBufReadCirc(&parent, pvBuf, cbBuf, &read));
     205        RTTESTI_CHECK(read == 31);
     206
     207        RTTESTI_CHECK_RC_OK(audioMixBufWriteAt(&child2, 0, &samples16, sizeof(samples16), &written));
     208        RTTESTI_CHECK(written == cSamplesChild2);
     209        RTTESTI_CHECK_RC_OK(audioMixBufMixToParent(&child2, written, &mixed));
     210        RTTESTI_CHECK(mixed == cSamplesChild2);
     211
     212        RTTESTI_CHECK_RC_OK(audioMixBufReadCirc(&parent, pvBuf, cbBuf, &read));
     213        RTTESTI_CHECK(read == 15);
     214    }
    190215
    191216    RTTESTI_CHECK(audioMixBufProcessed(&parent) == 0);
    192 
    193217
    194218    return RTTestSubErrorCount(hTest) ? VERR_GENERAL_FAILURE : VINF_SUCCESS;
     
    208232    RTTestBanner(hTest);
    209233
    210     rc = tstSingle(hTest);
    211     if (RT_SUCCESS(rc))
     234    /*rc = tstSingle(hTest);
     235    if (RT_SUCCESS(rc))*/
    212236        rc = tstParentChild(hTest);
    213237
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette