aboutsummaryrefslogtreecommitdiff
path: root/audio/paaudio.c
diff options
context:
space:
mode:
authorMartin Schrodt <martin@schrodt.org>2019-03-15 09:46:51 +0100
committerGerd Hoffmann <kraxel@redhat.com>2019-03-18 12:21:15 +0100
commitbaea032ec751306805214190b1ac23f409e9739a (patch)
tree79dc40352456bb0f2db752c50038c9ad4b25759c /audio/paaudio.c
parentd4e65539e570d5872003710b5a1064489911d33d (diff)
audio/paaudio: fix ignored buffer_length setting
Audiodev configuration allows to set the length of the buffered data. The setting was ignored and a constant value used instead. This patch makes the code apply the setting properly, and uses the previous default if nothing is supplied. Signed-off-by: Martin Schrodt <martin@schrodt.org> Message-id: 20190315084653.120020-2-martin@schrodt.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'audio/paaudio.c')
-rw-r--r--audio/paaudio.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/audio/paaudio.c b/audio/paaudio.c
index 5d410ed73f..ab2a37bbdb 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -577,7 +577,8 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as,
audio_pcm_init_info (&hw->info, &obt_as);
hw->samples = pa->samples = audio_buffer_samples(
- qapi_AudiodevPaPerDirectionOptions_base(ppdo), &obt_as, 46440);
+ qapi_AudiodevPaPerDirectionOptions_base(ppdo),
+ &obt_as, ppdo->buffer_length);
pa->pcm_buf = audio_calloc(__func__, hw->samples, 1 << hw->info.shift);
pa->rpos = hw->rpos;
if (!pa->pcm_buf) {
@@ -637,7 +638,8 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
audio_pcm_init_info (&hw->info, &obt_as);
hw->samples = pa->samples = audio_buffer_samples(
- qapi_AudiodevPaPerDirectionOptions_base(ppdo), &obt_as, 46440);
+ qapi_AudiodevPaPerDirectionOptions_base(ppdo),
+ &obt_as, ppdo->buffer_length);
pa->pcm_buf = audio_calloc(__func__, hw->samples, 1 << hw->info.shift);
pa->wpos = hw->wpos;
if (!pa->pcm_buf) {
@@ -809,7 +811,16 @@ static int qpa_ctl_in (HWVoiceIn *hw, int cmd, ...)
return 0;
}
-/* common */
+static int qpa_validate_per_direction_opts(Audiodev *dev,
+ AudiodevPaPerDirectionOptions *pdo)
+{
+ if (!pdo->has_buffer_length) {
+ pdo->has_buffer_length = true;
+ pdo->buffer_length = 46440;
+ }
+ return 1;
+}
+
static void *qpa_audio_init(Audiodev *dev)
{
paaudio *g;
@@ -836,6 +847,13 @@ static void *qpa_audio_init(Audiodev *dev)
g = g_malloc(sizeof(paaudio));
server = popts->has_server ? popts->server : NULL;
+ if (!qpa_validate_per_direction_opts(dev, popts->in)) {
+ goto fail;
+ }
+ if (!qpa_validate_per_direction_opts(dev, popts->out)) {
+ goto fail;
+ }
+
g->dev = dev;
g->mainloop = NULL;
g->context = NULL;