mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:57:45 +00:00
Userland: Use Core::ArgsParser for 'aplay'
This commit is contained in:
parent
8f33a44b6c
commit
d9de0a5007
1 changed files with 9 additions and 6 deletions
|
@ -27,26 +27,29 @@
|
||||||
#include <LibAudio/Buffer.h>
|
#include <LibAudio/Buffer.h>
|
||||||
#include <LibAudio/ClientConnection.h>
|
#include <LibAudio/ClientConnection.h>
|
||||||
#include <LibAudio/WavLoader.h>
|
#include <LibAudio/WavLoader.h>
|
||||||
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/EventLoop.h>
|
#include <LibCore/EventLoop.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
const char* path = nullptr;
|
||||||
|
|
||||||
|
Core::ArgsParser args_parser;
|
||||||
|
args_parser.add_positional_argument(path, "Path to WAV file", "path");
|
||||||
|
args_parser.parse(argc, argv);
|
||||||
|
|
||||||
Core::EventLoop loop;
|
Core::EventLoop loop;
|
||||||
if (argc < 2) {
|
|
||||||
fprintf(stderr, "Need a WAV to play\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto audio_client = Audio::ClientConnection::construct();
|
auto audio_client = Audio::ClientConnection::construct();
|
||||||
audio_client->handshake();
|
audio_client->handshake();
|
||||||
Audio::WavLoader loader(argv[1]);
|
Audio::WavLoader loader(path);
|
||||||
if (loader.has_error()) {
|
if (loader.has_error()) {
|
||||||
fprintf(stderr, "Failed to load WAV file: %s\n", loader.error_string());
|
fprintf(stderr, "Failed to load WAV file: %s\n", loader.error_string());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\033[34;1m Playing\033[0m: %s\n", argv[1]);
|
printf("\033[34;1m Playing\033[0m: %s\n", path);
|
||||||
printf("\033[34;1m Format\033[0m: %u Hz, %u-bit, %s\n",
|
printf("\033[34;1m Format\033[0m: %u Hz, %u-bit, %s\n",
|
||||||
loader.sample_rate(),
|
loader.sample_rate(),
|
||||||
loader.bits_per_sample(),
|
loader.bits_per_sample(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue