2019-04-23 16:45:02 -05:00
|
|
|
/**
|
|
|
|
|
* @file
|
Audio: New device name lookup
- A new AudioDevices class replaces the AudioDeviceInfo struct.
It has a single method, getNames(), which:
* creates an AudioDeviceManager (NOT using the singleton)
* scans for available devices
* returns the results as a std::vector containing
std::pair<std::string, std::string> objects
(The AudioDevices device manager is never initialize()d, so
no devices are opened; it should be safe to use even DURING
playback, without disruption.)
By using STL containers (rather than a custom struct) to return
the results, Python is able to consume the output as a native
list of tuples.
AudioDeviceInfo is still present for compatibility, but deprecated.
- Eliminated some unnecessary conversions (like):
* calls to std::string::c_str, when passing to juce::String.
juce::String accepts std::string directly.
* calls to juce::String::toRawUTF8, when creating std::string.
There's a juce::String::ToStdString, which is better.
2021-08-24 13:03:46 -04:00
|
|
|
* @brief Utility methods for identifying audio devices
|
2019-04-23 16:45:02 -05:00
|
|
|
* @author Jonathan Thomas <jonathan@openshot.org>
|
Audio: New device name lookup
- A new AudioDevices class replaces the AudioDeviceInfo struct.
It has a single method, getNames(), which:
* creates an AudioDeviceManager (NOT using the singleton)
* scans for available devices
* returns the results as a std::vector containing
std::pair<std::string, std::string> objects
(The AudioDevices device manager is never initialize()d, so
no devices are opened; it should be safe to use even DURING
playback, without disruption.)
By using STL containers (rather than a custom struct) to return
the results, Python is able to consume the output as a native
list of tuples.
AudioDeviceInfo is still present for compatibility, but deprecated.
- Eliminated some unnecessary conversions (like):
* calls to std::string::c_str, when passing to juce::String.
juce::String accepts std::string directly.
* calls to juce::String::toRawUTF8, when creating std::string.
There's a juce::String::ToStdString, which is better.
2021-08-24 13:03:46 -04:00
|
|
|
* @author FeRD (Frank Dana) <ferdnyc@gmail.com>
|
2019-04-23 16:45:02 -05:00
|
|
|
*
|
2019-06-09 08:31:04 -04:00
|
|
|
* @ref License
|
|
|
|
|
*/
|
|
|
|
|
|
2021-12-02 22:10:08 -06:00
|
|
|
// Copyright (c) 2008-2019 OpenShot Studios, LLC
|
|
|
|
|
//
|
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
2019-04-23 16:45:02 -05:00
|
|
|
|
Audio: New device name lookup
- A new AudioDevices class replaces the AudioDeviceInfo struct.
It has a single method, getNames(), which:
* creates an AudioDeviceManager (NOT using the singleton)
* scans for available devices
* returns the results as a std::vector containing
std::pair<std::string, std::string> objects
(The AudioDevices device manager is never initialize()d, so
no devices are opened; it should be safe to use even DURING
playback, without disruption.)
By using STL containers (rather than a custom struct) to return
the results, Python is able to consume the output as a native
list of tuples.
AudioDeviceInfo is still present for compatibility, but deprecated.
- Eliminated some unnecessary conversions (like):
* calls to std::string::c_str, when passing to juce::String.
juce::String accepts std::string directly.
* calls to juce::String::toRawUTF8, when creating std::string.
There's a juce::String::ToStdString, which is better.
2021-08-24 13:03:46 -04:00
|
|
|
#include "AudioDevices.h"
|
2019-04-23 16:45:02 -05:00
|
|
|
|
Audio: New device name lookup
- A new AudioDevices class replaces the AudioDeviceInfo struct.
It has a single method, getNames(), which:
* creates an AudioDeviceManager (NOT using the singleton)
* scans for available devices
* returns the results as a std::vector containing
std::pair<std::string, std::string> objects
(The AudioDevices device manager is never initialize()d, so
no devices are opened; it should be safe to use even DURING
playback, without disruption.)
By using STL containers (rather than a custom struct) to return
the results, Python is able to consume the output as a native
list of tuples.
AudioDeviceInfo is still present for compatibility, but deprecated.
- Eliminated some unnecessary conversions (like):
* calls to std::string::c_str, when passing to juce::String.
juce::String accepts std::string directly.
* calls to juce::String::toRawUTF8, when creating std::string.
There's a juce::String::ToStdString, which is better.
2021-08-24 13:03:46 -04:00
|
|
|
using namespace openshot;
|
|
|
|
|
|
|
|
|
|
using AudioDeviceList = std::vector<std::pair<std::string, std::string>>;
|
|
|
|
|
|
|
|
|
|
// Build a list of devices found, and return
|
|
|
|
|
AudioDeviceList AudioDevices::getNames() {
|
|
|
|
|
// A temporary device manager, used to scan device names.
|
|
|
|
|
// Its initialize() is never called, and devices are not opened.
|
|
|
|
|
std::unique_ptr<juce::AudioDeviceManager>
|
|
|
|
|
manager(new juce::AudioDeviceManager());
|
|
|
|
|
|
|
|
|
|
m_devices.clear();
|
|
|
|
|
|
|
|
|
|
auto &types = manager->getAvailableDeviceTypes();
|
|
|
|
|
for (auto* t : types) {
|
|
|
|
|
t->scanForDevices();
|
Refactoring Audio Device detection (don't crash on Windows, find actual sample rate and device details) (#883)
* Close down ZMQ context to stop the zmq threads (related to sentry bug: OPENSHOT-3X)
* Add Support for Windows 7/8.1 (#881)
Adding protection around getting current sample rate for win 7, if audio device not found. Also added mutex for Singleton method. Also, making whitespace consistent on AudioPlaybackThread.cpp
* Big refactor of audio device opening - with multiple sample rates attempted, for better recovery from a missing or unsupported sample rate. Debug logs added for testing.
* Additional failure logging for windows audio device init
* Refactor of Audio Device Initialization (#882)
* Huge refactor of audio device initialization:
- Attempt requested audio device first, and then iterate through all known audio types and devices, and common sample rates. The idea is to ignore an invalid default or invalid requested device, and keep looking until we find a valid one
- New public method to return active, open audio device
- Added methods for AudioDeviceInfo struct, to make it callable from Python
- Some code clean-up and whitespace fixes
- New unit tests for AudioDeviceManagerSingleton
* Ignore audio device unit tests on systems with "No Driver" returned in the audio error message
* Ignore audio device unit tests if any error is found during initialization (i.e. build servers don't have audio cards)
* Trying to update GitHub libomp errors during build checks
* Remove zmq context shutdown call, due to the method missing on newer versions of zmq.hpp
* Downgrading GitHub Ubuntu latest image to Ubuntu 20.04, for compatibility with Catchv2
* Initialize all audio device manager variables correctly, and ignore unit test on low or missing sample rate systems (i.e. GitHub build servers)
2022-12-19 13:15:43 -06:00
|
|
|
const auto names = t->getDeviceNames();
|
Audio: New device name lookup
- A new AudioDevices class replaces the AudioDeviceInfo struct.
It has a single method, getNames(), which:
* creates an AudioDeviceManager (NOT using the singleton)
* scans for available devices
* returns the results as a std::vector containing
std::pair<std::string, std::string> objects
(The AudioDevices device manager is never initialize()d, so
no devices are opened; it should be safe to use even DURING
playback, without disruption.)
By using STL containers (rather than a custom struct) to return
the results, Python is able to consume the output as a native
list of tuples.
AudioDeviceInfo is still present for compatibility, but deprecated.
- Eliminated some unnecessary conversions (like):
* calls to std::string::c_str, when passing to juce::String.
juce::String accepts std::string directly.
* calls to juce::String::toRawUTF8, when creating std::string.
There's a juce::String::ToStdString, which is better.
2021-08-24 13:03:46 -04:00
|
|
|
for (const auto& name : names) {
|
|
|
|
|
m_devices.emplace_back(
|
|
|
|
|
name.toStdString(), t->getTypeName().toStdString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return m_devices;
|
2019-08-05 02:12:44 -04:00
|
|
|
}
|