Code Monkey home page Code Monkey logo

Comments (4)

alexbw avatar alexbw commented on July 26, 2024

Pull request, if you please!

On Friday, September 7, 2012 at 7:10 PM, Corey wrote:

If I rapidly start and stop recording, I will very quickly get a memory exception caused by ExtAudioFileWriteAsync().
The error is shown to occur in the assembler for: AudioRingBuffer::GetTimeBounds()
I applied the instructions found here:
http://stackoverflow.com/questions/7961087/exc-bad-access-in-audioringbuffergettimebounds
(wrapping a mutex around each call to ExtAudioFileWriteAsync and ExtAudioFileDispose)
Now I can spam away without it crashing.


Reply to this email directly or view it on GitHub (#35).

from novocaine.

casbreuk avatar casbreuk commented on July 26, 2024

Just committed the change to my existing fork, which is already in a pull request.

from novocaine.

casbreuk avatar casbreuk commented on July 26, 2024

Okay, discovered today that while this works for the simulator, it fails on device.
I'm testing some different approaches right now...

Alright, got this going. It was actually quite simple. Just had to move the pthread_mutex_unlock into the if( pthread_mutex_trylock() ) scope.

- (void)writeNewAudio:(float *)newData numFrames:(UInt32)thisNumFrames numChannels:(UInt32)thisNumChannels
{
    UInt32 numIncomingBytes = thisNumFrames*thisNumChannels*sizeof(float);
    memcpy(self.outputBuffer, newData, numIncomingBytes);

    AudioBufferList outgoingAudio;
    outgoingAudio.mNumberBuffers = 1;
    outgoingAudio.mBuffers[0].mNumberChannels = thisNumChannels;
    outgoingAudio.mBuffers[0].mDataByteSize = numIncomingBytes;
    outgoingAudio.mBuffers[0].mData = self.outputBuffer;


    if( 0 == pthread_mutex_trylock( &outputAudioFileLock ) )
    {
        ExtAudioFileWriteAsync(self.outputFile, thisNumFrames, &outgoingAudio);
        pthread_mutex_unlock( &outputAudioFileLock ); // only unlock if it was successfully locked to begin with // 
    }


    // Figure out where we are in the file
    SInt64 frameOffset = 0;
    ExtAudioFileTell(self.outputFile, &frameOffset);
    self.currentTime = (float)frameOffset / self.samplingRate;

}

from novocaine.

alexbw avatar alexbw commented on July 26, 2024

I believe I've merged this in...

from novocaine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.