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

Unified Diff: ash/system/audio/tray_audio.cc

Issue 620673002: Flip the left/right speaker when the device is in yoga mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Swap the internal speaker left/right channel regardless of active node. Created 6 years, 3 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 | « ash/system/audio/tray_audio.h ('k') | ash/system/audio/tray_audio_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/audio/tray_audio.cc
diff --git a/ash/system/audio/tray_audio.cc b/ash/system/audio/tray_audio.cc
index a3b32ca96a822b0a1d33de7e9fb6b443055391d9..b860ec1846ceba090a0bfecabb7036af43448e9b 100644
--- a/ash/system/audio/tray_audio.cc
+++ b/ash/system/audio/tray_audio.cc
@@ -7,6 +7,7 @@
#include <cmath>
#include "ash/ash_constants.h"
+#include "ash/display/display_manager.h"
#include "ash/metrics/user_metrics_recorder.h"
#include "ash/shell.h"
#include "ash/system/audio/tray_audio_delegate.h"
@@ -26,6 +27,7 @@
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
#include "ui/gfx/canvas.h"
+#include "ui/gfx/display.h"
#include "ui/gfx/font_list.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia_operations.h"
@@ -45,9 +47,11 @@ TrayAudio::TrayAudio(SystemTray* system_tray,
volume_view_(NULL),
pop_up_volume_view_(false) {
Shell::GetInstance()->system_tray_notifier()->AddAudioObserver(this);
+ Shell::GetScreen()->AddObserver(this);
}
TrayAudio::~TrayAudio() {
+ Shell::GetScreen()->RemoveObserver(this);
Shell::GetInstance()->system_tray_notifier()->RemoveAudioObserver(this);
}
@@ -133,6 +137,39 @@ void TrayAudio::OnActiveInputNodeChanged() {
Update();
}
+void TrayAudio::OnDisplayAdded(const gfx::Display& new_display) {
oshima 2014/10/01 21:53:55 you should do the same here, in case the device ca
jennyz 2014/10/01 22:03:50 Done.
+}
+
+void TrayAudio::OnDisplayRemoved(const gfx::Display& old_display) {
+ if (old_display.id() != gfx::Display::InternalDisplayId())
+ return;
+ ChangeInternalSpeakerChannelMode();
+}
+
+void TrayAudio::OnDisplayMetricsChanged(const gfx::Display& display,
+ uint32_t changed_metrics) {
+ if (display.id() != gfx::Display::InternalDisplayId())
+ return;
+
+ if (changed_metrics & gfx::DisplayObserver::DISPLAY_METRIC_ROTATION)
+ ChangeInternalSpeakerChannelMode();
+}
+
+void TrayAudio::ChangeInternalSpeakerChannelMode() {
+ // Swap left/right channel only if it is in Yoga mode.
+ system::TrayAudioDelegate::AudioChannelMode channel_mode =
+ system::TrayAudioDelegate::NORMAL;
+ if (gfx::Display::InternalDisplayId() != gfx::Display::kInvalidDisplayID) {
+ const DisplayInfo& display_info =
+ Shell::GetInstance()->display_manager()->GetDisplayInfo(
+ gfx::Display::InternalDisplayId());
+ if (display_info.rotation() == gfx::Display::ROTATE_180)
+ channel_mode = system::TrayAudioDelegate::LEFT_RIGHT_SWAPPED;
+ }
+
+ audio_delegate_->SetInternalSpeakerChannelMode(channel_mode);
+}
+
void TrayAudio::Update() {
if (tray_view())
tray_view()->SetVisible(GetInitialVisibility());
« no previous file with comments | « ash/system/audio/tray_audio.h ('k') | ash/system/audio/tray_audio_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698