]> git.sesse.net Git - vlc/commitdiff
libvlc: check if we are in the proper state before to send libvlc_MediaPlayerStopped
authorTanguy Krotoff <tkrotoff@gmail.com>
Tue, 1 Apr 2008 14:24:02 +0000 (16:24 +0200)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Fri, 4 Apr 2008 11:33:19 +0000 (13:33 +0200)
Signed-off-by: Pierre d'Herbemont <pdherbemont@videolan.org>
src/control/media_player.c

index b59fafefd6e837142e44ea1d7cc1e154bf93b4f5..20faa24707355ad2e92b16b399ac893cb2d3fcc1 100644 (file)
@@ -627,6 +627,13 @@ void libvlc_media_player_pause( libvlc_media_player_t *p_mi,
 void libvlc_media_player_stop( libvlc_media_player_t *p_mi,
                                  libvlc_exception_t *p_e )
 {
+    input_thread_t * p_input_thread = libvlc_get_input_thread( p_mi, p_e );
+
+    if( !p_input_thread )
+            return;
+
+    int state = var_GetInteger( p_input_thread, "state" );
+
     if( p_mi->b_own_its_input_thread )
     {
         vlc_mutex_lock( &p_mi->object_lock );
@@ -635,20 +642,18 @@ void libvlc_media_player_stop( libvlc_media_player_t *p_mi,
     }
     else
     {
-        input_thread_t * p_input_thread = libvlc_get_input_thread( p_mi, p_e );
-
-        if( !p_input_thread )
-            return;
-
         input_StopThread( p_input_thread );
         vlc_object_release( p_input_thread );
     }
 
-    /* Send a stop notification event */
-    libvlc_event_t event;
-    libvlc_media_set_state( p_mi->p_md, libvlc_Stopped, NULL);
-    event.type = libvlc_MediaPlayerStopped;
-    libvlc_event_send( p_mi->p_event_manager, &event );
+    if( state == PLAYING_S || state == PAUSE_S )
+    {
+        /* Send a stop notification event */
+        libvlc_event_t event;
+        libvlc_media_set_state( p_mi->p_md, libvlc_Stopped, NULL );
+        event.type = libvlc_MediaPlayerStopped;
+        libvlc_event_send( p_mi->p_event_manager, &event );
+    }
 }
 
 /**************************************************************************