aboutsummaryrefslogtreecommitdiff
path: root/audio/mixeng.h
diff options
context:
space:
mode:
authorVolker Rümelin <vr_qemu@t-online.de>2023-02-24 20:05:49 +0100
committerMarc-André Lureau <marcandre.lureau@redhat.com>2023-03-06 10:30:23 +0400
commit1a01df3db89010d40eb43889c3272d864b3b9430 (patch)
treefba00f749f3ac1013c6ae9ae726dbd7d5eb25153 /audio/mixeng.h
parent1fe3cae39f059c9fc2010e3c51c0bbd696cbf880 (diff)
audio: make playback packet length calculation exact
Introduce the new function st_rate_frames_in() to calculate the exact number of audio input frames needed to get a given number of audio output frames. The exact number of frames depends only on the difference of opos - ipos and the number of output frames. When downsampling, this function returns the maximum number of input frames needed. This new function replaces the audio_frontend_frames_out() function, which calculated the average number of input frames rounded down to the nearest integer. Because audio_frontend_frames_out() also limited the number of input frames to the size of the resample buffer, st_rate_frames_in() is not a direct replacement and two additional MIN() functions are needed. One to prevent resample buffer overflows and one to limit the available bytes for the audio frontends. After this patch the audio packet length calculation for playback is exact. When upsampling, it's still possible that the audio frontends can't write the last audio frame. This will be fixed later. Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20230224190555.7409-9-vr_qemu@t-online.de>
Diffstat (limited to 'audio/mixeng.h')
-rw-r--r--audio/mixeng.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/audio/mixeng.h b/audio/mixeng.h
index 2dcd6df245..64c1e231cc 100644
--- a/audio/mixeng.h
+++ b/audio/mixeng.h
@@ -52,6 +52,7 @@ void st_rate_flow(void *opaque, st_sample *ibuf, st_sample *obuf,
void st_rate_flow_mix(void *opaque, st_sample *ibuf, st_sample *obuf,
size_t *isamp, size_t *osamp);
void st_rate_stop (void *opaque);
+uint32_t st_rate_frames_in(void *opaque, uint32_t frames_out);
void mixeng_clear (struct st_sample *buf, int len);
void mixeng_volume (struct st_sample *buf, int len, struct mixeng_volume *vol);