社区问答

欢迎来到 Audiokinetic 社区问答论坛。在此,Wwise 和 Strata 用户可互帮互助。如需我们团队直接提供协助,请前往技术支持申请单页面。若要报告问题,请在 Audiokinetic Launcher 中选择“报告错误”选项(注意,问答论坛并不会接收错误报告)。我们内部设有专门的错误报告系统,会有专人查看报告并设法解决问题。

要想尽快得到满意的解答,请在提问时注意以下几点:

  • 描述尽量具体:比如,想达到什么样的目的,或者具体哪里有问题。
  • 包含关键细节:比如,Wwise 和游戏引擎版本以及所用操作系统等等。
  • 阐明所做努力:阐明自己为了排除故障都采取了哪些措施。
  • 聚焦问题本身:聚焦于问题本身的相关技术细节,以便别人可以快速找到解决方案。

+1 投票
I always get AK_NotInitialized when call GetSourcePlayPosition after upgrading to Wwise 2022.1.3.

Is it a known issue? Thanks.
分类:General Discussion | 用户: Edward C. (140 分)
修改于 用户:Edward C.

1个回答

0 投票

Not work in 2022.1.3-2022.1.6
I guess it is caused by the inconsistency of SoundEngine。AK::SoundEngine is not instanced, So,return AK_NotInitialized.
But, can do as this:

//used by Cpp/Blueprint

int32 UAkGameplayStatics::GetSourcePlayPosition(UAkAudioEvent* AkEvent, int32 PlayingID)
{
    if (AkEvent) {
        return AkEvent->GetSourcePlayPosition(PlayingID);
    }
    return -1;
}

//expand UAkAudioEvent

int32 UAkAudioEvent::GetSourcePlayPosition(int32 PlayingID)
{
    SCOPED_AKAUDIO_EVENT_2(TEXT("UAkAudioEvent::PostEvent"));
    auto* AudioDevice = FAkAudioDevice::Get();
    if (UNLIKELY(!AudioDevice))
    {
        UE_LOG(LogAkAudio, Verbose, TEXT("Failed to post AkAudioEvent '%s' without an Audio Device."), *GetName());
        return AK_INVALID_PLAYING_ID;
    }

    if (UNLIKELY(!AudioDevice->IsInitialized()))
    {
        UE_LOG(LogAkAudio, Verbose, TEXT("Failed to post AkAudioEvent '%s' with the Sound Engine uninitialized."), *GetName());
        return AK_INVALID_PLAYING_ID;
    }

    auto* SoundEngine = IWwiseSoundEngineAPI::Get();
    if (UNLIKELY(!SoundEngine))
    {
        UE_LOG(LogAkAudio, Warning, TEXT("Failed to post AkAudioEvent '%s' without a Sound Engine."), *GetName());
        return AK_INVALID_PLAYING_ID;
    }

    auto* ExternalSourceManager = IWwiseExternalSourceManager::Get();
    if (UNLIKELY(!ExternalSourceManager))
    {
        UE_LOG(LogAkAudio, Warning, TEXT("Failed to post AkAudioEvent '%s' without the External Source Manager."), *GetName());
        return AK_INVALID_PLAYING_ID;
    }

    AkTimeMs CurrentPosition = 0;
    auto Result = SoundEngine->GetSourcePlayPosition(PlayingID, &CurrentPosition);
    if (Result == AK_Success)
    {
        return CurrentPosition;
    }
    else
    {
        GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Red, TEXT("GetSourcePlayPosition FAILED!"), false);
        return -1;
    }
}

用户: Sico Y. (160 分)
...