Commits

Anonymous committed 7f009aa

Lots of renames to make things more consistent. Add some comments

Comments (0)

Files changed (8)

Demo/DemoAppDelegate.m

 
 static void processBuffer(DDAudioQueueBuffer * buffer, DDAudioQueue * queue)
 {
-    const void * bytes = DDAudioBufferBytes(buffer);
-    NSUInteger length = DDAudioBufferLength(buffer);
+    const void * bytes = DDAudioQueueBufferGetBytes(buffer);
+    NSUInteger length = DDAudioQueueBufferGetLength(buffer);
     NSLog(@"Processing %u data at %p <0x%08X>", length, bytes, *(uint32_t*)bytes);
 }
 
     DDAudioQueue * queue = self->_audioQueue;
     if (self->_activeBuffer != nil) {
         processBuffer(self->_activeBuffer, queue);
-        DDAudioQueueBufferIsAvailable(queue, self->_activeBuffer);
+        DDAudioQueueMakeBufferAvailable(queue, self->_activeBuffer);
         self->_activeBuffer = nil;
     }
     else {

Source/DDAudioQueue.h

 
 DDAudioQueueBuffer * DDAudioQueueDequeueBuffer(DDAudioQueue * queue);
 
-void DDAudioQueueBufferIsAvailable(DDAudioQueue * queue, DDAudioQueueBuffer * buffer);
+void DDAudioQueueMakeBufferAvailable(DDAudioQueue * queue, DDAudioQueueBuffer * buffer);

Source/DDAudioQueue.m

     return buffer;
 }
 
-void DDAudioQueueBufferIsAvailable(DDAudioQueue * queue, DDAudioQueueBuffer * buffer)
+void DDAudioQueueMakeBufferAvailable(DDAudioQueue * queue, DDAudioQueueBuffer * buffer)
 {
     RAAtomicListInsert(&queue->_availableList, buffer);
     CFRunLoopSourceSignal(queue->_runLoopSource);

Source/DDAudioQueueBuffer.h

 
 @end
 
-const void * DDAudioBufferBytes(DDAudioQueueBuffer * buffer);
-NSUInteger DDAudioBufferLength(DDAudioQueueBuffer * buffer);
+const void * DDAudioQueueBufferGetBytes(DDAudioQueueBuffer * buffer);
+NSUInteger DDAudioQueueBufferGetLength(DDAudioQueueBuffer * buffer);

Source/DDAudioQueueBuffer.m

     _length = length;
 }
 
-const void * DDAudioBufferBytes(DDAudioQueueBuffer * buffer)
+const void * DDAudioQueueBufferGetBytes(DDAudioQueueBuffer * buffer)
 {
     return buffer->_bytes;
 }
 
-NSUInteger DDAudioBufferLength(DDAudioQueueBuffer * buffer)
+NSUInteger DDAudioQueueBufferGetLength(DDAudioQueueBuffer * buffer)
 {
     return buffer->_length;
 }

Source/DDAudioQueueReader.h

 /**
  * Reads bytesToRead bytes into the buffer, dequeing as necessary.  If there
  * is not enough data available, it only copies in the number of bytes
- * read. [Maybe fill in the rest as 0 automatically?]
+ * read.
  *
  * @return The actual number of bytes dequeued and copied into the buffer
  */

Source/DDAudioQueueReader.m

     _readCursor = 0;
 }
 
-UInt32 DDAudioQueueReaderPrimitiveRead(DDAudioQueueReader * reader, void * buffer, UInt32 bytesToRead)
+/**
+ * Reads only from a single reader->_readBuffer.  If reading completes this,
+ * buffer, it gets made available.
+ */
+static UInt32 primitiveRead(DDAudioQueueReader * reader, void * buffer, UInt32 bytesToRead)
 {
     if (reader->_readBuffer == nil) {
         reader->_readBuffer = DDAudioQueueDequeueBuffer(reader->_queue);
         return 0;
     }
     
-    NSUInteger bufferLength = DDAudioBufferLength(reader->_readBuffer);
+    NSUInteger bufferLength = DDAudioQueueBufferGetLength(reader->_readBuffer);
     NSUInteger bytesRemainingInReadBuffer = bufferLength - reader->_readCursor;
     UInt32 bytesToCopy = MIN(bytesToRead, bytesRemainingInReadBuffer);
 
-    const uint8_t * readBufferBytes = DDAudioBufferBytes(reader->_readBuffer);
+    const uint8_t * readBufferBytes = DDAudioQueueBufferGetBytes(reader->_readBuffer);
     readBufferBytes += reader->_readCursor;
     
     memcpy(buffer, readBufferBytes, bytesToCopy);
     
     if (bytesToCopy == bytesRemainingInReadBuffer) {
         NSLog(@"finished with buffer: %p", reader->_readBuffer);
-        DDAudioQueueBufferIsAvailable(reader->_queue, reader->_readBuffer);
+        DDAudioQueueMakeBufferAvailable(reader->_queue, reader->_readBuffer);
         reader->_readBuffer = nil;
     }
     
     while (bytesRead < bytesToRead) {
         UInt32 bytesToReadThisIteration = bytesToRead - bytesRead;
         UInt32 bytesReadThisIteration =
-            DDAudioQueueReaderPrimitiveRead(reader, byteBuffer, bytesToReadThisIteration);
+            primitiveRead(reader, byteBuffer, bytesToReadThisIteration);
         
         if (bytesReadThisIteration == 0) {
             break;

Tests/DDAudioQueueTest.m

 - (void)dequeueAndMakeAvailable
 {
     DDAudioQueueBuffer * buffer = DDAudioQueueDequeueBuffer(_queue);
-    DDAudioQueueBufferIsAvailable(_queue, buffer);
+    DDAudioQueueMakeBufferAvailable(_queue, buffer);
 }
 
 #pragma mark -