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
|
|
|
#include <OpenShotAudio.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();
|
|
|
|
|
const auto names = t->getDeviceNames();
|
|
|
|
|
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
|
|
|
}
|