[vlc-devel] Re: problems with many libvlc instances

Clément Stenac zorglub at diwi.org
Wed Jun 28 14:24:49 CEST 2006


It's actually a vocabulary problem. You can call libvlc_new() twice, but
some stuff behind will be shared. Most notably, the configuration will
be shared, that's why you can't use global options to handle
positionning.

For example, if you consider the following snippet: 

    libvlc_instance_t *p_instance, *p_instance2;
    char *argv[] = { "vlc", "-vvv","--no-color" };
    char *argv1[] = { "vlc", "-vvv","--color" };

    libvlc_exception_t exception;
    libvlc_exception_init( &exception );

    fprintf( stderr, "********* INIT 1\n" );
    p_instance = libvlc_new( 3, argv, &exception );
    fprintf( stderr, "********* INIT 2\n" );
    p_instance2 = libvlc_new( 3, argv1, &exception );
    fprintf( stderr, "********* Add\n" );
    libvlc_playlist_add( p_instance, "test.mp3" , NULL , &exception );
    fprintf( stderr, "************ Playing : %i %i\n", libvlc_playlist_isplaying( p_instance, &exception  ), libvlc_playlist_isplaying( p_instance2, &exception ) );
    fprintf( stderr, "********** Play\n" );
    libvlc_playlist_play( p_instance, -1, 0, NULL, &exception );
    sleep( 1 );
    fprintf( stderr, "************ Playing : %i %i\n", libvlc_playlist_isplaying( p_instance, &exception  ), libvlc_playlist_isplaying( p_instance2, &exception ) );
    sleep( 1 );
    fprintf( stderr, "********** Kill\n" );
    libvlc_destroy( p_instance );
    libvlc_destroy( p_instance2 );

You will correctly see that two instances are created, and that only one
plays the test.mp3 file (You'll see Playing : 1 0) ... but all messages
will be black-and-white.

What you can do is use so-called input options to the specific items.

For that, use the libvlc_playlist_add_extended call, which takes
an array of strings as argument. Use a syntax like "video-x=12"
"video-y=42" in this array.

Regards, 

-- 
Zorglub
Clément Stenac

-- 
This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html



More information about the vlc-devel mailing list