You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
record_windows: stop() fails with "Catastrophic failure" when the device delivered no audio #636
record 7.1.1, record_windows 2.3.0. The same code path is on main (2.4.0).
Environment
OS: Windows 10 and 11 (builds 19045, 22000, 26200, 26300)
Browser: not applicable
Describe the bug
If stop() runs before the capture device has delivered a single sample, it throws PlatformException(Record, null, Catastrophic failure, null) and isRecording() keeps returning true. We see this in production on more than 25 machines over the last two weeks, always on 5 second takes where the microphone delivered nothing at all.
Stop() cancels a take that has no data, and Cancel() goes through EndRecording(), which calls IMFSinkWriter::Finalize before it discards the file. Finalize returns E_UNEXPECTED (0x8000FFFF) on a WAV sink writer that never got a sample, so Cancel() returns that error and skips the state update. In 2.2.3 the error was hidden because EndRecording() overwrote it with the result of MFShutdown().
To Reproduce
Steps to reproduce the behavior:
Start a recording with the config above on an input device that delivers no audio.
Call stop() before any sample arrives (we call it after 5 seconds).
See PlatformException(Record, null, Catastrophic failure, null), and isRecording() still returns true.
To hit it every time without such a device, call Recorder::Start() and then Recorder::Stop() in the same dispatcher task, so no sample is processed in between. Stop() returns 0x8000FFFF.
Expected behavior
stop() returns null, the empty file is deleted, and the recorder is stopped.
Additional context
On main, EndRecording(true) still calls m_pSink->Finalize() before Discard(), so cancel() and stop() fail the same way there.
Activity
fix(windows): Discard a cancelled take without finalizing it.
fix(windows): Discard a cancelled take without finalizing it.