audioplayer blocks indefinitly if device is unplugged during playback
2 次查看(过去 30 天)
显示 更早的评论
Hi,
I am using the matlab audioplayer in a condition where the audiodevice may be unplugged or restarted during operation.
Both with audioplayer.play() and audioplayer.playblocking() I experienced that Matlab stalls when the playback device is unplugged and does not even recover when the device is plugged in again.
Stopping from MatLab prompt with Ctrl+C does not work.
Only working solution at the moment is to terminate MatLab with Ctrl+Alt+DEL, which of course is not the solution I want.
Has anybody dealt with the same issue and can provide a solution?
Best regards
2 个评论
Altaïr
2025-7-10
编辑:Altaïr
2025-7-10
I observed that when the active audio output device is disconnected, the audio continues on another available output device and sometimes an error appears stating the device is unresponsive. I didn't observe freezing of MATLAB. Here are a few steps that can be tried to investigate the issue:
1. Test if the beep command functions as expected.
2. Try running the following code:
load('handel.mat') ;
player = audioplayer(y, Fs) ;
play(player) ;
While the audio is playing, unplug the device and observe if MATLAB becomes unresponsive.
3. Retrieve information about connected audio devices:
info = audiodevinfo() ;
struct2table(info.output)
Ensure that the connected audio devices are listed. After unplugging any device, running audiodevreset will refresh the device information.
4. If the Handel example does not work, use the table from the previous step to identify suitable output audio devices and note their IDs (third column). Test playback for each device using:
load('handel.mat') ;
player = audioplayer(y, Fs, 8, 5) ; % <-- replace the 5 here by relevant device ID(s), one at a time
play(player) ;
This can help determine if the issue persists with other audio output devices.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!