Mpv crashes when Windows switches audio channels/config.
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 37k
- Forks
- 3.5k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 22
Description
Important Information
- mpv version: 0.34.0-325-g602995fd40 Copyright © 2000-2022 mpv/MPlayer/mplayer2 projects (built on Sun Jun 12 12:22:05 2022)
- Windows Version: Windows 10 Pro 20H2 v19042.985
- Source of the mpv binary: https://sourceforge.net/projects/mpv-player-windows/files
- If known which version of mpv introduced the problem: Don't know, but In version '0.22.0-git-1d4273c (C) 2000-2016 mpv/MPlayer/mplayer2 projects (built on Sun Nov 20 18:59:12 CET 2016)', the error was not present.
- update: version 0.32.0-645-g7f67c5250a Copyright © 2000-2020 mpv/MPlayer/mplayer2 projects (built on Sun Aug 16 15:31:30 +08 2020), works fine (log below)
- update2: after trying many files, the last working version for me is 0.32.0-690-gbb1f821078
- from 0.32.0-713-gf57b90b069 starts failing.
Reproduction steps
My PC is connected via HDMI (from GTX 1080) to and audio receiver (Yamaha RX-V385). It tunnels my video and audio to get 24bit 192khz and 5 channels support.
I don't turn off my PC at night, but I turn off monitors/audio. When I do that, the audio channel of Windows switches to 2.0 48khz. I expect mpv to switch audio channels too.
Actual behavior
Mpv doesn't switch audio channels and crashes. No error msg on screen, just closes by itself. There is an error in the log file. It's annoying because If I pause a video, go to sleep, and want to continue watching it the next day, I have to re open it and manual seek where I left off. It's ok if It loses audio focus, I just want to avoid the crash.
Log file [0.34v]
[ 525.746][v][ao/wasapi] OnDeviceStateChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}: requesting ao reload
[ 525.746][d][ao/wasapi] Uninit wasapi
[ 525.746][d][ao/wasapi] Thread Reset
[ 525.746][d][ao/wasapi] Thread shutdown
[ 525.746][v][ao/wasapi] OnDefaultDeviceChanged triggered: requesting ao reload
[ 525.748][d][ao/wasapi] Thread uninit done
[ 525.748][d][ao/wasapi] Thread return
[ 525.979][v][ao/wasapi] OnPropertyValueChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}
[ 525.979][v][ao/wasapi] Changed property: {b3f8fa53-0004-438e-9003-51a46e139bfc},11
[ 525.979][v][ao/wasapi] OnPropertyValueChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}
[ 525.979][v][ao/wasapi] Changed property: {b3f8fa53-0004-438e-9003-51a46e139bfc},12
[ 525.988][d][ao/wasapi] Uninit wasapi done
[ 525.989][v][af] User filter list:
[ 525.989][v][af] (empty)
[ 525.989][v][af] [in] 48000Hz stereo 2ch floatp
[ 525.989][v][af] [userspeed] 48000Hz stereo 2ch floatp
[ 525.989][v][af] [convert] 48000Hz stereo 2ch floatp
[ 525.989][v][ao] Trying audio driver 'wasapi'
[ 525.989][v][ao/wasapi] requested format: 48000 Hz, stereo channels, floatp
[ 525.989][d][ao/wasapi] Init wasapi
[ 525.989][d][ao/wasapi] Find device ''
[ 525.994][v][ao/wasapi] No device specified. Selecting default.
[ 525.998][v][ao/wasapi] Selecting device '{d3473d28-a696-4460-aed3-a0ef20895592}' (RX-V385 Center (NVIDIA High Definition Audio))
[ 525.998][v][ao/wasapi] Monitoring changes in device {0.0.0.00000000}.{d3473d28-a696-4460-aed3-a0ef20895592}
[ 526.012][d][ao/wasapi] Init wasapi thread
[ 526.012][d][ao/wasapi] Activating pAudioClient interface
[ 526.013][d][ao/wasapi] Probing formats
[ 526.017][v][ao/wasapi] Trying stereo float (32/32 bits) @ 192000hz (shared) -> unsupported
[ 526.017][v][ao/wasapi] Fallback to mix format 5.1 float (32/32 bits) @ 192000hz
[ 526.017][v][ao/wasapi] Accepted as 5.1 float @ 192000hz -> 5.1 float (32/32 bits) @ 192000hz (shared)
[ 526.017][d][ao/wasapi] Fixing format
[ 526.017][d][ao/wasapi] IAudioClient::GetDevicePeriod
[ 526.018][v][ao/wasapi] Device period: 10 ms
[ 526.018][d][ao/wasapi] IAudioClient::Initialize
[ 526.023][e][ao/wasapi] Error initializing device: AUDCLNT_E_UNSUPPORTED_FORMAT (0x88890008)
[ 526.023][d][ao/wasapi] Thread shutdown
[ 526.023][d][ao/wasapi] Uninit wasapi
[ 526.023][d][ao/wasapi] Thread uninit done
[ 526.023][d][ao/wasapi] Thread return
[ 526.023][d][ao/wasapi] Uninit wasapi done
[ 526.023][v][ao] Trying audio driver 'openal'
[ 526.023][v][ao/openal] requested format: 48000 Hz, stereo channels, floatp
[ 526.040][w][ao/openal] Direct channels aren't supported by this version of OpenAL
Same thing happens with --no-config
Log file of the OLD (not crashing) version [0.22v]
[ 10.964][v][ao/wasapi] OnDeviceStateChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}: requesting ao reload
[ 10.965][v][ao/wasapi] OnDefaultDeviceChanged triggered: requesting ao reload
[ 11.202][v][ao/wasapi] OnPropertyValueChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}
[ 11.202][v][ao/wasapi] Changed property: {b3f8fa53-0004-438e-9003-51a46e139bfc},11
[ 11.203][v][ao/wasapi] OnPropertyValueChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}
[ 11.203][v][ao/wasapi] Changed property: {b3f8fa53-0004-438e-9003-51a46e139bfc},12
[ 11.236][v][ao/wasapi] OnPropertyValueChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}
[ 11.236][v][ao/wasapi] Changed property: {b3f8fa53-0004-438e-9003-51a46e139bfc},24
[ 11.236][v][ao/wasapi] OnPropertyValueChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}
[ 11.236][v][ao/wasapi] Changed property: {b3f8fa53-0004-438e-9003-51a46e139bfc},27
[ 11.237][v][ao/wasapi] OnPropertyValueChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}
[ 11.237][v][ao/wasapi] Changed property: {540b947e-8b40-45bc-a8a2-6a0b894cbda2},9
[ 11.237][v][ao/wasapi] OnPropertyValueChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}
[ 11.237][v][ao/wasapi] Changed property: {8943b373-388c-4395-b557-bc6dbaffafdb},2
[ 11.238][v][ao/wasapi] OnPropertyValueChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}
[ 11.238][v][ao/wasapi] Changed property: {fb1de864-e06d-47f4-82a6-8a0aef44493c},2
[ 11.238][v][ao/wasapi] OnPropertyValueChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}
[ 11.238][v][ao/wasapi] Changed property: {b3f8fa53-0004-438e-9003-51a46e139bfc},5
[ 11.270][v][ao/wasapi] OnPropertyValueChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}
[ 11.270][v][ao/wasapi] Changed property: {194ef948-7cdb-403e-9f47-19418f7b24fd},1
[ 11.281][v][af] Removing filter lavrresample
[ 11.281][v][af] Removing filter volume
[ 11.281][v][af] Adding filter lavrresample
[ 11.281][v][lavrresample] Remix: stereo -> 5.1
[ 11.281][v][af] Audio filter chain:
[ 11.281][v][af] [in] 48000Hz stereo 2ch floatp
[ 11.281][v][af] [lavrresample] 192000Hz 5.1 6ch float [a]
[ 11.281][v][af] [out] 192000Hz 5.1 6ch float
[ 11.281][v][af] [ao] 192000Hz 5.1 6ch float
[ 11.281][v][cplayer] Inserting volume filter.
[ 11.281][v][af] Adding filter volume
[ 11.281][v][af] Removing filter lavrresample
[ 11.281][v][af] Adding filter lavrresample
[ 11.281][v][lavrresample] Remix: stereo -> 5.1
[ 11.282][v][af] Audio filter chain:
[ 11.282][v][af] [in] 48000Hz stereo 2ch floatp
[ 11.282][v][af] [volume] "softvol" 48000Hz stereo 2ch floatp
[ 11.282][v][af] [lavrresample] 192000Hz 5.1 6ch float [a]
[ 11.282][v][af] [out] 192000Hz 5.1 6ch float
[ 11.282][v][af] [ao] 192000Hz 5.1 6ch float
[ 11.282][v][af] Removing filter lavrresample
[ 11.282][v][af] Adding filter lavrresample
[ 11.282][v][lavrresample] Remix: stereo -> 5.1
[ 11.282][v][af] Moving up output conversion.
[ 11.282][v][lavrresample] Remix: stereo -> 5.1
[ 11.282][v][af] Audio filter chain:
[ 11.282][v][af] [in] 48000Hz stereo 2ch floatp
[ 11.282][v][af] [lavrresample] 192000Hz 5.1 6ch float [a]
[ 11.282][v][af] [volume] "softvol" 192000Hz 5.1 6ch float
[ 11.282][v][af] [out] 192000Hz 5.1 6ch float
[ 11.282][v][af] [ao] 192000Hz 5.1 6ch float
[ 11.282][v][volume] volume gain: 0.015625
[ 11.282][v][af] Removing filter lavrresample
[ 11.282][v][af] Audio filter chain:
[ 11.282][v][af] [in] 48000Hz stereo 2ch floatp
[ 11.282][v][af] [volume] "softvol" 48000Hz stereo 2ch floatp
[ 11.282][v][af] [out] 48000Hz stereo 2ch floatp
[ 11.282][v][af] [ao] 48000Hz stereo 2ch floatp
[ 11.282][v][ao] Trying audio driver 'wasapi'
[ 11.282][v][ao/wasapi] requested format: 48000 Hz, stereo channels, floatp
[ 11.284][v][ao/wasapi] No device specified. Selecting default.
[ 11.287][v][ao/wasapi] Selecting device '{87eaef72-536e-4e60-8dc3-9420a27617ce}' (Yamaha (NVIDIA High Definition Audio))
[ 11.295][v][ao/wasapi] Monitoring changes in device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}
[ 11.296][v][ao/wasapi] Trying stereo float @ 48000hz (shared)
[ 11.304][v][ao/wasapi] OnPropertyValueChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}
[ 11.304][v][ao/wasapi] Changed property: {b3f8fa53-0004-438e-9003-51a46e139bfc},24
[ 11.304][v][ao/wasapi] OnPropertyValueChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}
[ 11.304][v][ao/wasapi] Changed property: {b3f8fa53-0004-438e-9003-51a46e139bfc},27
[ 11.305][v][ao/wasapi] OnPropertyValueChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}
[ 11.305][v][ao/wasapi] Changed property: {540b947e-8b40-45bc-a8a2-6a0b894cbda2},9
[ 11.306][v][ao/wasapi] OnPropertyValueChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}
[ 11.306][v][ao/wasapi] Changed property: {8943b373-388c-4395-b557-bc6dbaffafdb},2
[ 11.306][v][ao/wasapi] OnPropertyValueChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}
[ 11.306][v][ao/wasapi] Changed property: {fb1de864-e06d-47f4-82a6-8a0aef44493c},2
[ 11.306][v][ao/wasapi] Fallback to mix format 5.1 float @ 192000hz
[ 11.306][v][ao/wasapi] Accepted as 5.1 float @ 192000hz (shared)
[ 11.306][v][ao/wasapi] Device period: 10 ms
[ 11.307][v][ao/wasapi] OnPropertyValueChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}
[ 11.307][v][ao/wasapi] Changed property: {b3f8fa53-0004-438e-9003-51a46e139bfc},5
[ 11.310][e][ao/wasapi] Error initializing device: AUDCLNT_E_UNSUPPORTED_FORMAT (0x88890008)
[ 11.310][f][ao/wasapi] Error setting up audio thread: AUDCLNT_E_UNSUPPORTED_FORMAT (0x88890008)
[ 11.310][f][ao/wasapi] Received failure from audio thread
[ 11.310][e][ao] Failed to initialize audio driver 'wasapi'
[ 11.310][e][cplayer] Could not open/initialize audio device -> no sound.
[ 11.310][v][ad] Uninit audio decoder.
[ 11.310][v][af] Removing filter volume
[ 11.310][i][cplayer] Audio: no audio
UPDATE. Another version (more recent) working [0.32v]
[ 33.873][v][ao/wasapi] OnDeviceStateChanged triggered on device {0.0.0.00000000}.{87eaef72-536e-4e60-8dc3-9420a27617ce}: requesting ao reload
[ 33.873][d][ao/wasapi] Uninit wasapi
[ 33.873][d][ao/wasapi] Thread Reset
[ 33.873][d][ao/wasapi] Thread Reset
[ 33.873][d][ao/wasapi] Thread shutdown
[ 33.873][v][ao/wasapi] OnDefaultDeviceChanged triggered: requesting ao reload
[ 33.877][d][ao/wasapi] Thread uninit done
[ 33.877][d][ao/wasapi] Thread return
[ 33.878][d][ao/wasapi] Uninit wasapi done
[ 33.878][v][af] User filter list:
[ 33.878][v][af] (empty)
[ 33.878][v][af] [in] 48000Hz stereo 2ch floatp
[ 33.878][v][af] [userspeed] 48000Hz stereo 2ch floatp
[ 33.878][v][af] [convert] 48000Hz stereo 2ch floatp
[ 33.878][v][ao] Trying audio driver 'wasapi'
[ 33.878][v][ao/wasapi] requested format: 48000 Hz, stereo channels, floatp
[ 33.878][d][ao/wasapi] Init wasapi
[ 33.878][d][ao/wasapi] Find device ''
[ 33.880][v][ao/wasapi] No device specified. Selecting default.
[ 33.886][v][ao/wasapi] Selecting device '{d3473d28-a696-4460-aed3-a0ef20895592}' (RX-V385 Center (NVIDIA High Definition Audio))
[ 33.886][v][ao/wasapi] Monitoring changes in device {0.0.0.00000000}.{d3473d28-a696-4460-aed3-a0ef20895592}
[ 33.888][d][ao/wasapi] Init wasapi thread
[ 33.888][d][ao/wasapi] Activating pAudioClient interface
[ 33.888][d][ao/wasapi] Probing formats
[ 33.894][v][ao/wasapi] Trying stereo float (32/32 bits) @ 192000hz (shared) -> unsupported
[ 33.894][v][ao/wasapi] Fallback to mix format 5.1 float (32/32 bits) @ 192000hz
[ 33.894][v][ao/wasapi] Accepted as 5.1 float @ 192000hz -> 5.1 float (32/32 bits) @ 192000hz (shared)
[ 33.894][d][ao/wasapi] Fixing format
[ 33.894][d][ao/wasapi] IAudioClient::GetDevicePeriod
[ 33.894][v][ao/wasapi] Device period: 10 ms
[ 33.894][d][ao/wasapi] IAudioClient::Initialize
[ 33.900][e][ao/wasapi] Error initializing device: AUDCLNT_E_UNSUPPORTED_FORMAT (0x88890008)
[ 33.900][d][ao/wasapi] Thread shutdown
[ 33.900][d][ao/wasapi] Uninit wasapi
[ 33.900][d][ao/wasapi] Thread uninit done
[ 33.900][d][ao/wasapi] Thread return
[ 33.900][d][ao/wasapi] Uninit wasapi done
[ 33.900][v][ao] Trying audio driver 'openal'
[ 33.900][v][ao/openal] requested format: 48000 Hz, stereo channels, floatp
[ 33.900][f][ao/openal] broken.
[ 33.900][v][ao] Trying audio driver 'sdl'
[ 33.900][v][ao/sdl] requested format: 48000 Hz, stereo channels, floatp
[ 33.905][v][ao/sdl] Channel layouts:
[ 33.905][v][ao/sdl] - mono
[ 33.905][v][ao/sdl] - stereo
[ 33.905][v][ao/sdl] - 2.1
[ 33.905][v][ao/sdl] - 4.0
[ 33.905][v][ao/sdl] - 5.0
[ 33.905][v][ao/sdl] - 5.1
[ 33.905][v][ao/sdl] - 6.1
[ 33.905][v][ao/sdl] - 7.1
[ 33.905][v][ao/sdl] - unknown9
[ 33.905][v][ao/sdl] - unknown10
[ 33.905][v][ao/sdl] - unknown11
[ 33.905][v][ao/sdl] - unknown12
[ 33.905][v][ao/sdl] - unknown13
[ 33.905][v][ao/sdl] - unknown14
[ 33.905][v][ao/sdl] - unknown15
[ 33.905][v][ao/sdl] - unknown16
[ 33.905][v][ao/sdl] result: stereo
[ 33.906][v][ao/sdl] requested format: 48000 Hz, 2 channels, 8120, buffer size: 0 samples
[ 33.913][e][ao/sdl] could not open audio: WASAPI can't initialize audio client: 윰繐ǵ
[ 33.913][e][ao] Failed to initialize audio driver 'sdl'
[ 33.913][e][cplayer] Could not open/initialize audio device -> no sound.
[ 33.913][d][decode_wrapper/ad] Uninit decoder.
[ 33.913][v][mkv] deselect track 5
[ 33.914][i][cplayer] Audio: no audio
[ 33.914][d][osc] osc_init
[ 33.914][d][cplayer] Run command: change-list, flags=64, args=[name="shared-script-properties", operation="append", value="osc-margins=0.000000,0.000000,0.000000,0.000000"]
[ 33.914][v][cplayer] Set property: shared-script-properties -> 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ao/wasapi audio-output path indicated by the logs and compare behavior between the reported working and failing versions. Reproduce a Windows audio-device channel/configuration change while playback is paused, focusing on the AUDCLNT_E_UNSUPPORTED_FORMAT failure and subsequent crash. Done means mpv does not close unexpectedly when the device changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- audio-video-rtc
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100