none
[UWP][C++] Trouble creating an audio graph. RRS feed

  • Question

  • My code is simple. I translated the C# AudioCreation sample into C++ (just the audio graph init portion)

    void createAudioGraph() { AudioGraphSettings^ settings = ref new AudioGraphSettings(AudioRenderCategory::Media); auto result = create_task(AudioGraph::CreateAsync(settings)).get();

    }

    This code is called from the constructor of a class from an ANGLE sample app.

    When I run the code it breaks on create_task(AudioGraph::CreateAsync ...) with this error

    Unhandled exception at 0x0F2C0A65 (ucrtbased.dll) in AppForOpenGLES1.exe: An invalid parameter was passed to a function that considers invalid parameters fatal.

    Help ! please.


    • Edited by xdaimon Thursday, August 25, 2016 5:41 AM
    Thursday, August 25, 2016 5:41 AM

Answers

  • You called "get" when the task was not yet ready.

    Similarly to C# tasks, you have to wait for it to finish first, before using its results.

    here's some basic stuff about c++ tasks.

    https://msdn.microsoft.com/en-us/library/hh750082.aspx

    • Marked as answer by xdaimon Friday, August 26, 2016 4:38 PM
    Thursday, August 25, 2016 9:35 AM

All replies

  • You called "get" when the task was not yet ready.

    Similarly to C# tasks, you have to wait for it to finish first, before using its results.

    here's some basic stuff about c++ tasks.

    https://msdn.microsoft.com/en-us/library/hh750082.aspx

    • Marked as answer by xdaimon Friday, August 26, 2016 4:38 PM
    Thursday, August 25, 2016 9:35 AM
  • void createAudioGraph()
    {
    	AudioGraphSettings^ settings = ref new AudioGraphSettings(AudioRenderCategory::Media);
    
    	task<CreateAudioGraphResult^> myTask = create_task(AudioGraph::CreateAsync(settings));
    
            myTask.wait();
    
    	auto result = myTask.get();
    
    }
    Still I have the same error at myTask.get()
    Thursday, August 25, 2016 4:13 PM
  • You were right!
    I've misunderstood myTask.wait() and myTask.get()

    My code now uses a create_task().then() type of control flow.

    Friday, August 26, 2016 4:38 PM