summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2012-10-31 12:57:56 +0100
committerPaul Kocialkowski <contact@paulk.fr>2012-10-31 12:57:56 +0100
commit07f20ab0fd9089a1b5c97a9bcbec1df5979f318e (patch)
tree6fdff5d8904cab4f80b3d03774cbf71f1d70a2bd
parentb484b2aa3ae9b8512eedac1f70a0d0a20c2ce672 (diff)
downloadhardware_tinyalsa-audio-07f20ab0fd9089a1b5c97a9bcbec1df5979f318e.zip
hardware_tinyalsa-audio-07f20ab0fd9089a1b5c97a9bcbec1df5979f318e.tar.gz
hardware_tinyalsa-audio-07f20ab0fd9089a1b5c97a9bcbec1df5979f318e.tar.bz2
Return correct input buffer size.
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r--audio_hw.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/audio_hw.c b/audio_hw.c
index 0292216..cfe4058 100644
--- a/audio_hw.c
+++ b/audio_hw.c
@@ -310,9 +310,33 @@ static char *audio_hw_get_parameters(const struct audio_hw_device *dev,
static size_t audio_hw_get_input_buffer_size(const struct audio_hw_device *dev,
uint32_t sample_rate, int format, int channel_count)
{
+ struct tinyalsa_audio_device *device;
+ struct tinyalsa_mixer_io_props *mixer_props;
+ size_t size;
+
LOGD("%s(%p, %d, %d, %d)", __func__, dev, sample_rate, format, channel_count);
- return 320;
+ if(dev == NULL)
+ return -1;
+
+ device = (struct tinyalsa_audio_device *) dev;
+
+ if(device->mixer == NULL)
+ return -1;
+
+ mixer_props = tinyalsa_mixer_get_input_props(device->mixer);
+ if(mixer_props == NULL)
+ return -1;
+
+ // Default value
+ if(mixer_props->rate == 0)
+ mixer_props->rate = 44100;
+
+ size = (mixer_props->period_size * sample_rate) / mixer_props->rate;
+ size = ((size + 15) / 16) * 16;
+ size = size * channel_count * audio_bytes_per_sample(format);
+
+ return size;
}
static int audio_hw_dump(const audio_hw_device_t *device, int fd)