Changeset 89226 in vbox
- Timestamp:
- May 21, 2021 3:02:10 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 144569
- Location:
- trunk/src/VBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioTestService.cpp
r89225 r89226 536 536 return atsReplyInvalidState(pThis, pClient, pPktHdr); 537 537 538 if (!pThis->Callbacks.pfnTonePlay) 539 return atsReplyRC(pThis, pClient, pPktHdr, VERR_NOT_SUPPORTED, "Playing tones not supported"); 540 541 PATSPKTREQTONEPLAY pReq = (PATSPKTREQTONEPLAY)pPktHdr; 542 rc = pThis->Callbacks.pfnTonePlay(pThis->Callbacks.pvUser, &pReq->StreamCfg, &pReq->ToneParms); 543 544 int rc2 = atsReplyAck(pThis, pClient, pPktHdr); 545 if (RT_SUCCESS(rc)) 546 rc = rc2; 547 538 548 return rc; 539 549 } … … 564 574 else if (atsIsSameOpcode(pPktHdr, ATSPKT_OPCODE_BYE)) 565 575 rc = atsDoBye(pThis, pClient, pPktHdr); 566 /* Gadget API.*/576 /* Audio testing: */ 567 577 else if (atsIsSameOpcode(pPktHdr, ATSPKT_OPCODE_TONE_PLAY)) 568 578 rc = atsDoTonePlay(pThis, pClient, pPktHdr); … … 762 772 * @param pThis The ATS instance. 763 773 * */ 764 int AudioTestSvcInit(PATSSERVER pThis) 765 { 774 int AudioTestSvcInit(PATSSERVER pThis, PCATSCALLBACKS pCallbacks) 775 { 776 memcpy(&pThis->Callbacks, pCallbacks, sizeof(ATSCALLBACKS)); 777 766 778 pThis->fStarted = false; 767 779 pThis->fTerminate = false; -
trunk/src/VBox/Devices/Audio/AudioTestService.h
r89225 r89226 26 26 27 27 /** 28 * Structure for keeping an Audio Test Server (ATS) callback table. 29 */ 30 typedef struct ATSCALLBACKS 31 { 32 /** 33 * Plays a test tone. 34 * 35 * @returns VBox status code. 36 * @param pvUser User-supplied pointer to context data. Optional. 37 * @param pStreamCfg Audio stream configuration to use for stream to play tone on. 38 * @param pToneParms Tone parameters to use for playback. 39 */ 40 DECLR3CALLBACKMEMBER(int, pfnTonePlay, (void const *pvUser, PPDMAUDIOSTREAMCFG pStreamCfg, PAUDIOTESTTONEPARMS pToneParms)); 41 /** Pointer to opaque user-provided context data. */ 42 void const *pvUser; 43 } ATSCALLBACKS; 44 /** Pointer to a const ATS callbacks table. */ 45 typedef const struct ATSCALLBACKS *PCATSCALLBACKS; 46 47 /** 28 48 * Structure for keeping an Audio Test Server (ATS) instance. 29 49 */ … … 32 52 /** The selected transport layer. */ 33 53 PCATSTRANSPORT pTransport; 54 /** The callbacks table. */ 55 ATSCALLBACKS Callbacks; 34 56 /** Whether server is in started state or not. */ 35 57 bool volatile fStarted; … … 55 77 56 78 57 int AudioTestSvcInit(PATSSERVER pThis );79 int AudioTestSvcInit(PATSSERVER pThis, PCATSCALLBACKS pCallbacks); 58 80 int AudioTestSvcDestroy(PATSSERVER pThis); 59 81 int AudioTestSvcStart(PATSSERVER pThis); -
trunk/src/VBox/Devices/Audio/AudioTestServiceClient.cpp
r89215 r89226 227 227 } 228 228 229 int AudioTestSvcClientTonePlay(PATSCLIENT pClient, PPDMAUDIOSTREAMCFG pStreamCfg, PAUDIOTESTTONEPARMS pToneParms) 230 { 231 ATSPKTREQTONEPLAY Req; 232 233 memcpy(&Req.StreamCfg, pStreamCfg, sizeof(PDMAUDIOSTREAMCFG)); 234 memcpy(&Req.ToneParms, pToneParms, sizeof(AUDIOTESTTONEPARMS)); 235 236 audioTestSvcClientReqHdrInit(&Req.Hdr, sizeof(Req), ATSPKT_OPCODE_TONE_PLAY, 0); 237 238 int rc = audioTestSvcClientSendMsg(pClient, &Req, sizeof(Req), NULL, 0); 239 if (RT_SUCCESS(rc)) 240 rc = audioTestSvcClientRecvAck(pClient); 241 242 return rc; 243 } 244 229 245 int AudioTestSvcClientClose(PATSCLIENT pClient) 230 246 { -
trunk/src/VBox/Devices/Audio/AudioTestServiceClient.h
r89215 r89226 31 31 32 32 int AudioTestSvcClientConnect(PATSCLIENT pClient, const char *pszAddr); 33 int AudioTestSvcClientTonePlay(PATSCLIENT pClient, PPDMAUDIOSTREAMCFG pStreamCfg, PAUDIOTESTTONEPARMS pToneParms); 33 34 int AudioTestSvcClientClose(PATSCLIENT pClient); 34 35 -
trunk/src/VBox/Devices/Audio/AudioTestServiceProtocol.h
r89215 r89226 130 130 /** Embedded packet header. */ 131 131 ATSPKTHDR Hdr; 132 AUDIOTESTTONEPARMS Parms; 133 uint8_t au8Padding[8]; 132 /** Stream configuration to use for playing the tone. 133 * Note: Depending on the actual implementation this configuration might or might not be available / supported. */ 134 PDMAUDIOSTREAMCFG StreamCfg; 135 /** Test tone parameters for playback. */ 136 AUDIOTESTTONEPARMS ToneParms; 134 137 } ATSPKTREQTONEPLAY; 135 138 AssertCompileSizeAlignment(ATSPKTREQTONEPLAY, ATSPKT_ALIGNMENT); -
trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp
r89225 r89226 2484 2484 2485 2485 /** 2486 * Structure for keeping a user context for the test service callbacks. 2487 */ 2488 typedef struct ATSCALLBACKCTX 2489 { 2490 /** Driver stack to use. */ 2491 PAUDIOTESTDRVSTACK pDrvStack; 2492 /** Audio stream to use. */ 2493 PPDMAUDIOSTREAM pStream; 2494 } ATSCALLBACKCTX; 2495 typedef ATSCALLBACKCTX *PATSCALLBACKCTX; 2496 2497 /** 2498 * Note: Called within server (client serving) thread. 2499 */ 2500 static DECLCALLBACK(int) audioTestSvcTonePlayCallback(void const *pvUser, PPDMAUDIOSTREAMCFG pStreamCfg, PAUDIOTESTTONEPARMS pToneParms) 2501 { 2502 PATSCALLBACKCTX pCtx = (PATSCALLBACKCTX)pvUser; 2503 2504 AUDIOTESTTONE TstTone; 2505 AudioTestToneInitRandom(&TstTone, &pStreamCfg->Props); 2506 2507 int rc; 2508 2509 if (audioTestDriverStackStreamIsOkay(pCtx->pDrvStack, pCtx->pStream)) 2510 { 2511 uint32_t cbBuf; 2512 uint8_t abBuf[_4K]; 2513 2514 const uint64_t tsStartMs = RTTimeMilliTS(); 2515 const uint16_t cSchedulingMs = RTRandU32Ex(10, 80); /* Chose a random scheduling (in ms). */ 2516 const uint32_t cbPerMs = PDMAudioPropsMilliToBytes(&pCtx->pStream->Props, cSchedulingMs); 2517 2518 do 2519 { 2520 rc = AudioTestToneGenerate(&TstTone, abBuf, RT_MIN(cbPerMs, sizeof(abBuf)), &cbBuf); 2521 if (RT_SUCCESS(rc)) 2522 { 2523 uint32_t cbWritten; 2524 rc = audioTestDriverStackStreamPlay(pCtx->pDrvStack, pCtx->pStream, abBuf, cbBuf, &cbWritten); 2525 } 2526 2527 if (RTTimeMilliTS() - tsStartMs >= pToneParms->msDuration) 2528 break; 2529 2530 if (RT_FAILURE(rc)) 2531 break; 2532 2533 RTThreadSleep(cSchedulingMs); 2534 2535 } while (RT_SUCCESS(rc)); 2536 } 2537 else 2538 rc = VERR_AUDIO_STREAM_NOT_READY; 2539 2540 return rc; 2541 } 2542 2543 /** 2486 2544 * Tests the Audio Test Service (ATS). 2487 2545 * 2546 * @param pDrvReg Backend driver to use. 2488 2547 * @returns VBox status code. 2489 2548 */ 2490 static int audioTestDoSelftestSvc( void)2491 { 2492 A TSSERVER Srv;2493 int rc = AudioTestSvcInit(&Srv);2549 static int audioTestDoSelftestSvc(PCPDMDRVREG pDrvReg) 2550 { 2551 AUDIOTESTDRVSTACK DrvStack; 2552 int rc = audioTestDriverStackInit(&DrvStack, pDrvReg, true /* fWithDrvAudio */); 2494 2553 if (RT_SUCCESS(rc)) 2495 2554 { 2496 rc = AudioTestSvcStart(&Srv); 2555 PDMAUDIOPCMPROPS Props; 2556 PDMAudioPropsInit(&Props, 16 /* bit */ / 8, true /* fSigned */, 2 /* Channels */, 44100 /* Hz */); 2557 2558 PDMAUDIOSTREAMCFG CfgAcq; 2559 PPDMAUDIOSTREAM pStream = NULL; 2560 rc = audioTestDriverStackStreamCreateOutput(&DrvStack, &Props, 2561 UINT32_MAX /* cMsBufferSize */, 2562 UINT32_MAX /* cMsPreBuffer */, 2563 UINT32_MAX /* cMsSchedulingHint */, &pStream, &CfgAcq); 2497 2564 if (RT_SUCCESS(rc)) 2498 2565 { 2499 ATSCLIENT Conn; 2500 rc = AudioTestSvcClientConnect(&Conn, NULL); 2566 rc = audioTestDriverStackStreamEnable(&DrvStack, pStream); 2501 2567 if (RT_SUCCESS(rc)) 2502 2568 { 2503 rc = AudioTestSvcClientClose(&Conn); 2569 ATSCALLBACKCTX Ctx; 2570 Ctx.pDrvStack = &DrvStack; 2571 Ctx.pStream = pStream; 2572 2573 ATSCALLBACKS Callbacks; 2574 Callbacks.pfnTonePlay = audioTestSvcTonePlayCallback; 2575 Callbacks.pvUser = &Ctx; 2576 2577 ATSSERVER Srv; 2578 rc = AudioTestSvcInit(&Srv, &Callbacks); 2579 if (RT_SUCCESS(rc)) 2580 { 2581 rc = AudioTestSvcStart(&Srv); 2582 if (RT_SUCCESS(rc)) 2583 { 2584 ATSCLIENT Conn; 2585 rc = AudioTestSvcClientConnect(&Conn, NULL); 2586 if (RT_SUCCESS(rc)) 2587 { 2588 /* Do the bare minimum here to get a test tone out. */ 2589 AUDIOTESTTONEPARMS ToneParms = { 0 }; 2590 ToneParms.msDuration = 2000; 2591 memcpy(&ToneParms.Props, &CfgAcq.Props, sizeof(PDMAUDIOPCMPROPS)); 2592 2593 rc = AudioTestSvcClientTonePlay(&Conn, &CfgAcq, &ToneParms); 2594 2595 int rc2 = AudioTestSvcClientClose(&Conn); 2596 if (RT_SUCCESS(rc)) 2597 rc = rc2; 2598 } 2599 2600 int rc2 = AudioTestSvcShutdown(&Srv); 2601 if (RT_SUCCESS(rc)) 2602 rc = rc2; 2603 } 2604 2605 int rc2 = AudioTestSvcDestroy(&Srv); 2606 if (RT_SUCCESS(rc)) 2607 rc = rc2; 2608 } 2504 2609 } 2505 2506 int rc2 = AudioTestSvcShutdown(&Srv);2507 if (RT_SUCCESS(rc))2508 rc = rc2;2509 2610 } 2510 2511 int rc2 = AudioTestSvcDestroy(&Srv);2512 if (RT_SUCCESS(rc))2513 rc = rc2;2514 2611 } 2515 2612 … … 2521 2618 * 2522 2619 * @returns VBox status code. 2523 */ 2524 static int audioTestDoSelftest(void) 2525 { 2526 int rc = audioTestDoSelftestSvc(); 2620 * @param pDrvReg Backend driver to use. 2621 */ 2622 static int audioTestDoSelftest(PCPDMDRVREG pDrvReg) 2623 { 2624 int rc = audioTestDoSelftestSvc(pDrvReg); 2527 2625 if (RT_FAILURE(rc)) 2528 2626 RTTestFailed(g_hTest, "Self-test failed with: %Rrc", rc); … … 2579 2677 } 2580 2678 2581 audioTestDoSelftest( );2679 audioTestDoSelftest(pDrvReg); 2582 2680 /* 2583 2681 * Print summary and exit.
Note:
See TracChangeset
for help on using the changeset viewer.