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,
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);
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);
}
/**
- * \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;
}
/**
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;
}
}