0

I've built an audio recording app (like 'SpeakHere' demo from apple), and I was wondering how can I modify it to work on BACKGROUND.

Every time I enter background, the AudioQueue callback freezes, and I did not receive a single audio byte.

I've seen that the Voice Memos app on the iPhone can record in background.

Here is my callback that does not work in background:

OSStatus AQRecorder::BufferFilled_callback( 
                                       void *                               inUserData,
                                       SInt64                               inPosition,
                                       UInt32                               requestCount,
                                       const void *                         buffer,
                                       UInt32 *                             actualCount) {


    AQRecorder *aqr = (AQRecorder *)inUserData;

    NSLog(@"THIS METHOD IS NOT CALLED ON BACKGROUND");  

    int fd = open(aqr->mWriteFile, O_WRONLY|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
    if (fd) {

    *actualCount = (int)write( fd, buffer, requestCount);
    close(fd);

    [aqr->mi setToread:[aqr->mi toread] + requestCount];

} else {
    perror("Fopen");
}

return 0;

Any thoughts?

Bart
  • 19,692
  • 7
  • 68
  • 77
Lucas
  • 1,135
  • 1
  • 9
  • 20

1 Answers1

0

Did you enable background recording using the appropriate value under your app's info.plist "Required background modes" key?

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
  • awesome! :). I was not aware about the "freezing when enters background". So I found the document that mentions the background modes. Thank you very much. – Lucas Feb 17 '11 at 12:18