mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:38:11 +00:00

Across the entire audio system, audio now works in 0-1 terms instead of 0-100 as before. Therefore, volume is now a double instead of an int. The master volume of the AudioServer changes smoothly through a FadingProperty, preventing clicks. Finally, volume computations are done with logarithmic scaling, which is more natural for the human ear. Note that this could be 4-5 different commits, but as they change each other's code all the time, it makes no sense to split them up.
38 lines
967 B
C++
38 lines
967 B
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AudioServer/AudioClientEndpoint.h>
|
|
#include <AudioServer/AudioServerEndpoint.h>
|
|
#include <LibIPC/ServerConnection.h>
|
|
|
|
namespace Audio {
|
|
|
|
class Buffer;
|
|
|
|
class ClientConnection final
|
|
: public IPC::ServerConnection<AudioClientEndpoint, AudioServerEndpoint>
|
|
, public AudioClientEndpoint {
|
|
C_OBJECT(ClientConnection)
|
|
public:
|
|
ClientConnection();
|
|
|
|
void enqueue(Buffer const&);
|
|
bool try_enqueue(Buffer const&);
|
|
void async_enqueue(Buffer const&);
|
|
|
|
Function<void(i32 buffer_id)> on_finish_playing_buffer;
|
|
Function<void(bool muted)> on_muted_state_change;
|
|
Function<void(double volume)> on_main_mix_volume_change;
|
|
|
|
private:
|
|
virtual void finished_playing_buffer(i32) override;
|
|
virtual void muted_state_changed(bool) override;
|
|
virtual void main_mix_volume_changed(double) override;
|
|
};
|
|
|
|
}
|