audioplayer blocks indefinitly if device is unplugged during playback

2 visualizaciones (últimos 30 días)
Thilo
Thilo el 24 de Jun. de 2025
Editada: Altaïr el 10 de Jul. de 2025
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 comentarios
Altaïr
Altaïr el 10 de Jul. de 2025
Editada: Altaïr el 10 de Jul. de 2025
Hey @Thilo,
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.
Altaïr
Altaïr el 10 de Jul. de 2025
Editada: Altaïr el 10 de Jul. de 2025
I think this query can be better resolved by MathWorks Technical Support. Feel free to raise a case at the following page:

Iniciar sesión para comentar.

Respuestas (0)

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by