add audio.get_input_info()

This commit is contained in:
MihailRis 2025-10-24 01:19:07 +03:00
parent 001c1b430b
commit 6c558eb3d5
4 changed files with 49 additions and 4 deletions

View file

@ -68,9 +68,17 @@ std::unique_ptr<Speaker> ALSound::newInstance(int priority, int channel) const {
}
ALInputDevice::ALInputDevice(
ALAudio* al, ALCdevice* device, uint channels, uint bitsPerSample
ALAudio* al,
ALCdevice* device,
uint channels,
uint bitsPerSample,
uint sampleRate
)
: al(al), device(device), channels(channels), bitsPerSample(bitsPerSample) {
: al(al),
device(device),
channels(channels),
bitsPerSample(bitsPerSample),
sampleRate(sampleRate) {
}
ALInputDevice::~ALInputDevice() {
@ -92,6 +100,14 @@ uint ALInputDevice::getChannels() const {
return channels;
}
uint ALInputDevice::getSampleRate() const {
return sampleRate;
}
uint ALInputDevice::getBitsPerSample() const {
return bitsPerSample;
}
size_t ALInputDevice::read(char* buffer, size_t bufferSize) {
ALCint samplesCount = 0;
alcGetIntegerv(device, ALC_CAPTURE_SAMPLES, sizeof(samplesCount), &samplesCount);
@ -546,7 +562,7 @@ std::unique_ptr<InputDevice> ALAudio::openInputDevice(
return nullptr;
return std::make_unique<ALInputDevice>(
this, device, channels, bitsPerSample
this, device, channels, bitsPerSample, sampleRate
);
}