mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 23:48:11 +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
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