开发者

iPhone dev - AudioQueue Services recording on background

开发者 https://www.devze.com 2023-02-11 05:10 出处:网络
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.

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;

    NSLo开发者_如何学JAVAg(@"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?

0

精彩评论

暂无评论...
验证码 换一张
取 消