Skip to content

Commit

Permalink
fix: initial stuff, still not working
Browse files Browse the repository at this point in the history
  • Loading branch information
Neko-Life committed Nov 26, 2024
1 parent f21c6b9 commit 8f05cf0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
6 changes: 5 additions & 1 deletion src/dpp/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,11 @@ void cluster::shutdown() {
/* Signal termination */
terminating = true;
if (engine_thread) {
engine_thread->join();
if (engine_thread->joinable()) {
engine_thread->join();
} else {
log(ll_warning, "Cluster engine_thread is not joinable on dtor");
}
}
{
std::lock_guard<std::mutex> l(timer_guard);
Expand Down
1 change: 1 addition & 0 deletions src/dpp/socketengines/epoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ struct DPP_EXPORT socket_engine_epoll : public socket_engine_base {
}

if ((ev.events & EPOLLOUT) != 0U) {
/* Should we have a flag to allow keeping WANT_WRITE? Maybe like WANT_WRITE_ONCE or GREEDY_WANT_WRITE, eh */
eh->flags = modify_event(epoll_handle, eh, eh->flags & ~WANT_WRITE);
if (eh->on_write) {
eh->on_write(fd, *eh);
Expand Down
4 changes: 0 additions & 4 deletions src/dpp/voice/enabled/read_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ void discord_voice_client::send(const char* packet, size_t len, uint64_t duratio
} else [[unlikely]] {
this->udp_send(packet, len);
}
if (!this->sent_stop_frames) {
udp_events.flags = WANT_READ | WANT_WRITE | WANT_ERROR;
owner->socketengine->update_socket(udp_events);
}
}

int discord_voice_client::udp_send(const char* data, size_t length) {
Expand Down
14 changes: 9 additions & 5 deletions src/dpp/voice/enabled/write_ready.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
namespace dpp {

void discord_voice_client::write_ready() {
/*
* WANT_WRITE has been reset everytime this method is being called,
* ALWAYS set it again no matter what we're gonna do.
*/
udp_events.flags = WANT_READ | WANT_WRITE | WANT_ERROR;
owner->socketengine->update_socket(udp_events);

uint64_t duration = 0;
bool track_marker_found = false;
uint64_t bufsize = 0;
Expand All @@ -54,15 +61,12 @@ void discord_voice_client::write_ready() {
}
}
if (!outbuf.empty()) {
if (this->udp_send(outbuf[0].packet.data(), outbuf[0].packet.length()) == (int)outbuf[0].packet.length()) {
int sent_siz = this->udp_send(outbuf[0].packet.data(), outbuf[0].packet.length());
if (sent_siz == (int)outbuf[0].packet.length()) {
duration = outbuf[0].duration * timescale;
bufsize = outbuf[0].packet.length();
outbuf.erase(outbuf.begin());
}
if (!outbuf.empty()) {
udp_events.flags = WANT_READ | WANT_WRITE | WANT_ERROR;
owner->socketengine->update_socket(udp_events);
}
}
}
}
Expand Down

0 comments on commit 8f05cf0

Please sign in to comment.