You've already forked RadioPlayer
mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-02-26 13:52:00 +01:00
better cache
This commit is contained in:
@@ -5,6 +5,14 @@ import sys, signal, threading, glob
|
||||
import libcache
|
||||
from modules import *
|
||||
|
||||
def prefetch(path):
|
||||
if os.name == "nt": return
|
||||
with open(path, "rb") as f:
|
||||
fd = f.fileno()
|
||||
os.posix_fadvise(fd, 0, 0, os.POSIX_FADV_SEQUENTIAL)
|
||||
os.posix_fadvise(fd, 0, 0, os.POSIX_FADV_NOREUSE)
|
||||
os.posix_fadvise(fd, 0, 0, os.POSIX_FADV_WILLNEED)
|
||||
|
||||
simple_modules: list[PlayerModule] = []
|
||||
playlist_modifier_modules: list[PlaylistModifierModule] = []
|
||||
playlist_advisor: PlaylistAdvisor | None = None
|
||||
@@ -148,6 +156,8 @@ def play_playlist(playlist_path: Path, starting_index: int = 0):
|
||||
|
||||
for module in playlist_modifier_modules: playlist = module.modify(global_args, playlist) or playlist
|
||||
|
||||
prefetch(playlist[0])
|
||||
|
||||
[mod.on_new_playlist(playlist) for mod in simple_modules + [active_modifier] if mod] # one liner'd everything
|
||||
|
||||
return_pending = False
|
||||
@@ -203,6 +213,7 @@ def play_playlist(playlist_path: Path, starting_index: int = 0):
|
||||
|
||||
i += 1
|
||||
if not extend: song_i += 1
|
||||
prefetch(playlist[song_i % len(playlist)])
|
||||
|
||||
def main():
|
||||
logger.info("Core is starting, loading modules")
|
||||
|
||||
Reference in New Issue
Block a user