Java JVM在释放VLCJ MediaPlayer时崩溃

Java JVM在释放VLCJ MediaPlayer时崩溃,java,jna,vlcj,Java,Jna,Vlcj,我使用的是OS X 10.11.6和Java 8u121,我正在尝试使用VLCJ 3.10.1(和VLC 2.2.4)对音频文件进行转码(从MP3到OGG Vorbis)。代码转换似乎工作正常,但我在发布MediaPlayer时出错 以下是我的最低测试代码,基于VLCJ repo的: public class VlcjTestMain { public static void main(String[] args) throws InterruptedException {

我使用的是OS X 10.11.6和Java 8u121,我正在尝试使用VLCJ 3.10.1(和VLC 2.2.4)对音频文件进行转码(从MP3到OGG Vorbis)。代码转换似乎工作正常,但我在发布
MediaPlayer
时出错

以下是我的最低测试代码,基于VLCJ repo的:

public class VlcjTestMain {

    public static void main(String[] args) throws InterruptedException {
        Path sourceFile = // source file here
        Path targetFile = // target file here

        new NativeDiscovery().discover();
        MediaPlayerFactory factory = new MediaPlayerFactory();
        MediaPlayer player = factory.newHeadlessMediaPlayer();

        CountDownLatch latch = new CountDownLatch(1);
        player.addMediaPlayerEventListener(new MediaPlayerEventAdapter() {
            @Override
            public void finished(MediaPlayer mediaPlayer) {
                latch.countDown();
            }

            @Override
            public void error(MediaPlayer mediaPlayer) {
                System.out.println("Rip failed");
                latch.countDown();
            }
        });

        String transcodeOpts =
                ":sout=#transcode{acodec=vorb,vcodec=dummy}:std{dst=" + targetFile.toAbsolutePath().toString() + ",mux=ogg,access=file}";
        player.playMedia(
                sourceFile.toAbsolutePath().toString(),
                transcodeOpts);

        latch.await();
        System.out.println("Finished!");

        player.release();
        System.out.println("Player released");

        factory.release();
        System.out.println("Factory released");
    }
}
转码成功完成,但在
player.release()
上,JVM崩溃并出现SIGSEGV错误:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00000001224e8649, pid=13561, tid=0x000000000000c253
#
# JRE version: Java(TM) SE Runtime Environment (8.0_121-b13) (build 1.8.0_121-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.121-b13 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [libvlc.dylib+0x6649]  libvlc_event_send+0x19
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
其余的崩溃日志


有人知道这是什么原因吗?

多亏卡布里卡的评论,我想我能够回答我的问题

tl;dr:
事件完成后,VLC仍然触发另外两个事件:
mediaChanged
newMedia
。如果在释放玩家后发生这种情况,它将崩溃

现在,这里是我实验的细节

我在Windows 10上尝试了相同的代码。它有时会工作,但最常见的是引发错误
java.lang.error:Invalid memory access
on
player.release()

然后,我尝试在
player.release()
之前添加一个
Thread.sleep(1000)
语句,但我无法再重现崩溃

因此,我使用了一个事件监听器来记录大多数事件,并将
Thread.sleep(1000)
语句保存在
player.release()之前。我注意到在
完成后收到了两个事件:首先是
mediaChanged
,然后是
newMedia
。下面是日志末尾的样子:

mediaStateChanged
完成
完了!
媒体改变
新媒体
[00000000 209F45B0]mux_ogg mux:Close[此行由VLCJ记录,而不是由我记录]
玩家释放
工厂放行

最后,我还尝试删除
sleep
语句,但在第二次
newMedia
事件(而不是第一次
完成
事件)后调用
player.release()
,我也无法重现崩溃。根据您发布的转储,可能本机代码仍在向您发送事件(通过libvlc_事件_发送)在Java端释放媒体播放器后。可能在某个地方出现了排序问题,或者vlcj清理中存在错误。我不确定。有趣的是,我想我会尝试记录事件侦听器接收到的所有事件,并在释放媒体播放器之前稍等片刻,看看我得到了什么……我会在尝试了之后更新我的问题我还将尝试在Windows上重复我的测试,看看它是否不同。这很难,因为vlcj的发行版()清理实际上是在其他任何事情之前显式取消注册本机事件侦听器。也许这在vlcj github项目页面上作为一个问题更好,由您决定。我会看看是否可以先找到更多的问题,但我可能会在稍后打开github问题,是的。我已经发布了一个带有我观察结果的答案-我认为这看起来确实像问题可能是由于在
完成后触发的事件引起的,尽管尝试释放媒体播放器(当然,只有在我没有立即释放媒体播放器时,我才能看到这些事件,所以我可能是错的…)。我猜这是我应该报告为错误的事情?