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

Unified Diff: trunk/src/media/audio/audio_input_controller.cc

Issue 335343004: Revert 277794 "Modifies AudioInputCallback::OnData and use media..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 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
Index: trunk/src/media/audio/audio_input_controller.cc
===================================================================
--- trunk/src/media/audio/audio_input_controller.cc (revision 277811)
+++ trunk/src/media/audio/audio_input_controller.cc (working copy)
@@ -202,6 +202,7 @@
audio_level_.reset(new media::AudioPowerMonitor(
params.sample_rate(),
TimeDelta::FromMilliseconds(kPowerMeasurementTimeConstantMilliseconds)));
+ audio_bus_ = AudioBus::Create(params);
audio_params_ = params;
#endif
@@ -382,7 +383,8 @@
}
void AudioInputController::OnData(AudioInputStream* stream,
- const AudioBus* source,
+ const uint8* data,
+ uint32 size,
uint32 hardware_delay_bytes,
double volume) {
// Mark data as active to ensure that the periodic calls to
@@ -406,7 +408,7 @@
// Use SharedMemory and SyncSocket if the client has created a SyncWriter.
// Used by all low-latency clients except WebSpeech.
if (SharedMemoryAndSyncSocketMode()) {
- sync_writer_->Write(source, volume, key_pressed);
+ sync_writer_->Write(data, size, volume, key_pressed);
sync_writer_->UpdateRecordedBytes(hardware_delay_bytes);
#if defined(AUDIO_POWER_MONITORING)
@@ -422,7 +424,9 @@
// Wrap data into an AudioBus to match AudioPowerMonitor::Scan.
// TODO(henrika): remove this section when capture side uses AudioBus.
// See http://crbug.com/375155 for details.
- audio_level_->Scan(*source, source->frames());
+ audio_bus_->FromInterleaved(
+ data, audio_bus_->frames(), audio_params_.bits_per_sample() / 8);
+ audio_level_->Scan(*audio_bus_, audio_bus_->frames());
// Get current average power level and add it to the log.
// Possible range is given by [-inf, 0] dBFS.
@@ -441,28 +445,26 @@
audio_level_->Reset();
}
#endif
+
return;
}
// TODO(henrika): Investigate if we can avoid the extra copy here.
// (see http://crbug.com/249316 for details). AFAIK, this scope is only
// active for WebSpeech clients.
- scoped_ptr<AudioBus> audio_data =
- AudioBus::Create(source->channels(), source->frames());
- source->CopyTo(audio_data.get());
+ scoped_ptr<uint8[]> audio_data(new uint8[size]);
+ memcpy(audio_data.get(), data, size);
// Ownership of the audio buffer will be with the callback until it is run,
// when ownership is passed to the callback function.
- task_runner_->PostTask(
- FROM_HERE,
- base::Bind(
- &AudioInputController::DoOnData, this, base::Passed(&audio_data)));
+ task_runner_->PostTask(FROM_HERE, base::Bind(
+ &AudioInputController::DoOnData, this, base::Passed(&audio_data), size));
}
-void AudioInputController::DoOnData(scoped_ptr<AudioBus> data) {
+void AudioInputController::DoOnData(scoped_ptr<uint8[]> data, uint32 size) {
DCHECK(task_runner_->BelongsToCurrentThread());
if (handler_)
- handler_->OnData(this, data.get());
+ handler_->OnData(this, data.get(), size);
}
void AudioInputController::DoLogAudioLevel(float level_dbfs) {
« no previous file with comments | « trunk/src/media/audio/audio_input_controller.h ('k') | trunk/src/media/audio/audio_input_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698