seberoon wrote: > I've done a bit of analysis by hand and found something that may be > relevant. My expectation was that, for a given player, while a track is > playing, and assuming no skip aheads, the value of (jiffies - > elapsed_milliseconds) should remain pretty much constant from one status > packet to the next. In the attached extract from the log, this is true > for player A (b8:27:eb:83:7f:a2) but not for player B > (00:13:ef:20:2d:21). For A that difference is constant at 330081211. For > B it seems to be oscillating; it starts at 218944165 then goes up and > down (the offsets from the initial value of 218944165 are 0, +23, +32, > -1, 0, +23, +32, -1). Would you expect variation on that scale?
It looks to me as though there is a problem in the code which measures the output delay, towards the end of output_thread() in output_alsa.c. The call to snd_pcm_delay() is happening before new frames are written to the device. But insofar as I understand it (not very, as already demonstrated) writing new frames will increase the output delay, so we need to measure the delay immediately -after- the call to _output_frames(). I've tried modifying the code as shown below. Initial testing indicates that this works but I haven't tested it in anger, nor have I tried to test if it actually impacts on my original sync issues. I'd appreciate a heads-up if you can see that I'm heading down a blind alley. Code: -------------------- // check for errors snd_pcm_sframes_t delay; if ((err = snd_pcm_delay(pcmp, &delay)) < 0) { if (err == -EPIPE) { // EPIPE indicates underrun - attempt to recover UNLOCK; continue; } else if (err == -EIO) { // EIO can occur with non existant pulse server UNLOCK; LOG_SDEBUG("snd_pcm_delay returns: EIO - sleeping"); usleep(100000); continue; } else { LOG_DEBUG("snd_pcm_delay returns: %d", err); } } // process frames frames_t wrote = _output_frames(avail); // measure output delay if ((err = snd_pcm_delay(pcmp, &delay)) < 0) { LOG_DEBUG("snd_pcm_delay returns: %d", err); } else { output.device_frames = delay; output.updated = gettime_ms(); } -------------------- ------------------------------------------------------------------------ seberoon's Profile: http://forums.slimdevices.com/member.php?userid=63052 View this thread: http://forums.slimdevices.com/showthread.php?t=97046 _______________________________________________ unix mailing list unix@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/unix