[vlc-devel] libvlc_MediaInstanceReachedEnd called twice

jboileau jboileau at gmail.com
Wed Feb 27 20:41:22 CET 2008

Hum... Looking at the code in media_instance.c in the function
input_state_changed where the event is sent from, I can see that the u
member of the event struct is left uninitialized (I think it should at
least get initialized to 0). It is then not a good idea to rely on an
uninitialized variable to discern between the two times the event is
triggered. The best I can do is ignore every other
libvlc_MediaInstanceReachedEnd event. Something like:

static bool ReceivedFirst = false;
if (!ReceivedFirst)
    ReceivedFirst = true;
    // *** Do my stuff here ****
    ReceivedFirst = false;

(I can see I am mostly talking to myself in this thread :-) but hey it
might serve somebody else, who knows. Anyway most of my colleague's
wouldn't find it to abnormal for me to be talking to myself! It ain't
the worst I have done!)

On Wed, Feb 27, 2008 at 11:38 AM, jboileau <jboileau at gmail.com> wrote:
> I have done more tests. If I interpret the last member of the libvlc_event_t
> struct as an vlc_int64_t, the value of that member is very large (always
> 7654035783464058496 maybe a pointer to something) the first time the
> callback is called and always 1 the second time the callback is called. This
> might be a way to differentiate the two. But which one should be ignored to
> be compatible with later versions that might fix this problem?
> Jacques
> On Tue, Feb 26, 2008 at 9:05 AM, jboileau <jboileau at gmail.com> wrote:
> >
> > Hi,
> >
> > I have given a spin to the latest build of libvlc. I still have my media
> reached end callback called twice when a file ends. Both times the state is
> libvlc_Ended, so it is not possible to discern the two using the state. In
> the libvlc_event_t struct there is a union : event_type_specific. Which
> member of this union pertains to the libvlc_MediaInstanceReachedEnd event?
> Maybe there is something there that can help discern the two calls.
> >
> > Thanks,
> >
> > Jacques Boileau
> --
> Jacques Boileau

Jacques Boileau

More information about the vlc-devel mailing list