perf: Use PlayerMode.lowLatency for AudioPools#1963
Conversation
…get duration of audio on pool creation, and timers to release the player when audio pool player has finished.
|
Not sure why those tests fail. I was testing this functionality on a physical Android device. |
|
@gnarhard thank you for contributing! Personally I think this is more a workaround than a real solution. The issue is not only with pools, but with the player itself, so that we cannot determine the duration in LLM (Low latency mode) for Android. Initializing a second source just to get the duration destroy all the arguments using LLM in the first place, like less initialization time. One should rather create a tool determining the duration of a source without need to fully initialize / download it (this is probably not scope of this library) e.g. via a bridge thtough ffmpeg or sth. What I see is the lacking customazibility of the pool, to set the LLM. You may can focus only on that aspect in this PR? |
…t use LLM on audio pool players. Use FFprobeKit to retrieve the file's duration to avoid creating a temporary player.
|
@Gustl22 My pleasure! I incorporated all of your feedback into the latest commit. Using FFprobeKit is a much more performant method of retrieving the audio file's duration so that was a good call. Since AudioPools are designed to cache many short audio files for rapid playback, I defaulted the Regarding the failing tests, it looks like ffmpeg_kit_flutter_new wants a minimum deployment target of 14 for iOS and Android wants a minSdkVersion of 24. I'm unfamiliar with how these values should be updated with packages so please let me know how you'd like this updated. |
|
@Gustl22 another observation: it looks like ffmpeg forces us to use iOS <=18.6 simulators. That really sucks imo. What is your direction here? |
|
@Gustl22 sorry to blow you up, but I've been doing more testing over here on my iPhone 15 and I'm getting tons of these errors intermittently from getDuration: I did a quick search of STH, but I'm not sure what you're referring to. Maybe just passing in the duration into create() might be the most reliable solution for now... |
|
Yes, I did not mean to include I am happy to include the changes for changing the player mode though. |
|
@Gustl22 I see what you mean now. I'll edit those changes and push it up. Unfortunately with soloud I was unable to play multiple players simultaneously. I'd definitely jump on pulling inspiration from it if my Swift and Java skills were better. |
| final int maxPlayers; | ||
|
|
||
| /// Whether the players in this pool use low latency mode. | ||
| final bool usesLowLatencyMode; |
There was a problem hiding this comment.
Would it be okay to set an playerMode object instead of just setting just the bool? This would give us more flexibility in the future, if we decide to add more options to it.
Description
Use PlayerMode.lowLatency for AudioPool, a temporary player to get duration of audio on pool creation, and timers to release the player when audio pool player has finished.
Checklist
fix:,feat:,refactor:,docs:,chore:,test:,ci:etc).///, where necessary.Breaking Change
Related Issues