SACN strips now wrap around to the next universe
This commit is contained in:
parent
d6eabfe3ac
commit
f0f0a48acb
|
@ -344,11 +344,14 @@ SACN_GetUniverseSendAddress(s32 Universe)
|
|||
return V4Address;
|
||||
}
|
||||
|
||||
internal void
|
||||
SACN_FillBufferWithLeds(u8* BufferStart, u32 BufferSize, v2_strip Strip, led_buffer LedBuffer)
|
||||
internal u64
|
||||
SACN_FillBufferWithLeds(u8* BufferStart, u32 BufferSize, v2_strip Strip, u64 LedsPlaced, led_buffer LedBuffer)
|
||||
{
|
||||
u8* DestChannel = BufferStart;
|
||||
for (u32 i = 0; i < Strip.LedCount; i++)
|
||||
u64 FirstLed = LedsPlaced;
|
||||
u64 LedsToAdd = Min(Strip.LedCount - LedsPlaced, STREAM_BODY_SIZE / 3);
|
||||
u64 OnePastLastLed = FirstLed + LedsToAdd;
|
||||
for (u32 i = FirstLed; i < OnePastLastLed; i++)
|
||||
{
|
||||
u32 LedIndex = Strip.LedLUT[i];
|
||||
pixel Color = LedBuffer.Colors[LedIndex];
|
||||
|
@ -358,6 +361,7 @@ SACN_FillBufferWithLeds(u8* BufferStart, u32 BufferSize, v2_strip Strip, led_buf
|
|||
DestChannel[2] = Color.B;
|
||||
DestChannel += 3;
|
||||
}
|
||||
return LedsToAdd;
|
||||
}
|
||||
|
||||
internal void
|
||||
|
@ -367,7 +371,7 @@ SACN_BuildOutputData(streaming_acn* SACN, addressed_data_buffer_list* Output, as
|
|||
|
||||
// TODO(pjs): 512 is a magic number - make it a constant?
|
||||
s32 BufferHeaderSize = STREAM_HEADER_SIZE;
|
||||
s32 BufferBodySize = 512;
|
||||
s32 BufferBodySize = STREAM_BODY_SIZE;
|
||||
s32 BufferSize = BufferHeaderSize + BufferBodySize;
|
||||
|
||||
for (u32 AssemblyIdx = 0; AssemblyIdx < Assemblies.Count; AssemblyIdx++)
|
||||
|
@ -379,14 +383,26 @@ SACN_BuildOutputData(streaming_acn* SACN, addressed_data_buffer_list* Output, as
|
|||
{
|
||||
v2_strip StripAt = Assembly.Strips[StripIdx];
|
||||
|
||||
u32 V4SendAddress = SACN_GetUniverseSendAddress(StripAt.SACNAddr.StartUniverse);
|
||||
// NOTE(PS): This isn't actually invalid, we just haven't needed to implement
|
||||
// something more complex than only allowing strips to start at the first
|
||||
// channel of a universe
|
||||
Assert(StripAt.SACNAddr.StartChannel == 1);
|
||||
|
||||
u32 UniverseAt = StripAt.SACNAddr.StartUniverse;
|
||||
u64 LedsPlaced = 0;
|
||||
while (LedsPlaced < StripAt.LedCount)
|
||||
{
|
||||
u32 V4SendAddress = SACN_GetUniverseSendAddress(UniverseAt);
|
||||
u32 SendPort = DEFAULT_STREAMING_ACN_PORT;
|
||||
|
||||
addressed_data_buffer* Data = AddressedDataBufferList_Push(Output, BufferSize);
|
||||
AddressedDataBuffer_SetNetworkAddress(Data, SACN->SendSocket, V4SendAddress, SendPort);
|
||||
|
||||
SACN_PrepareBufferHeader(StripAt.SACNAddr.StartUniverse, Data->Memory, Data->MemorySize, BufferHeaderSize, *SACN);
|
||||
SACN_FillBufferWithLeds(Data->Memory + BufferHeaderSize, BufferBodySize, StripAt, *LedBuffer);
|
||||
SACN_PrepareBufferHeader(UniverseAt, Data->Memory, Data->MemorySize, BufferHeaderSize, *SACN);
|
||||
LedsPlaced += SACN_FillBufferWithLeds(Data->Memory + BufferHeaderSize, BufferBodySize, StripAt, LedsPlaced, *LedBuffer);
|
||||
|
||||
UniverseAt += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue