mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
rawmidi: rename enum snd_rawmidi_framing to snd_rawmidi_read_mode
We hide the internal data transfers using the data frames. Rename the snd_rawmidi_framing enum to snd_rawmidi_read_mode to make API more straight and understandable. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
5a5c2953ea
commit
d3c5e9e009
3 changed files with 37 additions and 21 deletions
|
|
@ -79,7 +79,7 @@ typedef enum _snd_rawmidi_type {
|
|||
SND_RAWMIDI_TYPE_VIRTUAL
|
||||
} snd_rawmidi_type_t;
|
||||
|
||||
/** Type of clock used with rawmidi tstamp framing */
|
||||
/** Type of clock used with rawmidi timestamp */
|
||||
typedef enum _snd_rawmidi_clock {
|
||||
SND_RAWMIDI_CLOCK_NONE = 0,
|
||||
SND_RAWMIDI_CLOCK_REALTIME = 1,
|
||||
|
|
@ -87,11 +87,11 @@ typedef enum _snd_rawmidi_clock {
|
|||
SND_RAWMIDI_CLOCK_MONOTONIC_RAW = 3,
|
||||
} snd_rawmidi_clock_t;
|
||||
|
||||
/** Enable or disable rawmidi framing */
|
||||
typedef enum _snd_rawmidi_framing {
|
||||
SND_RAWMIDI_FRAMING_NONE = 0,
|
||||
SND_RAWMIDI_FRAMING_TSTAMP = 1,
|
||||
} snd_rawmidi_framing_t;
|
||||
/** Select the read mode (standard or with timestamps) */
|
||||
typedef enum _snd_rawmidi_read_mode {
|
||||
SND_RAWMIDI_READ_STANDARD = 0,
|
||||
SND_RAWMIDI_READ_TSTAMP = 1,
|
||||
} snd_rawmidi_read_mode_t;
|
||||
|
||||
int snd_rawmidi_open(snd_rawmidi_t **in_rmidi, snd_rawmidi_t **out_rmidi,
|
||||
const char *name, int mode);
|
||||
|
|
@ -140,8 +140,8 @@ int snd_rawmidi_params_set_avail_min(snd_rawmidi_t *rmidi, snd_rawmidi_params_t
|
|||
size_t snd_rawmidi_params_get_avail_min(const snd_rawmidi_params_t *params);
|
||||
int snd_rawmidi_params_set_no_active_sensing(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params, int val);
|
||||
int snd_rawmidi_params_get_no_active_sensing(const snd_rawmidi_params_t *params);
|
||||
int snd_rawmidi_params_set_framing_type(const snd_rawmidi_t *rawmidi, snd_rawmidi_params_t *params, snd_rawmidi_framing_t val);
|
||||
snd_rawmidi_framing_t snd_rawmidi_params_get_framing_type(const snd_rawmidi_params_t *params);
|
||||
int snd_rawmidi_params_set_read_mode(const snd_rawmidi_t *rawmidi, snd_rawmidi_params_t *params, snd_rawmidi_read_mode_t val);
|
||||
snd_rawmidi_read_mode_t snd_rawmidi_params_get_read_mode(const snd_rawmidi_params_t *params);
|
||||
int snd_rawmidi_params_set_clock_type(const snd_rawmidi_t *rawmidi, snd_rawmidi_params_t *params, snd_rawmidi_clock_t val);
|
||||
snd_rawmidi_clock_t snd_rawmidi_params_get_clock_type(const snd_rawmidi_params_t *params);
|
||||
|
||||
|
|
|
|||
|
|
@ -823,38 +823,54 @@ int snd_rawmidi_params_get_no_active_sensing(const snd_rawmidi_params_t *params)
|
|||
}
|
||||
|
||||
/**
|
||||
* \brief enable or disable rawmidi framing
|
||||
* \brief set read mode
|
||||
* \param rawmidi RawMidi handle
|
||||
* \param params pointer to snd_rawmidi_params_t structure
|
||||
* \param val type of rawmidi framing
|
||||
* \param val type of read_mode
|
||||
* \return 0 on success, otherwise a negative error code.
|
||||
*
|
||||
* Notable error codes:
|
||||
* -EINVAL - "val" is invalid
|
||||
* -ENOTSUP - Kernel is too old to support framing.
|
||||
* -ENOTSUP - mode is not supported
|
||||
*
|
||||
*/
|
||||
int snd_rawmidi_params_set_framing_type(const snd_rawmidi_t *rawmidi, snd_rawmidi_params_t *params, snd_rawmidi_framing_t val)
|
||||
int snd_rawmidi_params_set_read_mode(const snd_rawmidi_t *rawmidi, snd_rawmidi_params_t *params, snd_rawmidi_read_mode_t val)
|
||||
{
|
||||
unsigned int framing;
|
||||
assert(rawmidi && params);
|
||||
if (val > SNDRV_RAWMIDI_MODE_FRAMING_MASK >> SNDRV_RAWMIDI_MODE_FRAMING_SHIFT)
|
||||
|
||||
switch (val) {
|
||||
case SND_RAWMIDI_READ_STANDARD:
|
||||
framing = SNDRV_RAWMIDI_MODE_FRAMING_NONE;
|
||||
break;
|
||||
case SND_RAWMIDI_READ_TSTAMP:
|
||||
framing = SNDRV_RAWMIDI_MODE_FRAMING_TSTAMP;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
if (val != SNDRV_RAWMIDI_MODE_FRAMING_NONE &&
|
||||
}
|
||||
|
||||
if (framing != SNDRV_RAWMIDI_MODE_FRAMING_NONE &&
|
||||
(rawmidi->version < SNDRV_PROTOCOL_VERSION(2, 0, 2) || rawmidi->stream != SND_RAWMIDI_STREAM_INPUT))
|
||||
return -ENOTSUP;
|
||||
params->mode = (params->mode & ~SNDRV_RAWMIDI_MODE_FRAMING_MASK) + (val << SNDRV_RAWMIDI_MODE_FRAMING_SHIFT);
|
||||
params->mode = (params->mode & ~SNDRV_RAWMIDI_MODE_FRAMING_MASK) | framing;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get current framing type
|
||||
* \brief get current read mode
|
||||
* \param params pointer to snd_rawmidi_params_t structure
|
||||
* \return the current type (0 = no framing, 1 = tstamp type framing)
|
||||
* \return the current read mode (see enum)
|
||||
*/
|
||||
snd_rawmidi_framing_t snd_rawmidi_params_get_framing_type(const snd_rawmidi_params_t *params)
|
||||
snd_rawmidi_read_mode_t snd_rawmidi_params_get_read_mode(const snd_rawmidi_params_t *params)
|
||||
{
|
||||
unsigned int framing;
|
||||
|
||||
assert(params);
|
||||
return (params->mode & SNDRV_RAWMIDI_MODE_FRAMING_MASK) >> SNDRV_RAWMIDI_MODE_FRAMING_SHIFT;
|
||||
framing = params->mode & SNDRV_RAWMIDI_MODE_FRAMING_MASK;
|
||||
if (framing == SNDRV_RAWMIDI_MODE_FRAMING_TSTAMP)
|
||||
return SND_RAWMIDI_READ_TSTAMP;
|
||||
return SND_RAWMIDI_READ_STANDARD;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -151,9 +151,9 @@ int main(int argc,char** argv)
|
|||
if (clock_type != -1) {
|
||||
fprintf(stderr, "Enable kernel clock type %d\n", clock_type);
|
||||
snd_rawmidi_params_current(handle_in, params);
|
||||
err = snd_rawmidi_params_set_framing_type(handle_in, params, 1);
|
||||
err = snd_rawmidi_params_set_read_mode(handle_in, params, SND_RAWMIDI_READ_TSTAMP);
|
||||
if (err) {
|
||||
fprintf(stderr,"snd_rawmidi_params_set_framing_type failed: %d\n", err);
|
||||
fprintf(stderr,"snd_rawmidi_params_set_read_mode failed: %d\n", err);
|
||||
clock_type = -1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue