Changeset 91571 in vbox for trunk/src/VBox
- Timestamp:
- Oct 5, 2021 3:37:20 PM (3 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostAudioAlsaStubs.cpp
r89471 r91571 187 187 PROXY_STUB(snd_pcm_sw_params_sizeof, size_t, (void), ()) 188 188 189 /* 190 * Mixer 191 */ 192 193 PROXY_STUB(snd_mixer_selem_id_sizeof, size_t, 194 (void), ()) 195 PROXY_STUB(snd_mixer_open, int, 196 (snd_mixer_t **mixer, int mode), 197 (mixer, mode)) 198 PROXY_STUB(snd_mixer_attach, int, 199 (snd_mixer_t *mixer, const char *name), 200 (mixer, name)) 201 PROXY_STUB(snd_mixer_close, int, 202 (snd_mixer_t *mixer), 203 (mixer)) 204 PROXY_STUB(snd_mixer_selem_id_set_index, void, 205 (snd_mixer_selem_id_t *obj, unsigned int val), 206 (obj, val)) 207 PROXY_STUB(snd_mixer_selem_id_set_name, void, 208 (snd_mixer_selem_id_t *obj, const char *val), 209 (obj, val)) 210 PROXY_STUB(snd_mixer_selem_set_playback_volume, int, 211 (snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, long value), 212 (elem, channel, value)) 213 PROXY_STUB(snd_mixer_selem_get_playback_volume_range, int, 214 (snd_mixer_elem_t *elem, long *min, long *max), 215 (elem, min, max)) 216 PROXY_STUB(snd_mixer_selem_set_capture_volume, int, 217 (snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, long value), 218 (elem, channel, value)) 219 PROXY_STUB(snd_mixer_selem_get_capture_volume_range, int, 220 (snd_mixer_elem_t *elem, long *min, long *max), 221 (elem, min, max)) 222 PROXY_STUB(snd_mixer_selem_register, int, 223 (snd_mixer_t *mixer, snd_mixer_selem_regopt *options, snd_mixer_class_t **classp), 224 (mixer, options, classp)) 225 PROXY_STUB(snd_mixer_load, int, 226 (snd_mixer_t *mixer), 227 (mixer)) 228 PROXY_STUB(snd_mixer_find_selem, snd_mixer_elem_t *, 229 (snd_mixer_t *mixer, const snd_mixer_selem_id_t *id), 230 (mixer, id)) 231 189 232 typedef struct 190 233 { … … 245 288 ELEMENT(snd_pcm_sw_params_set_start_threshold), 246 289 ELEMENT(snd_pcm_sw_params_sizeof), 290 291 ELEMENT(snd_mixer_selem_id_sizeof), 292 ELEMENT(snd_mixer_open), 293 ELEMENT(snd_mixer_attach), 294 ELEMENT(snd_mixer_close), 295 ELEMENT(snd_mixer_selem_id_set_index), 296 ELEMENT(snd_mixer_selem_id_set_name), 297 ELEMENT(snd_mixer_selem_set_playback_volume), 298 ELEMENT(snd_mixer_selem_get_playback_volume_range), 299 ELEMENT(snd_mixer_selem_set_capture_volume), 300 ELEMENT(snd_mixer_selem_get_capture_volume_range), 301 ELEMENT(snd_mixer_selem_register), 302 ELEMENT(snd_mixer_load), 303 ELEMENT(snd_mixer_find_selem), 304 247 305 }; 248 306 #undef ELEMENT -
trunk/src/VBox/Devices/Audio/DrvHostAudioAlsaStubsMangling.h
r89471 r91571 26 26 #define ALSA_MANGLER(symbol) VBox_##symbol 27 27 28 #define snd_lib_error_set_handler ALSA_MANGLER(snd_lib_error_set_handler)29 #define snd_strerror ALSA_MANGLER(snd_strerror)28 #define snd_lib_error_set_handler ALSA_MANGLER(snd_lib_error_set_handler) 29 #define snd_strerror ALSA_MANGLER(snd_strerror) 30 30 31 #define snd_device_name_hint ALSA_MANGLER(snd_device_name_hint)32 #define snd_device_name_get_hint ALSA_MANGLER(snd_device_name_get_hint)33 #define snd_device_name_free_hint ALSA_MANGLER(snd_device_name_free_hint)31 #define snd_device_name_hint ALSA_MANGLER(snd_device_name_hint) 32 #define snd_device_name_get_hint ALSA_MANGLER(snd_device_name_get_hint) 33 #define snd_device_name_free_hint ALSA_MANGLER(snd_device_name_free_hint) 34 34 35 #define snd_pcm_avail_update ALSA_MANGLER(snd_pcm_avail_update)36 #define snd_pcm_close ALSA_MANGLER(snd_pcm_close)37 #define snd_pcm_avail_delay ALSA_MANGLER(snd_pcm_avail_delay)38 #define snd_pcm_delay ALSA_MANGLER(snd_pcm_delay)39 #define snd_pcm_drain ALSA_MANGLER(snd_pcm_drain)40 #define snd_pcm_drop ALSA_MANGLER(snd_pcm_drop)41 #define snd_pcm_nonblock ALSA_MANGLER(snd_pcm_nonblock)42 #define snd_pcm_open ALSA_MANGLER(snd_pcm_open)43 #define snd_pcm_prepare ALSA_MANGLER(snd_pcm_prepare)44 #define snd_pcm_readi ALSA_MANGLER(snd_pcm_readi)45 #define snd_pcm_resume ALSA_MANGLER(snd_pcm_resume)46 #define snd_pcm_set_chmap ALSA_MANGLER(snd_pcm_set_chmap)47 #define snd_pcm_start ALSA_MANGLER(snd_pcm_start)48 #define snd_pcm_state ALSA_MANGLER(snd_pcm_state)49 #define snd_pcm_state_name ALSA_MANGLER(snd_pcm_state_name)50 #define snd_pcm_writei ALSA_MANGLER(snd_pcm_writei)35 #define snd_pcm_avail_update ALSA_MANGLER(snd_pcm_avail_update) 36 #define snd_pcm_close ALSA_MANGLER(snd_pcm_close) 37 #define snd_pcm_avail_delay ALSA_MANGLER(snd_pcm_avail_delay) 38 #define snd_pcm_delay ALSA_MANGLER(snd_pcm_delay) 39 #define snd_pcm_drain ALSA_MANGLER(snd_pcm_drain) 40 #define snd_pcm_drop ALSA_MANGLER(snd_pcm_drop) 41 #define snd_pcm_nonblock ALSA_MANGLER(snd_pcm_nonblock) 42 #define snd_pcm_open ALSA_MANGLER(snd_pcm_open) 43 #define snd_pcm_prepare ALSA_MANGLER(snd_pcm_prepare) 44 #define snd_pcm_readi ALSA_MANGLER(snd_pcm_readi) 45 #define snd_pcm_resume ALSA_MANGLER(snd_pcm_resume) 46 #define snd_pcm_set_chmap ALSA_MANGLER(snd_pcm_set_chmap) 47 #define snd_pcm_start ALSA_MANGLER(snd_pcm_start) 48 #define snd_pcm_state ALSA_MANGLER(snd_pcm_state) 49 #define snd_pcm_state_name ALSA_MANGLER(snd_pcm_state_name) 50 #define snd_pcm_writei ALSA_MANGLER(snd_pcm_writei) 51 51 52 #define snd_pcm_hw_params ALSA_MANGLER(snd_pcm_hw_params)53 #define snd_pcm_hw_params_any ALSA_MANGLER(snd_pcm_hw_params_any)54 #define snd_pcm_hw_params_sizeof ALSA_MANGLER(snd_pcm_hw_params_sizeof)55 #define snd_pcm_hw_params_get_buffer_size ALSA_MANGLER(snd_pcm_hw_params_get_buffer_size)56 #define snd_pcm_hw_params_get_period_size_min ALSA_MANGLER(snd_pcm_hw_params_get_period_size_min)57 #define snd_pcm_hw_params_set_rate_near ALSA_MANGLER(snd_pcm_hw_params_set_rate_near)58 #define snd_pcm_hw_params_set_access ALSA_MANGLER(snd_pcm_hw_params_set_access)59 #define snd_pcm_hw_params_set_buffer_time_near ALSA_MANGLER(snd_pcm_hw_params_set_buffer_time_near)60 #define snd_pcm_hw_params_set_buffer_size_near ALSA_MANGLER(snd_pcm_hw_params_set_buffer_size_near)61 #define snd_pcm_hw_params_get_buffer_size_min ALSA_MANGLER(snd_pcm_hw_params_get_buffer_size_min)62 #define snd_pcm_hw_params_set_channels_near ALSA_MANGLER(snd_pcm_hw_params_set_channels_near)63 #define snd_pcm_hw_params_set_format ALSA_MANGLER(snd_pcm_hw_params_set_format)64 #define snd_pcm_hw_params_get_period_size ALSA_MANGLER(snd_pcm_hw_params_get_period_size)65 #define snd_pcm_hw_params_set_period_size_near ALSA_MANGLER(snd_pcm_hw_params_set_period_size_near)66 #define snd_pcm_hw_params_set_period_time_near ALSA_MANGLER(snd_pcm_hw_params_set_period_time_near)52 #define snd_pcm_hw_params ALSA_MANGLER(snd_pcm_hw_params) 53 #define snd_pcm_hw_params_any ALSA_MANGLER(snd_pcm_hw_params_any) 54 #define snd_pcm_hw_params_sizeof ALSA_MANGLER(snd_pcm_hw_params_sizeof) 55 #define snd_pcm_hw_params_get_buffer_size ALSA_MANGLER(snd_pcm_hw_params_get_buffer_size) 56 #define snd_pcm_hw_params_get_period_size_min ALSA_MANGLER(snd_pcm_hw_params_get_period_size_min) 57 #define snd_pcm_hw_params_set_rate_near ALSA_MANGLER(snd_pcm_hw_params_set_rate_near) 58 #define snd_pcm_hw_params_set_access ALSA_MANGLER(snd_pcm_hw_params_set_access) 59 #define snd_pcm_hw_params_set_buffer_time_near ALSA_MANGLER(snd_pcm_hw_params_set_buffer_time_near) 60 #define snd_pcm_hw_params_set_buffer_size_near ALSA_MANGLER(snd_pcm_hw_params_set_buffer_size_near) 61 #define snd_pcm_hw_params_get_buffer_size_min ALSA_MANGLER(snd_pcm_hw_params_get_buffer_size_min) 62 #define snd_pcm_hw_params_set_channels_near ALSA_MANGLER(snd_pcm_hw_params_set_channels_near) 63 #define snd_pcm_hw_params_set_format ALSA_MANGLER(snd_pcm_hw_params_set_format) 64 #define snd_pcm_hw_params_get_period_size ALSA_MANGLER(snd_pcm_hw_params_get_period_size) 65 #define snd_pcm_hw_params_set_period_size_near ALSA_MANGLER(snd_pcm_hw_params_set_period_size_near) 66 #define snd_pcm_hw_params_set_period_time_near ALSA_MANGLER(snd_pcm_hw_params_set_period_time_near) 67 67 68 #define snd_pcm_sw_params ALSA_MANGLER(snd_pcm_sw_params) 69 #define snd_pcm_sw_params_current ALSA_MANGLER(snd_pcm_sw_params_current) 70 #define snd_pcm_sw_params_get_start_threshold ALSA_MANGLER(snd_pcm_sw_params_get_start_threshold) 71 #define snd_pcm_sw_params_set_avail_min ALSA_MANGLER(snd_pcm_sw_params_set_avail_min) 72 #define snd_pcm_sw_params_set_start_threshold ALSA_MANGLER(snd_pcm_sw_params_set_start_threshold) 73 #define snd_pcm_sw_params_sizeof ALSA_MANGLER(snd_pcm_sw_params_sizeof) 68 #define snd_pcm_sw_params ALSA_MANGLER(snd_pcm_sw_params) 69 #define snd_pcm_sw_params_current ALSA_MANGLER(snd_pcm_sw_params_current) 70 #define snd_pcm_sw_params_get_start_threshold ALSA_MANGLER(snd_pcm_sw_params_get_start_threshold) 71 #define snd_pcm_sw_params_set_avail_min ALSA_MANGLER(snd_pcm_sw_params_set_avail_min) 72 #define snd_pcm_sw_params_set_start_threshold ALSA_MANGLER(snd_pcm_sw_params_set_start_threshold) 73 #define snd_pcm_sw_params_sizeof ALSA_MANGLER(snd_pcm_sw_params_sizeof) 74 75 #define snd_mixer_selem_id_sizeof ALSA_MANGLER(snd_mixer_selem_id_sizeof) 76 #define snd_mixer_open ALSA_MANGLER(snd_mixer_open) 77 #define snd_mixer_attach ALSA_MANGLER(snd_mixer_attach) 78 #define snd_mixer_close ALSA_MANGLER(snd_mixer_close) 79 #define snd_mixer_selem_id_set_index ALSA_MANGLER(snd_mixer_selem_id_set_index) 80 #define snd_mixer_selem_id_set_name ALSA_MANGLER(snd_mixer_selem_id_set_name) 81 #define snd_mixer_selem_set_playback_volume ALSA_MANGLER(snd_mixer_selem_set_playback_volume) 82 #define snd_mixer_selem_get_playback_volume_range ALSA_MANGLER(snd_mixer_selem_get_playback_volume_range) 83 #define snd_mixer_selem_set_capture_volume ALSA_MANGLER(snd_mixer_selem_set_capture_volume) 84 #define snd_mixer_selem_get_capture_volume_range ALSA_MANGLER(snd_mixer_selem_get_capture_volume_range) 85 #define snd_mixer_selem_register ALSA_MANGLER(snd_mixer_selem_register) 86 #define snd_mixer_load ALSA_MANGLER(snd_mixer_load) 87 #define snd_mixer_find_selem ALSA_MANGLER(snd_mixer_find_selem) 74 88 75 89 #endif /* !VBOX_INCLUDED_SRC_Audio_DrvHostAudioAlsaStubsMangling_h */ -
trunk/src/VBox/ValidationKit/utils/audio/Makefile.kmk
r91454 r91571 77 77 vkat_INCS = \ 78 78 $(PATH_ROOT)/src/VBox/Devices/build \ 79 $(PATH_ROOT)/src/VBox/Devices 79 $(PATH_ROOT)/src/VBox/Devices \ 80 $(PATH_ROOT)/src/VBox/Devices/Audio 80 81 vkat_SOURCES = \ 81 82 vkat.cpp \ -
trunk/src/VBox/ValidationKit/utils/audio/vkatCommon.cpp
r91570 r91571 32 32 #include <iprt/log.h> 33 33 34 #ifdef VBOX_WITH_AUDIO_ALSA 35 # include "DrvHostAudioAlsaStubsMangling.h" 36 # include <alsa/asoundlib.h> 37 # include <alsa/control.h> /* For device enumeration. */ 38 # include <alsa/version.h> 39 # include "DrvHostAudioAlsaStubs.h" 40 #endif 41 34 42 #include <iprt/ctype.h> 35 43 #include <iprt/dir.h> … … 59 67 static int audioTestStreamDestroy(PAUDIOTESTENV pTstEnv, PAUDIOTESTSTREAM pStream); 60 68 69 70 /********************************************************************************************************************************* 71 * Volume handling. * 72 *********************************************************************************************************************************/ 73 74 /** 75 * Sets the system's master volume, if available. 76 * 77 * @returns VBox status code. VERR_NOT_SUPPORTED if not supported. 78 * @param uPercentVol Volume (in percent) to set. 79 */ 80 int audioTestSetMasterVolume(unsigned uPercentVol) 81 { 82 #ifdef VBOX_WITH_AUDIO_ALSA 83 int rc = audioLoadAlsaLib(); 84 if (RT_FAILURE(rc)) 85 return rc; 86 87 int err; 88 snd_mixer_t *handle; 89 90 # define ALSA_CHECK_RET(a_Exp, a_Text) \ 91 if (!(a_Exp)) \ 92 { \ 93 AssertLogRelMsg(a_Exp, a_Text); \ 94 if (handle) \ 95 snd_mixer_close(handle); \ 96 return VERR_GENERAL_FAILURE; \ 97 } 98 99 # define ALSA_CHECK_ERR_RET(a_Text) \ 100 ALSA_CHECK_RET(err >= 0, a_Text) 101 102 err = snd_mixer_open(&handle, 0 /* Index */); 103 ALSA_CHECK_ERR_RET(("ALSA: Failed to open mixer: %s\n", snd_strerror(err))); 104 err = snd_mixer_attach(handle, "default"); 105 ALSA_CHECK_ERR_RET(("ALSA: Failed to attach to default sink: %s\n", snd_strerror(err))); 106 err = snd_mixer_selem_register(handle, NULL, NULL); 107 ALSA_CHECK_ERR_RET(("ALSA: Failed to attach to default sink: %s\n", snd_strerror(err))); 108 err = snd_mixer_load(handle); 109 ALSA_CHECK_ERR_RET(("ALSA: Failed to load mixer: %s\n", snd_strerror(err))); 110 111 snd_mixer_selem_id_t *sid = NULL; 112 snd_mixer_selem_id_alloca(&sid); 113 114 snd_mixer_selem_id_set_index(sid, 0 /* Index */); 115 snd_mixer_selem_id_set_name(sid, "Master"); 116 117 snd_mixer_elem_t* elem = snd_mixer_find_selem(handle, sid); 118 ALSA_CHECK_RET(elem != NULL, ("ALSA: Failed to find mixer element: %s\n", snd_strerror(err))); 119 120 long uVolMin, uVolMax; 121 122 snd_mixer_selem_get_playback_volume_range(elem, &uVolMin, &uVolMax); 123 ALSA_CHECK_ERR_RET(("ALSA: Failed to get playback volume range: %s\n", snd_strerror(err))); 124 125 long const uVol = RT_MIN(uPercentVol, 100) * uVolMax / 100; 126 127 err = snd_mixer_selem_set_playback_volume(elem, SND_MIXER_SCHN_FRONT_LEFT, uVol); 128 ALSA_CHECK_ERR_RET(("ALSA: Failed to set playback volume left: %s\n", snd_strerror(err))); 129 err = snd_mixer_selem_set_playback_volume(elem, SND_MIXER_SCHN_FRONT_RIGHT, uVol); 130 ALSA_CHECK_ERR_RET(("ALSA: Failed to set playback volume right: %s\n", snd_strerror(err))); 131 132 snd_mixer_close(handle); 133 134 return VINF_SUCCESS; 135 136 # undef ALSA_CHECK_RET 137 # undef ALSA_CHECK_ERR_RET 138 139 #endif /* VBOX_WITH_AUDIO_ALSA */ 140 141 /** @todo Port other platforms. */ 142 return VERR_NOT_SUPPORTED; 143 } 61 144 62 145 /********************************************************************************************************************************* … … 256 339 AssertRCReturn(rc, rc); 257 340 } 341 342 /* 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. 343 * Not supported on all platforms yet, therefore not critical for overall testing (yet). */ 344 unsigned const uVolPercent = 100; 345 int rc2 = audioTestSetMasterVolume(uVolPercent); 346 if (RT_FAILURE(rc2)) 347 { 348 if (rc2 == VERR_NOT_SUPPORTED) 349 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Setting system's master volume is not supported on this platform, skipping\n"); 350 else 351 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Setting system's master volume failed with %Rrc\n", rc2); 352 } 353 else 354 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Set system's master volume to %RU8%%\n", uVolPercent); 258 355 259 356 rc = AudioTestMixStreamEnable(&pStream->Mix); … … 426 523 if (pTstEnv) 427 524 { 428 intrc2 = AudioTestObjClose(Obj);525 rc2 = AudioTestObjClose(Obj); 429 526 if (RT_SUCCESS(rc)) 430 527 rc = rc2;
Note:
See TracChangeset
for help on using the changeset viewer.