-
Notifications
You must be signed in to change notification settings - Fork 8
Audio caching #19
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
base: spotty
Are you sure you want to change the base?
Audio caching #19
Conversation
eaba119
to
6a13d6b
Compare
Thanks for this PR! I understand this is mostly a restore/backport of the code upstream? Could you please also restore https://github.com/librespot-org/librespot/blob/dev/src/main.rs#L1063-L1068? |
Done. |
Looking into this again I fear more work is required: Could you please look into restoring the |
Do you think a shared audio cache is actually useful/necessary or did you just ask because librespot has it? Because personally I don't think a per-account cache is that much of an issue. If you use 1 GB of cache, like the official Spotify client, that would be 4 GB of cache. Not that much for a media server, even if it's a Pi. It becomes even less of an issue if you reduce the cache size. Currently we have no caching and it's mostly fine. I wanted the cache feature because I found it wasteful and annoying that it would stream the files again when I play the same playlist over and over again, 100 MB cache would already be enough to prevent that. In any case, I'm happy to port the shared audio cache if you think it's a desirable feature. |
Let's think about the UX: are we going to allow the user to define the amount of disk space to use? Or will this be a hard-coded value and a user selectable toggle on/off? That's probably more important to understand whether the question about shared caches or not. In any case we'd have to find a way to get the free disk space. I haven't found an OS agnostic way to get free disk space information in Perl. We might have to write something ourselves to make sure we don't use more than is available. People will be asking "how much are you using?". What will be the response? Even if we hard-code to a defensive 1GB, this could be too much for some installations (some people still believe formatting only a 2GB partition on their 64GB SD card will make things more stable). Having a shared cache would simplify this calculation. Because we'd know 1GB is 1GB. But with individual caches it's might x times 1GB. Edit: just found https://metacpan.org/pod/Filesys::DfPortable - but it would need to be compiled for each supported platform... Maybe shelling out to run |
So the UI I had in mind would look something like this: Informing the user about the size of their disk (or I did include the path to the cache in my mockup because that would be super helpful to set up appropriate volumes. That made me realize another reason to separate the credential cache from the audio cache though: You want the credential cache to be persistent, but you might want to put the audio cache on a ramdisk to reduce disk churn. So yeah, I'll go ahead and split up the paths. |
That setting actually looks amazingly simple and instructive! I almost don't know what I was thinking 😁. Except that I don't like the line with the cache folder. Could this be wrapped in a "info" bubble popup? Splitting the paths comes with a draw back: if you wanted to make this user configurable, there would be yet another potentially confusing preference on an already pretty busy and confusing screen... |
This enables optional audio caching in Spotty.
Spotty has two command line options,
--disable-audio-cache
and--enable-audio-cache
.--disable-audio-cache
is a no-op, provided only for compatibility with librespot.--enable-audio-cache
also did nothing until now. This PR changes that, it will now be honored and initializes the audio cache. The cache is then used in the same way as if in librespot the--disable-audio-cache
option wasn't given.This PR also restores the
--cache-size-limit
command line option that limits the total size of the cache by deleting older files whenever a new cache file is added.