Changeset 89422 in vbox for trunk/src/VBox
- Timestamp:
- Jun 1, 2021 10:13:34 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostAudioPulseAudioStubs.cpp
r88478 r89422 24 24 #include <iprt/ldr.h> 25 25 #include <VBox/log.h> 26 #include <iprt/once.h> 26 27 #include <iprt/err.h> 27 28 … … 322 323 #undef FUNC_ENTRY 323 324 324 /** 325 * Try to dynamically load the PulseAudio libraries. This function is not 326 * thread-safe, and should be called before attempting to use any of the 327 * PulseAudio functions. 328 * 329 * @returns iprt status code 330 */ 331 int audioLoadPulseLib(void) 325 /** Init once. */ 326 static RTONCE g_PulseAudioInitOnce = RTONCE_INITIALIZER; 327 328 /** @callback_method_impl{FNRTONCE} */ 329 static DECLCALLBACK(int32_t) drvHostAudioPusleInitOnce(void *pvUser) 332 330 { 333 static volatile int g_rc = VERR_IPE_UNINITIALIZED_STATUS; 334 RTLDRMOD hLib; 335 int rc; 336 331 RT_NOREF(pvUser); 337 332 LogFlowFunc(("\n")); 338 333 339 /* If this is not VERR_IPE_UNINITIALIZED_STATUS then the function has 340 obviously been called twice, which is likely to be a bug. */ 341 rc = g_rc; 342 AssertMsgReturn(rc == VERR_IPE_UNINITIALIZED_STATUS, ("g_rc=%Rrc\n", rc), rc); 343 344 rc = RTLdrLoadSystemEx(VBOX_PULSE_LIB, RTLDRLOAD_FLAGS_NO_UNLOAD, &hLib); 334 RTLDRMOD hLib = NIL_RTLDRMOD; 335 int rc = RTLdrLoadSystemEx(VBOX_PULSE_LIB, RTLDRLOAD_FLAGS_NO_UNLOAD, &hLib); 345 336 if (RT_SUCCESS(rc)) 346 337 { 347 unsigned i; 348 for (i = 0; i < RT_ELEMENTS(g_aImportedFunctions); i++) 338 for (unsigned i = 0; i < RT_ELEMENTS(g_aImportedFunctions); i++) 349 339 { 350 340 rc = RTLdrGetSymbol(hLib, g_aImportedFunctions[i].pszName, (void **)g_aImportedFunctions[i].pfn); … … 358 348 else 359 349 LogRelFunc(("Failed to load library %s: %Rrc\n", VBOX_PULSE_LIB, rc)); 360 g_rc = rc;361 350 return rc; 362 351 } 363 352 353 /** 354 * Try to dynamically load the PulseAudio libraries. 355 * 356 * @returns VBox status code 357 */ 358 int audioLoadPulseLib(void) 359 { 360 LogFlowFunc(("\n")); 361 return RTOnce(&g_PulseAudioInitOnce, drvHostAudioPusleInitOnce, NULL); 362 } 363
Note:
See TracChangeset
for help on using the changeset viewer.