SamDel / ChromeCast-Desktop-Audio-Streamer

Stream the sound of your desktop to your Chromecast Audio device
MIT License
412 stars 30 forks source link

Audio delay varies #71

Closed ablazhov closed 4 years ago

ablazhov commented 4 years ago

On every first start after Windows boots up there is a delay of about 9 seconds. If I leave the audio streaming for a little bit, then restarting DAS brings the delay to about 1.5-2 seconds, which is perfect. Well, it may take 2 or 3 restarts to get this short delay. What causes this initial long delay? Can't it be somehow avoided at all? My PC is on WiFi connection, no network traffic. Windows 7 x64.

Great piece of software! Thank you so much for all your efforts! Is there a way I can donate to the project?

SamDel commented 4 years ago

There always a delay, because of the buffers on the Chromecast & application. I'm not sure why the audio delay varies for you. Is the option 'Stream Format' on 'Mp3 - 320kbps' (default) for you? What type of Chromecast are you using?

You can contribute to the project by (keep) posting issues, or writing code & pull requests!

ablazhov commented 4 years ago

Stream format is 'Wav (44100 Hz)' Chromecast Audio (gen. 2 I believe) Lag Control is 700.

Just FYI, when I use Foobar2000 + UPnP MediaRenderer Output plugin + BubbleUPnPServer (no transcoding) for streaming FLAC and mp3 music I have a constant delay of about 1 sec.

SamDel commented 4 years ago

Thanks! To pinpoint: Maybe the soundcard has to 'wake up' after Windows boots up. DAS waits until there's 310k of audio data captured before it starts streaming.

ablazhov commented 4 years ago

I believe the problem isn't related to the audio subsystem. I can here sounds and music on my headphones immediately after Windows boots up. I discovered that I don't have to restart DAS to get the shorter delay - all it takes is restart the connection to my Cromecast Audio using the Start/Stop button from DAS' control panel. It takes several (5-6-7) restarts though before it eventually gets there. No, auto-start is disabled. Waiting doesn't help. Looks like the only thing that helps is reconnecting several times to Chromecast Audio. Initially I thought I have to stream some music first before I can get the shorter delay, but now I'm pretty sure this is not the case. Do you know of other DAS users with Chromecast Audio?

SamDel commented 4 years ago

Then it's indeed most likely related to the connection with the Chromecast. You can also try to put the lag control on 1 (left side) for about 10 seconds, and then back to 700. (Not a proper solution off course)

I'm going to do a test with my Chromecast audio...

SamDel commented 4 years ago

I have the same behaviour with my Chromecast audio (tested once). So I can investigate and will come back to you later...

ablazhov commented 4 years ago

I tested my Chromecast Audio with another computer on the same network and its behaviour is the same. Hope you will figure it out!

SamDel commented 4 years ago

In Setup 2.7.1.zip I increased the initial buffer from 310k to 350k. This audio buffer is send to the device when it starts playing. Can you try if it also works for you?

Sorry for the late response, I was busy with other things.

ablazhov commented 4 years ago

Looks like you've nailed it! Now every time I start DAS or reconnect it to my Chromecast Audio the delay is the same - about 2 seconds. Great Job!

SamDel commented 4 years ago

Nice, thanks!

ablazhov commented 4 years ago

Should I close the issue?

SamDel commented 4 years ago

Sure, I will close it. Let me know if there are further issues! I'll add the fix to the 2.8 release later!