From: Marcel van der Veldt Date: Fri, 5 Apr 2024 22:43:41 +0000 (+0200) Subject: extend pipe buffer size on linux X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=ddaf7de9a85e7759288335612b8ae30e682d9727;p=music-assistant-server.git extend pipe buffer size on linux --- 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,