diff options
Diffstat (limited to 'media/audio/mac')
-rw-r--r-- | media/audio/mac/audio_output_mac.cc | 6 | ||||
-rw-r--r-- | media/audio/mac/audio_output_mac_unittest.cc | 26 |
2 files changed, 21 insertions, 11 deletions
diff --git a/media/audio/mac/audio_output_mac.cc b/media/audio/mac/audio_output_mac.cc index 45de9a7..8d68b27 100644 --- a/media/audio/mac/audio_output_mac.cc +++ b/media/audio/mac/audio_output_mac.cc @@ -216,8 +216,10 @@ void PCMQueueOutAudioOutputStream::RenderCallback(void* p_this, if (!static_cast<AudioQueueUserData*>(buffer->mUserData)->empty_buffer) audio_stream->pending_bytes_ -= buffer->mAudioDataByteSize; uint32 capacity = buffer->mAudioDataBytesCapacity; - uint32 filled = source->OnMoreData(audio_stream, buffer->mAudioData, - capacity, audio_stream->pending_bytes_); + // TODO(sergeyu): Specify correct hardware delay for AudioBuffersState. + uint32 filled = source->OnMoreData( + audio_stream, reinterpret_cast<uint8*>(buffer->mAudioData), capacity, + AudioBuffersState(audio_stream->pending_bytes_, 0)); // In order to keep the callback running, we need to provide a positive amount // of data to the audio queue. To simulate the behavior of Windows, we write diff --git a/media/audio/mac/audio_output_mac_unittest.cc b/media/audio/mac/audio_output_mac_unittest.cc index 892dafe..061316f 100644 --- a/media/audio/mac/audio_output_mac_unittest.cc +++ b/media/audio/mac/audio_output_mac_unittest.cc @@ -12,6 +12,7 @@ using ::testing::_; using ::testing::AnyNumber; using ::testing::DoAll; +using ::testing::Field; using ::testing::InSequence; using ::testing::Invoke; using ::testing::NiceMock; @@ -20,8 +21,9 @@ using ::testing::Return; class MockAudioSource : public AudioOutputStream::AudioSourceCallback { public: - MOCK_METHOD4(OnMoreData, uint32(AudioOutputStream* stream, void* dest, - uint32 max_size, uint32 pending_bytes)); + MOCK_METHOD4(OnMoreData, uint32(AudioOutputStream* stream, uint8* dest, + uint32 max_size, + AudioBuffersState buffers_state)); MOCK_METHOD1(OnClose, void(AudioOutputStream* stream)); MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code)); }; @@ -36,8 +38,9 @@ TEST(MacAudioTest, SineWaveAudio16MonoTest) { freq, AudioParameters::kTelephoneSampleRate); // TODO(cpu): Put the real test when the mock renderer is ported. - int16 buffer[samples] = { 0xffff }; - source.OnMoreData(NULL, buffer, sizeof(buffer), 0); + uint16 buffer[samples] = { 0xffff }; + source.OnMoreData(NULL, reinterpret_cast<uint8*>(buffer), sizeof(buffer), + AudioBuffersState(0, 0)); EXPECT_EQ(0, buffer[0]); EXPECT_EQ(5126, buffer[1]); } @@ -132,8 +135,8 @@ TEST(MacAudioTest, PCMWaveStreamPlay200HzTone22KssMono) { } // Custom action to clear a memory buffer. -static void ClearBuffer(AudioOutputStream* strea, void* dest, - uint32 max_size, uint32 pending_bytes) { +static void ClearBuffer(AudioOutputStream* stream, uint8* dest, + uint32 max_size, AudioBuffersState buffers_state) { memset(dest, 0, max_size); } @@ -156,11 +159,16 @@ TEST(MacAudioTest, PCMWaveStreamPendingBytes) { // And then we will try to provide zero data so the amount of pending bytes // will go down and eventually read zero. InSequence s; - EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, 0)) + EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, + Field(&AudioBuffersState::pending_bytes, 0))) .WillOnce(DoAll(Invoke(&ClearBuffer), Return(bytes_100_ms))); - EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, bytes_100_ms)) + EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, + Field(&AudioBuffersState::pending_bytes, + bytes_100_ms))) .WillOnce(DoAll(Invoke(&ClearBuffer), Return(bytes_100_ms))); - EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, bytes_100_ms)) + EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, + Field(&AudioBuffersState::pending_bytes, + bytes_100_ms))) .WillOnce(Return(0)); EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, _)) .Times(AnyNumber()) |