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

Side by Side Diff: remoting/host/win/audio_volume_applier_win.cc

Issue 2840773004: [Chromoting] Add AudioVolumeApplier to reduce the complexity and the dependency of kChannels (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "remoting/host/win/audio_volume_applier_win.h"
6
7 #include "base/logging.h"
8
9 namespace remoting {
10
11 AudioVolumeApplierWin::AudioVolumeApplierWin(int silence_threshold)
12 : AudioVolumeApplier(silence_threshold) {}
13 AudioVolumeApplierWin::~AudioVolumeApplierWin() = default;
14
15 bool AudioVolumeApplierWin::ActivateBy(IMMDevice* mm_device) {
16 DCHECK(mm_device);
17 audio_volume_.Reset();
18 // TODO(zijiehe): Do we need to control the volume per process?
19 HRESULT hr = mm_device->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL,
20 nullptr, audio_volume_.ReceiveVoid());
21 if (FAILED(hr)) {
22 LOG(WARNING) << "Failed to get an IAudioEndpointVolume. Error " << hr;
23 return false;
24 }
25 return true;
26 }
27
28 float AudioVolumeApplierWin::GetAudioLevel() {
29 if (!audio_volume_) {
30 return 1;
31 }
32
33 BOOL mute;
34 HRESULT hr = audio_volume_->GetMute(&mute);
35 if (FAILED(hr)) {
36 LOG(ERROR) << "Failed to get mute status from IAudioEndpointVolume, error "
37 << hr;
38 return 1;
39 }
40 if (mute) {
41 return 0;
42 }
43
44 float level;
45 hr = audio_volume_->GetMasterVolumeLevelScalar(&level);
46 if (FAILED(hr) || level > 1) {
47 LOG(ERROR) << "Failed to get master volume from IAudioEndpointVolume, "
48 "error "
49 << hr;
50 return 1;
51 }
52 if (level < 0) {
53 return 0;
54 }
55 return level;
56 }
57
58 } // namespace remoting
OLDNEW
« remoting/host/audio_volume_applier.cc ('K') | « remoting/host/win/audio_volume_applier_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698