Play a file with Audio Queue

Source code

  1. QueuePlay.zip
  2. main.m
  3. Class QueuePlayAppDelegate
  4. Class View

Create the project

Take the file musette.mp3 from the switch project and add it to this project. Put it in the project’s folder,

Project → Add to Project…
Add
Add

Add the AudioToolbox framework to the project.

Project → Edit Active Target “QueuePlay” → General → Linked Libraries
Press + to add AudioToolbox.framework.
Add

AudioTimeStamp stamp;
		status = AudioQueueEnqueueBufferWithParameters(
			p->queue,
			buffer,
			p->description == NULL ? 0 : numPackets,
			p->description,
			0,
			0,
			0, NULL,
			NULL, &stamp
		);

		if (stamp.mFlags & kAudioTimeStampSampleTimeValid) {
			NSLog(@"stamp.mSampleTime / 21888 == %f",
				  stamp.mSampleTime / 21888);
		}

		if (stamp.mFlags & kAudioTimeStampHostTimeValid) {
			NSLog(@"stamp.mHostTime == %qu", stamp.mHostTime);
		}