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

Unified Diff: media/audio/linux/alsa_output.cc

Issue 159380: Software volume control hook-up in linux. (Closed)
Patch Set: Created 11 years, 5 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
« no previous file with comments | « media/audio/linux/alsa_output.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/linux/alsa_output.cc
diff --git a/media/audio/linux/alsa_output.cc b/media/audio/linux/alsa_output.cc
index 08075defa344f6ec2ef8b515ad9047dbe4cb0335..67cb16a7ad54b471f3ac1984713f1fb131f336d9 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_);
fbarchard 2009/07/25 00:57:26 is this necessary for one variable?
+ 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_;
fbarchard 2009/07/25 00:57:26 nit - we should really get rid of this right_level
}
« no previous file with comments | « media/audio/linux/alsa_output.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698