Fixed audio issue

This commit is contained in:
WolverinDEV 2019-12-08 17:08:47 +01:00
parent dbd8e73ab5
commit 58d4e1489b
No known key found for this signature in database
GPG Key ID: 77A6C15085150EEB
4 changed files with 13 additions and 7 deletions

View File

@ -147,7 +147,7 @@ void UDPSocket::callback_read(evutil_socket_t fd) {
source_address_length = sizeof(sockaddr);
read_length = recvfrom(fd, (char*) buffer, (int) buffer_length, MSG_DONTWAIT, &source_address, &source_address_length);
if(read_length <= 0) {
if(errno == EAGAIN || read_length == 0)
if(errno == EAGAIN || (read_length == 0 && read_count > 0))
break;
logger::warn(category::socket, tr("Failed to receive data: {}/{}"), errno, strerror(errno));

View File

@ -227,7 +227,7 @@ VoiceClient::VoiceClient(const std::shared_ptr<VoiceConnection>&, uint16_t clien
this->set_state(state::buffering);
}
audio::decode_event_loop->schedule(dynamic_pointer_cast<event::EventEntry>(this->ref()));
audio::decode_event_loop->schedule(static_pointer_cast<event::EventEntry>(this->ref()));
}
}
@ -368,7 +368,7 @@ void VoiceClient::process_packet(uint16_t packet_id, const pipes::buffer_view& b
codec_data.process_pending = true;
}
audio::decode_event_loop->schedule(dynamic_pointer_cast<event::EventEntry>(this->ref()));
audio::decode_event_loop->schedule(static_pointer_cast<event::EventEntry>(this->ref()));
}
void VoiceClient::cancel_replay() {
@ -376,7 +376,7 @@ void VoiceClient::cancel_replay() {
this->output_source->clear();
this->set_state(state::stopped);
audio::decode_event_loop->cancel(dynamic_pointer_cast<event::EventEntry>(this->ref()));
audio::decode_event_loop->cancel(static_pointer_cast<event::EventEntry>(this->ref()));
auto execute_lock = this->execute_lock(true);
for(auto& codec : this->codec) {
@ -549,7 +549,7 @@ void VoiceClient::event_execute(const std::chrono::system_clock::time_point &sch
if(reschedule) {
log_warn(category::voice_connection, tr("Audio data decode will take longer than {} us. Enqueueing for later"),
chrono::duration_cast<chrono::microseconds>(max_time).count());
audio::decode_event_loop->schedule(dynamic_pointer_cast<event::EventEntry>(this->ref()));
audio::decode_event_loop->schedule(static_pointer_cast<event::EventEntry>(this->ref()));
}
}

View File

@ -48,9 +48,15 @@ namespace tc {
class VoiceClient : private event::EventEntry {
friend class VoiceConnection;
#ifdef WIN32
template<typename _Tp, typename _Up>
friend _NODISCARD std::shared_ptr<_Tp> std::static_pointer_cast(std::shared_ptr<_Up>&& _Other) noexcept;
#else
template<typename _Tp, typename _Up>
friend inline std::shared_ptr<_Tp> std::static_pointer_cast(const std::shared_ptr<_Up>& __r) noexcept;
#endif
//_NODISCARD shared_ptr<_Ty1> static_pointer_cast(shared_ptr<_Ty2>&& _Other) noexcept
public:
struct state {
enum value {

View File

@ -1,6 +1,6 @@
{
"name": "TeaClient",
"version": "1.4.2-4",
"version": "1.4.2-5",
"description": "",
"main": "main.js",
"scripts": {