Bug 1521791 - Update cubeb from upstream to 67d37c1. r=padenot
authorAlex Chronopoulos <achronop@gmail.com>
Tue, 22 Jan 2019 16:09:51 +0000
changeset 514839 75dc8b3cc9a3fa4895cd10516de341fa4fee1957
parent 514838 d762822c538bf374820e7c63c3b5658f297b1d78
child 514840 8ba5964567a64f6a09b4de8ea4f8e8d151958f00
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1521791
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1521791 - Update cubeb from upstream to 67d37c1. r=padenot Differential Revision: https://phabricator.services.mozilla.com/D17248
media/libcubeb/gtest/test_sanity.cpp
media/libcubeb/include/cubeb.h
media/libcubeb/moz.yaml
media/libcubeb/src/cubeb_audiounit.cpp
media/libcubeb/src/cubeb_pulse.c
--- a/media/libcubeb/gtest/test_sanity.cpp
+++ b/media/libcubeb/gtest/test_sanity.cpp
@@ -395,51 +395,61 @@ TEST(cubeb, init_destroy_multiple_contex
 
 TEST(cubeb, basic_stream_operations)
 {
   int r;
   cubeb * ctx;
   cubeb_stream * stream;
   cubeb_stream_params params;
   uint64_t position;
+  uint32_t latency;
 
   r = common_init(&ctx, "test_sanity");
   ASSERT_EQ(r, CUBEB_OK);
   ASSERT_NE(ctx, nullptr);
 
   params.format = STREAM_FORMAT;
   params.rate = STREAM_RATE;
   params.channels = STREAM_CHANNELS;
   params.layout = STREAM_LAYOUT;
   params.prefs = CUBEB_STREAM_PREF_NONE;
 
   r = cubeb_stream_init(ctx, &stream, "test", NULL, NULL, NULL, &params, STREAM_LATENCY,
                         test_data_callback, test_state_callback, &dummy);
   ASSERT_EQ(r, CUBEB_OK);
   ASSERT_NE(stream, nullptr);
 
-  /* position and volume before stream has started */
+  /* position and latency before stream has started */
   r = cubeb_stream_get_position(stream, &position);
   ASSERT_EQ(r, CUBEB_OK);
   ASSERT_EQ(position, 0u);
 
+  r = cubeb_stream_get_latency(stream, &latency);
+  ASSERT_EQ(r, CUBEB_OK);
+
   r = cubeb_stream_start(stream);
   ASSERT_EQ(r, CUBEB_OK);
 
-  /* position and volume after while stream running */
+  /* position and latency after while stream running */
   r = cubeb_stream_get_position(stream, &position);
   ASSERT_EQ(r, CUBEB_OK);
 
+  r = cubeb_stream_get_latency(stream, &latency);
+  ASSERT_EQ(r, CUBEB_OK);
+
   r = cubeb_stream_stop(stream);
   ASSERT_EQ(r, CUBEB_OK);
 
-  /* position and volume after stream has stopped */
+  /* position and latency after stream has stopped */
   r = cubeb_stream_get_position(stream, &position);
   ASSERT_EQ(r, CUBEB_OK);
 
+  r = cubeb_stream_get_latency(stream, &latency);
+  ASSERT_EQ(r, CUBEB_OK);
+
   cubeb_stream_destroy(stream);
   cubeb_destroy(ctx);
 }
 
 TEST(cubeb, stream_position)
 {
   size_t i;
   int r;
--- a/media/libcubeb/include/cubeb.h
+++ b/media/libcubeb/include/cubeb.h
@@ -48,22 +48,24 @@ extern "C" {
       fprintf(stderr, "Could not get preferred sample-rate");
       return rv;
     }
 
     cubeb_stream_params output_params;
     output_params.format = CUBEB_SAMPLE_FLOAT32NE;
     output_params.rate = rate;
     output_params.channels = 2;
+    output_params.layout = CUBEB_LAYOUT_UNDEFINED;
     output_params.prefs = CUBEB_STREAM_PREF_NONE;
 
     cubeb_stream_params input_params;
     input_params.format = CUBEB_SAMPLE_FLOAT32NE;
     input_params.rate = rate;
     input_params.channels = 1;
+    input_params.layout = CUBEB_LAYOUT_UNDEFINED;
     input_params.prefs = CUBEB_STREAM_PREF_NONE;
 
     cubeb_stream * stm;
     rv = cubeb_stream_init(app_ctx, &stm, "Example Stream 1",
                            NULL, &input_params,
                            NULL, &output_params,
                            latency_frames,
                            data_cb, state_cb,
@@ -97,17 +99,17 @@ extern "C" {
     long data_cb(cubeb_stream * stm, void * user,
                  void * input_buffer, void * output_buffer, long nframes)
     {
       float * in  = input_buffer;
       float * out = output_buffer;
 
       for (i = 0; i < nframes; ++i) {
         for (c = 0; c < 2; ++c) {
-          buf[i][c] = in[i];
+          out[i][c] = in[i];
         }
       }
       return nframes;
     }
     @endcode
 
     @code
     void state_cb(cubeb_stream * stm, void * user, cubeb_state state)
--- a/media/libcubeb/moz.yaml
+++ b/media/libcubeb/moz.yaml
@@ -14,10 +14,10 @@ bugzilla:
 origin:
   name: "cubeb"
   description: "Cross platform audio library"
 
   url: "https://github.com/kinetiknz/cubeb"
   license: "ISC"
 
   # update.sh will update this value
-  release: "e5c3a1d8a68c412177f768908b1d54550cf9d510-dirty (2018-11-29 18:20:54 +0100)"
+  release: "67d37c16be84fcc469531d4b6f70eae8a2867a66 (2019-01-21 14:41:14 +0200)"
 
--- a/media/libcubeb/src/cubeb_audiounit.cpp
+++ b/media/libcubeb/src/cubeb_audiounit.cpp
@@ -1829,16 +1829,17 @@ audiounit_activate_clock_drift_compensat
   return CUBEB_OK;
 }
 
 static int audiounit_destroy_aggregate_device(AudioObjectID plugin_id, AudioDeviceID * aggregate_device_id);
 static void audiounit_get_available_samplerate(AudioObjectID devid, AudioObjectPropertyScope scope,
                                    uint32_t * min, uint32_t * max, uint32_t * def);
 static int
 audiounit_create_device_from_hwdev(cubeb_device_info * dev_info, AudioObjectID devid, cubeb_device_type type);
+static void audiounit_device_destroy(cubeb_device_info * device);
 
 static void
 audiounit_workaround_for_airpod(cubeb_stream * stm)
 {
   cubeb_device_info input_device_info;
   audiounit_create_device_from_hwdev(&input_device_info, stm->input_device.id, CUBEB_DEVICE_TYPE_INPUT);
 
   cubeb_device_info output_device_info;
@@ -1874,16 +1875,18 @@ audiounit_workaround_for_airpod(cubeb_st
                                              0,
                                              nullptr,
                                              sizeof(Float64),
                                              &rate);
     if (rv != noErr) {
       LOG("Non fatal error, AudioObjectSetPropertyData/kAudioDevicePropertyNominalSampleRate, rv=%d", rv);
     }
   }
+  audiounit_device_destroy(&input_device_info);
+  audiounit_device_destroy(&output_device_info);
 }
 
 /*
  * Aggregate Device is a virtual audio interface which utilizes inputs and outputs
  * of one or more physical audio interfaces. It is possible to use the clock of
  * one of the devices as a master clock for all the combined devices and enable
  * drift compensation for the devices that are not designated clock master.
  *
@@ -3096,17 +3099,17 @@ int audiounit_stream_device_destroy(cube
 }
 
 int audiounit_stream_register_device_changed_callback(cubeb_stream * stream,
                                                       cubeb_device_changed_callback device_changed_callback)
 {
   auto_lock dev_cb_lock(stream->device_changed_callback_lock);
   /* Note: second register without unregister first causes 'nope' error.
    * Current implementation requires unregister before register a new cb. */
-  assert(!stream->device_changed_callback);
+  assert(!device_changed_callback || !stream->device_changed_callback);
   stream->device_changed_callback = device_changed_callback;
   return CUBEB_OK;
 }
 
 static char *
 audiounit_strref_to_cstr_utf8(CFStringRef strref)
 {
   CFIndex len, size;
@@ -3373,24 +3376,30 @@ audiounit_enumerate_devices(cubeb * /* c
   } else {
     delete [] devices;
     collection->device = NULL;
   }
 
   return CUBEB_OK;
 }
 
+static void
+audiounit_device_destroy(cubeb_device_info * device)
+{
+  delete [] device->device_id;
+  delete [] device->friendly_name;
+  delete [] device->vendor_name;
+}
+
 static int
 audiounit_device_collection_destroy(cubeb * /* context */,
                                     cubeb_device_collection * collection)
 {
   for (size_t i = 0; i < collection->count; i++) {
-    delete [] collection->device[i].device_id;
-    delete [] collection->device[i].friendly_name;
-    delete [] collection->device[i].vendor_name;
+    audiounit_device_destroy(&collection->device[i]);
   }
   delete [] collection->device;
 
   return CUBEB_OK;
 }
 
 static vector<AudioObjectID>
 audiounit_get_devices_of_type(cubeb_device_type devtype)
--- a/media/libcubeb/src/cubeb_pulse.c
+++ b/media/libcubeb/src/cubeb_pulse.c
@@ -942,16 +942,17 @@ pulse_stream_init(cubeb * context,
       const pa_buffer_attr * input_att;
       input_att = WRAP(pa_stream_get_buffer_attr)(stm->input_stream);
       LOG("Input buffer attributes maxlength %u, tlength %u, prebuf %u, minreq %u, fragsize %u",input_att->maxlength, input_att->tlength,
           input_att->prebuf, input_att->minreq, input_att->fragsize);
     }
   }
 
   *stream = stm;
+  LOG("Cubeb stream (%p) init successful.", *stream);
 
   return CUBEB_OK;
 }
 
 static void
 pulse_stream_destroy(cubeb_stream * stm)
 {
   stream_cork(stm, CORK);
@@ -973,16 +974,17 @@ pulse_stream_destroy(cubeb_stream * stm)
   if (stm->input_stream) {
     WRAP(pa_stream_set_state_callback)(stm->input_stream, NULL, NULL);
     WRAP(pa_stream_set_read_callback)(stm->input_stream, NULL, NULL);
     WRAP(pa_stream_disconnect)(stm->input_stream);
     WRAP(pa_stream_unref)(stm->input_stream);
   }
   WRAP(pa_threaded_mainloop_unlock)(stm->context->mainloop);
 
+  LOG("Cubeb stream (%p) destroyed successfully.", stm);
   free(stm);
 }
 
 static void
 pulse_defer_event_cb(pa_mainloop_api * a, void * userdata)
 {
   (void)a;
   cubeb_stream * stm = userdata;
@@ -1004,31 +1006,33 @@ pulse_stream_start(cubeb_stream * stm)
      * things roll. This is done via a defer event in order to execute it
      * from PA server thread. */
     WRAP(pa_threaded_mainloop_lock)(stm->context->mainloop);
     WRAP(pa_mainloop_api_once)(WRAP(pa_threaded_mainloop_get_api)(stm->context->mainloop),
                                pulse_defer_event_cb, stm);
     WRAP(pa_threaded_mainloop_unlock)(stm->context->mainloop);
   }
 
+  LOG("Cubeb stream (%p) started successfully.", stm);
   return CUBEB_OK;
 }
 
 static int
 pulse_stream_stop(cubeb_stream * stm)
 {
   WRAP(pa_threaded_mainloop_lock)(stm->context->mainloop);
   stm->shutdown = 1;
   // If draining is taking place wait to finish
   while (stm->drain_timer) {
     WRAP(pa_threaded_mainloop_wait)(stm->context->mainloop);
   }
   WRAP(pa_threaded_mainloop_unlock)(stm->context->mainloop);
 
   stream_cork(stm, CORK | NOTIFY);
+  LOG("Cubeb stream (%p) stopped successfully.", stm);
   return CUBEB_OK;
 }
 
 static int
 pulse_stream_get_position(cubeb_stream * stm, uint64_t * position)
 {
   int r, in_thread;
   pa_usec_t r_usec;