summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-08-09 16:22:06 +0200
committerwm4 <wm4@nowhere>2016-08-09 17:09:29 +0200
commiteab92cec60d92e0de2ea53d4d01052f4d7acc5d5 (patch)
treecb6202b24b7407283dd5f28e650d3fc869a7e33d /audio
parent3759a3f40bed92b161342532445718906f903234 (diff)
downloadmpv-eab92cec60d92e0de2ea53d4d01052f4d7acc5d5.tar.bz2
mpv-eab92cec60d92e0de2ea53d4d01052f4d7acc5d5.tar.xz
player: add --audio-stream-silence
Completely insane that this has to be done. Crap for compensating HDMI crap.
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao.c2
-rw-r--r--audio/out/ao.h2
-rw-r--r--audio/out/internal.h1
-rw-r--r--audio/out/pull.c8
4 files changed, 11 insertions, 2 deletions
diff --git a/audio/out/ao.c b/audio/out/ao.c
index 0647067e50..cf66e0c64b 100644
--- a/audio/out/ao.c
+++ b/audio/out/ao.c
@@ -183,6 +183,8 @@ static struct ao *ao_init(bool probing, struct mpv_global *global,
ao->api_priv = talloc_zero_size(ao, ao->api->priv_size);
assert(!ao->api->priv_defaults && !ao->api->options);
+ ao->stream_silence = flags & AO_INIT_STREAM_SILENCE;
+
int r = ao->driver->init(ao);
if (r < 0) {
// Silly exception for coreaudio spdif redirection
diff --git a/audio/out/ao.h b/audio/out/ao.h
index 3c16cef0e5..3b187e7355 100644
--- a/audio/out/ao.h
+++ b/audio/out/ao.h
@@ -56,6 +56,8 @@ enum {
// Only accept multichannel configurations that are guaranteed to work
// (i.e. not sending arbitrary layouts over HDMI).
AO_INIT_SAFE_MULTICHANNEL_ONLY = 1 << 1,
+ // Stream silence as long as no audio is playing.
+ AO_INIT_STREAM_SILENCE = 1 << 2,
};
typedef struct ao_control_vol {
diff --git a/audio/out/internal.h b/audio/out/internal.h
index 88160bbeb6..518661c2bd 100644
--- a/audio/out/internal.h
+++ b/audio/out/internal.h
@@ -44,6 +44,7 @@ struct ao {
struct input_ctx *input_ctx;
struct mp_log *log; // Using e.g. "[ao/coreaudio]" as prefix
int init_flags; // AO_INIT_* flags
+ bool stream_silence; // if audio inactive, just play silence
// The device as selected by the user, usually using ao_device_desc.name
// from an entry from the list returned by driver->list_devices. If the
diff --git a/audio/out/pull.c b/audio/out/pull.c
index 89805809b7..2175a58db0 100644
--- a/audio/out/pull.c
+++ b/audio/out/pull.c
@@ -185,7 +185,7 @@ static double get_delay(struct ao *ao)
static void reset(struct ao *ao)
{
struct ao_pull_state *p = ao->api_priv;
- if (ao->driver->reset)
+ if (!ao->stream_silence && ao->driver->reset)
ao->driver->reset(ao); // assumes the audio callback thread is stopped
set_state(ao, AO_STATE_NONE);
for (int n = 0; n < ao->num_planes; n++)
@@ -195,7 +195,7 @@ static void reset(struct ao *ao)
static void pause(struct ao *ao)
{
- if (ao->driver->reset)
+ if (!ao->stream_silence && ao->driver->reset)
ao->driver->reset(ao);
set_state(ao, AO_STATE_NONE);
}
@@ -244,6 +244,10 @@ static int init(struct ao *ao)
p->buffers[n] = mp_ring_new(ao, ao->buffer * ao->sstride);
atomic_store(&p->state, AO_STATE_NONE);
assert(ao->driver->resume);
+
+ if (ao->stream_silence)
+ ao->driver->resume(ao);
+
return 0;
}