[vlc-devel] commit: test: Simplify media_player test. (Pierre d'Herbemont )

git version control git at videolan.org
Thu Feb 25 23:47:00 CET 2010


vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Thu Feb 25 22:05:05 2010 +0100| [1b1325c6d462f508f3e0d0e6ff2d4eed4e1d4b1e] | committer: Pierre d'Herbemont 

test: Simplify media_player test.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1b1325c6d462f508f3e0d0e6ff2d4eed4e1d4b1e
---

 test/libvlc/media_player.c |   52 ++++++++++++++-----------------------------
 1 files changed, 17 insertions(+), 35 deletions(-)

diff --git a/test/libvlc/media_player.c b/test/libvlc/media_player.c
index cba2a90..53ba3d6 100644
--- a/test/libvlc/media_player.c
+++ b/test/libvlc/media_player.c
@@ -23,6 +23,19 @@
 
 #include "test.h"
 
+static void wait_playing(libvlc_media_player_t *mp)
+{
+    libvlc_state_t state;
+    do {
+        state = libvlc_media_player_get_state (mp);
+    } while(state != libvlc_Playing &&
+            state != libvlc_Error &&
+            state != libvlc_Ended );
+
+    state = libvlc_media_player_get_state (mp);
+    assert(state == libvlc_Playing || state == libvlc_Ended);
+}
+
 static void test_media_player_set_media(const char** argv, int argc)
 {
     const char * file = test_default_sample;
@@ -44,15 +57,7 @@ static void test_media_player_set_media(const char** argv, int argc)
 
     libvlc_media_player_play (mp);
 
-    /* Wait a correct state */
-    libvlc_state_t state;
-    do {
-        state = libvlc_media_player_get_state (mp);
-    } while(state != libvlc_Playing &&
-            state != libvlc_Error &&
-            state != libvlc_Ended );
-
-    assert(state == libvlc_Playing || state == libvlc_Ended);
+    wait_playing (mp);
 
     libvlc_media_player_stop (mp);
     libvlc_media_player_release (mp);
@@ -81,15 +86,7 @@ static void test_media_player_play_stop(const char** argv, int argc)
 
     libvlc_media_player_play (mi);
 
-    /* Wait a correct state */
-    libvlc_state_t state;
-    do {
-        state = libvlc_media_player_get_state (mi);
-    } while( state != libvlc_Playing &&
-             state != libvlc_Error &&
-             state != libvlc_Ended );
-
-    assert( state == libvlc_Playing || state == libvlc_Ended );
+    wait_playing (mi);
 
     libvlc_media_player_stop (mi);
     libvlc_media_player_release (mi);
@@ -120,15 +117,7 @@ static void test_media_player_pause_stop(const char** argv, int argc)
 
     log ("Waiting for playing\n");
 
-    /* Wait a correct state */
-    libvlc_state_t state;
-    do {
-        state = libvlc_media_player_get_state (mi);
-    } while( state != libvlc_Playing &&
-             state != libvlc_Error &&
-             state != libvlc_Ended );
-
-    assert( state == libvlc_Playing || state == libvlc_Ended );
+    wait_playing (mi);
 
 #if 0
     /* This can't work because under some condition (short file, this is the case) this will be
@@ -137,14 +126,7 @@ static void test_media_player_pause_stop(const char** argv, int argc)
 
     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 );
+    wait_paused (mp);
 #endif
 
     libvlc_media_player_stop (mi);




More information about the vlc-devel mailing list