Bug 1289 - Playlist stops at track boundary
: Playlist stops at track boundary
Status: RESOLVED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Audio
: unspecified
: PC Windows XP
: P2 normal with 1 vote (vote)
: ---
Assigned To: Vidur Apparao
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-04-02 13:02 UTC by Greg Friedman
Modified: 2008-08-18 10:54 UTC (History)
1 user (show)

See Also:
Category: ---


Attachments
debug log capturing the behavior (20.70 KB, text/plain)
2005-04-02 13:03 UTC, Greg Friedman
Details
Log with Vidur's patch installed (26.26 KB, text/plain)
2005-04-23 07:52 UTC, Greg Friedman
Details
Log showing problem with latest (2005-4-23) nightly (31.15 KB, text/plain)
2005-04-23 20:16 UTC, radish
Details
Log w/"No pending chunks" traces (34.65 KB, text/plain)
2005-04-25 19:01 UTC, Greg Friedman
Details
log with 6.0.2 4-25 (48.11 KB, text/plain)
2005-04-25 21:10 UTC, radish
Details
log with http trace as well as source (2.36 MB, text/plain)
2005-04-26 21:03 UTC, radish
Details
second go with http & source (2.44 MB, text/plain)
2005-04-27 19:41 UTC, radish
Details
Log with source & http (1.12 MB, text/plain)
2005-04-27 20:17 UTC, Greg Friedman
Details
proposed fix (435 bytes, patch)
2005-04-28 16:38 UTC, Vidur Apparao
Details | Diff
patch with shutdown (1.08 KB, patch)
2005-04-29 08:47 UTC, Vidur Apparao
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Friedman 2005-04-02 13:02:21 UTC
I'm getting frequent 'stops' using 6.0 whether on SS2 or SB1s.  Tracks
will play for a while and then the playlist will stop and i'll need to
hit pause to restart.  It always happens at a track boundary - eg
track 9 will end, the title of track 10 will show but it wont play
until i hit pause.
Comment 1 Greg Friedman 2005-04-02 13:03:12 UTC
Created attachment 391 [details]
debug log capturing the behavior

I'm having the same problem as the original poster. In my case, it's 
happening on a SB2 with 6.0. It's stopping at the end of FLAC tracks. I also 
have an SB1 connected to the same server, but the two devices are not 
synced.

I've attached a d_source log. I believe that what I saw happen was as 
follows:

SB1: Manually paused in the middle of playing the album O Brother Where Art 
Thou for at least an hour.
SB2: Playing Diana Krall

SB2: Hits the end of the song Temptation and stops.
SB1: Wakes up and begins playing the next track on O Brother Where Art Thou. 
SB2 remains stopped.
Comment 2 KDF 2005-04-02 15:17:26 UTC
is this happening with a particular skin?  I'm not seeing the same thing here,
but I always use fishbone.  The reason I ask is that most skins refresh on a
track boundary, and we have seen problems before where the url in the refresh
can somehow get locked into a command or player.
Comment 3 Greg Friedman 2005-04-02 15:30:48 UTC
I'm also using Fishbone. I'm not convinced, though, that I've always had a UI 
up when the problem has occured (I run SS as a service on a headless system).
Comment 4 Simon Still 2005-04-02 16:41:06 UTC
Actually, pause doesnt seem to restart - I find i need to skip to another track
and then back to get it to play.
Comment 5 KDF 2005-04-02 19:12:31 UTC
I have put one of my SB1's on pause.  I have an SB2 playing tracks for 5 hours
now with no pause on SB2 and no unpause on the SB1.  Pressing pause on the
remote for the SB1 starts playback from the point it was paused 5 hours before.
 The SB2 hasn't been playing FLAC tracks, but have switched to that now.  SB1 is
paused mid-flac track.  This is using the latest nightly build.  That would be
worth a try if you have no already tried it.
Comment 6 Blackketter Dean 2005-04-04 13:29:04 UTC
This is a slimserver bug, moving to that product.
Comment 7 Pete Brubaker 2005-04-19 11:39:55 UTC
I'm also seeing the bug with Softsqueeze.  At the end of a track I need to press
next track for the next track to play.  Sometimes it reports that the next track
is playing, and it even reports the time left of the next track without any
audio.   More frequently however the track playing will just halt at the end and
the "next" button will have to be clicked before the next track will play.  This
was happening with 6.0 and 6.01.  I'm running Fedora Core 3, Slimserver 6.01,
and SoftSqueeze 2.0b5.
Comment 8 KDF 2005-04-19 12:35:35 UTC
I will again state that I have not seen this with april 02.  It would be
(hopefully) useful to see d_source logs from someone using the latest NIGHTLY
BUILD. 
Comment 9 Greg Friedman 2005-04-23 07:52:07 UTC
Created attachment 452 [details]
Log with Vidur's patch installed

This is a log of the multi-player synchronization problem with Vidur's patch
installed.

Two players are involved: "Family Room" and "Office".

Sequence of events is as follows:

1. Begin playing Diana Krall album on Family Room
2. Begin playing O'Brother Where Art Thou on Office
3. First song (Stop This World) completes on Family Room - player does not
advance to the next song. This occurs in the log at 7.33.05.XXXX.
4. First song (Po Lazarus) completes on Office. Both Office and Family Room
advance to the next song. This occurs in the log at 7.34.37.XXXX.

I stopped the log at this point. The behavior remains the same throughout the
rest of the album on Family Room - it stops at the end of each track and does
not progress until Office reaches the end of its current track.
Comment 10 radish 2005-04-23 20:16:44 UTC
Created attachment 454 [details]
Log showing problem with latest (2005-4-23) nightly
Comment 11 radish 2005-04-23 20:20:09 UTC
I've attached a log showing the problem from the latest nightly (6.0.2 4-23). I
didn't specifically apply Vidur's patch as it appeared that his changes were
already in the nightly build version. 

The test setup is exactly as before (see my forum post), the "pause" is between
22:50 and 22:56 (the SB1 continued playing as normal, the SB2 waited for the
next transition on the SB1).
Comment 12 Vidur Apparao 2005-04-25 11:12:18 UTC
Hmm...neither of the new logs includes any of the new debug messages (a line
including the phrase "pending chunks"). I'm not sure how that's possible with
the patch applied or a recent nightly build - all codepaths following the line
starting with "playing out before starting next song..." lead to one of the new
messages.

Greg, I presume that you're using slimserver.pl and not slim.exe (if you're on
Windows), after you applied the patch? Or if you're using an nightly please
confirm that it's 4/22 or later.
Comment 13 Greg Friedman 2005-04-25 11:45:09 UTC
I plead ignorance on Slim.pl vs. Slim.exe. I'm running 6.01 release as a 
service on W2k3. After hand-patching the affected files, I bounced the service 
(net stop slimserver, net start slimserver).

So how do I run slim.pl? Is it as simple as stopping the service and running 
slim.pl from the command line? Instructions or a pointer to instructions would 
be appreciated, and I'll give it another go tonight.
Comment 14 Jeff Coffler 2005-04-25 12:01:10 UTC
Hey Greg, I know this ...

First, be sure that ActiveState PERL is installed on your Windows system.

Then, stop the service, CD to your slimserver installation directory in a 
command window, and type:

<path-to-activestate-perl>\perl.exe server\slimserver.pl

That'll do it ...
Comment 15 Jeff Coffler 2005-04-25 12:03:55 UTC
Oh, one more thing:

Be aware that if you patch a SlimServer source on Windows, but are running 
the .EXE file, the PERL files are never used.  The .EXE file (which you'd be 
running as a service) contains the interpreter, and the perl files aren't 
actually used in that context.

You MUST run via PERL (not the .EXE) to have the perl files used ...

So, basically, due to your methods (stop/start the service), you ran the 
identical code both times.

Let me know if you have further questions.  Give me a call tonight (get my # 
from Nigel) if you have any problems ...
Comment 16 Greg Friedman 2005-04-25 16:32:04 UTC
Thanks, guys.

Jeff - From Vidur's comments, I figured that Slim.exe wasn't picking up 
changes to local perl files. I'll give it a whirl tonight and give you a call 
if I have problems. Thanks!
Comment 17 radish 2005-04-25 17:57:19 UTC
Is it possible that the windows exe also isn't built from the latest source?
(seems unlikely to me). As I mentioned, I was running latest nightly, and the
source files had the extra debug messages, but none came out. If I get a chance
I'll install activestate on my server and try that, seems a bit weird though.
Comment 18 Greg Friedman 2005-04-25 19:01:59 UTC
Created attachment 457 [details]
Log w/"No pending chunks" traces

This captures the behavior with Vidur's traces.

Scenario (and the specific albums/tracks involved) are the same as in my
previous post.
Comment 19 radish 2005-04-25 21:10:34 UTC
Created attachment 458 [details]
log with 6.0.2 4-25

OK, so I upgraded again to the latest nightly. This time the debug messages
seem to be appearing, hope this is more useful.
Comment 20 Vidur Apparao 2005-04-26 08:49:44 UTC
I know I'm being a pain about this, but remote debugging is hard (radish, I
think you suggested at one time that I could Remote Desktop to your machine?).
In either case, could you turn on --d_http as well for the problem and post a
log? Thanks.
Comment 21 Vidur Apparao 2005-04-26 17:41:42 UTC
The Remote Desktop offer was for another bug. Sorry.
Comment 22 Chris Masterton 2005-04-26 18:22:43 UTC
Hi,

I just wanted to lend any support I can to this bug. I am seeing exactly the 
same thing. It always happens at track boundaries. Sometimes pause and play 
works, sometimes I need to select the next track to "unpause" playback. 

If it helps at all I'm not seeing this bug: http://forums.slimdevices.com/
showthread.php?t=13726&page=2&pp=10 and the vast majority of my collection is in 
FLAC. 

I'm using a recent nightly build: 6.1.0 - 2895

Please let me know if there is anything I can do to help with fixing this one.

Chris.
Comment 23 radish 2005-04-26 21:03:01 UTC
Created attachment 464 [details]
log with http trace as well as source

Vidur - as requested a log with http enabled as well as source. Setup otherwise
exactly as before.
Comment 24 Vidur Apparao 2005-04-27 09:43:01 UTC
Looks like the last log was just --d_http. I don't see the --d_source. :-(

FYI - we're under external pressure to get 6.0.2 out, but I'll continue treating
this bug as a high priority. Not to worry, once we get a fix, I'll get it into a
stable build soon.
Comment 25 radish 2005-04-27 19:41:56 UTC
Created attachment 466 [details]
second go with http & source

Sorry - I got in a tangle with starting & restarting the server last night.
Here's another attempt. I checked this one and it looks like it has both sets
of messages to me.
Comment 26 Greg Friedman 2005-04-27 20:17:55 UTC
Created attachment 467 [details]
Log with source & http

Another log of my repro in case it adds value to Radish's.

Same albums, same scenario as before. Generated by the release drop of 6.01
with Vidur's changes applied.
Comment 27 Vidur Apparao 2005-04-28 14:23:38 UTC
OK. I finally was able to recreate this problem and I'm stumped so far. Here's
what I know:

1) SlimServer closes the streaming socket to the SB2 as expected. This does not
result in a FIN/RST TCP packet as one would expect. The socket remains in the
ESTABLISHED state according to netstat. Somewhere between our call to close() at
the Perl level and the TCP implementation, the close seems to get lost.

2) This only happens on Windows. I couldn't recreate on OS X. I don't know if
this is a function of the Perl implementation or the OS.

3) This only happens if the track playing on the SB1 is being transcoded to PCM.
I can't recreate if the non-FLAC track is MP3.

4) This only happens if the track on the SB1 starts after the track on the SB2.

I'll continue to investigate...
Comment 28 Vidur Apparao 2005-04-28 16:38:25 UTC
Created attachment 468 [details]
proposed fix

I've attached a possible fix. It seems that either Perl or Windows may be
putting the socket in a state that delays closing. Could you guys apply and let
me know if you see an improvement?
Comment 29 radish 2005-04-28 18:12:17 UTC
I just patched my server and retried the same test case I've been using all
along - looks good now! Any idea when this can be rolled into an exe bundle so I
can run it as a service?

Thanks for your help on this Vidur, much appreciated. Now if only someone could
fix 1434 I'd be totally happy with my flac rips ;)
Comment 30 Greg Friedman 2005-04-28 18:42:41 UTC
I can confirm that your patch fixes the problem. 

An alternative to setting SO_DONTLINGER is to call 

$httpClient->shutdown(2);

immediately before the call to close. Setting SO_DONTLINGER before calling 
close will cause any unsent data in the send buffer to be dropped on the 
floor. Calling shutdown will allow data in the send buffer to get sent and 
should guarantee that a FIN is sent after the buffer is drained.

I tested with the call to shutdown, and it works on my system. It's probably 
not a bad idea to call it on all platforms, but you probably know the 
idiosyncracies of the various socket implementations better than I do.

MSDN docs on shutdown are at the following link and should apply if Perl's 
socket APIs are a shim:

http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/winsock/winsock/shutdown_2.asp

Thanks for debugging this!
Comment 31 Vidur Apparao 2005-04-28 21:33:09 UTC
I was under the impression that SO_DONTLINGER did a graceful shutdown and that
SO_LINGER with a timeout of 0 threw away remaining data...but I'm seeing
problems with the web interface with the SO_DONTLINGER patch. Thanks for the tip
about shutdown, Greg. I'll investigate and post a new patch.
Comment 32 Vidur Apparao 2005-04-29 08:47:19 UTC
Created attachment 473 [details]
patch with shutdown

It seems that shutdown() is definitely a better option (thanks again, Greg).
I'll get this patch into the 6.1 trunk and 6.0.x branch. We haven't yet decided
whether to do a 6.0.3, but the nightly 6.0.x build is still available. Check
http://www.slimdevices.com/downloads/nightly/latest/6.0.3/ in the next 24
hours.

The patch is pretty conservative about using shutdown(). I'm still a little
wary, given potential differences between Windows and other platforms (see
http://www.experts-exchange.com/Programming/Programming_Platforms/Q_20341636.html,
for example). But, with a little more testing, we can consider the shutdown()
on other platforms and non-streaming connections.
Comment 33 Vidur Apparao 2005-04-29 11:08:27 UTC
Fix checked into trunk (change 3104) and 6.0.x branch (3105).
Comment 34 radish 2005-04-29 17:04:39 UTC
I'll wait for the next nightly and give it a try.

Thanks again.