Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Intermittent loud ticks and no-audio using Spotify
#12
Examining the source shows that period and buffer size are initially set by librespot.
https://github.com/librespot-org/libresp...nd/alsa.rs

The defaults
Code:
const PREFERED_PERIOD_SIZE: Frames = 5512; // Period of roughly 125ms
const BUFFERED_PERIODS: Frames = 4;

Possibly period_size is being overridden in this function ??
Code:
fn open_device(dev_name: &str) -> Result<(PCM, Frames), Box<Error>> {
   let pcm = PCM::new(dev_name, Direction::Playback, false)?;
   let mut period_size = PREFERED_PERIOD_SIZE;
   // http://www.linuxjournal.com/article/6735?page=0,1#N0x19ab2890.0x19ba78d8
   // latency = period_size * periods / (rate * bytes_per_frame)
   // For 16 Bit stereo data, one frame has a length of four bytes.
   // 500ms  = buffer_size / (44100 * 4)
   // buffer_size_bytes = 0.5 * 44100 / 4
   // buffer_size_frames = 0.5 * 44100 = 22050
   {
       // Set hardware parameters: 44100 Hz / Stereo / 16 bit
       let hwp = HwParams::any(&pcm)?;

       hwp.set_access(Access::RWInterleaved)?;
       hwp.set_format(Format::s16())?;
       hwp.set_rate(44100, ValueOr::Nearest)?;
       hwp.set_channels(2)?;
       period_size = hwp.set_period_size_near(period_size, ValueOr::Greater)?;
       hwp.set_buffer_size_near(period_size * BUFFERED_PERIODS)?;
       pcm.hw_params(&hwp)?;

       let swp = pcm.sw_params_current()?;
       swp.set_start_threshold(hwp.get_buffer_size()? - hwp.get_period_size()?)?;
       pcm.sw_params(&swp)?;
   }

   Ok((pcm, period_size))
}
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Messages In This Thread
RE: Intermittent loud ticks and no-audio using Spotify - by Tim Curtis - 10-10-2020, 04:06 PM

Forum Jump: