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

Unified Diff: media/audio/win/audio_low_latency_input_win.cc

Issue 9221010: Adds support for 16kHz input sample rate and mono channel config. in WebRTC. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed more size_t Created 8 years, 11 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 | « media/audio/win/audio_low_latency_input_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/win/audio_low_latency_input_win.cc
diff --git a/media/audio/win/audio_low_latency_input_win.cc b/media/audio/win/audio_low_latency_input_win.cc
index c6bb0ed06ad94a9e25bdc78dcd63f7a66f79fcbd..95dd42552446685b69fa85e43b20f712aa63b8b0 100644
--- a/media/audio/win/audio_low_latency_input_win.cc
+++ b/media/audio/win/audio_low_latency_input_win.cc
@@ -184,6 +184,31 @@ void WASAPIAudioInputStream::Close() {
// static
double WASAPIAudioInputStream::HardwareSampleRate(ERole device_role) {
+ base::win::ScopedCoMem<WAVEFORMATEX> audio_engine_mix_format;
+ HRESULT hr = GetMixFormat(device_role, &audio_engine_mix_format);
+ if (FAILED(hr)) {
+ NOTREACHED() << "error code: " << hr;
+ return 0.0;
+ }
+
+ return static_cast<double>(audio_engine_mix_format->nSamplesPerSec);
+}
+
+// static
+uint32 WASAPIAudioInputStream::HardwareChannelCount(ERole device_role) {
+ base::win::ScopedCoMem<WAVEFORMATEX> audio_engine_mix_format;
+ HRESULT hr = GetMixFormat(device_role, &audio_engine_mix_format);
+ if (FAILED(hr)) {
+ NOTREACHED() << "error code: " << hr;
+ return 0;
+ }
+
+ return static_cast<uint32>(audio_engine_mix_format->nChannels);
+}
+
+// static
+HRESULT WASAPIAudioInputStream::GetMixFormat(ERole device_role,
+ WAVEFORMATEX** device_format) {
// It is assumed that this static method is called from a COM thread, i.e.,
// CoInitializeEx() is not called here to avoid STA/MTA conflicts.
ScopedComPtr<IMMDeviceEnumerator> enumerator;
@@ -192,10 +217,8 @@ double WASAPIAudioInputStream::HardwareSampleRate(ERole device_role) {
CLSCTX_INPROC_SERVER,
__uuidof(IMMDeviceEnumerator),
enumerator.ReceiveVoid());
- if (FAILED(hr)) {
- NOTREACHED() << "error code: " << hr;
- return 0.0;
- }
+ if (FAILED(hr))
+ return hr;
ScopedComPtr<IMMDevice> endpoint_device;
hr = enumerator->GetDefaultAudioEndpoint(eCapture,
@@ -206,7 +229,7 @@ double WASAPIAudioInputStream::HardwareSampleRate(ERole device_role) {
// (e.g. some audio cards that have inputs will still report them as
// "not found" when no mic is plugged into the input jack).
LOG(WARNING) << "No audio end point: " << std::hex << hr;
- return 0.0;
+ return hr;
}
ScopedComPtr<IAudioClient> audio_client;
@@ -214,19 +237,10 @@ double WASAPIAudioInputStream::HardwareSampleRate(ERole device_role) {
CLSCTX_INPROC_SERVER,
NULL,
audio_client.ReceiveVoid());
- if (FAILED(hr)) {
- NOTREACHED() << "error code: " << hr;
- return 0.0;
- }
+ if (SUCCEEDED(hr))
+ hr = audio_client->GetMixFormat(device_format);
- base::win::ScopedCoMem<WAVEFORMATEX> audio_engine_mix_format;
- hr = audio_client->GetMixFormat(&audio_engine_mix_format);
- if (FAILED(hr)) {
- NOTREACHED() << "error code: " << hr;
- return 0.0;
- }
-
- return static_cast<double>(audio_engine_mix_format->nSamplesPerSec);
+ return hr;
}
void WASAPIAudioInputStream::Run() {
« no previous file with comments | « media/audio/win/audio_low_latency_input_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698