0
1
mirror of https://github.com/radio95-rnt/RadioPlayer.git synced 2026-02-26 21:53:54 +01:00

better cache

This commit is contained in:
KubaPro010
2025-11-06 18:56:17 +01:00
parent 2d5d899c41
commit 2bc7c557db

View File

@@ -13,14 +13,14 @@ class Module(PlayerModule):
next = self.playlist[index]
else:
next = self.playlist[index+1]
def prefetch(path):
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)
with open(track.path.absolute(), "rb") as f:
os.posix_fadvise(f.fileno(), 0, 0, os.POSIX_FADV_SEQUENTIAL)
os.posix_fadvise(f.fileno(), 0, 0, os.POSIX_FADV_NOREUSE)
os.posix_fadvise(f.fileno(), 0, 0, os.POSIX_FADV_WILLNEED)
with open(next, "rb") as f:
os.posix_fadvise(f.fileno(), 0, 0, os.POSIX_FADV_SEQUENTIAL)
os.posix_fadvise(f.fileno(), 0, 0, os.POSIX_FADV_NOREUSE)
os.posix_fadvise(f.fileno(), 0, 0, os.POSIX_FADV_WILLNEED)
prefetch(track.path.absolute())
prefetch(next)
module = Module()