minor refactor
This commit is contained in:
parent
6df27b8992
commit
001c1b430b
@ -533,11 +533,11 @@ std::vector<std::string> ALAudio::getOutputDeviceNames() {
|
||||
}
|
||||
|
||||
std::unique_ptr<InputDevice> ALAudio::openInputDevice(
|
||||
const char* deviceName, uint sampleRate, uint channels, uint bitsPerSample
|
||||
const std::string& deviceName, uint sampleRate, uint channels, uint bitsPerSample
|
||||
) {
|
||||
uint bps = bitsPerSample >> 3;
|
||||
ALCdevice* device = alcCaptureOpenDevice(
|
||||
deviceName,
|
||||
deviceName.empty() ? nullptr : deviceName.c_str(),
|
||||
sampleRate,
|
||||
AL::to_al_format(channels, bitsPerSample),
|
||||
sampleRate * channels * bps / 8
|
||||
|
||||
@ -181,7 +181,7 @@ namespace audio {
|
||||
) override;
|
||||
|
||||
std::unique_ptr<InputDevice> openInputDevice(
|
||||
const char* deviceName,
|
||||
const std::string& deviceName,
|
||||
uint sampleRate,
|
||||
uint channels,
|
||||
uint bitsPerSample
|
||||
|
||||
@ -77,7 +77,7 @@ namespace audio {
|
||||
) override;
|
||||
|
||||
std::unique_ptr<InputDevice> openInputDevice(
|
||||
const char* deviceName, uint sampleRate, uint channels, uint bitsPerSample
|
||||
const std::string& deviceName, uint sampleRate, uint channels, uint bitsPerSample
|
||||
) override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@ void audio::initialize(bool enabled, AudioSettings& settings) {
|
||||
}, true));
|
||||
}
|
||||
|
||||
input_device = backend->openInputDevice(nullptr, 44100, 1, 16);
|
||||
input_device = backend->openInputDevice("", 44100, 1, 16);
|
||||
if (input_device) {
|
||||
input_device->startCapture();
|
||||
}
|
||||
@ -254,7 +254,7 @@ std::unique_ptr<Stream> audio::open_stream(
|
||||
}
|
||||
|
||||
std::unique_ptr<InputDevice> audio::open_input_device(
|
||||
const char* deviceName, uint sampleRate, uint channels, uint bitsPerSample
|
||||
const std::string& deviceName, uint sampleRate, uint channels, uint bitsPerSample
|
||||
) {
|
||||
return backend->openInputDevice(
|
||||
deviceName, sampleRate, channels, bitsPerSample
|
||||
@ -270,9 +270,7 @@ std::vector<std::string> audio::get_output_devices_names() {
|
||||
}
|
||||
|
||||
void audio::set_input_device(const std::string& deviceName) {
|
||||
auto newDevice = backend->openInputDevice(
|
||||
deviceName.empty() ? nullptr : deviceName.c_str(), 44100, 1, 16
|
||||
);
|
||||
auto newDevice = backend->openInputDevice(deviceName, 44100, 1, 16);
|
||||
if (newDevice == nullptr) {
|
||||
logger.error() << "could not open input device: " << deviceName;
|
||||
return;
|
||||
|
||||
@ -362,7 +362,7 @@ namespace audio {
|
||||
std::shared_ptr<PCMStream> stream, bool keepSource
|
||||
) = 0;
|
||||
virtual std::unique_ptr<InputDevice> openInputDevice(
|
||||
const char* deviceName,
|
||||
const std::string& deviceName,
|
||||
uint sampleRate,
|
||||
uint channels,
|
||||
uint bitsPerSample
|
||||
@ -437,7 +437,7 @@ namespace audio {
|
||||
/// @param bitsPerSample number of bits per sample (8 or 16)
|
||||
/// @return new InputDevice instance or nullptr
|
||||
std::unique_ptr<InputDevice> open_input_device(
|
||||
const char* deviceName,
|
||||
const std::string& deviceName,
|
||||
uint sampleRate,
|
||||
uint channels,
|
||||
uint bitsPerSample
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user