mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-17 13:22:58 +00:00
Piano: Quit the audio thread by checking Core::EventLoop for exit
The infinite loop here doesn't really work at all for an application process that expects to be able to exit. Check against Core::EventLoop::current() to see if it's time to exit, and return 0 from the thread function if so. The thread will be joined in its destructor, which doesn't assert anymore now that Thread is a jthread.
This commit is contained in:
parent
06865c78c7
commit
084c296362
|
@ -82,7 +82,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
Array<Sample, sample_count> buffer;
|
||||
for (;;) {
|
||||
while (!Core::EventLoop::current().was_exit_requested()) {
|
||||
track_manager.fill_buffer(buffer);
|
||||
audio->write(reinterpret_cast<u8*>(buffer.data()), buffer_size);
|
||||
Core::EventLoop::current().post_event(main_widget, make<Core::CustomEvent>(0));
|
||||
|
@ -101,6 +101,7 @@ int main(int argc, char** argv)
|
|||
wav_writer.finalize();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
audio_thread->start();
|
||||
|
||||
|
|
Loading…
Reference in a new issue