snips-issues icon indicating copy to clipboard operation
snips-issues copied to clipboard

[audio-server] Audio issues using alsa playback backend (drain error + sound is cut)

Open cburghardt opened this issue 4 years ago • 22 comments

What's the issue

I just upgraded my system (Raspi 4 with Stretch packages) to 0.64. Unfortunately the error ALSA function 'snd_pcm_drain' failed with error 'EIO: I/O error' is back. None of the known workarounds fix it. Once I downgraded to 0.63.3 the problem disappears.

Expected Same behavior as 1.2.2

Version

1.3.0 (0.64.0)

Environment

  • Raspberry Pi 4 - Debian Stretch
  • Sound card - Raspberry pi sound card

[workaround edit by @cpoisson ]

Workaround 1 - Back to 0.63.3

Downgrade snips-tts and snips-audio-server to 1.2.2 (0.63.3)

sudo apt install snips-audio-server=0.63.3
sudo apt install snips-tts=0.63.3

Workaround 2 - Back to portaudio

Switch back to portaudio for playback.

  • Add portaudio_playback = "default" to the [snips-audio-server] section of your /etc/snips.toml configuration file.
  • sudo systemctl restart snips-audio-server

Workaround 3 - bcm2835

If you are using the pi 3 or pi 4 bcm2835 embedded sound card.

  • Switch back to portaudio
  • Use the following configuration for playback
pcm.!default {
    type asym
    playback.pcm {
        type plug
        slave.pcm "hw:0,0"
        slave.rate 48000  # Does not work if this is removed.
    }
    capture.pcm {
        type plug
        slave.pcm "hw:1,0"   # Configure the correct hw:Id,SubId for your capture device
    }
}

Workaround 4 : Delegate to dmix and dsnoop

Delegate to dmix to make sure that the sound is played well using alsa

pcm.!default {
    type asym
    playback.pcm "playback"
    capture.pcm "capture"
}

pcm.playback {
    type plug
    slave.pcm "dmixed"
}

pcm.capture {
    type plug
    slave.pcm "array"
}

pcm.dmixed {
    type dmix
    ipc_key 555555
    ipc_key_add_uid yes
    ipc_perm 0666
    slave.pcm "hw:1,0"  # Set the correct hw:Id,SubId for your playback device
}

pcm.array {
    type dsnoop
    ipc_key 666666
    ipc_key_add_uid yes
    ipc_perm 0666
    slave.pcm "hw:1,0"  # Set the correct hw:Id,SubId for your capture device
}

This configuration has been tested on the following devices

Audio device Playback Capture Details
bcm2835 (raspberry pi) Does not work. playback is stuck waiting for /dev/snd/timer (known issue)
Jabra PHS002W
UGREEN USB Sound card
PS Eye Camera
Respeaker PiHAT 2 mics
Respeaker 6 Microphones Playback does not work. The default configuration installed by the drivers works correctly tough

Related Issue

  • #201 : Sound partial playback (duplicated)
  • #148 : Other portaudio issue (22050 samples/s issue)

cburghardt avatar Oct 05 '19 13:10 cburghardt