diff options
author | Thomas Weißschuh <thomas@t-8ch.de> | 2022-11-29 01:45:12 +0100 |
---|---|---|
committer | Philip Langdale <github.philipl@overt.org> | 2022-12-18 13:34:29 -0800 |
commit | b5373079f20aeeba8ac80e773f3cc05692dbb51f (patch) | |
tree | 1ad815d2fe2202c587db731887349b6cbeea3342 /audio/out | |
parent | f9d0b0c08a35e67976a8c71ac16a832781c2313a (diff) | |
download | mpv-b5373079f20aeeba8ac80e773f3cc05692dbb51f.tar.bz2 mpv-b5373079f20aeeba8ac80e773f3cc05692dbb51f.tar.xz |
ao_pipewire: deactivate stream at end of playback
By explictly shutting down the stream pipewire can deactivate the used
hardware, saving CPU and power.
Fixes #9835
Diffstat (limited to 'audio/out')
-rw-r--r-- | audio/out/ao_pipewire.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/audio/out/ao_pipewire.c b/audio/out/ao_pipewire.c index 4880e776f0..267d649848 100644 --- a/audio/out/ao_pipewire.c +++ b/audio/out/ao_pipewire.c @@ -185,6 +185,11 @@ static void on_process(void *userdata) pw_stream_queue_buffer(p->stream, b); MP_TRACE(ao, "queued %d of %d samples\n", samples, nframes); + + if (samples == 0 && !ao_is_playing(ao)) { + MP_DBG(ao, "end of playback\n"); + pw_stream_flush(p->stream, true); + } } static void on_param_changed(void *userdata, uint32_t id, const struct spa_pod *param) @@ -274,12 +279,21 @@ static void on_control_info(void *userdata, uint32_t id, } } +static void on_drained(void *userdata) { + struct ao *ao = userdata; + struct priv *p = ao->priv; + + MP_DBG(ao, "stream drained\n"); + pw_stream_set_active(p->stream, false); +} + static const struct pw_stream_events stream_events = { .version = PW_VERSION_STREAM_EVENTS, .param_changed = on_param_changed, .process = on_process, .state_changed = on_state_changed, .control_info = on_control_info, + .drained = on_drained, }; static void uninit(struct ao *ao) |