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 #include <windows.h> | 7 #include <windows.h> |
8 #include <mmsystem.h> | 8 #include <mmsystem.h> |
9 #pragma comment(lib, "winmm.lib") | 9 #pragma comment(lib, "winmm.lib") |
10 | 10 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // this does but we can guess that causes the OS to keep a reference to | 161 // this does but we can guess that causes the OS to keep a reference to |
162 // the memory pages so the driver can use them without worries. | 162 // the memory pages so the driver can use them without worries. |
163 ::waveOutPrepareHeader(waveout_, buffer, sizeof(WAVEHDR)); | 163 ::waveOutPrepareHeader(waveout_, buffer, sizeof(WAVEHDR)); |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 void PCMWaveOutAudioOutputStream::FreeBuffers() { | 167 void PCMWaveOutAudioOutputStream::FreeBuffers() { |
168 for (int ix = 0; ix != num_buffers_; ++ix) { | 168 for (int ix = 0; ix != num_buffers_; ++ix) { |
169 ::waveOutUnprepareHeader(waveout_, GetBuffer(ix), sizeof(WAVEHDR)); | 169 ::waveOutUnprepareHeader(waveout_, GetBuffer(ix), sizeof(WAVEHDR)); |
170 } | 170 } |
171 buffers_.reset(NULL); | 171 buffers_.reset(); |
172 } | 172 } |
173 | 173 |
174 // Initially we ask the source to fill up all audio buffers. If we don't do | 174 // Initially we ask the source to fill up all audio buffers. If we don't do |
175 // this then we would always get the driver callback when it is about to run | 175 // this then we would always get the driver callback when it is about to run |
176 // samples and that would leave too little time to react. | 176 // samples and that would leave too little time to react. |
177 void PCMWaveOutAudioOutputStream::Start(AudioSourceCallback* callback) { | 177 void PCMWaveOutAudioOutputStream::Start(AudioSourceCallback* callback) { |
178 if (state_ != PCMA_READY) | 178 if (state_ != PCMA_READY) |
179 return; | 179 return; |
180 callback_ = callback; | 180 callback_ = callback; |
181 | 181 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 buffer, | 416 buffer, |
417 sizeof(WAVEHDR)); | 417 sizeof(WAVEHDR)); |
418 if (result != MMSYSERR_NOERROR) | 418 if (result != MMSYSERR_NOERROR) |
419 stream->HandleError(result); | 419 stream->HandleError(result); |
420 stream->pending_bytes_ += buffer->dwBufferLength; | 420 stream->pending_bytes_ += buffer->dwBufferLength; |
421 } | 421 } |
422 } | 422 } |
423 } | 423 } |
424 | 424 |
425 } // namespace media | 425 } // namespace media |
OLD | NEW |