aboutsummaryrefslogtreecommitdiff
path: root/audio/audio_template.h
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2023-09-22 18:36:28 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2023-10-03 10:29:39 +0200
commit5c63d141dc8768c7418893beef8f151a13883e65 (patch)
treefd95818877aededfe3c0be8aa13ee9c65ec15d0f /audio/audio_template.h
parent176adafca72ecc35e7f1f011deb52ca1ae091df6 (diff)
downloadqemu-5c63d141dc8768c7418893beef8f151a13883e65.zip
qemu-5c63d141dc8768c7418893beef8f151a13883e65.tar.gz
qemu-5c63d141dc8768c7418893beef8f151a13883e65.tar.bz2
audio: commonize voice initialization
Move some mostly irrelevant code out of audio_init. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'audio/audio_template.h')
-rw-r--r--audio/audio_template.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/audio/audio_template.h b/audio/audio_template.h
index dc0c74a..7ccfec0 100644
--- a/audio/audio_template.h
+++ b/audio/audio_template.h
@@ -37,11 +37,12 @@
#endif
static void glue(audio_init_nb_voices_, TYPE)(AudioState *s,
- struct audio_driver *drv)
+ struct audio_driver *drv, int min_voices)
{
int max_voices = glue (drv->max_voices_, TYPE);
size_t voice_size = glue(drv->voice_size_, TYPE);
+ glue (s->nb_hw_voices_, TYPE) = glue(audio_get_pdo_, TYPE)(s->dev)->voices;
if (glue (s->nb_hw_voices_, TYPE) > max_voices) {
if (!max_voices) {
#ifdef DAC
@@ -56,6 +57,12 @@ static void glue(audio_init_nb_voices_, TYPE)(AudioState *s,
glue (s->nb_hw_voices_, TYPE) = max_voices;
}
+ if (glue (s->nb_hw_voices_, TYPE) < min_voices) {
+ dolog ("Bogus number of " NAME " voices %d, setting to %d\n",
+ glue (s->nb_hw_voices_, TYPE),
+ min_voices);
+ }
+
if (audio_bug(__func__, !voice_size && max_voices)) {
dolog ("drv=`%s' voice_size=0 max_voices=%d\n",
drv->name, max_voices);