diff options
author | Sven Gothel <[email protected]> | 2014-01-26 03:00:36 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-01-26 03:00:36 +0100 |
commit | 323476249dd94e605b6627582ad0dbcaede0159e (patch) | |
tree | 6aa545dfda4e419388f33613337b00e8c219222d /src | |
parent | 87135467c4f292f7e43bc3957784b0e43769c9cc (diff) |
GLMediaPlayer: Add user attached objects, similar to GLContext - Allowing GLMediaEventListener impl. to access GLMediaPlayer associated objects
Diffstat (limited to 'src')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java | 20 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java | 19 |
2 files changed, 38 insertions, 1 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java index 22a5cfb32..9957f2093 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java @@ -391,7 +391,7 @@ public interface GLMediaPlayer extends TextureSequence { public AudioSink getAudioSink(); /** - * Releases the GL and stream resources. + * Releases the GL, stream and other resources, including {@link #attachObject(String, Object) attached user objects}. * <p> * <a href="#lifecycle">Lifecycle</a>: <code>ANY</code> -> {@link State#Uninitialized} * </p> @@ -626,4 +626,22 @@ public interface GLMediaPlayer extends TextureSequence { /** Return all {@link GLMediaEventListener} of this player. */ public GLMediaEventListener[] getEventListeners(); + + /** + * Returns the attached user object for the given name. + */ + public Object getAttachedObject(String name); + + /** + * Attaches the user object for the given name. + * Returns the previously set object, may be null. + */ + public Object attachObject(String name, Object obj); + + /** + * Detaches the user object for the given name. + * Returns the previously set object, may be null. + */ + public Object detachObject(String name); + } diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index 0bd1aa932..7cea51dc8 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -30,6 +30,7 @@ package jogamp.opengl.util.av; import java.io.IOException; import java.net.URI; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -374,6 +375,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { removeAllTextureFrames(gl); textureCount=0; changeState(event_mask, State.Uninitialized); + attachedObjects.clear(); return state; } } @@ -1594,6 +1596,23 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { private final Object eventListenersLock = new Object(); + @Override + public final Object getAttachedObject(String name) { + return attachedObjects.get(name); + } + + @Override + public final Object attachObject(String name, Object obj) { + return attachedObjects.put(name, obj); + } + + @Override + public final Object detachObject(String name) { + return attachedObjects.remove(name); + } + + private final HashMap<String, Object> attachedObjects = new HashMap<String, Object>(); + protected static final String toHexString(long v) { return "0x"+Long.toHexString(v); } |