调用AUGraphStart进行播放时接收kAUGraphErr_CannotDoInCurrentContext [英] Receiving kAUGraphErr_CannotDoInCurrentContext when calling AUGraphStart for playback

查看:348
本文介绍了调用AUGraphStart进行播放时接收kAUGraphErr_CannotDoInCurrentContext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AUGraph和Audio Units API在我的iOS应用中播放和录制音频.现在,当AUGraph无法启动并出现以下错误时,我遇到一个罕见的问题:

I'm working with AUGraph and Audio Units API to playback and record audio in my iOS app. Now I have a rare issue when an AUGraph is unable to start with the following error:

result = kAUGraphErr_CannotDoInCurrentContext(-10863)

result = kAUGraphErr_CannotDoInCurrentContext (-10863)

当我们尝试调用为音频播放设置的AUGraphStart时,意外发生了错误:

The error occurred unpredictably when we try to call AUGraphStart which is set up for audio playback:

(BOOL)startRendering
{
    if (playing) {
        return YES;
    }

    playing = YES;

    if (NO == [self setupAudioForGraph:&au_play_graph playout:YES]) {
        print_error("Failed to create play AUGraph",0);
        playing = NO;
        return NO;
    }

    //result = kAUGraphErr_CannotDoInCurrentContext (-10863)
    OSStatus result = AUGraphStart(au_play_graph);
    if (noErr != result) {
        print_error("AUGraphStart", result);
        playing = NO;
    }

    return playing;
}

这是我们从文档中获得的信息:

Here what we get from the documentation:

为避免旋转或等待渲染线程(一个坏主意!),许多 对AUGraph的调用可以返回: kAUGraphErr_CannotDoInCurrentContext.仅产生此结果 当您从其渲染回调调用AUGraph API时. 这意味着 当时所需的锁是由另一个线程持有的.如果 您看到此结果代码后,通常可以再次尝试执行操作- 通常是NEXT渲染周期(因此与此同时,锁定可以是 清除),或者您可以将该调用委派给您应用中的另一个线程. 您不应该旋转或休眠渲染线程.

To avoid spinning or waiting in the render thread (a bad idea!), many of the calls to AUGraph can return: kAUGraphErr_CannotDoInCurrentContext. This result is only generated when you call an AUGraph API from its render callback. It means that the lock that it required was held at that time, by another thread. If you see this result code, you can generally attempt the action again - typically the NEXT render cycle (so in the meantime the lock can be cleared), or you can delegate that call to another thread in your app. You should not spin or put-to-sleep the render thread.

此结果代码只是一个暂时状态,它将很快通过 当其他线程对AUGraph(具有锁)的调用完成时.

This result code is only a transitory state, which will pass as soon as your other thread's call to AUGraph (that has the lock) completes.

就我而言,我只是启动AUGraph,它是新创建的. 我该如何调试情况,这里可能存在什么问题?

In my case, I just start the AUGraph, it's new and just created. How can I debug the case and what could be the potential issue here?

推荐答案

您可以使用CSS或SQLite制作东西.这就是为什么

You can make something out of CSS or SQLite. This is why

OSStatus result = AUGraphStart(au_play_graph);
if (noErr != result) {
    print_error("AUGraphStart", result);
    playing = NO;
}

return playing;

}

尝试仅操作此代码,代码中的布尔值有问题...

Try to just manipulate this code, there is a problem with Booleans in your code...

这篇关于调用AUGraphStart进行播放时接收kAUGraphErr_CannotDoInCurrentContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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