diff --git a/media/libcubeb/README_MOZILLA b/media/libcubeb/README_MOZILLA index 14102c8ce9a5..833914b8015a 100644 --- a/media/libcubeb/README_MOZILLA +++ b/media/libcubeb/README_MOZILLA @@ -5,4 +5,4 @@ Makefile.in build files for the Mozilla build system. The cubeb git repository is: git://github.com/kinetiknz/cubeb.git -The git commit ID used was 0677b3027b78c629586b099b5155aa6ac7422674 (2018-06-12 08:48:55 -0700) +The git commit ID used was 2968cba6474822535275225e4583c67c6aaaf2ae (2018-06-26 10:58:56 +0200) diff --git a/media/libcubeb/src/cubeb_audiounit.cpp b/media/libcubeb/src/cubeb_audiounit.cpp index a9ea6a220289..6163ed72ad74 100644 --- a/media/libcubeb/src/cubeb_audiounit.cpp +++ b/media/libcubeb/src/cubeb_audiounit.cpp @@ -2585,6 +2585,8 @@ cubeb_stream::cubeb_stream(cubeb * context) PodZero(&output_desc, 1); } +static void audiounit_stream_destroy_internal(cubeb_stream * stm); + static int audiounit_stream_init(cubeb * context, cubeb_stream ** stream, @@ -2602,14 +2604,10 @@ audiounit_stream_init(cubeb * context, auto_lock context_lock(context->mutex); audiounit_increment_active_streams(context); unique_ptr stm(new cubeb_stream(context), - audiounit_stream_destroy); + audiounit_stream_destroy_internal); int r; *stream = NULL; assert(latency_frames > 0); - if ((input_device && !input_stream_params) || - (output_device && !output_stream_params)) { - return CUBEB_ERROR_INVALID_PARAMETER; - } /* These could be different in the future if we have both * full-duplex stream and different devices for input vs output. */ @@ -2617,6 +2615,11 @@ audiounit_stream_init(cubeb * context, stm->state_callback = state_callback; stm->user_ptr = user_ptr; stm->latency_frames = latency_frames; + + if ((input_device && !input_stream_params) || + (output_device && !output_stream_params)) { + return CUBEB_ERROR_INVALID_PARAMETER; + } if (input_stream_params) { stm->input_stream_params = *input_stream_params; r = audiounit_set_device_info(stm.get(), reinterpret_cast(input_device), INPUT); @@ -2687,33 +2690,39 @@ audiounit_close_stream(cubeb_stream *stm) } static void -audiounit_stream_destroy(cubeb_stream * stm) +audiounit_stream_destroy_internal(cubeb_stream *stm) { - stm->shutdown = true; + stm->context->mutex.assert_current_thread_owns(); int r = audiounit_uninstall_system_changed_callback(stm); if (r != CUBEB_OK) { LOG("(%p) Could not uninstall the device changed callback", stm); } - r = audiounit_uninstall_device_changed_callback(stm); if (r != CUBEB_OK) { LOG("(%p) Could not uninstall all device change listeners", stm); } - { + auto_lock lock(stm->mutex); + audiounit_close_stream(stm); + assert(audiounit_active_streams(stm->context) >= 1); + audiounit_decrement_active_streams(stm->context); +} + +static void +audiounit_stream_destroy(cubeb_stream * stm) +{ + if (!stm->shutdown.load()){ auto_lock context_lock(stm->context->mutex); audiounit_stream_stop_internal(stm); + stm->shutdown = true; } // Execute close in serial queue to avoid collision // with reinit when un/plug devices dispatch_sync(stm->context->serial_queue, ^() { - auto_lock lock(stm->mutex); - audiounit_close_stream(stm); auto_lock context_lock(stm->context->mutex); - assert(audiounit_active_streams(stm->context) >= 1); - audiounit_decrement_active_streams(stm->context); + audiounit_stream_destroy_internal(stm); }); LOG("Cubeb stream (%p) destroyed successful.", stm); diff --git a/media/libcubeb/src/cubeb_wasapi.cpp b/media/libcubeb/src/cubeb_wasapi.cpp index e2bcf63528f8..9f1831f79645 100644 --- a/media/libcubeb/src/cubeb_wasapi.cpp +++ b/media/libcubeb/src/cubeb_wasapi.cpp @@ -871,7 +871,7 @@ wasapi_stream_render_loop(LPVOID stream) the timeout error handling only when the timeout_limit is reached, which is reset on each successful loop. */ unsigned timeout_count = 0; - const unsigned timeout_limit = 5; + const unsigned timeout_limit = 3; while (is_playing) { // We want to check the emergency bailout variable before a // and after the WaitForMultipleObject, because the handles WaitForMultipleObjects diff --git a/media/libcubeb/src/cubeb_winmm.c b/media/libcubeb/src/cubeb_winmm.c index 40c80b3e8c31..fd5abe250b1a 100644 --- a/media/libcubeb/src/cubeb_winmm.c +++ b/media/libcubeb/src/cubeb_winmm.c @@ -4,7 +4,6 @@ * This program is made available under an ISC-style license. See the * accompanying file LICENSE for details. */ -#define __MSVCRT_VERSION__ 0x0700 #undef WINVER #define WINVER 0x0501 #undef WIN32_LEAN_AND_MEAN