Commit Graph

149 Commits

Author SHA1 Message Date
Kyle Simpson
be3030932e Chore: Clippy fixes for new lints 2021-07-01 11:34:30 +01:00
Vilgot Fredenberg
d6d6acabe1 Deps: Bump twilight versions -> 0.5 (#79) 2021-07-01 11:34:30 +01:00
Vilgot Fredenberg
00c8bc915a Input: Add separate YouTube title and channel to Metadata (#75) 2021-07-01 11:34:30 +01:00
Kyle Simpson
e47861c009 Chore: Release v0.2.0-beta.2 2021-07-01 11:34:30 +01:00
Vilgot Fredenberg
55e1567b90 Input, Driver: Make error messages more idiomatic (#74) 2021-07-01 11:33:51 +01:00
Kyle Simpson
3e0793644f Chore: Rewrite update pathway.
I had written this out before, but evidently it was lost somehow. This should fill in most of what was lost.
2021-07-01 11:33:51 +01:00
Kyle Simpson
cdebf79f07 Deps: Bump DiscoRTP version -> 0.4
Simple enough, tested using `cargo make ready`.
2021-07-01 11:33:51 +01:00
Vilgot Fredenberg
7045e2ec5a Input: Implement StdError for DcaError, input::Error (#73) 2021-07-01 11:33:51 +01:00
Kyle Simpson
6a441ba2f9 Chore: Release v0.2.0-beta1 2021-07-01 11:33:51 +01:00
Kyle Simpson
0f54d18455 Gateway: Add debug logging around shard handling
Adds some additional logging around some critical sections, rarely hit (i.e., during shard reconnections) in pursuit of issue #69. It's strongly suspected to lie here, at any rate...
2021-07-01 11:33:12 +01:00
Kyle Simpson
6d66b499e5 Deps: Bump twilight versions -> 0.4 2021-07-01 11:33:12 +01:00
Kyle Simpson
d1999776a8 Release v0.2.0-beta0 2021-07-01 11:33:12 +01:00
Kyle Simpson
fea204366b Chore: Repair formatting. 2021-07-01 11:30:02 +01:00
Kyle Simpson
91be0df5d5 Chore: Fix clippy warnings (useless clones). 2021-07-01 11:30:02 +01:00
Kyle Simpson
94c57f4ab5 Deps: Bump xsalsa20poly1305 version -> 0.7
This dependency upgrade (at last) resolves the duplicated rand_core versions present in builds. This was tested using `cargo make ready`.
2021-07-01 11:30:02 +01:00
Clarity
3c9b421fb4 Input: Change all Youtube-dl functions to take AsRef<str> (#70)
Unifies the API on all ytdl functions to remove some friction in passing in Strings, Cows, strs, and so on.

Closes #57.
2021-07-01 11:30:02 +01:00
James Liu
bc9a78e050 Use symphonia::io::MediaSource for Reader extensions (#61)
This PR does the following:

 * Changes both `Reader::Extension` and `Reader::ExtensionSeek`  to use `symphonia::io::MediaSource`.
 * Removes the `File` and `Vec` variants of readers, instead opting to provide a `from_file` and `from_memory` associated function to create readers from the `File` and `Cursor<Vec<u8>>` implementations of `MediaSource`. 
 * Removes the ReadSeek trait.
 * Added a dependency on `symphonia_core`. This crate has no additional dependencies.
2021-07-01 11:30:02 +01:00
Kyle Simpson
0bb2572deb Chore: Adapt #60, #64 in line with other breaking changes.
This commit undoes #64 (and bumps the library MSRV accordingly), and modifies #60 to match the new `Call` connection handling.

This was tested using `cargo make ready`, and rustc v1.49.0 on `examples/serenity/voice`.
2021-07-01 11:30:01 +01:00
Kyle Simpson
af2347c128 Input: Rename YTDL error variants for Clippy (#55)
This silences a clippy lint around incorrect capitalisation of acronyms, but sis a breaking API change.

This was tested using `cargo make ready`.
2021-07-01 11:30:01 +01:00
Kyle Simpson
27f26ade99 Events: Break out and non-exhaust context body structs (#54)
This PR makes many of the types under `EventContext` separate `#[non_exhaustive]` structs. This makes it more feasible to add further information to connection and packet events as required in future. On this note, driver (re)connection events now include the SSRC supplied by Discord and the domain name which was connected to.

In addition, this fixes global timed events to return a list of all live tracks, and extensively details/documents events at a high level.

This was tested using `cargo make ready`.
2021-07-01 11:30:01 +01:00
Kyle Simpson
1bfee1b989 Driver: Move Bitrate import out of crate root. (#53)
This is a simple organisational change which moves `crate::Bitrate` to `crate::driver::Bitrate` to slightly clean up the crate root.

This has been tested using `cargo make ready`.
2021-07-01 11:30:01 +01:00
Kyle Simpson
1fc3dc2259 Gateway: Add connection timeout, add Config to gateway. (#51)
This change fixes tasks hanging due to rare cases of messages being lost between full Discord reconnections by placing a configurable timeout on the `ConnectionInfo` responses. This is a companion fix to [serenity#1255](https://github.com/serenity-rs/serenity/pull/1255). To make this doable, `Config`s are now used by all versions of `Songbird`/`Call`, and relevant functions are  added to simplify setup with configuration. These are now non-exhaustive, correcting an earlier oversight. For future extensibility, this PR moves the return type of `join`/`join_gateway` into a custom future (no longer leaking flume's `RecvFut` type).

Additionally, this fixes the Makefile's feature sets for driver/gateway-only compilation.

This is a breaking change in:
* the return types of `join`/`join_gateway`
* moving `crate::driver::Config` -> `crate::Config`,
* `Config` and `JoinError` becoming `#[non_breaking]`.

This was tested via `cargo make ready`, and by testing `examples/serenity/voice_receive` with various timeout settings.
2021-07-01 11:30:01 +01:00
Kyle Simpson
f449d4f679 Deps: Bump DiscoRTP version -> 0.3 (#52)
This change increases the version of DiscoRTP, which fixes upstream issues in libpnet and allows additional RTCP types to be added over time without breaking semver. This is a breaking change for users explicitly matching on RTCP packet types, as DiscoRTP is exposed here.

This has been tested using `cargo make ready`.
2021-07-01 11:30:01 +01:00
Kyle Simpson
e59c546503 Gateway: Fix repeat joins on same channel from stalling (#47)
Joining a channel returns a future which fires on receipt of two messages from discord (by locally storing a channel). However, joining this same channel again after a success returns only *one* such message, causing the command to hang until another join fires or the channel is left. This alters internal behaviour to correctly cancel an in-progress connection attempt, or return success with known data if such a connection is present.

This introduces a breaking change on `Call::update_state` to include the target `ChannelId`. The reason for this is that although the `ChannelId` of a target channel was being stored, server admins may move or kick a bot from its voice channel. This changes the true channel, and may accidentally trigger a "double join" elsewhere.

This fix was tested by using an example to have a bot join its channel twice, to do so in a channel it had been moved to, and to move from a channel it had been moved to.
2021-07-01 11:30:01 +01:00
Kyle Simpson
ebff98e873 Release v0.1.8 2021-07-01 10:27:03 +01:00
Jude Southworth
e58cadb2a4 Input: Fix Duration underflow on negative start time (#83) 2021-06-24 17:57:40 +01:00
Kyle Simpson
af79c23b19 Chore: Append comparison link to Changelog 2021-06-14 23:11:14 +01:00
Kyle Simpson
d01bef729d Release v0.1.7 2021-06-14 23:07:10 +01:00
Kyle Simpson
b925309778 Driver: Fix for busy-wait in WS thread. (#78)
Debugging work put forth by JellyWx and jtscuba suggests that this WS thread receive is ending up in a permanent failure loop. This adapts the timeout-less receive such that receive failures are properly propagated.

This was tested using `cargo make ready` and using the `voice_storage` example (although I cannot repro the locking behaviour myself).

Comments in #69 suggest this is fixed -- closes #69.
2021-06-14 12:15:23 +01:00
Vilgot Fredenberg
c97f23ee27 Tracks: Simplify track end event handler (#77) 2021-06-14 11:42:37 +01:00
Kyle Simpson
9e202f602d Release v0.1.6 2021-04-11 13:33:19 +01:00
Kyle Simpson
a88b185676 Deps: Prevent MSRV breakage via spinning_top (#64)
The upstream crate `spinning_top` used newer elements of rustc's std in a patch release, unknowingly bumping its MSRV to 1.49.0. This patch reverts to the older, compatible, version.

This has been tested by manually building `examples/serenity/voice` using rustc v1.48.0.

Closes #62.
2021-04-10 22:56:30 +01:00
Kyle Simpson
24d8da69c0 Driver: Fix crash on .leave() (#63)
Leaving (rather than removing) a call would cause the driver to crash as it would try to use a non-existent connection immediately after it had been invalidated.

This has been tested using a modified `examples/serenity/voice_storage`, felyne, and via `cargo make ready`.
2021-04-10 22:44:17 +01:00
Douman
22214a0f89 Gateway: Introduce Call::current_channel (#60)
* Introduce Call::current_channel

* Add note on channel id
2021-04-10 13:19:59 +01:00
Kyle Simpson
df64ad92e5 Release v0.1.5 2021-03-23 09:09:09 +00:00
Kyle Simpson
f230b41110 Deps: Update async-tungstenite -> 0.13 (#50)
Updates to the latest async-tungstenite version. This was tested by `cargo make ready` and by testing driver/gateway function via `examples/serenity/voice_storage`.
2021-03-23 08:22:38 +00:00
Kyle Simpson
db7994087a Gateway: Allow connection info to be retrieved (#49)
This is a simple addition to allow current connection state to be retrieved *after* establishment, even when using the voice driver.

This has been tested using `cargo make ready`, as it is fairly simple functionality.
2021-03-22 20:50:35 +00:00
Kyle Simpson
a3f86ad34d Driver: Reduce logging level in general (#48)
This change reduces many log levels to debug, particularly where errors are likely to be triggered by undocumented Discord messages or by threads exiting in an unpredictable way. This also reduces the task entry/exit messages to `trace`.

This PR has been tested via `cargo make ready`, and by manually inspecting logs at `debug` and `info` levels running `examples/serenity/voice`.
2021-03-22 19:00:19 +00:00
Kyle Simpson
1fcc8c0eb9 Repo: Organise and document processes and architecture (#43)
* Add Makefile for common contributor tasks

Narrows down a few commands to automatically format when building, and neatly expose testing/benching.

Empty files added to describe contributor guidelines, overall architecture.

* First draft of contributor guidelines

* Simple architecture diagrams

* Add PNG variants of architecture diagrams

Swapping to these because not having Fira Sans installed on a viewing machine leads to terrible kerning.

* Architecture description.

* MD cross-refs.
2021-03-18 20:54:07 +00:00
Kyle Simpson
a9b4cb7715 Prevent mixer thread from waking while inactive (#46)
This change prevents mixer threads from waking every 20ms without an active voice connection. This was leading to unacceptably high CPU usage in cases where users needed to preserve this state between many active connections. Additionally, this modifies the documentation of `Songbird::leave` to emphasise why users would prefer to `remove` their calls.

This was tested by examining the CPU usage in task manager before and after the change was made, using a control of 10k manually created `Driver` instances. After creation is finished, the Drivers no longer saturate a 6-core laptop Intel i7 (while they very much did so before).

Closes #42.
2021-03-14 17:18:24 +00:00
DasEtwas
c488ce3dc9 Fix input source timestamp pre-input argument decimal formatting (#45) 2021-03-13 10:17:26 +00:00
Kyle Simpson
b9a926c125 Break reference cycle in voice storage example (#44)
Changes a stored `Arc` pointer to the call (used to queue up further tracks in response to events) into a `Weak`, as the event handler's strong pointer would keep the Call and Driver objects alive. This would have caused an unintentional resource leak of threads/tasks. This was found by some internal profiling in search of #42.
2021-03-11 22:58:30 +00:00
Kyle Simpson
dd49c5d99f Release v0.1.4 2021-02-10 16:53:20 +00:00
Kyle Simpson
f3f52427ea Events: Add SsrcKnown event
Knowing your own SSRC is useful for handling RTCP packets, which may detail information about *ourselves* rather than another host. In theory, at least: this confirms that Discord just sends ReceiverReports containing your own packet stats.

This would have been better to fit into Driver(Re)Connect, but that would be a breaking change: when this change is made, `SsrcKnown` shall be deprecated.
2021-02-10 14:33:34 +00:00
Kyle Simpson
a40fac3109 Deps: Update async-tungstenite -> 0.12
This is a non-breaking change, since WsError is private.
2021-02-10 14:00:03 +00:00
Kyle Simpson
0e860dc29d Chore: Add missing changelog notes for 0.1.3
It seems like these were accidentally unstaged.
2021-02-10 13:42:00 +00:00
Kyle Simpson
fa9de67ac2 Release v0.1.3 2021-02-04 02:46:05 +00:00
Kyle Simpson
1863d39356 Chore + Deps: Add the log feature to tracing 2021-02-04 02:38:09 +00:00
Kyle Simpson
aaab97511d Library: Add compatibility for legacy Tokio 0.2 (#40)
Adds support to the library for tokio 0.2 backward-compatibility. This should hopefully benefit, and prevent lavalink-rs from being blocked on this feature.

These can be reached using, e.g., `gateway-tokio-02`, `driver-tokio-02`, `serenity-rustls-tokio-02`, and `serenity-native-tokio-02` features.

Naturally, this requires some jiggering about with features and the underlying CI, which has been taken care of. Twilight can't be handled in this way, as their last tokio 0.2 version uses the deprecated Discord Gateway v6.
2021-02-04 02:34:07 +00:00
Kyle Simpson
b2453091e7 Fix: hand off process killing to blocking thread, await all children.
This should make dropping `ChildContainer`s and their parent `Input`s safer in async contexts.

It seems like SIGINT is insufficient to make wait terminate, but SIGKILL suffices. This introduced a new problem, namely that we have to remember and wait on *every* pid we create. This should, hopefully, put the issue of zombie processes to bed for good.
2021-02-01 13:43:26 +00:00