mirror of
https://github.com/RGBCube/serenity
synced 2026-01-21 01:11:00 +00:00
I had to solve a bunch of things simultaneously to make this work. Refactor AWavLoader to be a streaming loader rather than a one-shot one. The constructor parses the header, and if everything looks good, you can repeatedly ask the AWavLoader for sample buffers until it runs out. Also send a message from AudioServer when a buffer has finished playing. That allows us to implement a blocking variant of play(). Use all of this in aplay to play WAV files chunk-at-a-time. This is definitely not perfect and it's a little glitchy and skippy, but I think it's a step in the right direction.
43 lines
750 B
C
43 lines
750 B
C
#pragma once
|
|
|
|
struct ASAPI_ServerMessage {
|
|
enum class Type {
|
|
Invalid,
|
|
Greeting,
|
|
PlayingBuffer,
|
|
FinishedPlayingBuffer,
|
|
};
|
|
|
|
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;
|
|
};
|
|
};
|