From 925ad97bb46e3fd9c60382418c1aa079fe49ff3a Mon Sep 17 00:00:00 2001 From: Alex Chronopoulos Date: Wed, 3 Apr 2019 12:50:40 +0300 Subject: [PATCH] Bug 1541101 - Update cubeb from upstream to 66d9c48. r=kinetik --- media/libcubeb/moz.yaml | 2 +- media/libcubeb/src/cubeb.c | 2 +- media/libcubeb/src/cubeb_audiounit.cpp | 40 +++++++++++++++++++++----- media/libcubeb/src/cubeb_wasapi.cpp | 1 + 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/media/libcubeb/moz.yaml b/media/libcubeb/moz.yaml index 0a7d749846ec..662b1bc12bd8 100644 --- a/media/libcubeb/moz.yaml +++ b/media/libcubeb/moz.yaml @@ -19,5 +19,5 @@ origin: license: "ISC" # update.sh will update this value - release: "3afc3350063ce1d68bbd0287fde4f70b4803d2eb (2019-02-13 10:28:58 +1300)" + release: "66d9c48d916f00c396482f9c5075feacc2bc0db8 (2019-04-03 12:41:20 +0300)" diff --git a/media/libcubeb/src/cubeb.c b/media/libcubeb/src/cubeb.c index bb35e0ce349f..98a735f8df5a 100644 --- a/media/libcubeb/src/cubeb.c +++ b/media/libcubeb/src/cubeb.c @@ -303,7 +303,7 @@ cubeb_stream_init(cubeb * context, cubeb_stream ** stream, char const * stream_n { int r; - if (!context || !stream) { + if (!context || !stream || !data_callback || !state_callback) { return CUBEB_ERROR_INVALID_PARAMETER; } diff --git a/media/libcubeb/src/cubeb_audiounit.cpp b/media/libcubeb/src/cubeb_audiounit.cpp index 6bf0e3da8515..94ea28fd3f29 100644 --- a/media/libcubeb/src/cubeb_audiounit.cpp +++ b/media/libcubeb/src/cubeb_audiounit.cpp @@ -111,7 +111,7 @@ enum device_flags { }; void audiounit_stream_stop_internal(cubeb_stream * stm); -void audiounit_stream_start_internal(cubeb_stream * stm); +static int audiounit_stream_start_internal(cubeb_stream * stm); static void audiounit_close_stream(cubeb_stream *stm); static int audiounit_setup_stream(cubeb_stream *stm); static vector @@ -139,7 +139,7 @@ struct cubeb { // Store list of devices to detect changes vector input_device_array; vector output_device_array; - // The queue is asynchronously deallocated once all references to it are released + // The queue should be released when it’s no longer needed. dispatch_queue_t serial_queue = dispatch_queue_create(DISPATCH_QUEUE_LABEL, DISPATCH_QUEUE_SERIAL); // Current used channel layout atomic layout{ CUBEB_LAYOUT_UNDEFINED }; @@ -854,7 +854,10 @@ audiounit_reinit_stream(cubeb_stream * stm, device_flags_value flags) // If the stream was running, start it again. if (!stm->shutdown) { - audiounit_stream_start_internal(stm); + r = audiounit_stream_start_internal(stm); + if (r != CUBEB_OK) { + return CUBEB_ERROR; + } } } return CUBEB_OK; @@ -1432,6 +1435,8 @@ audiounit_destroy(cubeb * ctx) } } + dispatch_release(ctx->serial_queue); + delete ctx; } @@ -1681,6 +1686,9 @@ audiounit_create_blank_aggregate_device(AudioObjectID * plugin_id, AudioDeviceID return CUBEB_OK; } +// The returned CFStringRef object needs to be released (via CFRelease) +// if it's not NULL, since the reference count of the returned CFStringRef +// object is increased. static CFStringRef get_device_name(AudioDeviceID id) { @@ -1713,6 +1721,7 @@ audiounit_set_aggregate_sub_device_list(AudioDeviceID aggregate_device_id, return CUBEB_ERROR; } CFArrayAppendValue(aggregate_sub_devices_array, ref); + CFRelease(ref); } for (UInt32 i = 0; i < input_sub_devices.size(); i++) { CFStringRef ref = get_device_name(input_sub_devices[i]); @@ -1721,6 +1730,7 @@ audiounit_set_aggregate_sub_device_list(AudioDeviceID aggregate_device_id, return CUBEB_ERROR; } CFArrayAppendValue(aggregate_sub_devices_array, ref); + CFRelease(ref); } AudioObjectPropertyAddress aggregate_sub_device_list = { kAudioAggregateDevicePropertyFullSubDeviceList, @@ -1762,6 +1772,9 @@ audiounit_set_master_aggregate_device(const AudioDeviceID aggregate_device_id) NULL, size, &master_sub_device); + if (master_sub_device) { + CFRelease(master_sub_device); + } if (rv != noErr) { LOG("AudioObjectSetPropertyData/kAudioAggregateDevicePropertyMasterSubDevice, rv=%d", rv); return CUBEB_ERROR; @@ -2874,18 +2887,25 @@ audiounit_stream_destroy(cubeb_stream * stm) delete stm; } -void +static int audiounit_stream_start_internal(cubeb_stream * stm) { OSStatus r; if (stm->input_unit != NULL) { r = AudioOutputUnitStart(stm->input_unit); - assert(r == 0); + if (r != noErr) { + LOG("AudioOutputUnitStart (input) rv=%d", r); + return CUBEB_ERROR; + } } if (stm->output_unit != NULL) { r = AudioOutputUnitStart(stm->output_unit); - assert(r == 0); + if (r != noErr) { + LOG("AudioOutputUnitStart (output) rv=%d", r); + return CUBEB_ERROR; + } } + return CUBEB_OK; } static int @@ -2895,7 +2915,10 @@ audiounit_stream_start(cubeb_stream * stm) stm->shutdown = false; stm->draining = false; - audiounit_stream_start_internal(stm); + int r = audiounit_stream_start_internal(stm); + if (r != CUBEB_OK) { + return r; + } stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_STARTED); @@ -3428,6 +3451,9 @@ audiounit_get_devices_of_type(cubeb_device_type devtype) } else { it++; } + if (name) { + CFRelease(name); + } } /* Expected sorted but did not find anything in the docs. */ diff --git a/media/libcubeb/src/cubeb_wasapi.cpp b/media/libcubeb/src/cubeb_wasapi.cpp index 64248821db09..fd72417439b3 100644 --- a/media/libcubeb/src/cubeb_wasapi.cpp +++ b/media/libcubeb/src/cubeb_wasapi.cpp @@ -1449,6 +1449,7 @@ int wasapi_init(cubeb ** context, char const * context_name) com_ptr device; HRESULT hr = get_default_endpoint(device, eRender); if (FAILED(hr)) { + XASSERT(hr != CO_E_NOTINITIALIZED); LOG("It wasn't able to find a default rendering device: %lx", hr); hr = get_default_endpoint(device, eCapture); if (FAILED(hr)) {