-
Notifications
You must be signed in to change notification settings - Fork 154
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
An async version of Symphonia #27
Comments
Hey @GeoffClements, I think there are two ways Symphonia could be made async:
Solution 1 has a lot of problems, but I think solution 2 makes the most sense, and I believe this is what you're proposing. In that case, I don't think there should be any problem so long as the I'd be happy to merge this async support into Symphonia so long as it's an optional feature with as minimal dependencies as possible. Unfortunately, my async experience is limited, but I'd be happy to answer any questions re: Symphonia itself. |
Hi, thanks for the feedback.
TBH I was thinking of something along the lines of what lewton has done which is to create async implementations for existing structs. I notice that Symphonia makes frequent use of trait objects and I'll have to work through the implications of this regarding async. So having an AsyncRead implementation of I think that would be the minimum for an async implementation however it may also be useful to add futures for any computational intensive operations. This big downside to this approach is code duplication between non-async and async methods, I've not yet thought of an easy way around this.
OK thanks. I understand the drive to minimise dependencies. Although Futures have now hit the standard library they have done so in a very limited manner so a dependency on the Futures crate is almost inevitable, however it will be behind an async feature option. Overall I think it may be better to have an async branch as this may take some time to get right (if it's possible at all!). I'm still reading through the Symphonia codebase and my knowledge is cursory at best so I need to get myself into a position where I can start experimenting with async. *Edit to fix a typo |
hi @pdeljanov - I am trying to re on-board with Rust echo system which I worked a few years ago. Things have changed for the better and hence the interest. I am not familiar with Symphonia, but let's say we want to go with Option 1, what are small milestones we want to get to. I would imagine a huge PR is never welcomed. |
Hi vishalcjha, I did make a start at this to see what the obstacles might be. Unfortunately life got in the way and I haven't coded for some time. I did make some headway though until I hit a major problem that I was still working through and, sadly, now cannot remember exactly what it was but it was to do with the Rust compiler and looked like it was non-trivial. I found the async-std library to be most useful as it mirrors (more or less) Rust's std library. I used maybe-async to conditionally compile the code and async-trait to drastically reduce code duplication. If you are interested I can push my local repo onto my Github repo so you can have a look but please remember that this code is a work-in-progress and does not compile, |
Sure @GeoffClements . I was thinking to use async-std. Push what you have and I can give it a try too. What I wanted before making start is small milestones that can be trackable. But if the plan is to make all async at a go, can do that too. Not sure if that code would be easy to test and merge then. |
Sorry for the delay, my repo is here. TBH I'm not sure how realistic it will be to have a series of small working PRs as async code is a complete paradigm shift from sync code. I think the best course will be to have an async branch as I have done in my repo and do all the work there. I suspect keeping this branch long-term may be a better option as clients of Symphonia will either want async or not. In any case I will defer to someone more experienced in these things than I am. Best wishes. |
Hi @GeoffClements and @vishalcjha, I took a look at what's already implemented and wanted to chime in with a few of my thoughts. The first thing that sticks out to me is that you are making
I think the work that needs to be done is as follows:
For now, I'd like to keep all this work on a branch as we prototype a solution. I believe async is mostly a niche use-case (WASM target?) for Symphonia all things considered so I'd want to keep the maintenance burden low. Another interesting solution that would be less involved is an adapter that implements a |
Another option would be to build APIs that can resume after |
Any progress of this issue? It should be a need. Like fetching network audio file and instant play without download it entirely. At lease return the |
Hi, Firstly, the functions that usually call Here's where it get's hairy though - all implementations of In general though, it feels like an |
Hi, I've made Symphonia async compatible in this fork (forked from the dev-0.6 branch). It seems to work, I've tested the library with a tweaked version of librespot. Performance wise, it looks the same as before on my machine (according to benchtest.py). In my opinion, it's not possible (or very hard) to use To solve the problem, I've made "everything" async (except functions that only interact with memory buffers) and the sync APIs just call the async ones. The sync APIs aren't even using an executor, they use The fork needs some clean-up but the main things are there. |
Hello!,
I'm currently investigating the use of Symphonia as a dependency in a pet project of my own. Trouble is, my project is based on Tokio and Futures so I'm working out if I can make Symphonia async. Is there any interest in this with the Symphonia devs? I'm considering adding an "async" feature which will not be default; I believe that the async code can be added without changing the current source, i.e. by just adding new source enabled by the async feature although I need to complete my investigation before being sure.
The text was updated successfully, but these errors were encountered: