summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2011-10-19 22:09:43 -0700
committerEric Laurent <elaurent@google.com>2011-10-20 11:15:45 -0700
commit5f6c07212c316d4f09636c7033bcc912315b8dde (patch)
tree38f78a180d176b5ecbc76d33f7c2c3f1ff8b3161 /audio
parent9e3fe5dc7630aa103be95a43ff0012a7bb37c77c (diff)
downloaddevice_samsung_tuna-5f6c07212c316d4f09636c7033bcc912315b8dde.zip
device_samsung_tuna-5f6c07212c316d4f09636c7033bcc912315b8dde.tar.gz
device_samsung_tuna-5f6c07212c316d4f09636c7033bcc912315b8dde.tar.bz2
audio: increased low power playback buffer size.
Defined new audio buffer sizes to help increase periods of idle CPU with new scaling governor settings. Related to issue 5486806: mp3 playback power re-regressed... Change-Id: I5f0f54d0ef8e189c2e3ac84bf8eed4bafece9111
Diffstat (limited to 'audio')
-rwxr-xr-xaudio/audio_hw.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index e488b50..acfcbda 100755
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -118,15 +118,17 @@
/* constraint imposed by ABE: all period sizes must be multiples of 24 */
#define ABE_BASE_FRAME_COUNT 24
/* number of base blocks in a short period (low latency) */
-#define SHORT_PERIOD_MULTIPLIER 40 /* 20 ms */
+#define SHORT_PERIOD_MULTIPLIER 44 /* 22 ms */
/* number of frames per short period (low latency) */
#define SHORT_PERIOD_SIZE (ABE_BASE_FRAME_COUNT * SHORT_PERIOD_MULTIPLIER)
/* number of short periods in a long period (low power) */
-#define LONG_PERIOD_MULTIPLIER 6 /* 120 ms */
+#define LONG_PERIOD_MULTIPLIER 14 /* 308 ms */
/* number of frames per long period (low power) */
#define LONG_PERIOD_SIZE (SHORT_PERIOD_SIZE * LONG_PERIOD_MULTIPLIER)
-/* number of periods for playback */
-#define PLAYBACK_PERIOD_COUNT 4
+/* number of periods for low power playback */
+#define PLAYBACK_LONG_PERIOD_COUNT 2
+/* number of pseudo periods for low latency playback */
+#define PLAYBACK_SHORT_PERIOD_COUNT 4
/* number of periods for capture */
#define CAPTURE_PERIOD_COUNT 2
/* minimum sleep time in out_write() when write threshold is not reached */
@@ -206,7 +208,7 @@ struct pcm_config pcm_config_mm = {
.channels = 2,
.rate = MM_FULL_POWER_SAMPLING_RATE,
.period_size = LONG_PERIOD_SIZE,
- .period_count = PLAYBACK_PERIOD_COUNT,
+ .period_count = PLAYBACK_LONG_PERIOD_COUNT,
.format = PCM_FORMAT_S16_LE,
};
@@ -1057,9 +1059,9 @@ static int start_output_stream(struct tuna_stream_out *out)
/* default to low power: will be corrected in out_write if necessary before first write to
* tinyalsa.
*/
- out->write_threshold = PLAYBACK_PERIOD_COUNT * LONG_PERIOD_SIZE;
+ out->write_threshold = PLAYBACK_LONG_PERIOD_COUNT * LONG_PERIOD_SIZE;
out->config.start_threshold = SHORT_PERIOD_SIZE * 2;
- out->config.avail_min = LONG_PERIOD_SIZE,
+ out->config.avail_min = LONG_PERIOD_SIZE;
out->low_power = 1;
out->pcm = pcm_open(card, port, PCM_OUT | PCM_MMAP | PCM_NOIRQ, &out->config);
@@ -1349,7 +1351,7 @@ static uint32_t out_get_latency(const struct audio_stream_out *stream)
{
struct tuna_stream_out *out = (struct tuna_stream_out *)stream;
- return (SHORT_PERIOD_SIZE * PLAYBACK_PERIOD_COUNT * 1000) / out->config.rate;
+ return (SHORT_PERIOD_SIZE * PLAYBACK_SHORT_PERIOD_COUNT * 1000) / out->config.rate;
}
static int out_set_volume(struct audio_stream_out *stream, float left,
@@ -1396,10 +1398,10 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
if (low_power != out->low_power) {
if (low_power) {
- out->write_threshold = LONG_PERIOD_SIZE * PLAYBACK_PERIOD_COUNT;
+ out->write_threshold = LONG_PERIOD_SIZE * PLAYBACK_LONG_PERIOD_COUNT;
out->config.avail_min = LONG_PERIOD_SIZE;
} else {
- out->write_threshold = SHORT_PERIOD_SIZE * PLAYBACK_PERIOD_COUNT;
+ out->write_threshold = SHORT_PERIOD_SIZE * PLAYBACK_SHORT_PERIOD_COUNT;
out->config.avail_min = SHORT_PERIOD_SIZE;
}
pcm_set_avail_min(out->pcm, out->config.avail_min);