Note that there are some explanatory texts on larger screens.

plurals
  1. POIntermittent crash in recordingCallback() on app launch
    primarykey
    data
    text
    <p>My iOS app (using openFrameworks) crashes 30-40% of the time on launch on this line:</p> <pre><code> if(soundInputPtr!=NULL) soundInputPtr-&gt;audioIn(tempBuffer, ioData-&gt;mBuffers[i].mDataByteSize/2, 1); </code></pre> <p>which is inside the larger function in <code>ofxiPhoneSoundStream.m</code></p> <pre><code>static OSStatus recordingCallback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) { </code></pre> <p>I am doing audio setup with <code>ofSoundStreamSetup(0, 1, this, 44100, 256, 4);</code> in <code>setup()</code>.</p> <p>In the simulator this crash happens 100% of the time. Any idea (a) what's happening or (b) how to debug it?</p> <p>Update: Stack trace:</p> <pre><code>Thread 11 AURemoteIO::IOThread, Queue : (null) #0 0x00008ff2 in Gameplay::listen() at /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/include/c++/4.2.1/bits/basic_string.h:238 #1 0x003178bc in recordingCallback(void*, unsigned long*, AudioTimeStamp const*, unsigned long, unsigned long, AudioBufferList*) at /Developer/of_007_iphone/libs/openFrameworks/sound/ofxiPhoneSoundStream.mm:143 #2 0x019447e4 in AUIOHelper::NotifyInputAvailable(AudioTimeStamp const&amp;, unsigned long, AudioBufferList const&amp;) () #3 0x0192baf1 in AURemoteIO::PerformIO(unsigned int, unsigned int, XAudioTimeStamp const&amp;, XAudioTimeStamp const&amp;, int&amp;) () #4 0x0192bbc1 in AURIOCallbackReceiver_PerformIO () #5 0x0191b3bf in _XPerformIO () #6 0x01861c11 in mshMIGPerform () #7 0x018e4180 in MSHMIGDispatchMessage () #8 0x019297ba in AURemoteIO::IOThread::Run() () #9 0x0192e8e1 in AURemoteIO::IOThread::Entry(void*) () #10 0x01836972 in CAPThread::Entry(CAPThread*) () #11 0x97bf7259 in _pthread_start () #12 0x97bf70de in thread_start () </code></pre> <p>And then <code>Thread 11 AURemoteIO::IOThread: Program received signal: "EXC_BAD_ACCESS"</code></p> <p>As requested, <code>recordingCallback()</code>:</p> <pre><code>static OSStatus recordingCallback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) { AudioBufferList list; // redundant list.mNumberBuffers = 1; list.mBuffers[0].mData = sampleBuffer; list.mBuffers[0].mDataByteSize = 2 * inNumberFrames; list.mBuffers[0].mNumberChannels = 1; ioData = &amp;list; //printf("No buffers: %d, buffer length: %d bus number: %d\n", ioData-&gt;mNumberBuffers, ioData-&gt;mBuffers[0].mDataByteSize, inBusNumber); // Then: // Obtain recorded samples OSStatus status = AudioUnitRender(audioUnit, ioActionFlags, inTimeStamp, 1, inNumberFrames, ioData); checkStatus(status); if(status!=noErr) return status; if(ioData-&gt;mNumberBuffers&gt;0) { int i = 0; short int *buffer = (short int *) list.mBuffers[i].mData; for(int j = 0; j &lt; ioData-&gt;mBuffers[i].mDataByteSize/2; j++) { // go through each sample and turn it into a float tempBuffer[j] = (float)buffer[j]/32767.f; } done = true; // THIS LINE IS LINE 143 if(soundInputPtr!=NULL) soundInputPtr-&gt;audioIn(tempBuffer, ioData-&gt;mBuffers[i].mDataByteSize/2, 1); } return noErr; } </code></pre> <p>Line 143 marked above, also: <code>if(soundInputPtr!=NULL) soundInputPtr-&gt;audioIn(tempBuffer, ioData-&gt;mBuffers[i].mDataByteSize/2, 1);</code></p> <p><strong>Added:</strong></p> <p><code>Gameplay::listen()</code> is just a max/min tracker-- it used to do more, but I realized those functions were better moved to <code>audioRecieved()</code>. In fact, <em>no</em> other code is calling this function:</p> <pre><code>void Gameplay::listen() { // track extremes for XML purpose if (pitchAvg &gt; move.highestPitch) move.highestPitch = pitchAvg; if ((pitchAvg &lt; move.lowestPitch) &amp;&amp; pitchAvg != 0) move.lowestPitch = pitchAvg; if (ampAvg &gt; move.loudestVol) move.loudestVol = ampAvg; if ((ampAvg &lt; move.softestVol) &amp;&amp; ampAvg &gt; 0.15) move.softestVol = ampAvg; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload