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

Unified Diff: media/audio/audio_output_device.cc

Issue 12379071: Use multiple shared memory buffers cyclically for audio capture. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: rebase Created 7 years, 10 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
« media/audio/audio_input_device.cc ('K') | « media/audio/audio_input_ipc.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_output_device.cc
===================================================================
--- media/audio/audio_output_device.cc (revision 186213)
+++ media/audio/audio_output_device.cc (working copy)
@@ -22,7 +22,7 @@
: public AudioDeviceThread::Callback {
public:
AudioThreadCallback(const AudioParameters& audio_parameters,
- base::SharedMemoryHandle memory,
+ SharedMemoryHandleVector memory,
int memory_length,
AudioRendererSink::RenderCallback* render_callback);
virtual ~AudioThreadCallback();
@@ -30,7 +30,7 @@
virtual void MapSharedMemory() OVERRIDE;
// Called whenever we receive notifications about pending data.
- virtual void Process(int pending_data) OVERRIDE;
+ virtual void Process(int pending_data, int index) OVERRIDE;
private:
AudioRendererSink::RenderCallback* render_callback_;
@@ -48,6 +48,7 @@
stream_id_(0),
state_(IDLE),
play_on_start_(true),
+ audio_thread_(false),
stopping_hack_(false) {
CHECK(ipc_);
}
@@ -226,7 +227,9 @@
DCHECK(audio_thread_.IsStopped());
audio_callback_.reset(new AudioOutputDevice::AudioThreadCallback(
- audio_parameters_, handle, length, callback_));
+ audio_parameters_,
+ AudioDeviceThread::Callback::SharedMemoryHandleVector(1, handle),
+ length, callback_));
audio_thread_.Start(audio_callback_.get(), socket_handle,
"AudioOutputDevice");
state_ = PAUSED;
@@ -252,7 +255,7 @@
AudioOutputDevice::AudioThreadCallback::AudioThreadCallback(
const AudioParameters& audio_parameters,
- base::SharedMemoryHandle memory,
+ SharedMemoryHandleVector memory,
int memory_length,
AudioRendererSink::RenderCallback* render_callback)
: AudioDeviceThread::Callback(audio_parameters,
@@ -265,7 +268,9 @@
}
void AudioOutputDevice::AudioThreadCallback::MapSharedMemory() {
- CHECK(shared_memory_.Map(TotalSharedMemorySizeInBytes(memory_length_)));
+ DCHECK_EQ(shared_memory_.size(), 1u);
+ base::SharedMemory* shared_buffer = shared_memory_[0];
+ CHECK(shared_buffer->Map(TotalSharedMemorySizeInBytes(memory_length_)));
// Calculate output and input memory size.
int output_memory_size = AudioBus::CalculateMemorySize(audio_parameters_);
@@ -279,22 +284,24 @@
DCHECK_EQ(memory_length_, io_size);
output_bus_ =
- AudioBus::WrapMemory(audio_parameters_, shared_memory_.memory());
+ AudioBus::WrapMemory(audio_parameters_, shared_buffer->memory());
if (input_channels > 0) {
// The input data is after the output data.
char* input_data =
- static_cast<char*>(shared_memory_.memory()) + output_memory_size;
+ static_cast<char*>(shared_buffer->memory()) + output_memory_size;
input_bus_ =
AudioBus::WrapMemory(input_channels, frames, input_data);
}
}
// Called whenever we receive notifications about pending data.
-void AudioOutputDevice::AudioThreadCallback::Process(int pending_data) {
+void AudioOutputDevice::AudioThreadCallback::Process(
+ int pending_data, int index) {
+ base::SharedMemory* shared_buffer = shared_memory_[0];
if (pending_data == kPauseMark) {
- memset(shared_memory_.memory(), 0, memory_length_);
- SetActualDataSizeInBytes(&shared_memory_, memory_length_, 0);
+ memset(shared_buffer->memory(), 0, memory_length_);
+ SetActualDataSizeInBytes(shared_buffer, memory_length_, 0);
return;
}
@@ -325,7 +332,7 @@
// relying on AudioSyncReader::Read() to parse this with that in mind. Rename
// these methods to Set/GetActualFrameCount().
SetActualDataSizeInBytes(
- &shared_memory_, memory_length_,
+ shared_buffer, memory_length_,
num_frames * sizeof(*output_bus_->channel(0)) * output_bus_->channels());
}
« media/audio/audio_input_device.cc ('K') | « media/audio/audio_input_ipc.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698