summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-28 21:52:30 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-28 21:52:30 +0200
commitae4a9e017aba665a9d432d6cac785048be013f30 (patch)
tree561e4abf23cc926e7e06134a973e07c9ecbe147b /Userland
parentb44d3faa1c926204643d41eb1dac31a3ec301029 (diff)
downloadserenity-ae4a9e017aba665a9d432d6cac785048be013f30.zip
LibAudio+aplay: Make the aplay output look a little funner.
Show some information about the file we're playing, and display how many samples we've played out of how many total. This might be a bit buggy as I haven't tested it with many different files, but it's a start. :^)
Diffstat (limited to 'Userland')
-rw-r--r--Userland/aplay.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/Userland/aplay.cpp b/Userland/aplay.cpp
index 9d2fba736b..5582fd9ca0 100644
--- a/Userland/aplay.cpp
+++ b/Userland/aplay.cpp
@@ -1,10 +1,10 @@
-#include <LibCore/CEventLoop.h>
-#include <LibAudio/AWavLoader.h>
-#include <LibAudio/AClientConnection.h>
#include <LibAudio/ABuffer.h>
+#include <LibAudio/AClientConnection.h>
+#include <LibAudio/AWavLoader.h>
+#include <LibCore/CEventLoop.h>
#include <cstdio>
-int main(int argc, char **argv)
+int main(int argc, char** argv)
{
CEventLoop loop;
if (argc < 2) {
@@ -12,22 +12,25 @@ int main(int argc, char **argv)
return 1;
}
- printf("Establishing connection\n");
AClientConnection a_conn;
a_conn.handshake();
- printf("Established connection\n");
AWavLoader loader(argv[1]);
- printf("Loaded WAV\n");
+ printf("\033[34;1mPlaying\033[0m: %s\n", argv[1]);
+ printf("\033[34;1m Format\033[0m: %u Hz, %u-bit, %s\n",
+ loader.sample_rate(),
+ loader.bits_per_sample(),
+ loader.num_channels() == 1 ? "Mono" : "Stereo");
+ printf("\033[34;1m Sample\033[0m: \033[s");
for (;;) {
auto samples = loader.get_more_samples();
- if (!samples) {
+ if (!samples)
break;
- }
- printf("Playing %d sample(s)\n", samples->sample_count());
+ printf("\033[u");
+ printf("%d/%d", loader.loaded_samples(), loader.total_samples());
+ fflush(stdout);
a_conn.enqueue(*samples);
}
-
- printf("Exiting! :)\n");
+ printf("\n");
return 0;
}