VirtualBox

Ignore:
Timestamp:
Oct 8, 2021 6:59:29 AM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
147357
Message:

Audio/Validation Kit: Factored out general I/O options into AUDIOTESTIOOPTS to also support setting the master volume besides the test tone volume, as function parameter lists already were too big. Also uniformed the command line volume arguments a little ("--vol vs. --volume" everywhere). ​bugref:10008

Location:
trunk/src/VBox/ValidationKit/utils/audio
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp

    r91454 r91632  
    122122    VKAT_TEST_OPT_COUNT = 900,
    123123    VKAT_TEST_OPT_DEV,
    124     VKAT_TEST_OPT_TONE_DURATION_MS,
    125124    VKAT_TEST_OPT_GUEST_ATS_ADDR,
    126125    VKAT_TEST_OPT_GUEST_ATS_PORT,
     
    142141    VKAT_TEST_OPT_TCP_BIND_PORT,
    143142    VKAT_TEST_OPT_TCP_CONNECT_ADDRESS,
    144     VKAT_TEST_OPT_TCP_CONNECT_PORT
     143    VKAT_TEST_OPT_TCP_CONNECT_PORT,
     144    VKAT_TEST_OPT_TONE_DURATION_MS,
     145    VKAT_TEST_OPT_TONE_VOL_PERCENT
    145146};
    146147
     
    195196    { "--tag",               VKAT_TEST_OPT_TAG,                 RTGETOPT_REQ_STRING  },
    196197    { "--tempdir",           VKAT_TEST_OPT_TEMPDIR,             RTGETOPT_REQ_STRING  },
    197     { "--volume",            VKAT_TEST_OPT_VOL,                 RTGETOPT_REQ_UINT8   },
     198    { "--vol",               VKAT_TEST_OPT_VOL,                 RTGETOPT_REQ_UINT8   },
    198199    { "--tcp-bind-addr",     VKAT_TEST_OPT_TCP_BIND_ADDRESS,    RTGETOPT_REQ_STRING  },
    199200    { "--tcp-bind-port",     VKAT_TEST_OPT_TCP_BIND_PORT,       RTGETOPT_REQ_UINT16  },
    200201    { "--tcp-connect-addr",  VKAT_TEST_OPT_TCP_CONNECT_ADDRESS, RTGETOPT_REQ_STRING  },
    201202    { "--tcp-connect-port",  VKAT_TEST_OPT_TCP_CONNECT_PORT,    RTGETOPT_REQ_UINT16  },
    202     { "--tone-duration",     VKAT_TEST_OPT_TONE_DURATION_MS,    RTGETOPT_REQ_UINT32  }
     203    { "--tone-duration",     VKAT_TEST_OPT_TONE_DURATION_MS,    RTGETOPT_REQ_UINT32  },
     204    { "--tone-vol",          VKAT_TEST_OPT_TONE_VOL_PERCENT,    RTGETOPT_REQ_UINT8   }
    203205};
    204206
     
    275277
    276278    pTstParmsAcq->enmType     = AUDIOTESTTYPE_TESTTONE_PLAY;
    277     pTstParmsAcq->Props       = pTstEnv->Props;
    278279    pTstParmsAcq->enmDir      = PDMAUDIODIR_OUT;
    279280    pTstParmsAcq->cIterations = pTstEnv->cIterations == 0 ? RTRandU32Ex(1, 10) : pTstEnv->cIterations;
    280281    pTstParmsAcq->idxCurrent  = 0;
    281282
    282     PAUDIOTESTTONEPARMS pToneParms = &pTstParmsAcq->TestTone;
    283 
    284     pToneParms->Props          = pTstParmsAcq->Props;
    285     pToneParms->dbFreqHz       = AudioTestToneGetRandomFreq();
    286     pToneParms->msPrequel      = 0; /** @todo Implement analyzing this first! */
    287     pToneParms->msDuration     = pTstEnv->cMsToneDuration == 0 ? RTRandU32Ex(200, RT_MS_30SEC) : pTstEnv->cMsToneDuration;
    288     pToneParms->msSequel       = 0;   /** @todo Implement analyzing this first! */
    289     pToneParms->uVolumePercent = 100; /** @todo Implement analyzing this first! */
     283    pTstParmsAcq->TestTone    = pTstEnv->ToneParms;
    290284
    291285    return rc;
     
    381375
    382376    pTstParmsAcq->enmType     = AUDIOTESTTYPE_TESTTONE_RECORD;
    383     pTstParmsAcq->Props       = pTstEnv->Props;
    384377    pTstParmsAcq->enmDir      = PDMAUDIODIR_IN;
    385378    pTstParmsAcq->cIterations = pTstEnv->cIterations == 0 ? RTRandU32Ex(1, 10) : pTstEnv->cIterations;
    386379    pTstParmsAcq->idxCurrent  = 0;
    387380
    388     PAUDIOTESTTONEPARMS pToneParms = &pTstParmsAcq->TestTone;
    389 
    390     pToneParms->Props          = pTstParmsAcq->Props;
    391     pToneParms->dbFreqHz       = AudioTestToneGetRandomFreq();
    392     pToneParms->msPrequel      = 0; /** @todo Implement analyzing this first! */
    393     pToneParms->Props          = pTstParmsAcq->Props;
    394     pToneParms->msDuration     = pTstEnv->cMsToneDuration == 0 ? RTRandU32Ex(200, RT_MS_30SEC) : pTstEnv->cMsToneDuration;
    395     pToneParms->msSequel       = 0;   /** @todo Implement analyzing this first! */
    396     pToneParms->uVolumePercent = 100; /** @todo Implement analyzing this first! */
     381    pTstParmsAcq->TestTone    = pTstEnv->ToneParms;
    397382
    398383    return rc;
     
    717702        case VKAT_TEST_OPT_DEV:                 return "Name of the input/output device to use\n"
    718703                                                       "    Default: default device";
    719         case VKAT_TEST_OPT_TONE_DURATION_MS:    return "Duration (in ms) of test tone to play / record for selected tests\n"
    720                                                        "    Default: random number";
     704        case VKAT_TEST_OPT_TONE_DURATION_MS:    return "Test tone duration to play / record (ms)\n"
     705                                                       "    Default: random duration";
     706        case VKAT_TEST_OPT_TONE_VOL_PERCENT:    return "Test tone volume (percent)\n"
     707                                                       "    Default: 100";
    721708        case VKAT_TEST_OPT_GUEST_ATS_ADDR:      return "Address of guest ATS to connect to\n"
    722709                                                       "    Default: " ATS_TCP_DEF_CONNECT_GUEST_STR;
     
    727714        case VKAT_TEST_OPT_HOST_ATS_PORT:       return "Port of host ATS to connect to\n"
    728715                                                       "    Default: 6052"; /* ATS_TCP_DEF_BIND_PORT_VALKIT */
    729         case VKAT_TEST_OPT_MODE:                return "Specifies the test mode to use when running the tests";
     716        case VKAT_TEST_OPT_MODE:                return "Test mode to use when running the tests";
    730717        case VKAT_TEST_OPT_NO_VERIFY:           return "Skips the verification step";
    731         case VKAT_TEST_OPT_OUTDIR:              return "Specifies the output directory to use";
     718        case VKAT_TEST_OPT_OUTDIR:              return "Output directory to use";
    732719        case VKAT_TEST_OPT_PAUSE:               return "Not yet implemented";
    733         case VKAT_TEST_OPT_PCM_HZ:              return "Specifies the PCM Hetz (Hz) rate to use\n"
     720        case VKAT_TEST_OPT_PCM_HZ:              return "PCM Hertz (Hz) rate to use\n"
    734721                                                       "    Default: 44100";
    735         case VKAT_TEST_OPT_PCM_BIT:             return "Specifies the PCM sample bits (i.e. 16) to use\n"
     722        case VKAT_TEST_OPT_PCM_BIT:             return "PCM sample bits (i.e. 16) to use\n"
    736723                                                       "    Default: 16";
    737         case VKAT_TEST_OPT_PCM_CHAN:            return "Specifies the number of PCM channels to use\n"
     724        case VKAT_TEST_OPT_PCM_CHAN:            return "PCM channels to use\n"
    738725                                                       "    Default: 2";
    739         case VKAT_TEST_OPT_PCM_SIGNED:          return "Specifies whether to use signed (true) or unsigned (false) samples\n"
     726        case VKAT_TEST_OPT_PCM_SIGNED:          return "PCM samples to use (signed = true, unsigned = false)\n"
    740727                                                       "    Default: true";
    741         case VKAT_TEST_OPT_PROBE_BACKENDS:      return "Specifies whether to probe all (available) backends until a working one is found\n"
     728        case VKAT_TEST_OPT_PROBE_BACKENDS:      return "Whether to probe all (available) backends until a working one is found\n"
    742729                                                       "    Default: false";
    743         case VKAT_TEST_OPT_TAG:                 return "Specifies the test set tag to use";
    744         case VKAT_TEST_OPT_TEMPDIR:             return "Specifies the temporary directory to use";
    745         case VKAT_TEST_OPT_VOL:                 return "Specifies the audio volume (in percent, 0-100) to use";
    746         case VKAT_TEST_OPT_TCP_BIND_ADDRESS:    return "Specifies the TCP address listening to (server mode)";
    747         case VKAT_TEST_OPT_TCP_BIND_PORT:       return "Specifies the TCP port listening to (server mode)";
    748         case VKAT_TEST_OPT_TCP_CONNECT_ADDRESS: return "Specifies the TCP address to connect to (client mode)";
    749         case VKAT_TEST_OPT_TCP_CONNECT_PORT:    return "Specifies the TCP port to connect to (client mode)";
     730        case VKAT_TEST_OPT_TAG:                 return "Test set tag to use";
     731        case VKAT_TEST_OPT_TEMPDIR:             return "Temporary directory to use";
     732        case VKAT_TEST_OPT_VOL:                 return "Audio volume (percent) to use";
     733        case VKAT_TEST_OPT_TCP_BIND_ADDRESS:    return "TCP address listening to (server mode)";
     734        case VKAT_TEST_OPT_TCP_BIND_PORT:       return "TCP port listening to (server mode)";
     735        case VKAT_TEST_OPT_TCP_CONNECT_ADDRESS: return "TCP address to connect to (client mode)";
     736        case VKAT_TEST_OPT_TCP_CONNECT_PORT:    return "TCP port to connect to (client mode)";
    750737        default:
    751738            break;
     
    763750{
    764751    AUDIOTESTENV TstEnv;
    765     RT_ZERO(TstEnv);
     752    audioTestEnvInit(&TstEnv);
    766753
    767754    int         rc;
    768755
    769     PCPDMDRVREG pDrvReg       = AudioTestGetDefaultBackend();
    770     bool        fWithDrvAudio = false;
    771     uint8_t     cPcmSampleBit = 0;
    772     uint8_t     cPcmChannels  = 0;
    773     uint32_t    uPcmHz        = 0;
    774     bool        fPcmSigned    = true;
     756    PCPDMDRVREG pDrvReg        = AudioTestGetDefaultBackend();
     757    uint8_t     cPcmSampleBit  = 0;
     758    uint8_t     cPcmChannels   = 0;
     759    uint32_t    uPcmHz         = 0;
     760    bool        fPcmSigned     = true;
    775761    bool        fProbeBackends = false;
    776762
     
    798784
    799785            case 'd':
    800                 fWithDrvAudio = true;
     786                TstEnv.IoOpts.fWithDrvAudio = true;
    801787                break;
    802788
     
    850836
    851837            case VKAT_TEST_OPT_TONE_DURATION_MS:
    852                 TstEnv.cMsToneDuration = ValueUnion.u32;
     838                TstEnv.ToneParms.msDuration = ValueUnion.u32;
     839                break;
     840
     841            case VKAT_TEST_OPT_TONE_VOL_PERCENT:
     842                TstEnv.ToneParms.uVolumePercent = ValueUnion.u8;
    853843                break;
    854844
     
    895885
    896886            case VKAT_TEST_OPT_VOL:
    897                 TstEnv.uVolumePercent = ValueUnion.u8;
     887                TstEnv.IoOpts.uVolumePercent = ValueUnion.u8;
    898888                break;
    899889
     
    930920    RTTestBanner(g_hTest);
    931921
    932     /* Initialize the custom test parameters with sensible defaults if nothing else is given. */
    933     PDMAudioPropsInit(&TstEnv.Props,
    934                       cPcmSampleBit ? cPcmSampleBit / 8 : 2 /* 16-bit */, fPcmSigned, cPcmChannels ? cPcmChannels : 2,
    935                       uPcmHz ? uPcmHz : 44100);
    936 
    937922    if (TstEnv.enmMode == AUDIOTESTMODE_UNKNOWN)
    938923        return RTMsgErrorExit(RTEXITCODE_SYNTAX, "No test mode (--mode) specified!\n");
     
    943928        return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Only one TCP connection mode (connect as client *or* bind as server) can be specified) at a time!\n");
    944929
     930    /* Set new (override standard) I/O PCM properties if set by the user. */
     931    if (   cPcmSampleBit
     932        || cPcmChannels
     933        || uPcmHz)
     934    {
     935        PDMAudioPropsInit(&TstEnv.IoOpts.Props,
     936                          cPcmSampleBit ? cPcmSampleBit / 2 : 2 /* 16-bit */, fPcmSigned /* fSigned */,
     937                          cPcmChannels  ? cPcmChannels      : 2 /* Stereo */, uPcmHz ? uPcmHz : 44100);
     938    }
     939
    945940    AUDIOTESTDRVSTACK DrvStack;
    946941    if (fProbeBackends)
    947942        rc = audioTestDriverStackProbe(&DrvStack, pDrvReg,
    948                                        true /* fEnabledIn */, true /* fEnabledOut */, fWithDrvAudio); /** @todo Make in/out configurable, too. */
     943                                       true /* fEnabledIn */, true /* fEnabledOut */, TstEnv.IoOpts.fWithDrvAudio); /** @todo Make in/out configurable, too. */
    949944    else
    950945        rc = audioTestDriverStackInitEx(&DrvStack, pDrvReg,
    951                                         true /* fEnabledIn */, true /* fEnabledOut */, fWithDrvAudio); /** @todo Make in/out configurable, too. */
     946                                        true /* fEnabledIn */, true /* fEnabledOut */, TstEnv.IoOpts.fWithDrvAudio); /** @todo Make in/out configurable, too. */
    952947    if (RT_FAILURE(rc))
    953948        return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unable to init driver stack: %Rrc\n", rc);
     
    959954
    960955    /* For now all tests have the same test environment and driver stack. */
    961     rc = audioTestEnvInit(&TstEnv, &DrvStack);
     956    rc = audioTestEnvCreate(&TstEnv, &DrvStack);
    962957    if (RT_SUCCESS(rc))
    963958        rc = audioTestWorker(&TstEnv);
  • trunk/src/VBox/ValidationKit/utils/audio/vkatCmdGeneric.cpp

    r91453 r91632  
    6767    {
    6868        case 'b':                               return "The audio backend to use.";
    69         case VKAT_ENUM_OPT_PROBE_BACKENDS:      return "Specifies whether to probe all (available) backends until a working one is found\n"
     69        case VKAT_ENUM_OPT_PROBE_BACKENDS:      return "Whether to probe all (available) backends until a working one is found\n"
    7070                                                       "    Default: false";
    7171        default:  return NULL;
     
    191191*   Command: play                                                                                                                *
    192192*********************************************************************************************************************************/
    193 
    194 /**
    195  * Structure holding additional playback options.
    196  */
    197 typedef struct AUDIOTESTPLAYOPTS
    198 {
    199     /** Whether to use the audio connector or not. */
    200     bool             fWithDrvAudio;
    201     /** Whether to use a mixing buffer or not. */
    202     bool             fWithMixer;
    203     /** Buffer size (in ms). */
    204     uint32_t         cMsBufferSize;
    205     /** Pre-buffering size (in ms). */
    206     uint32_t         cMsPreBuffer;
    207     /** Scheduling (in ms). */
    208     uint32_t         cMsSchedulingHint;
    209     /** Audio vlume to use (in percent). */
    210     uint8_t          uVolumePercent;
    211     /** PCM audio properties to use. */
    212     PDMAUDIOPCMPROPS Props;
    213 } AUDIOTESTPLAYOPTS;
    214 /** Pointer to additional playback options. */
    215 typedef AUDIOTESTPLAYOPTS *PAUDIOTESTPLAYOPTS;
    216193
    217194/**
     
    304281 */
    305282static RTEXITCODE audioTestPlayOne(const char *pszFile, PCPDMDRVREG pDrvReg, const char *pszDevId,
    306                                    PAUDIOTESTPLAYOPTS pOpts)
     283                                   PAUDIOTESTIOOPTS pIoOpts)
    307284{
    308285    char szTmp[128];
     
    332309    RTEXITCODE          rcExit = RTEXITCODE_FAILURE;
    333310    AUDIOTESTDRVSTACK   DrvStack;
    334     rc = audioTestDriverStackInit(&DrvStack, pDrvReg, pOpts->fWithDrvAudio);
     311    rc = audioTestDriverStackInit(&DrvStack, pDrvReg, pIoOpts->fWithDrvAudio);
    335312    if (RT_SUCCESS(rc))
    336313    {
     
    344321             * Open a stream for the output.
    345322             */
    346             uint8_t const cChannels = PDMAudioPropsChannels(&pOpts->Props);
     323            uint8_t const cChannels = PDMAudioPropsChannels(&pIoOpts->Props);
    347324
    348325            PDMAUDIOPCMPROPS ReqProps = WaveFile.Props;
     
    350327                PDMAudioPropsSetChannels(&ReqProps, cChannels);
    351328
    352             uint8_t const cbSample = PDMAudioPropsSampleSize(&pOpts->Props);
     329            uint8_t const cbSample = PDMAudioPropsSampleSize(&pIoOpts->Props);
    353330            if (cbSample != 0)
    354331                PDMAudioPropsSetSampleSize(&ReqProps, cbSample);
    355332
    356             uint32_t const uHz = PDMAudioPropsHz(&pOpts->Props);
     333            uint32_t const uHz = PDMAudioPropsHz(&pIoOpts->Props);
    357334            if (uHz != 0)
    358335                ReqProps.uHz = uHz;
     
    360337            PDMAUDIOSTREAMCFG CfgAcq;
    361338            PPDMAUDIOSTREAM   pStream  = NULL;
    362             rc = audioTestDriverStackStreamCreateOutput(&DrvStack, &ReqProps, pOpts->cMsBufferSize,
    363                                                         pOpts->cMsPreBuffer, pOpts->cMsSchedulingHint, &pStream, &CfgAcq);
     339            rc = audioTestDriverStackStreamCreateOutput(&DrvStack, &ReqProps, pIoOpts->cMsBufferSize,
     340                                                        pIoOpts->cMsPreBuffer, pIoOpts->cMsSchedulingHint, &pStream, &CfgAcq);
    364341            if (RT_SUCCESS(rc))
    365342            {
     
    368345                 * output parameters doesn't match.
    369346                 */
    370                 if (   !pOpts->fWithMixer
     347                if (   !pIoOpts->fWithMixer
    371348                    && (   !PDMAudioPropsAreEqual(&WaveFile.Props, &pStream->Cfg.Props)
    372                         || pOpts->uVolumePercent != 100)
     349                        || pIoOpts->uVolumePercent != 100)
    373350                   )
    374351                {
    375352                    RTMsgInfo("Enabling the mixer buffer.\n");
    376                     pOpts->fWithMixer = true;
     353                    pIoOpts->fWithMixer = true;
    377354                }
    378355
     
    382359                 */
    383360                AUDIOTESTDRVMIXSTREAM Mix;
    384                 rc = AudioTestMixStreamInit(&Mix, &DrvStack, pStream, pOpts->fWithMixer ? &WaveFile.Props : NULL, 100 /*ms*/);
     361                rc = AudioTestMixStreamInit(&Mix, &DrvStack, pStream, pIoOpts->fWithMixer ? &WaveFile.Props : NULL, 100 /*ms*/);
    385362                if (RT_SUCCESS(rc))
    386363                {
     
    388365                        RTMsgInfo("Stream: %s cbBackend=%#RX32%s\n",
    389366                                  PDMAudioPropsToString(&pStream->Cfg.Props, szTmp, sizeof(szTmp)),
    390                                   pStream->cbBackend, pOpts->fWithMixer ? " mixed" : "");
    391 
    392                     if (pOpts->fWithMixer)
    393                         AudioTestMixStreamSetVolume(&Mix, pOpts->uVolumePercent);
     367                                  pStream->cbBackend, pIoOpts->fWithMixer ? " mixed" : "");
     368
     369                    if (pIoOpts->fWithMixer)
     370                        AudioTestMixStreamSetVolume(&Mix, pIoOpts->uVolumePercent);
    394371
    395372                    /*
     
    427404static RTEXITCODE audioTestPlayTestToneOne(PAUDIOTESTTONEPARMS pToneParms,
    428405                                           PCPDMDRVREG pDrvReg, const char *pszDevId,
    429                                            PAUDIOTESTPLAYOPTS pOpts)
     406                                           PAUDIOTESTIOOPTS pIoOpts)
    430407{
    431408    char szTmp[128];
     
    439416    RTEXITCODE          rcExit = RTEXITCODE_FAILURE;
    440417    AUDIOTESTDRVSTACK   DrvStack;
    441     int rc = audioTestDriverStackInit(&DrvStack, pDrvReg, pOpts->fWithDrvAudio);
     418    int rc = audioTestDriverStackInit(&DrvStack, pDrvReg, pIoOpts->fWithDrvAudio);
    442419    if (RT_SUCCESS(rc))
    443420    {
     
    451428             * Open a stream for the output.
    452429             */
    453             uint8_t const cChannels = PDMAudioPropsChannels(&pOpts->Props);
     430            uint8_t const cChannels = PDMAudioPropsChannels(&pIoOpts->Props);
    454431
    455432            PDMAUDIOPCMPROPS ReqProps = pToneParms->Props;
     
    457434                PDMAudioPropsSetChannels(&ReqProps, cChannels);
    458435
    459             uint8_t const cbSample = PDMAudioPropsSampleSize(&pOpts->Props);
     436            uint8_t const cbSample = PDMAudioPropsSampleSize(&pIoOpts->Props);
    460437            if (cbSample != 0)
    461438                PDMAudioPropsSetSampleSize(&ReqProps, cbSample);
    462439
    463             uint32_t const uHz = PDMAudioPropsHz(&pOpts->Props);
     440            uint32_t const uHz = PDMAudioPropsHz(&pIoOpts->Props);
    464441            if (uHz != 0)
    465442                ReqProps.uHz = uHz;
    466443
    467             rc = audioTestDriverStackStreamCreateOutput(&DrvStack, &ReqProps, pOpts->cMsBufferSize,
    468                                                         pOpts->cMsPreBuffer, pOpts->cMsSchedulingHint, &TstStream.pStream, &TstStream.Cfg);
     444            rc = audioTestDriverStackStreamCreateOutput(&DrvStack, &ReqProps, pIoOpts->cMsBufferSize,
     445                                                        pIoOpts->cMsPreBuffer, pIoOpts->cMsSchedulingHint, &TstStream.pStream, &TstStream.Cfg);
    469446            if (RT_SUCCESS(rc))
    470447            {
     
    473450                 * output parameters doesn't match.
    474451                 */
    475                 if (   !pOpts->fWithMixer
     452                if (   !pIoOpts->fWithMixer
    476453                    && (   !PDMAudioPropsAreEqual(&pToneParms->Props, &TstStream.pStream->Cfg.Props)
    477454                        || pToneParms->uVolumePercent != 100)
     
    479456                {
    480457                    RTMsgInfo("Enabling the mixer buffer.\n");
    481                     pOpts->fWithMixer = true;
     458                    pIoOpts->fWithMixer = true;
    482459                }
    483460
     
    487464                 */
    488465                rc = AudioTestMixStreamInit(&TstStream.Mix, &DrvStack, TstStream.pStream,
    489                                             pOpts->fWithMixer ? &pToneParms->Props : NULL, 100 /*ms*/);
     466                                            pIoOpts->fWithMixer ? &pToneParms->Props : NULL, 100 /*ms*/);
    490467                if (RT_SUCCESS(rc))
    491468                {
     
    493470                        RTMsgInfo("Stream: %s cbBackend=%#RX32%s\n",
    494471                                  PDMAudioPropsToString(&TstStream.pStream->Cfg.Props, szTmp, sizeof(szTmp)),
    495                                   TstStream.pStream->cbBackend, pOpts->fWithMixer ? " mixed" : "");
     472                                  TstStream.pStream->cbBackend, pIoOpts->fWithMixer ? " mixed" : "");
    496473
    497474                    /*
     
    501478                    if (RT_SUCCESS(rc))
    502479                    {
    503                         if (pOpts->fWithMixer)
     480                        if (pIoOpts->fWithMixer)
    504481                            AudioTestMixStreamSetVolume(&TstStream.Mix, pToneParms->uVolumePercent);
    505482
    506                         rc = audioTestPlayTone(NULL /* pTstEnv */, &TstStream, pToneParms);
     483                        rc = audioTestPlayTone(pIoOpts, NULL /* pTstEnv */, &TstStream, pToneParms);
    507484                        if (RT_SUCCESS(rc))
    508485                            rcExit = RTEXITCODE_SUCCESS;
     
    538515    VKAT_PLAY_OPT_TONE_DUR = 900,
    539516    VKAT_PLAY_OPT_TONE_FREQ,
     517    VKAT_PLAY_OPT_TONE_VOL,
    540518    VKAT_PLAY_OPT_VOL
    541519};
     
    555533    { "--tone-dur",         VKAT_PLAY_OPT_TONE_DUR,       RTGETOPT_REQ_UINT32 },
    556534    { "--tone-freq",        VKAT_PLAY_OPT_TONE_FREQ,      RTGETOPT_REQ_UINT32 },
     535    { "--tone-vol",         VKAT_PLAY_OPT_TONE_VOL,       RTGETOPT_REQ_UINT32 },
    557536    { "--output-device",    'o',                          RTGETOPT_REQ_STRING  },
    558537    { "--with-drv-audio",   'd',                          RTGETOPT_REQ_NOTHING },
     
    577556        case VKAT_PLAY_OPT_TONE_DUR:    return "Test tone duration (ms)";
    578557        case VKAT_PLAY_OPT_TONE_FREQ:   return "Test tone frequency (Hz)";
    579         case VKAT_PLAY_OPT_VOL:         return "Volume (in percent, 0-100) to use";
     558        case VKAT_PLAY_OPT_TONE_VOL:    return "Test tone volume (percent)";
     559        case VKAT_PLAY_OPT_VOL:         return "Playback volume (percent)";
    580560        default:                        return NULL;
    581561    }
     
    599579    uint32_t    uHz                 = 0;
    600580
    601     AUDIOTESTPLAYOPTS PlayOpts;
    602     RT_ZERO(PlayOpts);
    603 
    604     PlayOpts.uVolumePercent = 100; /* Use maximum volume by default. */
     581    AUDIOTESTIOOPTS IoOpts;
     582    audioTestIoOptsInitDefaults(&IoOpts);
    605583
    606584    AUDIOTESTTONEPARMS ToneParms;
    607     RT_ZERO(ToneParms);
    608 
    609     ToneParms.dbFreqHz   = AudioTestToneGetRandomFreq();
    610     ToneParms.msDuration = RTRandU32Ex(0, RT_MS_10SEC); /** @todo Probably a bit too long, but let's see. */
     585    audioTestToneParmsInit(&ToneParms);
    611586
    612587    /* Argument processing loop: */
     
    628603
    629604            case 'd':
    630                 PlayOpts.fWithDrvAudio = true;
     605                IoOpts.fWithDrvAudio = true;
    631606                break;
    632607
     
    636611
    637612            case 'm':
    638                 PlayOpts.fWithMixer = true;
     613                IoOpts.fWithMixer = true;
    639614                break;
    640615
     
    659634                break;
    660635
     636            case VKAT_PLAY_OPT_TONE_VOL:
     637                ToneParms.uVolumePercent = ValueUnion.u8;
     638                if (ToneParms.uVolumePercent > 100)
     639                    return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid tonevolume (0-100)");
     640                break;
     641
    661642            case VKAT_PLAY_OPT_VOL:
    662                 PlayOpts.uVolumePercent = ValueUnion.u8;
    663                 if (PlayOpts.uVolumePercent > 100)
    664                     return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid volume (0-100)");
     643                IoOpts.uVolumePercent = ValueUnion.u8;
     644                if (IoOpts.uVolumePercent > 100)
     645                    return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid playback volume (0-100)");
    665646                break;
    666647
     
    670651                    return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Playing test tones (-t) cannot be combined with playing files");
    671652
    672                 /* Use some sane defaults if no PCM props are set by the user. */
    673                 PDMAudioPropsInit(&PlayOpts.Props,
     653                /* Set new (override standard) I/O PCM properties if set by the user. */
     654                PDMAudioPropsInit(&IoOpts.Props,
    674655                                  cbSample  ? cbSample  : 2 /* 16-bit */, true /* fSigned */,
    675656                                  cChannels ? cChannels : 2 /* Stereo */, uHz ? uHz : 44100);
    676657
    677                 RTEXITCODE rcExit = audioTestPlayOne(ValueUnion.psz, pDrvReg, pszDevId, &PlayOpts);
     658                RTEXITCODE rcExit = audioTestPlayOne(ValueUnion.psz, pDrvReg, pszDevId, &IoOpts);
    678659                if (rcExit != RTEXITCODE_SUCCESS)
    679660                    return rcExit;
     
    695676                          cChannels ? cChannels : 2 /* Stereo */, uHz ? uHz : 44100);
    696677
    697         ToneParms.uVolumePercent = PlayOpts.uVolumePercent;
    698 
    699         RTEXITCODE rcExit = audioTestPlayTestToneOne(&ToneParms, pDrvReg, pszDevId, &PlayOpts);
     678        RTEXITCODE rcExit = audioTestPlayTestToneOne(&ToneParms, pDrvReg, pszDevId, &IoOpts);
    700679        if (rcExit != RTEXITCODE_SUCCESS)
    701680            return rcExit;
     
    800779 */
    801780static RTEXITCODE audioTestRecOne(const char *pszFile, uint8_t cWaveChannels, uint8_t cbWaveSample, uint32_t uWaveHz,
    802                                   PCPDMDRVREG pDrvReg, const char *pszDevId, uint32_t cMsBufferSize,
    803                                   uint32_t cMsPreBuffer, uint32_t cMsSchedulingHint,
    804                                   uint8_t cChannels, uint8_t cbSample, uint32_t uHz, bool fWithDrvAudio, bool fWithMixer,
     781                                  PCPDMDRVREG pDrvReg, const char *pszDevId, PAUDIOTESTIOOPTS pIoOpts,
    805782                                  uint64_t cMaxFrames, uint64_t cNsMaxDuration)
    806783{
     
    810787    RTEXITCODE          rcExit = RTEXITCODE_FAILURE;
    811788    AUDIOTESTDRVSTACK   DrvStack;
    812     int rc = audioTestDriverStackInit(&DrvStack, pDrvReg, fWithDrvAudio);
     789    int rc = audioTestDriverStackInit(&DrvStack, pDrvReg, pIoOpts->fWithDrvAudio);
    813790    if (RT_SUCCESS(rc))
    814791    {
     
    824801            PDMAUDIOPCMPROPS  ReqProps;
    825802            PDMAudioPropsInit(&ReqProps,
    826                               cbSample ? cbSample : cbWaveSample ? cbWaveSample : 2,
    827                               true /*fSigned*/,
    828                               cChannels ? cChannels : cWaveChannels ? cWaveChannels : 2,
    829                               uHz ? uHz : uWaveHz ? uWaveHz : 44100);
     803                              pIoOpts->Props.cbSampleX ? pIoOpts->Props.cbSampleX : cbWaveSample ? cbWaveSample : 2,
     804                              pIoOpts->Props.fSigned,
     805                              pIoOpts->Props.cChannelsX ? pIoOpts->Props.cChannelsX : cWaveChannels ? cWaveChannels : 2,
     806                              pIoOpts->Props.uHz ? pIoOpts->Props.uHz : uWaveHz ? uWaveHz : 44100);
     807
    830808            PDMAUDIOSTREAMCFG CfgAcq;
    831809            PPDMAUDIOSTREAM   pStream  = NULL;
    832             rc = audioTestDriverStackStreamCreateInput(&DrvStack, &ReqProps, cMsBufferSize,
    833                                                        cMsPreBuffer, cMsSchedulingHint, &pStream, &CfgAcq);
     810            rc = audioTestDriverStackStreamCreateInput(&DrvStack, &ReqProps, pIoOpts->cMsBufferSize,
     811                                                       pIoOpts->cMsPreBuffer, pIoOpts->cMsSchedulingHint, &pStream, &CfgAcq);
    834812            if (RT_SUCCESS(rc))
    835813            {
     
    844822                                  cWaveChannels ? cWaveChannels : PDMAudioPropsChannels(&CfgAcq.Props),
    845823                                  uWaveHz ? uWaveHz : PDMAudioPropsHz(&CfgAcq.Props));
    846                 if (!fWithMixer && !PDMAudioPropsAreEqual(&WaveProps, &CfgAcq.Props))
     824                if (!pIoOpts->fWithMixer && !PDMAudioPropsAreEqual(&WaveProps, &CfgAcq.Props))
    847825                {
    848826                    RTMsgInfo("Enabling the mixer buffer.\n");
    849                     fWithMixer = true;
     827                    pIoOpts->fWithMixer = true;
    850828                }
    851829
     
    864842                 */
    865843                AUDIOTESTDRVMIXSTREAM Mix;
    866                 rc = AudioTestMixStreamInit(&Mix, &DrvStack, pStream, fWithMixer ? &WaveProps : NULL, 100 /*ms*/);
     844                rc = AudioTestMixStreamInit(&Mix, &DrvStack, pStream, pIoOpts->fWithMixer ? &WaveProps : NULL, 100 /*ms*/);
    867845                if (RT_SUCCESS(rc))
    868846                {
     
    871849                        RTMsgInfo("Stream: %s cbBackend=%#RX32%s\n",
    872850                                  PDMAudioPropsToString(&pStream->Cfg.Props, szTmp, sizeof(szTmp)),
    873                                   pStream->cbBackend, fWithMixer ? " mixed" : "");
     851                                  pStream->cbBackend, pIoOpts->fWithMixer ? " mixed" : "");
    874852
    875853                    /*
     
    986964    /* Option values: */
    987965    PCPDMDRVREG pDrvReg             = AudioTestGetDefaultBackend();
    988     uint32_t    cMsBufferSize       = UINT32_MAX;
    989     uint32_t    cMsPreBuffer        = UINT32_MAX;
    990     uint32_t    cMsSchedulingHint   = UINT32_MAX;
    991966    const char *pszDevId            = NULL;
    992     bool        fWithDrvAudio       = false;
    993     bool        fWithMixer          = false;
    994967    uint8_t     cbSample            = 0;
    995968    uint8_t     cChannels           = 0;
     
    1001974    uint64_t    cNsMaxDuration      = UINT64_MAX;
    1002975
     976    AUDIOTESTIOOPTS IoOpts;
     977    audioTestIoOptsInitDefaults(&IoOpts);
     978
    1003979    /* Argument processing loop: */
    1004980    int           ch;
     
    1023999
    10241000            case 'd':
    1025                 fWithDrvAudio = true;
     1001                IoOpts.fWithDrvAudio = true;
    10261002                break;
    10271003
     
    10391015
    10401016            case 'm':
    1041                 fWithMixer = true;
     1017                IoOpts.fWithMixer = true;
    10421018                break;
    10431019
     
    10681044            case VINF_GETOPT_NOT_OPTION:
    10691045            {
     1046                if (   cbSample
     1047                    || cChannels
     1048                    || uHz)
     1049                {
     1050                    /* Set new (override standard) I/O PCM properties if set by the user. */
     1051                    PDMAudioPropsInit(&IoOpts.Props,
     1052                                      cbSample  ? cbSample  : 2 /* 16-bit */, true /* fSigned */,
     1053                                      cChannels ? cChannels : 2 /* Stereo */, uHz ? uHz : 44100);
     1054                }
     1055
    10701056                RTEXITCODE rcExit = audioTestRecOne(ValueUnion.psz, cWaveChannels, cbWaveSample, uWaveHz,
    1071                                                     pDrvReg, pszDevId, cMsBufferSize, cMsPreBuffer, cMsSchedulingHint,
    1072                                                     cChannels, cbSample, uHz, fWithDrvAudio, fWithMixer,
     1057                                                    pDrvReg, pszDevId, &IoOpts,
    10731058                                                    cMaxFrames, cNsMaxDuration);
    10741059                if (rcExit != RTEXITCODE_SUCCESS)
  • trunk/src/VBox/ValidationKit/utils/audio/vkatCmdSelfTest.cpp

    r90918 r91632  
    131131    PAUDIOTESTENV pTstEnvGst = &pCtx->Guest.TstEnv;
    132132
     133    audioTestEnvInit(pTstEnvGst);
     134
    133135    /* Flag the environment for self test mode. */
    134136    pTstEnvGst->fSelftest = true;
     
    151153    pTstEnvGst->enmMode = AUDIOTESTMODE_GUEST;
    152154
    153     /** @todo Make this customizable. */
    154     PDMAudioPropsInit(&pTstEnvGst->Props,
    155                       2 /* 16-bit */, true  /* fSigned */, 2 /* cChannels */, 44100 /* uHz */);
    156 
    157     rc = audioTestEnvInit(pTstEnvGst, &pCtx->DrvStack);
     155    rc = audioTestEnvCreate(pTstEnvGst, &pCtx->DrvStack);
    158156    if (RT_SUCCESS(rc))
    159157    {
     
    183181    PAUDIOTESTENV pTstEnvHst = &pCtx->Host.TstEnv;
    184182
     183    audioTestEnvInit(pTstEnvHst);
     184
    185185    /* Flag the environment for self test mode. */
    186186    pTstEnvHst->fSelftest = true;
     
    195195    rc = AudioTestPathCreateTemp(pTstEnvHst->szPathOut, sizeof(pTstEnvHst->szPathOut), "selftest-out");
    196196    AssertRCReturn(rc, RTEXITCODE_FAILURE);
    197 
    198     /* Initialize the PCM properties to some sane values. */
    199     PDMAudioPropsInit(&pTstEnvHst->Props,
    200                       2 /* 16-bit */, true /* fPcmSigned */, 2 /* cPcmChannels */, 44100 /* uPcmHz */);
    201197
    202198    /*
     
    224220        pTstEnvHst->enmMode = AUDIOTESTMODE_HOST;
    225221
    226         rc = audioTestEnvInit(pTstEnvHst, &pCtx->DrvStack);
     222        rc = audioTestEnvCreate(pTstEnvHst, &pCtx->DrvStack);
    227223        if (RT_SUCCESS(rc))
    228224        {
  • trunk/src/VBox/ValidationKit/utils/audio/vkatCommon.cpp

    r91619 r91632  
    8080*   Internal Functions                                                                                                           *
    8181*********************************************************************************************************************************/
    82 static int audioTestStreamInit(PAUDIOTESTDRVSTACK pDrvStack, PAUDIOTESTSTREAM pStream, PDMAUDIODIR enmDir, PCPDMAUDIOPCMPROPS pProps, bool fWithMixer, uint32_t cMsBufferSize, uint32_t cMsPreBuffer, uint32_t cMsSchedulingHint);
     82static int audioTestStreamInit(PAUDIOTESTDRVSTACK pDrvStack, PAUDIOTESTSTREAM pStream, PDMAUDIODIR enmDir, PAUDIOTESTIOOPTS pPlayOpt);
    8383static int audioTestStreamDestroy(PAUDIOTESTENV pTstEnv, PAUDIOTESTSTREAM pStream);
    8484
     
    334334
    335335static int audioTestStreamInit(PAUDIOTESTDRVSTACK pDrvStack, PAUDIOTESTSTREAM pStream,
    336                                PDMAUDIODIR enmDir, PCPDMAUDIOPCMPROPS pProps, bool fWithMixer,
    337                                uint32_t cMsBufferSize, uint32_t cMsPreBuffer, uint32_t cMsSchedulingHint)
     336                               PDMAUDIODIR enmDir, PAUDIOTESTIOOPTS pIoOpts)
    338337{
    339338    int rc;
    340339
    341340    if (enmDir == PDMAUDIODIR_IN)
    342         rc = audioTestDriverStackStreamCreateInput(pDrvStack, pProps, cMsBufferSize,
    343                                                    cMsPreBuffer, cMsSchedulingHint, &pStream->pStream, &pStream->Cfg);
     341        rc = audioTestDriverStackStreamCreateInput(pDrvStack, &pIoOpts->Props, pIoOpts->cMsBufferSize,
     342                                                   pIoOpts->cMsPreBuffer, pIoOpts->cMsSchedulingHint, &pStream->pStream, &pStream->Cfg);
    344343    else if (enmDir == PDMAUDIODIR_OUT)
    345         rc = audioTestDriverStackStreamCreateOutput(pDrvStack, pProps, cMsBufferSize,
    346                                                     cMsPreBuffer, cMsSchedulingHint, &pStream->pStream, &pStream->Cfg);
     344        rc = audioTestDriverStackStreamCreateOutput(pDrvStack, &pIoOpts->Props, pIoOpts->cMsBufferSize,
     345                                                    pIoOpts->cMsPreBuffer, pIoOpts->cMsSchedulingHint, &pStream->pStream, &pStream->Cfg);
    347346    else
    348347        rc = VERR_NOT_SUPPORTED;
     
    360359         * Automatically enable the mixer if the PCM properties don't match.
    361360         */
    362         if (   !fWithMixer
    363             && !PDMAudioPropsAreEqual(pProps, &pStream->Cfg.Props))
     361        if (   !pIoOpts->fWithMixer
     362            && !PDMAudioPropsAreEqual(&pIoOpts->Props, &pStream->Cfg.Props))
    364363        {
    365364            RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS,  "Enabling stream mixer\n");
    366             fWithMixer = true;
     365            pIoOpts->fWithMixer = true;
    367366        }
    368367
    369368        rc = AudioTestMixStreamInit(&pStream->Mix, pDrvStack, pStream->pStream,
    370                                     fWithMixer ? pProps : NULL, 100 /* ms */); /** @todo Configure mixer buffer? */
     369                                    pIoOpts->fWithMixer ? &pIoOpts->Props : NULL, 100 /* ms */); /** @todo Configure mixer buffer? */
    371370    }
    372371
     
    405404*   Test Primitives                                                                                                              *
    406405*********************************************************************************************************************************/
     406
     407/**
     408 * Initializes test tone parameters (partly with random values).
     409
     410 * @param   pToneParms          Test tone parameters to initialize.
     411 */
     412void audioTestToneParmsInit(PAUDIOTESTTONEPARMS pToneParms)
     413{
     414    RT_BZERO(pToneParms, sizeof(AUDIOTESTTONEPARMS));
     415
     416    /**
     417     * Set default (randomized) test tone parameters if not set explicitly.
     418     */
     419    pToneParms->dbFreqHz       = AudioTestToneGetRandomFreq();
     420    pToneParms->msDuration     = RTRandU32Ex(200, RT_MS_30SEC);
     421    pToneParms->uVolumePercent = 100; /* We always go with maximum volume for now. */
     422
     423    PDMAudioPropsInit(&pToneParms->Props,
     424                      2 /* 16-bit */, true /* fPcmSigned */, 2 /* cPcmChannels */, 44100 /* uPcmHz */);
     425}
     426
     427/**
     428 * Initializes I/O options with some sane default values.
     429 *
     430 * @param   pIoOpts             I/O options to initialize.
     431 */
     432void audioTestIoOptsInitDefaults(PAUDIOTESTIOOPTS pIoOpts)
     433{
     434    RT_BZERO(pIoOpts, sizeof(AUDIOTESTIOOPTS));
     435
     436    /* Initialize the PCM properties to some sane values. */
     437    PDMAudioPropsInit(&pIoOpts->Props,
     438                      2 /* 16-bit */, true /* fPcmSigned */, 2 /* cPcmChannels */, 44100 /* uPcmHz */);
     439
     440    pIoOpts->cMsBufferSize     = UINT32_MAX;
     441    pIoOpts->cMsPreBuffer      = UINT32_MAX;
     442    pIoOpts->cMsSchedulingHint = UINT32_MAX;
     443    pIoOpts->uVolumePercent    = 100; /* Use maximum volume by default. */
     444}
    407445
    408446#if 0 /* Unused */
     
    430468 *
    431469 * @returns VBox status code.
     470 * @param   pIoOpts             I/O options to use.
    432471 * @param   pTstEnv             Test environment to use for running the test.
    433472 *                              Optional and can be NULL (for simple playback only).
     
    437476 * @note    Blocking function.
    438477 */
    439 int audioTestPlayTone(PAUDIOTESTENV pTstEnv, PAUDIOTESTSTREAM pStream, PAUDIOTESTTONEPARMS pParms)
     478int audioTestPlayTone(PAUDIOTESTIOOPTS pIoOpts, PAUDIOTESTENV pTstEnv, PAUDIOTESTSTREAM pStream, PAUDIOTESTTONEPARMS pParms)
    440479{
    441480    AUDIOTESTTONE TstTone;
     
    446485        pcszPathOut = pTstEnv->Set.szPathAbs;
    447486
    448     RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Playing test tone (tone frequency is %RU16Hz, %RU32ms)\n", (uint16_t)pParms->dbFreqHz, pParms->msDuration);
     487    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Playing test tone (tone frequency is %RU16Hz, %RU32ms, %RU8%% volume)\n",
     488                 (uint16_t)pParms->dbFreqHz, pParms->msDuration, pParms->uVolumePercent);
    449489    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Using %RU32ms stream scheduling hint\n", pStream->Cfg.Device.cMsSchedulingHint);
    450490    if (pcszPathOut)
     
    462502    }
    463503
    464     /* Try to crank up the system's master volume up to 100% so that we (hopefully) play the test tone always at the same leve.
    465      * Not supported on all platforms yet, therefore not critical for overall testing (yet). */
    466     unsigned const uVolPercent = 100;
     504    uint8_t const uVolPercent = pIoOpts->uVolumePercent;
    467505    int rc2 = audioTestSetMasterVolume(uVolPercent);
    468506    if (RT_FAILURE(rc2))
     
    666704 *
    667705 * @returns VBox status code.
     706 * @param   pIoOpts             I/O options to use.
    668707 * @param   pTstEnv             Test environment to use for running the test.
    669708 * @param   pStream             Stream to use for recording the tone.
     
    672711 * @note    Blocking function.
    673712 */
    674 static int audioTestRecordTone(PAUDIOTESTENV pTstEnv, PAUDIOTESTSTREAM pStream, PAUDIOTESTTONEPARMS pParms)
     713static int audioTestRecordTone(PAUDIOTESTIOOPTS pIoOpts, PAUDIOTESTENV pTstEnv, PAUDIOTESTSTREAM pStream, PAUDIOTESTTONEPARMS pParms)
    675714{
    676715    const char *pcszPathOut = pTstEnv->Set.szPathAbs;
     
    694733
    695734        AudioTestObjAddMetadataStr(Obj, "stream_to_record_bytes=%RU32\n", cbToRecTotal);
    696         AudioTestObjAddMetadataStr(Obj, "stream_buffer_size_ms=%RU32\n", pTstEnv->cMsBufferSize);
    697         AudioTestObjAddMetadataStr(Obj, "stream_prebuf_size_ms=%RU32\n", pTstEnv->cMsPreBuffer);
     735        AudioTestObjAddMetadataStr(Obj, "stream_buffer_size_ms=%RU32\n", pIoOpts->cMsBufferSize);
     736        AudioTestObjAddMetadataStr(Obj, "stream_prebuf_size_ms=%RU32\n", pIoOpts->cMsPreBuffer);
    698737        /* Note: This mostly is provided by backend (e.g. PulseAudio / ALSA / ++) and
    699738         *       has nothing to do with the device emulation scheduling hint. */
    700         AudioTestObjAddMetadataStr(Obj, "device_scheduling_hint_ms=%RU32\n", pTstEnv->cMsSchedulingHint);
     739        AudioTestObjAddMetadataStr(Obj, "device_scheduling_hint_ms=%RU32\n", pIoOpts->cMsSchedulingHint);
    701740
    702741        uint8_t         abSamples[16384];
     
    862901static DECLCALLBACK(int) audioTestGstAtsTonePlayCallback(void const *pvUser, PAUDIOTESTTONEPARMS pToneParms)
    863902{
    864     PATSCALLBACKCTX pCtx    = (PATSCALLBACKCTX)pvUser;
    865     PAUDIOTESTENV   pTstEnv = pCtx->pTstEnv;
     903    PATSCALLBACKCTX  pCtx    = (PATSCALLBACKCTX)pvUser;
     904    PAUDIOTESTENV    pTstEnv = pCtx->pTstEnv;
     905    PAUDIOTESTIOOPTS pIoOpts = &pTstEnv->IoOpts;
    866906
    867907    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Got request for playing test tone #%RU32 (%RU16Hz, %RU32ms) ...\n",
     
    874914    const PAUDIOTESTSTREAM pTstStream = &pTstEnv->aStreams[0]; /** @todo Make this dynamic. */
    875915
    876     int rc = audioTestStreamInit(pTstEnv->pDrvStack, pTstStream, PDMAUDIODIR_OUT, &pTstEnv->Props, false /* fWithMixer */,
    877                                  pTstEnv->cMsBufferSize, pTstEnv->cMsPreBuffer, pTstEnv->cMsSchedulingHint);
     916    int rc = audioTestStreamInit(pTstEnv->pDrvStack, pTstStream, PDMAUDIODIR_OUT, pIoOpts);
    878917    if (RT_SUCCESS(rc))
    879918    {
     
    888927        if (RT_SUCCESS(rc))
    889928        {
    890             rc = audioTestPlayTone(pTstEnv, pTstStream, pToneParms);
     929            rc = audioTestPlayTone(&pTstEnv->IoOpts, pTstEnv, pTstStream, pToneParms);
    891930            if (RT_SUCCESS(rc))
    892931            {
     
    910949static DECLCALLBACK(int) audioTestGstAtsToneRecordCallback(void const *pvUser, PAUDIOTESTTONEPARMS pToneParms)
    911950{
    912     PATSCALLBACKCTX pCtx    = (PATSCALLBACKCTX)pvUser;
    913     PAUDIOTESTENV   pTstEnv = pCtx->pTstEnv;
     951    PATSCALLBACKCTX  pCtx    = (PATSCALLBACKCTX)pvUser;
     952    PAUDIOTESTENV    pTstEnv = pCtx->pTstEnv;
     953    PAUDIOTESTIOOPTS pIoOpts = &pTstEnv->IoOpts;
    914954
    915955    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Got request for recording test tone #%RU32 (%RU32ms) ...\n",
     
    922962    const PAUDIOTESTSTREAM pTstStream = &pTstEnv->aStreams[0]; /** @todo Make this dynamic. */
    923963
    924     int rc = audioTestStreamInit(pTstEnv->pDrvStack, pTstStream, PDMAUDIODIR_IN, &pTstEnv->Props, false /* fWithMixer */,
    925                                  pTstEnv->cMsBufferSize, pTstEnv->cMsPreBuffer, pTstEnv->cMsSchedulingHint);
     964    int rc = audioTestStreamInit(pTstEnv->pDrvStack, pTstStream, PDMAUDIODIR_IN, pIoOpts);
    926965    if (RT_SUCCESS(rc))
    927966    {
     
    930969        TstParms.enmType  = AUDIOTESTTYPE_TESTTONE_RECORD;
    931970        TstParms.enmDir   = PDMAUDIODIR_IN;
    932         TstParms.Props    = pToneParms->Props;
    933971        TstParms.TestTone = *pToneParms;
    934972
     
    937975        if (RT_SUCCESS(rc))
    938976        {
    939             rc = audioTestRecordTone(pTstEnv, pTstStream, pToneParms);
     977            rc = audioTestRecordTone(pIoOpts, pTstEnv, pTstStream, pToneParms);
    940978            if (RT_SUCCESS(rc))
    941979            {
     
    11751213 * Initializes an audio test environment.
    11761214 *
     1215 * @param   pTstEnv             Audio test environment to initialize.
     1216 */
     1217void audioTestEnvInit(PAUDIOTESTENV pTstEnv)
     1218{
     1219    RT_BZERO(pTstEnv, sizeof(AUDIOTESTENV));
     1220
     1221    audioTestIoOptsInitDefaults(&pTstEnv->IoOpts);
     1222    audioTestToneParmsInit(&pTstEnv->ToneParms);
     1223}
     1224
     1225/**
     1226 * Creates an audio test environment.
     1227 *
    11771228 * @returns VBox status code.
    1178  * @param   pTstEnv             Audio test environment to initialize.
     1229 * @param   pTstEnv             Audio test environment to create.
    11791230 * @param   pDrvStack           Driver stack to use.
    11801231 */
    1181 int audioTestEnvInit(PAUDIOTESTENV pTstEnv, PAUDIOTESTDRVSTACK pDrvStack)
    1182 {
     1232int audioTestEnvCreate(PAUDIOTESTENV pTstEnv, PAUDIOTESTDRVSTACK pDrvStack)
     1233{
     1234    AssertReturn(PDMAudioPropsAreValid(&pTstEnv->IoOpts.Props), VERR_WRONG_ORDER);
     1235
    11831236    int rc = VINF_SUCCESS;
    11841237
     
    12101263    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Output directory is '%s'\n", pTstEnv->szPathOut);
    12111264    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Temp directory is '%s'\n", pTstEnv->szPathTemp);
    1212 
    1213     if (!pTstEnv->cMsBufferSize)
    1214         pTstEnv->cMsBufferSize     = UINT32_MAX;
    1215     if (!pTstEnv->cMsPreBuffer)
    1216         pTstEnv->cMsPreBuffer      = UINT32_MAX;
    1217     if (!pTstEnv->cMsSchedulingHint)
    1218         pTstEnv->cMsSchedulingHint = UINT32_MAX;
    12191265
    12201266    char szPathTemp[RTPATH_MAX];
  • trunk/src/VBox/ValidationKit/utils/audio/vkatInternal.h

    r91489 r91632  
    197197
    198198/**
     199 * Structure holding additional I/O options.
     200 */
     201typedef struct AUDIOTESTIOOPTS
     202{
     203    /** Whether to use the audio connector or not. */
     204    bool             fWithDrvAudio;
     205    /** Whether to use a mixing buffer or not. */
     206    bool             fWithMixer;
     207    /** Buffer size (in ms). */
     208    uint32_t         cMsBufferSize;
     209    /** Pre-buffering size (in ms). */
     210    uint32_t         cMsPreBuffer;
     211    /** Scheduling (in ms). */
     212    uint32_t         cMsSchedulingHint;
     213    /** Audio vlume to use (in percent). */
     214    uint8_t          uVolumePercent;
     215    /** PCM audio properties to use. */
     216    PDMAUDIOPCMPROPS Props;
     217} AUDIOTESTIOOPTS;
     218/** Pointer to additional playback options. */
     219typedef AUDIOTESTIOOPTS *PAUDIOTESTIOOPTS;
     220
     221/**
    199222 * Structure for keeping a user context for the test service callbacks.
    200223 */
     
    225248    /** Whether skip the actual verification or not. */
    226249    bool                    fSkipVerify;
    227     /** The PCM properties to use. */
    228     PDMAUDIOPCMPROPS        Props;
    229250    /** Name of the audio device to use.
    230251     *  If empty the default audio device will be used. */
    231252    char                    szDev[128];
    232     /** Audio volume to use (in percent).
    233      *  Might not be available on all systems. */
    234     uint8_t                 uVolumePercent;
    235253    /** Number of iterations for *all* tests specified.
    236254     *  When set to 0 (default), a random value (see specific test) will be chosen. */
    237255    uint32_t                cIterations;
    238     /** Duration (in ms) to play / record test tone.
    239      *  When set to 0 (default), a random value (see specific test) will be chosen. */
    240     uint32_t                cMsToneDuration;
     256    /** I/O options to use. */
     257    AUDIOTESTIOOPTS         IoOpts;
     258    /** Test tone parameters to use. */
     259    AUDIOTESTTONEPARMS      ToneParms;
    241260    /** Output path for storing the test environment's final test files. */
    242261    char                    szTag[AUDIOTEST_TAG_MAX];
     
    245264    /** Temporary path for this test environment. */
    246265    char                    szPathTemp[RTPATH_MAX];
    247     /** Buffer size (in ms). */
    248     RTMSINTERVAL            cMsBufferSize;
    249     /** Pre-buffering time (in ms). */
    250     RTMSINTERVAL            cMsPreBuffer;
    251     /** Scheduling hint (in ms). */
    252     RTMSINTERVAL            cMsSchedulingHint;
    253266    /** Pointer to audio test driver stack to use. */
    254267    PAUDIOTESTDRVSTACK      pDrvStack;
     
    454467/** @name Test environment handling
    455468 * @{ */
    456 int         audioTestEnvInit(PAUDIOTESTENV pTstEnv, PAUDIOTESTDRVSTACK pDrvStack);
     469void        audioTestEnvInit(PAUDIOTESTENV pTstEnv);
     470int         audioTestEnvCreate(PAUDIOTESTENV pTstEnv, PAUDIOTESTDRVSTACK pDrvStack);
    457471void        audioTestEnvDestroy(PAUDIOTESTENV pTstEnv);
    458472int         audioTestEnvPrologue(PAUDIOTESTENV pTstEnv, bool fPack, char *pszPackFile, size_t cbPackFile);
     
    465479
    466480/** @todo Test tone handling */
    467 int         audioTestPlayTone(PAUDIOTESTENV pTstEnv, PAUDIOTESTSTREAM pStream, PAUDIOTESTTONEPARMS pParms);
    468 /** @}  */
    469 
     481int         audioTestPlayTone(PAUDIOTESTIOOPTS pIoOpts, PAUDIOTESTENV pTstEnv, PAUDIOTESTSTREAM pStream, PAUDIOTESTTONEPARMS pParms);
     482void        audioTestToneParmsInit(PAUDIOTESTTONEPARMS pToneParms);
     483/** @}  */
     484
     485void        audioTestIoOptsInitDefaults(PAUDIOTESTIOOPTS pIoOpts);
    470486
    471487/*********************************************************************************************************************************
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