failed to call `ActivateAudioInterfaceAsync` , HRESULT: -2147417850

TianpingHsu 26 Reputation points
2022-12-08T05:01:47.013+00:00

Hi, I try to record the system audio by using applicationloopbackaudio-sample, it's ok; Then, I just compile it as a dll (exporting some interfaces) and link it to my GUI(QT) project (multithreading), however, when I call StartCaptureAsyn , I just get the error code: -2147417850 (0x80010106) ((failed in ActivateAudioInterfaceAsync);

Actually, it sometimes works fine, most times not; And if I try to adjust the function call position (say my app initializtion place), it works; if I put it into a callback function (say click a button, call the StartCaptureAsync), it may not work. I don't know why.

I googled, but can't find a solution; May I get some help here? Many thanks.

Windows development | Windows API - Win32
Developer technologies | C++
{count} votes

1 answer

Sort by: Most helpful
  1. Xiaopo Yang - MSFT 12,731 Reputation points Microsoft External Staff
    2022-12-08T08:24:32.12+00:00

    Hello,

    Welcome to Microsoft Q&A!

    RPC_E_CHANGED_MODE indicates A previous call to CoInitializeEx specified the concurrency model for this thread as multithread apartment (MTA). This could also indicate that a change from neutral-threaded apartment to single-threaded apartment has occurred.

    Edit:
    According to ActivateAudioInterfaceAsync ,

    For many implementations, an application must call this function from the main UI thread to activate a COM interface in the WASAPI family so that the system can show a dialog to the user. Except

    • Calling ActivateAudioInterfaceAsync with a deviceInterfacePath that specifies an audio render device and an riid that specifies the IAudioClient interface.
    • Calling ActivateAudioInterfaceAsync with a deviceInterfacePath that specifies an audio render device and an riid that specifies the IAudioEndpointVolume interface.
    • Calling ActivateAudioInterfaceAsync from a session 0 service.

    and

    On versions of Windows previous to Windows 10, ActivateAudioInterfaceAsync must be called on a thread in a COM Single-Threaded Apartment (STA), when opening a device for audio capture.

    Thank you.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.