Snap.Net icon indicating copy to clipboard operation
Snap.Net copied to clipboard

[proposal]: Extend Broadcast-Functionality to Android and/or Web

Open YeonV opened this issue 3 years ago • 14 comments

The Broadcast-Functionality is AWESOME!!!

would be nice to have it also available on Android and/or Web:

Android: https://developer.android.com/guide/topics/media/av-capture Web: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia

Example of WebAudio including input device selection: https://github.com/YeonV/wled-manager/blob/v0.0.9/renderer/components/AudioContainer.jsx#L41-L65

YeonV avatar Nov 03 '21 15:11 YeonV

Hi!

Web is out of the scope of this project unfortunately - Snap.Net only runs on Windows, Android and iOS for the moment. Snapcast itself does have a web implementation though (https://github.com/badaix/snapweb), it might be worth opening a feature request there :)

Broadcasting for android is already on my todo-list! See https://github.com/stijnvdb88/Snap.Net/issues/7

stijnvdb88 avatar Nov 03 '21 16:11 stijnvdb88

Update: this feature is mostly working now, just a few kinks to iron out. Please have a quick look and let me know if it's all working as expected!

https://github.com/stijnvdb88/Snap.Net/releases/tag/v0.25.0.1

The broadcasting feature has 2 major caveats to be aware of:

  • it may crash if another application is already broadcasting (if you've got Snap.Net running on your PC with broadcasting enabled, disable it!)
  • some applications such as Spotify explicitly disallow recording by third party apps, which means audio from apps like that can not be broadcast at all: https://developer.android.com/guide/topics/media/av-capture https://developer.android.com/reference/android/media/AudioAttributes#ALLOW_CAPTURE_BY_NONE

stijnvdb88 avatar Nov 05 '21 10:11 stijnvdb88

Just got around to test this out, and it works really well!
I'm having some trouble with my Snapcast server, at some point it stops accepting broadcast streams (the stream stays idle and nothing is transmitted to the clients), and this caused some issues with the app too.
Starting to broadcast "worked" (snapserver didn't play anything, but that was to be expected), however when trying to stop the broadcast the app got stuck, but didn't crash.

Here's a picture of the frozen app: Screenshot_20211113-215831_Snap Net

You can still see the ripple effect from pressing the "Stop Broadcast" button, the ripple never disappeared until force-closing the app through Android settings.

The "Stop" button inside the persistent notification also didn't do anything :)

Aside from that, everything worked great!
Both media and microphone broadcast worked, and you can even mute the music volume on the device and it still broadcasts playing music, etc. (on Android 11 at least).

Given that the device's music/media volume doesn't affect the volume of the broadcast, it would be nice to have a way to manually control that volume.
One way would be to add the broadcast volume as a "Cast" audio stream, like other apps are doing it (e.g. when connected to YouTube TV, etc.). This would offer easy and native volume control, hopefully without too much work :)

Anyway, thanks a ton for your efforts!
If there's anything else you want me to test, just tell me :D

Chaphasilor avatar Nov 13 '21 21:11 Chaphasilor

Thanks! That issue with the server is new to me - you're saying it randomly occurs after x amount of time? Do you see the same/similar when you use the Snap.Net broadcast feature? Next time it happens you can also try connecting manually through the Snap.Net.Broadcast.exe command line app, it might spit out some useful errors (be sure to close/disconnect all broadcast clients first though, multiple broadcasting clients will definitely make it go haywire)

stijnvdb88 avatar Nov 14 '21 10:11 stijnvdb88

Well I don't think it's an issue with Snap.Net. It looks like the snapserver either doesn't accept or ignores the incoming TCP stream. Other input sources, like pipes (e.g. for Mopidy) still work just fine.

I only use the TCP input for Snap.Net's broadcast, and that stops working if the server ignores the stream :)

I might try using the binary to get some logs...

Chaphasilor avatar Nov 16 '21 00:11 Chaphasilor

Yooo broadcasting was not working for me until i swapped to microphone. When setting mode to Media, no sound is incoming. (although it sees the active stream)

Tried with BubbleUpnp and android integrated music app (spotify ofc didnt work, but i thought local mp3 from phone would be fine)

airmusic + magiskmodule + spotify does work via airplay+shareport as pipe in snap-server. really looking forward to replace that messy airmusic with the clean snap.net app

Snapserver-log
snapcastserver | 2021-11-08 10-34-43.189 [Error] (ControlServer) Removing 3 inactive session(s), active sessions: 8
snapcastserver | 2021-11-08 10-34-43.326 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-43.326 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-43.449 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-43.740 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-43.741 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-43.808 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-43.808 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-43.810 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-44.362 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-44.658 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-44.658 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-46.168 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-46.433 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-46.433 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-46.659 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-46.912 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-46.912 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-49.284 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-49.562 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-49.562 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-49.757 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-50.017 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-50.017 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-52.919 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-53.156 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-53.156 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-55.984 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-56.262 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-34-56.265 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-08 10-37-45.145 [Error] (ControlSessionTCP) Error while reading from control socket: End of file
snapcastserver | 2021-11-08 10-37-45.145 [Error] (ControlSessionTCP) Error while reading from control socket: End of file
snapcastserver | 2021-11-08 10-37-45.145 [Error] (ControlSessionTCP) Error while reading from control socket: End of file
snapcastserver | 2021-11-08 10-37-45.148 [Error] (ControlSessionTCP) Error while reading from control socket: End of file
snapcastserver | 2021-11-08 10-37-45.149 [Error] (ControlSessionTCP) Error while reading from control socket: End of file
snapcastserver | 2021-11-08 10-37-45.149 [Error] (ControlSessionTCP) Error while reading from control socket: End of file
snapcastserver | 2021-11-08 10-37-45.149 [Error] (ControlSessionTCP) Error while reading from control socket: End of file
snapcastserver | 2021-11-08 10-37-45.150 [Error] (ControlSessionTCP) Error while reading from control socket: End of file
snapcastserver | %Y-%m-%d %H-%M-%S.#ms [Error] (log) ControlSessionTcp::~ControlSessionTcp()
snapcastserver | 2021-11-08 10-37-45.150 [Error] (ControlSessionTCP) Error while reading from control socket: End of file
snapcastserver | 2021-11-08 10-37-45.151 [Error] (ControlSessionTCP) Error while reading from control socket: End of file
snapcastserver | 2021-11-08 10-37-45.151 [Error] (ControlSessionTCP) Error while reading from control socket: End of file
snapcastserver | 2021-11-08 10-37-45.151 [Error] (ControlSessionTCP) Error while reading from control socket: End of file
snapcastserver | 2021-11-08 10-37-45.151 [Error] (ControlSessionTCP) ControlSession ControlSession stopped
snapcastserver | 2021-11-08 10-37-45.152 [Error] (ControlSessionTCP) Error while reading from control socket: End of file
snapcastserver | 2021-11-08 10-37-45.152 [Error] (ControlSessionTCP) Error while reading from control socket: End of file
snapcastserver | 2021-11-08 10-37-45.152 [Error] (ControlSessionTCP) ControlSession::stop
snapcastserver | 2021-11-08 10-37-45.152 [Error] (ControlSessionTCP) ControlSessionTcp::~ControlSessionTcp()
snapcastserver | 2021-11-08 10-37-45.153 [Error] (ControlSessionTCP) Error while reading from control socket: End of file
snapcastserver | 2021-11-08 10-37-45.153 [Error] (ControlSessionTCP) Error while reading from control socket: End of file
snapcastserver | 2021-11-08 10-37-45.153 [Error] (ControlSessionTCP) Error while reading from control socket: End of file
snapcastserver | 2021-11-08 10-41-40.774 [Error] (ControlSessionTCP) Error while reading from control socket: Connection reset by peer
snapcastserver | 2021-11-08 10-41-40.774 [Error] (ControlSessionTCP) Error in socket shutdown: Transport endpoint is not connected
snapcastserver | 2021-11-08 10-41-40.777 [Error] (ControlSessionTCP) Error while reading from control socket: Connection reset by peer
snapcastserver | 2021-11-08 10-41-40.777 [Error] (ControlSessionTCP) ControlSessionTcp::~ControlSessionTcp()
snapcastserver | 2021-11-08 10-41-40.777 [Error] (ControlSessionTCP) Error while reading from control socket: Connection reset by peer
snapcastserver | 2021-11-08 10-41-40.777 [Error] (ControlSessionTCP) ControlSessionTcp::~ControlSessionTcp()
snapcastserver | 2021-11-08 10-41-40.778 [Error] (ControlSessionTCP) ControlSession::stop
snapcastserver | 2021-11-08 10-41-40.778 [Error] (ControlSessionTCP) Error in socket shutdown: Transport endpoint is not connected
snapcastserver | 2021-11-08 10-41-40.778 [Error] (ControlSessionTCP) Error in socket shutdown: Transport endpoint is not connected
snapcastserver | 2021-11-08 10-41-40.778 [Error] (ControlSessionTCP) Error in socket shutdown: Transport endpoint is not connected
snapcastserver | 2021-11-08 10-41-40.779 [Error] (ControlSessionTCP) Error in socket shutdown: Transport endpoint is not connected
snapcastserver | 2021-11-08 10-41-40.778 [Error] (ControlSessionTCP) ControlSession ControlSession stopped
snapcastserver | 2021-11-11 12-45-43.768 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.56
snapcastserver | 2021-11-11 12-45-43.768 [Error] (ControlServer) Removing 30 inactive session(s), active sessions: 8
snapcastserver | 2021-11-11 12-45-45.012 [Notice] (StreamServer) StreamServer::NewConnection: 192.168.1.56
snapcastserver | 2021-11-11 12-45-45.012 [Notice] (StreamServer) StreamServer::NewConnection: 192.168.1.56
snapcastserver | 2021-11-11 12-45-45.018 [Info] (Server) Hello from 44:37:e6:c6:3e:f9#6, host: BLADE-SERVER, v0.25.0, ClientName: Snapclient, OS: Windows 8, Arch: amd64, Protocol version: 2
snapcastserver | 2021-11-11 12-45-45.021 [Info] (Server) Hello from 44:37:e6:c6:3e:f9#3, host: BLADE-SERVER, v0.25.0, ClientName: Snapclient, OS: Windows 8, Arch: amd64, Protocol version: 2
snapcastserver | 2021-11-11 12-46-31.038 [Info] (PcmStream) State changed: snapbroadcast, state: 1 => 2
snapcastserver | 2021-11-11 12-46-31.038 [Info] (Server) onStateChanged (snapbroadcast): 2
snapcastserver | 2021-11-11 12-47-39.612 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.200
snapcastserver | 2021-11-11 12-47-39.730 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.200
snapcastserver | 2021-11-11 12-47-39.760 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.200
snapcastserver | 2021-11-11 12-47-40.798 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.200
snapcastserver | 2021-11-11 12-47-40.865 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.200
snapcastserver | 2021-11-11 12-47-41.051 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.200
snapcastserver | 2021-11-11 12-47-44.715 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.200
snapcastserver | 2021-11-11 12-47-44.715 [Error] (ControlServer) Removing 1 inactive session(s), active sessions: 16
snapcastserver | 2021-11-11 12-47-44.722 [Info] (Server) onNewSession
snapcastserver | 2021-11-11 12-47-44.771 [Info] (Server) Hello from a51726ad-f10d-4e62-8c59-ab36815c02d6, host: Snapweb client, v0.1.0, ClientName: Snapweb, OS: Linux aarch64, Arch: web, Protocol version: 2
snapcastserver | 2021-11-11 12-47-44.784 [Error] (ControlServer) Removing 1 inactive session(s), active sessions: 15
snapcastserver | 2021-11-11 12-48-09.389 [Info] (StreamServer) onDisconnect: a51726ad-f10d-4e62-8c59-ab36815c02d6
snapcastserver | 2021-11-11 12-48-11.360 [Error] (ControlServer) Removing 1 inactive session(s), active sessions: 14
snapcastserver | 2021-11-11 12-48-11.731 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.200
snapcastserver | 2021-11-11 12-48-11.733 [Info] (Server) onNewSession
snapcastserver | 2021-11-11 12-48-11.801 [Info] (Server) Hello from a51726ad-f10d-4e62-8c59-ab36815c02d6, host: Snapweb client, v0.1.0, ClientName: Snapweb, OS: Linux aarch64, Arch: web, Protocol version: 2
snapcastserver | 2021-11-11 12-48-11.802 [Error] (ControlServer) Removing 1 inactive session(s), active sessions: 14
snapcastserver | 2021-11-11 12-48-17.780 [Error] (ControlServer) sendAsync: 3
snapcastserver | 2021-11-11 12-48-17.780 [Error] (ControlServer) Removing 6 inactive session(s), active sessions: 8
snapcastserver | 2021-11-11 12-48-44.263 [Info] (StreamServer) onDisconnect: a51726ad-f10d-4e62-8c59-ab36815c02d6
snapcastserver | 2021-11-11 12-48-44.264 [Error] (StreamSession) StreamSession write error (msg length: 0): Operation canceled
snapcastserver | 2021-11-11 12-48-44.537 [Info] (Server) onResync (snapbroadcast): 40.9778 ms
snapcastserver | 2021-11-11 12-48-50.514 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.200
snapcastserver | 2021-11-11 12-48-50.522 [Info] (Server) onNewSession
snapcastserver | 2021-11-11 12-48-50.570 [Info] (Server) Hello from a51726ad-f10d-4e62-8c59-ab36815c02d6, host: Snapweb client, v0.1.0, ClientName: Snapweb, OS: Linux aarch64, Arch: web, Protocol version: 2
snapcastserver | 2021-11-11 12-48-50.571 [Error] (ControlServer) Removing 1 inactive session(s), active sessions: 8
snapcastserver | 2021-11-11 12-49-37.675 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.200
snapcastserver | 2021-11-11 12-49-37.777 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.200
snapcastserver | 2021-11-11 12-49-37.783 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.200
snapcastserver | 2021-11-11 12-49-37.790 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.200
snapcastserver | 2021-11-11 12-49-38.875 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.200
snapcastserver | 2021-11-11 12-49-38.906 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.200
snapcastserver | 2021-11-11 12-49-38.906 [Error] (ControlServer) Removing 1 inactive session(s), active sessions: 14
snapcastserver | 2021-11-11 12-49-50.425 [Error] (ControlServer) Removing 1 inactive session(s), active sessions: 13
snapcastserver | 2021-11-11 12-50-37.123 [Info] (Server) onResync (snapbroadcast): 5.8046 ms
snapcastserver | 2021-11-11 12-51-08.386 [Info] (Server) onResync (snapbroadcast): 94.7284 ms
snapcastserver | 2021-11-11 12-51-15.385 [Error] (ControlServer) Removing 4 inactive session(s), active sessions: 9
snapcastserver | 2021-11-11 12-51-15.457 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.200
snapcastserver | 2021-11-11 12-54-31.878 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-11 12-54-31.878 [Error] (ControlServer) Removing 1 inactive session(s), active sessions: 10
snapcastserver | 2021-11-11 12-54-40.388 [Notice] (StreamServer) StreamServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-11 12-54-40.397 [Info] (Server) Hello from Nexus 6P, host: Nexus 6P, v0.25.0, ClientName: Snapclient, OS: Android 10, Arch: arm64-v8a, Protocol version: 2
snapcastserver | 2021-11-11 12-56-47.198 [Error] (ControlSessionWS) ControlSessionWebsocket::on_read_ws error: Connection reset by peer
snapcastserver | 2021-11-11 12-56-47.198 [Info] (StreamServer) onDisconnect: a51726ad-f10d-4e62-8c59-ab36815c02d6
snapcastserver | 2021-11-11 12-56-47.199 [Error] (ControlServer) Removing 1 inactive session(s), active sessions: 9
snapcastserver | 2021-11-11 12-59-57.791 [Info] (PcmStream) State changed: snapbroadcast, state: 2 => 1
snapcastserver | 2021-11-11 12-59-57.792 [Info] (Server) onStateChanged (snapbroadcast): 1
snapcastserver | 2021-11-11 13-00-07.230 [Warn] (AsioStream) Stream and system time out of sync: 10189.8 ms, resetting stream time.
snapcastserver | 2021-11-11 13-00-07.675 [Info] (PcmStream) State changed: snapbroadcast, state: 1 => 2
snapcastserver | 2021-11-11 13-00-07.675 [Info] (Server) onStateChanged (snapbroadcast): 2
snapcastserver | 2021-11-11 13-01-03.062 [Info] (Server) onResync (snapbroadcast): 32.1953 ms
snapcastserver | 2021-11-11 13-02-22.682 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.217
snapcastserver | %Y-%m-%d %H-%M-%S.#ms [Notice] (log) ControlSessionHttp
snapcastserver | 2021-11-11 13-02-22.682 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.217
snapcastserver | 2021-11-11 13-02-22.737 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.217
snapcastserver | 2021-11-11 13-02-22.757 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.217
snapcastserver | 2021-11-11 13-02-23.200 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.217
snapcastserver | 2021-11-11 13-02-23.252 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.217
snapcastserver | 2021-11-11 13-02-23.255 [Error] (ControlServer) Removing 1 inactive session(s), active sessions: 15
snapcastserver | 2021-11-11 13-02-25.742 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.217
snapcastserver | 2021-11-11 13-02-25.753 [Info] (Server) onNewSession
snapcastserver | 2021-11-11 13-02-25.767 [Info] (Server) Hello from 68073e3f-e8d6-4e45-99f5-ee32958950c5, host: Snapweb client, v0.1.0, ClientName: Snapweb, OS: iPhone, Arch: web, Protocol version: 2
snapcastserver | 2021-11-11 13-02-25.780 [Error] (ControlServer) Removing 1 inactive session(s), active sessions: 15
snapcastserver | 2021-11-11 13-02-59.629 [Info] (StreamServer) onDisconnect: 68073e3f-e8d6-4e45-99f5-ee32958950c5
snapcastserver | 2021-11-11 13-02-59.630 [Error] (ControlServer) Removing 5 inactive session(s), active sessions: 10
snapcastserver | 2021-11-11 13-03-07.167 [Error] (ControlSessionWS) ControlSessionWebsocket::on_read_ws error: End of file
snapcastserver | 2021-11-11 13-03-21.746 [Error] (ControlServer) Removing 1 inactive session(s), active sessions: 9
snapcastserver | 2021-11-11 13-08-49.326 [Info] (Server) onResync (snapbroadcast): 39.7548 ms
snapcastserver | 2021-11-11 13-08-49.435 [Info] (Server) onResync (snapbroadcast): 7.7908 ms
snapcastserver | 2021-11-11 13-12-13.268 [Info] (PcmStream) State changed: snapbroadcast, state: 2 => 1
snapcastserver | 2021-11-11 13-12-13.268 [Info] (Server) onStateChanged (snapbroadcast): 1
snapcastserver | 2021-11-11 13-22-30.321 [Warn] (AsioStream) Stream and system time out of sync: 617650 ms, resetting stream time.
snapcastserver | 2021-11-11 13-22-30.379 [Info] (Server) onResync (snapbroadcast): 17.0135 ms
snapcastserver | 2021-11-11 13-22-30.695 [Info] (PcmStream) State changed: snapbroadcast, state: 1 => 2
snapcastserver | 2021-11-11 13-22-30.695 [Info] (Server) onStateChanged (snapbroadcast): 2
snapcastserver | 2021-11-11 13-22-33.297 [Info] (PcmStream) State changed: snapbroadcast, state: 2 => 1
snapcastserver | 2021-11-11 13-22-33.297 [Info] (Server) onStateChanged (snapbroadcast): 1
snapcastserver | 2021-11-11 13-22-39.137 [Warn] (AsioStream) Stream and system time out of sync: 6758.71 ms, resetting stream time.
snapcastserver | 2021-11-11 13-22-39.198 [Info] (Server) onResync (snapbroadcast): 21.1741 ms
snapcastserver | 2021-11-11 13-22-39.539 [Info] (PcmStream) State changed: snapbroadcast, state: 1 => 2
snapcastserver | 2021-11-11 13-22-39.539 [Info] (Server) onStateChanged (snapbroadcast): 2
snapcastserver | 2021-11-11 13-22-41.620 [Info] (PcmStream) State changed: snapbroadcast, state: 2 => 1
snapcastserver | 2021-11-11 13-22-41.621 [Info] (Server) onStateChanged (snapbroadcast): 1
snapcastserver | 2021-11-11 13-32-14.403 [Error] (AsioStream) Error reading message: End of file, length: 0
snapcastserver | 2021-11-11 13-32-26.401 [Error] (ControlSessionTCP) Error while reading from control socket: End of file
snapcastserver | 2021-11-11 13-32-26.464 [Error] (StreamSessionTCP) Error reading message header of length 0: Connection reset by peer
snapcastserver | 2021-11-11 13-32-26.464 [Info] (StreamServer) onDisconnect: 44:37:e6:c6:3e:f9#6
snapcastserver | 2021-11-11 13-32-26.465 [Error] (ControlServer) Removing 1 inactive session(s), active sessions: 8
snapcastserver | 2021-11-11 13-32-26.465 [Error] (StreamSessionTCP) Error in socket shutdown: Transport endpoint is not connected
snapcastserver | 2021-11-11 13-32-26.465 [Error] (StreamSessionTCP) Error reading message header of length 0: Connection reset by peer
snapcastserver | 2021-11-11 13-32-26.466 [Info] (StreamServer) onDisconnect: 44:37:e6:c6:3e:f9#3
snapcastserver | 2021-11-12 13-36-59.701 [Notice] (StreamServer) StreamServer::NewConnection: 192.168.1.42
snapcastserver | 2021-11-12 13-36-59.715 [Info] (Server) Hello from dc:a6:32:a9:7c:4b, host: LedFX, v0.24.0, ClientName: Snapclient, OS: Debian GNU/Linux 10 (buster), Arch: armv7l, Protocol version: 2
snapcastserver | 2021-11-12 13-37-00.231 [Error] (ControlSessionTCP) Error while reading from control socket: Connection reset by peer
snapcastserver | 2021-11-12 13-37-00.232 [Error] (ControlSessionTCP) Error in socket shutdown: Transport endpoint is not connected
snapcastserver | 2021-11-19 00-26-25.723 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-19 00-26-25.723 [Error] (ControlServer) Removing 1 inactive session(s), active sessions: 8
snapcastserver | 2021-11-19 00-26-38.446 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.56
snapcastserver | 2021-11-19 00-26-39.682 [Notice] (StreamServer) StreamServer::NewConnection: 192.168.1.56
snapcastserver | 2021-11-19 00-26-39.690 [Info] (Server) Hello from 44:37:e6:c6:3e:f9#3, host: BLADE-SERVER, v0.25.0, ClientName: Snapclient, OS: Windows 8, Arch: amd64, Protocol version: 2
snapcastserver | 2021-11-19 00-26-39.721 [Notice] (StreamServer) StreamServer::NewConnection: 192.168.1.56
snapcastserver | 2021-11-19 00-26-39.729 [Info] (Server) Hello from 44:37:e6:c6:3e:f9#6, host: BLADE-SERVER, v0.25.0, ClientName: Snapclient, OS: Windows 8, Arch: amd64, Protocol version: 2
snapcastserver | 2021-11-19 00-27-19.808 [Error] (StreamSessionTCP) Error reading message header of length 0: Connection reset by peer
snapcastserver | 2021-11-19 00-27-19.808 [Info] (StreamServer) onDisconnect: dc:a6:32:a9:7c:4b
snapcastserver | 2021-11-19 00-27-19.809 [Error] (StreamSessionTCP) Error in socket shutdown: Transport endpoint is not connected
snapcastserver | 2021-11-19 00-27-19.828 [Info] (PcmStream) State changed: snapbroadcast, state: 1 => 2
snapcastserver | 2021-11-19 00-27-19.828 [Info] (Server) onStateChanged (snapbroadcast): 2
snapcastserver | 2021-11-19 00-27-19.829 [Error] (StreamSessionTCP) Error reading message header of length 0: Connection reset by peer
snapcastserver | 2021-11-19 00-27-19.829 [Info] (StreamServer) onDisconnect: Nexus 6P
snapcastserver | 2021-11-19 00-27-19.830 [Error] (StreamSessionTCP) Error in socket shutdown: Transport endpoint is not connected
snapcastserver | 2021-11-19 00-27-51.387 [Info] (Server) onResync (snapbroadcast): 59.7731 ms
snapcastserver | 2021-11-19 00-28-18.202 [Info] (Server) onResync (snapbroadcast): 50.1791 ms
snapcastserver | 2021-11-19 00-28-24.401 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-19 00-28-37.884 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-19 00-28-40.434 [Error] (AsioStream) Error reading message: End of file, length: 3328
snapcastserver | 2021-11-19 00-28-40.972 [Info] (PcmStream) State changed: snapbroadcast, state: 2 => 1
snapcastserver | 2021-11-19 00-28-40.972 [Info] (Server) onStateChanged (snapbroadcast): 1
snapcastserver | 2021-11-19 00-28-49.978 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-19 00-28-57.616 [Info] (PcmStream) State changed: snapbroadcast, state: 1 => 2
snapcastserver | 2021-11-19 00-28-57.616 [Info] (Server) onStateChanged (snapbroadcast): 2
snapcastserver | 2021-11-19 00-29-03.074 [Error] (AsioStream) Error reading message: End of file, length: 1792
snapcastserver | 2021-11-19 00-29-03.859 [Info] (PcmStream) State changed: snapbroadcast, state: 2 => 1
snapcastserver | 2021-11-19 00-29-03.859 [Info] (Server) onStateChanged (snapbroadcast): 1
snapcastserver | 2021-11-19 00-29-11.775 [Notice] (ControlServer) ControlServer::NewConnection: 192.168.1.61
snapcastserver | 2021-11-19 00-29-18.423 [Info] (PcmStream) State changed: snapbroadcast, state: 1 => 2
snapcastserver | 2021-11-19 00-29-18.423 [Info] (Server) onStateChanged (snapbroadcast): 2
snapcastserver | 2021-11-19 00-29-18.458 [Info] (Server) onResync (snapbroadcast): 4.41333 ms
snapcastserver | 2021-11-19 00-29-20.630 [Info] (Server) onResync (snapbroadcast): 21.3825 ms
snapcastserver | 2021-11-19 00-29-37.580 [Info] (Server) onResync (snapbroadcast): 28.9699 ms
snapcastserver | 2021-11-19 00-29-54.758 [Error] (AsioStream) Error reading message: End of file, length: 0
snapcastserver | 2021-11-19 00-29-55.354 [Info] (PcmStream) State changed: snapbroadcast, state: 2 => 1
snapcastserver | 2021-11-19 00-29-55.354 [Info] (Server) onStateChanged (snapbroadcast): 1
snapcastserver | 2021-11-19 00-30-05.758 [Info] (PcmStream) State changed: snapbroadcast, state: 1 => 2
snapcastserver | 2021-11-19 00-30-05.758 [Info] (Server) onStateChanged (snapbroadcast): 2
snapcastserver | 2021-11-19 00-30-05.805 [Info] (Server) onResync (snapbroadcast): 18.4234 ms
snapcastserver | 2021-11-19 00-30-05.955 [Info] (Server) onResync (snapbroadcast): 6.17499 ms
snapcastserver | 2021-11-19 00-33-04.719 [Info] (Server) onResync (snapbroadcast): 3.92406 ms
snapcastserver | 2021-11-19 00-33-04.813 [Info] (Server) onResync (snapbroadcast): 13.2648 ms
snapcastserver | 2021-11-19 00-33-04.897 [Info] (Server) onResync (snapbroadcast): 10.3876 ms
snapcastserver | 2021-11-19 00-33-04.993 [Info] (Server) onResync (snapbroadcast): 31.8055 ms
snapcastserver | 2021-11-19 00-33-05.127 [Info] (Server) onResync (snapbroadcast): 18.7953 ms
snapcastserver | 2021-11-19 00-33-05.208 [Info] (Server) onResync (snapbroadcast): 19.937 ms
snapcastserver | 2021-11-19 00-33-05.336 [Info] (Server) onResync (snapbroadcast): 48.8083 ms
snapcastserver | 2021-11-19 00-33-05.504 [Info] (Server) onResync (snapbroadcast): 62.2009 ms
snapcastserver | 2021-11-19 00-33-05.716 [Info] (Server) onResync (snapbroadcast): 150.596 ms
snapcastserver | 2021-11-19 00-33-05.840 [Info] (Server) onResync (snapbroadcast): 31.2111 ms
snapcastserver | 2021-11-19 00-33-06.119 [Info] (Server) onResync (snapbroadcast): 113.018 ms
snapcastserver | 2021-11-19 00-33-06.368 [Info] (Server) onResync (snapbroadcast): 206.324 ms
snapcastserver | 2021-11-19 00-33-06.474 [Info] (Server) onResync (snapbroadcast): 45.5167 ms
snapcastserver | 2021-11-19 00-33-06.895 [Info] (Server) onResync (snapbroadcast): 155.117 ms
snapcastserver | 2021-11-19 00-33-07.271 [Info] (Server) onResync (snapbroadcast): 194.631 ms
snapcastserver | 2021-11-19 00-33-07.413 [Info] (Server) onResync (snapbroadcast): 91.5915 ms
snapcastserver | 2021-11-19 00-33-07.763 [Info] (Server) onResync (snapbroadcast): 32.3615 ms
snapcastserver | 2021-11-19 00-33-08.172 [Info] (Server) onResync (snapbroadcast): 86.1204 ms
snapcastserver | 2021-11-19 00-33-08.557 [Info] (Server) onResync (snapbroadcast): 150.444 ms
snapcastserver | 2021-11-19 00-33-08.710 [Info] (Server) onResync (snapbroadcast): 104.848 ms
snapcastserver | 2021-11-19 00-33-08.928 [Info] (Server) onResync (snapbroadcast): 177.466 ms
snapcastserver | 2021-11-19 00-33-09.041 [Info] (Server) onResync (snapbroadcast): 12.6808 ms
snapcastserver | 2021-11-19 00-33-09.301 [Info] (Server) onResync (snapbroadcast): 219.608 ms
snapcastserver | 2021-11-19 00-33-09.576 [Info] (Server) onResync (snapbroadcast): 52.7151 ms
snapcastserver | 2021-11-19 00-33-09.816 [Info] (Server) onResync (snapbroadcast): 199.307 ms
snapcastserver | 2021-11-19 00-33-09.960 [Info] (Server) onResync (snapbroadcast): 82.3054 ms
snapcastserver | 2021-11-19 00-33-10.165 [Info] (Server) onResync (snapbroadcast): 158.3 ms
snapcastserver | 2021-11-19 00-33-10.283 [Info] (Server) onResync (snapbroadcast): 16.6469 ms
snapcastserver | 2021-11-19 00-33-10.536 [Info] (Server) onResync (snapbroadcast): 181.466 ms
snapcastserver | 2021-11-19 00-33-10.672 [Info] (Server) onResync (snapbroadcast): 95.3512 ms
snapcastserver | 2021-11-19 00-33-10.744 [Info] (Server) onResync (snapbroadcast): 4.47117 ms
snapcastserver | 2021-11-19 00-33-10.954 [Info] (Server) onResync (snapbroadcast): 167.623 ms
snapcastserver | 2021-11-19 00-33-11.127 [Info] (Server) onResync (snapbroadcast): 113.152 ms
snapcastserver | 2021-11-19 00-33-11.190 [Info] (Server) onResync (snapbroadcast): 22.2823 ms
snapcastserver | 2021-11-19 00-33-11.324 [Info] (Server) onResync (snapbroadcast): 70.3627 ms
snapcastserver | 2021-11-19 00-33-11.667 [Info] (Server) onResync (snapbroadcast): 171.24 ms
snapcastserver | 2021-11-19 00-33-11.857 [Info] (Server) onResync (snapbroadcast): 130.596 ms
snapcastserver | 2021-11-19 00-33-12.147 [Info] (Server) onResync (snapbroadcast): 144.476 ms
snapcastserver | 2021-11-19 00-33-12.244 [Info] (Server) onResync (snapbroadcast): 36.9153 ms
snapcastserver | 2021-11-19 00-33-12.413 [Info] (Server) onResync (snapbroadcast): 108.645 ms
snapcastserver | 2021-11-19 00-33-12.529 [Info] (Server) onResync (snapbroadcast): 56.2324 ms
snapcastserver | 2021-11-19 00-33-12.854 [Info] (Server) onResync (snapbroadcast): 154.662 ms
snapcastserver | 2021-11-19 00-33-13.045 [Info] (Server) onResync (snapbroadcast): 90.999 ms
snapcastserver | 2021-11-19 00-33-33.905 [Info] (Server) onResync (snapbroadcast): 15.7534 ms

YeonV avatar Nov 19 '21 00:11 YeonV

@YeonV what's your ROM / Android version? can you try with the SoundCloud app? that one works for me...

Chaphasilor avatar Jan 07 '22 12:01 Chaphasilor

@stijnvdb88 Any plans for adding support for the Metadata API to the broadcast implementations on windows and especially android? :D

Chaphasilor avatar Jan 07 '22 12:01 Chaphasilor

@Chaphasilor I've given it some thought, but I'm not sure it's possible tbh. There are two major issues with getting audio metadata from a broadcast stream to snapserver:

  1. We literally don't actually know what's playing :-D the way broadcast works, is we simply forward whatever audio's being sent to our sound card to snapserver instead (just raw pcm, nothing else). we don't even know which software is sending that audio, let alone artist/song. The audio isn't necessarily even music - you could be broadcasting the sound of a movie you're watching, or talking through a microphone. This goes for both PC and Android - while Android does have the concept of "now playing" metadata which apps can set, I can't find any way of querying/reading from it.

  2. Even if we did somehow figure out what's playing, we don't have any way of reporting this to snapserver. The scriptControl plug-in system queries the stream instead of the other way around. Eg. snapserver asks the mpd plugin, which asks the MPD server. A Spotify plug-in would ask Spotify, using your credentials and Connect device name. The tcp stream however barely even knows which device is sending the audio (pc/android/something else), and there's no protocol for exchanging metadata atm. In other words, it wouldn't know who to ask, or how to ask.

Do you have any thoughts on these? The second problem might be solvable if snapserver would allow us to report metadata across the json-rpc api, but if I'm reading this code right, "metadata" isn't a property you can set that way. That's a decision that makes sense imo, it would be backwards for the server to expect a client to report what the server is playing.

stijnvdb88 avatar Jan 09 '22 14:01 stijnvdb88

  1. Well I don't know about .NET android apps, but generally it should be fairly straight-forward to get the now playing metadata.
    Especially on Windows, where you should have proper .NET APIs for it.
  2. Well there is a python script for mpd, so we could use another script for snap.net broadcast. Just add yet another port for communicating with the script/plugin server and send the metadata to it, then the snapserver queries the plugin to get the current data. Control would also be possible this way, if we're using a tcp socket, right? :)

Chaphasilor avatar Jan 10 '22 10:01 Chaphasilor

you're completely right, opening our own socket on the plugin script would work for that second issue!

The first one is trickier than you'd think though, the problem isn't exactly that there's no API to access this data, it's that the data simply isn't there: iirc the concept of "now playing" didn't even exist in Windows until a few years ago. There is some API for reading "now playing" metadata, but it doesn't look like most media players actually report to it, which makes it useless for what we're trying to do here. I've tried VLC, MPC and even Windows Media Player but none of them seem to be sending their metadata to this system. You can try it yourself by downloading a release from this demo project, for me it's only showing things like Youtube videos that were left open in Chrome - not output people are likely to be broadcasting. Does it show anything useful on your end?

For Android, maybe MediaSessionManager.getActiveSessions does what we're looking for. On that platform at least we know the data is there since you can plainly see the "now playing" info on the lock screen, it's just a matter of figuring out how to get to it.

stijnvdb88 avatar Jan 10 '22 23:01 stijnvdb88

Well yeah, if the data isn't available (e.g. pre-Win10), there's nothing to show. But I would suggest we use the new media session stuff used by browsers and some music players.

I myself use the YT Music and Spotify PWAs (web-based) extensively, and they all show up there.

VLC and WinMediaPlayer are pretty outdated feature-wise, and mpc is probably not bothering with any system APIs at all.
But them not using available APIs (yet) isn't our problem :)
Also, there might be plugins for VLC and mpc that add support, I know there is one for MusicBee. So if someone wants to use that feature of Snap.net, they probably can...

If you want to implement custom metadata detection, go ahead, but I don't think it's worth it 😅

Chaphasilor avatar Jan 11 '22 08:01 Chaphasilor

@YeonV what's your ROM / Android version? can you try with the SoundCloud app? that one works for me... @Chaphasilor Android 10 - LinageOS 17.1 Thanks for the tip, i will try

SoundCloud app: Mircophone works, media not :/

YeonV avatar Jan 15 '22 14:01 YeonV

@stijnvdb88 so it's been a few months and I've actually been using this feature extensively. Here are my thoughts:

  1. The core functionality is pretty solid. Connectivity is good (slightly more dropouts compared to e.g. Mopidy, but that's to be expected due to the additional hop). Battery drain is high, but tolerable while at home. I can leave the broadcast running over night without a problem.

  2. The issues I mentioned above about the app hanging up when stopping the broadcast is still there. What I've gained since then is that the issue occurs when my phone loses connection to my snapserver (e.g. when WiFi disconnects). In this case, the server hangs up:

    • Snap.Net Android App still shows "Stop Broadcast" in upper right corner, but the snapcast stream says "idle"
    • You can sometimes tap on "Stop Broadcast" and it will switch back to offer "Play" or "Broadcast". Clicking on "Broadcast" again will start broadcasting to the server again, it seems.
    • After the phone disconnected, the snapserver will stay on "idle" and not play back any audio. Even after re-starting the broadcast from the app, it stays "idle". Restarting the snapserver fixes the problem easily, and it will start playing back the broadcast immediately, if the app is already connected.
      So all in all it seems to be mostly a lack of error handling on both sides, probably because mobile devices aren't really a common scenario for Snapcast.
  3. As mentioned before, changing the volume really is a pain, because the broadcast is unaffected by the system volume.
    This means that you always need to open the Snap.Net app and use the volume slider there. Adding a "remote volume control" slider (as seen in Yatse, YouTube TV) would be the nicest option in my opinion.

I think the focus right now should be point 3, as it's the greatest pain-point.
The rest of the features worked well enough for me on both Android 11 and 12 that I can live with the current version for a while.

What do you think?

Chaphasilor avatar Feb 19 '22 14:02 Chaphasilor