seberoon wrote: > 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(); > } -------------------- > >
This is probably a reasonable observation as the number of frames played will get updated in _output_frames() so it should probably include the additional frames in the delay measurement. In practice this is likely to add the period size to the measurement, so depending on the period size setting it could justify adding 20ms or so to the results. However it depends on what else linux is doing as to whether this is a constant addition or it varies. Have you measured the effect this has? ------------------------------------------------------------------------ Triode's Profile: http://forums.slimdevices.com/member.php?userid=17 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