seq: Add API functions to set different tempo base values
PATCH 1/1 seq: Add API functions to set different tempo base values
MIDI2 Set Tempo message uses 10ns-based values, and we need to update the API to change the base time unit.
This patch adds a few new API functions:
- snd_seq_has_queue_tempo_base() returns 1 if the client supports a new tempo-base value; if 0, it's an old system and application has to use the tempo in the fixed 1us unit
- the tempo base can be changed with snd_seq_queue_tempo_set_tempo_base(), provided in nsec unit; the value has to be either 10 or 1000 (or 0 as default, equivalent with 1000)
The protocol version is checked and fallback to the fixed 1us base for the old clients.
Signed-off-by Takashi Iwai <[email protected]>
--- include/seq.h | 3 ++ include/sound/uapi/asequencer.h | 7 ++-- src/Versions.in.in | 3 ++ src/seq/seq.c | 58 +++++++++++++++++++++++++++++++++ src/seq/seq_hw.c | 5 +++ src/seq/seq_local.h | 1 + 6 files changed, 74 insertions(+), 3 deletions(-)
include/seq.h +3 -0
@@ -506,13 +506,16 @@ unsigned int snd_seq_queue_tempo_get_tempo(const snd_seq_queue_tempo_t *info);int snd_seq_queue_tempo_get_ppq (const snd_seq_queue_tempo_t *info);unsigned int snd_seq_queue_tempo_get_skew (const snd_seq_queue_tempo_t *info);unsigned int snd_seq_queue_tempo_get_skew_base (const snd_seq_queue_tempo_t *info); +unsigned int snd_seq_queue_tempo_get_tempo_base (const snd_seq_queue_tempo_t *info);void snd_seq_queue_tempo_set_tempo (snd_seq_queue_tempo_t *info,unsigned int tempo);void snd_seq_queue_tempo_set_ppq (snd_seq_queue_tempo_t *info,int ppq);void snd_seq_queue_tempo_set_skew (snd_seq_queue_tempo_t *info,unsigned int skew);void snd_seq_queue_tempo_set_skew_base (snd_seq_queue_tempo_t *info,unsigned int base); +void snd_seq_queue_tempo_set_tempo_base (snd_seq_queue_tempo_t *info,unsigned int tempo_base);int snd_seq_get_queue_tempo (snd_seq_t *handle,int q,snd_seq_queue_tempo_t *tempo);int snd_seq_set_queue_tempo (snd_seq_t *handle,int q,snd_seq_queue_tempo_t *tempo); +int snd_seq_has_queue_tempo_base (snd_seq_t *handle);/* */
include/sound/uapi/asequencer.h +4 -3
@@ -26,7 +26,7 @@#include <sound/asound.h> /** version of the sequencer */ -#define SNDRV_SEQ_VERSION SNDRV_PROTOCOL_VERSION(1, 0, 3) +#define SNDRV_SEQ_VERSION SNDRV_PROTOCOL_VERSION(1, 0, 4)/** * definition of sequencer event types
@@ -539,11 +539,12 @@ struct snd_seq_queue_status {/* queue tempo */ struct snd_seq_queue_tempo {int queue;/* sequencer queue */ -unsigned int tempo;/* current tempo, us/tick */ +unsigned int tempo;/* current tempo, us/tick (or different time-base below) */ int ppq;/* time resolution, ticks/quarter */ unsigned int skew_value;/* queue skew */ unsigned int skew_base;/* queue skew base */ -char reserved[24 ];/* for the future */ +unsigned short tempo_base;/* tempo base in nsec unit; either 10 or 1000 */ +char reserved[22 ];/* for the future */ };
src/Versions.in.in +3 -0
@@ -206,6 +206,9 @@ ALSA_1.2.13 { #ifdef HAVE_SEQ_SYMS @SYMBOL_PREFIX@snd_seq_create_ump_endpoint; @SYMBOL_PREFIX@snd_seq_create_ump_block; + @SYMBOL_PREFIX@snd_seq_queue_tempo_get_tempo_base; + @SYMBOL_PREFIX@snd_seq_queue_tempo_set_tempo_base; + @SYMBOL_PREFIX@snd_seq_has_tempo_base; #endif #ifdef HAVE_RAWMIDI_SYMS @SYMBOL_PREFIX@snd_ump_endpoint_info_clear;
src/seq/seq.c +58 -0
86 lines not on this page · raw message
src/seq/seq_hw.c +5 -0
@@ -275,12 +275,15 @@ static int snd_seq_hw_get_queue_tempo(snd_seq_t *seq, snd_seq_queue_tempo_t * te/*SYSERR("SNDRV_SEQ_IOCTL_GET_QUEUE_TEMPO failed");*/ return -errno; } +if (!seq->has_queue_tempo_base) + tempo->tempo_base =1000 ;return 0 ; }static int snd_seq_hw_set_queue_tempo (snd_seq_t *seq,snd_seq_queue_tempo_t * tempo) {snd_seq_hw_t *hw = seq->private_data; +if (ioctl (hw->fd,SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO , tempo) <0 ) {/*SYSERR("SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO failed");*/ return -errno;
@@ -587,6 +590,8 @@ int snd_seq_hw_open(snd_seq_t **handle, const char *name, int streams, int mode) seq->ops = &snd_seq_hw_ops; seq->private_data = hw; seq->packet_size =sizeof (snd_seq_event_t); + seq->has_queue_tempo_base = ver >=SNDRV_PROTOCOL_VERSION (1 ,0 ,4 ); + client =snd_seq_hw_client_id (seq);if (client <0 ) {snd_seq_close (seq);
src/seq/seq_local.h +1 -0
@@ -94,6 +94,7 @@ struct _snd_seq {size_t tmpbufsize;/* size of errbuf */ size_t packet_size;/* input packet alignment size */ int midi_version;/* current protocol version */ +int has_queue_tempo_base;/* support queue tempo-base? */ unsigned int num_ump_groups;/* number of UMP groups */ snd_ump_endpoint_info_t *ump_ep;/* optional UMP info */
Signature · 1 line
2.43.0