Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose an AsyncReadOnlySource #256

Merged
merged 1 commit into from
Sep 28, 2024
Merged

Conversation

rhgndf
Copy link
Contributor

@rhgndf rhgndf commented Sep 28, 2024

HlsStream already wraps any struct with the AsyncRead trait into an AsyncMediaSource, so rename it to AsyncReadOnlySource and expose it in the crate. This is very similar to the sync version symphonia_core::io::ReadOnlySource.

A possible use case would be streaming PCM samples to a discord voice channel:

let (audio_receiver, mut audio_sender) = tokio::io::simplex(76800);
let audio_stream = AsyncAdapterStream::new(
    Box::new(AsyncReadOnlySource::new(audio_receiver)),
    76800,
);
let adapter = RawAdapter::new(audio_stream, 48000, 2);
let _ = handler.play_input(adapter.into());

Unfortunately, doing cargo make ready results in a lot of errors and I am not familiar enough with the codebase to add docs or fix them. However, since this is mostly shuffling around existing code, there shouldn't be any additional errors.

@rhgndf rhgndf changed the title Expose a AsyncReadOnlySource Expose an AsyncReadOnlySource Sep 28, 2024
Copy link
Member

@FelixMcFelix FelixMcFelix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first glance this looks reasonable enough to me; thanks for putting it together. AsyncReadOnlySource is a useful utility to expose.

One minor nit/question. Otherwise, I would ignore the CI failure on missing documentation. Those are benchmark-harness specific methods which should be marked s.t. the missing_docs lint skips them. I'm not sure what's changed in nightly to cause this, but I'll tackle that shortly.

Makefile.toml Outdated
@@ -30,7 +30,7 @@ command = "cargo"
dependencies = ["format"]

[tasks.build-variants]
dependencies = ["build", "build-gateway", "build-driver", "build-simd"]
dependencies = ["build", "build-gateway", "build-driver"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I ask why you've done this? async-simd is still supported as of 0.4.x.

Copy link
Contributor Author

@rhgndf rhgndf Sep 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes some tests run when rebased on top of serenity-next. Probably due to this commit:

05cf36b#diff-9375fd04332c86472d7be397ef09428cb86babd8826880a5835bd1d1c1bdbc08L11

I have removed the commit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the support is removed from next but still present here. Thanks for fixing that up.

Copy link
Member

@FelixMcFelix FelixMcFelix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks; happy that this is non-breaking since most of the HlsStream internals are private. Feel free to merge when you're ready!

EDIT: D'oh, I'll pull it in.

@FelixMcFelix FelixMcFelix merged commit fe9b156 into serenity-rs:current Sep 28, 2024
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants