]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: add helper functions to query timestamping capabilities
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Wed, 1 Jul 2015 20:40:54 +0000 (15:40 -0500)
committerTakashi Iwai <tiwai@suse.de>
Thu, 2 Jul 2015 15:02:03 +0000 (17:02 +0200)
extend support to link, link_estimated and link_synchronized
timestamp. wall-clock is deprecated

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/pcm.h
src/pcm/pcm.c

index 0655e7f43ef61ad10461b3f34592860f92d0cec4..2aa1eff36be37c686deb8f1602ee4ddd169fe25e 100644 (file)
@@ -668,7 +668,8 @@ int snd_pcm_hw_params_is_half_duplex(const snd_pcm_hw_params_t *params);
 int snd_pcm_hw_params_is_joint_duplex(const snd_pcm_hw_params_t *params);
 int snd_pcm_hw_params_can_sync_start(const snd_pcm_hw_params_t *params);
 int snd_pcm_hw_params_can_disable_period_wakeup(const snd_pcm_hw_params_t *params);
-int snd_pcm_hw_params_supports_audio_wallclock_ts(const snd_pcm_hw_params_t *params);
+int snd_pcm_hw_params_supports_audio_wallclock_ts(const snd_pcm_hw_params_t *params); /* deprecated, use audio_ts_type */
+int snd_pcm_hw_params_supports_audio_ts_type(const snd_pcm_hw_params_t *params, int type);
 int snd_pcm_hw_params_get_rate_numden(const snd_pcm_hw_params_t *params,
                                      unsigned int *rate_num,
                                      unsigned int *rate_den);
index bc18954b92da124bafd3a67913bd3c8900dd012f..846d502a6cb16db54cdbf0276cf74becb9bbb411 100644 (file)
@@ -3189,13 +3189,46 @@ int snd_pcm_hw_params_can_disable_period_wakeup(const snd_pcm_hw_params_t *param
  * a single configuration from the configuration space.
  */
 int snd_pcm_hw_params_supports_audio_wallclock_ts(const snd_pcm_hw_params_t *params)
+{
+       /* deprecated */
+       return snd_pcm_hw_params_supports_audio_ts_type(params,
+                                                       SNDRV_PCM_AUDIO_TSTAMP_TYPE_COMPAT);
+}
+
+/**
+ * \brief Check if hardware supports type of audio timestamps
+ * \param params Configuration space
+ * \param type   Audio timestamp type
+ * \retval 0 Hardware doesn't support type of audio timestamps
+ * \retval 1 Hardware supports type of audio timestamps
+ *
+ * This function should only be called when the configuration space
+ * contains a single configuration. Call #snd_pcm_hw_params to choose
+ * a single configuration from the configuration space.
+ */
+int snd_pcm_hw_params_supports_audio_ts_type(const snd_pcm_hw_params_t *params, int type)
 {
        assert(params);
        if (CHECK_SANITY(params->info == ~0U)) {
                SNDMSG("invalid PCM info field");
                return 0; /* FIXME: should be a negative error? */
        }
-       return !!(params->info & SNDRV_PCM_INFO_HAS_WALL_CLOCK);
+       switch (type) {
+       case SNDRV_PCM_AUDIO_TSTAMP_TYPE_COMPAT:
+               return !!(params->info & SNDRV_PCM_INFO_HAS_WALL_CLOCK); /* deprecated */
+       case SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT:
+               return 1; /* always supported, based on hw_ptr */
+       case SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK:
+               return !!(params->info & SNDRV_PCM_INFO_HAS_LINK_ATIME);
+       case SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_ABSOLUTE:
+               return !!(params->info & SNDRV_PCM_INFO_HAS_LINK_ABSOLUTE_ATIME);
+       case SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_ESTIMATED:
+               return !!(params->info & SNDRV_PCM_INFO_HAS_LINK_ESTIMATED_ATIME);
+       case SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED:
+               return !!(params->info & SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME);
+       default:
+               return 0;
+       }
 }
 
 /**