summaryrefslogtreecommitdiff
path: root/Userland/aplay.cpp
blob: a86088c55c73950dd2197dff7bc84c79621e6876 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#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->samples().size());
        a_conn.play(*samples, true);
    }

    printf("Exiting! :)\n");
    return 0;
}