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/mac/audio_output_mac.h" | 5 #include "media/audio/mac/audio_output_mac.h" |
6 | 6 |
7 #include <CoreServices/CoreServices.h> | 7 #include <CoreServices/CoreServices.h> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 AudioSourceCallback* source = audio_stream->GetSource(); | 400 AudioSourceCallback* source = audio_stream->GetSource(); |
401 if (!source) | 401 if (!source) |
402 return; | 402 return; |
403 | 403 |
404 // Adjust the number of pending bytes by subtracting the amount played. | 404 // Adjust the number of pending bytes by subtracting the amount played. |
405 if (!static_cast<AudioQueueUserData*>(buffer->mUserData)->empty_buffer) | 405 if (!static_cast<AudioQueueUserData*>(buffer->mUserData)->empty_buffer) |
406 audio_stream->pending_bytes_ -= buffer->mAudioDataByteSize; | 406 audio_stream->pending_bytes_ -= buffer->mAudioDataByteSize; |
407 uint32 capacity = buffer->mAudioDataBytesCapacity; | 407 uint32 capacity = buffer->mAudioDataBytesCapacity; |
408 // TODO(sergeyu): Specify correct hardware delay for AudioBuffersState. | 408 // TODO(sergeyu): Specify correct hardware delay for AudioBuffersState. |
409 uint32 filled = source->OnMoreData( | 409 uint32 filled = source->OnMoreData( |
410 audio_stream, reinterpret_cast<uint8*>(buffer->mAudioData), capacity, | 410 reinterpret_cast<uint8*>(buffer->mAudioData), capacity, |
411 AudioBuffersState(audio_stream->pending_bytes_, 0)); | 411 AudioBuffersState(audio_stream->pending_bytes_, 0)); |
412 | 412 |
413 // In order to keep the callback running, we need to provide a positive amount | 413 // In order to keep the callback running, we need to provide a positive amount |
414 // of data to the audio queue. To simulate the behavior of Windows, we write | 414 // of data to the audio queue. To simulate the behavior of Windows, we write |
415 // a buffer of silence. | 415 // a buffer of silence. |
416 if (!filled) { | 416 if (!filled) { |
417 CHECK(audio_stream->silence_bytes_ <= static_cast<int>(capacity)); | 417 CHECK(audio_stream->silence_bytes_ <= static_cast<int>(capacity)); |
418 filled = audio_stream->silence_bytes_; | 418 filled = audio_stream->silence_bytes_; |
419 | 419 |
420 // Assume unsigned audio. | 420 // Assume unsigned audio. |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 source_ = source; | 524 source_ = source; |
525 } | 525 } |
526 | 526 |
527 AudioOutputStream::AudioSourceCallback* | 527 AudioOutputStream::AudioSourceCallback* |
528 PCMQueueOutAudioOutputStream::GetSource() { | 528 PCMQueueOutAudioOutputStream::GetSource() { |
529 base::AutoLock lock(source_lock_); | 529 base::AutoLock lock(source_lock_); |
530 return source_; | 530 return source_; |
531 } | 531 } |
532 | 532 |
533 } // namespace media | 533 } // namespace media |
OLD | NEW |