Community Q&A

Welcome to Audiokinetic’s community-driven Q&A forum. This is the place where Wwise and Strata users help each other out. For direct help from our team, please use the Support Tickets page. To report a bug, use the Bug Report option in the Audiokinetic Launcher. (Note that Bug Reports submitted to the Q&A forum will be rejected. Using our dedicated Bug Report system ensures your report is seen by the right people and has the best chance of being fixed.)

To get the best answers quickly, follow these tips when posting a question:

  • Be Specific: What are you trying to achieve, or what specific issue are you running into?
  • Include Key Details: Include details like your Wwise and game engine versions, operating system, etc.
  • Explain What You've Tried: Let others know what troubleshooting steps you've already taken.
  • Focus on the Facts: Describe the technical facts of your issue. Focusing on the problem helps others find a solution quickly.

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

Is it a known issue? Thanks.
in General Discussion by Edward C. (140 points)
edited by Edward C.

1 Answer

0 votes

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;
    }
}

by Sico Y. (160 points)
...