MuseScore icon indicating copy to clipboard operation
MuseScore copied to clipboard

[MU4 Issue] When audio open fails, users should be notified in some way other than the logs.

Open 4gboframram opened this issue 2 years ago • 3 comments

Describe the bug When an audio device fails to open, something like 19:41:57.038 | ERROR | main_thread | AudioModule | setupAudioDriver: audio output open failed is written to the log. However, an average user would not know if a critical error like this actually occurred and they would continue to use MuseScore in a malformed state where a lot of weird behavior can happen such as crashes when trying to set the buffer size and playback freezing.

To Reproduce Steps to reproduce the behavior:

  1. Run MuseScore on a machine where audio output open fails
  2. Notice that the error message is logged, but there is no indication of a failure outside of that
  3. Open any score and notice that when pressing play, playback freezes until paused
  4. Go to Edit -> Preferences -> IO and try to set buffer size and notice that MuseScore crashes

Expected behavior The end user should be notified in some way that an error has occurred. Potentially this could be a popup that could prevent further use of the application, but I'm not an expert in user interface.

Screenshots

Current log message: image

An example of just a few of the weird things that can happen when the audio device fails to open, the buffer size being blanked and when changed, the application crashes: image

Platform information

  • OS: Arch Linux
  • Kernel: Linux 6.0.12-zen1-1-zen

Additional context For Linux, I believe the opening seems to fail in a call to alsa's snd_pcm_open in LinuxAudioDriver::open in file src/framework/audio/internal/platform/lin/linuxaudiodriver.cpp line 143 because alsa cannot find a device named "default" on some machines. One cause is bad machine configuration, and MuseScore probably cannot do anything about this.

4gboframram avatar Dec 15 '22 01:12 4gboframram

If anyone that is wondering how to fix the audio open failing, I personally was able to fix it on Linux with the following procedure:

  • Find the desired card with cat /proc/asound/cards
  • Create /etc/asound.conf with following:
   defaults.pcm.card 1
   defaults.ctl.card 1

replacing "1" with number of the desired card you want as default.

I have no idea if this fix works for others, but this is what worked for me

4gboframram avatar Dec 15 '22 01:12 4gboframram

I believe #15182 could be dealt with in a similar way, but it isn't as critical of an error

4gboframram avatar Dec 15 '22 01:12 4gboframram

@4gboframram's fix did not solve the issue for me.

Any ideas on more diagnosis? Can I change the log level to a DEBUG or TRACE level to see more verbose info?

Edit: Looks like the debug level is set during build if I'm reading this line correctly: https://github.com/musescore/MuseScore/blob/5d03be99f7ec7374ae5eaf2b9835a74a737fbcdd/src/framework/global/globalmodule.cpp#L106-L110

AadamZ5 avatar Dec 19 '22 21:12 AadamZ5

If anyone that is wondering how to fix the audio open failing, I personally was able to fix it on Linux with the following procedure:

* Find the desired card with `cat /proc/asound/cards`

* Create  `/etc/asound.conf` with following:
   defaults.pcm.card 1
   defaults.ctl.card 1

replacing "1" with number of the desired card you want as default.

I have no idea if this fix works for others, but this is what worked for me

I had to find another fix for my system (Qubes 4.1 with Fedora), which does not use ALSA at all (no physical sound card), and instead communicates entirely to a remote Pulseaudio: Simply install the the alsa-plugins-pulseaudio package through your package manager.

jmickelin avatar Mar 25 '23 10:03 jmickelin

Yup, I didn't have a default device in aplay -l likely due to a malformed config file. After deleting my config file at /etc/asound.conf and re-creating with the default card I'd like listed, MuseScore successfully initialized the Linux Audio Driver.

It seems like the project has plenty of priority items, but can we propagate driver init return codes somehow? Instead of bool return value, maybe const-like number codes of where driver initialization fails? This would ultimately allow for solving this issue's original intent, notifying the user properly.

It'd be great if we could return const int codes like AUDIO_DEV_OPEN_FAILED or something in the open function. https://github.com/musescore/MuseScore/blob/f31d372fc291a8a384d95f19db25b6e96dba1292/src/framework/audio/internal/platform/lin/linuxaudiodriver.cpp#L133-L195

That would need a change to the IAudioDriver class...

AadamZ5 avatar Mar 29 '23 15:03 AadamZ5