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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 if (callback_) | 318 if (callback_) |
319 callback_->OnError(this); | 319 callback_->OnError(this); |
320 } | 320 } |
321 | 321 |
322 void PCMWaveOutAudioOutputStream::QueueNextPacket(WAVEHDR *buffer) { | 322 void PCMWaveOutAudioOutputStream::QueueNextPacket(WAVEHDR *buffer) { |
323 DCHECK_EQ(channels_, format_.Format.nChannels); | 323 DCHECK_EQ(channels_, format_.Format.nChannels); |
324 // Call the source which will fill our buffer with pleasant sounds and | 324 // Call the source which will fill our buffer with pleasant sounds and |
325 // return to us how many bytes were used. | 325 // return to us how many bytes were used. |
326 // TODO(fbarchard): Handle used 0 by queueing more. | 326 // TODO(fbarchard): Handle used 0 by queueing more. |
327 | 327 |
328 // TODO(sergeyu): Specify correct hardware delay for AudioBuffersState. | 328 // TODO(sergeyu): Specify correct hardware delay for |total_delay_bytes|. |
| 329 uint32 total_delay_bytes = pending_bytes_; |
329 int frames_filled = callback_->OnMoreData( | 330 int frames_filled = callback_->OnMoreData( |
330 audio_bus_.get(), AudioBuffersState(pending_bytes_, 0)); | 331 audio_bus_.get(), total_delay_bytes); |
331 uint32 used = frames_filled * audio_bus_->channels() * | 332 uint32 used = frames_filled * audio_bus_->channels() * |
332 format_.Format.wBitsPerSample / 8; | 333 format_.Format.wBitsPerSample / 8; |
333 | 334 |
334 if (used <= buffer_size_) { | 335 if (used <= buffer_size_) { |
335 // Note: If this ever changes to output raw float the data must be clipped | 336 // Note: If this ever changes to output raw float the data must be clipped |
336 // and sanitized since it may come from an untrusted source such as NaCl. | 337 // and sanitized since it may come from an untrusted source such as NaCl. |
337 audio_bus_->Scale(volume_); | 338 audio_bus_->Scale(volume_); |
338 audio_bus_->ToInterleaved( | 339 audio_bus_->ToInterleaved( |
339 frames_filled, format_.Format.wBitsPerSample / 8, buffer->lpData); | 340 frames_filled, format_.Format.wBitsPerSample / 8, buffer->lpData); |
340 | 341 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 buffer, | 388 buffer, |
388 sizeof(WAVEHDR)); | 389 sizeof(WAVEHDR)); |
389 if (result != MMSYSERR_NOERROR) | 390 if (result != MMSYSERR_NOERROR) |
390 stream->HandleError(result); | 391 stream->HandleError(result); |
391 stream->pending_bytes_ += buffer->dwBufferLength; | 392 stream->pending_bytes_ += buffer->dwBufferLength; |
392 } | 393 } |
393 } | 394 } |
394 } | 395 } |
395 | 396 |
396 } // namespace media | 397 } // namespace media |
OLD | NEW |