]> git.sesse.net Git - vlc/blobdiff - test/libvlc/media_player.c
Fixed heavy memory leaks in bandlimited.c
[vlc] / test / libvlc / media_player.c
index 54f98cdeaae891ad730e7fd05ce16543cdfb1b05..8ebde89d2bed30061bc25af977ede7b4e7442a38 100644 (file)
@@ -50,22 +50,16 @@ static void test_media_player_play_stop(const char** argv, int argc)
     /* Wait a correct state */
     libvlc_state_t state;
     do {
-        state = libvlc_media_player_get_state (mi, &ex);
-        catch ();
+        state = libvlc_media_player_get_state (mi);
     } while( state != libvlc_Playing &&
              state != libvlc_Error &&
-             state != libvlc_MediaPlayerEndReached );
-
-    assert( state == libvlc_Playing || state == libvlc_MediaPlayerEndReached );
+             state != libvlc_Ended );
 
-    libvlc_media_player_stop (mi, &ex);
-    catch ();
+    assert( state == libvlc_Playing || state == libvlc_Ended );
 
+    libvlc_media_player_stop (mi);
     libvlc_media_player_release (mi);
-    catch ();
-
     libvlc_release (vlc);
-    catch ();
 }
 
 static void test_media_player_pause_stop(const char** argv, int argc)
@@ -75,7 +69,7 @@ static void test_media_player_pause_stop(const char** argv, int argc)
     libvlc_media_player_t *mi;
     const char * file = test_default_sample;
 
-    log ("Testing play and pause of %s\n", file);
+    log ("Testing pause and stop of %s\n", file);
 
     libvlc_exception_init (&ex);
     vlc = libvlc_new (argc, argv, &ex);
@@ -92,29 +86,40 @@ static void test_media_player_pause_stop(const char** argv, int argc)
     libvlc_media_player_play (mi, &ex);
     catch ();
 
+    log ("Waiting for playing\n");
+
     /* Wait a correct state */
     libvlc_state_t state;
     do {
-        state = libvlc_media_player_get_state (mi, &ex);
+        state = libvlc_media_player_get_state (mi);
         catch ();
     } while( state != libvlc_Playing &&
              state != libvlc_Error &&
-             state != libvlc_MediaPlayerEndReached );
+             state != libvlc_Ended );
 
-    assert( state == libvlc_Playing || state == libvlc_MediaPlayerEndReached );
+    assert( state == libvlc_Playing || state == libvlc_Ended );
 
+#if 0
+    /* This can't work because under some condition (short file, this is the case) this will be
+     * equivalent to a play() */
     libvlc_media_player_pause (mi, &ex);
-    assert( libvlc_media_player_get_state (mi, &ex) == libvlc_Paused );
     catch();
 
-    libvlc_media_player_stop (mi, &ex);
-    catch ();
+    log ("Waiting for pause\n");
 
+    /* Wait a correct state */
+    do {
+        state = libvlc_media_player_get_state (mi);
+    } while( state != libvlc_Paused &&
+            state != libvlc_Error &&
+            state != libvlc_Ended );
+
+    assert( state == libvlc_Paused || state == libvlc_Ended );
+#endif
+    
+    libvlc_media_player_stop (mi);
     libvlc_media_player_release (mi);
-    catch ();
-
     libvlc_release (vlc);
-    catch ();
 }