stsaz / fmedia

fast audio player/recorder/converter
BSD 2-Clause "Simplified" License
212 stars 20 forks source link

[Windows] Recording is deleted when device is disabled/unplugged #61

Closed unitwobble closed 2 years ago

unitwobble commented 2 years ago

When devices go missing, the program fails catastrophically and deletes all recorded content. The problem is reproducable by disabling the device in the control panel. Would it be possible to make the program write any content that was saved to disk as a default mode of failure (not only for this event but for other errors as well)?

Command line options: fmedia --record --out=$date-$time.opus --opus.bitrate=64 --dev-loopback=2

Sample output: fmedia v1.25 (win-x64) Recording... Source: float32 48000Hz stereo. Press "s" to stop. 0:00 [..........] -40dB / -40dB 00:47:50.533 :3598 [warning] #soundmod.autoconv: 1: conversion format was overwritten by output filters: float32/2/48000 0:23 [..........] -40dB / -12dB 00:48:13.542 :3598 [error] wasapi.out: 2:write(): IAudioClient_GetCurrentPadding: (0x88890004) AUDCLNT_E_DEVICE_INVALIDATED 00:48:13.543 :3598 [error] wasapi.in: *1: read(): IAudioCaptureClient_GetBuffer: (0x88890004) AUDCLNT_E_DEVICE_INVALIDATED

stsaz commented 2 years ago

Hi! Handling AUDCLNT_E_DEVICE_INVALIDATED is in my todo list for quite some time but it never was a priority. Looks like it's time to finally do it, thank you for bringing this up!

stsaz commented 2 years ago

v1.25.1