-
Notifications
You must be signed in to change notification settings - Fork 802
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
Fixed alsa dev read pcm bug #4206
Conversation
|
||
snd_pcm_uframes_t avail; | ||
avail = snd_pcm_avail(pcm); | ||
if (avail > 0 && avail <= nframes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be >=0 and < nframes
? We shouldn't need to sleep and continue when we already have nframes
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when snd_pcm_prepare called,the snd_pcm_state is SND_PCM_STATE_PREPARED,snd_pcm_avail will return 0 always,need call snd_pcm_readi or snd_pcm_stop to change state to SND_PCM_STATE_RUNNING. i will update code with snd_pcm_state check later.
I tried to reproduce it here using a USB/removable sound card during a call/sound card is used, however it doesn't block instead printing this on the log:
Any specific scenario to trigger this issue? |
set playback device plughw:usb sound card,and set capture device default. |
ff98f3c
to
6c329bb
Compare
Still couldn't reproduce it. Based on the doc the |
i insert two same usb soundcard,if it doesn't work too,maybe my soundcard bugs. |
Perhaps you can consider submitting your issue to https://github.com/alsa-project/alsa-lib/issues (https://www.alsa-project.org/wiki/Bug_Tracking). |
remove sound card device when capture audio data, the alsa audio cache may less than nframes, snd_pcm_readi wait for audio data forever.so when close the audio device ,the ca_thread_func can`t quite.use snd_pcm_avail to make sure audio cache has enough audio data.