Skip to content

Commit

Permalink
fix: add packets_left count (#1194)
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis authored Jul 8, 2024
2 parents a439d69 + b972257 commit b599812
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
7 changes: 6 additions & 1 deletion include/dpp/dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -1980,7 +1980,12 @@ struct DPP_EXPORT voice_buffer_send_t : public event_dispatch_t {
/**
* @brief encoded size of sent buffer
*/
int buffer_size = 0;
uint64_t buffer_size = 0;

/**
* @brief number of packet waiting to be sent in the queue
*/
size_t packets_left = 0;
};

/**
Expand Down
3 changes: 2 additions & 1 deletion src/dpp/discordvoiceclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,8 @@ void discord_voice_client::write_ready()
last_timestamp = std::chrono::high_resolution_clock::now();
if (!creator->on_voice_buffer_send.empty()) {
voice_buffer_send_t snd(nullptr, "");
snd.buffer_size = (int)bufsize;
snd.buffer_size = bufsize;
snd.packets_left = outbuf.size();
snd.voice_client = this;
creator->on_voice_buffer_send.call(snd);
}
Expand Down
8 changes: 7 additions & 1 deletion src/unittest/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,13 @@ Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* b
});

bot.on_voice_buffer_send([&](const dpp::voice_buffer_send_t & event) {
if (event.buffer_size == 0) {
static bool sent_some_data = false;

if (event.buffer_size > 0) {
sent_some_data = true;
}

if (sent_some_data && event.packets_left == 0) {
set_test(VOICESEND, true);
}
});
Expand Down

0 comments on commit b599812

Please sign in to comment.