diff options
author | Thomas Weißschuh <thomas@t-8ch.de> | 2024-02-05 08:27:03 +0100 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2024-02-15 16:43:25 +0000 |
commit | 790b12da8908654f38a992f7fc79beb4d51ab4f6 (patch) | |
tree | 4269c7cfbf5697bcefca3ca8061563e80c7dd52f /audio/out | |
parent | 195aa7fd962d011922ec005a73bd4b66c953d9f6 (diff) | |
download | mpv-790b12da8908654f38a992f7fc79beb4d51ab4f6.tar.bz2 mpv-790b12da8908654f38a992f7fc79beb4d51ab4f6.tar.xz |
ao_pipewire: don't interpret unknown formats
Interpreting data in the wrong sample format has unpredictable results
and may damage hardware and hurt users.
Instead error out.
Diffstat (limited to 'audio/out')
-rw-r--r-- | audio/out/ao_pipewire.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/audio/out/ao_pipewire.c b/audio/out/ao_pipewire.c index 3fbcbf613d..82bb060b6a 100644 --- a/audio/out/ao_pipewire.c +++ b/audio/out/ao_pipewire.c @@ -86,7 +86,7 @@ struct id_list { struct spa_list node; }; -static enum spa_audio_format af_fmt_to_pw(struct ao *ao, enum af_format format) +static enum spa_audio_format af_fmt_to_pw(enum af_format format) { switch (format) { case AF_FORMAT_U8: return SPA_AUDIO_FORMAT_U8; @@ -99,9 +99,7 @@ static enum spa_audio_format af_fmt_to_pw(struct ao *ao, enum af_format format) case AF_FORMAT_S32P: return SPA_AUDIO_FORMAT_S32P; case AF_FORMAT_FLOATP: return SPA_AUDIO_FORMAT_F32P; case AF_FORMAT_DOUBLEP: return SPA_AUDIO_FORMAT_F64P; - default: - MP_WARN(ao, "Unhandled format %d\n", format); - return SPA_AUDIO_FORMAT_UNKNOWN; + default: return SPA_AUDIO_FORMAT_UNKNOWN; } } @@ -580,10 +578,10 @@ static int init(struct ao *ao) pw_properties_setf(props, PW_KEY_NODE_RATE, "1/%d", ao->samplerate); - enum spa_audio_format spa_format = af_fmt_to_pw(ao, ao->format); + enum spa_audio_format spa_format = af_fmt_to_pw(ao->format); if (spa_format == SPA_AUDIO_FORMAT_UNKNOWN) { - ao->format = AF_FORMAT_FLOATP; - spa_format = SPA_AUDIO_FORMAT_F32P; + MP_ERR(ao, "Unhandled format %d\n", ao->format); + goto error_props; } struct spa_audio_info_raw audio_info = { |