Skip to content

Commit

Permalink
MASSIVE CRASHFIX! Remove audio deadlock.
Browse files Browse the repository at this point in the history
  • Loading branch information
geneotech committed Mar 15, 2024
1 parent efe7af2 commit e405d43
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
14 changes: 10 additions & 4 deletions src/augs/audio/audio_command_buffers.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "augs/audio/audio_command.h"
#include "augs/audio/audio_backend.h"

static constexpr int num_audio_buffers_v = 4;
static constexpr int num_audio_buffers_v = 10;

namespace augs {
class audio_command_buffers {
Expand Down Expand Up @@ -73,10 +73,16 @@ namespace augs {
}

void report_completion() {
auto lk = lock_queue();
read_index = next_to(read_index);
bool finished = false;

{
auto lk = lock_queue();
read_index = next_to(read_index);

finished = has_finished();
}

if (has_finished()) {
if (finished) {
for_completion.notify_all();
pool_to_help_when_idle.help_until_no_tasks();
}
Expand Down
10 changes: 7 additions & 3 deletions src/augs/templates/thread_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ namespace augs {
}

void register_completion() {
bool completed = false;

{
auto lock = lock_completion();
++tasks_completed;

if (tasks_completed == tasks_posted) {
completion_variable.notify_all();
}
completed = tasks_completed == tasks_posted;
}

if (completed) {
completion_variable.notify_all();
}
}

Expand Down

0 comments on commit e405d43

Please sign in to comment.