Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(828)

Unified Diff: content/renderer/media/audio_track_recorder.cc

Issue 2024993004: AudioBus: Add a ToInterleavedFloat() method to AudioBus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed a todo Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/audio_track_recorder.cc
diff --git a/content/renderer/media/audio_track_recorder.cc b/content/renderer/media/audio_track_recorder.cc
index ad28b28d96b5ee3ae0d4015514ddbc5d296d23b4..5d5e75235fa41b8f1351700c40a8b846f220888e 100644
--- a/content/renderer/media/audio_track_recorder.cc
+++ b/content/renderer/media/audio_track_recorder.cc
@@ -15,6 +15,7 @@
#include "media/base/audio_converter.h"
#include "media/base/audio_fifo.h"
#include "media/base/audio_parameters.h"
+#include "media/base/audio_sample_types.h"
#include "media/base/bind_to_current_loop.h"
#include "third_party/opus/src/include/opus.h"
@@ -76,19 +77,6 @@ bool DoEncode(OpusEncoder* opus_encoder,
return false;
}
-// Interleaves |audio_bus| channels() of floats into a single output linear
-// |buffer|.
-// TODO(mcasas) https://crbug.com/580391 use AudioBus::ToInterleavedFloat().
-void ToInterleaved(media::AudioBus* audio_bus, float* buffer) {
- for (int ch = 0; ch < audio_bus->channels(); ++ch) {
- const float* src = audio_bus->channel(ch);
- const float* const src_end = src + audio_bus->frames();
- float* dest = buffer + ch;
- for (; src < src_end; ++src, dest += audio_bus->channels())
- *dest = *src;
- }
-}
-
} // anonymous namespace
// Nested class encapsulating opus-related encoding details. It contains an
@@ -259,7 +247,8 @@ void AudioTrackRecorder::AudioEncoder::EncodeAudio(
std::unique_ptr<media::AudioBus> audio_bus = media::AudioBus::Create(
output_params_.channels(), kOpusPreferredFramesPerBuffer);
converter_->Convert(audio_bus.get());
- ToInterleaved(audio_bus.get(), buffer_.get());
+ audio_bus->ToInterleaved<media::Float32SampleTypeTraits>(
+ audio_bus->frames(), buffer_.get());
std::unique_ptr<std::string> encoded_data(new std::string());
if (DoEncode(opus_encoder_, buffer_.get(), kOpusPreferredFramesPerBuffer,
« no previous file with comments | « no previous file | media/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698