From 3cb4116243e54b0452d88c70a7acd4af17cf8d02 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 10 Nov 2013 23:05:51 +0100 Subject: ao: add ao_play_silence, use for ao_alsa and ao_oss Also add a corresponding function to audio/format.c, which fills an audio block with silence. --- audio/out/ao.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'audio/out/ao.c') diff --git a/audio/out/ao.c b/audio/out/ao.c index 88f0b2223d..55db34becb 100644 --- a/audio/out/ao.c +++ b/audio/out/ao.c @@ -250,6 +250,18 @@ void ao_resume(struct ao *ao) ao->driver->resume(ao); } +int ao_play_silence(struct ao *ao, int samples) +{ + if (samples <= 0 || AF_FORMAT_IS_SPECIAL(ao->format)) + return 0; + int s = ao->channels.num * (af_fmt2bits(ao->format) / 8); + char *p = talloc_size(NULL, samples * s); + af_fill_silence(p, samples * s, ao->format); + int r = ao_play(ao, p, samples * s, 0); + talloc_free(p); + return r; +} + bool ao_chmap_sel_adjust(struct ao *ao, const struct mp_chmap_sel *s, struct mp_chmap *map) { -- cgit v1.2.3