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

Side by Side Diff: ash/system/win/audio/tray_audio_delegate_win.cc

Issue 720753003: Remove implicit conversions from scoped_refptr to T* in ash/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix formatting Created 6 years, 1 month 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 | « no previous file | no next file » | 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/win/audio/tray_audio_delegate_win.h" 5 #include "ash/system/win/audio/tray_audio_delegate_win.h"
6 6
7 #include <audiopolicy.h> 7 #include <audiopolicy.h>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "media/audio/win/core_audio_util_win.h" 10 #include "media/audio/win/core_audio_util_win.h"
(...skipping 18 matching lines...) Expand all
29 SetOutputVolumeLevel(kDefaultUnmuteVolumePercent); 29 SetOutputVolumeLevel(kDefaultUnmuteVolumePercent);
30 } 30 }
31 31
32 int TrayAudioDelegateWin::GetOutputDefaultVolumeMuteLevel() { 32 int TrayAudioDelegateWin::GetOutputDefaultVolumeMuteLevel() {
33 return kMuteThresholdPercent; 33 return kMuteThresholdPercent;
34 } 34 }
35 35
36 int TrayAudioDelegateWin::GetOutputVolumeLevel() { 36 int TrayAudioDelegateWin::GetOutputVolumeLevel() {
37 ScopedComPtr<ISimpleAudioVolume> volume_control = 37 ScopedComPtr<ISimpleAudioVolume> volume_control =
38 CreateDefaultVolumeControl(); 38 CreateDefaultVolumeControl();
39 if (!volume_control) 39 if (!volume_control.get())
40 return 0; 40 return 0;
41 41
42 float level = 0.0f; 42 float level = 0.0f;
43 if (FAILED(volume_control->GetMasterVolume(&level))) 43 if (FAILED(volume_control->GetMasterVolume(&level)))
44 return 0; 44 return 0;
45 45
46 // MSVC prior to 2013 doesn't have a round function. The below code is not 46 // MSVC prior to 2013 doesn't have a round function. The below code is not
47 // conformant to C99 round(), but since we know that 0 <= level <= 100, it 47 // conformant to C99 round(), but since we know that 0 <= level <= 100, it
48 // should be ok. 48 // should be ok.
49 return static_cast<int>(level + 0.5); 49 return static_cast<int>(level + 0.5);
50 } 50 }
51 51
52 int TrayAudioDelegateWin::GetActiveOutputDeviceIconId() { 52 int TrayAudioDelegateWin::GetActiveOutputDeviceIconId() {
53 return kNoAudioDeviceIcon; 53 return kNoAudioDeviceIcon;
54 } 54 }
55 55
56 bool TrayAudioDelegateWin::HasAlternativeSources() { 56 bool TrayAudioDelegateWin::HasAlternativeSources() {
57 return false; 57 return false;
58 } 58 }
59 59
60 bool TrayAudioDelegateWin::IsOutputAudioMuted() { 60 bool TrayAudioDelegateWin::IsOutputAudioMuted() {
61 ScopedComPtr<ISimpleAudioVolume> volume_control = 61 ScopedComPtr<ISimpleAudioVolume> volume_control =
62 CreateDefaultVolumeControl(); 62 CreateDefaultVolumeControl();
63 63
64 if (!volume_control) 64 if (!volume_control.get())
65 return false; 65 return false;
66 66
67 BOOL mute = FALSE; 67 BOOL mute = FALSE;
68 if (FAILED(volume_control->GetMute(&mute))) 68 if (FAILED(volume_control->GetMute(&mute)))
69 return false; 69 return false;
70 70
71 return !!mute; 71 return !!mute;
72 } 72 }
73 73
74 void TrayAudioDelegateWin::SetOutputAudioIsMuted(bool is_muted) { 74 void TrayAudioDelegateWin::SetOutputAudioIsMuted(bool is_muted) {
75 ScopedComPtr<ISimpleAudioVolume> volume_control = 75 ScopedComPtr<ISimpleAudioVolume> volume_control =
76 CreateDefaultVolumeControl(); 76 CreateDefaultVolumeControl();
77 77
78 if (!volume_control) 78 if (!volume_control.get())
79 return; 79 return;
80 80
81 volume_control->SetMute(is_muted, NULL); 81 volume_control->SetMute(is_muted, NULL);
82 } 82 }
83 83
84 void TrayAudioDelegateWin::SetOutputVolumeLevel(int level) { 84 void TrayAudioDelegateWin::SetOutputVolumeLevel(int level) {
85 ScopedComPtr<ISimpleAudioVolume> volume_control = 85 ScopedComPtr<ISimpleAudioVolume> volume_control =
86 CreateDefaultVolumeControl(); 86 CreateDefaultVolumeControl();
87 87
88 if (!volume_control) 88 if (!volume_control.get())
89 return; 89 return;
90 90
91 float volume_level = static_cast<float>(level) / 100.0f; 91 float volume_level = static_cast<float>(level) / 100.0f;
92 volume_control->SetMasterVolume(volume_level, NULL); 92 volume_control->SetMasterVolume(volume_level, NULL);
93 } 93 }
94 94
95 void TrayAudioDelegateWin::SetInternalSpeakerChannelMode( 95 void TrayAudioDelegateWin::SetInternalSpeakerChannelMode(
96 AudioChannelMode mode) { 96 AudioChannelMode mode) {
97 } 97 }
98 98
99 ScopedComPtr<ISimpleAudioVolume> 99 ScopedComPtr<ISimpleAudioVolume>
100 TrayAudioDelegateWin::CreateDefaultVolumeControl() { 100 TrayAudioDelegateWin::CreateDefaultVolumeControl() {
101 ScopedComPtr<ISimpleAudioVolume> volume_control; 101 ScopedComPtr<ISimpleAudioVolume> volume_control;
102 ScopedComPtr<IAudioSessionManager> session_manager; 102 ScopedComPtr<IAudioSessionManager> session_manager;
103 103
104 ScopedComPtr<IMMDevice> device = 104 ScopedComPtr<IMMDevice> device =
105 media::CoreAudioUtil::CreateDefaultDevice(eRender, eConsole); 105 media::CoreAudioUtil::CreateDefaultDevice(eRender, eConsole);
106 if (!device || 106 if (!device.get() ||
107 FAILED(device->Activate(__uuidof(IAudioSessionManager), CLSCTX_ALL, NULL, 107 FAILED(device->Activate(__uuidof(IAudioSessionManager), CLSCTX_ALL, NULL,
108 session_manager.ReceiveVoid()))) { 108 session_manager.ReceiveVoid()))) {
109 return volume_control; 109 return volume_control;
110 } 110 }
111 111
112 session_manager->GetSimpleAudioVolume(NULL, FALSE, 112 session_manager->GetSimpleAudioVolume(NULL, FALSE,
113 volume_control.Receive()); 113 volume_control.Receive());
114 114
115 return volume_control; 115 return volume_control;
116 } 116 }
117 117
118 } // namespace system 118 } // namespace system
119 } // namespace ash 119 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698