Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Crash] WASAPI output causes unhandled exception when device is lost in paused state and playback is resumed #1880

Open
maxmitti opened this issue Oct 15, 2023 · 3 comments
Labels

Comments

@maxmitti
Copy link
Contributor

maxmitti commented Oct 15, 2023

Bug report

WASAPI output causes unhandled exception when device is lost in paused state and playback is resumed.

  • Start playback on WASAPI output
  • Pause playback
  • Unplug/deactivate audio device
  • Resume playback
  • mpd terminates.

Expected Behavior

No termination. Try to reopen the device or stop playback.

Actual Behavior

mpd terminates due to an unhandled exception.

Version

Music Player Daemon 0.23.14 (0.23.14)
Copyright 2003-2007 Warren Dukes <warren.dukes@gmail.com>
Copyright 2008-2021 Max Kellermann <max.kellermann@gmail.com>
This is free software; see the source for copying conditions.  There is NO
warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Database plugins:
 simple proxy

Storage plugins:
 local nfs curl


Decoders plugins:
 [vorbis] ogg oga
 [oggflac] ogg oga
 [flac] flac
 [opus] opus ogg oga
 [dsdiff] dff
 [dsf] dsf
 [hybrid_dsd] m4a
 [openmpt] mptm mod s3m xm it 669 amf ams c67 dbm digi dmf dsm dtm far imf ice j2b m15 mdl med mms mt2 mtm nst okt plm psm pt36 ptm sfx sfx2 st26 stk stm stp ult wow gdm mo3 oxm umx xpk ppm mmcmp
 [modplug] 669 amf ams dbm dfm dsm far it med mdl mod mtm mt2 okt s3m stm ult umx xm
 [wildmidi] mid
 [gme] ay gbs gym hes kss nsf nsfe rsn sap spc vgm vgz
 [ffmpeg] 16sv 3g2 3gp 4xm 8svx aa3 aac ac3 adx afc aif aifc aiff al alaw amr anim apc ape asf atrac au aud avi avm2 avs bap bfi c93 cak cin cmv cpk daud dct divx dts dv dvd dxa eac3 film flac flc fli fll flx flv g726 gsm gxf iss m1v m2v m2t m2ts m4a m4b m4v mad mj2 mjpeg mjpg mka mkv mlp mm mmf mov mp+ mp1 mp2 mp3 mp4 mpc mpeg mpg mpga mpp mpu mve mvi mxf nc nsv nut nuv oga ogm ogv ogx oma ogg omg opus psp pva qcp qt r3d ra ram rl2 rm rmvb roq rpl rvc shn smk snd sol son spx str swf tak tgi tgq tgv thp ts tsp tta xa xvid uv uv2 vb vid vob voc vp6 vmd wav webm wma wmv wsaud wsvga wv wve
 [pcm]

Filters:


Tag plugins:


Output plugins:
 null jack httpd snapcast recorder winmm wasapi

Encoder plugins:
 null vorbis opus lame wave flac

Input plugins:
 file curl ffmpeg nfs

Playlist plugins:
 extm3u m3u pls xspf asx rss flac cue embcue

Protocols:
 http:// https:// nfs://

Other features:
 ipv6 tcp

Configuration

music_directory "C:\Users\User\Documents\MPD\music"

audio_output {
        type "wasapi"
        name "WASAPI"
}

Log

client: command returned 0
client: [11] process command list returned 0
client: [11] closed
client: [12] opened from 10.0.0.11:36922
client: [12] process command "play"
playlist: play 0:"https://cf-media.sndcdn.com/TnxvRDNapufm.128.mp3?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiKjovL2NmLW1lZGlhLnNuZGNkbi5jb20vVG54dlJETmFwdWZtLjEyOC5tcDMqIiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNjk3MzY3ODE1fX19XX0_&Signature=MR~9euKNhUm69eoXZfM-MM~-eXlj9meYms9OMeE917LxisZoZUkDFSpzLdbBkPtz698XA1w2ALfNRoPctgK81anmKauNX~9rqU7-0hR0T6Ovp6gk4yVcVd3HR3lSqTWsAcSPg7KDLQEKoIXaCzngDx7pfdHHt2BLTB2tYyDYIom2j0hTvUWQN7I8PeOkozTSi0tCn3yAH7VCBkIgn04h3AXK6NXjvweu0NTBySBGny-NnQO3Q-RSAtGxeV1HdMixYj0uoozF6igYTED6y7Zb0fhm2hJza1RCiIaBjmbM2Cov08ki5c7~RK~Co1KQjImTt1vOFkjWlsvCSnIuvI6stg__&Key-Pair-Id=APKAI6TU7MMXM5DG6EPQ"
client: [12] command returned 0
client: [12] process command list
client: process command "status"
client: command returned 0
client: process command "currentsong"
client: command returned 0
client: [12] process command list returned 0
client: [12] closed
decoder_thread: probing plugin ffmpeg
ffmpeg/mp3: Format mp3 probed with size=4096 and score=51
ffmpeg/mp3: pad 576 576
ffmpeg/mp3: Skipping 0 bytes of junk at 417.
ffmpeg: detected input format 'mp3'
ffmpeg/mp3: Before avformat_find_stream_info() pos: 417 bytes read:16512 seeks:2 nb_streams:1
ffmpeg/mp3: demuxer injecting skip 1105 / discard 0
ffmpeg/mp3float: skip 1105 / discard 0 samples due to side data
ffmpeg/mp3float: skip 1105/1152 samples
ffmpeg/mp3: All info found
ffmpeg/mp3: stream 0: start_time: 0.0250567 duration: 325.799
ffmpeg/mp3: format: start_time: 0.025057 duration: 325.799 (estimate from stream) bitrate=128 kb/s
ffmpeg/mp3: After avformat_find_stream_info() pos: 21921 bytes read:32896 seeks:2 frames:50
ffmpeg: codec 'mp3'
decoder: audio_format=44100:f:2, seekable=true
ffmpeg/mp3float: skip 1105 / discard 0 samples due to side data
ffmpeg/mp3float: Could not update timestamps for skipped samples.
ffmpeg/mp3float: skip 1105/1152 samples
wasapi_output: Trying 48000:f:2 48000 32-32 (shared) -> NO_ERROR
wasapi_output: Default device period: 10000000 ns, Minimum device period: 3000000 ns
wasapi_output: Buffer duration: 50000000 ns
output: opened "WASAPI" (wasapi) audio_format=48000:f:2
output: converting in=44100:f:2 -> f=44100:f:2 -> out=48000:f:2
wasapi_output: Working thread started
client: [13] opened from 10.0.0.11:46586
client: [13] process command "pause "1""
client: [13] command returned 0
client: [13] process command list
client: process command "status"
client: command returned 0
client: process command "currentsong"
client: command returned 0
client: [13] process command list returned 0
client: [13] closed
client: [14] opened from 10.0.0.11:43528
client: [14] process command "play"
output: converting in=44100:f:2 -> f=44100:f:2 -> out=48000:f:2
client: [14] command returned 0
client: [14] process command list
client: process command "status"
mixer: Failed to read mixer for 'WASAPI': Unable to get service: AUDCLNT_E_DEVICE_INVALIDATED
client: command returned 0
client: process command "currentsong"
client: command returned 0
client: [14] process command list returned 0
client: [14] closed
terminate called after throwing an instance of 'std::system_error'
  what():  Failed to start client: AUDCLNT_E_DEVICE_INVALIDATED

Backtrace

(gdb) bt
#0  0x00007ff64b452bc7 in __cxa_throw ()
#1  0x00007ff64b3f6631 in GetService<ISimpleAudioVolume> (client=...)
    at ../../src/output/plugins/wasapi/AudioClient.hxx:98
#2  WasapiMixer::GetVolume()::{lambda()#1}::operator()() const (
    __closure=0x3afb080) at ../../src/mixer/plugins/WasapiMixerPlugin.cxx:70
#3  std::__invoke_impl<int, WasapiMixer::GetVolume()::{lambda()#1}>(std::__invoke_other, WasapiMixer::GetVolume()::{lambda()#1}&&) (__f=...)
    at /usr/lib/gcc/x86_64-w64-mingw32/12-win32/include/c++/bits/invoke.h:61
#4  std::__invoke<WasapiMixer::GetVolume()::{lambda()#1}>(WasapiMixer::GetVolume()::{lambda()#1}&&) (__fn=...)
    at /usr/lib/gcc/x86_64-w64-mingw32/12-win32/include/c++/bits/invoke.h:96
#5  std::invoke<WasapiMixer::GetVolume()::{lambda()#1}>(WasapiMixer::GetVolume()::{lambda()#1}&&) (__fn=...)
    at /usr/lib/gcc/x86_64-w64-mingw32/12-win32/include/c++/functional:110
#6  COMWorker::Async<WasapiMixer::GetVolume()::{lambda()#1}>(WasapiMixer::GetVolume()::{lambda()#1}&&)::{lambda()#1}::operator()() (__closure=0x3afb080)
    at ../../src/win32/ComWorker.hxx:62
#7  std::__invoke_impl<void, COMWorker::Async<WasapiMixer::GetVolume()::{lambda()#1}>(WasapiMixer::GetVolume()::{lambda()#1}&&)::{lambda()#1}&>(std::__invoke_other, COMWorker::Async<WasapiMixer::GetVolume()::{lambda()#1}>(WasapiMixer::GetVolume()::{lambda()#1}&&)::{lambda()#1}&) (__f=...)
    at /usr/lib/gcc/x86_64-w64-mingw32/12-win32/include/c++/bits/invoke.h:61
#8  std::__invoke_r<void, COMWorker::Async<WasapiMixer::GetVolume()::{lambda()#1}>(WasapiMixer::GetVolume()::{lambda()#1}&&)::{lambda()#1}&>(COMWorker::Async<WasapiMixer::GetVolume()::{lambda()#1}>(WasapiMixer::GetVolume()::{lambda()#1}&&)::{lambda()#1}&) (__fn=...)
    at /usr/lib/gcc/x86_64-w64-mingw32/12-win32/include/c++/bits/invoke.h:111
#9  std::_Function_handler<void (), COMWorker::Async<WasapiMixer::GetVolume()::{lambda()#1}>(WasapiMixer::GetVolume()::{lambda()#1}&&)::{lambda()#1}>::_M_invoke(std::_Any_data const&) (__functor=...)
    at /usr/lib/gcc/x86_64-w64-mingw32/12-win32/include/c++/bits/std_function.h:290
#10 0x00007ff64b357adf in std::function<void ()>::operator()() const (
    this=0x40dfe60)
    at /usr/lib/gcc/x86_64-w64-mingw32/12-win32/include/c++/bits/std_function.h:591
#11 COMWorker::Work (this=0x3aec0f0) at ../../src/win32/ComWorker.cxx:38
#12 0x00007ff64b34884d in BoundMethod<void () noexcept>::operator()() const (
    this=<optimized out>) at ../../src/util/BindMethod.hxx:78
#13 Thread::Run (this=<optimized out>) at ../../src/thread/Thread.cxx:63
#14 Thread::ThreadProc (ctx=<optimized out>) at ../../src/thread/Thread.cxx:77
#15 0x00007fff39227614 in KERNEL32!BaseThreadInitThunk ()
   from C:\Windows\System32\kernel32.dll
#16 0x00007fff393626f1 in ntdll!RtlUserThreadStart ()
   from C:\Windows\SYSTEM32\ntdll.dll
#17 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) cont
Continuing.
[Thread 9172.0x292c exited with code 3]
[Thread 9172.0x3738 exited with code 3]
[Thread 9172.0x1778 exited with code 3]
[Thread 9172.0x2268 exited with code 3]
[Thread 9172.0x57c exited with code 3]
[Thread 9172.0x34c8 exited with code 3]
[Thread 9172.0x2e70 exited with code 3]
[Thread 9172.0x3220 exited with code 3]
[Thread 9172.0x16a8 exited with code 3]
[Thread 9172.0x21ac exited with code 3]
[Thread 9172.0x2068 exited with code 3]
[Thread 9172.0x1b0 exited with code 3]
[Thread 9172.0x1e34 exited with code 3]
[Thread 9172.0x11a0 exited with code 3]
[Thread 9172.0x18d0 exited with code 3]
[Thread 9172.0x2e18 exited with code 3]
terminate called after throwing an instance of 'std::system_error'
  what():  Failed to start client: AUDCLNT_E_DEVICE_INVALIDATED
[Inferior 1 (process 9172) exited with code 03]
@Fulgen301
Copy link

AUDCLNT_E_DEVICE_INVALIDATED

This has its own page in the documentation: https://learn.microsoft.com/en-us/windows/win32/coreaudio/recovering-from-an-invalid-device-error

@MaxKellermann
Copy link
Member

@ibmibmibm?

@MaxKellermann
Copy link
Member

Sorry, still no reply from @ibmibmibm, the author of the offending code - and since I don't have Windows, I'm unable to provide support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants