OpenShot / libopenshot-audio

OpenShot Audio Library (libopenshot-audio) is a free, open-source project that enables high-quality editing and playback of audio, and is based on the amazing JUCE library.
http://www.openshot.org
GNU General Public License v3.0
251 stars 98 forks source link

Demo app: Fix Windows device detection #132

Closed ferdnyc closed 2 years ago

ferdnyc commented 3 years ago

Since the test app is built as a MinGW console app, it won't detect any Windows audio devices. But it will still try, and JUCE normally makes those the default device type, meaning it won't automatically find a default device. To avoid this, we subclass the AudioDeviceManager class and override its createAudioDeviceTypes() method, avoiding any WASAPI probing at all.

The test app is also enhanced to show the current default device (if one is detected), and to display some parameters about it. Sample output on Linux:

build/src/openshot-audio-demo 
Initialising audio playback device.
Audio device probe results:
Type ALSA:
  - Default ALSA Output (currently PulseAudio Sound Server)
  - PulseAudio Sound Server
  - Default Audio Device
  - PipeWire Sound Server
  - USB Audio Device, USB Audio; Front output / input
  - USB Audio Device, USB Audio; 2.1 Surround output to Front and Subwoofer speakers
  - USB Audio Device, USB Audio; 4.0 Surround output to Front and Rear speakers
  - USB Audio Device, USB Audio; 4.1 Surround output to Front, Rear and Subwoofer speakers
  - USB Audio Device, USB Audio; 5.0 Surround output to Front, Center and Rear speakers
  - USB Audio Device, USB Audio; 5.1 Surround output to Front, Center, Rear and Subwoofer speakers
  - USB Audio Device, USB Audio; 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
  - USB Audio Device, USB Audio; IEC958 (S/PDIF) Digital Audio Output
  - USB Audio Device, USB Audio #1; IEC958 (S/PDIF) Digital Audio Output
  - HDA Intel PCH, ALC662 rev1 Analog; Front output / input
  - HDA Intel PCH, ALC662 rev1 Analog; 2.1 Surround output to Front and Subwoofer speakers
  - HDA Intel PCH, ALC662 rev1 Analog; 4.0 Surround output to Front and Rear speakers
  - HDA Intel PCH, ALC662 rev1 Analog; 4.1 Surround output to Front, Rear and Subwoofer speakers
  - HDA Intel PCH, ALC662 rev1 Analog; 5.0 Surround output to Front, Center and Rear speakers
  - HDA Intel PCH, ALC662 rev1 Analog; 5.1 Surround output to Front, Center, Rear and Subwoofer speakers
  - HDA Intel PCH, ALC662 rev1 Analog; 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
  - HDA NVidia, HDMI 0; HDMI Audio Output
  - HDA NVidia, HDMI 1; HDMI Audio Output
  - HDA NVidia, HDMI 2; HDMI Audio Output
  - HDA NVidia, HDMI 3; HDMI Audio Output
  - HDA NVidia, HDMI 4; HDMI Audio Output
Discovered 25 total audio devices.

Current audio device: ALSA - "Default ALSA Output (currently PulseAudio Sound Server)"
Sample rate: 44100 Hz
Block size: 512 samples
Bit depth: 32

You should hear five test tones, precisely 2 seconds apart.
1... 2... 3... 4... 5.
Demo complete. Shutting down device manager.

Fixes #130

ferdnyc commented 3 years ago

(It's arguably a bug that, absent any other configuration, JUCE sets the default device to the first device from the first available type — not the first device from the first type that contains devices. So, if the first detected device type contains no devices, you're SOL.)

jonoomph commented 2 years ago

LG, merging this also