pcm->private_data = adpcm;
pcm->poll_fd = slave->poll_fd;
pcm->poll_events = slave->poll_events;
- pcm->monotonic = slave->monotonic;
+ pcm->tstamp_type = slave->tstamp_type;
snd_pcm_set_hw_ptr(pcm, &adpcm->plug.hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &adpcm->plug.appl_ptr, -1, 0);
*pcmp = pcm;
pcm->private_data = alaw;
pcm->poll_fd = slave->poll_fd;
pcm->poll_events = slave->poll_events;
- pcm->monotonic = slave->monotonic;
+ pcm->tstamp_type = slave->tstamp_type;
snd_pcm_set_hw_ptr(pcm, &alaw->plug.hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &alaw->plug.appl_ptr, -1, 0);
*pcmp = pcm;
pcm->private_data = copy;
pcm->poll_fd = slave->poll_fd;
pcm->poll_events = slave->poll_events;
- pcm->monotonic = slave->monotonic;
+ pcm->tstamp_type = slave->tstamp_type;
snd_pcm_set_hw_ptr(pcm, ©->plug.hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, ©->plug.appl_ptr, -1, 0);
*pcmp = pcm;
COPY_SLAVE(period_time);
COPY_SLAVE(periods);
COPY_SLAVE(tstamp_mode);
+ COPY_SLAVE(tstamp_type);
COPY_SLAVE(period_step);
COPY_SLAVE(avail_min);
COPY_SLAVE(start_threshold);
COPY_SLAVE(buffer_time);
COPY_SLAVE(sample_bits);
COPY_SLAVE(frame_bits);
- COPY_SLAVE(monotonic);
}
#undef COPY_SLAVE
COPY_SLAVE(period_time);
COPY_SLAVE(periods);
COPY_SLAVE(tstamp_mode);
+ COPY_SLAVE(tstamp_type);
COPY_SLAVE(period_step);
COPY_SLAVE(avail_min);
COPY_SLAVE(start_threshold);
COPY_SLAVE(buffer_time);
COPY_SLAVE(sample_bits);
COPY_SLAVE(frame_bits);
- COPY_SLAVE(monotonic);
spcm->info &= ~SND_PCM_INFO_PAUSE;
spcm->boundary = recalc_boundary_size(dmix->shmptr->s.boundary, spcm->buffer_size);
unsigned int period_size;
unsigned int period_time;
snd_interval_t periods;
- unsigned int monotonic;
snd_pcm_tstamp_t tstamp_mode;
+ snd_pcm_tstamp_type_t tstamp_type;
unsigned int period_step;
unsigned int sleep_min; /* not used */
unsigned int avail_min;
dmix->avail_max = avail;
if (avail >= pcm->stop_threshold) {
snd_timer_stop(dmix->timer);
- gettimestamp(&dmix->trigger_tstamp, pcm->monotonic);
+ gettimestamp(&dmix->trigger_tstamp, pcm->tstamp_type);
if (dmix->state == SND_PCM_STATE_RUNNING) {
dmix->state = SND_PCM_STATE_XRUN;
return -EPIPE;
memset(status, 0, sizeof(*status));
status->state = snd_pcm_dmix_state(pcm);
status->trigger_tstamp = dmix->trigger_tstamp;
- gettimestamp(&status->tstamp, pcm->monotonic);
+ gettimestamp(&status->tstamp, pcm->tstamp_type);
status->avail = snd_pcm_mmap_playback_avail(pcm);
status->avail_max = status->avail > dmix->avail_max ? status->avail : dmix->avail_max;
dmix->avail_max = 0;
return err;
snd_pcm_dmix_sync_area(pcm);
}
- gettimestamp(&dmix->trigger_tstamp, pcm->monotonic);
+ gettimestamp(&dmix->trigger_tstamp, pcm->tstamp_type);
return 0;
}
pcm->poll_fd = dmix->poll_fd;
pcm->poll_events = POLLIN; /* it's different than other plugins */
- pcm->monotonic = spcm->monotonic;
+ pcm->tstamp_type = spcm->tstamp_type;
pcm->mmap_rw = 1;
snd_pcm_set_hw_ptr(pcm, &dmix->hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &dmix->appl_ptr, -1, 0);
dshare->avail_max = avail;
if (avail >= pcm->stop_threshold) {
snd_timer_stop(dshare->timer);
- gettimestamp(&dshare->trigger_tstamp, pcm->monotonic);
+ gettimestamp(&dshare->trigger_tstamp, pcm->tstamp_type);
if (dshare->state == SND_PCM_STATE_RUNNING) {
dshare->state = SND_PCM_STATE_XRUN;
return -EPIPE;
memset(status, 0, sizeof(*status));
status->state = snd_pcm_state(dshare->spcm);
status->trigger_tstamp = dshare->trigger_tstamp;
- gettimestamp(&status->tstamp, pcm->monotonic);
+ gettimestamp(&status->tstamp, pcm->tstamp_type);
status->avail = snd_pcm_mmap_playback_avail(pcm);
status->avail_max = status->avail > dshare->avail_max ? status->avail : dshare->avail_max;
dshare->avail_max = 0;
return err;
snd_pcm_dshare_sync_area(pcm);
}
- gettimestamp(&dshare->trigger_tstamp, pcm->monotonic);
+ gettimestamp(&dshare->trigger_tstamp, pcm->tstamp_type);
return 0;
}
pcm->poll_fd = dshare->poll_fd;
pcm->poll_events = POLLIN; /* it's different than other plugins */
- pcm->monotonic = spcm->monotonic;
+ pcm->tstamp_type = spcm->tstamp_type;
pcm->mmap_rw = 1;
snd_pcm_set_hw_ptr(pcm, &dshare->hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &dshare->appl_ptr, -1, 0);
if (pcm->stop_threshold >= pcm->boundary) /* don't care */
return 0;
if ((avail = snd_pcm_mmap_capture_hw_avail(pcm)) >= pcm->stop_threshold) {
- gettimestamp(&dsnoop->trigger_tstamp, pcm->monotonic);
+ gettimestamp(&dsnoop->trigger_tstamp, pcm->tstamp_type);
dsnoop->state = SND_PCM_STATE_XRUN;
dsnoop->avail_max = avail;
return -EPIPE;
pcm->poll_fd = dsnoop->poll_fd;
pcm->poll_events = POLLIN; /* it's different than other plugins */
- pcm->monotonic = spcm->monotonic;
+ pcm->tstamp_type = spcm->tstamp_type;
pcm->mmap_rw = 1;
snd_pcm_set_hw_ptr(pcm, &dsnoop->hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &dsnoop->appl_ptr, -1, 0);
pcm->poll_fd = slave->poll_fd;
pcm->poll_events = slave->poll_events;
pcm->mmap_shadow = 1;
+ pcm->tstamp_type = SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY;
#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
- pcm->monotonic = clock_gettime(CLOCK_MONOTONIC, ×pec) == 0;
-#else
- pcm->monotonic = 0;
+ if (clock_gettime(CLOCK_MONOTONIC, ×pec) == 0)
+ pcm->tstamp_type = SND_PCM_TSTAMP_TYPE_MONOTONIC;
#endif
pcm->stream = stream;
snd_pcm_link_hw_ptr(pcm, slave);
if (ok && (snd_pcm_uframes_t)avail1 == *avail)
break;
*avail = avail1;
- gettimestamp(tstamp, pcm->monotonic);
+ gettimestamp(tstamp, pcm->tstamp_type);
ok = 1;
}
return 0;
pcm->poll_fd = slave->poll_fd;
pcm->poll_events = slave->poll_events;
pcm->mmap_shadow = 1;
- pcm->monotonic = slave->monotonic;
+ pcm->tstamp_type = slave->tstamp_type;
snd_pcm_link_hw_ptr(pcm, slave);
snd_pcm_link_appl_ptr(pcm, slave);
*pcmp = pcm;
pcm->poll_fd = fd;
pcm->poll_events = info.stream == SND_PCM_STREAM_PLAYBACK ? POLLOUT : POLLIN;
pcm->tstamp_type = tstamp_type;
- pcm->monotonic = tstamp_type != SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY;
ret = snd_pcm_hw_mmap_status(pcm);
if (ret < 0) {
pcm->private_data = iec;
pcm->poll_fd = slave->poll_fd;
pcm->poll_events = slave->poll_events;
- pcm->monotonic = slave->monotonic;
+ pcm->tstamp_type = slave->tstamp_type;
snd_pcm_set_hw_ptr(pcm, &iec->plug.hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &iec->plug.appl_ptr, -1, 0);
*pcmp = pcm;
if (err < 0)
return err;
- gettimestamp(&io->trigger_tstamp, pcm->monotonic);
+ gettimestamp(&io->trigger_tstamp, pcm->tstamp_type);
io->data->state = SND_PCM_STATE_RUNNING;
return 0;
io->data->callback->stop(io->data);
- gettimestamp(&io->trigger_tstamp, pcm->monotonic);
+ gettimestamp(&io->trigger_tstamp, pcm->tstamp_type);
io->data->state = SND_PCM_STATE_SETUP;
return 0;
{
ioplug->pcm->poll_fd = ioplug->poll_fd;
ioplug->pcm->poll_events = ioplug->poll_events;
- ioplug->pcm->monotonic = (ioplug->flags & SND_PCM_IOPLUG_FLAG_MONOTONIC) != 0;
+ if (ioplug->flags & SND_PCM_IOPLUG_FLAG_MONOTONIC)
+ ioplug->pcm->tstamp_type = SND_PCM_TSTAMP_TYPE_MONOTONIC;
+ else
+ ioplug->pcm->tstamp_type = SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY;
ioplug->pcm->mmap_rw = ioplug->mmap_rw;
return 0;
}
pcm->private_data = ladspa;
pcm->poll_fd = slave->poll_fd;
pcm->poll_events = slave->poll_events;
- pcm->monotonic = slave->monotonic;
+ pcm->tstamp_type = slave->tstamp_type;
snd_pcm_set_hw_ptr(pcm, &ladspa->plug.hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &ladspa->plug.appl_ptr, -1, 0);
*pcmp = pcm;
pcm->private_data = lfloat;
pcm->poll_fd = slave->poll_fd;
pcm->poll_events = slave->poll_events;
- pcm->monotonic = slave->monotonic;
+ pcm->tstamp_type = slave->tstamp_type;
snd_pcm_set_hw_ptr(pcm, &lfloat->plug.hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &lfloat->plug.appl_ptr, -1, 0);
*pcmp = pcm;
pcm->private_data = linear;
pcm->poll_fd = slave->poll_fd;
pcm->poll_events = slave->poll_events;
- pcm->monotonic = slave->monotonic;
+ pcm->tstamp_type = slave->tstamp_type;
snd_pcm_set_hw_ptr(pcm, &linear->plug.hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &linear->plug.appl_ptr, -1, 0);
*pcmp = pcm;
int poll_fd;
unsigned short poll_events;
int setup: 1,
- monotonic: 1,
compat: 1;
snd_pcm_access_t access; /* access mode */
snd_pcm_format_t format; /* SND_PCM_FORMAT_* */
} snd_tmp_double_t;
/* get the current timestamp */
-static inline void gettimestamp(snd_htimestamp_t *tstamp, int monotonic)
+#ifdef HAVE_CLOCK_GETTIME
+static inline void gettimestamp(snd_htimestamp_t *tstamp,
+ snd_pcm_tstamp_type_t tstamp_type)
{
-#if defined(HAVE_CLOCK_GETTIME)
-#if defined(CLOCK_MONOTONIC)
- if (monotonic) {
- clock_gettime(CLOCK_MONOTONIC, tstamp);
- } else {
-#endif
- clock_gettime(CLOCK_REALTIME, tstamp);
-#else
- struct timeval tv;
+ clockid_t id;
- gettimeofday(&tv, 0);
- tstamp->tv_sec = tv.tv_sec;
- tstamp->tv_nsec = tv.tv_usec * 1000L;
+ switch (tstamp_type) {
+#ifdef CLOCK_MONOTONIC_RAW
+ case SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW:
+ id = CLOCK_MONOTONIC_RAW;
+ break;
#endif
-#if defined(HAVE_CLOCK_GETTIME)
- }
+#ifdef CLOCK_MONOTONIC
+ case SND_PCM_TSTAMP_TYPE_MONOTONIC:
+ id = CLOCK_MONOTONIC;
+ break;
#endif
+ default:
+ id = CLOCK_REALTIME;
+ break;
+ }
+ clock_gettime(id, tstamp);
+}
+#else /* HAVE_CLOCK_GETTIME */
+static inline void gettimestamp(snd_htimestamp_t *tstamp,
+ snd_pcm_tstamp_type_t tstamp_type)
+{
+ struct timeval tv;
+
+ gettimeofday(&tv, 0);
+ tstamp->tv_sec = tv.tv_sec;
+ tstamp->tv_nsec = tv.tv_usec * 1000L;
}
+#endif /* HAVE_CLOCK_GETTIME */
snd_pcm_chmap_query_t **
_snd_pcm_make_single_query_chmaps(const snd_pcm_chmap_t *src);
pcm->private_data = meter;
pcm->poll_fd = slave->poll_fd;
pcm->poll_events = slave->poll_events;
- pcm->monotonic = slave->monotonic;
+ pcm->tstamp_type = slave->tstamp_type;
snd_pcm_link_hw_ptr(pcm, slave);
snd_pcm_link_appl_ptr(pcm, slave);
*pcmp = pcm;
pcm->private_data = map;
pcm->poll_fd = slave->poll_fd;
pcm->poll_events = slave->poll_events;
- pcm->monotonic = slave->monotonic;
+ pcm->tstamp_type = slave->tstamp_type;
snd_pcm_set_hw_ptr(pcm, &map->hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &map->appl_ptr, -1, 0);
*pcmp = pcm;
pcm->private_data = mulaw;
pcm->poll_fd = slave->poll_fd;
pcm->poll_events = slave->poll_events;
- pcm->monotonic = slave->monotonic;
+ pcm->tstamp_type = slave->tstamp_type;
snd_pcm_set_hw_ptr(pcm, &mulaw->plug.hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &mulaw->plug.appl_ptr, -1, 0);
*pcmp = pcm;
pcm->private_data = multi;
pcm->poll_fd = multi->slaves[master_slave].pcm->poll_fd;
pcm->poll_events = multi->slaves[master_slave].pcm->poll_events;
- pcm->monotonic = multi->slaves[master_slave].pcm->monotonic;
+ pcm->tstamp_type = multi->slaves[master_slave].pcm->tstamp_type;
snd_pcm_link_hw_ptr(pcm, multi->slaves[master_slave].pcm);
snd_pcm_link_appl_ptr(pcm, multi->slaves[master_slave].pcm);
*pcmp = pcm;
memset(status, 0, sizeof(*status));
status->state = null->state;
status->trigger_tstamp = null->trigger_tstamp;
- gettimestamp(&status->tstamp, pcm->monotonic);
+ gettimestamp(&status->tstamp, pcm->tstamp_type);
status->avail = snd_pcm_null_avail_update(pcm);
status->avail_max = pcm->buffer_size;
return 0;
pcm->poll_fd = slave->poll_fd;
pcm->poll_events = slave->poll_events;
pcm->mmap_shadow = 1;
- pcm->monotonic = slave->monotonic;
+ pcm->tstamp_type = slave->tstamp_type;
snd_pcm_link_hw_ptr(pcm, slave);
snd_pcm_link_appl_ptr(pcm, slave);
*pcmp = pcm;
if (snd_pcm_state(rate->gen.slave) != SND_PCM_STATE_PREPARED)
return -EBADFD;
- gettimestamp(&rate->trigger_tstamp, pcm->monotonic);
+ gettimestamp(&rate->trigger_tstamp, pcm->tstamp_type);
avail = snd_pcm_mmap_playback_hw_avail(rate->gen.slave);
if (avail == 0) {
pcm->poll_fd = slave->poll_fd;
pcm->poll_events = slave->poll_events;
pcm->mmap_rw = 1;
- pcm->monotonic = slave->monotonic;
+ pcm->tstamp_type = slave->tstamp_type;
snd_pcm_set_hw_ptr(pcm, &rate->hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &rate->appl_ptr, -1, 0);
*pcmp = pcm;
pcm->private_data = route;
pcm->poll_fd = slave->poll_fd;
pcm->poll_events = slave->poll_events;
- pcm->monotonic = slave->monotonic;
+ pcm->tstamp_type = slave->tstamp_type;
snd_pcm_set_hw_ptr(pcm, &route->plug.hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &route->plug.appl_ptr, -1, 0);
err = route_load_ttable(&route->params, pcm->stream, tt_ssize, ttable, tt_cused, tt_sused);
}
slave->running_count++;
_snd_pcm_share_update(pcm);
- gettimestamp(&share->trigger_tstamp, pcm->monotonic);
+ gettimestamp(&share->trigger_tstamp, pcm->tstamp_type);
_end:
Pthread_mutex_unlock(&slave->mutex);
return err;
return;
}
#endif
- gettimestamp(&share->trigger_tstamp, pcm->monotonic);
+ gettimestamp(&share->trigger_tstamp, pcm->tstamp_type);
if (pcm->stream == SND_PCM_STREAM_CAPTURE) {
snd_pcm_areas_copy(pcm->stopped_areas, 0,
pcm->running_areas, 0,
pcm->private_data = share;
pcm->poll_fd = share->client_socket;
pcm->poll_events = stream == SND_PCM_STREAM_PLAYBACK ? POLLOUT : POLLIN;
- pcm->monotonic = slave->pcm->monotonic;
+ pcm->tstamp_type = slave->pcm->tstamp_type;
snd_pcm_set_hw_ptr(pcm, &share->hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &share->appl_ptr, -1, 0);
* an extra buffer.
*/
pcm->mmap_shadow = 1;
- pcm->monotonic = slave->monotonic;
+ pcm->tstamp_type = slave->tstamp_type;
snd_pcm_set_hw_ptr(pcm, &svol->plug.hw_ptr, -1, 0);
snd_pcm_set_appl_ptr(pcm, &svol->plug.appl_ptr, -1, 0);
*pcmp = pcm;