summaryrefslogtreecommitdiffstats
path: root/media/audio/mac
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-29 01:21:27 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-29 01:21:27 +0000
commit5c86ecf8936269cdc5f00f57b7531cdac7b3e706 (patch)
tree79392d0c2e959af863e2b6d4626a79d039b178ab /media/audio/mac
parente10eacda58687b9363919a9203181322b649946c (diff)
downloadchromium_src-5c86ecf8936269cdc5f00f57b7531cdac7b3e706.zip
chromium_src-5c86ecf8936269cdc5f00f57b7531cdac7b3e706.tar.gz
chromium_src-5c86ecf8936269cdc5f00f57b7531cdac7b3e706.tar.bz2
Add AudioBuffersState struct. Use it for audio synchronization.
The new AudioBuffersState contains current state of the audio buffers. This object is passed all the way from the device to the audio renderer. Audio renderer uses this information to synchronize audio. BUG=52196,49110 TEST=see repro steps for 51637 and 52196. Review URL: http://codereview.chromium.org/3444017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60891 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/mac')
-rw-r--r--media/audio/mac/audio_output_mac.cc6
-rw-r--r--media/audio/mac/audio_output_mac_unittest.cc26
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())