2 Replies Latest reply on Dec 9, 2011 2:02 AM by acon cagua

    NetStreamSwitchManager never shut down, breaking dynamic switching

    acon cagua Level 1

      Hi guys,

      I realized that NetStreamSwitchingManager is never ever shut down. By shutting down I mean stopping it's rule checking timer and disconnecting (removing event handlers) from underlying NetConnection and NetStream. This totally breaks dynamic switching when your player attempts to play items following the first dynamic one - since multiple switching managers attempt to evaluate rules and switch streams. It causes problems even if the following items are not dynamic - the previous switching manager continues with checking switching rules on these (not dynamic) resources. It might also be the cause of (or at least related to) the weird behavior reported by Silviu Vergoti in the thread InsufficientBufferRuleReporting bogus buffer lengths with live dynamic MBR streams.

       

      I fixed it by implemeting a new "NetStreamSwitchingManager.shutdown()" method, that performs actions mentioned above, and by calling that method from netLoader.executUnload() - please see below.

       

      Would you please look at it and possibly say whether it makes sense or not?

       

      I'm using OSMF 1.6.1, but the same probably applies to 1.6, too.

       

      Thanks and regards,

      Jiri Volejnik

       


      NetStreamSwitchManagerBase:


      public function shutdown():void
      {
              // Subclasses should override.
              _autoSwitch = false;
      }

       


      NetStreamSwitchManager:


      public override function shutdown():void
      {
            super.shutdown();
            if (checkRulesTimer != null)
            {
                 if (checkRulesTimer.running)
                      checkRulesTimer.stop();
                 checkRulesTimer.removeEventListener(TimerEvent.TIMER, checkRules);
            }
            if (netStream != null)
            {
                 netStream.removeEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
                 NetClient(netStream.client).removeHandler(NetStreamCodes.ON_PLAY_STATUS, onPlayStatus);
            }
      }

       


      NetLoader:


      override protected function executeUnload(loadTrait:LoadTrait):void {
           ...
           if (netLoadTrait != null)
           {
                ...
                if (netLoadTrait.switchManager != null)
                {
                     netLoadTrait.switchManager.shutdown();
                     netLoadTrait.switchManager = null;
                }
           }
           ...
      }