[vlc-devel] Problem transporting psz (string) data with a libvlc event

basos g noxelia at gmail.com
Fri Nov 7 11:45:16 CET 2008

I'm going to implenent a new mediaplayer event
"libvlc_MediaPlayerSnapshotTaken" that should also transport the new
image filename. The event sending mechanism is based on a libvlc
object variable (STRING variable) that is set (var_Set) from
vout_thread when the snap occurs with psz data concerning new image

I'm using the following callback function to proccess the var_Set and
emit the libvlc_MediaPlayerSnapshotTaken event. Of course i have
extended the event u structure to include the new transporter
 The problem is that i got a segi when i try to read the string data
outside vlc (from the libvlc user thread). I have comfirmed that the
psz_filename address is the same inside and outside of libvlc.
Is there some point i'm missing about free storage concerning
interthread transport ? Is there a limitation for access rights on
memmory allocated withing a thread from another ?? Or is there some
implicit mechanism that might free the string data asynchronously
while we are inside libvlc_event_send ?????


 * Trigger a snapshot Taken Event
static int SnapshotTakenCallback( vlc_object_t *p_this, char const *psz_cmd,
                       vlc_value_t oldval, vlc_value_t newval, void *p_data )
    VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
    VLC_UNUSED(p_this) ;

	libvlc_media_player_t* p_mi = (libvlc_media_player_t*) p_data ;
	libvlc_event_t event ;
	event.type = libvlc_MediaPlayerSnapshotTaken ;
	event.u.media_player_snapshot_taken.psz_filename = newval.psz_string ;

    msg_Dbg( p_this, "about to emit libvlc_snapshot_taken.make
psz_str=0x%x (%s)",
,event.u.media_player_snapshot_taken.psz_filename );

    libvlc_event_send( p_mi->p_event_manager, &event );

    return VLC_SUCCESS;

More information about the vlc-devel mailing list