mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-17 07:50:04 +00:00
AudioServer: Expose the ability to get and set the sample rate
Two new IPC calls allow audio clients to get and set the sample rate. The AudioServer calls into the new ioctl of the sound card.
This commit is contained in:
parent
d0ceaa24a6
commit
9880a5c481
Notes:
sideshowbarker
2024-07-18 05:12:49 +09:00
Author: https://github.com/kleinesfilmroellchen
Commit: 9880a5c481
Pull-request: https://github.com/SerenityOS/serenity/pull/9471
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/awesomekling
5 changed files with 38 additions and 0 deletions
|
@ -14,6 +14,8 @@
|
|||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibCore/Timer.h>
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
namespace AudioServer {
|
||||
|
||||
|
@ -150,6 +152,23 @@ void Mixer::set_muted(bool muted)
|
|||
});
|
||||
}
|
||||
|
||||
int Mixer::audiodevice_set_sample_rate(u16 sample_rate)
|
||||
{
|
||||
int code = ioctl(m_device->fd(), SOUNDCARD_IOCTL_SET_SAMPLE_RATE, sample_rate);
|
||||
if (code != 0)
|
||||
dbgln("Error while setting sample rate to {}: ioctl returned with {}", sample_rate, strerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
u16 Mixer::audiodevice_get_sample_rate() const
|
||||
{
|
||||
u16 sample_rate = 0;
|
||||
int code = ioctl(m_device->fd(), SOUNDCARD_IOCTL_GET_SAMPLE_RATE, &sample_rate);
|
||||
if (code != 0)
|
||||
dbgln("Error while getting sample rate: ioctl returned with {}", strerror(code));
|
||||
return sample_rate;
|
||||
}
|
||||
|
||||
void Mixer::request_setting_sync()
|
||||
{
|
||||
if (m_config_write_timer.is_null() || !m_config_write_timer->is_active()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue