niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
xians@webrtc.org | 3ab6dda | 2012-02-16 18:15:54 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
pbos@webrtc.org | 956aa7e | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 11 | #include "webrtc/voice_engine/voe_volume_control_impl.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 12 | |
pbos@webrtc.org | 956aa7e | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 13 | #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
| 14 | #include "webrtc/system_wrappers/interface/trace.h" |
| 15 | #include "webrtc/voice_engine/channel.h" |
| 16 | #include "webrtc/voice_engine/include/voe_errors.h" |
| 17 | #include "webrtc/voice_engine/output_mixer.h" |
| 18 | #include "webrtc/voice_engine/transmit_mixer.h" |
| 19 | #include "webrtc/voice_engine/voice_engine_impl.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 20 | |
| 21 | namespace webrtc { |
| 22 | |
| 23 | VoEVolumeControl* VoEVolumeControl::GetInterface(VoiceEngine* voiceEngine) |
| 24 | { |
| 25 | #ifndef WEBRTC_VOICE_ENGINE_VOLUME_CONTROL_API |
| 26 | return NULL; |
| 27 | #else |
| 28 | if (NULL == voiceEngine) |
| 29 | { |
| 30 | return NULL; |
| 31 | } |
tommi@webrtc.org | 0989fb7 | 2013-02-15 15:07:32 +0000 | [diff] [blame] | 32 | VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine); |
tommi@webrtc.org | a990e12 | 2012-04-26 15:28:22 +0000 | [diff] [blame] | 33 | s->AddRef(); |
| 34 | return s; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 35 | #endif |
| 36 | } |
| 37 | |
| 38 | #ifdef WEBRTC_VOICE_ENGINE_VOLUME_CONTROL_API |
| 39 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 40 | VoEVolumeControlImpl::VoEVolumeControlImpl(voe::SharedData* shared) |
| 41 | : _shared(shared) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 42 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 43 | WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | "VoEVolumeControlImpl::VoEVolumeControlImpl() - ctor"); |
| 45 | } |
| 46 | |
| 47 | VoEVolumeControlImpl::~VoEVolumeControlImpl() |
| 48 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 49 | WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 50 | "VoEVolumeControlImpl::~VoEVolumeControlImpl() - dtor"); |
| 51 | } |
| 52 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 53 | int VoEVolumeControlImpl::SetSpeakerVolume(unsigned int volume) |
| 54 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 55 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 56 | "SetSpeakerVolume(volume=%u)", volume); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 58 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 59 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 60 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 61 | return -1; |
| 62 | } |
| 63 | if (volume > kMaxVolumeLevel) |
| 64 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 65 | _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 66 | "SetSpeakerVolume() invalid argument"); |
| 67 | return -1; |
| 68 | } |
| 69 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 70 | uint32_t maxVol(0); |
| 71 | uint32_t spkrVol(0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 72 | |
| 73 | // scale: [0,kMaxVolumeLevel] -> [0,MaxSpeakerVolume] |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 74 | if (_shared->audio_device()->MaxSpeakerVolume(&maxVol) != 0) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 75 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 76 | _shared->SetLastError(VE_MIC_VOL_ERROR, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 77 | "SetSpeakerVolume() failed to get max volume"); |
| 78 | return -1; |
| 79 | } |
xians@webrtc.org | 3ab6dda | 2012-02-16 18:15:54 +0000 | [diff] [blame] | 80 | // Round the value and avoid floating computation. |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 81 | spkrVol = (uint32_t)((volume * maxVol + |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 82 | (int)(kMaxVolumeLevel / 2)) / (kMaxVolumeLevel)); |
| 83 | |
| 84 | // set the actual volume using the audio mixer |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 85 | if (_shared->audio_device()->SetSpeakerVolume(spkrVol) != 0) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 86 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 87 | _shared->SetLastError(VE_MIC_VOL_ERROR, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 88 | "SetSpeakerVolume() failed to set speaker volume"); |
| 89 | return -1; |
| 90 | } |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | int VoEVolumeControlImpl::GetSpeakerVolume(unsigned int& volume) |
| 95 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 96 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 97 | "GetSpeakerVolume()"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 98 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 99 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 100 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 101 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 102 | return -1; |
| 103 | } |
| 104 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 105 | uint32_t spkrVol(0); |
| 106 | uint32_t maxVol(0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 107 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 108 | if (_shared->audio_device()->SpeakerVolume(&spkrVol) != 0) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 109 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 110 | _shared->SetLastError(VE_GET_MIC_VOL_ERROR, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 111 | "GetSpeakerVolume() unable to get speaker volume"); |
| 112 | return -1; |
| 113 | } |
| 114 | |
| 115 | // scale: [0, MaxSpeakerVolume] -> [0, kMaxVolumeLevel] |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 116 | if (_shared->audio_device()->MaxSpeakerVolume(&maxVol) != 0) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 117 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 118 | _shared->SetLastError(VE_GET_MIC_VOL_ERROR, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 119 | "GetSpeakerVolume() unable to get max speaker volume"); |
| 120 | return -1; |
| 121 | } |
xians@webrtc.org | 3ab6dda | 2012-02-16 18:15:54 +0000 | [diff] [blame] | 122 | // Round the value and avoid floating computation. |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 123 | volume = (uint32_t) ((spkrVol * kMaxVolumeLevel + |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 124 | (int)(maxVol / 2)) / (maxVol)); |
| 125 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 126 | WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, |
| 127 | VoEId(_shared->instance_id(), -1), |
| 128 | "GetSpeakerVolume() => volume=%d", volume); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 129 | return 0; |
| 130 | } |
| 131 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 132 | int VoEVolumeControlImpl::SetMicVolume(unsigned int volume) |
| 133 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 134 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 135 | "SetMicVolume(volume=%u)", volume); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 136 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 137 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 138 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 139 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 140 | return -1; |
| 141 | } |
| 142 | if (volume > kMaxVolumeLevel) |
| 143 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 144 | _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 145 | "SetMicVolume() invalid argument"); |
| 146 | return -1; |
| 147 | } |
| 148 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 149 | uint32_t maxVol(0); |
| 150 | uint32_t micVol(0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 151 | |
| 152 | // scale: [0, kMaxVolumeLevel] -> [0,MaxMicrophoneVolume] |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 153 | if (_shared->audio_device()->MaxMicrophoneVolume(&maxVol) != 0) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 154 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 155 | _shared->SetLastError(VE_MIC_VOL_ERROR, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 156 | "SetMicVolume() failed to get max volume"); |
| 157 | return -1; |
| 158 | } |
xians@webrtc.org | 3ab6dda | 2012-02-16 18:15:54 +0000 | [diff] [blame] | 159 | |
| 160 | if (volume == kMaxVolumeLevel) { |
| 161 | // On Linux running pulse, users are able to set the volume above 100% |
| 162 | // through the volume control panel, where the +100% range is digital |
| 163 | // scaling. WebRTC does not support setting the volume above 100%, and |
| 164 | // simply ignores changing the volume if the user tries to set it to |
| 165 | // |kMaxVolumeLevel| while the current volume is higher than |maxVol|. |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 166 | if (_shared->audio_device()->MicrophoneVolume(&micVol) != 0) { |
| 167 | _shared->SetLastError(VE_GET_MIC_VOL_ERROR, kTraceError, |
xians@webrtc.org | 3ab6dda | 2012-02-16 18:15:54 +0000 | [diff] [blame] | 168 | "SetMicVolume() unable to get microphone volume"); |
| 169 | return -1; |
| 170 | } |
| 171 | if (micVol >= maxVol) |
| 172 | return 0; |
| 173 | } |
| 174 | |
| 175 | // Round the value and avoid floating point computation. |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 176 | micVol = (uint32_t) ((volume * maxVol + |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 177 | (int)(kMaxVolumeLevel / 2)) / (kMaxVolumeLevel)); |
| 178 | |
xians@webrtc.org | 3ab6dda | 2012-02-16 18:15:54 +0000 | [diff] [blame] | 179 | // set the actual volume using the audio mixer |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 180 | if (_shared->audio_device()->SetMicrophoneVolume(micVol) != 0) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 181 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 182 | _shared->SetLastError(VE_MIC_VOL_ERROR, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 183 | "SetMicVolume() failed to set mic volume"); |
| 184 | return -1; |
| 185 | } |
| 186 | return 0; |
| 187 | } |
| 188 | |
| 189 | int VoEVolumeControlImpl::GetMicVolume(unsigned int& volume) |
| 190 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 191 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 192 | "GetMicVolume()"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 193 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 194 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 195 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 196 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 197 | return -1; |
| 198 | } |
| 199 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 200 | uint32_t micVol(0); |
| 201 | uint32_t maxVol(0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 202 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 203 | if (_shared->audio_device()->MicrophoneVolume(&micVol) != 0) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 204 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 205 | _shared->SetLastError(VE_GET_MIC_VOL_ERROR, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 206 | "GetMicVolume() unable to get microphone volume"); |
| 207 | return -1; |
| 208 | } |
| 209 | |
xians@webrtc.org | 3ab6dda | 2012-02-16 18:15:54 +0000 | [diff] [blame] | 210 | // scale: [0, MaxMicrophoneVolume] -> [0, kMaxVolumeLevel] |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 211 | if (_shared->audio_device()->MaxMicrophoneVolume(&maxVol) != 0) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 212 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 213 | _shared->SetLastError(VE_GET_MIC_VOL_ERROR, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 214 | "GetMicVolume() unable to get max microphone volume"); |
| 215 | return -1; |
| 216 | } |
xians@webrtc.org | 3ab6dda | 2012-02-16 18:15:54 +0000 | [diff] [blame] | 217 | if (micVol < maxVol) { |
| 218 | // Round the value and avoid floating point calculation. |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 219 | volume = (uint32_t) ((micVol * kMaxVolumeLevel + |
xians@webrtc.org | 3ab6dda | 2012-02-16 18:15:54 +0000 | [diff] [blame] | 220 | (int)(maxVol / 2)) / (maxVol)); |
| 221 | } else { |
| 222 | // Truncate the value to the kMaxVolumeLevel. |
| 223 | volume = kMaxVolumeLevel; |
| 224 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 225 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 226 | WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, |
| 227 | VoEId(_shared->instance_id(), -1), |
| 228 | "GetMicVolume() => volume=%d", volume); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 229 | return 0; |
| 230 | } |
| 231 | |
| 232 | int VoEVolumeControlImpl::SetInputMute(int channel, bool enable) |
| 233 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 234 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 235 | "SetInputMute(channel=%d, enable=%d)", channel, enable); |
| 236 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 237 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 238 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 239 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 240 | return -1; |
| 241 | } |
| 242 | if (channel == -1) |
| 243 | { |
| 244 | // Mute before demultiplexing <=> affects all channels |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 245 | return _shared->transmit_mixer()->SetMute(enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 246 | } |
pbos@webrtc.org | 0e65fda | 2014-03-21 10:26:42 +0000 | [diff] [blame] | 247 | // Mute after demultiplexing <=> affects one channel only |
| 248 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 249 | voe::Channel* channelPtr = ch.channel(); |
| 250 | if (channelPtr == NULL) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 251 | { |
pbos@webrtc.org | 0e65fda | 2014-03-21 10:26:42 +0000 | [diff] [blame] | 252 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 253 | "SetInputMute() failed to locate channel"); |
| 254 | return -1; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 255 | } |
pbos@webrtc.org | 0e65fda | 2014-03-21 10:26:42 +0000 | [diff] [blame] | 256 | return channelPtr->SetMute(enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | int VoEVolumeControlImpl::GetInputMute(int channel, bool& enabled) |
| 260 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 261 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 262 | "GetInputMute(channel=%d)", channel); |
| 263 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 264 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 265 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 266 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 267 | return -1; |
| 268 | } |
| 269 | if (channel == -1) |
| 270 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 271 | enabled = _shared->transmit_mixer()->Mute(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 272 | } |
| 273 | else |
| 274 | { |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 275 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 276 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 277 | if (channelPtr == NULL) |
| 278 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 279 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 280 | "SetInputMute() failed to locate channel"); |
| 281 | return -1; |
| 282 | } |
| 283 | enabled = channelPtr->Mute(); |
| 284 | } |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 285 | WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, |
| 286 | VoEId(_shared->instance_id(), -1), |
| 287 | "GetInputMute() => enabled = %d", (int)enabled); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 288 | return 0; |
| 289 | } |
| 290 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 291 | int VoEVolumeControlImpl::GetSpeechInputLevel(unsigned int& level) |
| 292 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 293 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 294 | "GetSpeechInputLevel()"); |
zakkhoyt@google.com | 630504f | 2011-07-13 20:06:58 +0000 | [diff] [blame] | 295 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 296 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 297 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 298 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 299 | return -1; |
| 300 | } |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 301 | int8_t currentLevel = _shared->transmit_mixer()->AudioLevel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 302 | level = static_cast<unsigned int> (currentLevel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 303 | WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, |
| 304 | VoEId(_shared->instance_id(), -1), |
| 305 | "GetSpeechInputLevel() => %d", level); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 306 | return 0; |
| 307 | } |
| 308 | |
| 309 | int VoEVolumeControlImpl::GetSpeechOutputLevel(int channel, |
| 310 | unsigned int& level) |
| 311 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 312 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
zakkhoyt@google.com | 630504f | 2011-07-13 20:06:58 +0000 | [diff] [blame] | 313 | "GetSpeechOutputLevel(channel=%d, level=?)", channel); |
henrika@webrtc.org | f383a1b | 2014-05-14 11:51:45 +0000 | [diff] [blame] | 314 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 315 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 316 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 317 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 318 | return -1; |
| 319 | } |
| 320 | if (channel == -1) |
| 321 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 322 | return _shared->output_mixer()->GetSpeechOutputLevel( |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 323 | (uint32_t&)level); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 324 | } |
| 325 | else |
| 326 | { |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 327 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 328 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 329 | if (channelPtr == NULL) |
| 330 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 331 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 332 | "GetSpeechOutputLevel() failed to locate channel"); |
| 333 | return -1; |
| 334 | } |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 335 | channelPtr->GetSpeechOutputLevel((uint32_t&)level); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 336 | } |
| 337 | return 0; |
| 338 | } |
| 339 | |
| 340 | int VoEVolumeControlImpl::GetSpeechInputLevelFullRange(unsigned int& level) |
| 341 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 342 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 343 | "GetSpeechInputLevelFullRange(level=?)"); |
zakkhoyt@google.com | 5e26663 | 2011-07-15 18:21:34 +0000 | [diff] [blame] | 344 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 345 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 346 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 347 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 348 | return -1; |
| 349 | } |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 350 | int16_t currentLevel = _shared->transmit_mixer()-> |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 351 | AudioLevelFullRange(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 352 | level = static_cast<unsigned int> (currentLevel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 353 | WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, |
| 354 | VoEId(_shared->instance_id(), -1), |
| 355 | "GetSpeechInputLevelFullRange() => %d", level); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 356 | return 0; |
| 357 | } |
| 358 | |
| 359 | int VoEVolumeControlImpl::GetSpeechOutputLevelFullRange(int channel, |
| 360 | unsigned int& level) |
| 361 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 362 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 363 | "GetSpeechOutputLevelFullRange(channel=%d, level=?)", channel); |
zakkhoyt@google.com | 5e26663 | 2011-07-15 18:21:34 +0000 | [diff] [blame] | 364 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 365 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 366 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 367 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 368 | return -1; |
| 369 | } |
| 370 | if (channel == -1) |
| 371 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 372 | return _shared->output_mixer()->GetSpeechOutputLevelFullRange( |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 373 | (uint32_t&)level); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 374 | } |
| 375 | else |
| 376 | { |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 377 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 378 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 379 | if (channelPtr == NULL) |
| 380 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 381 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 382 | "GetSpeechOutputLevelFullRange() failed to locate channel"); |
| 383 | return -1; |
| 384 | } |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 385 | channelPtr->GetSpeechOutputLevelFullRange((uint32_t&)level); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 386 | } |
| 387 | return 0; |
| 388 | } |
| 389 | |
| 390 | int VoEVolumeControlImpl::SetChannelOutputVolumeScaling(int channel, |
| 391 | float scaling) |
| 392 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 393 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 394 | "SetChannelOutputVolumeScaling(channel=%d, scaling=%3.2f)", |
| 395 | channel, scaling); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 396 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 397 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 398 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 399 | return -1; |
| 400 | } |
| 401 | if (scaling < kMinOutputVolumeScaling || |
| 402 | scaling > kMaxOutputVolumeScaling) |
| 403 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 404 | _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 405 | "SetChannelOutputVolumeScaling() invalid parameter"); |
| 406 | return -1; |
| 407 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 408 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 409 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 410 | if (channelPtr == NULL) |
| 411 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 412 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 413 | "SetChannelOutputVolumeScaling() failed to locate channel"); |
| 414 | return -1; |
| 415 | } |
| 416 | return channelPtr->SetChannelOutputVolumeScaling(scaling); |
| 417 | } |
| 418 | |
| 419 | int VoEVolumeControlImpl::GetChannelOutputVolumeScaling(int channel, |
| 420 | float& scaling) |
| 421 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 422 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 423 | "GetChannelOutputVolumeScaling(channel=%d, scaling=?)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 424 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 425 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 426 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 427 | return -1; |
| 428 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 429 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 430 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 431 | if (channelPtr == NULL) |
| 432 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 433 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 434 | "GetChannelOutputVolumeScaling() failed to locate channel"); |
| 435 | return -1; |
| 436 | } |
| 437 | return channelPtr->GetChannelOutputVolumeScaling(scaling); |
| 438 | } |
| 439 | |
| 440 | int VoEVolumeControlImpl::SetOutputVolumePan(int channel, |
| 441 | float left, |
| 442 | float right) |
| 443 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 444 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 445 | "SetOutputVolumePan(channel=%d, left=%2.1f, right=%2.1f)", |
| 446 | channel, left, right); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 447 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 448 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 449 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 450 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 451 | return -1; |
| 452 | } |
| 453 | |
| 454 | bool available(false); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 455 | _shared->audio_device()->StereoPlayoutIsAvailable(&available); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 456 | if (!available) |
| 457 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 458 | _shared->SetLastError(VE_FUNC_NO_STEREO, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 459 | "SetOutputVolumePan() stereo playout not supported"); |
| 460 | return -1; |
| 461 | } |
| 462 | if ((left < kMinOutputVolumePanning) || |
| 463 | (left > kMaxOutputVolumePanning) || |
| 464 | (right < kMinOutputVolumePanning) || |
| 465 | (right > kMaxOutputVolumePanning)) |
| 466 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 467 | _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 468 | "SetOutputVolumePan() invalid parameter"); |
| 469 | return -1; |
| 470 | } |
| 471 | |
| 472 | if (channel == -1) |
| 473 | { |
| 474 | // Master balance (affectes the signal after output mixing) |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 475 | return _shared->output_mixer()->SetOutputVolumePan(left, right); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 476 | } |
pbos@webrtc.org | 0e65fda | 2014-03-21 10:26:42 +0000 | [diff] [blame] | 477 | // Per-channel balance (affects the signal before output mixing) |
| 478 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 479 | voe::Channel* channelPtr = ch.channel(); |
| 480 | if (channelPtr == NULL) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 481 | { |
pbos@webrtc.org | 0e65fda | 2014-03-21 10:26:42 +0000 | [diff] [blame] | 482 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 483 | "SetOutputVolumePan() failed to locate channel"); |
| 484 | return -1; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 485 | } |
pbos@webrtc.org | 0e65fda | 2014-03-21 10:26:42 +0000 | [diff] [blame] | 486 | return channelPtr->SetOutputVolumePan(left, right); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 487 | } |
| 488 | |
| 489 | int VoEVolumeControlImpl::GetOutputVolumePan(int channel, |
| 490 | float& left, |
| 491 | float& right) |
| 492 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 493 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 494 | "GetOutputVolumePan(channel=%d, left=?, right=?)", channel); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 495 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 496 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 497 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 498 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 499 | return -1; |
| 500 | } |
| 501 | |
| 502 | bool available(false); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 503 | _shared->audio_device()->StereoPlayoutIsAvailable(&available); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 504 | if (!available) |
| 505 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 506 | _shared->SetLastError(VE_FUNC_NO_STEREO, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 507 | "GetOutputVolumePan() stereo playout not supported"); |
| 508 | return -1; |
| 509 | } |
| 510 | |
| 511 | if (channel == -1) |
| 512 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 513 | return _shared->output_mixer()->GetOutputVolumePan(left, right); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 514 | } |
pbos@webrtc.org | 0e65fda | 2014-03-21 10:26:42 +0000 | [diff] [blame] | 515 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 516 | voe::Channel* channelPtr = ch.channel(); |
| 517 | if (channelPtr == NULL) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 518 | { |
pbos@webrtc.org | 0e65fda | 2014-03-21 10:26:42 +0000 | [diff] [blame] | 519 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 520 | "GetOutputVolumePan() failed to locate channel"); |
| 521 | return -1; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 522 | } |
pbos@webrtc.org | 0e65fda | 2014-03-21 10:26:42 +0000 | [diff] [blame] | 523 | return channelPtr->GetOutputVolumePan(left, right); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | #endif // #ifdef WEBRTC_VOICE_ENGINE_VOLUME_CONTROL_API |
| 527 | |
| 528 | } // namespace webrtc |