bmc0 / dsp

An audio processing program with an interactive mode.
ISC License
219 stars 31 forks source link

pause and seek bug #29

Closed sjfricke closed 6 years ago

sjfricke commented 6 years ago

I have found if you pause the audio clip, then seek, it will get stuck looping the clip you are seeking to.

Note: This is running on Ubuntu

./dsp: output: plughw:0,1; type=alsa enc=s16 precision=16 channels=1 fs=44100 frames=682111 [00:00:15.47]
./dsp: input: ../test.wav; type=ffmpeg/pcm_s16le enc=s16 precision=16 channels=1 fs=44100 frames=682111 [00:00:15.47]

Might have time later to try and PR a fix, more of a FYI issue

bmc0 commented 6 years ago

I've not seen this behavior and can't reproduce it. Could you be more specific about what you did to trigger the bug and what it actually does? Does it loop the whole thing? Just a small portion at the end? Looping a short section indicates that it's probably a hardware problem or a bug somewhere in ALSA (probably the device driver). If you have another sound card, you could see if the problem happens with that device too.

sjfricke commented 6 years ago

Recloned and rebuilt it

Big Note: I am running this on a Qualcomm Dragonboard 410c

./configure

enabled dsp
[dsp] enabled gpl code (reverb.o g2reverb.o)
[dsp] enabled ladspa_host.o
[dsp] disabled sndfile.o (sndfile)
[dsp] enabled ffmpeg.o (libavcodec libavformat libavutil)
[dsp] enabled resample.o fir.o (fftw3)
[dsp] disabled zita_convolver.o
[dsp] enabled alsa.o (alsa)
[dsp] disabled ao.o (ao)
[dsp] disabled mp3.o (mad)
[dsp] enabled pulse.o (libpulse-simple)
enabled ladspa_dsp
[ladspa_dsp] enabled gpl code (reverb.o g2reverb.o)
[ladspa_dsp] enabled ladspa_host.o
[ladspa_dsp] enabled fir.o (fftw3)
[ladspa_dsp] disabled zita_convolver.o
[ladspa_dsp] disabled sndfile.o (sndfile)
[ladspa_dsp] enabled ffmpeg.o (libavcodec libavformat libavutil)

After make installing I ran

./dsp ../test.wav as and same output as above

I then hit c to pause and when I press . to seek forward it turns into an infinite loop of that last frame of audio. If I keep seeking around its still the same frame, but when I unpause it resumes nicely. I can pause and seek and the same issue happens.

With verbose mode on I got this

wav @ 0xaaab0cfcd470] parser not found for codec pcm_s16le, packets or times may be invalid.
./dsp: input: /home/linaro/test.wav; type=ffmpeg/pcm_s16le enc=s16 precision=16 channels=2 fs=44100 frames=682111 [00:00:15.47]
./dsp: pulse: failed to open device: Connection refused
./dsp: output: plughw:0,1; type=alsa enc=s16 precision=16 channels=2 fs=44100 frames=682111 [00:00:15.47]
./dsp: info: running interactively; type 'h' for help
./dsp: info: dither off
./dsp: input: /home/linaro/test.wav; type=ffmpeg/pcm_s16le enc=s16 precision=16 channels=2 fs=44100 frames=682111 [00:00:15.47]
bmc0 commented 6 years ago

Sounds like the driver for the audio codec on that board doesn't like it when you call snd_pcm_drop() and then snd_pcm_prepare() when it's in a paused state. You can try the patch below, which delays calling snd_pcm_prepare() until the next block of audio is read/written.

dsp_alsa_defer_prepare.patch.txt

If that doesn't work you can try simply deleting everything in the alsa_drop() function in alsa.c. This will cause a delay between seeking (and other things) and actually hearing the result of the seek, but it may fix the problem you're describing.

sjfricke commented 6 years ago

Well, that patch worked!

Thanks for the quick help!

bmc0 commented 6 years ago

You're welcome. The workaround is in the master branch now, so I'm going to close this.