Summary: Improve accuracy of capture timestamps.

The time stamps should be accurate to within about +-1ms now.



git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/trunk@120 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
J C Dutton 2006-01-28 14:58:55 +00:00
parent 88d42d608c
commit e4d62536d7

View File

@ -391,6 +391,7 @@ int capture_callback(alsa_driver_t *alsa_driver_capture) {
struct timeval tv;
double stime;
int ib;
snd_pcm_sframes_t delay;
#ifdef ALSA_CAPTURE_LOG
printf("capture callback %d samples\n", this->period_size);
#endif
@ -400,12 +401,16 @@ int capture_callback(alsa_driver_t *alsa_driver_capture) {
snd_pcm_status(this->audio_fd, pcm_stat);
snd_pcm_status_dump(pcm_stat, jcd_out);
#endif
snd_pcm_delay(this->audio_fd, &delay);
gettimeofday(&tv, NULL);
stime = (double) tv.tv_sec + ((double)tv.tv_usec / 1000000.0) +
*(this->ndsec) * 0.1;
stime = stime - ((double)delay / (double)(this->output_sample_rate));
*(this->Tsec) = stime;
ib=*(this->ibuf);
this->tbuf[ib++] = stime;
this->tbuf[ib] = stime;
//printf("CAP:TIME, %d, %lf, %ld, %ld, %d\n",ib, stime, delay, this->output_sample_rate, *this->ndsec);
ib++;
if(ib>=1024)
ib = 0;
*(this->ibuf) = ib;