Driver: Split receive into its own feature (#141)

Adds the "receive" feature, which is disabled by default. When this is disabled, the UDP receive task is not compiled and not run, and as an optimisation the UDP receive buffer size is set to 0. All related events are also removed.

This also removes the UDP Tx task, and moves packet and keepalive sends back into the mixer thread. This allows us to entirely remove channels and various allocations between the mixer and an async task created only for sending data (i.e., fewer memcopies).

If "receive" is enabled, UDP sends are now non-blocking due to technical constraints -- failure to send is non-fatal, but *will* drop affected packets. Given that blocking on a UDP send indicates that the OS cannot clear send buffers fast enough, this should alleviate OS load.

Closes #131.
This commit is contained in:
Kyle Simpson
2022-08-01 15:54:20 +01:00
parent c1d93f790c
commit 2277595be4
27 changed files with 299 additions and 206 deletions

View File

@@ -13,11 +13,13 @@
//! `"gateway"` and `"[serenity/twilight]"` plus `"[rustls/native]"` features. You can even run
//! driverless, to help manage your [lavalink] sessions.
//! * A standalone driver for voice calls, via the `"driver"` feature. If you can create
//! a [`ConnectionInfo`] using any other gateway, or language for your bot, then you
//! a `ConnectionInfo` using any other gateway, or language for your bot, then you
//! can run the songbird voice driver.
//! * And, by default, a fully featured voice system featuring events, queues, RT(C)P packet
//! handling, seeking on compatible streams, shared multithreaded audio stream caches,
//! and direct Opus data passthrough.
//! * Voice receive and RT(C)P packet handling via the `"receive"` feature.
//! * SIMD-accelerated JSON decoding via the `"simd-json"` feature.
//! * And, by default, a fully featured voice system featuring events, queues,
//! seeking on compatible streams, shared multithreaded audio stream caches,
//! and direct Opus data passthrough from DCA files.
//!
//! ## Intents
//! Songbird's gateway functionality requires you to specify the `GUILD_VOICE_STATES` intent.
@@ -101,7 +103,7 @@ pub mod tracks;
#[cfg(feature = "driver")]
mod ws;
#[cfg(feature = "driver")]
#[cfg(all(feature = "driver", feature = "receive"))]
pub use discortp as packet;
#[cfg(feature = "driver")]
pub use serenity_voice_model as model;