summaryrefslogtreecommitdiff
path: root/Userland/aplay.cpp
diff options
context:
space:
mode:
authorTill Mayer <till.mayer@web.de>2019-10-19 19:15:40 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-10-19 20:05:13 +0200
commit02e787f8a4a43aeef36463c68416a2b43ddf686b (patch)
tree2d2bf35c3178bf32f8a5d5223b1c342f5fd82a2f /Userland/aplay.cpp
parent406aabff233d2f6d312a5dc9131e616d7f8e4261 (diff)
downloadserenity-02e787f8a4a43aeef36463c68416a2b43ddf686b.zip
aplay: Fixed incomplete playback of files
aplay used to quit as soon as the last enqueue of new buffer data was sucessful. Because the connection closes as soon as the application quits, samples were still in the buffer of the ASBufferQueue as playback was halted.
Diffstat (limited to 'Userland/aplay.cpp')
-rw-r--r--Userland/aplay.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/Userland/aplay.cpp b/Userland/aplay.cpp
index dfae016a41..b8126ad99a 100644
--- a/Userland/aplay.cpp
+++ b/Userland/aplay.cpp
@@ -24,12 +24,16 @@ int main(int argc, char** argv)
printf("\033[34;1mProgress\033[0m: \033[s");
for (;;) {
auto samples = loader.get_more_samples();
- if (!samples)
+ if (samples) {
+ printf("\033[u");
+ printf("%d/%d", loader.loaded_samples(), loader.total_samples());
+ fflush(stdout);
+ audio_client->enqueue(*samples);
+ } else if (audio_client->get_remaining_samples()) {
+ sleep(1);
+ } else {
break;
- printf("\033[u");
- printf("%d/%d", loader.loaded_samples(), loader.total_samples());
- fflush(stdout);
- audio_client->enqueue(*samples);
+ }
}
printf("\n");
return 0;