duncanthrax / scream

Virtual network sound card for Microsoft Windows
Microsoft Public License
1.74k stars 147 forks source link

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

Open DominikStarke opened 2 years ago

DominikStarke commented 2 years ago

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 commented 2 years ago

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

duncanthrax commented 2 years ago

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.

DominikStarke commented 2 years ago

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?

duncanthrax commented 2 years ago

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