diff options
-rw-r--r-- | audio_hw.c | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -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) |