add device select to audio settings
This commit is contained in:
@@ -79,6 +79,13 @@ ALInputDevice::ALInputDevice(
|
||||
channels(channels),
|
||||
bitsPerSample(bitsPerSample),
|
||||
sampleRate(sampleRate) {
|
||||
const ALCchar* deviceName = alcGetString(device, ALC_CAPTURE_DEVICE_SPECIFIER);
|
||||
|
||||
if (deviceName) {
|
||||
deviceSpecifier = std::string(deviceName);
|
||||
} else {
|
||||
logger.warning() << "could not retrieve input device specifier";
|
||||
}
|
||||
}
|
||||
|
||||
ALInputDevice::~ALInputDevice() {
|
||||
@@ -108,6 +115,10 @@ uint ALInputDevice::getBitsPerSample() const {
|
||||
return bitsPerSample;
|
||||
}
|
||||
|
||||
const std::string& ALInputDevice::getDeviceSpecifier() const {
|
||||
return deviceSpecifier;
|
||||
}
|
||||
|
||||
size_t ALInputDevice::read(char* buffer, size_t bufferSize) {
|
||||
ALCint samplesCount = 0;
|
||||
alcGetIntegerv(device, ALC_CAPTURE_SAMPLES, sizeof(samplesCount), &samplesCount);
|
||||
|
||||
@@ -104,6 +104,7 @@ namespace audio {
|
||||
uint getChannels() const override;
|
||||
uint getSampleRate() const override;
|
||||
uint getBitsPerSample() const override;
|
||||
const std::string& getDeviceSpecifier() const override;
|
||||
|
||||
size_t read(char* buffer, size_t bufferSize) override;
|
||||
private:
|
||||
@@ -112,6 +113,7 @@ namespace audio {
|
||||
uint channels;
|
||||
uint bitsPerSample;
|
||||
uint sampleRate;
|
||||
std::string deviceSpecifier;
|
||||
};
|
||||
|
||||
/// @brief AL source adapter
|
||||
|
||||
@@ -127,7 +127,12 @@ namespace audio {
|
||||
/// @return 8 or 16
|
||||
virtual uint getBitsPerSample() const = 0;
|
||||
|
||||
/// @brief Read available data to buffer.
|
||||
/// @return size of data received or PCMStream::ERROR in case of error
|
||||
virtual size_t read(char* buffer, size_t bufferSize) = 0;
|
||||
|
||||
/// @brief Get device specifier string
|
||||
virtual const std::string& getDeviceSpecifier() const = 0;
|
||||
};
|
||||
|
||||
/// @brief audio::PCMStream is a data source for audio::Stream
|
||||
|
||||
@@ -441,7 +441,9 @@ static int l_audio_get_input_info(lua::State* L) {
|
||||
if (device == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
lua::createtable(L, 0, 3);
|
||||
lua::createtable(L, 0, 4);
|
||||
lua::pushlstring(L, device->getDeviceSpecifier());
|
||||
lua::setfield(L, "device_specifier");
|
||||
lua::pushinteger(L, device->getChannels());
|
||||
lua::setfield(L, "channels");
|
||||
lua::pushinteger(L, device->getSampleRate());
|
||||
|
||||
Reference in New Issue
Block a user