OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "media/audio/win/wavein_input_win.h" | 5 #include "media/audio/win/wavein_input_win.h" |
6 | 6 |
7 #pragma comment(lib, "winmm.lib") | 7 #pragma comment(lib, "winmm.lib") |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "media/audio/audio_io.h" | 10 #include "media/audio/audio_io.h" |
11 #include "media/audio/win/audio_manager_win.h" | 11 #include "media/audio/win/audio_manager_win.h" |
12 #include "media/audio/win/device_enumeration_win.h" | 12 #include "media/audio/win/device_enumeration_win.h" |
13 #include "media/base/audio_bus.h" | 13 #include "media/base/audio_bus.h" |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 | 16 |
17 // Our sound buffers are allocated once and kept in a linked list using the | 17 // Our sound buffers are allocated once and kept in a linked list using the |
18 // the WAVEHDR::dwUser variable. The last buffer points to the first buffer. | 18 // the WAVEHDR::dwUser variable. The last buffer points to the first buffer. |
19 static WAVEHDR* GetNextBuffer(WAVEHDR* current) { | 19 static WAVEHDR* GetNextBuffer(WAVEHDR* current) { |
20 return reinterpret_cast<WAVEHDR*>(current->dwUser); | 20 return reinterpret_cast<WAVEHDR*>(current->dwUser); |
21 } | 21 } |
22 | 22 |
23 PCMWaveInAudioInputStream::PCMWaveInAudioInputStream( | 23 PCMWaveInAudioInputStream::PCMWaveInAudioInputStream( |
24 AudioManagerWin* manager, | 24 AudioManagerWin* manager, |
25 const AudioParameters& params, | 25 const AudioParameters& params, |
26 int num_buffers, | 26 int num_buffers, |
27 const std::string& device_id) | 27 const std::string& device_id) |
28 : state_(kStateEmpty), | 28 : state_(kStateEmpty), |
29 manager_(manager), | 29 manager_(manager), |
| 30 callback_(NULL), |
| 31 num_buffers_(num_buffers), |
| 32 channels_(params.channels()), |
30 device_id_(device_id), | 33 device_id_(device_id), |
31 wavein_(NULL), | 34 wavein_(NULL), |
32 callback_(NULL), | |
33 num_buffers_(num_buffers), | |
34 buffer_(NULL), | 35 buffer_(NULL), |
35 channels_(params.channels()), | |
36 audio_bus_(media::AudioBus::Create(params)) { | 36 audio_bus_(media::AudioBus::Create(params)) { |
37 DCHECK_GT(num_buffers_, 0); | 37 DCHECK_GT(num_buffers_, 0); |
38 format_.wFormatTag = WAVE_FORMAT_PCM; | 38 format_.wFormatTag = WAVE_FORMAT_PCM; |
39 format_.nChannels = params.channels() > 2 ? 2 : params.channels(); | 39 format_.nChannels = params.channels() > 2 ? 2 : params.channels(); |
40 format_.nSamplesPerSec = params.sample_rate(); | 40 format_.nSamplesPerSec = params.sample_rate(); |
41 format_.wBitsPerSample = params.bits_per_sample(); | 41 format_.wBitsPerSample = params.bits_per_sample(); |
42 format_.cbSize = 0; | 42 format_.cbSize = 0; |
43 format_.nBlockAlign = (format_.nChannels * format_.wBitsPerSample) / 8; | 43 format_.nBlockAlign = (format_.nChannels * format_.wBitsPerSample) / 8; |
44 format_.nAvgBytesPerSec = format_.nBlockAlign * format_.nSamplesPerSec; | 44 format_.nAvgBytesPerSec = format_.nBlockAlign * format_.nSamplesPerSec; |
45 buffer_size_ = params.frames_per_buffer() * format_.nBlockAlign; | 45 buffer_size_ = params.frames_per_buffer() * format_.nBlockAlign; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 ::SetEvent(obj->stopped_event_.Get()); | 317 ::SetEvent(obj->stopped_event_.Get()); |
318 } | 318 } |
319 } else if (msg == WIM_CLOSE) { | 319 } else if (msg == WIM_CLOSE) { |
320 // Intentionaly no-op for now. | 320 // Intentionaly no-op for now. |
321 } else if (msg == WIM_OPEN) { | 321 } else if (msg == WIM_OPEN) { |
322 // Intentionaly no-op for now. | 322 // Intentionaly no-op for now. |
323 } | 323 } |
324 } | 324 } |
325 | 325 |
326 } // namespace media | 326 } // namespace media |
OLD | NEW |