diff options
author | Andy Hung <hunga@google.com> | 2015-05-31 22:49:46 -0700 |
---|---|---|
committer | Andy Hung <hunga@google.com> | 2015-06-03 22:26:44 -0700 |
commit | 179652ee2a508361df1aa18e99000373886f0816 (patch) | |
tree | cab9a40399ab43231c8a9b9fc00985b2efaf600c /media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp | |
parent | a7f03353d5f172016f324e2a01f301cca6794152 (diff) | |
download | frameworks_av-179652ee2a508361df1aa18e99000373886f0816.zip frameworks_av-179652ee2a508361df1aa18e99000373886f0816.tar.gz frameworks_av-179652ee2a508361df1aa18e99000373886f0816.tar.bz2 |
NuPlayer: Add audio sink buffer configuration
Property media.stagefright.audio.sink (in milliseconds)
Also change the default buffer size for PCM playback to 500 ms.
Bug: 21198655
Change-Id: I5781288f59bf08fbecd9263a26c919570b58be0f
Diffstat (limited to 'media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp')
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp index 89c261c..10ffc23 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp @@ -48,6 +48,9 @@ namespace android { #Use audio callbacks for PCM data adb shell setprop media.stagefright.audio.cbk 1 + #Set size of buffers for pcm audio sink in msec (example: 1000 msec) + adb shell setprop media.stagefright.audio.sink 1000 + * These configurations take effect for the next track played (not the current track). */ @@ -55,6 +58,11 @@ static inline bool getUseAudioCallbackSetting() { return property_get_bool("media.stagefright.audio.cbk", false /* default_value */); } +static inline int32_t getAudioSinkPcmMsSetting() { + return property_get_int32( + "media.stagefright.audio.sink", 500 /* default_value */); +} + // Maximum time in paused state when offloading audio decompression. When elapsed, the AudioSink // is closed to allow the audio DSP to power down. static const int64_t kOffloadPauseMaxUs = 10000000ll; @@ -1636,7 +1644,7 @@ status_t NuPlayer::Renderer::onOpenAudioSink( numChannels, (audio_channel_mask_t)channelMask, audioFormat, - 8 /* bufferCount */, + 0 /* bufferCount - unused */, &NuPlayer::Renderer::AudioSinkCallback, this, (audio_output_flags_t)offloadFlags, @@ -1691,17 +1699,24 @@ status_t NuPlayer::Renderer::onOpenAudioSink( // Note: It is possible to set up the callback, but not use it to send audio data. // This requires a fix in AudioSink to explicitly specify the transfer mode. mUseAudioCallback = getUseAudioCallbackSetting(); + + // Compute the desired buffer size. + // For callback mode, the amount of time before wakeup is about half the buffer size. + const uint32_t frameCount = + (unsigned long long)sampleRate * getAudioSinkPcmMsSetting() / 1000; + status_t err = mAudioSink->open( sampleRate, numChannels, (audio_channel_mask_t)channelMask, AUDIO_FORMAT_PCM_16_BIT, - 8 /* bufferCount */, + 0 /* bufferCount - unused */, mUseAudioCallback ? &NuPlayer::Renderer::AudioSinkCallback : NULL, mUseAudioCallback ? this : NULL, (audio_output_flags_t)pcmFlags, NULL, - true /* doNotReconnect */); + true /* doNotReconnect */, + frameCount); if (err == OK) { err = mAudioSink->setPlaybackRate(mPlaybackSettings); } |