-
Notifications
You must be signed in to change notification settings - Fork 456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server continually sending data even when not playing #729
Comments
Your router is getting hot from three compressed audio streams? The server is only sending audio when the source is active. When the source is idle, the client will not receive any audio and release the PCM device after 5s, as you can see in the client logs:
On the server:
with 1 = ilde, 2 = playing enum class ReaderState
{
kUnknown = 0,
kIdle = 1,
kPlaying = 2,
kDisabled = 3
}; So it rather seems that your stream source is continuously playing. |
It's not the case that the source is continually playing. Mopidy is *not even running* when I do these tests. The network traffic starts as soon as I start snapserver. It seems as if, with the ALSA loopback sink, snapserver thinks playback is always happening, or is just sending silence when there is no incoming audio.
Here are some logs. These were taken *with the player not running*. The snapcast traffic was clearly happening and started as soon as I started the server.
Nov 24 18:33:47 kodi snapserver[25842]: Settings file: "/var/lib/snapserver/server.json"
Nov 24 18:33:47 kodi snapserver[25842]: Adding service 'Snapcast'
Nov 24 18:33:47 kodi snapserver[25842]: PcmStream: RompR, sampleFormat: 44100:16:2
Nov 24 18:33:47 kodi snapserver[25842]: Stream: RompR, metadata={
Nov 24 18:33:47 kodi snapserver[25842]: "STREAM": "RompR"
Nov 24 18:33:47 kodi snapserver[25842]: }
Nov 24 18:33:47 kodi snapserver[25842]: onMetaChanged (RompR)
Nov 24 18:33:47 kodi snapserver[25842]: Stream: {"fragment":"","host":"","path":"","query":{"chunk_ms":"20","codec":"pcm","device":"hw:0,1,0","name":"RompR","sampleformat":"44100:16:2"},"raw":"alsa:///?chunk_ms=20&codec=pcm&device=hw:0,1,0&name=RompR&sampleformat=44100:16:2","scheme":"alsa"}
Nov 24 18:33:47 kodi snapserver[25842]: No data availabale, playing silence.
Nov 24 18:33:47 kodi snapserver[25842]: Creating TCP acceptor for address: 0.0.0.0, port: 1705
Nov 24 18:33:47 kodi snapserver[25842]: Creating HTTP acceptor for address: 0.0.0.0, port: 1780
Nov 24 18:33:47 kodi snapserver[25842]: Creating stream acceptor for address: 0.0.0.0, port: 1704
Nov 24 18:33:47 kodi snapserver[25842]: number of threads: 4, hw threads: 4
Nov 24 18:33:48 kodi snapserver[25842]: Service 'Snapcast' successfully established.
Nov 24 18:33:48 kodi snapserver[25842]: StreamServer::NewConnection: 192.168.0.26
Nov 24 18:33:48 kodi snapserver[25842]: StreamServer::NewConnection: 192.168.0.35
Nov 24 18:33:48 kodi snapserver[25842]: Hello from b8:27:eb:08:34:61, host: kitchen, v0.21.0, ClientName: Snapclient, OS: Raspbian GNU/Linux 10 (buster), Arch: armv7l, Protocol version: 2
Nov 24 18:33:48 kodi snapserver[25842]: Hello from b8:27:eb:9a:d5:ee, host: raspberrypi, v0.21.0, ClientName: Snapclient, OS: Raspbian GNU/Linux 10 (buster), Arch: armv7l, Protocol version: 2
Nov 24 18:33:48 kodi snapserver[25842]: StreamServer::NewConnection: 192.168.0.20
Nov 24 18:33:48 kodi snapserver[25842]: Hello from b8:27:eb:93:d1:cf, host: zero, v0.21.0, ClientName: Snapclient, OS: Raspbian GNU/Linux 10 (buster), Arch: armv6l, Protocol version: 2
Nov 24 20:14:44 kodi snapserver[25842]: next read < 0 (RompR): -1.421 ms
Nov 24 20:14:44 kodi snapserver[25842]:
Nov 24 20:14:44 kodi snapserver[25842]: next read < 0 (RompR): -7.453 ms
Nov 24 20:14:47 kodi snapserver[25842]: next read < 0 (RompR): -1.911 ms
Nov 24 18:33:48 zero snapclient[2046]: Connecting
Nov 24 18:33:48 zero snapclient[2046]: Connected to 192.168.0.33
Nov 24 18:33:48 zero snapclient[2046]: My MAC: "b8:27:eb:93:d1:cf", socket: 8
Nov 24 18:33:48 zero snapclient[2046]: ServerSettings - buffer: 1000, latency: 0, volume: 58, muted: 0
Nov 24 18:33:48 zero snapclient[2046]: Codec: pcm, sampleformat: 44100:16:2
Nov 24 18:33:48 zero snapclient[2046]: Player name: alsa, device: hw:CARD=BossDAC,DEV=0, description: BossDAC, Boss DAC HiFi [Master] pcm512x-hifi-0
Nov 24 18:33:48 zero snapclient[2046]: Direct hardware device without any conversions, idx: 7, sharing mode: unspecified
Nov 24 18:33:48 zero snapclient[2046]: Mixer mode: hardware, parameters: Digital
Nov 24 18:33:48 zero snapclient[2046]: Sampleformat: 44100:16:2, stream: 44100:16:2
Nov 24 18:33:48 zero snapclient[2046]: diff to server [ms]: -4.28301e+08
That is everything in the logs.
Thanks
… On 24 Nov 2020, at 21:05, Johannes Pohl ***@***.***> wrote:
Your router is getting hot from three compressed audio streams?
The server is only sending audio when the source is active. When the source is idle, the client will not receive any audio and release the PCM device after 5s, as you can see in the client logs:
2020-11-24 21-54-33.773 [Info] (Connection) Resolving host IP for: 192.168.0.3
2020-11-24 21-54-33.774 [Info] (Connection) Connecting
2020-11-24 21-54-33.780 [Notice] (Connection) Connected to 192.168.0.3
2020-11-24 21-54-33.780 [Info] (Connection) My MAC: "00:21:6a:7d:74:fc", socket: 8
2020-11-24 21-54-33.861 [Debug] (Connection) outstanding async_write
2020-11-24 21-54-33.865 [Info] (Controller) ServerSettings - buffer: 1000, latency: 0, volume: 75, muted: 0
metadata:{"STREAM":"Meta"}
2020-11-24 21-54-33.865 [Info] (Controller) Codec: flac, sampleformat: 48000:16:2
2020-11-24 21-54-33.865 [Info] (Player) Player name: alsa, device: hw:CARD=Intel,DEV=0, description: HDA Intel, CX20561 Analog
2020-11-24 21-54-33.865 [Info] (Player) Direct hardware device without any conversions, idx: 32, sharing mode: unspecified, parameters: <none>
2020-11-24 21-54-33.865 [Info] (Player) Mixer mode: software, parameters: <none>
2020-11-24 21-54-33.865 [Info] (Player) Sampleformat: 48000:16:2, stream: 48000:16:2
2020-11-24 21-54-33.865 [Info] (Alsa) Using buffer_time: 80 ms, fragments: 4
2020-11-24 21-54-33.865 [Debug] (Alsa) PCM name: hw:CARD=Intel,DEV=0
2020-11-24 21-54-33.865 [Debug] (Alsa) PCM state: PREPARED
2020-11-24 21-54-33.866 [Debug] (Alsa) channels: 2
2020-11-24 21-54-33.866 [Debug] (Alsa) rate: 48000 bps
2020-11-24 21-54-33.866 [Debug] (Alsa) frames: 960
2020-11-24 21-54-33.866 [Debug] (Alsa) buffer time: 80000
2020-11-24 21-54-33.866 [Debug] (Alsa) period time: 20000
2020-11-24 21-54-33.866 [Debug] (Alsa) periods: 4
2020-11-24 21-54-33.866 [Debug] (Player) setVolume exp with base 10: 0.75 => 0.513713
2020-11-24 21-54-33.866 [Debug] (Alsa) Resizing buffer from 0 to 15360
2020-11-24 21-54-33.866 [Info] (Stream) no chunks available
2020-11-24 21-54-33.866 [Info] (Alsa) Failed to get chunk
2020-11-24 21-54-34.130 [Info] (Controller) diff to server [ms]: 5.95066e+09
2020-11-24 21-54-34.774 [Debug] (Stream) Silent frames: 437, frames: 960, age: -9.105
2020-11-24 21-54-34.794 [Debug] (Stats) Chunk: 0 0 0 0 1 60 0
2020-11-24 21-54-35.014 [Debug] (Stats) Chunk: 0 0 0 0 12 60 0
2020-11-24 21-54-36.014 [Debug] (Stats) Chunk: 0 0 0 0 58 60 0
2020-11-24 21-54-37.014 [Debug] (Stats) Chunk: 0 0 0 0 105 60 0
2020-11-24 21-54-38.014 [Debug] (Stats) Chunk: 0 0 0 0 146 60 0
2020-11-24 21-54-39.034 [Debug] (Stats) Chunk: 0 0 0 0 187 40 0
2020-11-24 21-54-40.034 [Debug] (Stats) Chunk: 0 0 0 0 231 40 0
2020-11-24 21-54-41.014 [Debug] (Stats) Chunk: 0 0 0 0 275 60 0
2020-11-24 21-54-42.014 [Debug] (Stats) Chunk: 0 0 0 0 314 60 0
2020-11-24 21-54-43.014 [Debug] (Stats) Chunk: 0 0 0 0 359 60 0
2020-11-24 21-54-44.034 [Debug] (Stats) Chunk: 0 0 0 0 397 40 0
2020-11-24 21-54-45.014 [Debug] (Stats) Chunk: 0 0 0 0 440 60 0
2020-11-24 21-54-46.014 [Debug] (Stats) Chunk: 0 0 0 0 479 60 0
2020-11-24 21-54-47.014 [Debug] (Stats) Chunk: 0 0 0 0 500 60 0
2020-11-24 21-54-48.014 [Debug] (Stats) Chunk: -1 0 0 0 500 60 0
2020-11-24 21-54-49.034 [Debug] (Stats) Chunk: 0 0 0 0 500 40 0
2020-11-24 21-54-50.014 [Debug] (Stats) Chunk: 0 0 0 0 500 60 0
2020-11-24 21-54-51.014 [Debug] (Stats) Chunk: 0 0 0 0 500 60 0
2020-11-24 21-54-52.014 [Debug] (Stats) Chunk: -1 0 0 0 500 60 0
2020-11-24 21-54-53.014 [Debug] (Stats) Chunk: 0 0 0 0 500 60 0
Pause pressed in MPD
2020-11-24 21-54-54.194 [Info] (Stream) Exception: 0
2020-11-24 21-54-54.194 [Info] (Alsa) Failed to get chunk
2020-11-24 21-54-54.294 [Debug] (Alsa) Waiting for chunk
....
2020-11-24 21-54-59.208 [Debug] (Alsa) Waiting for chunk
2020-11-24 21-54-59.208 [Notice] (Alsa) No chunk received for 5000ms. Closing ALSA.
2020-11-24 21-54-59.308 [Debug] (Alsa) Waiting for chunk
2020-11-24 21-54-59.409 [Debug] (Alsa) Waiting for chunk
...
On the server:
Nov 24 21:54:53 raspberrypi snapserver[32557]: State changed: default, state: 2 => 1
Nov 24 21:54:53 raspberrypi snapserver[32557]: onStateChanged (default): 1
Nov 24 21:54:53 raspberrypi snapserver[32557]: State changed: Meta, state: 2 => 1
with 1 = ilde, 2 = playing
enum class ReaderState
{
kUnknown = 0,
kIdle = 1,
kPlaying = 2,
kDisabled = 3
};
So it rather seems that your stream source is continuously playing.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
To follow up, I tried using a pipe sink instead, and that behaves as you describe. So it seems this is only occurring with the alsa loopback sink. Sadly the pipe sink does not work well with Mopidy. The alsa loopback works very well apart from this. |
yes, you're right. The Alsa stream plugin has a silence detection: if (std::memcmp(chunk_->payload, silent_chunk_.data(), silent_chunk_.size()) == 0)
{
silence_ += chunk_->duration<std::chrono::microseconds>();
if (silence_ > 100ms)
{
setState(ReaderState::kIdle);
}
} And this is working: after 100ms of silence, the stream state switches to "idle", but the silence is actually sent to the clients, which is not intended. |
fixed 4b7c313 |
I have the same/similar problem. I run My observation is, that since some version (I didn't trac down which) the client acquires the soundcard even when nothing is played back (empty playlist in mpd), which blocks mpd from playing and the amp is powered all the time. The workaround currently is to start playback on the server for second, then stop it and the snapclients will free the soundcard. |
btw: What do the numbers in |
I just encountered the described situation again. The process using the soundcard is snapclient, no playback is running on the server and the is no audible sound output, but the soundcard is blocked by snapclient.
Then I did
What does that tell us? Is mpd feeding silence or invalid data into the fifo or is snapserver sending something even though nothing is actually played? |
FTR I have the same kind of setup, and the same problem. In my case, I have a nas (debian+openmediavault) on which is my music collection as well as an mpd server feeding a local snapserver via the On the client side I have orangepilite (armbian) driving a pcm5142 DAC and a small python daemon watching the When I stop the music, after a few seconds, the alsa card is properly closed, as expected (then the power amp is shut down). But any now and them the alsa card is "woken up" for no apparent reasons (note that the owner PID in the status file of the alsa card is a thread of the snapclient process, I guess the I'll try to gather debug level logs and put them here ASAP. I am using snapclient and snapserver 0.23 from develop_snapshot_armhf-99f76263d0edfd5cff327a0c4d711fb8ae321b3f.zip |
Here are some logs My daemon that indirectly shows when the alsa card is activated:
The logs of snapclient: You can see that when the daemon detects activity on the alsa card, at timestamp 17:20:45, the snapclient logs show:
Note that in this session, I've hit "play" the "pause" on mpd at timestamp 17:27:xx (to force snapclient to close the alsa card), as can be seen in the logs of my custom daemon. The logs of snapserver shows nothing special at that timestamp (not in debug mode however). |
@douardda @quantenschaum this is a different issue (that I don't fully understand yet, it seems like the device is blocked/released when playing/paused in @douardda logs). Please stop posting here, I've opened issue #741 for you. The original issue is about the server sending silence when the (alsa) audio source becomes idle, and this is fixed. |
Describe the bug
Snapserver is sending audio to all connected clients even when nothing is playing. This means all clients are permanently using the sound card of the machine they are running on and no other application can play audio on them.
Steps to Reproduce
Environment details
I don't know whether this is possible to fix - what's the difference between "nothing playing" and "a bit of silence in a track"? - but it's definitely undesirable behaviour. I have 3 clients connected by wifi and my router is getting hot!
The text was updated successfully, but these errors were encountered: