Commits

Anonymous committed e4d2382

Set buffer length to 0 in enqueueFenceBuffer

Comments (0)

Files changed (2)

Source/DDAudioQueue.m

 #import "DDAudioQueueDelegate.h"
 #import "DDAudioQueueBuffer.h"
 
+/*
+ * Play a little trick here. By putting the buffer as the first element in the
+ * structure, assume we can just cast a pointer to a buffer and node and
+ * vice versa.  If padding somehow got in front of buffer, this wouldn't work.
+ */
 typedef struct DDAudioQueueListNode
 {
     DDAudioQueueBuffer buffer;
 
 - (void)enqueueFenceBuffer;
 {
+    DDAudioQueueFenceBuffer->length = 0;
     [self enqueueBuffer:DDAudioQueueFenceBuffer];
 }
 

Tests/DDAudioQueueTest.m

     STAssertEquals([self availableBuffer:1], DDAudioQueueFenceBuffer, nil);
 }
 
+- (void)testEnqueueFenceBufferSetsLenghtToZero
+{
+    DDAudioQueueFenceBuffer->length = 10;
+    
+    [_queue enqueueFenceBuffer];
+    
+    STAssertEquals(DDAudioQueueFenceBuffer->length, (NSUInteger)0, nil);
+}
+
 @end