aboutsummaryrefslogtreecommitdiff
path: root/audio/audio_legacy.c
diff options
context:
space:
mode:
authorKővágó, Zoltán <dirty.ice.hu@gmail.com>2019-03-08 23:34:18 +0100
committerGerd Hoffmann <kraxel@redhat.com>2019-03-11 10:29:27 +0100
commit4a3b8b344495cd7e7419604fbf51d8efd088c210 (patch)
treed9566055eb5aa4214553dcac6c8d34fedc1067fa /audio/audio_legacy.c
parent17c56dc1d1882fd98d263a43c71761ffe17c6f65 (diff)
downloadqemu-4a3b8b344495cd7e7419604fbf51d8efd088c210.zip
qemu-4a3b8b344495cd7e7419604fbf51d8efd088c210.tar.gz
qemu-4a3b8b344495cd7e7419604fbf51d8efd088c210.tar.bz2
dsoundaudio: port to -audiodev config
Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: f25562cb88246b41c3e6380685a108fd341d5b50.1552083282.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'audio/audio_legacy.c')
-rw-r--r--audio/audio_legacy.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c
index 5f557a2..bf326bd 100644
--- a/audio/audio_legacy.c
+++ b/audio/audio_legacy.c
@@ -120,6 +120,30 @@ static void get_frames_to_usecs(const char *env, uint32_t *dst, bool *has_dst,
}
}
+static uint32_t samples_to_usecs(uint32_t samples,
+ AudiodevPerDirectionOptions *pdo)
+{
+ uint32_t channels = pdo->has_channels ? pdo->channels : 2;
+ return frames_to_usecs(samples / channels, pdo);
+}
+
+static uint32_t bytes_to_usecs(uint32_t bytes, AudiodevPerDirectionOptions *pdo)
+{
+ AudioFormat fmt = pdo->has_format ? pdo->format : AUDIO_FORMAT_S16;
+ uint32_t bytes_per_sample = audioformat_bytes_per_sample(fmt);
+ return samples_to_usecs(bytes / bytes_per_sample, pdo);
+}
+
+static void get_bytes_to_usecs(const char *env, uint32_t *dst, bool *has_dst,
+ AudiodevPerDirectionOptions *pdo)
+{
+ const char *val = getenv(env);
+ if (val) {
+ *dst = bytes_to_usecs(toui32(val), pdo);
+ *has_dst = true;
+ }
+}
+
/* backend specific functions */
/* ALSA */
static void handle_alsa_per_direction(
@@ -180,6 +204,21 @@ static void handle_coreaudio(Audiodev *dev)
&dev->u.coreaudio.out->has_buffer_count);
}
+/* dsound */
+static void handle_dsound(Audiodev *dev)
+{
+ get_millis_to_usecs("QEMU_DSOUND_LATENCY_MILLIS",
+ &dev->u.dsound.latency, &dev->u.dsound.has_latency);
+ get_bytes_to_usecs("QEMU_DSOUND_BUFSIZE_OUT",
+ &dev->u.dsound.out->buffer_length,
+ &dev->u.dsound.out->has_buffer_length,
+ dev->u.dsound.out);
+ get_bytes_to_usecs("QEMU_DSOUND_BUFSIZE_IN",
+ &dev->u.dsound.in->buffer_length,
+ &dev->u.dsound.in->has_buffer_length,
+ dev->u.dsound.in);
+}
+
/* general */
static void handle_per_direction(
AudiodevPerDirectionOptions *pdo, const char *prefix)
@@ -229,6 +268,10 @@ static AudiodevListEntry *legacy_opt(const char *drvname)
handle_coreaudio(e->dev);
break;
+ case AUDIODEV_DRIVER_DSOUND:
+ handle_dsound(e->dev);
+ break;
+
default:
break;
}