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

Side by Side Diff: ash/system/audio/tray_audio.cc

Issue 1199413008: Work around for HDMI audio output rediscovering transistion loss. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed to VLOG. Created 5 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/system/audio/tray_audio.h" 5 #include "ash/system/audio/tray_audio.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "ash/ash_constants.h" 9 #include "ash/ash_constants.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 131 }
132 132
133 void TrayAudio::OnActiveOutputNodeChanged() { 133 void TrayAudio::OnActiveOutputNodeChanged() {
134 Update(); 134 Update();
135 } 135 }
136 136
137 void TrayAudio::OnActiveInputNodeChanged() { 137 void TrayAudio::OnActiveInputNodeChanged() {
138 Update(); 138 Update();
139 } 139 }
140 140
141 void TrayAudio::ChangeInternalSpeakerChannelMode() {
142 // Swap left/right channel only if it is in Yoga mode.
143 system::TrayAudioDelegate::AudioChannelMode channel_mode =
144 system::TrayAudioDelegate::NORMAL;
145 if (gfx::Display::InternalDisplayId() != gfx::Display::kInvalidDisplayID) {
146 const DisplayInfo& display_info =
147 Shell::GetInstance()->display_manager()->GetDisplayInfo(
148 gfx::Display::InternalDisplayId());
149 if (display_info.GetActiveRotation() == gfx::Display::ROTATE_180)
150 channel_mode = system::TrayAudioDelegate::LEFT_RIGHT_SWAPPED;
151 }
152
153 audio_delegate_->SetInternalSpeakerChannelMode(channel_mode);
154 }
155
141 void TrayAudio::OnDisplayAdded(const gfx::Display& new_display) { 156 void TrayAudio::OnDisplayAdded(const gfx::Display& new_display) {
142 if (new_display.id() != gfx::Display::InternalDisplayId()) 157 if (new_display.id() != gfx::Display::InternalDisplayId())
143 return; 158 return;
144 ChangeInternalSpeakerChannelMode(); 159 ChangeInternalSpeakerChannelMode();
145 } 160 }
146 161
147 void TrayAudio::OnDisplayRemoved(const gfx::Display& old_display) { 162 void TrayAudio::OnDisplayRemoved(const gfx::Display& old_display) {
148 if (old_display.id() != gfx::Display::InternalDisplayId()) 163 if (old_display.id() != gfx::Display::InternalDisplayId())
149 return; 164 return;
150 ChangeInternalSpeakerChannelMode(); 165 ChangeInternalSpeakerChannelMode();
151 } 166 }
152 167
153 void TrayAudio::OnDisplayMetricsChanged(const gfx::Display& display, 168 void TrayAudio::OnDisplayMetricsChanged(const gfx::Display& display,
154 uint32_t changed_metrics) { 169 uint32_t changed_metrics) {
155 if (display.id() != gfx::Display::InternalDisplayId()) 170 if (display.id() != gfx::Display::InternalDisplayId())
156 return; 171 return;
157 172
158 if (changed_metrics & gfx::DisplayObserver::DISPLAY_METRIC_ROTATION) 173 if (changed_metrics & gfx::DisplayObserver::DISPLAY_METRIC_ROTATION)
159 ChangeInternalSpeakerChannelMode(); 174 ChangeInternalSpeakerChannelMode();
160 } 175 }
161 176
162 void TrayAudio::ChangeInternalSpeakerChannelMode() {
163 // Swap left/right channel only if it is in Yoga mode.
164 system::TrayAudioDelegate::AudioChannelMode channel_mode =
165 system::TrayAudioDelegate::NORMAL;
166 if (gfx::Display::InternalDisplayId() != gfx::Display::kInvalidDisplayID) {
167 const DisplayInfo& display_info =
168 Shell::GetInstance()->display_manager()->GetDisplayInfo(
169 gfx::Display::InternalDisplayId());
170 if (display_info.GetActiveRotation() == gfx::Display::ROTATE_180)
171 channel_mode = system::TrayAudioDelegate::LEFT_RIGHT_SWAPPED;
172 }
173
174 audio_delegate_->SetInternalSpeakerChannelMode(channel_mode);
175 }
176
177 void TrayAudio::Update() { 177 void TrayAudio::Update() {
178 if (tray_view()) 178 if (tray_view())
179 tray_view()->SetVisible(GetInitialVisibility()); 179 tray_view()->SetVisible(GetInitialVisibility());
180 if (volume_view_) { 180 if (volume_view_) {
181 volume_view_->SetVolumeLevel( 181 volume_view_->SetVolumeLevel(
182 static_cast<float>(audio_delegate_->GetOutputVolumeLevel()) / 100.0f); 182 static_cast<float>(audio_delegate_->GetOutputVolumeLevel()) / 100.0f);
183 volume_view_->Update(); 183 volume_view_->Update();
184 } 184 }
185 } 185 }
186 186
187 } // namespace ash 187 } // namespace ash
OLDNEW
« 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