scream icon indicating copy to clipboard operation
scream copied to clipboard

Alsa receiver not working if Soundcard doesn't support 44.1kHz

Open DominikStarke opened this issue 2 years ago • 4 comments

My receiver is running on a raspberry pi 3 with a blokas pisound, which doesn't support rates lower than 48kHz. This can be worked around by changing the sample rate on line 106 in alsa.c:

  if (setup_alsa(&ao_data.snd, SND_PCM_FORMAT_S16_LE, 44100, latency, alsa_device, ao_data.receiver_format.channels, &ao_data.channel_map) == -1) {
    return 1;
  }

to

  if (setup_alsa(&ao_data.snd, SND_PCM_FORMAT_S16_LE, 48000, latency, alsa_device, ao_data.receiver_format.channels, &ao_data.channel_map) == -1) {
    return 1;
  }

DominikStarke avatar Sep 29 '22 09:09 DominikStarke

After further investigation, the first call to setup_alsa seems to be unnecessary?

DominikStarke avatar Sep 29 '22 19:09 DominikStarke

Might be unnecessary, yes. The way the code works historically is that the output is opened (with some default settings) regardless of a stream being received. The whole thing is stateless, so that is the natural way :) I would prefer to change the default sample rate over introducing a "waiting" state.

duncanthrax avatar Sep 30 '22 17:09 duncanthrax

Nice profile picture.

It might be a good idea to override the default value with a rate argument (something like scream -r 48000) falling back to 44.1k if not specified and updating on stream change?

DominikStarke avatar Oct 01 '22 08:10 DominikStarke

Sounds good! Since I'm incredibly lazy, please send a patch :)

duncanthrax avatar Oct 01 '22 08:10 duncanthrax