diff options
author | Sven Gothel <[email protected]> | 2014-02-16 06:12:45 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-02-16 06:12:45 +0100 |
commit | e685f79ec7071e266a1bd3d3ce3e742397b5372e (patch) | |
tree | 7328960c34c3083e91ec47793993c686359e0015 /src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java | |
parent | a6acce1be19060a6a4801582f0534e0d6887467a (diff) |
Bug 927: Fix minor MT issues w/ libav/ffmpeg
Issue:
[NULL @ 0x35bde60] insufficient thread locking around avcodec_open/close()
Decorating said libav functions w/ mutex lock/release.
Abstract impl. to either use pthread or JNI Monitor,
but using the latter to reduce dependencies (ming64 windows).
FFMPEGNatives is now an abstract class containing the
'static final Object mutex_avcodec_openclose'
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java index bc0865aa9..c3fc2898f 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java @@ -29,17 +29,23 @@ package jogamp.opengl.util.av.impl; import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; -interface FFMPEGNatives { +/* pp */ abstract class FFMPEGNatives { - boolean initSymbols0(long[] symbols, int count); - int getAvUtilMajorVersionCC0(); - int getAvFormatMajorVersionCC0(); - int getAvCodecMajorVersionCC0(); - int getAvResampleMajorVersionCC0(); - int getSwResampleMajorVersionCC0(); + private static final Object mutex_avcodec_openclose = new Object(); - long createInstance0(FFMPEGMediaPlayer upstream, boolean verbose); - void destroyInstance0(long moviePtr); + abstract boolean initSymbols0(long[] symbols, int count); + abstract int getAvUtilMajorVersionCC0(); + abstract int getAvFormatMajorVersionCC0(); + abstract int getAvCodecMajorVersionCC0(); + abstract int getAvResampleMajorVersionCC0(); + abstract int getSwResampleMajorVersionCC0(); + + final long createInstance0(FFMPEGMediaPlayer upstream, boolean verbose) { + return createInstance0(mutex_avcodec_openclose, upstream, verbose); + } + abstract long createInstance0(Object mutex_avcodec_openclose, FFMPEGMediaPlayer upstream, boolean verbose); + + abstract void destroyInstance0(long moviePtr); /** * Issues {@link #updateAttributes(int, int, int, int, int, int, int, float, int, int, String, String)} @@ -56,24 +62,24 @@ interface FFMPEGNatives { * @param aPrefSampleRate * @param aPrefChannelCount */ - void setStream0(long moviePtr, String url, boolean isCameraInput, - int vid, String sizes, int vWidth, int vHeight, - int vRate, int aid, int aMaxChannelCount, int aPrefSampleRate); + abstract void setStream0(long moviePtr, String url, boolean isCameraInput, + int vid, String sizes, int vWidth, int vHeight, + int vRate, int aid, int aMaxChannelCount, int aPrefSampleRate); - void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); + abstract void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); - int getVideoPTS0(long moviePtr); + abstract int getVideoPTS0(long moviePtr); - int getAudioPTS0(long moviePtr); + abstract int getAudioPTS0(long moviePtr); /** * @return resulting current video PTS, or {@link TextureFrame#INVALID_PTS} */ - int readNextPacket0(long moviePtr, int texTarget, int texFmt, int texType); + abstract int readNextPacket0(long moviePtr, int texTarget, int texFmt, int texType); - int play0(long moviePtr); - int pause0(long moviePtr); - int seek0(long moviePtr, int position); + abstract int play0(long moviePtr); + abstract int pause0(long moviePtr); + abstract int seek0(long moviePtr, int position); /** FFMPEG/libAV Audio Sample Format */ public static enum SampleFormat { |