Browse Source

Continue LV2 work; All MIDI APIs in place

tags/1.9.4
falkTX 10 years ago
parent
commit
544ddf59c1
5 changed files with 40 additions and 59 deletions
  1. +26
    -45
      source/backend/plugin/Lv2Plugin.cpp
  2. +5
    -5
      source/includes/lv2/event-helpers.h
  3. +6
    -6
      source/includes/lv2/lv2-midifunctions.h
  4. +2
    -2
      source/utils/CarlaLv2Utils.hpp
  5. +1
    -1
      source/utils/Lv2AtomQueue.hpp

+ 26
- 45
source/backend/plugin/Lv2Plugin.cpp View File

@@ -1395,9 +1395,7 @@ public:
else if (type == CARLA_EVENT_DATA_EVENT) else if (type == CARLA_EVENT_DATA_EVENT)
{ {
fEventsIn.data[i].type = CARLA_EVENT_DATA_EVENT; fEventsIn.data[i].type = CARLA_EVENT_DATA_EVENT;
#if 0
fEventsIn.data[i].event = lv2_event_buffer_new(MAX_DEFAULT_BUFFER_SIZE, LV2_EVENT_AUDIO_STAMP); fEventsIn.data[i].event = lv2_event_buffer_new(MAX_DEFAULT_BUFFER_SIZE, LV2_EVENT_AUDIO_STAMP);
#endif
} }
else if (type == CARLA_EVENT_DATA_MIDI_LL) else if (type == CARLA_EVENT_DATA_MIDI_LL)
{ {
@@ -1424,9 +1422,7 @@ public:
else if (type == CARLA_EVENT_DATA_EVENT) else if (type == CARLA_EVENT_DATA_EVENT)
{ {
fEventsOut.data[i].type = CARLA_EVENT_DATA_EVENT; fEventsOut.data[i].type = CARLA_EVENT_DATA_EVENT;
#if 0
fEventsOut.data[i].event = lv2_event_buffer_new(MAX_DEFAULT_BUFFER_SIZE, LV2_EVENT_AUDIO_STAMP); fEventsOut.data[i].event = lv2_event_buffer_new(MAX_DEFAULT_BUFFER_SIZE, LV2_EVENT_AUDIO_STAMP);
#endif
} }
else if (type == CARLA_EVENT_DATA_MIDI_LL) else if (type == CARLA_EVENT_DATA_MIDI_LL)
{ {
@@ -1588,7 +1584,6 @@ public:
else else
carla_stderr2("WARNING - Got a broken Port (Atom-Sequence, but not input or output)"); carla_stderr2("WARNING - Got a broken Port (Atom-Sequence, but not input or output)");
} }
#if 0
else if (LV2_IS_PORT_EVENT(portTypes)) else if (LV2_IS_PORT_EVENT(portTypes))
{ {
if (LV2_IS_PORT_INPUT(portTypes)) if (LV2_IS_PORT_INPUT(portTypes))
@@ -1670,7 +1665,6 @@ public:
else else
carla_stderr2("WARNING - Got a broken Port (Event, but not input or output)"); carla_stderr2("WARNING - Got a broken Port (Event, but not input or output)");
} }
#endif
else if (LV2_IS_PORT_MIDI_LL(portTypes)) else if (LV2_IS_PORT_MIDI_LL(portTypes))
{ {
if (LV2_IS_PORT_INPUT(portTypes)) if (LV2_IS_PORT_INPUT(portTypes))
@@ -2240,10 +2234,8 @@ public:
// Event itenerators from different APIs (input) // Event itenerators from different APIs (input)


LV2_Atom_Buffer_Iterator evInAtomIters[fEventsIn.count]; LV2_Atom_Buffer_Iterator evInAtomIters[fEventsIn.count];
#if 0
LV2_Event_Iterator evInEventIters[fEventsIn.count]; LV2_Event_Iterator evInEventIters[fEventsIn.count];
LV2_MIDIState evInMidiStates[fEventsIn.count]; LV2_MIDIState evInMidiStates[fEventsIn.count];
#endif


for (uint32_t i=0; i < fEventsIn.count; ++i) for (uint32_t i=0; i < fEventsIn.count; ++i)
{ {
@@ -2252,22 +2244,18 @@ public:
lv2_atom_buffer_reset(fEventsIn.data[i].atom, true); lv2_atom_buffer_reset(fEventsIn.data[i].atom, true);
lv2_atom_buffer_begin(&evInAtomIters[i], fEventsIn.data[i].atom); lv2_atom_buffer_begin(&evInAtomIters[i], fEventsIn.data[i].atom);
} }
#if 0
else if (fEventsIn.data[i].type & CARLA_EVENT_DATA_EVENT) else if (fEventsIn.data[i].type & CARLA_EVENT_DATA_EVENT)
{ {
lv2_event_buffer_reset(fEventsIn.data[i].event, LV2_EVENT_AUDIO_STAMP, fEventsIn.data[i].event->data); lv2_event_buffer_reset(fEventsIn.data[i].event, LV2_EVENT_AUDIO_STAMP, fEventsIn.data[i].event->data);
lv2_event_begin(&evInEventIters[i], fEventsIn.data[i].event); lv2_event_begin(&evInEventIters[i], fEventsIn.data[i].event);
} }
#endif
else if (fEventsIn.data[i].type & CARLA_EVENT_DATA_MIDI_LL) else if (fEventsIn.data[i].type & CARLA_EVENT_DATA_MIDI_LL)
{ {
fEventsIn.data[i].midi.event_count = 0; fEventsIn.data[i].midi.event_count = 0;
fEventsIn.data[i].midi.size = 0; fEventsIn.data[i].midi.size = 0;
#if 0
evInMidiStates[i].midi = fEventsIn.data[i].midi;
evInMidiStates[i].midi = &fEventsIn.data[i].midi;
evInMidiStates[i].frame_count = frames; evInMidiStates[i].frame_count = frames;
evInMidiStates[i].position = 0; evInMidiStates[i].position = 0;
#endif
} }
} }


@@ -2277,12 +2265,10 @@ public:
{ {
lv2_atom_buffer_reset(fEventsOut.data[i].atom, false); lv2_atom_buffer_reset(fEventsOut.data[i].atom, false);
} }
#if 0
else if (fEventsOut.data[i].type & CARLA_EVENT_DATA_EVENT) else if (fEventsOut.data[i].type & CARLA_EVENT_DATA_EVENT)
{ {
lv2_event_buffer_reset(fEventsOut.data[i].event, LV2_EVENT_AUDIO_STAMP, fEventsOut.data[i].event->data); lv2_event_buffer_reset(fEventsOut.data[i].event, LV2_EVENT_AUDIO_STAMP, fEventsOut.data[i].event->data);
} }
#endif
else if (fEventsOut.data[i].type & CARLA_EVENT_DATA_MIDI_LL) else if (fEventsOut.data[i].type & CARLA_EVENT_DATA_MIDI_LL)
{ {
// not needed // not needed
@@ -2312,13 +2298,11 @@ public:
if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM) if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[j], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData); lv2_atom_buffer_write(&evInAtomIters[j], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);


#if 0
else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT) else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[j], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData); lv2_event_write(&evInEventIters[j], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);


else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL) else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[j], 0, 3, midiData);
#endif
lv2midi_put_event(&evInMidiStates[j], 0.0, 3, midiData);


midiData[0] = static_cast<uint8_t>(MIDI_STATUS_CONTROL_CHANGE + i); midiData[0] = static_cast<uint8_t>(MIDI_STATUS_CONTROL_CHANGE + i);
midiData[1] = MIDI_CONTROL_ALL_SOUND_OFF; midiData[1] = MIDI_CONTROL_ALL_SOUND_OFF;
@@ -2326,13 +2310,11 @@ public:
if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM) if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[j], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData); lv2_atom_buffer_write(&evInAtomIters[j], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);


#if 0
else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT) else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[j], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData); lv2_event_write(&evInEventIters[j], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);


else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL) else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[j], 0, 3, midiData);
#endif
lv2midi_put_event(&evInMidiStates[j], 0.0, 3, midiData);
} }
} }
else if (pData->ctrlChannel >= 0 && pData->ctrlChannel < MAX_MIDI_CHANNELS) else if (pData->ctrlChannel >= 0 && pData->ctrlChannel < MAX_MIDI_CHANNELS)
@@ -2345,13 +2327,11 @@ public:
if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM) if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[k], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData); lv2_atom_buffer_write(&evInAtomIters[k], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);


#if 0
else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT) else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[k], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData); lv2_event_write(&evInEventIters[k], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);


else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL) else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[k], 0, 3, midiData);
#endif
lv2midi_put_event(&evInMidiStates[k], 0.0, 3, midiData);
} }
} }
} }
@@ -2564,13 +2544,11 @@ public:
if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM) if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[j], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiEvent); lv2_atom_buffer_write(&evInAtomIters[j], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiEvent);


#if 0
else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT) else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[j], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiEvent); lv2_event_write(&evInEventIters[j], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiEvent);


else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL) else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[j], 0, 3, midiEvent);
#endif
lv2midi_put_event(&evInMidiStates[j], 0.0, 3, midiEvent);
} }
} }


@@ -2623,7 +2601,6 @@ public:
lv2_atom_buffer_reset(fEventsIn.data[j].atom, true); lv2_atom_buffer_reset(fEventsIn.data[j].atom, true);
lv2_atom_buffer_begin(&evInAtomIters[j], fEventsIn.data[j].atom); lv2_atom_buffer_begin(&evInAtomIters[j], fEventsIn.data[j].atom);
} }
#if 0
else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT) else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
{ {
lv2_event_buffer_reset(fEventsIn.data[j].event, LV2_EVENT_AUDIO_STAMP, fEventsIn.data[j].event->data); lv2_event_buffer_reset(fEventsIn.data[j].event, LV2_EVENT_AUDIO_STAMP, fEventsIn.data[j].event->data);
@@ -2635,7 +2612,6 @@ public:
fEventsIn.data[j].midi.size = 0; fEventsIn.data[j].midi.size = 0;
evInMidiStates[j].position = event.time; evInMidiStates[j].position = event.time;
} }
#endif
} }
else else
startTime += timeOffset; startTime += timeOffset;
@@ -2753,13 +2729,11 @@ public:
if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM) if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[fEventsIn.ctrlIndex], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData); lv2_atom_buffer_write(&evInAtomIters[fEventsIn.ctrlIndex], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);


#if 0
else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT) else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[fEventsIn.ctrlIndex], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData); lv2_event_write(&evInEventIters[fEventsIn.ctrlIndex], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);


else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL) else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[fEventsIn.ctrlIndex], 0, 3, midiData);
#endif
lv2midi_put_event(&evInMidiStates[fEventsIn.ctrlIndex], 0.0, 3, midiData);
} }


break; break;
@@ -2801,13 +2775,11 @@ public:
if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM) if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[fEventsIn.ctrlIndex], mtime, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData); lv2_atom_buffer_write(&evInAtomIters[fEventsIn.ctrlIndex], mtime, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);


#if 0
else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT) else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[fEventsIn.ctrlIndex], mtime, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData); lv2_event_write(&evInEventIters[fEventsIn.ctrlIndex], mtime, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);


else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL) else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[fEventsIn.ctrlIndex], mtime, 3, midiData); lv2midi_put_event(&evInMidiStates[fEventsIn.ctrlIndex], mtime, 3, midiData);
#endif
} }
break; break;


@@ -2830,13 +2802,11 @@ public:
if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM) if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[fEventsIn.ctrlIndex], mtime, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData); lv2_atom_buffer_write(&evInAtomIters[fEventsIn.ctrlIndex], mtime, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);


#if 0
else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT) else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[fEventsIn.ctrlIndex], mtime, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData); lv2_event_write(&evInEventIters[fEventsIn.ctrlIndex], mtime, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData);


else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL) else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[fEventsIn.ctrlIndex], mtime, 3, midiData); lv2midi_put_event(&evInMidiStates[fEventsIn.ctrlIndex], mtime, 3, midiData);
#endif
} }
break; break;
} // switch (ctrlEvent.type) } // switch (ctrlEvent.type)
@@ -2869,13 +2839,11 @@ public:
if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM) if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[j], mtime, 0, CARLA_URI_MAP_ID_MIDI_EVENT, midiEvent.size, midiEvent.data); lv2_atom_buffer_write(&evInAtomIters[j], mtime, 0, CARLA_URI_MAP_ID_MIDI_EVENT, midiEvent.size, midiEvent.data);


#if 0
else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT) else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[j], mtime, 0, CARLA_URI_MAP_ID_MIDI_EVENT, midiEvent.size, midiEvent.data); lv2_event_write(&evInEventIters[j], mtime, 0, CARLA_URI_MAP_ID_MIDI_EVENT, midiEvent.size, midiEvent.data);


else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL) else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[j], mtime, midiEvent.size, midiEvent.data); lv2midi_put_event(&evInMidiStates[j], mtime, midiEvent.size, midiEvent.data);
#endif


if (status == MIDI_STATUS_NOTE_ON) if (status == MIDI_STATUS_NOTE_ON)
pData->postponeRtEvent(kPluginPostRtEventNoteOn, channel, midiEvent.data[1], midiEvent.data[2]); pData->postponeRtEvent(kPluginPostRtEventNoteOn, channel, midiEvent.data[1], midiEvent.data[2]);
@@ -2928,8 +2896,12 @@ public:


if (ev->body.type == CARLA_URI_MAP_ID_MIDI_EVENT) if (ev->body.type == CARLA_URI_MAP_ID_MIDI_EVENT)
{ {
if (fEventsOut.ctrl->port != nullptr && ev->time.frames >= 0 && ev->body.size <= 0xFF)
if (fEventsOut.ctrl->port != nullptr)
{
CARLA_SAFE_ASSERT_CONTINUE(ev->time.frames >= 0);
CARLA_SAFE_ASSERT_CONTINUE(ev->body.size < 0xFF);
fEventsOut.ctrl->port->writeMidiEvent(static_cast<uint32_t>(ev->time.frames), static_cast<uint8_t>(ev->body.size), data); fEventsOut.ctrl->port->writeMidiEvent(static_cast<uint32_t>(ev->time.frames), static_cast<uint8_t>(ev->body.size), data);
}
} }
else if (ev->body.type == CARLA_URI_MAP_ID_ATOM_BLANK) else if (ev->body.type == CARLA_URI_MAP_ID_ATOM_BLANK)
{ {
@@ -2939,7 +2911,6 @@ public:
lv2_atom_buffer_increment(&iter); lv2_atom_buffer_increment(&iter);
} }
} }
#if 0
else if ((fEventsOut.ctrl->type & CARLA_EVENT_DATA_EVENT) != 0 && fEventsOut.ctrl->port != nullptr) else if ((fEventsOut.ctrl->type & CARLA_EVENT_DATA_EVENT) != 0 && fEventsOut.ctrl->port != nullptr)
{ {
const LV2_Event* ev; const LV2_Event* ev;
@@ -2957,29 +2928,39 @@ public:
break; break;


if (ev->type == CARLA_URI_MAP_ID_MIDI_EVENT) if (ev->type == CARLA_URI_MAP_ID_MIDI_EVENT)
fEventsOut.ctrl->port->writeMidiEvent(ev->frames, ev->size, data);
{
CARLA_SAFE_ASSERT_CONTINUE(ev->size < 0xFF);
fEventsOut.ctrl->port->writeMidiEvent(ev->frames, static_cast<uint8_t>(ev->size), data);
}


lv2_event_increment(&iter); lv2_event_increment(&iter);
} }
} }
else if ((fEventsOut.ctrl->type & CARLA_EVENT_DATA_MIDI_LL) != 0 && fEventsOut.ctrl->port != nullptr) else if ((fEventsOut.ctrl->type & CARLA_EVENT_DATA_MIDI_LL) != 0 && fEventsOut.ctrl->port != nullptr)
{ {
LV2_MIDIState state = { fEventsOut.ctrl->midi, frames, 0 };
LV2_MIDIState state = { &fEventsOut.ctrl->midi, frames, 0 };


uint32_t eventSize; uint32_t eventSize;
double eventTime; double eventTime;
unsigned char* eventData; unsigned char* eventData;


for (; lv2midi_get_event(&state, &eventTime, &eventSize, &eventData) < frames;)
for (;;)
{ {
eventSize = 0;
eventTime = 0.0;
eventData = nullptr;
lv2midi_get_event(&state, &eventTime, &eventSize, &eventData);

if (eventData == nullptr || eventSize == 0) if (eventData == nullptr || eventSize == 0)
break; break;


fEventsOut.ctrl->port->writeMidiEvent(eventTime, eventSize, eventData);
CARLA_SAFE_ASSERT_CONTINUE(eventSize < 0xFF);
CARLA_SAFE_ASSERT_CONTINUE(eventTime >= 0.0);

fEventsOut.ctrl->port->writeMidiEvent(static_cast<uint32_t>(eventTime), static_cast<uint8_t>(eventSize), eventData);
lv2midi_step(&state); lv2midi_step(&state);
} }
} }
#endif
} }


// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------


+ 5
- 5
source/includes/lv2/event-helpers.h View File

@@ -50,7 +50,7 @@ extern "C" {
static inline uint16_t static inline uint16_t
lv2_event_pad_size(uint16_t size) lv2_event_pad_size(uint16_t size)
{ {
return (size + 7) & (~7);
return (uint16_t)((uint16_t)(size + 7) & (~7));
} }




@@ -130,7 +130,7 @@ lv2_event_increment(LV2_Event_Iterator* iter)
LV2_Event* const ev = (LV2_Event*)( LV2_Event* const ev = (LV2_Event*)(
(uint8_t*)iter->buf->data + iter->offset); (uint8_t*)iter->buf->data + iter->offset);


iter->offset += lv2_event_pad_size(sizeof(LV2_Event) + ev->size);
iter->offset += lv2_event_pad_size((uint16_t)(sizeof(LV2_Event) + ev->size));


return true; return true;
} }
@@ -190,7 +190,7 @@ lv2_event_write(LV2_Event_Iterator* iter,
memcpy((uint8_t*)ev + sizeof(LV2_Event), data, size); memcpy((uint8_t*)ev + sizeof(LV2_Event), data, size);
++iter->buf->event_count; ++iter->buf->event_count;


size = lv2_event_pad_size(sizeof(LV2_Event) + size);
size = lv2_event_pad_size((uint16_t)(sizeof(LV2_Event) + size));
iter->buf->size += size; iter->buf->size += size;
iter->offset += size; iter->offset += size;


@@ -220,7 +220,7 @@ lv2_event_reserve(LV2_Event_Iterator* iter,
ev->size = size; ev->size = size;
++iter->buf->event_count; ++iter->buf->event_count;


size = lv2_event_pad_size(sizeof(LV2_Event) + size);
size = lv2_event_pad_size((uint16_t)(sizeof(LV2_Event) + size));
iter->buf->size += size; iter->buf->size += size;
iter->offset += size; iter->offset += size;


@@ -248,7 +248,7 @@ lv2_event_write_event(LV2_Event_Iterator* iter,
memcpy((uint8_t*)write_ev + sizeof(LV2_Event), data, ev->size); memcpy((uint8_t*)write_ev + sizeof(LV2_Event), data, ev->size);
++iter->buf->event_count; ++iter->buf->event_count;


const uint16_t size = lv2_event_pad_size(sizeof(LV2_Event) + ev->size);
const uint16_t size = lv2_event_pad_size((uint16_t)(sizeof(LV2_Event) + ev->size));
iter->buf->size += size; iter->buf->size += size;
iter->offset += size; iter->offset += size;




+ 6
- 6
source/includes/lv2/lv2-midifunctions.h View File

@@ -50,7 +50,7 @@ inline double lv2midi_get_event(LV2_MIDIState* state,
} }
*timestamp = *(double*)(state->midi->data + state->position); *timestamp = *(double*)(state->midi->data + state->position);
*size = *(size_t*)(state->midi->data + state->position + sizeof(double));
*size = (uint32_t)*(size_t*)(state->midi->data + state->position + sizeof(double));
*data = state->midi->data + state->position + *data = state->midi->data + state->position +
sizeof(double) + sizeof(size_t); sizeof(double) + sizeof(size_t);
return *timestamp; return *timestamp;
@@ -64,10 +64,10 @@ inline double lv2midi_step(LV2_MIDIState* state) {
return state->frame_count; return state->frame_count;
} }
state->position += sizeof(double);
state->position += (uint32_t)sizeof(double);
size_t size = *(size_t*)(state->midi->data + state->position); size_t size = *(size_t*)(state->midi->data + state->position);
state->position += sizeof(size_t);
state->position += size;
state->position += (uint32_t)sizeof(size_t);
state->position += (uint32_t)size;
return *(double*)(state->midi->data + state->position); return *(double*)(state->midi->data + state->position);
} }


@@ -80,9 +80,9 @@ inline void lv2midi_put_event(LV2_MIDIState* state,
if (state->midi->size + sizeof(double) + sizeof(size_t) + size < state->midi->capacity) if (state->midi->size + sizeof(double) + sizeof(size_t) + size < state->midi->capacity)
{ {
*((double*)(state->midi->data + state->midi->size)) = timestamp; *((double*)(state->midi->data + state->midi->size)) = timestamp;
state->midi->size += sizeof(double);
state->midi->size += (uint32_t)sizeof(double);
*((size_t*)(state->midi->data + state->midi->size)) = size; *((size_t*)(state->midi->data + state->midi->size)) = size;
state->midi->size += sizeof(size_t);
state->midi->size += (uint32_t)sizeof(size_t);
memcpy(state->midi->data + state->midi->size, data, size); memcpy(state->midi->data + state->midi->size, data, size);


state->midi->size += size; state->midi->size += size;


+ 2
- 2
source/utils/CarlaLv2Utils.hpp View File

@@ -29,7 +29,7 @@
#include "lv2/data-access.h" #include "lv2/data-access.h"
// dynmanifest // dynmanifest
#include "lv2/event.h" #include "lv2/event.h"
//#include "lv2/event-helpers.h"
#include "lv2/event-helpers.h"
#include "lv2/instance-access.h" #include "lv2/instance-access.h"
#include "lv2/log.h" #include "lv2/log.h"
// logger // logger
@@ -51,7 +51,7 @@
#include "lv2/worker.h" #include "lv2/worker.h"


#include "lv2/lv2-miditype.h" #include "lv2/lv2-miditype.h"
//#include "lv2/lv2-midifunctions.h"
#include "lv2/lv2-midifunctions.h"
#include "lv2/lv2_external_ui.h" #include "lv2/lv2_external_ui.h"
#include "lv2/lv2_programs.h" #include "lv2/lv2_programs.h"
#include "lv2/lv2_rtmempool.h" #include "lv2/lv2_rtmempool.h"


+ 1
- 1
source/utils/Lv2AtomQueue.hpp View File

@@ -144,7 +144,7 @@ public:


bool isEmpty() const noexcept bool isEmpty() const noexcept
{ {
return !fRingBufferCtrl.isDataAvailable();
return (fRingBufferCtrl.fBuffer.buf == nullptr || !fRingBufferCtrl.isDataAvailable());
} }


// must have been locked before // must have been locked before


Loading…
Cancel
Save