0
1
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:
KubaPro010
2025-11-06 19:16:01 +01:00
parent 2bc7c557db
commit 7a1fe3c73f
2 changed files with 11 additions and 26 deletions

View File

@@ -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")