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