mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
jack: set the final midi size as the buffer size.
The buffer has initially a maxsize. After writing we midi events, we can update it with the real size.
This commit is contained in:
parent
92f35b99a0
commit
537fc63cc6
1 changed files with 16 additions and 8 deletions
|
|
@ -902,7 +902,7 @@ static inline void reuse_buffer(struct client *c, struct mix *mix, uint32_t id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void convert_from_midi(void *midi, void *buffer, size_t size)
|
static size_t convert_from_midi(void *midi, void *buffer, size_t size)
|
||||||
{
|
{
|
||||||
struct spa_pod_builder b = { 0, };
|
struct spa_pod_builder b = { 0, };
|
||||||
uint32_t i, count;
|
uint32_t i, count;
|
||||||
|
|
@ -920,6 +920,7 @@ static void convert_from_midi(void *midi, void *buffer, size_t size)
|
||||||
spa_pod_builder_bytes(&b, ev.buffer, ev.size);
|
spa_pod_builder_bytes(&b, ev.buffer, ev.size);
|
||||||
}
|
}
|
||||||
spa_pod_builder_pop(&b, &f);
|
spa_pod_builder_pop(&b, &f);
|
||||||
|
return b.state.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void convert_to_midi(struct spa_pod_sequence **seq, uint32_t n_seq, void *midi)
|
static void convert_to_midi(struct spa_pod_sequence **seq, uint32_t n_seq, void *midi)
|
||||||
|
|
@ -960,7 +961,7 @@ static void convert_to_midi(struct spa_pod_sequence **seq, uint32_t n_seq, void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline void *get_buffer_output(struct port *p, uint32_t frames, uint32_t stride)
|
static inline void *get_buffer_output(struct port *p, uint32_t frames, uint32_t stride, struct buffer **buf)
|
||||||
{
|
{
|
||||||
struct mix *mix;
|
struct mix *mix;
|
||||||
struct client *c = p->client;
|
struct client *c = p->client;
|
||||||
|
|
@ -987,6 +988,8 @@ static inline void *get_buffer_output(struct port *p, uint32_t frames, uint32_t
|
||||||
}
|
}
|
||||||
reuse_buffer(c, mix, b->id);
|
reuse_buffer(c, mix, b->id);
|
||||||
ptr = b->datas[0].data;
|
ptr = b->datas[0].data;
|
||||||
|
if (buf)
|
||||||
|
*buf = b;
|
||||||
|
|
||||||
b->datas[0].chunk->offset = 0;
|
b->datas[0].chunk->offset = 0;
|
||||||
b->datas[0].chunk->size = frames * sizeof(float);
|
b->datas[0].chunk->size = frames * sizeof(float);
|
||||||
|
|
@ -1019,15 +1022,20 @@ static void process_tee(struct client *c, uint32_t frames)
|
||||||
|
|
||||||
switch (p->object->port.type_id) {
|
switch (p->object->port.type_id) {
|
||||||
case TYPE_ID_AUDIO:
|
case TYPE_ID_AUDIO:
|
||||||
ptr = get_buffer_output(p, frames, sizeof(float));
|
ptr = get_buffer_output(p, frames, sizeof(float), NULL);
|
||||||
if (SPA_LIKELY(ptr != NULL))
|
if (SPA_LIKELY(ptr != NULL))
|
||||||
memcpy(ptr, p->emptyptr, frames * sizeof(float));
|
memcpy(ptr, p->emptyptr, frames * sizeof(float));
|
||||||
break;
|
break;
|
||||||
case TYPE_ID_MIDI:
|
case TYPE_ID_MIDI:
|
||||||
ptr = get_buffer_output(p, MAX_BUFFER_FRAMES, 1);
|
{
|
||||||
if (SPA_LIKELY(ptr != NULL))
|
struct buffer *b;
|
||||||
convert_from_midi(p->emptyptr, ptr, MAX_BUFFER_FRAMES * sizeof(float));
|
ptr = get_buffer_output(p, MAX_BUFFER_FRAMES, 1, &b);
|
||||||
|
if (SPA_LIKELY(ptr != NULL)) {
|
||||||
|
b->datas[0].chunk->size = convert_from_midi(p->emptyptr,
|
||||||
|
ptr, MAX_BUFFER_FRAMES * sizeof(float));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
pw_log_warn("port %p: unhandled format %d", p, p->object->port.type_id);
|
pw_log_warn("port %p: unhandled format %d", p, p->object->port.type_id);
|
||||||
break;
|
break;
|
||||||
|
|
@ -4105,7 +4113,7 @@ static void *get_buffer_output_float(struct port *p, jack_nframes_t frames)
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
ptr = get_buffer_output(p, frames, sizeof(float));
|
ptr = get_buffer_output(p, frames, sizeof(float), NULL);
|
||||||
if (SPA_UNLIKELY(p->empty_out = (ptr == NULL)))
|
if (SPA_UNLIKELY(p->empty_out = (ptr == NULL)))
|
||||||
ptr = p->emptyptr;
|
ptr = p->emptyptr;
|
||||||
return ptr;
|
return ptr;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue