mirror of
https://github.com/storytold/UE4-OSC.git
synced 2026-10-18 07:33:16 +00:00
increase the max messages per frame number + log ignored messages
This commit is contained in:
@@ -10,7 +10,7 @@ UOscDispatcher::UOscDispatcher(const class FPostConstructInitializeProperties& P
|
|||||||
_listening(FIPv4Address(0), 0),
|
_listening(FIPv4Address(0), 0),
|
||||||
_socket(nullptr),
|
_socket(nullptr),
|
||||||
_socketReceiver(nullptr),
|
_socketReceiver(nullptr),
|
||||||
_pendingMessages(64)
|
_pendingMessages(1024) // arbitrary max message count per frame
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,13 @@ static void SendMessage(TCircularQueue<std::pair<FName, TArray<FOscDataElemStruc
|
|||||||
}
|
}
|
||||||
|
|
||||||
// save it in pending messages
|
// save it in pending messages
|
||||||
_pendingMessages.Enqueue(std::make_pair(address, data));
|
const auto added = _pendingMessages.Enqueue(std::make_pair(address, data));
|
||||||
|
|
||||||
|
// the circular buffer may be full.
|
||||||
|
if(!added)
|
||||||
|
{
|
||||||
|
UE_LOG(LogOSC, Warning, TEXT("Circular Buffer Full: Message Ignored"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SendBundle(TCircularQueue<std::pair<FName, TArray<FOscDataElemStruct>>> & _pendingMessages, const osc::ReceivedBundle & bundle)
|
static void SendBundle(TCircularQueue<std::pair<FName, TArray<FOscDataElemStruct>>> & _pendingMessages, const osc::ReceivedBundle & bundle)
|
||||||
@@ -141,6 +147,7 @@ static void SendBundle(TCircularQueue<std::pair<FName, TArray<FOscDataElemStruct
|
|||||||
|
|
||||||
void UOscDispatcher::Callback(const FArrayReaderPtr& data, const FIPv4Endpoint&)
|
void UOscDispatcher::Callback(const FArrayReaderPtr& data, const FIPv4Endpoint&)
|
||||||
{
|
{
|
||||||
|
const auto wasEmpty = _pendingMessages.IsEmpty();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const osc::ReceivedPacket packet((const char *)data->GetData(), data->Num());
|
const osc::ReceivedPacket packet((const char *)data->GetData(), data->Num());
|
||||||
@@ -161,7 +168,8 @@ void UOscDispatcher::Callback(const FArrayReaderPtr& data, const FIPv4Endpoint&)
|
|||||||
UE_LOG(LogOSC, Warning, TEXT("OSC Message Error: %s"), *wide);
|
UE_LOG(LogOSC, Warning, TEXT("OSC Message Error: %s"), *wide);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!_pendingMessages.IsEmpty())
|
// Set a single callback in the main thread per frame.
|
||||||
|
if(wasEmpty && !_pendingMessages.IsEmpty())
|
||||||
{
|
{
|
||||||
FSimpleDelegateGraphTask::CreateAndDispatchWhenReady(
|
FSimpleDelegateGraphTask::CreateAndDispatchWhenReady(
|
||||||
FSimpleDelegateGraphTask::FDelegate::CreateUObject(this, &UOscDispatcher::CallbackMainThread),
|
FSimpleDelegateGraphTask::FDelegate::CreateUObject(this, &UOscDispatcher::CallbackMainThread),
|
||||||
|
|||||||
Reference in New Issue
Block a user