summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-31 23:18:48 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-31 23:18:48 +0000
commit2f6d086da79c737bc2a0ee3023ca80c608c75d19 (patch)
tree6943204cb1c9c7d7cbe722f91a64a1c326601fef /chrome/renderer
parent87949cc2b85979964ca9de9483ba1ba2758e0b81 (diff)
downloadchromium_src-2f6d086da79c737bc2a0ee3023ca80c608c75d19.zip
chromium_src-2f6d086da79c737bc2a0ee3023ca80c608c75d19.tar.gz
chromium_src-2f6d086da79c737bc2a0ee3023ca80c608c75d19.tar.bz2
Add AudioParameters struct. Use it everywhere.
BUG=None TEST=unittests Review URL: http://codereview.chromium.org/3226012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58097 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/media/audio_renderer_impl.cc27
-rw-r--r--chrome/renderer/media/audio_renderer_impl.h7
-rw-r--r--chrome/renderer/pepper_devices.cc15
-rw-r--r--chrome/renderer/pepper_plugin_delegate_impl.cc12
4 files changed, 25 insertions, 36 deletions
diff --git a/chrome/renderer/media/audio_renderer_impl.cc b/chrome/renderer/media/audio_renderer_impl.cc
index 06356cc..b7e021f 100644
--- a/chrome/renderer/media/audio_renderer_impl.cc
+++ b/chrome/renderer/media/audio_renderer_impl.cc
@@ -27,9 +27,6 @@ const int kPacketsInBuffer = 3;
AudioRendererImpl::AudioRendererImpl(AudioMessageFilter* filter)
: AudioRendererBase(),
- channels_(0),
- sample_rate_(0),
- sample_bits_(0),
bytes_per_second_(0),
filter_(filter),
stream_id_(0),
@@ -63,18 +60,19 @@ bool AudioRendererImpl::IsMediaFormatSupported(
bool AudioRendererImpl::OnInitialize(const media::MediaFormat& media_format) {
// Parse integer values in MediaFormat.
if (!ParseMediaFormat(media_format,
- &channels_,
- &sample_rate_,
- &sample_bits_)) {
+ &params_.channels,
+ &params_.sample_rate,
+ &params_.bits_per_sample)) {
return false;
}
+ params_.format = AudioParameters::AUDIO_PCM_LINEAR;
// Calculate the number of bytes per second using information of the stream.
- bytes_per_second_ = sample_rate_ * channels_ * sample_bits_ / 8;
+ bytes_per_second_ = params_.sample_rate * params_.channels *
+ params_.bits_per_sample / 8;
+
io_loop_->PostTask(FROM_HERE,
- NewRunnableMethod(this, &AudioRendererImpl::CreateStreamTask,
- AudioManager::AUDIO_PCM_LINEAR, channels_,
- sample_rate_, sample_bits_));
+ NewRunnableMethod(this, &AudioRendererImpl::CreateStreamTask, params_));
return true;
}
@@ -253,9 +251,7 @@ void AudioRendererImpl::OnVolume(double volume) {
// pipeline.
}
-void AudioRendererImpl::CreateStreamTask(
- AudioManager::Format format, int channels,
- int sample_rate, int bits_per_sample) {
+void AudioRendererImpl::CreateStreamTask(AudioParameters audio_params) {
DCHECK(MessageLoop::current() == io_loop_);
AutoLock auto_lock(lock_);
@@ -268,10 +264,7 @@ void AudioRendererImpl::CreateStreamTask(
io_loop_->AddDestructionObserver(this);
ViewHostMsg_Audio_CreateStream_Params params;
- params.format = format;
- params.channels = channels;
- params.sample_rate = sample_rate;
- params.bits_per_sample = bits_per_sample;
+ params.params = audio_params;
params.packet_size = 0;
filter_->Send(new ViewHostMsg_CreateAudioStream(0, stream_id_, params,
diff --git a/chrome/renderer/media/audio_renderer_impl.h b/chrome/renderer/media/audio_renderer_impl.h
index 30ac36f..f8fa094 100644
--- a/chrome/renderer/media/audio_renderer_impl.h
+++ b/chrome/renderer/media/audio_renderer_impl.h
@@ -115,8 +115,7 @@ class AudioRendererImpl : public media::AudioRendererBase,
// The following methods are tasks posted on the IO thread that needs to
// be executed on that thread. They interact with AudioMessageFilter and
// sends IPC messages on that thread.
- void CreateStreamTask(AudioManager::Format format, int channels,
- int sample_rate, int bits_per_sample);
+ void CreateStreamTask(AudioParameters params);
void PlayTask();
void PauseTask();
void SeekTask();
@@ -128,9 +127,7 @@ class AudioRendererImpl : public media::AudioRendererBase,
virtual void WillDestroyCurrentMessageLoop();
// Information about the audio stream.
- int channels_;
- int sample_rate_;
- int sample_bits_;
+ AudioParameters params_;
uint32 bytes_per_second_;
scoped_refptr<AudioMessageFilter> filter_;
diff --git a/chrome/renderer/pepper_devices.cc b/chrome/renderer/pepper_devices.cc
index 0e4f2ac..54232ee 100644
--- a/chrome/renderer/pepper_devices.cc
+++ b/chrome/renderer/pepper_devices.cc
@@ -173,23 +173,23 @@ NPError AudioDeviceContext::Initialize(AudioMessageFilter* filter,
context_= context;
ViewHostMsg_Audio_CreateStream_Params params;
- params.format = AudioManager::AUDIO_PCM_LINEAR;
- params.channels = config->outputChannelMap;
- params.sample_rate = config->sampleRate;
+ params.params.format = AudioParameters::AUDIO_PCM_LINEAR;
+ params.params.channels = config->outputChannelMap;
+ params.params.sample_rate = config->sampleRate;
switch (config->sampleType) {
case NPAudioSampleTypeInt16:
- params.bits_per_sample = 16;
+ params.params.bits_per_sample = 16;
break;
case NPAudioSampleTypeFloat32:
- params.bits_per_sample = 32;
+ params.params.bits_per_sample = 32;
break;
default:
return NPERR_INVALID_PARAM;
}
context->config = *config;
- params.packet_size = config->sampleFrameCount * config->outputChannelMap
- * (params.bits_per_sample >> 3);
+ params.packet_size = config->sampleFrameCount * config->outputChannelMap *
+ (params.params.bits_per_sample >> 3);
stream_id_ = filter_->AddDelegate(this);
filter->Send(new ViewHostMsg_CreateAudioStream(0, stream_id_, params, true));
@@ -278,4 +278,3 @@ void AudioDeviceContext::Run() {
FireAudioCallback();
}
}
-
diff --git a/chrome/renderer/pepper_plugin_delegate_impl.cc b/chrome/renderer/pepper_plugin_delegate_impl.cc
index 8ccaed4..8e6763c 100644
--- a/chrome/renderer/pepper_plugin_delegate_impl.cc
+++ b/chrome/renderer/pepper_plugin_delegate_impl.cc
@@ -344,13 +344,13 @@ bool PlatformAudioImpl::Initialize(
client_ = client;
ViewHostMsg_Audio_CreateStream_Params params;
- params.format = AudioManager::AUDIO_PCM_LINEAR;
- params.channels = 2;
- params.sample_rate = sample_rate;
- params.bits_per_sample = 16;
+ params.params.format = AudioParameters::AUDIO_PCM_LINEAR;
+ params.params.channels = 2;
+ params.params.sample_rate = sample_rate;
+ params.params.bits_per_sample = 16;
- params.packet_size = sample_count * params.channels *
- (params.bits_per_sample >> 3);
+ params.packet_size = sample_count * params.params.channels *
+ (params.params.bits_per_sample >> 3);
stream_id_ = filter_->AddDelegate(this);
return filter_->Send(new ViewHostMsg_CreateAudioStream(0, stream_id_, params,