AudioTrack: fix stall if setBufferSizeInFrames() called before play()
The server was waiting for a full buffer.
But the buffer was only getting partly filled.
So the stream was not starting.
The fix involves having the server look at the adjustable threshold.
Bug: 27505889
Change-Id: I5dbf686413e670dacbbecc9e0f838744e465f44f
Signed-off-by: Phil Burk <philburk@google.com>
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 423273d..272b0cd 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -860,7 +860,7 @@
if (mOutput == AUDIO_IO_HANDLE_NONE || mProxy.get() == 0) {
return NO_INIT;
}
- return mProxy->getBufferSizeInFrames();
+ return (ssize_t) mProxy->getBufferSizeInFrames();
}
ssize_t AudioTrack::setBufferSizeInFrames(size_t bufferSizeInFrames)
@@ -873,10 +873,7 @@
if (!audio_is_linear_pcm(mFormat)) {
return INVALID_OPERATION;
}
- // TODO also need to inform the server side (through mAudioTrack) that
- // the buffer count is reduced, otherwise the track may never start
- // because the server thinks it is never filled.
- return mProxy->setBufferSizeInFrames(bufferSizeInFrames);
+ return (ssize_t) mProxy->setBufferSizeInFrames((uint32_t) bufferSizeInFrames);
}
status_t AudioTrack::setLoop(uint32_t loopStart, uint32_t loopEnd, int loopCount)