Bug 1471164 - Update cubeb from upstream to 2968cba. r?padenot
MozReview-Commit-ID: Lwalw9Hxf70
--- a/media/libcubeb/README_MOZILLA
+++ b/media/libcubeb/README_MOZILLA
@@ -1,8 +1,8 @@
The source from this directory was copied from the cubeb
git repository using the update.sh script. The only changes
made were those applied by update.sh and the addition of
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)
--- a/media/libcubeb/src/cubeb_audiounit.cpp
+++ b/media/libcubeb/src/cubeb_audiounit.cpp
@@ -2580,16 +2580,18 @@ cubeb_stream::cubeb_stream(cubeb * conte
: context(context)
, resampler(nullptr, cubeb_resampler_destroy)
, mixer(nullptr, cubeb_mixer_destroy)
{
PodZero(&input_desc, 1);
PodZero(&output_desc, 1);
}
+static void audiounit_stream_destroy_internal(cubeb_stream * stm);
+
static int
audiounit_stream_init(cubeb * context,
cubeb_stream ** stream,
char const * /* stream_name */,
cubeb_devid input_device,
cubeb_stream_params * input_stream_params,
cubeb_devid output_device,
cubeb_stream_params * output_stream_params,
@@ -2597,31 +2599,32 @@ audiounit_stream_init(cubeb * context,
cubeb_data_callback data_callback,
cubeb_state_callback state_callback,
void * user_ptr)
{
assert(context);
auto_lock context_lock(context->mutex);
audiounit_increment_active_streams(context);
unique_ptr<cubeb_stream, decltype(&audiounit_stream_destroy)> 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. */
stm->data_callback = data_callback;
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<uintptr_t>(input_device), INPUT);
if (r != CUBEB_OK) {
LOG("(%p) Fail to set device info for input.", stm.get());
return r;
}
}
@@ -2682,43 +2685,49 @@ audiounit_close_stream(cubeb_stream *stm
if (stm->aggregate_device_id) {
audiounit_destroy_aggregate_device(stm->plugin_id, &stm->aggregate_device_id);
stm->aggregate_device_id = 0;
}
}
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);
delete stm;
}
void
audiounit_stream_start_internal(cubeb_stream * stm)
--- a/media/libcubeb/src/cubeb_wasapi.cpp
+++ b/media/libcubeb/src/cubeb_wasapi.cpp
@@ -866,17 +866,17 @@ wasapi_stream_render_loop(LPVOID stream)
is_playing = false;
}
/* WaitForMultipleObjects timeout can trigger in cases where we don't want to
treat it as a timeout, such as across a system sleep/wake cycle. Trigger
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
// is going to wait on might have been closed already.
if (*emergency_bailout) {
delete emergency_bailout;
return 0;
}
--- a/media/libcubeb/src/cubeb_winmm.c
+++ b/media/libcubeb/src/cubeb_winmm.c
@@ -1,15 +1,14 @@
/*
* Copyright © 2011 Mozilla Foundation
*
* 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
#include <malloc.h>
#include <windows.h>
#include <mmreg.h>
#include <mmsystem.h>