diff options
author | wm4 <wm4@nowhere> | 2013-11-10 23:05:51 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-11-10 23:05:59 +0100 |
commit | 3cb4116243e54b0452d88c70a7acd4af17cf8d02 (patch) | |
tree | f1e97c8d9f630e81c3e7e7c4022b87952bcfcc15 /audio/out/ao.c | |
parent | 6ec1f317654ae1e1424ec7c519cf307aae7c3efe (diff) | |
download | mpv-3cb4116243e54b0452d88c70a7acd4af17cf8d02.tar.bz2 mpv-3cb4116243e54b0452d88c70a7acd4af17cf8d02.tar.xz |
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.
Diffstat (limited to 'audio/out/ao.c')
-rw-r--r-- | audio/out/ao.c | 12 |
1 files changed, 12 insertions, 0 deletions
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) { |