Skip to content

Commit 2a80471

Browse files
committed
Add timestamp memory to DataBuffer
1 parent 2f3cd26 commit 2a80471

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

Source/Processors/DataThreads/DataBuffer.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ DataBuffer::DataBuffer (int chans, int size)
3030
{
3131
timestampBuffer.malloc (size);
3232
eventCodeBuffer.malloc (size);
33+
34+
lastTimestamp = 0;
3335
}
3436

3537

@@ -40,6 +42,7 @@ void DataBuffer::clear()
4042
{
4143
buffer.clear();
4244
abstractFifo.reset();
45+
lastTimestamp = 0;
4346
}
4447

4548

@@ -50,6 +53,8 @@ void DataBuffer::resize (int chans, int size)
5053
timestampBuffer.malloc (size);
5154
eventCodeBuffer.malloc (size);
5255

56+
lastTimestamp = 0;
57+
5358
numChans = chans;
5459
}
5560

@@ -65,6 +70,9 @@ int DataBuffer::addToBuffer (float* data, int64* timestamps, uint64* eventCodes,
6570
int idx = 0;
6671
int blkIdx;
6772

73+
if (numItems > 0)
74+
lastTimestamp = timestamps[numItems-1];
75+
6876
for (int i = 0; bs[i] != 0; ++i)
6977
{ // for each of the dest blocks we can write to...
7078
blkIdx = 0;
@@ -89,6 +97,8 @@ int DataBuffer::addToBuffer (float* data, int64* timestamps, uint64* eventCodes,
8997
}
9098
}
9199

100+
101+
92102
// finish write
93103
abstractFifo.finishedWrite (idx);
94104

@@ -133,7 +143,7 @@ int DataBuffer::readAllFromBuffer (AudioSampleBuffer& data, uint64* timestamp, u
133143
}
134144
else
135145
{
136-
memcpy (timestamp, timestampBuffer + startIndex2, 8);
146+
memcpy(timestamp, &lastTimestamp, 8);
137147
}
138148

139149
if (blockSize2 > 0)

0 commit comments

Comments
 (0)