mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-03-08 05:34:03 -04:00
control: improve UMP to Midi conversiom
Improve the spa_ump_to_midi function so that it can consume multiple UMP messages and produce multiple midi messages. Some UMP messages (like program changes) need to be translated into up to 3 midi messages. Do this byt adding a state to the function and by making it consume the input bytes, just like the spa_ump_from_midi function. Adapt code to this new world. This is a little API break..
This commit is contained in:
parent
bf10458604
commit
e35a8554f8
13 changed files with 307 additions and 228 deletions
|
|
@ -826,11 +826,15 @@ static int impl_node_process(void *object)
|
|||
case SPA_CONTROL_UMP:
|
||||
{
|
||||
uint8_t ev[8];
|
||||
int ev_size = spa_ump_to_midi((uint32_t*)body, size, ev, sizeof(ev));
|
||||
if (ev_size <= 0)
|
||||
break;
|
||||
spa_pod_builder_control(&builder, control->offset, SPA_CONTROL_Midi);
|
||||
spa_pod_builder_bytes(&builder, ev, ev_size);
|
||||
const uint32_t *ump = (const uint32_t*)body;
|
||||
uint64_t state = 0;
|
||||
while (size > 0) {
|
||||
int ev_size = spa_ump_to_midi(&ump, &size, ev, sizeof(ev), &state);
|
||||
if (ev_size <= 0)
|
||||
break;
|
||||
spa_pod_builder_control(&builder, control->offset, SPA_CONTROL_Midi);
|
||||
spa_pod_builder_bytes(&builder, ev, ev_size);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue