Changeset 89286 in vbox for trunk/src/VBox/ValidationKit/utils
- Timestamp:
- May 26, 2021 8:23:56 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 144632
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp
r89265 r89286 279 279 { 280 280 VKAT_VERIFY_OPT_TAG = 900 281 }; 282 283 /** 284 * Long option values for the 'selftest' command. 285 */ 286 enum 287 { 288 VKAT_SELFTEST_OPT_ATS_HOST = 900 281 289 }; 282 290 … … 2569 2577 static const RTGETOPTDEF g_aCmdSelftestOptions[] = 2570 2578 { 2579 { "--ats-host", VKAT_SELFTEST_OPT_ATS_HOST, RTGETOPT_REQ_STRING }, 2571 2580 { "--backend", 'b', RTGETOPT_REQ_STRING }, 2572 2581 { "--with-drv-audio", 'd', RTGETOPT_REQ_NOTHING }, … … 2645 2654 * Tests the Audio Test Service (ATS). 2646 2655 * 2656 * @returns VBox status code. 2647 2657 * @param pDrvReg Backend driver to use. 2648 * @returns VBox status code. 2649 */ 2650 static int audioTestDoSelftestSvc(PCPDMDRVREG pDrvReg) 2658 * @param pszAdr Address of ATS server to connect to. 2659 * If NULL, an own (local) ATS server will be created. 2660 */ 2661 static int audioTestDoSelftestAts(PCPDMDRVREG pDrvReg, const char *pszAdr) 2651 2662 { 2652 2663 AUDIOTESTDRVSTACK DrvStack; … … 2654 2665 if (RT_SUCCESS(rc)) 2655 2666 { 2667 /** @todo Make stream parameters configurable. */ 2656 2668 PDMAUDIOPCMPROPS Props; 2657 2669 PDMAudioPropsInit(&Props, 16 /* bit */ / 8, true /* fSigned */, 2 /* Channels */, 44100 /* Hz */); … … 2676 2688 Callbacks.pvUser = &Ctx; 2677 2689 2690 /* Start an own ATS instance if no address to connect was specified. */ 2678 2691 ATSSERVER Srv; 2679 rc = AudioTestSvcInit(&Srv, &Callbacks); 2692 if (pszAdr == NULL) 2693 { 2694 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Starting ATS ...\n"); 2695 2696 rc = AudioTestSvcInit(&Srv, &Callbacks); 2697 if (RT_SUCCESS(rc)) 2698 { 2699 rc = AudioTestSvcStart(&Srv); 2700 if (RT_SUCCESS(rc)) 2701 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "ATS running\n"); 2702 } 2703 } 2704 else 2705 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Connecting to ATS at '%s' ...\n", pszAdr); 2706 2680 2707 if (RT_SUCCESS(rc)) 2681 2708 { 2682 rc = AudioTestSvcStart(&Srv); 2709 ATSCLIENT Conn; 2710 rc = AudioTestSvcClientConnect(&Conn, NULL); 2683 2711 if (RT_SUCCESS(rc)) 2684 2712 { 2685 ATSCLIENT Conn; 2686 rc = AudioTestSvcClientConnect(&Conn, NULL); 2687 if (RT_SUCCESS(rc)) 2688 { 2689 /* Do the bare minimum here to get a test tone out. */ 2690 AUDIOTESTTONEPARMS ToneParms; 2691 RT_ZERO(ToneParms); 2692 ToneParms.msDuration = 2000; 2693 memcpy(&ToneParms.Props, &CfgAcq.Props, sizeof(PDMAUDIOPCMPROPS)); 2694 2695 rc = AudioTestSvcClientTonePlay(&Conn, &CfgAcq, &ToneParms); 2696 2697 int rc2 = AudioTestSvcClientClose(&Conn); 2698 if (RT_SUCCESS(rc)) 2699 rc = rc2; 2700 } 2701 2702 int rc2 = AudioTestSvcShutdown(&Srv); 2713 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Connected to ATS, testing ...\n"); 2714 2715 /* Do the bare minimum here to get a test tone out. */ 2716 AUDIOTESTTONEPARMS ToneParms; 2717 RT_ZERO(ToneParms); 2718 ToneParms.msDuration = RTRandU32Ex(250, 1000 * 5); 2719 memcpy(&ToneParms.Props, &CfgAcq.Props, sizeof(PDMAUDIOPCMPROPS)); 2720 2721 rc = AudioTestSvcClientTonePlay(&Conn, &CfgAcq, &ToneParms); 2722 2723 int rc2 = AudioTestSvcClientClose(&Conn); 2703 2724 if (RT_SUCCESS(rc)) 2704 2725 rc = rc2; 2705 2726 } 2706 2707 int rc2 = AudioTestSvcDestroy(&Srv); 2727 else 2728 RTTestFailed(g_hTest, "Connecting to ATS failed, rc=%Rrc\n", rc); 2729 2730 int rc2 = AudioTestSvcShutdown(&Srv); 2708 2731 if (RT_SUCCESS(rc)) 2709 2732 rc = rc2; 2710 2733 } 2734 2735 if (pszAdr == NULL) 2736 { 2737 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Shutting down ATS ...\n"); 2738 2739 int rc2 = AudioTestSvcDestroy(&Srv); 2740 if (RT_SUCCESS(rc)) 2741 rc = rc2; 2742 } 2711 2743 } 2712 2744 } 2713 2745 } 2714 2746 2747 if (RT_FAILURE(rc)) 2748 RTTestFailed(g_hTest, "Testing ATS failed with %Rrc\n", rc); 2749 2715 2750 return rc; 2716 2751 } … … 2721 2756 * @returns VBox status code. 2722 2757 * @param pDrvReg Backend driver to use. 2723 */ 2724 static int audioTestDoSelftest(PCPDMDRVREG pDrvReg) 2725 { 2726 int rc = audioTestDoSelftestSvc(pDrvReg); 2758 * @param pszAtsAdr Address of ATS server to connect to. 2759 * If NULL, an own (local) ATS server will be created. 2760 */ 2761 static int audioTestDoSelftest(PCPDMDRVREG pDrvReg, const char *pszAtsAdr) 2762 { 2763 int rc = audioTestDoSelftestAts(pDrvReg, pszAtsAdr); 2727 2764 if (RT_FAILURE(rc)) 2728 2765 RTTestFailed(g_hTest, "Self-test failed with: %Rrc", rc); … … 2742 2779 PCPDMDRVREG pDrvReg = g_aBackends[0].pDrvReg; 2743 2780 bool fWithDrvAudio = false; 2781 char *pszAtsAddr = NULL; 2744 2782 2745 2783 /* Argument processing loop: */ … … 2750 2788 switch (rc) 2751 2789 { 2790 case VKAT_SELFTEST_OPT_ATS_HOST: 2791 { 2792 pszAtsAddr = RTStrDup(ValueUnion.psz); 2793 break; 2794 } 2795 2752 2796 case 'b': 2797 { 2753 2798 pDrvReg = NULL; 2754 2799 for (uintptr_t i = 0; i < RT_ELEMENTS(g_aBackends); i++) … … 2762 2807 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unknown backend: '%s'", ValueUnion.psz); 2763 2808 break; 2809 } 2764 2810 2765 2811 case 'd': 2812 { 2766 2813 fWithDrvAudio = true; 2767 2814 break; 2815 } 2768 2816 2769 2817 case VINF_GETOPT_NOT_OPTION: … … 2779 2827 } 2780 2828 2781 audioTestDoSelftest(pDrvReg); 2782 /* 2829 audioTestDoSelftest(pDrvReg, pszAtsAddr); 2830 2831 RTStrFree(pszAtsAddr); 2832 2833 /* 2783 2834 * Print summary and exit. 2784 2835 */
Note:
See TracChangeset
for help on using the changeset viewer.