drowe67 / freedv-gui

GUI Application for FreeDV – open source digital voice for HF radio
https://freedv.org/
GNU Lesser General Public License v2.1
193 stars 49 forks source link

If a USB audio card is unplugged FreeDV wipes audio settings for that card. #734

Closed barjac closed 1 month ago

barjac commented 2 months ago

I have hit this many times and it is really frustrating and should not happen.

I use an external USB (CM108 based) audio dongle to handle audio to and from my transceiver.

I sometimes use that USB port with extension cable to connect other devices when not using FreeDV.

If I forget to re-connect it to the CM108 device afterwards and start FreeDV, then instead of just warning that the device is missing, FreeDV wipes it from the configuration as well!

Why, when it only needs to remind me to plug in the correct device and re-try?

tmiw commented 1 month ago

Part of what it's supposed to do is to switch the "analog" device(s) to the system's default if they no longer exist (i.e. if your USB headset's unplugged or something). Are you proposing that no configuration changes happen on any of the configured devices at all, or is it only the radio device(s) that shouldn't be touched?

Tyrbiter commented 1 month ago

FWIW I saw a similar problem in WSJTX the other day, I had a mains RCD trip out (due to a failing LED light) which caused the radios to lose power but not the PCs (on a UPS) and as a result I had to restart the PC connected to the radios because the USB connections didn't reinitialise and the USB cables are hard to reach.

I don't think this is anything to do with the WSJTX or freedv applications, it's at a lower level in the OS and USB subsystem.

What do you think @tmiw?

barjac commented 1 month ago

Part of what it's supposed to do is to switch the "analog" device(s) to the system's default if they no longer exist (i.e. if your USB headset's unplugged or something).

That sounds possibly reasonable for fixed devices but not for removable ones that may be only temporarily missing.

Are you proposing that no configuration changes happen on any of the configured devices at all, or is it only the radio device(s) that shouldn't be touched?

I would say that no configuration changes should take place without first asking.

tmiw commented 1 month ago

I don't think this is anything to do with the WSJTX or freedv applications, it's at a lower level in the OS and USB subsystem.

Likely, yes. @barjac's comments are definitely related to FreeDV, though, so we should determine how it should work there.

tmiw commented 1 month ago

Part of what it's supposed to do is to switch the "analog" device(s) to the system's default if they no longer exist (i.e. if your USB headset's unplugged or something).

That sounds possibly reasonable for fixed devices but not for removable ones that may be only temporarily missing.

Any ideas how to determine that? The most common way to trip this scenario would likely be removable devices going away, not someone deciding to upgrade to a new sound card/motherboard or something.

barjac commented 1 month ago

I would expect that if a configured audio device is missing then an error message should warn the user and allow the device to be replaced and the program re-started or re-initialized to correctly find the device listed in the config.

This is something that could be very off-putting to some new users who initially have difficulty configuring the audio devices. To have a good working configuration lost by simply having a USB plug removed could be the last straw for some. :(

Tyrbiter commented 1 month ago

I don't think this is anything to do with the WSJTX or freedv applications, it's at a lower level in the OS and USB subsystem.

Likely, yes. @barjac's comments are definitely related to FreeDV, though, so we should determine how it should work there.

The only reason it didn't happen to me in freedv is because the freedv modem wasn't running whereas WSJTX was decoding WSPR signals when the audio device disappeared from under it. I think it's essentially the same thing happening in both cases.

barjac commented 1 month ago

I suspect that the error to trip this already happens. It only needs to stop updating the config and simply say that the config seems wrong because ' device xyz is missing.

barjac commented 1 month ago

This is the message that appears when a first attempt to start the modem is made with the device removed.

Screenshot_20240715_111201

You can't confirm the setup as it has already been changed at this point and the selected audio device is "none".

Maybe this first dialogue should say "Check that your alsa_input.usb-0d8c_USB_PnP_Sound_Device-00.mono-fallback device is connected" and NOT change the config at this point?

Subsequent attempts to use the modem (ignoring the first message) produces:

Screenshot_20240715_105556

barjac commented 1 month ago

Ah!! I just discovered that if the first message is left on the screen while the device is re-inserted and then the dialogue closed with the X rather than OK, the modem can be re-started.

So possibly a little re-wording of the message may be needed along with an extra button.

Config appears to only be changed on hitting the 'OK button' to go to the audio setup. If there was another button to close the dialogue - maybe "Close" with the text changed to something like: "..... Please check that this audio device is correctly connected and hit "Close" or to go to the configuration screen hit "Configuration".

I still think though that the "Configuration" (old OK button) should not change the config, although with the above change it would not be so critical.

Tyrbiter commented 1 month ago

Ah!! I just discovered that if the first message is left on the screen while the device is re-inserted and then the dialogue closed with the X rather than OK, the modem can be re-started.

A message like "Re-insert the missing device before clicking OK to continue normally" could be added. Or maybe add a Retry button for this purpose.

barjac commented 1 month ago

Ah!! I just discovered that if the first message is left on the screen while the device is re-inserted and then the dialogue closed with the X rather than OK, the modem can be re-started.

A message like "Re-insert the missing device before clicking OK to continue normally" could be added. Or maybe add a Retry button for this purpose.

We doubled!! I was editing my above message during lunch and only saw your comment when I updated it. We are on the same page I think :)

tmiw commented 1 month ago

See https://github.com/drowe67/freedv-gui/pull/735. Does that message work for you guys?