• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: AVAssetReader and Audio Queue streaming problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AVAssetReader and Audio Queue streaming problem


  • Subject: Re: AVAssetReader and Audio Queue streaming problem
  • From: Aran Mulholland <email@hidden>
  • Date: Sat, 22 Jan 2011 21:07:37 +1100

Nick Collinsky has a working example here

http://www.cogs.susx.ac.uk/users/nc81/code.html

called MusicLibraryRemoteIODemo.zip 

On Sat, Jan 22, 2011 at 10:28 AM, Samuel Kitono <email@hidden> wrote:
Hi Everyone,

I have a problem with the AVAssetReader here to get samples from the iPod library and stream it via Audio Queue. I have not been able to find any such example so I try to implement my own but it seems that somehow the AssetReader is "screwed up" at the callback function of audio queue. Specifically it fails when it does the copyNextSampleBuffer ie it returns null when it is not finished yet. I have made sure the pointer exists and such so it will be great if anyone can help.

Below is the callback function code that I have used. This callback function 'works' when it is not called by the AudioQueue callback.

        static void HandleOutputBuffer (
            void                *playerStateH,
            AudioQueueRef       inAQ,
            AudioQueueBufferRef inBuffer
            ) {
   
     AQPlayerState *pplayerState = (AQPlayerState *) playerStateH;
     //if (pplayerState->mIsRunning == 0) return;   
    
    
    
     UInt32 bytesToRead = pplayerState->bufferByteSize;
     [[NSNotificationCenter defaultCenter] postNotificationName:NOTIF_callsample object:nil];
     
   
     float * inData =(float *) inBuffer->mAudioData;
     int offsetSample = 0;
     //Loop until finish reading from the music data
     while (bytesToRead) {
    
      /*THIS IS THE PROBLEMATIC LINE*/
      CMSampleBufferRef sampBuffer = [pplayerState->assetWrapper getNextSampleBuffer]; //the assetreader getting nextsample with copyNextSampleBuffer
     
      if (sampBuffer == nil) {
       NSLog(@"No more data to read from");
     //  NSLog(@"aro status after null %d",[pplayerState->ar status]);
       AudioQueueStop (
           pplayerState->mQueue,
           false
           );
       pplayerState->mIsRunning = NO;
      
       return;
      }

      AudioBufferList  audioBufferList;
      CMBlockBufferRef blockBuffer;
      CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(sampBuffer, NULL, &audioBufferList, sizeof(audioBufferList), NULL, NULL, 0, &blockBuffer);
      AudioBuffer audioBuffer = audioBufferList.mBuffers[0];
      memcpy(inData + (2*offsetSample),audioBuffer.mData,audioBuffer.mDataByteSize);
      bytesToRead = bytesToRead - audioBuffer.mDataByteSize;
      offsetSample = offsetSample + audioBuffer.mDataByteSize/8;
    
     
     
     }
     inBuffer->mAudioDataByteSize = offsetSample*8;
    
     AudioQueueEnqueueBuffer (
            pplayerState->mQueue,
            inBuffer,
            0,
            0
            );
    
    
    }

Thanks in advance for any assistance.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >AVAssetReader and Audio Queue streaming problem (From: Samuel Kitono <email@hidden>)

  • Prev by Date: Re: Fw: Question about compiling the SampleUSBAudioPlugin
  • Next by Date: Re: kExtAudioFileError_AsyncWriteBufferOverflow on iPad
  • Previous by thread: AVAssetReader and Audio Queue streaming problem
  • Next by thread: 2 small questions...
  • Index(es):
    • Date
    • Thread