Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add packets_left count #1194

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading