audioplayer blocks indefinitly if device is unplugged during playback

조회 수: 2 (최근 30일)
Thilo
Thilo 2025년 6월 24일
편집: Altaïr 2025년 7월 10일
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
Altaïr 2025년 7월 10일
편집: Altaïr 2025년 7월 10일
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 2025년 7월 10일
편집: Altaïr 2025년 7월 10일
I think this query can be better resolved by MathWorks Technical Support. Feel free to raise a case at the following page:

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by