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?
Did you enable background recording using the appropriate value under your app's info.plist "Required background modes" key?