mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-02-11 04:27:56 -05:00
modules: accept and produce UMP only
This commit is contained in:
parent
40cd8535eb
commit
d9e7a10b0d
11 changed files with 199 additions and 126 deletions
|
|
@ -67,7 +67,7 @@ static void vban_midi_process_playback(void *data)
|
|||
} else {
|
||||
timestamp = target;
|
||||
}
|
||||
spa_pod_builder_control(&b, target - timestamp, SPA_CONTROL_Midi);
|
||||
spa_pod_builder_control(&b, target - timestamp, c->type);
|
||||
spa_pod_builder_bytes(&b,
|
||||
SPA_POD_BODY(&c->value),
|
||||
SPA_POD_BODY_SIZE(&c->value));
|
||||
|
|
@ -162,19 +162,29 @@ static int vban_midi_receive_midi(struct impl *impl, uint8_t *packet,
|
|||
|
||||
while (offs < plen) {
|
||||
int size;
|
||||
|
||||
spa_pod_builder_control(&b, timestamp, SPA_CONTROL_Midi);
|
||||
uint8_t *midi_data;
|
||||
size_t midi_size;
|
||||
uint64_t midi_state = 0;
|
||||
|
||||
size = get_midi_size(&packet[offs], plen - offs);
|
||||
|
||||
if (size <= 0 || offs + size > plen) {
|
||||
pw_log_warn("invalid size (%08x) %d (%u %u)",
|
||||
packet[offs], size, offs, plen);
|
||||
break;
|
||||
}
|
||||
|
||||
spa_pod_builder_bytes(&b, &packet[offs], size);
|
||||
midi_data = &packet[offs];
|
||||
midi_size = size;
|
||||
while (midi_size > 0) {
|
||||
uint32_t ump[4];
|
||||
int ump_size = spa_ump_from_midi(&midi_data, &midi_size,
|
||||
ump, sizeof(ump), 0, &midi_state);
|
||||
if (ump_size <= 0)
|
||||
break;
|
||||
|
||||
spa_pod_builder_control(&b, timestamp, SPA_CONTROL_UMP);
|
||||
spa_pod_builder_bytes(&b, ump, ump_size);
|
||||
}
|
||||
offs += size;
|
||||
}
|
||||
spa_pod_builder_pop(&b, &f[0]);
|
||||
|
|
@ -239,14 +249,17 @@ static void vban_midi_flush_packets(struct impl *impl,
|
|||
len = 0;
|
||||
|
||||
SPA_POD_SEQUENCE_FOREACH(sequence, c) {
|
||||
void *ev;
|
||||
uint32_t size;
|
||||
int size;
|
||||
uint8_t event[16];
|
||||
|
||||
if (c->type != SPA_CONTROL_Midi)
|
||||
if (c->type != SPA_CONTROL_UMP)
|
||||
continue;
|
||||
|
||||
size = spa_ump_to_midi(SPA_POD_BODY(&c->value),
|
||||
SPA_POD_BODY_SIZE(&c->value), event, sizeof(event));
|
||||
if (size <= 0)
|
||||
continue;
|
||||
|
||||
ev = SPA_POD_BODY(&c->value),
|
||||
size = SPA_POD_BODY_SIZE(&c->value);
|
||||
if (len == 0) {
|
||||
/* start new packet */
|
||||
header.n_frames++;
|
||||
|
|
@ -258,7 +271,7 @@ static void vban_midi_flush_packets(struct impl *impl,
|
|||
vban_stream_emit_send_packet(impl, iov, 2);
|
||||
len = 0;
|
||||
}
|
||||
memcpy(&impl->buffer[len], ev, size);
|
||||
memcpy(&impl->buffer[len], event, size);
|
||||
len += size;
|
||||
}
|
||||
if (len > 0) {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <spa/utils/dll.h>
|
||||
#include <spa/param/audio/format-utils.h>
|
||||
#include <spa/control/control.h>
|
||||
#include <spa/control/ump-utils.h>
|
||||
#include <spa/debug/types.h>
|
||||
#include <spa/debug/mem.h>
|
||||
#include <spa/debug/log.h>
|
||||
|
|
@ -325,7 +326,7 @@ struct vban_stream *vban_stream_new(struct pw_core *core,
|
|||
res = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
pw_properties_set(props, PW_KEY_FORMAT_DSP, "8 bit raw midi");
|
||||
pw_properties_set(props, PW_KEY_FORMAT_DSP, "32 bit raw UMP");
|
||||
impl->stride = impl->format_info->size;
|
||||
impl->rate = pw_properties_get_uint32(props, "midi.rate", 10000);
|
||||
if (impl->rate == 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue