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

Unified Diff: content/browser/renderer_host/media/audio_input_sync_writer.cc

Issue 314713002: Modifies AudioInputCallback::OnData and use media::AudioBus instead of plain byte vector (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
Index: content/browser/renderer_host/media/audio_input_sync_writer.cc
diff --git a/content/browser/renderer_host/media/audio_input_sync_writer.cc b/content/browser/renderer_host/media/audio_input_sync_writer.cc
index 99b91b7b9f6b8fcf2e19c2df0504f593c16b2d21..3ad3d096bf27f0e87bc9f37fd02b1c55bc980488 100644
--- a/content/browser/renderer_host/media/audio_input_sync_writer.cc
+++ b/content/browser/renderer_host/media/audio_input_sync_writer.cc
@@ -8,16 +8,19 @@
#include "base/memory/shared_memory.h"
#include "content/browser/renderer_host/media/media_stream_manager.h"
+#include "media/base/audio_bus.h"
namespace content {
AudioInputSyncWriter::AudioInputSyncWriter(
base::SharedMemory* shared_memory,
- int shared_memory_segment_count)
+ int shared_memory_segment_count,
+ const media::AudioParameters& params)
: shared_memory_(shared_memory),
shared_memory_segment_count_(shared_memory_segment_count),
current_segment_id_(0),
- creation_time_(base::Time::Now()) {
+ creation_time_(base::Time::Now()),
+ params_(params) {
DCHECK_GT(shared_memory_segment_count, 0);
DCHECK_EQ(shared_memory->requested_size() % shared_memory_segment_count, 0u);
shared_memory_segment_size_ =
@@ -31,8 +34,7 @@ void AudioInputSyncWriter::UpdateRecordedBytes(uint32 bytes) {
socket_->Send(&bytes, sizeof(bytes));
}
-uint32 AudioInputSyncWriter::Write(const void* data,
- uint32 size,
+uint32 AudioInputSyncWriter::Write(const media::AudioBus* data,
double volume,
bool key_pressed) {
#if !defined(OS_ANDROID)
@@ -64,14 +66,14 @@ uint32 AudioInputSyncWriter::Write(const void* data,
media::AudioInputBuffer* buffer =
reinterpret_cast<media::AudioInputBuffer*>(ptr);
buffer->params.volume = volume;
- buffer->params.size = size;
+ buffer->params.size = params_.GetBytesPerBuffer();
buffer->params.key_pressed = key_pressed;
- memcpy(buffer->audio, data, size);
-
+ data->ToInterleaved(data->frames(), params_.bits_per_sample() / 8,
henrika (OOO until Aug 14) 2014/06/03 14:43:51 Can we do something here to prevent what is done c
DaleCurtis 2014/06/03 21:03:06 Just use AudioBus::WrapMemory() and size the share
henrika (OOO until Aug 14) 2014/06/04 07:50:22 Thanks Dale! I will use your first idea and upload
no longer working on chromium 2014/06/04 12:38:12 This is a bit hard, on the input side, we create a
+ buffer->audio);
if (++current_segment_id_ >= shared_memory_segment_count_)
current_segment_id_ = 0;
- return size;
+ return params_.GetBytesPerBuffer();
}
void AudioInputSyncWriter::Close() {

Powered by Google App Engine
This is Rietveld 408576698