Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Oct 23, 2024
2 parents ebfeae1 + 44e4c25 commit 9cc0d25
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions music_assistant/server/providers/snapcast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,12 +559,17 @@ async def _streamer() -> None:
self.mass.players.update(player_id)
self._set_childs_state(player_id)
finally:
with suppress(TypeError, KeyError, AttributeError):
await self._snapserver.stream_remove_stream(stream.identifier)
await self._delete_current_snapstream(stream, media)

# start streaming the queue (pcm) audio in a background task
self._stream_tasks[player_id] = asyncio.create_task(_streamer())

async def _delete_current_snapstream(self, stream: Snapstream, media: PlayerMedia) -> None:
with suppress(TypeError, KeyError, AttributeError):
if media.duration < 5:
await asyncio.sleep(5)
await self._snapserver.stream_remove_stream(stream.identifier)

def _get_snapgroup(self, player_id: str) -> Snapgroup:
"""Get snapcast group for given player_id."""
snap_client_id = self._get_snapclient_id(player_id)
Expand Down Expand Up @@ -628,7 +633,9 @@ async def _create_default_stream(self) -> None:
"""Create new stream on snapcast server named default case not exist."""
all_streams = {stream.name for stream in self._snapserver.streams}
if "default" not in all_streams:
await self._snapserver.stream_add_stream("pipe:///tmp/snapfifo?name=default")
await self._snapserver.stream_add_stream(
"pipe:///tmp/snapfifo?name=default&sampleformat=48000:16:2"
)

def _set_childs_state(self, player_id: str) -> None:
"""Set the state of the child`s of the player."""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ server = [
"python-slugify==8.0.4",
"mashumaro==3.13.1",
"memory-tempfile==2.2.3",
"music-assistant-frontend==2.9.9",
"music-assistant-frontend==v2.9.10",
"pillow==11.0.0",
"unidecode==1.3.8",
"xmltodict==0.13.0",
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ hass-client==1.2.0
ifaddr==0.2.0
mashumaro==3.13.1
memory-tempfile==2.2.3
music-assistant-frontend==2.9.9
music-assistant-frontend==v2.9.10
orjson==3.10.7
pillow==11.0.0
pkce==1.0.3
Expand Down

0 comments on commit 9cc0d25

Please sign in to comment.