Add monotonic raw timestamp support
cover Add monotonic raw timestamp support
Hi,
this is a series of patches to add the monotonic raw timestamp support to alsa-lib. A couple of new API functions and the new type are introduced while the old hw_params monotonic function still remains. Maybe we should mark it depecated?
Takashi
PATCH 1/5 pcm: Provide a CLOCK_MONOTONIC_RAW timestamp type
From: Mark Brown <[email protected]>
For applications which need to synchronise with external timebases such as broadcast TV applications the kernel monotonic time is not optimal as it includes adjustments from NTP and so may still include discontinuities due to that. A raw monotonic time which does not include any adjustments is available in the kernel from getrawmonotonic() so provide userspace with a new timestamp type SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW which provides timestamps based on this as an option.
--- include/sound/asound.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/sound/asound.h +2 -1
@@ -457,7 +457,8 @@ struct snd_xfern {enum {SNDRV_PCM_TSTAMP_TYPE_GETTIMEOFDAY =0 ,/* gettimeofday equivalent */ SNDRV_PCM_TSTAMP_TYPE_MONOTONIC ,/* posix_clock_monotonic equivalent */ -SNDRV_PCM_TSTAMP_TYPE_LAST =SNDRV_PCM_TSTAMP_TYPE_MONOTONIC , +SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW ,/* monotonic_raw (no NTP) */ +SNDRV_PCM_TSTAMP_TYPE_LAST =SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW , };/* channel positions */
Signature · 1 line
2.0.1
PATCH 2/5 Add timestamp type to sw_params (internal only)
In reply to Takashi IwaiThis patch is just the udpate of sound/asound.h taken from the kernel commit. The API changes and PCM structure changes will follow after this.
--- include/sound/asound.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
include/sound/asound.h +4 -2
@@ -136,7 +136,7 @@ struct snd_hwdep_dsp_image {* * *****************************************************************************/ -#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 11) +#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 12)typedef unsigned long snd_pcm_uframes_t ;typedef signed long snd_pcm_sframes_t ;
@@ -386,7 +386,9 @@ struct snd_pcm_sw_params {snd_pcm_uframes_t silence_threshold;/* min distance from noise for silence filling */ snd_pcm_uframes_t silence_size;/* silence block size */ snd_pcm_uframes_t boundary;/* pointers wrap point */ -unsigned char reserved[64 ];/* reserved for future */ +unsigned int tstamp_type;/* timestamp type */ +int pads;/* alignment, reserved */ +unsigned char reserved[56 ];/* reserved for future */ };struct snd_pcm_channel_info {
Signature · 1 line
2.0.1
PATCH 3/5 pcm: Add sw_params API functions to get/set timestamp type
In reply to Takashi IwaiFor obtaining / changing the timestamp type, add the corresponding sw_params accessor API functions together with the public definitions of timestamp types.
This patch only adds the functions and defines but doesn't bring the functional changes yet.
--- include/pcm.h | 9 +++++++++ src/pcm/pcm.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/pcm/pcm_local.h | 1 + 3 files changed, 63 insertions(+)
include/pcm.h +9 -0
@@ -317,6 +317,13 @@ typedef enum _snd_pcm_tstamp { SND_PCM_TSTAMP_LAST = SND_PCM_TSTAMP_ENABLE } snd_pcm_tstamp_t; +typedef enum _snd_pcm_tstamp_type { +SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY =0 ,/** gettimeofday equivalent */ +SND_PCM_TSTAMP_TYPE_MONOTONIC ,/** posix_clock_monotonic equivalent */ +SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW ,/** monotonic_raw (no NTP) */ +SND_PCM_TSTAMP_TYPE_LAST =SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW , +}snd_pcm_tstamp_type_t ; +/** Unsigned frames quantity */ typedef unsigned long snd_pcm_uframes_t ;/** Signed frames quantity */
@@ -844,6 +851,8 @@ int snd_pcm_sw_params_get_boundary(const snd_pcm_sw_params_t *params, snd_pcm_ufint snd_pcm_sw_params_set_tstamp_mode (snd_pcm_t *pcm,snd_pcm_sw_params_t *params,snd_pcm_tstamp_t val);int snd_pcm_sw_params_get_tstamp_mode (const snd_pcm_sw_params_t *params,snd_pcm_tstamp_t *val); +int snd_pcm_sw_params_set_tstamp_type (snd_pcm_t *pcm,snd_pcm_sw_params_t *params,snd_pcm_tstamp_type_t val); +int snd_pcm_sw_params_get_tstamp_type (const snd_pcm_sw_params_t *params,snd_pcm_tstamp_type_t *val);int snd_pcm_sw_params_set_avail_min (snd_pcm_t *pcm,snd_pcm_sw_params_t *params,snd_pcm_uframes_t val);int snd_pcm_sw_params_get_avail_min (const snd_pcm_sw_params_t *params,snd_pcm_uframes_t *val);int snd_pcm_sw_params_set_period_event (snd_pcm_t *pcm,snd_pcm_sw_params_t *params,int val);
src/pcm/pcm.c +53 -0
95 lines not on this page · raw message
src/pcm/pcm_local.h +1 -0
@@ -202,6 +202,7 @@ struct _snd_pcm {unsigned int period_time;/* period duration */ snd_interval_t periods;snd_pcm_tstamp_t tstamp_mode;/* timestamp mode */ +snd_pcm_tstamp_type_t tstamp_type;/* timestamp type */ unsigned int period_step;snd_pcm_uframes_t avail_min;/* min avail frames for wakeup */ int period_event;
Signature · 1 line
2.0.1
Re: [PATCH alsa-lib 3/5] pcm: Add sw_params API functions to get/set timestamp type
src/pcm/pcm.c int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) · line 5637
Quoted 11 lines · Takashi Iwai
src/pcm/pcm.c +2
-0@@ -1899,6 +1918,7 @@ int snd_pcm_dump_sw_setup(snd_pcm_t *pcm, snd_output_t *out)return -EIO ; }snd_output_printf (out," tstamp_mode : %s\n" ,snd_pcm_tstamp_mode_name (pcm->tstamp_mode)); +snd_output_printf (out," tstamp_type : %s\n" ,snd_pcm_tstamp_type_name (pcm->tstamp_mode));@@ -5613,6 +5634,7 @@ int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)int snd_pcm_sw_params_dump (snd_pcm_sw_params_t *params,snd_output_t *out) {snd_output_printf (out,"tstamp_mode: %s\n" ,snd_pcm_tstamp_mode_name (params->tstamp_mode)); +snd_output_printf (out,"tstamp_type: %s\n" ,snd_pcm_tstamp_type_name (params->tstamp_mode));
_type, not _mode
Regards,
Clemens
Re: [PATCH alsa-lib 3/5] pcm: Add sw_params API functions to get/set timestamp type
At Thu, 10 Jul 2014 15:22:06 +0200,
Quoted 8 lines · Clemens Ladisch
Quoted 5 lines · Takashi Iwai
src/pcm/pcm.c +1
-0@@ -1899,6 +1918,7 @@ int snd_pcm_dump_sw_setup(snd_pcm_t *pcm, snd_output_t *out)return -EIO ; }snd_output_printf (out," tstamp_mode : %s\n" ,snd_pcm_tstamp_mode_name (pcm->tstamp_mode)); +snd_output_printf (out," tstamp_type : %s\n" ,snd_pcm_tstamp_type_name (pcm->tstamp_mode));
Quoted 7 lines
src/pcm/pcm.c int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) · line 5637
Quoted 5 lines
src/pcm/pcm.c +1
-0@@ -5613,6 +5634,7 @@ int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)int snd_pcm_sw_params_dump (snd_pcm_sw_params_t *params,snd_output_t *out) {snd_output_printf (out,"tstamp_mode: %s\n" ,snd_pcm_tstamp_mode_name (params->tstamp_mode)); +snd_output_printf (out,"tstamp_type: %s\n" ,snd_pcm_tstamp_type_name (params->tstamp_mode));
_type, not_mode
Thanks, fixed.
Takashi
PATCH 4/5 pcm: Implement timestamp type setup in hw plugin
In reply to Takashi IwaiThis patch implements the support for sw_params timestamp type in PCM hw layer. As gettimestamp() is still unchanged, the resultant timstamps may be still with CLOCK_MONOTONIC even if you pass monotonic raw type. More fixes will follow.
--- src/pcm/pcm_hw.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-)
src/pcm/pcm_hw.c +32 -5
@@ -304,7 +304,8 @@ static int snd_pcm_hw_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)if (params->info != ~0U ) { params->info &= ~0xf0000000 ; - params->info |= (pcm->monotonic ?SND_PCM_INFO_MONOTONIC :0 ); +if (pcm->tstamp_type !=SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY ) + params->info |=SND_PCM_INFO_MONOTONIC ; }return 0 ;
@@ -328,7 +329,8 @@ static int snd_pcm_hw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)return err; } params->info &= ~0xf0000000 ; - params->info |= (pcm->monotonic ?SND_PCM_INFO_MONOTONIC :0 ); +if (pcm->tstamp_type !=SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY ) + params->info |=SND_PCM_INFO_MONOTONIC ; err =sync_ptr (hw,0 );if (err <0 )return err;
@@ -435,6 +437,7 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)int old_period_event =sw_get_period_event (params);sw_set_period_event (params,0 ); if ((snd_pcm_tstamp_t) params->tstamp_mode == pcm->tstamp_mode && + (snd_pcm_tstamp_type_t) params->tstamp_type == pcm->tstamp_type && params->period_step == pcm->period_step && params->start_threshold == pcm->start_threshold && params->stop_threshold == pcm->stop_threshold &&
@@ -444,11 +447,33 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params) hw->mmap_control->avail_min = params->avail_min;return sync_ptr (hw,0 ); } +if (params->tstamp_type ==SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW && + hw->version <SNDRV_PROTOCOL_VERSION (2 ,0 ,12 )) { +SYSMSG ("Kernel doesn't support SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW" ); +return -EINVAL ; + } +if (params->tstamp_type ==SND_PCM_TSTAMP_TYPE_MONOTONIC && + hw->version <SNDRV_PROTOCOL_VERSION (2 ,0 ,5 )) { +SYSMSG ("Kernel doesn't support SND_PCM_TSTAMP_TYPE_MONOTONIC" ); +return -EINVAL ; + }if (ioctl (fd,SNDRV_PCM_IOCTL_SW_PARAMS , params) <0 ) { err = -errno;SYSMSG ("SNDRV_PCM_IOCTL_SW_PARAMS failed (%i)" , err);return err; } +if ((snd_pcm_tstamp_type_t ) params->tstamp_type != pcm->tstamp_type) { +if (hw->version <SNDRV_PROTOCOL_VERSION (2 ,0 ,12 )) { +int on = (snd_pcm_tstamp_type_t ) params->tstamp_type == +SND_PCM_TSTAMP_TYPE_MONOTONIC ; +if (ioctl (fd,SNDRV_PCM_IOCTL_TSTAMP , &on) <0 ) { + err = -errno; +SNDMSG ("TSTAMP failed\n" ); +return err; + } + } + pcm->tstamp_type = params->tstamp_type; + }sw_set_period_event (params, old_period_event); hw->mmap_control->avail_min = params->avail_min;if (hw->period_event != old_period_event) {
@@ -1381,7 +1406,8 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd, int mmap_emulation ATTRIBUTE_UNUSED, int sync_ptr_ioctl) { - int ver, mode, monotonic = 0; + int ver, mode; +snd_pcm_tstamp_type_t tstamp_type =SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY ;long fmode;snd_pcm_t *pcm =NULL ;snd_pcm_hw_t *hw =NULL ;
@@ -1429,7 +1455,7 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name,SNDMSG ("TTSTAMP failed\n" ); return ret; } - monotonic =1 ; + tstamp_type =SND_PCM_TSTAMP_TYPE_MONOTONIC ; } } else#endif
@@ -1471,7 +1497,8 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, pcm->private_data = hw; pcm->poll_fd = fd; pcm->poll_events = info.stream ==SND_PCM_STREAM_PLAYBACK ?POLLOUT :POLLIN ; - pcm->monotonic = monotonic; + pcm->tstamp_type = tstamp_type; + pcm->monotonic = tstamp_type !=SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY ; ret =snd_pcm_hw_mmap_status (pcm);if (ret <0 ) {
Signature · 1 line
2.0.1
PATCH 5/5 pcm: Implement timestamp type handling in all plugins
In reply to Takashi IwaiNow all PCM plugins do support the proper timestamp type or pass it over slaves. The internal monotonic flag is dropped and replaced with tstamp_type in all places.
--- src/pcm/pcm_adpcm.c | 2 +- src/pcm/pcm_alaw.c | 2 +- src/pcm/pcm_copy.c | 2 +- src/pcm/pcm_direct.c | 4 ++-- src/pcm/pcm_direct.h | 2 +- src/pcm/pcm_dmix.c | 8 ++++---- src/pcm/pcm_dshare.c | 8 ++++---- src/pcm/pcm_dsnoop.c | 4 ++-- src/pcm/pcm_file.c | 6 +++--- src/pcm/pcm_generic.c | 2 +- src/pcm/pcm_hooks.c | 2 +- src/pcm/pcm_hw.c | 1 - src/pcm/pcm_iec958.c | 2 +- src/pcm/pcm_ioplug.c | 9 ++++++--- src/pcm/pcm_ladspa.c | 2 +- src/pcm/pcm_lfloat.c | 2 +- src/pcm/pcm_linear.c | 2 +- src/pcm/pcm_local.h | 45 +++++++++++++++++++++++++++++---------------- src/pcm/pcm_meter.c | 2 +- src/pcm/pcm_mmap_emul.c | 2 +- src/pcm/pcm_mulaw.c | 2 +- src/pcm/pcm_multi.c | 2 +- src/pcm/pcm_null.c | 2 +- src/pcm/pcm_plug.c | 2 +- src/pcm/pcm_rate.c | 4 ++-- src/pcm/pcm_route.c | 2 +- src/pcm/pcm_share.c | 6 +++--- src/pcm/pcm_softvol.c | 2 +- 28 files changed, 73 insertions(+), 58 deletions(-)
src/pcm/pcm_adpcm.c +1 -1
@@ -579,7 +579,7 @@ int snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sfor 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;
src/pcm/pcm_alaw.c +1 -1
@@ -453,7 +453,7 @@ int snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sform 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;
src/pcm/pcm_copy.c +1 -1
@@ -209,7 +209,7 @@ int snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name, snd_pcm_t *slave, int 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;
src/pcm/pcm_direct.c +2 -2
@@ -840,6 +840,7 @@ static void save_slave_setting(snd_pcm_direct_t *dmix, snd_pcm_t *spcm)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);
@@ -857,7 +858,6 @@ static void save_slave_setting(snd_pcm_direct_t *dmix, snd_pcm_t *spcm)COPY_SLAVE (buffer_time);COPY_SLAVE (sample_bits);COPY_SLAVE (frame_bits); -COPY_SLAVE (monotonic); }#undef COPY_SLAVE
@@ -1204,6 +1204,7 @@ static void copy_slave_setting(snd_pcm_direct_t *dmix, snd_pcm_t *spcm)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);
@@ -1221,7 +1222,6 @@ static void copy_slave_setting(snd_pcm_direct_t *dmix, snd_pcm_t *spcm)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);
src/pcm/pcm_direct.h +1 -1
@@ -85,8 +85,8 @@ typedef struct {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;
src/pcm/pcm_dmix.c +4 -4
@@ -428,7 +428,7 @@ static int snd_pcm_dmix_sync_ptr(snd_pcm_t *pcm) 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 ;
@@ -477,7 +477,7 @@ static int snd_pcm_dmix_status(snd_pcm_t *pcm, snd_pcm_status_t * status)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 ;
@@ -596,7 +596,7 @@ static int snd_pcm_dmix_start(snd_pcm_t *pcm)return err;snd_pcm_dmix_sync_area (pcm); } -gettimestamp (&dmix->trigger_tstamp, pcm->monotonic); +gettimestamp (&dmix->trigger_tstamp, pcm->tstamp_type);return 0 ; }
@@ -1104,7 +1104,7 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name, 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 );
src/pcm/pcm_dshare.c +4 -4
@@ -195,7 +195,7 @@ static int snd_pcm_dshare_sync_ptr(snd_pcm_t *pcm) 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 ;
@@ -226,7 +226,7 @@ static int snd_pcm_dshare_status(snd_pcm_t *pcm, snd_pcm_status_t * status)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 ;
@@ -346,7 +346,7 @@ static int snd_pcm_dshare_start(snd_pcm_t *pcm)return err;snd_pcm_dshare_sync_area (pcm); } -gettimestamp (&dshare->trigger_tstamp, pcm->monotonic); +gettimestamp (&dshare->trigger_tstamp, pcm->tstamp_type);return 0 ; }
@@ -792,7 +792,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name, 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 );
src/pcm/pcm_dsnoop.c +2 -2
@@ -159,7 +159,7 @@ static int snd_pcm_dsnoop_sync_ptr(snd_pcm_t *pcm)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 ;
@@ -690,7 +690,7 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name, 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 );
src/pcm/pcm_file.c +3 -3
@@ -781,10 +781,10 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, 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);
src/pcm/pcm_generic.c +1 -1
@@ -294,7 +294,7 @@ int snd_pcm_generic_real_htimestamp(snd_pcm_t *pcm, snd_pcm_uframes_t *avail,if (ok && (snd_pcm_uframes_t )avail1 == *avail)break ; *avail = avail1; -gettimestamp (tstamp, pcm->monotonic); +gettimestamp (tstamp, pcm->tstamp_type); ok =1 ; }return 0 ;
src/pcm/pcm_hooks.c +1 -1
@@ -240,7 +240,7 @@ int snd_pcm_hooks_open(snd_pcm_t **pcmp, const char *name, snd_pcm_t *slave, int 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;
src/pcm/pcm_hw.c +0 -1
@@ -1498,7 +1498,6 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, 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 ) {
src/pcm/pcm_iec958.c +1 -1
@@ -534,7 +534,7 @@ int snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sfo 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;
src/pcm/pcm_ioplug.c +6 -3
@@ -448,7 +448,7 @@ static int snd_pcm_ioplug_start(snd_pcm_t *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 ;
@@ -463,7 +463,7 @@ static int snd_pcm_ioplug_drop(snd_pcm_t *pcm) 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 ;
@@ -1069,7 +1069,10 @@ int snd_pcm_ioplug_reinit_status(snd_pcm_ioplug_t *ioplug) { 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 ; }
src/pcm/pcm_ladspa.c +1 -1
@@ -1641,7 +1641,7 @@ int snd_pcm_ladspa_open(snd_pcm_t **pcmp, const char *name, 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;
src/pcm/pcm_lfloat.c +1 -1
@@ -412,7 +412,7 @@ int snd_pcm_lfloat_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sfo 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;
src/pcm/pcm_linear.c +1 -1
@@ -484,7 +484,7 @@ int snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sfo 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;
src/pcm/pcm_local.h +29 -16
62 lines not on this page · raw message
src/pcm/pcm_meter.c +1 -1
@@ -591,7 +591,7 @@ int snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name, unsigned int frequenc 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;
src/pcm/pcm_mmap_emul.c +1 -1
@@ -428,7 +428,7 @@ int __snd_pcm_mmap_emul_open(snd_pcm_t **pcmp, const char *name, 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;
src/pcm/pcm_mulaw.c +1 -1
@@ -467,7 +467,7 @@ int snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sfor 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;
src/pcm/pcm_multi.c +1 -1
@@ -1077,7 +1077,7 @@ int snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, 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;
src/pcm/pcm_null.c +1 -1
@@ -100,7 +100,7 @@ static int snd_pcm_null_status(snd_pcm_t *pcm, snd_pcm_status_t * status)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 ;
src/pcm/pcm_plug.c +1 -1
@@ -1127,7 +1127,7 @@ int snd_pcm_plug_open(snd_pcm_t **pcmp, 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;
src/pcm/pcm_rate.c +2 -2
@@ -1067,7 +1067,7 @@ static int snd_pcm_rate_start(snd_pcm_t *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 ) {
@@ -1370,7 +1370,7 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name, 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;
src/pcm/pcm_route.c +1 -1
@@ -1122,7 +1122,7 @@ int snd_pcm_route_open(snd_pcm_t **pcmp, const char *name, 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);
src/pcm/pcm_share.c +3 -3
@@ -971,7 +971,7 @@ static int snd_pcm_share_start(snd_pcm_t *pcm) } 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;
@@ -1126,7 +1126,7 @@ static void _snd_pcm_share_stop(snd_pcm_t *pcm, snd_pcm_state_t state)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,
@@ -1526,7 +1526,7 @@ int snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, const char *sname, 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 );
src/pcm/pcm_softvol.c +1 -1
@@ -903,7 +903,7 @@ int snd_pcm_softvol_open(snd_pcm_t **pcmp, const char *name,* 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;
Signature · 1 line
2.0.1