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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 if (callback_) | 335 if (callback_) |
336 callback_->OnError(this, error); | 336 callback_->OnError(this, error); |
337 } | 337 } |
338 | 338 |
339 void PCMWaveOutAudioOutputStream::QueueNextPacket(WAVEHDR *buffer) { | 339 void PCMWaveOutAudioOutputStream::QueueNextPacket(WAVEHDR *buffer) { |
340 DCHECK_EQ(channels_, format_.Format.nChannels); | 340 DCHECK_EQ(channels_, format_.Format.nChannels); |
341 // Call the source which will fill our buffer with pleasant sounds and | 341 // Call the source which will fill our buffer with pleasant sounds and |
342 // return to us how many bytes were used. | 342 // return to us how many bytes were used. |
343 // TODO(fbarchard): Handle used 0 by queueing more. | 343 // TODO(fbarchard): Handle used 0 by queueing more. |
344 | 344 |
345 // HACK: Yield if Read() is called too often. On older platforms which are | |
346 // still using the WaveOut back end, we run into synchronization issues where | |
scherkus (not reviewing)
2012/11/21 21:37:57
s/back end/backend/
DaleCurtis
2012/11/21 22:42:10
Done.
| |
347 // the renderer has not finished filling the shared memory when Read() is | |
348 // called. Reading too early will lead to clicks and pops. See issues: | |
349 // http://crbug.com/161307 and http://crbug.com/61022 | |
350 callback_->WaitTillDataReady(); | |
DaleCurtis
2012/11/21 19:31:07
I'm digging through the WaveOut docs to see if we
| |
351 | |
345 // TODO(sergeyu): Specify correct hardware delay for AudioBuffersState. | 352 // TODO(sergeyu): Specify correct hardware delay for AudioBuffersState. |
346 int frames_filled = callback_->OnMoreData( | 353 int frames_filled = callback_->OnMoreData( |
347 audio_bus_.get(), AudioBuffersState(pending_bytes_, 0)); | 354 audio_bus_.get(), AudioBuffersState(pending_bytes_, 0)); |
348 uint32 used = frames_filled * audio_bus_->channels() * | 355 uint32 used = frames_filled * audio_bus_->channels() * |
349 format_.Format.wBitsPerSample / 8; | 356 format_.Format.wBitsPerSample / 8; |
350 | 357 |
351 if (used <= buffer_size_) { | 358 if (used <= buffer_size_) { |
352 // Note: If this ever changes to output raw float the data must be clipped | 359 // Note: If this ever changes to output raw float the data must be clipped |
353 // and sanitized since it may come from an untrusted source such as NaCl. | 360 // and sanitized since it may come from an untrusted source such as NaCl. |
354 audio_bus_->ToInterleaved( | 361 audio_bus_->ToInterleaved( |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
407 buffer, | 414 buffer, |
408 sizeof(WAVEHDR)); | 415 sizeof(WAVEHDR)); |
409 if (result != MMSYSERR_NOERROR) | 416 if (result != MMSYSERR_NOERROR) |
410 stream->HandleError(result); | 417 stream->HandleError(result); |
411 stream->pending_bytes_ += buffer->dwBufferLength; | 418 stream->pending_bytes_ += buffer->dwBufferLength; |
412 } | 419 } |
413 } | 420 } |
414 } | 421 } |
415 | 422 |
416 } // namespace media | 423 } // namespace media |
OLD | NEW |