This commit is contained in:
Robin Davies
2022-02-01 18:51:38 -05:00
parent dddd6a85d5
commit caa2aa1312
26 changed files with 1245 additions and 114 deletions
+51 -1
View File
@@ -23,7 +23,6 @@
#include "Lv2Log.hpp"
#include "VuUpdate.hpp"
#include "JackHost.hpp"
namespace pipedal
{
@@ -50,6 +49,8 @@ namespace pipedal
OnMidiListen = 16,
AtomOutput = 17,
};
class RealtimeMonitorPortSubscription
@@ -186,6 +187,16 @@ namespace pipedal
}
return true;
}
bool read(size_t size, uint8_t*data)
{
if (!ringBuffer->read(size,data))
{
throw PiPedalStateException("Ringbuffer read failed. Did you forget to check for space?");
}
return true;
}
template <typename T>
void readComplete(T *output)
{
@@ -251,6 +262,24 @@ namespace pipedal
}
}
template <typename T>
void write(RingBufferCommand command, const T &value, size_t dataLength, uint8_t*variableData)
{
// the goal: to atomically write the command and associated data.
CommandBuffer<T> buffer(command, value);
if (!ringBuffer->write(buffer.size(),(uint8_t *)&buffer,dataLength,variableData))
{
Lv2Log::error("No space in audio service ringbuffer.");
return;
}
}
void AtomOutput(uint64_t instanceId, size_t bytes, uint8_t*data)
{
write(RingBufferCommand::AtomOutput,instanceId,bytes,data);
}
void ParameterRequest(RealtimeParameterRequest *pRequest)
{
write(RingBufferCommand::ParameterRequest,pRequest);
@@ -354,4 +383,25 @@ namespace pipedal
}
};
typedef RingBufferReader<true, false> RealtimeRingBufferReader;
typedef RingBufferReader<false, true> HostRingBufferReader;
typedef RingBufferWriter<true, false> HostRingBufferWriter;
// cures a forward-declaration problem.
class RealtimeRingBufferWriter: public RingBufferWriter<false, true>
{
public:
RealtimeRingBufferWriter()
{
}
RealtimeRingBufferWriter(RingBuffer<false,true>*ringBuffer)
: RingBufferWriter<false, true> (ringBuffer)
{
}
};
} //namespace