音频队列启动失败 [英] Audio queue start failed

查看:51
本文介绍了音频队列启动失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个项目,该项目同时具有音频流和播放文件中的音频.对于音频流,我使用AudioStreamer,对于文件播放,我使用avaudioplayer. 只要应用程序不被电话或短信打扰,流媒体和播放都可以完美运行.但是,当我尝试重新启动流式传输而在取消呼叫后有一个呼叫/短信时,出现错误音频队列启动失败". .仅当我至少一次使用过avaudioplayer并在使用过流式传输之后才发生这种情况.当没有创建avaudioplayer对象时,在这种情况下,在取消呼叫后恢复流式传输不会有问题.我的猜测是音频队列有些问题.

I'm developing a project which has both audio streaming and playing audio from file. For audio streaming i'm using AudioStreamer and for playing from file i'm using avaudioplayer. Both streaming and playing works perfectly as long as the app is not interrupted by a phone call or sms. But when a call/sms comes after dismissing the call when i try to restart streaming i'm getting the error "Audio queue start failed" . This happens only when i have used avaudioplayer at least once and after that used streaming. When the avaudioplayer obeject is not created , in this scenario the there is no problem with resuming streaming after dismissing the call. My guess is that some thing is wrong with audioqueue.

非常感谢您的帮助.

我当前正在使用的代码如下

The code that I'm currently using is given below

void interruptionListenerCallback (void *inUserData, UInt32 interruptionState) {
    
    // This callback, being outside the implementation block, needs a reference 
    //to the AudioPlayer object
    AudioStreamer *player = (AudioStreamer *)[streamerArray objectAtIndex:0];
    
    if (interruptionState == kAudioSessionBeginInterruption) {
        NSLog(@"kAudioSessionBeginInterruption 1");
       
            [player pause];
            interruptedOnPlayback = YES;
       
        
    }       else if (interruptionState == kAudioSessionEndInterruption) {
            NSLog(@"kAudioSessionEndInterruption 2");
              AudioSessionSetActive( true );

        
        [player start];
        interruptedOnPlayback = NO;
            
    }
}

正如您所看到的,只要没有创建avaudioplayer对象,它就可以正常使用AudioSessionSetActive(true).仅当我在创建Avaudioplayer对象后使用流光并且应用程序被电话打扰时才会出现问题
或短信,我收到错误音频队列启动失败"?!

as you could see i'm using AudioSessionSetActive(true) it works fine as long as the avaudioplayer object is not created . The problem occurs only when i'm using the streamer after creating the Avaudioplayer object and if the app gets interrupted by a phone call
or sms i get the error Audio queue start failed?!

推荐答案

我遇到了同样的问题,更详细的错误消息是"hwiu"(正在使用的硬件)或1752656245.但是我之前使用的是MPMoviePlayerController启动audioStreamer. 在moviePlayBackDidFinish方法中释放它之前,我只需要停止MPMoviePlayerController([moviePlayer stop])即可. 停止会释放一些硬件组件.

I had the same problem, in more detail the error message was "hwiu" (hardware in use) or 1752656245. But I was using the MPMoviePlayerController before starting the audioStreamer. I only had to stop the MPMoviePlayerController ([moviePlayer stop]) before releasing it in the moviePlayBackDidFinish method. the stop should release some hardware componants.

我希望对您有帮助

这篇关于音频队列启动失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆