summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Repinski <repinski23@gmail.com>2015-03-24 18:05:08 -0500
committerZiyan <jaraidaniel@gmail.com>2016-01-15 12:29:39 +0100
commit9889bb6352966f869ccbc682858f2f3a98f8422a (patch)
treeca00c9c6a0b068bd828f587cfb5b7d3e8b478d35
parent1da4513f2dc7e631c3d7604a1e5d9fce517eaaec (diff)
downloaddevice_samsung_tuna-9889bb6352966f869ccbc682858f2f3a98f8422a.zip
device_samsung_tuna-9889bb6352966f869ccbc682858f2f3a98f8422a.tar.gz
device_samsung_tuna-9889bb6352966f869ccbc682858f2f3a98f8422a.tar.bz2
audio: Decide use_long_periods on start_output_stream.
Previously this was corrected on the first write, however that was causing a buffer underrun sometimes when a stream was started. This avoids that.
-rw-r--r--audio/audio_hw.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index 5e36799..24f507f 100644
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -1505,8 +1505,13 @@ static int start_output_stream_deep_buffer(struct tuna_stream_out *out)
select_output_device(adev);
}
- out->write_threshold = PLAYBACK_DEEP_BUFFER_LONG_PERIOD_COUNT * DEEP_BUFFER_LONG_PERIOD_SIZE;
- out->use_long_periods = true;
+ out->use_long_periods = adev->screen_off && !adev->active_input;
+ /* TODO: Do we need a pcm_set_avail_min here somehow? */
+ if (out->use_long_periods) {
+ out->write_threshold = PLAYBACK_DEEP_BUFFER_LONG_PERIOD_COUNT * DEEP_BUFFER_LONG_PERIOD_SIZE;
+ } else {
+ out->write_threshold = PLAYBACK_DEEP_BUFFER_SHORT_PERIOD_COUNT * DEEP_BUFFER_SHORT_PERIOD_SIZE;
+ }
out->config[PCM_NORMAL] = pcm_config_mm;
#ifndef USE_VARIABLE_SAMPLING_RATE