• 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
Bad access with reference within mixer callback
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bad access with reference within mixer callback


  • Subject: Bad access with reference within mixer callback
  • From: Espen Kluge <email@hidden>
  • Date: Sun, 12 Feb 2012 22:27:30 +0000

What I'm trying to do, is to update my display based on variable in the callback.
Why do i get bad access with this code,I see its done on other types of callbacks.

In other 

static OSStatus inputRenderCallback (

   void                        *inRefCon,      // A pointer to a struct containing the complete audio data
                                               //    to play, as well as state information such as the  
                                               //    first sample to play on this invocation of the callback.
   AudioUnitRenderActionFlags  *ioActionFlags, // Unused here. When generating audio, use ioActionFlags to indicate silence
                                               //    between sounds; for silence, also memset the ioData buffers to 0.
   const AudioTimeStamp        *inTimeStamp,   // Unused here.
   UInt32                      inBusNumber,    // The mixer unit input bus that is requesting some new
                                               //        frames of audio data to play.
   UInt32                      inNumberFrames, // The number of frames of audio to provide to the buffer(s)
                                               //        pointed to by the ioData parameter.
   AudioBufferList             *ioData         // On output, the audio data to play. The callback's primary
                                               //        responsibility is to fill the buffer(s) in the
                                               //        AudioBufferList.
) {
   
   MixerHostAudio* THIS = (MixerHostAudio *)inRefCon;

   soundStructPtr    soundStructPointerArray   = (soundStructPtr) inRefCon;
   UInt32            frameTotalForSound        = soundStructPointerArray[inBusNumber].frameCount;
   BOOL              isStereo                  = soundStructPointerArray[inBusNumber].isStereo;

   // Declare variables to point to the audio buffers. Their data type must match the buffer data type.
   AudioUnitSampleType *dataInLeft;
   AudioUnitSampleType *dataInRight;
   
   dataInLeft                 = soundStructPointerArray[inBusNumber].audioDataLeft;
   if (isStereo) dataInRight  = soundStructPointerArray[inBusNumber].audioDataRight;
   
   // Establish pointers to the memory into which the audio from the buffers should go. This reflects
   //    the fact that each Multichannel Mixer unit input bus has two channels, as specified by this app's
   //    graphStreamFormat variable.
   AudioUnitSampleType *outSamplesChannelLeft;
   AudioUnitSampleType *outSamplesChannelRight;
   
   outSamplesChannelLeft                 = (AudioUnitSampleType *) ioData->mBuffers[0].mData;
   if (isStereo) outSamplesChannelRight  = (AudioUnitSampleType *) ioData->mBuffers[1].mData;

   // Get the sample number, as an index into the sound stored in memory,
   //    to start reading data from.
   UInt32 sampleNumber = soundStructPointerArray[inBusNumber].sampleNumber;

   // Fill the buffer or buffers pointed at by *ioData with the requested number of samples
   //    of audio from the sound stored in memory.
   for (UInt32 frameNumber = 0; frameNumber < inNumberFrames; ++frameNumber) {

       outSamplesChannelLeft[frameNumber]                 = dataInLeft[sampleNumber];
       if (isStereo) outSamplesChannelRight[frameNumber]  = dataInRight[sampleNumber];
       
       sampleNumber++;

       // After reaching the end of the sound stored in memory--that is, after
       //    (frameTotalForSound / inNumberFrames) invocations of this callback--loop back to the
       //    start of the sound so playback resumes from there.
       if (sampleNumber >= frameTotalForSound) sampleNumber = 0;
       
       THIS.timeIntoBeat = sampleNumber;  //this is where i get the bad access
   }
   
   // Update the stored sample number so, the next time this callback is invoked, playback resumes
   //    at the correct spot.
   soundStructPointerArray[inBusNumber].sampleNumber = sampleNumber;
   
   return noErr;
}
 _______________________________________________
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

  • Follow-Ups:
    • RE: Bad access with reference within mixer callback
      • From: Hari Karam Singh <email@hidden>
  • Prev by Date: Re: sample data types (iOS)
  • Next by Date: RE: Threading Question
  • Previous by thread: Re: sample data types (iOS)
  • Next by thread: RE: Bad access with reference within mixer callback
  • Index(es):
    • Date
    • Thread