audioplayer blocks indefinitly if device is unplugged during playback
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Altaïr
le 10 Juil 2025
Modifié(e) : Altaïr
le 10 Juil 2025
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.
Réponses (0)
Voir également
Catégories
En savoir plus sur Audio and Video Data dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!