mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-02 09:01:48 -05:00
ump: Add a function to provide the packet word length of a UMP type
Add a helper function to return the number of words of a given UMP packet type. Used for parsing MIDI Clip File stream, for example. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
ade099fab7
commit
568b2ac1db
3 changed files with 19 additions and 0 deletions
|
|
@ -1072,3 +1072,20 @@ int snd_ump_msg_sysex_expand(const uint32_t *ump, uint8_t *buf, size_t maxlen,
|
|||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief return the length of a UMP packet type
|
||||
* \param type UMP packet type
|
||||
* \return the length of the given UMP packet type in 32bit words (from 1 to 4),
|
||||
* or 0 for negative inputs.
|
||||
*/
|
||||
int snd_ump_packet_length(unsigned int type)
|
||||
{
|
||||
static int packet_length[16] = {
|
||||
1, 1, 1, 2, 2, 4, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4
|
||||
};
|
||||
|
||||
if (type > 16)
|
||||
return 0;
|
||||
return packet_length[type];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue