Commit Graph

229 Commits

Author SHA1 Message Date
Kyle Simpson
169d527e54 chore(deps): Update rubato -> 0.15 2024-07-08 11:49:46 +01:00
Kyle Simpson
93f2e0b636 chore(deps): Update ringbuf -> 0.4 2024-07-08 11:46:08 +01:00
Erk
8e92c49b2b feat(input): Support HLS streams (#242)
This patch adds support for yt-dl streams with the protocol m3u8_native which includes sites like Soundcloud.

Closes: #241
2024-07-07 19:37:25 +02:00
Erk
2e683380fa fix(conn): Some operating systems does not allow 0 recv buffer (#243)
This will cause FreeBSD to fail setting up the socket. It may also be true of some other operating systems, but these are the ones I have been able to test.

It works on Windows and Linux.
2024-07-07 16:29:26 +01:00
Gnome!
5bbe80f20c Fix clippy warnings (#236) 2024-04-02 08:57:47 +01:00
Alvaro
1d5b25965b Make DisposalThread reachable (#235)
The `Config` object provided to `Call`s and `Driver`s allows setting a `DisposalThread`, but since it is unreachable from outside the crate, the only way to properly set it is using a `Songbird` instance, which may not be adequate for all use cases. This PR just makes `DisposalThread` reachable from the outside.
2024-03-30 12:14:24 +00:00
Kyle Simpson
a5d9b58e94 Driver: Fix multiple disconnect events on leave (#233)
Fixes behaviour where a Driver which was asked to leave an active call would receive the disconnect event several times: once when we started the disconnect, and once again when Discord killed the WS client.
2024-03-19 08:28:56 +00:00
Kyle Simpson
58f5c89f92 Driver: Fix slot length check on packet passthrough (#231)
Corrects a buffer length check identified in #230 which was reversed,
such that overly large Opus packets would panic on a subsequent
`write_all`.
2024-03-04 08:59:25 +00:00
Kyle Simpson
8f60cf573e Chore: Fix timestamp in \git cliff -u\ 2024-02-29 23:11:39 +00:00
Kyle Simpson
b07e9b4178 Chore: Release v0.4.1 2024-02-29 23:07:04 +00:00
Kyle Simpson
cdb2df69c7 Chore: Initial git-cliff config
A little hacked together, but it is close enough to our primary format.
Will still require manual sorting of commits by function since we're not
doing conventional commits, but its lower friction for filling out
github usernames etc.
2024-02-29 22:39:22 +00:00
Kyle Simpson
4d67a73851 Chore: update tokio-tungstenite 2024-02-24 20:58:27 +00:00
Kyle Simpson
873fb68726 Move empty packet check to also cover 48kHz audio (#225)
Previously, we were only skipping zero-packet frames when we needed to
resample because the source sampling rate was not set to 48kHz. This
check should have also been applied in the case that a packet did not
need a resampler to be built.

Fixes #224.
2024-02-24 19:46:15 +00:00
Kyle Simpson
087e5f2292 Driver: Fix transition to Live on connect (#222)
This PR fixes a case where a call which changes channel or gracefully
reconnects would have been stuck in the Idle state. SetConn events will
now allow a transition straight back to Live if any tracks are found
attached to a mixer.
2024-01-24 09:30:50 +00:00
Gnome!
1b98c30746 Fix clippy warnings (#214)
* Fix clippy warnings

* Fix implicitly elided lifetimes
2024-01-03 16:45:23 +00:00
Cycle Five
d681b71b1f Input: Add ytdl search (#210)
* Add ytdl search

* fix fmt

* Remove compose, add tests, return AuxMetadata

* fix parsing of AuxMetadata and better test

* Fix playability of `YoutubeDl::new_search`

Refactors such that parsing of (ND)JSON is handled in only one location
now, which allows us to greatly simplify the actual `search` method. The
main change is that any `new_search` is now instantly playable.

---------

Co-authored-by: Kyle Simpson <kyleandrew.simpson@gmail.com>
2023-12-12 08:28:13 +00:00
Kyle Simpson
873aeae16a Chore: Release v0.4.0 2023-11-27 22:22:19 +00:00
Kyle Simpson
22ceb175b6 Chore: Fixup examples, bump version pre-push
Takes the chance to bring shared deps into the example workspace while we're here. Release notes, tags etc will follow in time.
2023-11-27 21:16:53 +00:00
Kane Wang
1ec569baf2 Driver: Remove RwLock from ThreadPool (#206) 2023-11-27 20:03:57 +00:00
Kyle Simpson
1f616daee6 Chore: Release v0.4.0-rc-2 2023-11-23 12:21:33 +00:00
Kyle Simpson
cc53312569 Deps: Re-disable default Serenity features 2023-11-23 12:01:24 +00:00
Kyle Simpson
38096163ab Chore: Release v0.4.0-rc 2023-11-20 02:53:33 +00:00
Kyle Simpson
91640f6c86 Chore: Cleanup clippy lints 2023-11-20 00:03:54 +00:00
Kyle Simpson
1487da175c Chore: Upgrade serenity to 0.12.0-rc 2023-11-20 00:03:53 +00:00
Kyle Simpson
0ef0e4fc82 Chore: Bump DiscoRTP version 2023-11-20 00:02:58 +00:00
Gnome!
3d307aaa8b Fix clippy pedantic warnings (#204) 2023-11-20 00:02:58 +00:00
Gnome!
63d48ee597 Update simd-json to 0.13 (#203) 2023-11-20 00:02:58 +00:00
Gnome!
509743fd40 Fix compiling with latest serenity (#199) 2023-11-20 00:02:58 +00:00
Kyle Simpson
935171df4f Driver: Correct buffer instantiation for Rubato
I had slightly misread the changes from 0.12->0.14, so buffers were
not correctly instantiated for resampling.
2023-11-20 00:02:58 +00:00
Kyle Simpson
67b3b3ec50 Chore: Update Rubato -> 0.14.1 2023-11-20 00:02:58 +00:00
Kyle Simpson
4220c1ffe5 Chore: Update (most) dependencies
Updates all bar rubato, which I fear may take a little more work...
2023-11-20 00:02:58 +00:00
Kyle Simpson
6f801563e5 Chore: Rust 1.72.0 Clippy lints, adjust MSRV
MSRV was bumped by serenity-next, and so we too must follow suit.
2023-11-20 00:02:58 +00:00
Sebbl0508
77a9b4626c Driver: Replace xsalsa20poly1305 with crypto_secretbox (#198)
As of v0.9.1, `xsalsa20poly1305` has been deprecated. This is a mostly seamless replacement, as it appears to be the same crate authors / code / etc.

Co-authored-by: Kyle Simpson <kyleandrew.simpson@gmail.com>
2023-11-20 00:02:57 +00:00
Jonathan
5ddc8f4448 Chore(ci): Update rust, cargo and cache actions (#177)
* chore(ci): Update rust setup and cache action
* chore(ci): Remove legacy-tokio from test matrix

This was removed as it doesn't seem to be used any more.
2023-11-20 00:02:57 +00:00
Jonathan
4eadeb6834 chore(docs): Update rust setup action and cache (#176)
This PR changes the following things in the docs workflow:
- Move from the deprecated actions-rs action to the maintained alternative of dtolnay https://github.com/dtolnay/rust-toolchain
- Instead of manually defining the cache paths and the cache keys, I moved to an action that handles this for us: https://github.com/Swatinem/rust-cache
- As github decided at some point that the generated `GITHUB_TOKEN` secret will only have read-only permissions (for new repos), unless you tell them to be different, I added the `permissions` key to the job. This will not affect this repository, but will affect e.g. new forks (the workflow will not throw an permissions error any more - Read more here: https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/ )
2023-11-20 00:02:57 +00:00
Jonathan
841224ee7a chore(workflows): Update checkout action to v3 (#175)
This change was done as the v2 version still used the node v12 runtime.
This runtime is deprecated by github. There are no other breaking
changes done by the action. With the update to v3 now node v16 is used
as runtime.

You can read more about the changes from v2 to v3 here:
https://github.com/actions/checkout/releases/tag/v3.0.0
2023-11-20 00:02:57 +00:00
Kyle Simpson
9ab5be8c9f Driver: Retune threadpool keepalive time 2023-11-20 00:02:57 +00:00
Kyle Simpson
c55a3130d6 Chore: Update test URL for playlist.
One of our tests had begun to fail on account of a change Youtube-side.
2023-11-20 00:02:57 +00:00
Kyle Simpson
019ac27a85 Driver: Don't trim recv_buffer on MacOS
This should fix #193 -- it seems that a zero-size recv buffer is an invalid argument as far as darwin is concerned.

Tested with `cargo make ready`.
2023-11-20 00:02:57 +00:00
Kyle Simpson
02c9812c3e Driver: Downgrade failed scheduler message delivery to info 2023-11-20 00:02:57 +00:00
Kyle Simpson
77e3916bdc Driver: Fix scheduler crash after task closure
A removed audio task could still have one or more driver messages left in its queue, leading to a crash when the id->mixer lookup failed. This removes an unwrap which is invalid under these assumptions and includes an extra cleanup measure for message forwarders under the same circumstances.

This was tested using `cargo make ready`.
2023-11-20 00:02:57 +00:00
Max Campbell
c976d50cc5 Input: Add HTTP Status Code Checks (#190)
`HttpRequest`s will now return an `AudioStreamError::Fail` on receipt of a non-2xx status code from a server. This has the advantage of making it clearer *why* a failure occurred rather than leaving users to piece the truth together from a Symphonia parsing error.

Closes #184.
2023-11-20 00:02:57 +00:00
Kyle Simpson
9fa063ff0e Chore: Clippy fixes to match new MSRV. 2023-11-20 00:02:57 +00:00
Kyle Simpson
1bf17d128e Chore: Update dependencies, MSRV.
Tested using `cargo make ready`.
2023-11-20 00:02:57 +00:00
Kyle Simpson
3daf11f5d1 Driver: Implement audio scheduler (#179)
This PR implements a custom scheduler for audio threads, which reduces thread use and (often) memory consumption.

To save threads and memory (e.g., packet buffer allocations), Songbird parks Mixer tasks which do not have any live Tracks.
These are now all co-located on a single async 'Idle' task.
This task is responsible for managing UDP keepalive messages for each task, maintaining event state, and executing any Mixer task messages.
Whenever any message arrives which adds a `Track`, the mixer task is moved to a live thread.
The Idle task inspects task counts and execution time on each thread, choosing the first live thread with room, and creating a new one if needed.

Each live thread is responsible for running as many live mixers as it can in a single tick every 20ms: this currently defaults to 16 mixers per thread, but is user-configurable.
A live thread also stores RTP packet blocks to be written into by each sub-task.
Each live thread has a conservative limit of 18ms that it will aim to stay under: if all work takes longer than this, it will offload the task with the highest mixing cost once per tick onto another (possibly new) live worker thread.
2023-11-20 00:02:57 +00:00
Kyle Simpson
a5f7d3f488 Chore: Update dependencies.
Updates simd-json -> 0.8, socket2 -> 0.5.

Tested using `cargo make ready`.
2023-11-20 00:02:56 +00:00
Erk
500d679ae5 Fix: Move WS error handling (#174)
Moves all WS handling of unexpected payloads into the stream to prevent code duplication.

This also prevents non-{Hello,Resumed,Ready} messages from causing a handshake failure, as it seems Discord do not prevent such messages from appearing.

---------

Co-authored-by: Kyle Simpson <kyleandrew.simpson@gmail.com>
2023-11-20 00:02:56 +00:00
0/0
4d0c1c030d Gateway: Fix serenity breaking changes (#173)
Fix issues caused by serenity-rs/serenity#2372 and serenity-rs/serenity#2380.

Additionally, this Boxes the TrySendError from Serenity at Clippy's behest (causing a ~330B Result type).

---------

Co-authored-by: Kyle Simpson <kyleandrew.simpson@gmail.com>
2023-11-20 00:02:56 +00:00
Alex M. M
7f519d0503 Chore: Release v0.3.2 2023-11-20 00:02:56 +00:00
Erk
c73f4988c8 fix(ws): Songbird would fail if it could not deserialize ws payload. (#170)
Receiving a new opcode while connecting to a voice channel was causing the connection to fail, while this was handled correctly elsewhere. Unfortunately, Discord added such a payload during every connection.

This PR moves the logging and conversion to no-op (and log) to catch both locations.
2023-11-20 00:02:56 +00:00