Commit 5df9e3d6 authored by Petri Hintukainen's avatar Petri Hintukainen

BD-J: Add separate event queue for media events.

parent 5c2cadd9
......@@ -92,6 +92,33 @@ public class BDJListeners {
}
public void putCallback(Object event) {
boolean mediaQueue = true;
/*
if (event instanceof PlaybackMarkEvent) {
} else if (event instanceof PlaybackPlayItemEvent) {
} else if (event instanceof UOMaskTableChangedEvent) {
} else if (event instanceof UOMaskedEvent) {
} else if (event instanceof PiPStatusEvent) {
} else if (event instanceof PanningChangeEvent) {
} else if (event instanceof AngleChangeEvent) {
} else if (event instanceof MediaSelectEvent) {
} else if (event instanceof GainChangeEvent) {
} else if (event instanceof ControllerEvent) {
}
*/
if (event instanceof ServiceContextEvent) {
mediaQueue = false;
} else if (event instanceof ResourceStatusEvent) {
mediaQueue = false;
} else if (event instanceof AppsDatabaseEvent) {
mediaQueue = false;
} else if (event instanceof PSR102Status) {
mediaQueue = false;
}
putCallback(event, mediaQueue);
}
public void putCallback(Object event, boolean mediaQueue) {
synchronized (listeners) {
for (Iterator it = listeners.iterator(); it.hasNext(); ) {
BDJListener item = (BDJListener)it.next();
......@@ -99,7 +126,11 @@ public class BDJListeners {
logger.info("Listener terminated: " + item.ctx);
it.remove();
} else {
item.ctx.putCallback(new Callback(event, item.listener));
if (mediaQueue) {
item.ctx.putMediaCallback(new Callback(event, item.listener));
} else {
item.ctx.putCallback(new Callback(event, item.listener));
}
}
}
}
......
......@@ -55,6 +55,7 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
this);
callbackQueue = new BDJActionQueue(this.threadGroup, "CallbackQueue");
mediaQueue = new BDJActionQueue(this.threadGroup, "MediaQueue");
userEventQueue = new BDJActionQueue(this.threadGroup, "UserEventQueue");
mountHomeDir(entry);
......@@ -197,35 +198,39 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
return eventQueue;
}
/* must be called from synchronized (this) {} */
private boolean putCallbackImpl(BDJAction cb, BDJActionQueue queue)
{
if (isReleased()) {
logger.error("callback ignored (xlet destroyed)");
return false;
}
if (queue == null) {
logger.error("callback ignored (no queue)");
return false;
}
queue.put(cb);
return true;
}
public boolean putCallback(BDJAction cb)
{
synchronized (this) {
if (isReleased()) {
logger.error("callback ignored (xlet destroyed)");
return false;
}
if (callbackQueue == null) {
logger.error("callback ignored (no queue)");
return false;
}
callbackQueue.put(cb);
return true;
return putCallbackImpl(cb, callbackQueue);
}
}
public boolean putMediaCallback(BDJAction cb)
{
synchronized (this) {
return putCallbackImpl(cb, mediaQueue);
}
}
public boolean putUserEvent(BDJAction cb)
{
synchronized (this) {
if (isReleased()) {
logger.error("UE callback ignored (xlet destroyed)");
return false;
}
if (userEventQueue == null) {
logger.error("UE callback ignored (no queue)");
return false;
}
userEventQueue.put(cb);
return true;
return putCallbackImpl(cb, userEventQueue);
}
}
......@@ -238,8 +243,8 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
}
}
if (!released) {
// callbackQueue
cnt++;
// callbackQueue, userEventQueue, mediaQueue
cnt += 3;
}
return cnt;
}
......@@ -446,6 +451,7 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
callbackQueue.shutdown();
userEventQueue.shutdown();
mediaQueue.shutdown();
EventQueue eq = eventQueue;
eventQueue = null;
......@@ -471,6 +477,7 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
container = null;
callbackQueue = null;
userEventQueue = null;
mediaQueue = null;
defaultLooks = null;
released = true;
}
......@@ -495,5 +502,6 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
private HashMap defaultLooks = new HashMap();
private BDJActionQueue callbackQueue;
private BDJActionQueue userEventQueue;
private BDJActionQueue mediaQueue;
private static final Logger logger = Logger.getLogger(BDJXletContext.class.getName());
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment