Bug 1281402 - Uplift cubeb to revision 9a1d6ccd2. r?kinetik draft
authorPaul Adenot <paul@paul.cx>
Wed, 22 Jun 2016 15:12:58 +0200
changeset 380605 08e2030544d10acb0340257d2648cba35ebc7b09
parent 380596 40969d155419f72fa31e5b0e24158eb1fc10238c
child 523759 d16f801a9d78849b00ff91a87e87b3b4cbc4e24d
push id21258
push userpaul@paul.cx
push dateWed, 22 Jun 2016 13:13:23 +0000
reviewerskinetik
bugs1281402
milestone50.0a1
Bug 1281402 - Uplift cubeb to revision 9a1d6ccd2. r?kinetik MozReview-Commit-ID: 36jF493k7XW
media/libcubeb/README_MOZILLA
media/libcubeb/src/cubeb_audiounit.c
media/libcubeb/src/cubeb_pulse.c
media/libcubeb/src/cubeb_wasapi.cpp
--- 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 073c9f011114fe4208b4aa49e99e33cde1deb6f1.
+The git commit ID used was 9a1d6ccd2a0d65bfb985743b927398bcbeb05ad6.
--- a/media/libcubeb/src/cubeb_audiounit.c
+++ b/media/libcubeb/src/cubeb_audiounit.c
@@ -1531,16 +1531,17 @@ audiounit_get_devices(AudioObjectID ** d
 
     ret = AudioObjectGetPropertyData(kAudioObjectSystemObject, &adr, 0, NULL, &size, (void *)*devices);
     if (ret != noErr) {
       free(*devices);
       *devices = NULL;
     }
   } else {
     *devices = NULL;
+    ret = -1;
   }
 
   return ret;
 }
 
 static char *
 audiounit_strref_to_cstr_utf8(CFStringRef strref)
 {
@@ -1593,34 +1594,33 @@ audiounit_get_available_samplerate(Audio
     UInt32 size = sizeof(Float64);
     Float64 fvalue = 0.0;
     if (AudioObjectGetPropertyData(devid, &adr, 0, NULL, &size, &fvalue) == noErr) {
       *def = fvalue;
     }
   }
 
   adr.mSelector = kAudioDevicePropertyAvailableNominalSampleRates;
-  if (AudioObjectHasProperty(devid, &adr)) {
-    UInt32 size = 0;
-    AudioValueRange range;
-    if (AudioObjectGetPropertyDataSize(devid, &adr, 0, NULL, &size) == noErr) {
-      uint32_t i, count = size / sizeof(AudioValueRange);
-      AudioValueRange * ranges = malloc(size);
-      range.mMinimum = 9999999999.0;
-      range.mMaximum = 0.0;
-      if (AudioObjectGetPropertyData(devid, &adr, 0, NULL, &size, ranges) == noErr) {
-        for (i = 0; i < count; i++) {
-          if (ranges[i].mMaximum > range.mMaximum)
-            range.mMaximum = ranges[i].mMaximum;
-          if (ranges[i].mMinimum < range.mMinimum)
-            range.mMinimum = ranges[i].mMinimum;
-        }
+  UInt32 size = 0;
+  AudioValueRange range;
+  if (AudioObjectHasProperty(devid, &adr) &&
+      AudioObjectGetPropertyDataSize(devid, &adr, 0, NULL, &size) == noErr) {
+    uint32_t i, count = size / sizeof(AudioValueRange);
+    AudioValueRange * ranges = malloc(size);
+    range.mMinimum = 9999999999.0;
+    range.mMaximum = 0.0;
+    if (AudioObjectGetPropertyData(devid, &adr, 0, NULL, &size, ranges) == noErr) {
+      for (i = 0; i < count; i++) {
+        if (ranges[i].mMaximum > range.mMaximum)
+          range.mMaximum = ranges[i].mMaximum;
+        if (ranges[i].mMinimum < range.mMinimum)
+          range.mMinimum = ranges[i].mMinimum;
       }
-      free(ranges);
     }
+    free(ranges);
     *max = (uint32_t)range.mMaximum;
     *min = (uint32_t)range.mMinimum;
   } else {
     *min = *max = 0;
   }
 
 }
 
@@ -1834,17 +1834,17 @@ audiounit_get_devices_of_type(cubeb_devi
   for(uint32_t i = 0; i < count; ++i) {
     /* For device in the given scope channel must be > 0. */
     if (audiounit_get_channel_count(devices[i], scope) > 0) {
       devices_in_scope[dev_count] = devices[i];
       ++dev_count;
     }
   }
 
-  if (devid_array) {
+  if (devid_array && dev_count > 0) {
     *devid_array = calloc(dev_count, sizeof(AudioObjectID));
     assert(*devid_array);
     memcpy(*devid_array, &devices_in_scope, dev_count * sizeof(AudioObjectID));
   }
   return dev_count;
 }
 
 static uint32_t
--- a/media/libcubeb/src/cubeb_pulse.c
+++ b/media/libcubeb/src/cubeb_pulse.c
@@ -996,17 +996,17 @@ pulse_format_to_cubeb_format(pa_sample_f
 }
 
 static void
 pulse_ensure_dev_list_data_list_size (pulse_dev_list_data * list_data)
 {
   if (list_data->count == list_data->max) {
     list_data->max += 8;
     list_data->devinfo = realloc(list_data->devinfo,
-        sizeof(cubeb_device_info) * list_data->max);
+        sizeof(cubeb_device_info *) * list_data->max);
   }
 }
 
 static cubeb_device_state
 pulse_get_state_from_sink_port(pa_sink_port_info * info)
 {
   if (info != NULL) {
 #if PA_CHECK_VERSION(2, 0, 0)
--- a/media/libcubeb/src/cubeb_wasapi.cpp
+++ b/media/libcubeb/src/cubeb_wasapi.cpp
@@ -1725,17 +1725,17 @@ wasapi_stream_init(cubeb * context, cube
 
   *stream = stm;
 
   return CUBEB_OK;
 }
 
 void close_wasapi_stream(cubeb_stream * stm)
 {
-  XASSERT(stm && !stm->thread && !stm->shutdown_event);
+  XASSERT(stm);
 
   stm->stream_reset_lock->assert_current_thread_owns();
 
   XASSERT(stm->output_client || stm->input_client);
 
   SafeRelease(stm->output_client);
   stm->output_client = NULL;
   SafeRelease(stm->input_client);