ladybird/Userland/aplay.cpp
Andreas Kling 7cabe6433e AudioServer: Add a buffer queue so we can buffer some sound.
The idea here is to keep a small number of sample buffers queued in the
AudioServer so we don't get caught without something to play.
2019-07-28 18:27:32 +02:00

33 lines
770 B
C++

#include <LibCore/CEventLoop.h>
#include <LibAudio/AWavLoader.h>
#include <LibAudio/AClientConnection.h>
#include <LibAudio/ABuffer.h>
#include <cstdio>
int main(int argc, char **argv)
{
CEventLoop loop;
if (argc < 2) {
fprintf(stderr, "Need a WAV to play\n");
return 1;
}
printf("Establishing connection\n");
AClientConnection a_conn;
a_conn.handshake();
printf("Established connection\n");
AWavLoader loader(argv[1]);
printf("Loaded WAV\n");
for (;;) {
auto samples = loader.get_more_samples();
if (!samples) {
break;
}
printf("Playing %d sample(s)\n", samples->sample_count());
a_conn.enqueue(*samples);
}
printf("Exiting! :)\n");
return 0;
}