Skip to main content

Waiting for a stop on service context never updates ServiceContextListener

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
2 replies [Last post]
david_crandall
Offline
Joined: 2010-01-05

I'm writing a simple little TV tune application.
When I initialize everything, I add a ServiceContextListener to my ServiceContext.
this ServiceContextListener seems to catch most of my NormalContentEvent events, and I can tune.
However, when I go to channel change, an interesting phenomena happens.
I issue a 'stop' on my ServiceContext. I then wait to hear something back from my ServiceContextListener about the presentation being stopped.
I get nothing back.
So after some digging, I found myself in ServiceContextImpl.java

       CallerContext callerContext;
        synchronized (callerContextMutex)
        {
            callerContext = callerContextList;
        }
        if (callerContext != null)
        {
           System.out.println("Caller context is not null...2");
            // Execute the runnable in each caller context in callerContextList
            callerContext.runInContext(new Runnable()
            {
                public void run()
                {
                   System.out.println("Running the updater...");
                    // Notify listeners. Use a local copy of data so that it
                    // does not change while we are using it.
                    CallerContext cc = callerContextManager.getCurrentContext();
                    CCData data = getCCData(cc);
                    if ((data != null) && (data.listeners != null))
                    {
                       System.out.println("Context was not nulll...........");
                        data.listeners.receiveServiceContextEvent(event);
                    }
                    else
                    {
                        if (true)
                        {
                            log.debug("data or listeners was null - not notifying of event: " + event + ": "
                                    + getDiagnosticInfo());
                        }
                    }
                    System.out.println("Whoa....");

I'll see the "Running the updater..." printlines for every time we hear a NormalContentEvent. However, on my stop, I'll only see the lines up to runInContext. I'm a little at a loss as to what I could be doing that could break this. I have other applications that seem to do exactly what I'm doing, and they 'stop' just fine.
Thanks in advance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
scottdeboy
Offline
Joined: 2009-02-02

Can you attach a log with java debug enabled in mpeenv.ini?
Thanks
Scott

david_crandall
Offline
Joined: 2010-01-05

I have some logs for this, I just can't figure out how to attach them. Apologies.
So basically I do this:

        if(svcCtx.getService() == null)
         return;

      stopped = false;
      svcCtx.stop();
      updateEverybody(String_friendlyStatus, "Tuning...stop issued, waiting");

      synchronized(tune_pending_lock)
      {
         try
         {
            while(!stopped)
            {
               System.out.println("***************Not stopped yet...************");
               tune_pending_lock.wait(1000);
            }
            updateEverybody(String_friendlyStatus, "Tuning...stop recieved");

         }catch(InterruptedException e)
         {
            System.out.println("interruption type thing happening");
         }
      }

And I never get my stop response here.

   private class SvcCtxListener implements ServiceContextListener
   {
      public void receiveServiceContextEvent(ServiceContextEvent e)
      {
         if(e instanceof PresentationTerminatedEvent)
         {
            System.out.println("***************************SUCCESSFUL PRESENTATION TERMINATED EVENT!!****************************");
            stopped = true;
         }

         //Update our status with a friendly
         //word on what just happened.
         if( (e instanceof NormalContentEvent) || (e instanceof AlternativeContentEvent) )
         {
  ///do stuff that's not important to this post...
         }

         if( e instanceof SelectionFailedEvent)
         {
            ///notification of a selection failed change that doesn't happen for the sake of this post...
         }
      }
   }

Now, if I don't do the synchronized 'loop' at the end of my stop function, I'm fine. I get the PresentationTerminatedEvent.
The logs show everything up until actually giving me a PresentationTerminatedEvent, the device stops and the video stops playing... so a stop is happening, it's like somehow there's a link between that loop at the end, and not getting my PresentationTerminatedEvent. It's super weird.