| 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/waveout_output_win.h" | 5 #include "media/audio/win/waveout_output_win.h" |
| 6 | 6 |
| 7 #pragma comment(lib, "winmm.lib") | 7 #pragma comment(lib, "winmm.lib") |
| 8 | 8 |
| 9 #include "base/atomicops.h" | 9 #include "base/atomicops.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 return (sizeof(WAVEHDR) + buffer_size_ + 15u) & static_cast<size_t>(~15); | 68 return (sizeof(WAVEHDR) + buffer_size_ + 15u) & static_cast<size_t>(~15); |
| 69 } | 69 } |
| 70 | 70 |
| 71 inline WAVEHDR* PCMWaveOutAudioOutputStream::GetBuffer(int n) const { | 71 inline WAVEHDR* PCMWaveOutAudioOutputStream::GetBuffer(int n) const { |
| 72 DCHECK_GE(n, 0); | 72 DCHECK_GE(n, 0); |
| 73 DCHECK_LT(n, num_buffers_); | 73 DCHECK_LT(n, num_buffers_); |
| 74 return reinterpret_cast<WAVEHDR*>(&buffers_[n * BufferSize()]); | 74 return reinterpret_cast<WAVEHDR*>(&buffers_[n * BufferSize()]); |
| 75 } | 75 } |
| 76 | 76 |
| 77 PCMWaveOutAudioOutputStream::PCMWaveOutAudioOutputStream( | 77 PCMWaveOutAudioOutputStream::PCMWaveOutAudioOutputStream( |
| 78 AudioManagerWin* manager, const AudioParameters& params, int num_buffers, | 78 AudioManagerWin* manager, |
| 79 const AudioParameters& params, |
| 80 int num_buffers, |
| 79 UINT device_id) | 81 UINT device_id) |
| 80 : state_(PCMA_BRAND_NEW), | 82 : state_(PCMA_BRAND_NEW), |
| 81 manager_(manager), | 83 manager_(manager), |
| 82 device_id_(device_id), | |
| 83 waveout_(NULL), | |
| 84 callback_(NULL), | 84 callback_(NULL), |
| 85 num_buffers_(num_buffers), | 85 num_buffers_(num_buffers), |
| 86 buffer_size_(params.GetBytesPerBuffer()), | 86 buffer_size_(params.GetBytesPerBuffer()), |
| 87 volume_(1), | 87 volume_(1), |
| 88 channels_(params.channels()), | 88 channels_(params.channels()), |
| 89 pending_bytes_(0), | 89 pending_bytes_(0), |
| 90 device_id_(device_id), |
| 91 waveout_(NULL), |
| 90 waiting_handle_(NULL), | 92 waiting_handle_(NULL), |
| 91 audio_bus_(AudioBus::Create(params)) { | 93 audio_bus_(AudioBus::Create(params)) { |
| 92 format_.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; | 94 format_.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; |
| 93 format_.Format.nChannels = params.channels(); | 95 format_.Format.nChannels = params.channels(); |
| 94 format_.Format.nSamplesPerSec = params.sample_rate(); | 96 format_.Format.nSamplesPerSec = params.sample_rate(); |
| 95 format_.Format.wBitsPerSample = params.bits_per_sample(); | 97 format_.Format.wBitsPerSample = params.bits_per_sample(); |
| 96 format_.Format.cbSize = sizeof(format_) - sizeof(WAVEFORMATEX); | 98 format_.Format.cbSize = sizeof(format_) - sizeof(WAVEFORMATEX); |
| 97 // The next are computed from above. | 99 // The next are computed from above. |
| 98 format_.Format.nBlockAlign = (format_.Format.nChannels * | 100 format_.Format.nBlockAlign = (format_.Format.nChannels * |
| 99 format_.Format.wBitsPerSample) / 8; | 101 format_.Format.wBitsPerSample) / 8; |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 buffer, | 388 buffer, |
| 387 sizeof(WAVEHDR)); | 389 sizeof(WAVEHDR)); |
| 388 if (result != MMSYSERR_NOERROR) | 390 if (result != MMSYSERR_NOERROR) |
| 389 stream->HandleError(result); | 391 stream->HandleError(result); |
| 390 stream->pending_bytes_ += buffer->dwBufferLength; | 392 stream->pending_bytes_ += buffer->dwBufferLength; |
| 391 } | 393 } |
| 392 } | 394 } |
| 393 } | 395 } |
| 394 | 396 |
| 395 } // namespace media | 397 } // namespace media |
| OLD | NEW |