From ddaf7de9a85e7759288335612b8ae30e682d9727 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Sat, 6 Apr 2024 00:43:41 +0200 Subject: [PATCH] extend pipe buffer size on linux --- .../server/providers/airplay/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/music_assistant/server/providers/airplay/__init__.py b/music_assistant/server/providers/airplay/__init__.py index 90d065d0..3cc9acec 100644 --- a/music_assistant/server/providers/airplay/__init__.py +++ b/music_assistant/server/providers/airplay/__init__.py @@ -3,6 +3,7 @@ from __future__ import annotations import asyncio +import fcntl import logging import os import platform @@ -254,7 +255,17 @@ class AirplayStream: # one could argue that the intermediate ffmpeg towards cliraop is not needed # when there are no player specific filters or extras but in this case # ffmpeg serves as a small buffer towards the realtime cliraop streamer - read, write = os.pipe() + + # create pipes to interconnect ffmpeg with cliraop + def create_pipes() -> tuple[int, int]: + read, write = os.pipe() + if platform.system() == "Linux": + # extend the pipe buffer a bit for smoother playback + fcntl.fcntl(read, 1031, 1000000) + fcntl.fcntl(write, 1031, 1000000) + return (read, write) + + read, write = await asyncio.to_thread(create_pipes) ffmpeg_args = get_ffmpeg_args( input_format=self.input_format, -- 2.34.1