diff --git a/userspace/programs/CMakeLists.txt b/userspace/programs/CMakeLists.txt index 54f823fb..288bbc05 100644 --- a/userspace/programs/CMakeLists.txt +++ b/userspace/programs/CMakeLists.txt @@ -1,4 +1,5 @@ set(USERSPACE_PROGRAMS + audio AudioServer bananfetch basename diff --git a/userspace/programs/audio/CMakeLists.txt b/userspace/programs/audio/CMakeLists.txt new file mode 100644 index 00000000..27980848 --- /dev/null +++ b/userspace/programs/audio/CMakeLists.txt @@ -0,0 +1,9 @@ +set(SOURCES + main.cpp +) + +add_executable(audio ${SOURCES}) +banan_link_library(audio libc) +banan_link_library(audio libaudio) + +install(TARGETS audio OPTIONAL) diff --git a/userspace/programs/audio/main.cpp b/userspace/programs/audio/main.cpp new file mode 100644 index 00000000..f8bf29ec --- /dev/null +++ b/userspace/programs/audio/main.cpp @@ -0,0 +1,36 @@ +#include + +#include +#include + +int main(int argc, char** argv) +{ + if (argc != 2) + { + fprintf(stderr, "usage: %s FILE\n", argv[0]); + return 1; + } + + auto audio_or_error = LibAudio::Audio::load(argv[1]); + if (audio_or_error.is_error()) + { + fprintf(stderr, "failed to load %s: %s\n", argv[1], audio_or_error.error().get_message()); + return 1; + } + + auto audio = audio_or_error.release_value(); + + if (auto ret = audio.start(); ret.is_error()) + { + fprintf(stderr, "failed start playing audio: %s\n", ret.error().get_message()); + return 1; + } + + while (audio.is_playing()) + { + usleep(10'000); + audio.update(); + } + + return 0; +}