[Android] Use length_change_monitor to wait until the demux is working
Edward Wang
edward.c.wang at compdigitec.com
Wed Jun 20 13:15:18 CEST 2012
On 12-06-20 03:19 AM, Ludovic Fauvet <etix at videolan.org> wrote:
>> + /* Initialize pthread variables. */
>> > + pthread_mutex_init(&monitor->doneMutex, NULL);
>> > + pthread_cond_init(&monitor->doneCondVar, NULL);
>> > + monitor->length_changed = false;
>> > +
>> > + libvlc_event_manager_t *ev = libvlc_media_player_event_manager(p_mp);
>> > + libvlc_event_attach(ev, libvlc_MediaPlayerLengthChanged, length_changed_callback, monitor);
>> > + libvlc_media_player_play( p_mp );
>> > +
>> > + pthread_mutex_lock(&monitor->doneMutex);
>> > + while (!monitor->length_changed)
>> > + pthread_cond_wait(&monitor->doneCondVar,&monitor->doneMutex);
>> > + pthread_mutex_unlock(&monitor->doneMutex);
>> > +
>> > + int i_nbTracks = libvlc_video_get_track_count(p_mp);
>> > + LOGI("Number of video tracks: %d",i_nbTracks);
>> > +
>> > + libvlc_media_player_stop(p_mp);
>> > + libvlc_media_player_release(p_mp);
>> > libvlc_media_release(p_m);
>> >
> aren't you leaking monitor here?
>
Fixed.
Thanks,
Edward Wang
More information about the Android
mailing list