Skip to content
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

ALSA lib pcm.c:8306:(snd_pcm_recover) underrun occurred #45

Open
jorgelscati opened this issue Nov 23, 2020 · 3 comments
Open

ALSA lib pcm.c:8306:(snd_pcm_recover) underrun occurred #45

jorgelscati opened this issue Nov 23, 2020 · 3 comments

Comments

@jorgelscati
Copy link

Sometimes, I am getting this error when some wav files are playing.

I have an application that plays a wav file in loop. This app is querying if wav is playing every time. If it is not playing, it plays again.

The error occurred when wav file is play again.

This is the simplified code:

import time
import simpleaudio

WAV = "02_off.wav"

def play():
    last_wave_object = simpleaudio.WaveObject.from_wave_file(WAV)
    last_play_object = last_wave_object.play()
    alive = True
    while alive:
        try:
            if last_play_object.is_playing():
                print("Already it's playing")
            else:
                print("Wav reaches end. Starting again")
                last_play_object = last_wave_object.play()
        except KeyboardInterrupt:
            alive = False
        finally:
            time.sleep(0.25)

if __name__ == "__main__":
    play()

And, I attach the wav file.
02_off.zip

The output will be some like:

Already it's playing
Already it's playing
Already it's playing
Already it's playing
Already it's playing
Already it's playing
Already it's playing
Already it's playing
Already it's playing
Already it's playing
Already it's playing
Already it's playing
Already it's playing
Wav reaches end. Starting again
Already it's playing
Already it's playing
Already it's playing
Already it's playing
Already it's playing
Already it's playing
Already it's playing
Already it's playing
Already it's playing
Already it's playing
Already it's playing
Already it's playing
Wav reaches end. Starting again
ALSA lib pcm.c:8306:(snd_pcm_recover) underrun occurred
Already it's playing
Already it's playing
Already it's playing
Already it's playing
@jorgelscati
Copy link
Author

Sorry.

I test on:

  • Ubuntu 18.04
  • simpleaudio 1.0.4
  • python 3.6.9

@jorgelscati
Copy link
Author

The error depends wav file played. With other wav files, it does not happen.

@jorgelscati
Copy link
Author

I have tried to stop audio before playing again. And also, make a new "wav_object".

The "else" code is changed to:

else:
    simpleaudio.stop_all()
    time.sleep(1)
    print("Wav reaches end. Starting again")
    last_wave_object = simpleaudio.WaveObject.from_wave_file(WAV)
    last_play_object = last_wave_object.play()

Maybe, it is needed more time to error happens, but error occurred too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant