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" |
(...skipping 17 matching lines...) Expand all Loading... | |
28 AudioManagerWin* manager, const AudioParameters& params, int num_buffers, | 28 AudioManagerWin* manager, const AudioParameters& params, int num_buffers, |
29 const std::string& device_id) | 29 const std::string& device_id) |
30 : state_(kStateEmpty), | 30 : state_(kStateEmpty), |
31 manager_(manager), | 31 manager_(manager), |
32 device_id_(device_id), | 32 device_id_(device_id), |
33 wavein_(NULL), | 33 wavein_(NULL), |
34 callback_(NULL), | 34 callback_(NULL), |
35 num_buffers_(num_buffers), | 35 num_buffers_(num_buffers), |
36 buffer_(NULL), | 36 buffer_(NULL), |
37 channels_(params.channels()) { | 37 channels_(params.channels()) { |
38 DCHECK(num_buffers_ > 0); | |
James Hawkins
2012/07/26 17:20:27
DCHECK_LE(0, num_buffers_)
| |
38 format_.wFormatTag = WAVE_FORMAT_PCM; | 39 format_.wFormatTag = WAVE_FORMAT_PCM; |
39 format_.nChannels = params.channels() > 2 ? 2 : params.channels(); | 40 format_.nChannels = params.channels() > 2 ? 2 : params.channels(); |
40 format_.nSamplesPerSec = params.sample_rate(); | 41 format_.nSamplesPerSec = params.sample_rate(); |
41 format_.wBitsPerSample = params.bits_per_sample(); | 42 format_.wBitsPerSample = params.bits_per_sample(); |
42 format_.cbSize = 0; | 43 format_.cbSize = 0; |
43 format_.nBlockAlign = (format_.nChannels * format_.wBitsPerSample) / 8; | 44 format_.nBlockAlign = (format_.nChannels * format_.wBitsPerSample) / 8; |
44 format_.nAvgBytesPerSec = format_.nBlockAlign * format_.nSamplesPerSec; | 45 format_.nAvgBytesPerSec = format_.nBlockAlign * format_.nSamplesPerSec; |
45 buffer_size_ = params.frames_per_buffer() * format_.nBlockAlign; | 46 buffer_size_ = params.frames_per_buffer() * format_.nBlockAlign; |
46 // If we don't have a packet size we use 100ms. | 47 // If we don't have a packet size we use 100ms. |
47 if (!buffer_size_) | 48 if (!buffer_size_) |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 } | 293 } |
293 } else if (msg == WIM_CLOSE) { | 294 } else if (msg == WIM_CLOSE) { |
294 // We can be closed before calling Start, so it is possible to have a | 295 // We can be closed before calling Start, so it is possible to have a |
295 // null callback at this point. | 296 // null callback at this point. |
296 if (obj->callback_) | 297 if (obj->callback_) |
297 obj->callback_->OnClose(obj); | 298 obj->callback_->OnClose(obj); |
298 } | 299 } |
299 } | 300 } |
300 | 301 |
301 } // namespace media | 302 } // namespace media |
OLD | NEW |