duncanthrax/scream

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

Opened this issue · 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;
  }

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

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.

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?

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