[vlc-devel] libvlc_media_player_stop

David Hoyt dhoyt at llnl.gov
Tue Oct 28 19:19:23 CET 2008


Here's the backtrace for the thread (using process explorer):

ntdll.dll!KiFastSystemCallRet
libvlccore.dll!vlc_join+0x38
libvlccore.dll!_vlc_thread_join+0xb4
libvlc.dll!libvlc_media_player_get_drawable+0x3c3
libvlc.dll!libvlc_media_player_stop+0x3a
jna13887.tmp+0xda37
jna13887.tmp+0x9182
jna13887.tmp+0x2161
jna13887.tmp!Java_com_sun_jna_Function_invokeVoid+0x35
jvm.dll!AsyncGetCallTrace+0x2d65d

It's basically that call to vlc_join() that's freezing the app - but I'm not
sure why that's causing the problem. 

-----Original Message-----
From: David Hoyt [mailto:dhoyt at llnl.gov] 
Sent: Monday, October 27, 2008 1:11 PM
To: 'Mailing list for VLC media player developers'
Subject: RE: [vlc-devel] libvlc_media_player_stop

Using JVLC and SWT, do:

1. Make sure you have a working SWT environment (use eclipse or get the SWT
jars - http://www.eclipse.org/swt/)

2. Create a class named "Utilities" in the org.videolan.jvlc package. Put
this in:

package org.videolan.jvlc;

import org.videolan.jvlc.internal.LibVlc.LibVlcInstance;

public class Utilities {
	public static LibVlcInstance getNativeInstance(JVLC vlc) {
		return vlc.getInstance();
	}
}

3. Create a class named "Main" in the default package. Put this in:

import java.io.File;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.videolan.jvlc.JVLC;
import org.videolan.jvlc.MediaPlayer;
import org.videolan.jvlc.Utilities;
import org.videolan.jvlc.internal.LibVlc;

class Main {

    public static void runMessageLoop(Shell shell) {
        if (shell == null) {
            throw new IllegalStateException("Please define the shell before
continuing");
        }

        Display display = shell.getDisplay();
        if (display != null && !display.isDisposed()) {
            while (!display.isDisposed() && !shell.isDisposed()) {
                if (!display.isDisposed() && !display.readAndDispatch()) {
                    display.sleep();
                }
            }
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        //<editor-fold defaultstate="collapsed" desc="GUI objects">
        final Display display = new Display();
        final Shell shell = new Shell(display);
        shell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
        shell.setLayout(new FillLayout());
        final Button btnSwitch = new Button(shell, SWT.PUSH);
        btnSwitch.setText("Switch");
        btnSwitch.setSize(100, 40);
        //</editor-fold>

        final Canvas[] canvases = new Canvas[24];
        final JVLC[] vlcs = new JVLC[canvases.length];
        final MediaPlayer[] mps = new MediaPlayer[canvases.length];

        for (int i = 0; i < canvases.length; ++i) {
            canvases[i] = new Canvas(shell, SWT.NONE);
            vlcs[i] = new JVLC(new String[]{
                "--plugin-path=" + new File(".").getAbsolutePath() + "\\" +
"plugins"
            });
        }

        btnSwitch.addSelectionListener(new SelectionAdapter() {

            FileDialog fd = null;

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (fd == null) {
                    fd = new FileDialog(shell, SWT.OPEN);
                    fd.setText("Select Media File");
                    fd.setFilterExtensions(new String[]{
                        "*.mjpg",
                        "*.avi",
                        "*.mpeg;*.mpg",
                        "*.mpeg2;*.mpg2",
                        "*.mpeg4;*.mp4",
                        "*.png",
                        "*.jpg;*.jpeg",
                        "*.*"
                    });
                    fd.setFilterNames(new String[]{
                        "Motion JPEG Files (*.mjpg)",
                        "AVI Files (*.avi)",
                        "MPEG Files (*.mpeg, *.mpg)",
                        "MPEG2 Files (*.mpeg2, *.mpg2)",
                        "MPEG4 Files (*.mpeg4, *.mp4)",
                        "PNG Files (*.png)",
                        "JPEG Files (*.jpg, *.jpeg)",
                        "All Files (*.*)"
                    });
                    fd.setFilterIndex(0);
                }

                String file = "";
                if ((file = fd.open()) != null && !"".equals(file)) {
                    final File f = new File(file);
                    if (!f.exists()) {
                        return;
                    }
                    for (int i = 0; i < canvases.length; ++i) {
                        if (mps[i] != null) {
                            mps[i].stop();
                        }
                        if (mps[i] == null) {
 
LibVlc.INSTANCE.libvlc_video_set_parent(Utilities.getNativeInstance(vlcs[i])
, canvases[i].handle, new LibVlc.libvlc_exception_t());
                        }
                        mps[i] = vlcs[i].play(f.getAbsolutePath());
                    }
                }
            }
        });

        shell.open();
        shell.setVisible(true);

        runMessageLoop(shell);
    }
}

4. Run the class.
5. Click on the "Switch" button and open up a video (I was testing w/ MPEG
and WMV videos).
6. Repeat step 5.

You'll see the videos freeze after about 4-5 panels. I can reproduce this
behavior pretty much every time I run it. If you're able to pause your
debugger, you'll see that it's stuck in the call to
libvlc_media_player_stop(). I haven't tested it out in Linux (Ubuntu) and so
I'm not sure if it will show the same behavior. But in Windows XP at least,
the app freezes up.


-----Original Message-----
From: vlc-devel-bounces at videolan.org [mailto:vlc-devel-bounces at videolan.org]
On Behalf Of Pierre d'Herbemont
Sent: Saturday, October 25, 2008 3:49 AM
To: Mailing list for VLC media player developers
Subject: Re: [vlc-devel] libvlc_media_player_stop


On Oct 25, 2008, at 1:43 AM, David Hoyt wrote:

> I've got an interesting error that I've tried everything I know how to 
> resolve it. Ultimately, it comes down to the fact that I'm just not 
> that familiar w/ the VLC internals.
>
> I'm trying to use vlc in java through the java bindings (JVLC). The 
> app freezes on me, however, in libvlc_media_player_stop and sometimes 
> in libvlc_media_player_release on Windows XP SP2.
>
> I can't release any example code without going through an exhaustive 
> review and release process. So I'm stuck explaining the problem.
>
> Here are some others with the same problem:
> http:// forum.videolan.org/viewtopic.php?f=2&t=51509
> http://
> forum.videolan.org/viewtopic.php?f=14&t=47385&st=0&sk=t&sd=a&start=60
>
> I've got 12+ videos going on a single dialog using SWT. I start them 
> out all playing the same video. They then reach the end of the 3- 
> second long clip and all stop. I then tell one panel to play a video.
> It plays just fine. Then I tell it to switch and play another video 
> while it's still playing (my code asks it to stop first and then play) 
> and it freezes. Java tells me it's stuck on the call to 
> libvlc_media_player_stop(). This freezes up my app.
>
> I've tried running all the commands on the GUI thread and then also on 
> separate threads and no luck. My guess is that it's stuck on line
> 689 of https://
> trac.videolan.org/vlc/browser/src/control/media_player.c


> I've also run into another error if you try and call
> libvlc_media_player_stop() from the endReached event handler. It 
> freezes there as well. That's not a tough one to get around, but it 
> shouldn't lock up on you.

Could you provide a backtrace, or a sample code that shows the issue?

Pierre.
_______________________________________________
vlc-devel mailing list
To unsubscribe or modify your subscription options:
http:// mailman.videolan.org/listinfo/vlc-devel




More information about the vlc-devel mailing list