diff options
author | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-25 01:01:45 +0000 |
---|---|---|
committer | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-25 01:01:45 +0000 |
commit | 97b3aef453bcfa1771bebcd68d8bc76a6c113826 (patch) | |
tree | e0178ccfb1db0bcf83aa56c18b19b41ad54bc5e8 /media | |
parent | badb5c8278eb9d4f8fa958a71e52d9155f75d9df (diff) | |
download | chromium_src-97b3aef453bcfa1771bebcd68d8bc76a6c113826.zip chromium_src-97b3aef453bcfa1771bebcd68d8bc76a6c113826.tar.gz chromium_src-97b3aef453bcfa1771bebcd68d8bc76a6c113826.tar.bz2 |
Software volume control hook-up in linux.
BUG=17709
TEST=None
Review URL: http://codereview.chromium.org/159380
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21602 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/audio/linux/alsa_output.cc | 14 | ||||
-rw-r--r-- | media/audio/linux/alsa_output.h | 3 |
2 files changed, 14 insertions, 3 deletions
diff --git a/media/audio/linux/alsa_output.cc b/media/audio/linux/alsa_output.cc index 08075de..67cb16a 100644 --- a/media/audio/linux/alsa_output.cc +++ b/media/audio/linux/alsa_output.cc @@ -55,6 +55,7 @@ #include "base/logging.h" #include "base/stl_util-inl.h" #include "base/time.h" +#include "media/audio/audio_util.h" // Require 10ms latency from the audio device. Taken from ALSA documentation // example. @@ -89,7 +90,8 @@ AlsaPCMOutputStream::AlsaPCMOutputStream(const std::string& device_name, base::Time::kMillisecondsPerSecond), packet_size_(0), device_write_suspended_(true), // Start suspended. - resources_released_(false) { + resources_released_(false), + volume_(1.0) { // Reference self to avoid accidental deletion before the message loop is // done. AddRef(); @@ -407,6 +409,9 @@ void AlsaPCMOutputStream::BufferPackets() { packet->capacity); CHECK(used <= capacity) << "Data source overran buffer. Aborting."; packet->size = used; + media::AdjustVolume(packet->buffer.get(), packet->size, + channels_, bits_per_sample_ >> 3, + volume_); // TODO(ajwong): Do more buffer validation here, like checking that the // packet is correctly aligned to frames, etc. } @@ -521,9 +526,12 @@ void AlsaPCMOutputStream::FillAlsaDeviceBuffer() { } void AlsaPCMOutputStream::SetVolume(double left_level, double right_level) { - NOTIMPLEMENTED(); + AutoLock l(lock_); + volume_ = static_cast<float>(left_level); } void AlsaPCMOutputStream::GetVolume(double* left_level, double* right_level) { - NOTIMPLEMENTED(); + AutoLock l(lock_); + *left_level = volume_; + *right_level = volume_; } diff --git a/media/audio/linux/alsa_output.h b/media/audio/linux/alsa_output.h index 850ab7f..2b619c0 100644 --- a/media/audio/linux/alsa_output.h +++ b/media/audio/linux/alsa_output.h @@ -159,6 +159,9 @@ class AlsaPCMOutputStream : // Flag indicating that the resources are already cleaned. bool resources_released_; + // Volume level from 0 to 1. + float volume_; + DISALLOW_COPY_AND_ASSIGN(AlsaPCMOutputStream); }; |