Skip to content

Commit 0df6894

Browse files
author
Eric Laurent
committed
AudioTrack: relax check on minimum buffer size
Current AudioTrack implementation enforces that the requested audio buffer size is at least corresponding the audio latency. This requirement is too strong and leads to problems with current stagefright and AudioSink implementations when playing over output streams with long latency. Ultimately, the AudioSink design should be changed to specify a minimum buffer size in time or frames units but not in buffer count units. Change-Id: I8ba603956f92ac49143a8249572665aa548f2f0f Conflicts: media/libmedia/AudioTrack.cpp
1 parent 2b056c6 commit 0df6894

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

include/media/AudioTrack.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@ class AudioTrack
130130
* format: Audio format (e.g AUDIO_FORMAT_PCM_16_BIT for signed
131131
* 16 bits per sample).
132132
* channelMask: Channel mask: see audio_channels_t.
133-
* frameCount: Total size of track PCM buffer in frames. This defines the
134-
* latency of the track.
133+
* frameCount: Minimum size of track PCM buffer in frames. This defines the
134+
* latency of the track. The actual size selected by the AudioTrack could be
135+
* larger if the requested size is not compatible with current audio HAL
136+
* latency.
135137
* flags: Reserved for future use.
136138
* cbf: Callback function. If not null, this function is called periodically
137139
* to request new PCM data.

media/libmedia/AudioTrack.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -763,12 +763,9 @@ status_t AudioTrack::createTrack_l(
763763
mNotificationFramesAct = frameCount/2;
764764
}
765765
if (frameCount < minFrameCount) {
766-
if (enforceFrameCount) {
767-
LOGE("Invalid buffer size: minFrameCount %d, frameCount %d", minFrameCount, frameCount);
768-
return BAD_VALUE;
769-
} else {
770-
frameCount = minFrameCount;
771-
}
766+
LOGW_IF(enforceFrameCount, "Minimum buffer size corrected from %d to %d",
767+
frameCount, minFrameCount);
768+
frameCount = minFrameCount;
772769
}
773770
} else {
774771
// Ensure that buffer alignment matches channelcount

0 commit comments

Comments
 (0)