microsoft / microsoft/Windows-classic-samples
Race conditions in various WASAPI audio examples during deinitialization/Stop() functions.
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 5.7k
- Forks
- 3.3k
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Samples/ApplicationLoopback/cpp/LoopbackCapture.cpp, reading OnStopCapture, OnFinishCapture, and OnSampleReady together with the capture object's destruction path. Trace how m_DeviceState and queued work are accessed during Stop and deinitialization. Done means the involved examples have a defined, race-free stop and destruction lifecycle.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- audio-video-rtc, desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100