Bug 1476278 - Update libcubeb to revision 6c47043. r=jya
authorPaul Adenot <paul@paul.cx>
Tue, 17 Jul 2018 15:25:59 +0200
changeset 427488 d22727e8db06829fa086a23ced8740a42882a898
parent 427487 9649aefe9a6b245c04206080d2338e7b92da6cdf
child 427489 ccee0cdce495c9269db8f22b4261b82985488964
push id34306
push usercsabou@mozilla.com
push dateFri, 20 Jul 2018 21:41:18 +0000
treeherdermozilla-central@d6a5e8aea651 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1476278
milestone63.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 1476278 - Update libcubeb to revision 6c47043. r=jya MozReview-Commit-ID: K03bJy6rSJ1
media/libcubeb/0001-Correctly-retrieve-the-output-layout-on-macOS-10.12.patch
media/libcubeb/0002-Always-upmix-mono-to-the-first-two-channels-if-enoug.patch
media/libcubeb/README_MOZILLA
media/libcubeb/src/cubeb_resampler.cpp
media/libcubeb/update.sh
deleted file mode 100644
--- a/media/libcubeb/0001-Correctly-retrieve-the-output-layout-on-macOS-10.12.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-From 59f5cb4ba01f21c4ad87e9404d1e470408e18505 Mon Sep 17 00:00:00 2001
-From: Jean-Yves Avenard <jyavenard@mozilla.com>
-Date: Mon, 9 Jul 2018 17:37:16 +0200
-Subject: [PATCH 1/2] Correctly retrieve the output layout on macOS < 10.12.
-
-The method kAudioUnitProperty_AudioChannelLayout used to retrieve the channel layout wasn't introduced until 10.12. So we use kAudioDevicePropertyPreferredChannelLayout instead should it fails.
-
-Fixes #448
----
- src/cubeb_audiounit.cpp | 35 ++++++++++++++++++++++++++++++++++-
- 1 file changed, 34 insertions(+), 1 deletion(-)
-
-diff --git a/src/cubeb_audiounit.cpp b/src/cubeb_audiounit.cpp
-index 6163ed7..43120b3 100644
---- a/src/cubeb_audiounit.cpp
-+++ b/src/cubeb_audiounit.cpp
-@@ -1239,6 +1239,38 @@ audiounit_convert_channel_layout(AudioChannelLayout * layout)
-   return cl;
- }
- 
-+static cubeb_channel_layout
-+audiounit_get_preferred_channel_layout(AudioUnit output_unit)
-+{
-+  OSStatus rv = noErr;
-+  UInt32 size = 0;
-+  rv = AudioUnitGetPropertyInfo(output_unit,
-+                                kAudioDevicePropertyPreferredChannelLayout,
-+                                kAudioUnitScope_Output,
-+                                AU_OUT_BUS,
-+                                &size,
-+                                nullptr);
-+  if (rv != noErr) {
-+    LOG("AudioUnitGetPropertyInfo/kAudioDevicePropertyPreferredChannelLayout rv=%d", rv);
-+    return CUBEB_LAYOUT_UNDEFINED;
-+  }
-+  assert(size > 0);
-+
-+  auto layout = make_sized_audio_channel_layout(size);
-+  rv = AudioUnitGetProperty(output_unit,
-+                            kAudioDevicePropertyPreferredChannelLayout,
-+                            kAudioUnitScope_Output,
-+                            AU_OUT_BUS,
-+                            layout.get(),
-+                            &size);
-+  if (rv != noErr) {
-+    LOG("AudioUnitGetProperty/kAudioDevicePropertyPreferredChannelLayout rv=%d", rv);
-+    return CUBEB_LAYOUT_UNDEFINED;
-+  }
-+
-+  return audiounit_convert_channel_layout(layout.get());
-+}
-+
- static cubeb_channel_layout
- audiounit_get_current_channel_layout(AudioUnit output_unit)
- {
-@@ -1252,7 +1284,8 @@ audiounit_get_current_channel_layout(AudioUnit output_unit)
-                                 nullptr);
-   if (rv != noErr) {
-     LOG("AudioUnitGetPropertyInfo/kAudioUnitProperty_AudioChannelLayout rv=%d", rv);
--    return CUBEB_LAYOUT_UNDEFINED;
-+    // This property isn't known before macOS 10.12, attempt another method.
-+    return audiounit_get_preferred_channel_layout(output_unit);
-   }
-   assert(size > 0);
- 
--- 
-2.17.0
-
deleted file mode 100644
--- a/media/libcubeb/0002-Always-upmix-mono-to-the-first-two-channels-if-enoug.patch
+++ /dev/null
@@ -1,51 +0,0 @@
-diff --git a/src/cubeb_audiounit.cpp b/src/cubeb_audiounit.cpp
-index 43120b3..5a83098 100644
---- a/src/cubeb_audiounit.cpp
-+++ b/src/cubeb_audiounit.cpp
-@@ -291,7 +291,7 @@ cubeb_channel_to_channel_label(cubeb_channel channel)
-     case CHANNEL_TOP_BACK_RIGHT:
-       return kAudioChannelLabel_TopBackRight;
-     default:
--      return CHANNEL_UNKNOWN;
-+      return kAudioChannelLabel_Unknown;
-   }
- }
- 
-@@ -1232,8 +1232,12 @@ audiounit_convert_channel_layout(AudioChannelLayout * layout)
- 
-   cubeb_channel_layout cl = 0;
-   for (UInt32 i = 0; i < layout->mNumberChannelDescriptions; ++i) {
--    cl |= channel_label_to_cubeb_channel(
-+    cubeb_channel cc = channel_label_to_cubeb_channel(
-       layout->mChannelDescriptions[i].mChannelLabel);
-+    if (cc == CHANNEL_UNKNOWN) {
-+      return CUBEB_LAYOUT_UNDEFINED;
-+    }
-+    cl |= cc;
-   }
- 
-   return cl;
-diff --git a/src/cubeb_mixer.cpp b/src/cubeb_mixer.cpp
-index 8995c55..c95fef6 100644
---- a/src/cubeb_mixer.cpp
-+++ b/src/cubeb_mixer.cpp
-@@ -525,6 +525,19 @@ struct cubeb_mixer
-   {
-     if (_context._in_ch_count <= _context._out_ch_count) {
-       // Not enough channels to copy, fill the gaps with silence.
-+      if (_context._in_ch_count == 1 && _context._out_ch_count >= 2) {
-+        // Special case for upmixing mono input to stereo and more. We will
-+        // duplicate the mono channel to the first two channels. On most system,
-+        // the first two channels are for left and right. It is commonly
-+        // expected that mono will on both left+right channels
-+        for (uint32_t i = 0; i < frames; i++) {
-+          output_buffer[0] = output_buffer[1] = *input_buffer;
-+          PodZero(output_buffer + 2, _context._out_ch_count - 2);
-+          output_buffer += _context._out_ch_count;
-+          input_buffer++;
-+        }
-+        return;
-+      }
-       for (uint32_t i = 0; i < frames; i++) {
-         PodCopy(output_buffer, input_buffer, _context._in_ch_count);
-         output_buffer += _context._in_ch_count;
--- 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 2968cba6474822535275225e4583c67c6aaaf2ae (2018-06-26 10:58:56 +0200)
+The git commit ID used was 6c4704304288c45d8198173ac4a6fe27d82b1e7c (2018-07-17 15:23:38 +0200)
--- a/media/libcubeb/src/cubeb_resampler.cpp
+++ b/media/libcubeb/src/cubeb_resampler.cpp
@@ -188,17 +188,20 @@ cubeb_resampler_speex<T, InputProcessor,
 
   /* The input data, after eventual resampling. This is passed to the callback. */
   T * resampled_input = nullptr;
   uint32_t resampled_frame_count = input_processor->output_for_input(*input_frames_count);
 
   /* process the input, and present exactly `output_frames_needed` in the
   * callback. */
   input_processor->input(input_buffer, *input_frames_count);
-  resampled_input = input_processor->output(resampled_frame_count, (size_t*)input_frames_count);
+
+  size_t frames_resampled = 0;
+  resampled_input = input_processor->output(resampled_frame_count, &frames_resampled);
+  *input_frames_count = frames_resampled;
 
   long got = data_callback(stream, user_ptr,
                            resampled_input, nullptr, resampled_frame_count);
 
   /* Return the number of initial input frames or part of it.
   * Since output_frames_needed == 0 in input scenario, the only
   * available number outside resampler is the initial number of frames. */
   return (*input_frames_count) * (got / resampled_frame_count);
@@ -239,18 +242,21 @@ cubeb_resampler_speex<T, InputProcessor,
    /* fill directly the input buffer of the output processor to save a copy */
   out_unprocessed =
     output_processor->input_buffer(output_frames_before_processing);
 
   if (in_buffer) {
     /* process the input, and present exactly `output_frames_needed` in the
     * callback. */
     input_processor->input(in_buffer, *input_frames_count);
+
+    size_t frames_resampled = 0;
     resampled_input =
-      input_processor->output(output_frames_before_processing, (size_t*)input_frames_count);
+      input_processor->output(output_frames_before_processing, &frames_resampled);
+    *input_frames_count = frames_resampled;
   } else {
     resampled_input = nullptr;
   }
 
   got = data_callback(stream, user_ptr,
                       resampled_input, out_unprocessed,
                       output_frames_before_processing);
 
--- a/media/libcubeb/update.sh
+++ b/media/libcubeb/update.sh
@@ -77,14 +77,8 @@ fi
 echo "Applying disable-assert.patch on top of $rev"
 patch -p3 < disable-assert.patch
 
 echo "Applying prefer-pulse-rust.patch on top of $rev"
 patch -p3 < prefer-pulse-rust.patch
 
 echo "Applying disable-device-switching.patch on top of $rev"
 patch -p3 < disable-device-switching.patch
-
-echo "Applying Correctly-retrieve-the-output-layout-on-macOS-10.12.patch on top of $rev"
-patch -p1 < 0001-Correctly-retrieve-the-output-layout-on-macOS-10.12.patch
-
-echo "Applying Always-upmix-mono-to-the-first-two-channels-if-enoug.patch on top of $rev"
-patch -p1 < 0002-Always-upmix-mono-to-the-first-two-channels-if-enoug.patch