Skip to content

Commit 5b26f1f

Browse files
committed
Add optional cache data to streamdetails
1 parent b92e49c commit 5b26f1f

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

music_assistant_models/enums.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ class EventType(StrEnum):
379379
PLAYER_ADDED = "player_added"
380380
PLAYER_UPDATED = "player_updated"
381381
PLAYER_REMOVED = "player_removed"
382-
PLAYER_SETTINGS_UPDATED = "player_settings_updated"
382+
PLAYER_CONFIG_UPDATED = "player_config_updated"
383383
QUEUE_ADDED = "queue_added"
384384
QUEUE_UPDATED = "queue_updated"
385385
QUEUE_ITEMS_UPDATED = "queue_items_updated"
@@ -390,7 +390,6 @@ class EventType(StrEnum):
390390
MEDIA_ITEM_UPDATED = "media_item_updated"
391391
MEDIA_ITEM_DELETED = "media_item_deleted"
392392
PROVIDERS_UPDATED = "providers_updated"
393-
PLAYER_CONFIG_UPDATED = "player_config_updated"
394393
SYNC_TASKS_UPDATED = "sync_tasks_updated"
395394
AUTH_SESSION = "auth_session"
396395
UNKNOWN = "unknown"
@@ -526,6 +525,9 @@ class StreamType(StrEnum):
526525
# other_ffmpeg: any other ffmpeg compatible input stream (used together with extra_input_args)
527526
OTHER_FFMPEG = "other_ffmpeg"
528527

528+
# cache_file: (temporary) cached file - path provided in path
529+
CACHE_FILE = "cache_file"
530+
529531
# custom: custom (bytes) stream - provided by an (async) generator
530532
CUSTOM = "custom"
531533

music_assistant_models/streamdetails.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,19 @@ class StreamDetails(DataClassDictMixin):
103103
repr=False,
104104
)
105105

106+
# enable_cache: bool to indicate that the audio be be temporary cached
107+
# this increases performance (especially while seeking) and reduces network
108+
# usage for streams that are played multiple times. For some (slow) streams
109+
# its even required to prevent buffering issues.
110+
# leave/set to None to let the core decide based on the stream type.
111+
# True to enforce caching, False to disable caching.
112+
enable_cache: bool | None = field(
113+
default=None,
114+
compare=False,
115+
metadata=field_options(serialize="omit", deserialize=pass_through),
116+
repr=False,
117+
)
118+
106119
#############################################################################
107120
# the fields below will be set/controlled by the streamcontroller #
108121
#############################################################################
@@ -150,6 +163,12 @@ class StreamDetails(DataClassDictMixin):
150163
metadata=field_options(serialize="omit", deserialize=pass_through),
151164
repr=False,
152165
)
166+
cache: Any = field(
167+
default=None,
168+
compare=False,
169+
metadata=field_options(serialize="omit", deserialize=pass_through),
170+
repr=False,
171+
)
153172

154173
def __str__(self) -> str:
155174
"""Return pretty printable string of object."""

0 commit comments

Comments
 (0)