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

Unified Diff: chromeos/audio/cras_audio_handler.cc

Issue 1845733002: cras_audio_handler add SetOutputMono method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: channels_ -> output_channels_ Created 4 years, 9 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 | « chromeos/audio/cras_audio_handler.h ('k') | chromeos/audio/cras_audio_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/audio/cras_audio_handler.cc
diff --git a/chromeos/audio/cras_audio_handler.cc b/chromeos/audio/cras_audio_handler.cc
index d008d8657792756c4f5995417fb8770780c47cf5..75a391d576dc3e3b9115c6e0364b61915c073516 100644
--- a/chromeos/audio/cras_audio_handler.cc
+++ b/chromeos/audio/cras_audio_handler.cc
@@ -34,6 +34,11 @@ const int kMuteThresholdPercent = 1;
// The duration of HDMI output re-discover grace period in milliseconds.
const int kHDMIRediscoverGracePeriodDurationInMs = 2000;
+// Mixer matrix, [0.5, 0.5; 0.5, 0.5]
+const std::vector<double> kStereoToMono = {0.5, 0.5, 0.5, 0.5};
+// Mixer matrix, [1, 0; 0, 1]
+const std::vector<double> kStereoToStereo = {1, 0, 0, 1};
+
static CrasAudioHandler* g_cras_audio_handler = NULL;
bool IsSameAudioDevice(const AudioDevice& a, const AudioDevice& b) {
@@ -88,6 +93,10 @@ void CrasAudioHandler::AudioObserver::OnActiveOutputNodeChanged() {
void CrasAudioHandler::AudioObserver::OnActiveInputNodeChanged() {
}
+void CrasAudioHandler::AudioObserver::OnOuputChannelRemixingChanged(
+ bool /* mono_on */) {
+}
+
// static
void CrasAudioHandler::Initialize(
scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler) {
@@ -328,6 +337,25 @@ void CrasAudioHandler::SwapInternalSpeakerLeftRightChannel(bool swap) {
}
}
+void CrasAudioHandler::SetOutputMono(bool mono_on) {
+ output_mono_on_ = mono_on;
+ if (mono_on) {
+ chromeos::DBusThreadManager::Get()->GetCrasAudioClient()->
+ SetGlobalOutputChannelRemix(output_channels_, kStereoToMono);
+ } else {
+ chromeos::DBusThreadManager::Get()->GetCrasAudioClient()->
+ SetGlobalOutputChannelRemix(output_channels_, kStereoToStereo);
+ }
+
+ FOR_EACH_OBSERVER(
+ AudioObserver, observers_,
+ OnOuputChannelRemixingChanged(mono_on));
+}
+
+bool CrasAudioHandler::IsOutputMonoEnabled() const {
+ return output_mono_on_;
+}
+
bool CrasAudioHandler::has_alternative_input() const {
return has_alternative_input_;
}
@@ -513,6 +541,8 @@ CrasAudioHandler::CrasAudioHandler(
has_alternative_input_(false),
has_alternative_output_(false),
output_mute_locked_(false),
+ output_channels_(2),
+ output_mono_on_(false),
log_errors_(false),
hdmi_rediscover_grace_period_duration_in_ms_(
kHDMIRediscoverGracePeriodDurationInMs),
« no previous file with comments | « chromeos/audio/cras_audio_handler.h ('k') | chromeos/audio/cras_audio_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698