rawmidi: define more abstract API for the timestamp reads

The frame structure is a bit internal thing for the kernel
data transfer implementation. Introduce snd_rawmidi_tread()
function which is straight for the application usage and hides
the framing data transfers (kernel space API).

The current code implements the read cache and does the merging
of the frame reads with the similar timestamps (opposite
to the kernel data split for big chunks).

If the application wants to use super-duper-lighting-fast reads,
the snd_rawmidi_read() may be used, but the structure must be
defined on it's own, because this mechanism is not preferred
and unsupported.

BugLink: https://github.com/alsa-project/alsa-lib/issues/172
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2021-08-24 11:36:30 +02:00
parent 42eeb5eca0
commit 5a5c2953ea
5 changed files with 144 additions and 37 deletions

View file

@ -34,6 +34,7 @@ typedef struct {
int (*drain)(snd_rawmidi_t *rawmidi);
ssize_t (*write)(snd_rawmidi_t *rawmidi, const void *buffer, size_t size);
ssize_t (*read)(snd_rawmidi_t *rawmidi, void *buffer, size_t size);
ssize_t (*tread)(snd_rawmidi_t *rawmidi, struct timespec *tstamp, void *buffer, size_t size);
} snd_rawmidi_ops_t;
struct _snd_rawmidi {