bhattisatish / squeezelite

Automatically exported from code.google.com/p/squeezelite
Other
1 stars 0 forks source link

SqueezeLite does not release the Alsa device once playback is stopped #83

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. play something in squeezelite to Alsa device
2. stop squeezelite playback
3. try playing to same alsa device, using any other Alsa audio app. For 
example, speaker-test 

What is the expected output? What do you see instead?

It is expected that squeezelite will release device once playback is stopped. 
This does not happen, so all other application return error message:

Playback open error: -16,Device or resource busy

The only way to restore audio functionality (AFAIK) is to stop squeezelite.

What version of the product are you using? On what operating system?

Squeezelite v1.6.4-test, FC20

Please provide any additional information below.

This behaviour, for me, makes it impossible to use my dedicated media player 
for any other use. Cant watch videos in XBMC, cant use MPD - or any other audio 
application for that matter.

MPD releases Alsa device. XBMC releases Alsa device. Almost every other audio 
app I know of releases Alsa device when not playing.

Is it possible that I misconfigured something, or is this behaviour intended? 
If it is intended, is there any chance that a configuration option for people 
in my situation may be added?

Thank you for looking into this, and Happy New Year!

Original issue reported on code.google.com by and...@falout.org on 1 Jan 2015 at 4:48

GoogleCodeExporter commented 8 years ago
If you "power off" the player in LMS then it will release the audio device.  
Otherwise it keeps it open.  

If you use an audio device which uses a software mixer then it can share with 
other applications.

Original comment by trio...@btinternet.com on 1 Jan 2015 at 10:40

GoogleCodeExporter commented 8 years ago
Thank you for you reply, Triode!

Can you help me understand, what are the benefits of keeping device open when 
not playing?

And what would be the downside of releasing the device?

BTW, "power off" requires manual intervention, just as stopping squeezelite 
does - and it has more or less same effect.

Using software mixer device is not an option for audiophile quality playback, 
unfortunately.

Thank you for your advice,
Andrej

Original comment by and...@falout.org on 2 Jan 2015 at 12:27

GoogleCodeExporter commented 8 years ago
The LMS protocol does not differentiate between pause and stop.  For audiophile 
purposes squeezelite keeps sending digital 0 at the previous track sample rate 
when not playing - this means that if you pause and restart you don't get 
clicks on dacs which make noises when the clock is dropped.  This is a design 
feature of squeezelite.

The turn off output when "off" was added for your case - all you need do is 
logically turn the player off from LMS/iPeng or other LMS control application.

Original comment by trio...@btinternet.com on 2 Jan 2015 at 11:07

GoogleCodeExporter commented 8 years ago
Thanks for that clarification.

I must say, I did not see this behaviour with any of the players that do 
release the device, with any of that DACs I had (with exception of some DSD 
DACs). Would it be fair to say that this is therefore a "design feature" 
intended to work around a fault in some DACs?

Would you accept a patch, that adds a command line option to release device 
when not playing?

Thanks,
Andrej

Original comment by and...@falout.org on 3 Jan 2015 at 12:45

GoogleCodeExporter commented 8 years ago
This is the long term behavior of squeezebox hardware players - due to the 
impact on some spdif dacs of disabling the output.

How do you define not playing - do you so it when you pause, or when there's a 
drop in audio meaning that you need to make up samples or underrun?

Original comment by trio...@btinternet.com on 3 Jan 2015 at 11:53

GoogleCodeExporter commented 8 years ago
Hi again, and thank you very much for your advice and help.

Ah yes, some old SPDIF DACs had this issue. It was probably 10 years now that I 
did not see one with it.

Pause=not playing. 
Play=playing

Playing silence due to under-run or source being silent is still playing in my 
book.

So simply following SBS pause/play commands should be perfectly OK I would say.

Probably not a bad idea is what XBMC guys did, they have a configurable delay 
after they stop playback and before they release card. I think it is 3 or 4 
seconds by default in XMBC. Even 10 seconds should work for most people, and 
catch all probable intervals between two tracks in the playlist.

Original comment by and...@falout.org on 4 Jan 2015 at 4:39

GoogleCodeExporter commented 8 years ago
Please try latest git - I have added a -C "close" option for this.

Original comment by trio...@btinternet.com on 11 Jan 2015 at 8:20

GoogleCodeExporter commented 8 years ago
I am humbled by your kind consideration!

I have started the new instance:

root      4550     1  0 18:50 ?        00:00:00 
/storage/usr-src/squeezelite/squeezelite/squeezelite -s localhost -o 
plughw:CARD=Intel,DEV=0 -d all info -f /var/log/squeezelite-1.log -C 5 -m 00 04 
21 F2 00 01 -n Dev IHD (Int) A -z -P /tmp/startSqueezelite.pid

/storage/usr-src/squeezelite/squeezelite/squeezelite --version
Option error: --version
Squeezelite v1.8-dev

I did not even attempt to play anything, then:

speaker-test --device=plughw:CARD=Intel,DEV=0 -c 2

speaker-test 1.0.27.2

Playback device is plughw:CARD=Intel,DEV=0
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Playback open error: -16,Device or resource busy

If I try to play something via SBS on that instance, then pause it and wait 5 
seconds, then repeat test, it works as expected:

speaker-test --device=plughw:CARD=Intel,DEV=0 -c 2

speaker-test 1.0.27.2

Playback device is plughw:CARD=Intel,DEV=0
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 64 to 1048576
Period size range from 32 to 524288
Using max buffer size 1048576
Periods = 4
was set period_size = 262144
was set buffer_size = 1048576
 0 - Front Left
...

So apparently SL starts and opens audio device? Would it be possible to have it 
not do that, when -C is used?

Thanks!

Original comment by and...@falout.org on 12 Jan 2015 at 7:31

GoogleCodeExporter commented 8 years ago
Please try the latest git - I've updated to hopefully allow this.

You will need to use the -r option to set the maximum sample rate supported as 
otherwise this requires the device to be opened to establish it.

Original comment by trio...@btinternet.com on 12 Jan 2015 at 7:30