Commit Graph

241 Commits

Author SHA1 Message Date
Kyle Simpson
55b8e7fb4e Driver: Add ability to clear all global event handlers.
Closes #32. This should make event handler cleanup considerably easier depending on use case.
2021-01-17 21:29:19 +00:00
Kyle Simpson
dcb6ad97b2 Driver: Fix noisy errors, UDP message send failure spam.
Closes #26.

This will also prevent a full reconnect failure from endlessly spamming attempts and error logs. I'll follow this up by looking into decent reconnection strategies, although sadly these won't be configurable until the next semver break due to an oversight on my part.
2021-01-17 20:12:55 +00:00
Kyle Simpson
12776fc6f8 Release v0.1.0 (#34)
* Update dependencies, draft initial structure for changelog.

* Full changelog!
2021-01-08 11:42:07 +00:00
Kyle Simpson
7d767d2919 Chore: Bump to published twilight. 2021-01-08 10:27:25 +00:00
Kyle Simpson
53ab9dac03 Chore: Bump to published serenity. 2021-01-06 23:12:24 +00:00
Kyle Simpson
f05b7414a0 Songbird: Tokio 1.0 (#36)
Migrates to the new version of tokio, requiring channel and sleep changes in a few locations. Additionally points to the in-tree v0.3 version of twilight.
2021-01-06 13:01:14 +00:00
Kyle Simpson
d42e09f72b Tracks: Add TypeMap to Handles.
Adds a shared TypeMap per TrackHandle. This should greatly simplify the user experience for attaching additional per-track state which the driver does not care for.
2021-01-02 23:43:28 +00:00
baguette
873458d288 Tracks: Allow custom UUID setting (#33) 2020-12-30 10:09:44 +00:00
Kyle Simpson
03ae0e7628 Input: Allow Restartable sources to be lazy
This change is made with queue users in mind. Since sources
of this kind *know* how to (re)create themselves, they can
avoid being created at all until needed.

This also adds machinery to preload tracks *before* they are
needed, for gapless playback on queues and so on. Queues
make use of the event system to do this.
2020-12-28 17:17:57 +00:00
Kyle Simpson
c0d3cb3113 Docs: Warn about twilight task deadlock
Potential deadlock (identified by a user) has now been warned about. The way the example is structured prevents this from occurring, but it's worth making this more explicit due to the more free-form nature of twilight.

The design of serenity's event handling and framework should prevent this issue from cropping up when using it as a gateway backend.
2020-12-27 00:16:05 +00:00
Kyle Simpson
504b8dfaef Driver, Input: Performance & Benchmarks (#27)
* Driver Benchmarks

Benchmarks driver use cases for single packet send,
multiple packet send, float vs opus, and the cost of
head-of-queue track removal.

Mix costs for large packet counts are also included.

This is a prelude to the optimisations discussed in
#21.

* Typo in benchmark

* Place Opus packet directly into packet buffer

Cleans up some other logic surrounding this, too. Gets a 16.9% perf improvement on opus packet passthrough (sub 5us here).

* Better track removal

In theory this should be faster, but it aint. Keeping in case
reducing struct sizes down the line magically makes this
faster.

* Reduce size of Input, TrackHandle

Metadata is now boxed away. Similarly, TrackHandles are neatly Arc'd to reduce their size to pointer length (and mitigate the impact of copies if we add in more fields).
2020-12-26 23:08:35 +00:00
Kyle Simpson
2fc88a6ef1 Deps: Patch flume.
Addresses security advisory in downstream nanorand.
2020-12-19 13:18:46 +00:00
Maspenguin
8d6bd4fd63 Input: Json parsing errors now contain the parsed text (#31) 2020-12-13 12:19:49 +00:00
Saanu Reghunadh
700f20dff9 Metadata: Add source_url and thumbnail fields (#28) 2020-12-07 14:54:29 +00:00
Kyle Simpson
f222ce9969 Driver, Tracks: Cleanup of leaky types (#20)
Main goal: a lot of nested future/result folding.

This mainly modifies error handling for Tracks and TrackHandles to be
more consistent, and hides the underlying channel result passing in
get_info. Errors returned should be far clearer, and are domain
specific rather than falling back to a very opaque use of the underlying
channel error. It should be clearer to users why their handle commands
failed, or why they can't make a ytdl track loop or similar.

Also fixed/cleaned up Songbird::join(_gateway) to return in a single
await, sparing the user from the underlying channel details and repeated
Errs. I was trying for some time to extend the same graces to `Call`,
but could not figure out a sane way to get a 'static version of the
first future in the chain (i.e., the gateway send) so that the whole
thing could happen after dropping the lock around the Call. I really
wanted to fix this to happen as a single folded await too, but I think
this might need some crazy hack or redesign.
2020-12-04 15:13:43 +00:00
Kyle Simpson
9fdbcd77be Driver: Handle receiving large non-standard packets (#23)
Discord's web client on Firefox seems to send very large packets,
ranging from 20ms to 60ms at different times and systems. This adapts
the UDP Rx task to remember the largest packet needed for any SSRC
in a call and preallocate that much, which also allows it to decode
such packets.
2020-12-04 13:55:22 +00:00
baguette
57df3fe53a TrackHandle: add metadata field (#25)
* Adds metadata field to TrackHandle.

Co-authored-by: Kyle Simpson <kyleandrew.simpson@gmail.com>
2020-12-04 13:43:35 +00:00
Kyle Simpson
94157b12bc Docs: Move to new intra-doc links, make events non-exhaustive. (#19)
Far cleaner and more reliable than the old doc-link pattern. Also allowed me to spot some event types and sources which should have been made non_exhaustive.
2020-11-24 19:52:23 +00:00
Maspenguin
1ada46d24b Fix: Remove serenity default features (#18)
Allows use of songbird without serenity's framework.
2020-11-23 10:43:24 +00:00
baguette
69acea8664 TrackQueue: Add current_queue method (#16) 2020-11-19 00:33:00 +00:00
Kyle Simpson
2da5901930 Input: Make restartable sources fully async. (#15)
Redresses a previous holdover from an attempt to get Restartable sources to work more neatly inside the synchronous mixer thread. This prevents `Restartable::*` from blocking without warning.

The initial fix at the time was to perform the restart work on a task provided by the tokio runtime as `executor::block_on` needs to be run from within a valid async runtime. Naturally, this completely missed the point that these closures should/could be async, without any need to fudge async functions into a sync wrapper.

Also removes the `From` for normal closures, as this will probably act as a footgun for folks on a single-threaded executor.
2020-11-18 20:48:34 +00:00
( ͡° ͜ʖ ͡°)
cb7d8cc618 Lint: Clippy warning cleanup (#8) 2020-11-16 15:54:29 +00:00
Kyle Simpson
de652250d8 TrackQueues: Convenience methods and extension (#7)
* Adds a uuid field to tracks and handles to make it easier to identify and match event sources after the fact.
* Adds optional feature "builtin-queue" to expose a queue on every driver, as a convenience for users who can guarantee they'll need a queue for every driver/call.
* Adds methods to queues to allow access to the currently running track handle, remove a specified queue entry, as well as to mutate the underlying queue from a closure.
2020-11-16 08:57:54 +00:00
Alex M. M
047ce0379a Docs: Add a dependencies section in the README (#2) 2020-11-14 20:23:49 +00:00
Kyle Simpson
45b1fb13bf Docs: describe youtube-dlc feature 2020-11-13 22:41:01 +00:00
( ͡° ͜ʖ ͡°)
6702520b7c Offer youtube-dlc as an alternative to youtube-dl (#1)
* Adds youtube-dlc feature.
2020-11-13 22:27:28 +00:00
Kyle Simpson
a9f8d6c93a Fix: Use correct tokio features for driver-only mode 2020-11-13 19:32:03 +00:00
Kyle Simpson
35d262d946 CI round 2 2020-11-13 19:15:33 +00:00
Kyle Simpson
c5ce107d55 Attempt CI similar to serenity 2020-11-13 18:56:18 +00:00
Kyle Simpson
09da85bfc3 Some updated links, move to current/next branches. 2020-11-13 17:55:36 +00:00
Alex M. M
a778d24941 Add the ISC license 2020-11-13 16:45:59 +01:00
Alex M. M
4f5b767dba Fix links in the README regarding examples 2020-11-13 16:41:35 +01:00
Alex M. M
f5bf54a63d Move examples from the Serenity repository 2020-11-13 16:20:57 +01:00
Alex M. M
4a897a7b76 Remove mentions of versions to Serenity git dependencies 2020-11-13 15:07:29 +01:00
Alex M. M
ec7f5bca2d Add a .gitignore file as songbird is in its own repository 2020-11-13 14:56:31 +01:00
Alex M. M
6724655351 Update Cargo.toml to reflect the separation of songbird from Serenity's repository 2020-11-13 14:55:38 +01:00
Kyle Simpson
868785ba71 Update versions for twilight and serenity-voice-model in songbird (#1075) 2020-11-12 13:34:23 +01:00
Kyle Simpson
8b7f388f7b Implement Songbird driver configuration (#1074) 2020-11-11 23:40:09 +01:00
Kyle Simpson
26c9c9117c Handle Voice close codes, prevent Songbird spinning WS threads (#1068)
Voice `CloseCode`s now map to a type rather than a collection of constants. Correct close code handling in this way terminates the websocket task when there is no likelihood of resuming, which was causing leftover tasks to spin at the `tokio::select` in some circumstances (i.e., ::leave, which keeps the `Driver` alive).
2020-11-08 22:28:40 +01:00
Kyle Simpson
38a55da88b Document intents for Songbird (#1061) 2020-11-06 00:25:29 +01:00
Kyle Simpson
7e4392ae68 Voice Rework -- Events, Track Queues (#806)
This implements a proof-of-concept for an improved audio frontend. The largest change is the introduction of events and event handling: both by time elapsed and by track events, such as ending or looping. Following on from this, the library now includes a basic, event-driven track queue system (which people seem to ask for unusually often). A new sample, `examples/13_voice_events`, demonstrates both the `TrackQueue` system and some basic events via the `~queue` and `~play_fade` commands.

Locks are removed from around the control of `Audio` objects, which should allow the backend to be moved to a more granular futures-based backend solution in a cleaner way.
2020-10-31 12:19:07 +01:00