Skip to content

Race conditions in various WASAPI audio examples during deinitialization/Stop() functions. #379

@pk1234dva

Description

@pk1234dva

Example, in
https://github.com/microsoft/Windows-classic-samples/blob/main/Samples/ApplicationLoopback/cpp/LoopbackCapture.cpp

HRESULT CLoopbackCapture::OnStopCapture(IMFAsyncResult* pResult)

It seems to me like there's no thread safety. The device state m_DeviceState writes are made without any sort of thread safety. None of the OnStopCapture or OnFinishCapture are happening in any either thread safe manner - they might be writing to things that OnSampleReady doing simultaneously (one simple solution would be to run these OnStop/OnFinish on the same worker queue as OnSampleReady and also make that queue serial.

There's also no real way to tell if it's safe to destroy a CLoopbackCapture object - should we not wait until all the jobs have finished before we allow destruction of a CLoopbackCapture?

I'm not an experienced windows developer so I might be missing something, sorry if that's the case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions