Driver, Gateway: Remove tokio 0.2 support (#118)
* Remove tokio 0.2 compat * Remove tokio 0.2 test * Remove tokio 0.2 CI
This commit is contained in:
@@ -11,10 +11,7 @@ mod ws;
|
||||
pub use self::{core::*, disposal::*, events::*, mixer::*, udp_rx::*, udp_tx::*, ws::*};
|
||||
|
||||
use flume::Sender;
|
||||
#[cfg(not(feature = "tokio-02-marker"))]
|
||||
use tokio::spawn;
|
||||
#[cfg(feature = "tokio-02-marker")]
|
||||
use tokio_compat::spawn;
|
||||
use tracing::trace;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
||||
@@ -19,10 +19,7 @@ use flume::{Receiver, Sender, TryRecvError};
|
||||
use rand::random;
|
||||
use spin_sleep::SpinSleeper;
|
||||
use std::time::Instant;
|
||||
#[cfg(not(feature = "tokio-02-marker"))]
|
||||
use tokio::runtime::Handle;
|
||||
#[cfg(feature = "tokio-02-marker")]
|
||||
use tokio_compat::runtime::Handle;
|
||||
use tracing::{debug, error, instrument};
|
||||
use xsalsa20poly1305::TAG_SIZE;
|
||||
|
||||
|
||||
@@ -23,10 +23,7 @@ use crate::{
|
||||
};
|
||||
use flume::{Receiver, RecvError, Sender};
|
||||
use message::*;
|
||||
#[cfg(not(feature = "tokio-02-marker"))]
|
||||
use tokio::{runtime::Handle, spawn, time::sleep as tsleep};
|
||||
#[cfg(feature = "tokio-02-marker")]
|
||||
use tokio_compat::{runtime::Handle, spawn, time::delay_for as tsleep};
|
||||
use tracing::{debug, instrument, trace};
|
||||
|
||||
pub(crate) fn start(config: Config, rx: Receiver<CoreMessage>, tx: Sender<CoreMessage>) {
|
||||
|
||||
@@ -22,10 +22,7 @@ use discortp::{
|
||||
};
|
||||
use flume::Receiver;
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
#[cfg(not(feature = "tokio-02-marker"))]
|
||||
use tokio::{net::UdpSocket, select};
|
||||
#[cfg(feature = "tokio-02-marker")]
|
||||
use tokio_compat::{net::udp::RecvHalf, select};
|
||||
use tracing::{error, instrument, trace, warn};
|
||||
use xsalsa20poly1305::XSalsa20Poly1305 as Cipher;
|
||||
|
||||
@@ -241,10 +238,7 @@ struct UdpRx {
|
||||
packet_buffer: [u8; VOICE_PACKET_MAX],
|
||||
rx: Receiver<UdpRxMessage>,
|
||||
|
||||
#[cfg(not(feature = "tokio-02-marker"))]
|
||||
udp_socket: Arc<UdpSocket>,
|
||||
#[cfg(feature = "tokio-02-marker")]
|
||||
udp_socket: RecvHalf,
|
||||
}
|
||||
|
||||
impl UdpRx {
|
||||
@@ -396,7 +390,6 @@ impl UdpRx {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tokio-02-marker"))]
|
||||
#[instrument(skip(interconnect, rx, cipher))]
|
||||
pub(crate) async fn runner(
|
||||
mut interconnect: Interconnect,
|
||||
@@ -421,31 +414,6 @@ pub(crate) async fn runner(
|
||||
trace!("UDP receive handle stopped.");
|
||||
}
|
||||
|
||||
#[cfg(feature = "tokio-02-marker")]
|
||||
#[instrument(skip(interconnect, rx, cipher))]
|
||||
pub(crate) async fn runner(
|
||||
mut interconnect: Interconnect,
|
||||
rx: Receiver<UdpRxMessage>,
|
||||
cipher: Cipher,
|
||||
config: Config,
|
||||
udp_socket: RecvHalf,
|
||||
) {
|
||||
trace!("UDP receive handle started.");
|
||||
|
||||
let mut state = UdpRx {
|
||||
cipher,
|
||||
decoder_map: Default::default(),
|
||||
config,
|
||||
packet_buffer: [0u8; VOICE_PACKET_MAX],
|
||||
rx,
|
||||
udp_socket,
|
||||
};
|
||||
|
||||
state.run(&mut interconnect).await;
|
||||
|
||||
trace!("UDP receive handle stopped.");
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn rtp_valid(packet: RtpPacket<'_>) -> bool {
|
||||
packet.get_version() == RTP_VERSION && packet.get_payload_type() == RTP_PROFILE_TYPE
|
||||
|
||||
@@ -3,26 +3,17 @@ use crate::constants::*;
|
||||
use discortp::discord::MutableKeepalivePacket;
|
||||
use flume::Receiver;
|
||||
use std::sync::Arc;
|
||||
#[cfg(not(feature = "tokio-02-marker"))]
|
||||
use tokio::{
|
||||
net::UdpSocket,
|
||||
time::{timeout_at, Instant},
|
||||
};
|
||||
#[cfg(feature = "tokio-02-marker")]
|
||||
use tokio_compat::{
|
||||
net::udp::SendHalf,
|
||||
time::{timeout_at, Instant},
|
||||
};
|
||||
use tracing::{error, instrument, trace};
|
||||
|
||||
struct UdpTx {
|
||||
ssrc: u32,
|
||||
rx: Receiver<UdpTxMessage>,
|
||||
|
||||
#[cfg(not(feature = "tokio-02-marker"))]
|
||||
udp_tx: Arc<UdpSocket>,
|
||||
#[cfg(feature = "tokio-02-marker")]
|
||||
udp_tx: SendHalf,
|
||||
}
|
||||
|
||||
impl UdpTx {
|
||||
@@ -62,7 +53,6 @@ impl UdpTx {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tokio-02-marker"))]
|
||||
#[instrument(skip(udp_msg_rx))]
|
||||
pub(crate) async fn runner(udp_msg_rx: Receiver<UdpTxMessage>, ssrc: u32, udp_tx: Arc<UdpSocket>) {
|
||||
trace!("UDP transmit handle started.");
|
||||
@@ -77,19 +67,3 @@ pub(crate) async fn runner(udp_msg_rx: Receiver<UdpTxMessage>, ssrc: u32, udp_tx
|
||||
|
||||
trace!("UDP transmit handle stopped.");
|
||||
}
|
||||
|
||||
#[cfg(feature = "tokio-02-marker")]
|
||||
#[instrument(skip(udp_msg_rx))]
|
||||
pub(crate) async fn runner(udp_msg_rx: Receiver<UdpTxMessage>, ssrc: u32, udp_tx: SendHalf) {
|
||||
trace!("UDP transmit handle started.");
|
||||
|
||||
let mut txer = UdpTx {
|
||||
ssrc,
|
||||
rx: udp_msg_rx,
|
||||
udp_tx,
|
||||
};
|
||||
|
||||
txer.run().await;
|
||||
|
||||
trace!("UDP transmit handle stopped.");
|
||||
}
|
||||
|
||||
@@ -11,23 +11,14 @@ use crate::{
|
||||
ws::{Error as WsError, ReceiverExt, SenderExt, WsStream},
|
||||
ConnectionInfo,
|
||||
};
|
||||
#[cfg(not(feature = "tokio-02-marker"))]
|
||||
use async_tungstenite::tungstenite::protocol::frame::coding::CloseCode;
|
||||
#[cfg(feature = "tokio-02-marker")]
|
||||
use async_tungstenite_compat::tungstenite::protocol::frame::coding::CloseCode;
|
||||
use flume::Receiver;
|
||||
use rand::random;
|
||||
use std::time::Duration;
|
||||
#[cfg(not(feature = "tokio-02-marker"))]
|
||||
use tokio::{
|
||||
select,
|
||||
time::{sleep_until, Instant},
|
||||
};
|
||||
#[cfg(feature = "tokio-02-marker")]
|
||||
use tokio_compat::{
|
||||
select,
|
||||
time::{delay_until as sleep_until, Instant},
|
||||
};
|
||||
use tracing::{debug, info, instrument, trace, warn};
|
||||
|
||||
struct AuxNetwork {
|
||||
|
||||
Reference in New Issue
Block a user