ladybird/Libraries/LibAudio/ASAPI.h
Robin Burchell 2df6f0e87f Work on AudioServer
The center of this is now an ABuffer class in LibAudio.
ABuffer contains ASample, which has two channels (left/right) in
floating point for mixing purposes, in 44100hz.

This means that the loaders (AWavLoader in this case) needs to do some
manipulation to get things in the right format, but that we don't need
to care after format loading is done.

While we're at it, do some correctness fixes. PCM data is unsigned if
it's 8 bit, but 16 bit is signed. And /dev/audio also wants signed 16
bit audio, so give it what it wants.

On top of this, AudioServer now accepts requests to play a buffer.
The IPC mechanism here is pretty much a 1:1 copy-paste from
LibGUI/WindowServer. It can be generalized more in the future, but for
now I want to get AudioServer working decently first :)

Additionally, add a little "aplay" tool to load and play a WAV file. It
will break with large WAVs (run out of memory, heh...) but it's a start.

Future work needs to make AudioServer block buffer submission from
clients until it has played the buffer they are requesting to play.
2019-07-17 09:39:31 +02:00

43 lines
719 B
C

#pragma once
struct ASAPI_ServerMessage {
enum class Type {
Invalid,
Greeting,
PlayingBuffer,
};
Type type { Type::Invalid };
unsigned extra_size { 0 };
union {
struct {
int server_pid;
int your_client_id;
} greeting;
struct {
int buffer_id;
} playing_buffer;
};
};
struct ASAPI_ClientMessage {
enum class Type {
Invalid,
Greeting,
PlayBuffer,
};
Type type { Type::Invalid };
unsigned extra_size { 0 };
union {
struct {
int client_pid;
} greeting;
struct {
int buffer_id;
} play_buffer;
};
};