jamesbirtles/Hallon — comment on commit 7cec046959ec2ab25c893c1bbcf009be6fe3ab89
File: lib/hallon/player.rb line 45
By Burgestrand:

Hi! Sorry to just barge in like this, but I’d like to highlight something. Here you’re setting the audio format of the driver and the queue; as you might’ve noticed this is the format of the audio that’s currently being streamed.

The interesting thing is that once you start streaming music, the [music delivery callback](https://github.com/jamesbirtles/Hallon/blob/7cec046959ec2ab25c893c1bbcf009be6fe3ab89/lib/hallon/player.rb#L106) will receive the format of the audio in addition to the audio data. If this does not match the current format, it’ll set the format of the queue (which clears it) before storing the data for later playback.

If we then look at the loop that streams audio to the player, you can see that [it also makes sure the format is correct](https://github.com/jamesbirtles/Hallon/blob/7cec046959ec2ab25c893c1bbcf009be6fe3ab89/lib/hallon/player.rb#L60) and then lets the driver reinitialize itself before it begins anew to stream audio in the new format.

All in all, this means that if the queue format and driver format is not exactly right, all it will do is that the first few frames of audio you receive it’ll set the *actual* format of the audio on both the queue and the audio. This change should have no effect unless the majority of audio you receive from libspotify has a sample rate of whatever `@driver.rate` is. :)

Hopefully this might shine some light on the problem you are having that brought up this change in the first place!

PS: if you’d like to allow the buffer to store more than three seconds of audio, do use whatever number you see fit in `AudioQueue.new(size)`, because that will probably have a fair impact of how well the audio may stream.