ladybird/Userland/avol.cpp
Andreas Kling 107011f119 AudioServer: Allow muting the system audio
This patch adds muting to ASMixer, which works by substituting what we
would normally send to the sound card with zero-filled memory instead.
We do it this way to ensure that the queued sample buffers keep getting
played (silently.)

This is obviously not the perfect way of doing this, and in the future
we should improve on this, and also find a way to utilize any hardware
mixing functions in the sound card.
2019-11-22 21:44:02 +01:00

31 lines
757 B
C++

#include <LibAudio/ABuffer.h>
#include <LibAudio/AClientConnection.h>
#include <stdio.h>
int main(int argc, char** argv)
{
CEventLoop loop;
auto audio_client = AClientConnection::construct();
audio_client->handshake();
if (argc > 1) {
if (String(argv[1]) == "-m") {
audio_client->set_muted(true);
printf("Muted.\n");
return 0;
}
if (String(argv[1]) == "-M") {
audio_client->set_muted(false);
printf("Unmuted.\n");
return 0;
}
int new_volume = atoi(argv[1]);
audio_client->set_main_mix_volume(new_volume);
}
int volume = audio_client->get_main_mix_volume();
printf("Volume: %d\n", volume);
return 0;
}