Author: awy
Date: Tue Sep 30 07:43:44 2008
New Revision: 3023

URL: http://svn.slimdevices.com?rev=3023&root=Jive&view=rev
Log:
Fix track-start for short tracks.
User DSCO for normal and error end-of-stream, and STMf just for stream flush 
indications.

Modified:
    7.3/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua
    7.3/trunk/squeezeplay/src/squeezeplay/share/jive/net/SlimProto.lua

Modified: 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua?rev=3023&root=Jive&r1=3022&r2=3023&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua 
(original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua Tue Sep 
30 07:43:44 2008
@@ -26,6 +26,14 @@
 local DECODE_UNDERRUN       = (1 << 1)
 local DECODE_ERROR          = (1 << 2)
 local DECODE_NOT_SUPPORTED  = (1 << 3)
+
+-- disconnect codes
+local TCP_CLOSE_FIN           = 0
+local TCP_CLOSE_LOCAL_RST     = 1
+local TCP_CLOSE_REMOTE_RST    = 2
+local TCP_CLOSE_UNREACHABLE   = 3
+local TCP_CLOSE_LOCAL_TIMEOUT = 4
+
 
 
 function __init(self, jnt, slimproto)
@@ -71,7 +79,8 @@
        self.sentOutputUnderrunEvent = false
        self.sentAudioUnderrunEvent = false
 
-
+       log:info("playback init")
+       
        return obj
 end
 
@@ -161,8 +170,8 @@
        end
 
 
-       -- XXXX
-       if self.stream and (self.tracksStarted < status.tracksStarted) then
+       -- Cannot test of stream is not nil because stream may be complete (and 
closed) before track start
+       if status.decodeState & DECODE_RUNNING and (self.tracksStarted < 
status.tracksStarted) then
 
                log:info("status TRACK STARTED")
                self:sendStatus(status, "STMs")
@@ -223,7 +232,7 @@
 end
 
 
-function _streamDisconnect(self, flush)
+function _streamDisconnect(self, reason, flush)
        if not self.stream then
                return
        end
@@ -240,14 +249,21 @@
        self.stream = nil
 
        -- Notify SqueezeCenter the stream is closed
-       self.slimproto:sendStatus('STMf')
+       if (flush) then
+               self.slimproto:sendStatus('STMf')
+       else
+               self.slimproto:send({
+                       opcode = "DSCO",
+                       reason = reason,
+               })
+       end
 end
 
 
 function _streamWrite(self, networkErr)
        if networkErr then
                log:error("write error: ", networkErr)
-               self:_streamDisconnect()
+               self:_streamDisconnect(TCP_CLOSE_LOCAL_RST)
                return
        end
 
@@ -263,7 +279,7 @@
 function _streamRead(self, networkErr)
        if networkErr then
                log:error("read error: ", networkErr)
-               self:_streamDisconnect()
+               self:_streamDisconnect(TCP_CLOSE_LOCAL_RST)
                return
        end
 
@@ -279,7 +295,7 @@
                n = self.stream:read(self)
        end
 
-       self:_streamDisconnect()
+       self:_streamDisconnect((n == false) and TCP_CLOSE_FIN or 
TCP_CLOSE_LOCAL_RST)
 end
 
 
@@ -300,7 +316,7 @@
 
                -- if we aborted the stream early, or there's any junk left 
                -- over, flush out whatever's left.
-               self:_streamDisconnect(true)
+               self:_streamDisconnect(nil, true)
 
                Decode:start(string.byte(data.mode),
                             string.byte(data.transitionType),
@@ -335,7 +351,7 @@
                -- quit
                -- XXXX check against ip3k
                Decode:stop()
-               self:_streamDisconnect()
+               self:_streamDisconnect(nil, true)
 
                self.tracksStarted = 0
 

Modified: 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/net/SlimProto.lua
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/share/jive/net/SlimProto.lua?rev=3023&root=Jive&r1=3022&r2=3023&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/net/SlimProto.lua 
(original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/net/SlimProto.lua Tue Sep 
30 07:43:44 2008
@@ -208,8 +208,11 @@
        end,
 
        DSCO = function(self, data)
-               -- XXXX
-               log:warn("TODO")
+               assert(data.reason)
+               
+               return {
+                       packNumber(data.reason, 1),
+               }
        end,
 
        aude = function(self, packet)

_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins

Reply via email to