Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > Mac OS X Development Forums > Mac OS X Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-21-2010, 07:48 AM   #1 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 4
allb4u is on a distinguished road
Default AudioQueueAllocateBuffer no allocation

Hi

I'm trying to use the Audio Queue API to play out linear PCM audio received over the net.

I create an audio queue and then try to allocate the first buffer. The allocation call returns OK but the buffer data space isn't allocated.

Can anyone see what I'm doing wrong?

Code:
aQState->bufferSize = 4800;

AudioStreamBasicDescription* desc = &aQState->audioDataFormat;
desc->mSampleRate = 48000;
desc->mFormatID = kAudioFormatLinearPCM;
desc->mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
desc->mBytesPerPacket = 2;
desc->mFramesPerPacket = 1;
desc->mBytesPerFrame = 2;
desc->mChannelsPerFrame = 1;
desc->mBitsPerChannel = 16;
	
OSStatus result = AudioQueueNewOutput( &aQState->audioDataFormat, 
                               audioPlayCallBack, 
                               &aQState,
                               NULL,
                               kCFRunLoopCommonModes,
                               0,
                               &aQState->audioQueue );
//result is 0 OK so far	
	
for (int i =0; i < numAudioBuffers; i++) {
		
  result = AudioQueueAllocateBuffer( aQState->audioQueue, 
                               aQState->bufferSize, 
                               &aQState->audioBuffers[i] );			
  // again result 0 OK
		
  AudioQueueBufferRef thisBuf = aQState->audioBuffers[1];
		
  /* problem is here thisBuf->mAudioData is 0 so no data space 
      has been allocated*/
 }
allb4u is offline   Reply With Quote
Old 10-22-2010, 05:15 AM   #2 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 4
allb4u is on a distinguished road
Default Spotted the error myself

Hi

My mistake. Was checking audioBuffers[1] not audioBuffers[i] which wouldn't have worked on the first run of my loop.

Thanks

Quote:
Originally Posted by allb4u View Post
Hi

I'm trying to use the Audio Queue API to play out linear PCM audio received over the net.

I create an audio queue and then try to allocate the first buffer. The allocation call returns OK but the buffer data space isn't allocated.

Can anyone see what I'm doing wrong?

Code:
aQState->bufferSize = 4800;

AudioStreamBasicDescription* desc = &aQState->audioDataFormat;
desc->mSampleRate = 48000;
desc->mFormatID = kAudioFormatLinearPCM;
desc->mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
desc->mBytesPerPacket = 2;
desc->mFramesPerPacket = 1;
desc->mBytesPerFrame = 2;
desc->mChannelsPerFrame = 1;
desc->mBitsPerChannel = 16;
	
OSStatus result = AudioQueueNewOutput( &aQState->audioDataFormat, 
                               audioPlayCallBack, 
                               &aQState,
                               NULL,
                               kCFRunLoopCommonModes,
                               0,
                               &aQState->audioQueue );
//result is 0 OK so far	
	
for (int i =0; i < numAudioBuffers; i++) {
		
  result = AudioQueueAllocateBuffer( aQState->audioQueue, 
                               aQState->bufferSize, 
                               &aQState->audioBuffers[i] );			
  // again result 0 OK
		
  AudioQueueBufferRef thisBuf = aQState->audioBuffers[1];
		
  /* problem is here thisBuf->mAudioData is 0 so no data space 
      has been allocated*/
 }
allb4u is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 460
17 members and 443 guests
alexeir, David-T, Dj_kades, foslock, iAppDeveloper, ilmman, j.b.rajesh@gmail.com, jeroenkeij, mer10, mkjarred, myach, pipposanta, QuantumDoja, robsmy, sacha1996, SLIC, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,129
Posts: 402,928
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:31 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0