| 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 void PCMWaveOutAudioOutputStream::QueueNextPacket(WAVEHDR *buffer) { | 339 void PCMWaveOutAudioOutputStream::QueueNextPacket(WAVEHDR *buffer) { |
| 340 // Call the source which will fill our buffer with pleasant sounds and | 340 // Call the source which will fill our buffer with pleasant sounds and |
| 341 // return to us how many bytes were used. | 341 // return to us how many bytes were used. |
| 342 // If we are down sampling to a smaller number of channels, we need to | 342 // If we are down sampling to a smaller number of channels, we need to |
| 343 // scale up the amount of pending bytes. | 343 // scale up the amount of pending bytes. |
| 344 // TODO(fbarchard): Handle used 0 by queueing more. | 344 // TODO(fbarchard): Handle used 0 by queueing more. |
| 345 uint32 scaled_pending_bytes = pending_bytes_ * channels_ / | 345 uint32 scaled_pending_bytes = pending_bytes_ * channels_ / |
| 346 format_.Format.nChannels; | 346 format_.Format.nChannels; |
| 347 // TODO(sergeyu): Specify correct hardware delay for AudioBuffersState. | 347 // TODO(sergeyu): Specify correct hardware delay for AudioBuffersState. |
| 348 uint32 used = callback_->OnMoreData( | 348 uint32 used = callback_->OnMoreData( |
| 349 this, reinterpret_cast<uint8*>(buffer->lpData), buffer_size_, | 349 reinterpret_cast<uint8*>(buffer->lpData), buffer_size_, |
| 350 AudioBuffersState(scaled_pending_bytes, 0)); | 350 AudioBuffersState(scaled_pending_bytes, 0)); |
| 351 if (used <= buffer_size_) { | 351 if (used <= buffer_size_) { |
| 352 buffer->dwBufferLength = used * format_.Format.nChannels / channels_; | 352 buffer->dwBufferLength = used * format_.Format.nChannels / channels_; |
| 353 if (channels_ > 2 && format_.Format.nChannels == 2) { | 353 if (channels_ > 2 && format_.Format.nChannels == 2) { |
| 354 media::FoldChannels(buffer->lpData, used, | 354 media::FoldChannels(buffer->lpData, used, |
| 355 channels_, format_.Format.wBitsPerSample >> 3, | 355 channels_, format_.Format.wBitsPerSample >> 3, |
| 356 volume_); | 356 volume_); |
| 357 } else { | 357 } else { |
| 358 media::AdjustVolume(buffer->lpData, used, | 358 media::AdjustVolume(buffer->lpData, used, |
| 359 format_.Format.nChannels, | 359 format_.Format.nChannels, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 buffer, | 408 buffer, |
| 409 sizeof(WAVEHDR)); | 409 sizeof(WAVEHDR)); |
| 410 if (result != MMSYSERR_NOERROR) | 410 if (result != MMSYSERR_NOERROR) |
| 411 stream->HandleError(result); | 411 stream->HandleError(result); |
| 412 stream->pending_bytes_ += buffer->dwBufferLength; | 412 stream->pending_bytes_ += buffer->dwBufferLength; |
| 413 } | 413 } |
| 414 } | 414 } |
| 415 } | 415 } |
| 416 | 416 |
| 417 } // namespace media | 417 } // namespace media |
| OLD | NEW |