我已经创建了一个音频录制应用程序(就像苹果的'SpeakHere‘演示程序),我想知道如何修改它才能在后台工作。
每次我进入后台时,AudioQueue回调都会冻结,并且我没有收到一个音频字节。
我已经看到iPhone上的语音备忘录应用程序可以在后台录音。
下面是我的后台不起作用的回调:
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;有什么想法吗?
发布于 2011-02-16 07:45:05
您是否使用应用程序的info.plist "Required background modes“键下的相应值启用了后台录制?
https://stackoverflow.com/questions/5010835
复制相似问题