[vlc-devel] commit: test: Simplify media_list_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 23:02:15 2010 +0100| [ad3a30059635060be68935d167f8d9887a0a7bd9] | committer: Pierre d'Herbemont
test: Simplify media_list_player test.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ad3a30059635060be68935d167f8d9887a0a7bd9
---
test/libvlc/media_list_player.c | 103 +++++++++++++++-----------------------
1 files changed, 41 insertions(+), 62 deletions(-)
diff --git a/test/libvlc/media_list_player.c b/test/libvlc/media_list_player.c
index 169731d..9084ce7 100644
--- a/test/libvlc/media_list_player.c
+++ b/test/libvlc/media_list_player.c
@@ -61,7 +61,25 @@ static inline void wait_queued_items(struct check_items_order_data *check)
{
// Wait dummily for check_items_order_callback() to flag 'done_playing':
while (!check->done_playing)
- msleep(100000);
+ sched_yield();
+}
+
+static inline void wait_playing(libvlc_media_list_player_t *mlp)
+{
+ while (!libvlc_media_list_player_is_playing (mlp))
+ sched_yield();
+}
+
+static inline void wait_stopped(libvlc_media_list_player_t *mlp)
+{
+ while (libvlc_media_list_player_is_playing (mlp))
+ sched_yield();
+}
+
+static inline void stop_and_wait(libvlc_media_list_player_t *mlp)
+{
+ libvlc_media_list_player_stop (mlp);
+ wait_stopped (mlp);
}
static void check_items_order_callback(const libvlc_event_t * p_event, void * user_data)
@@ -148,9 +166,7 @@ static void test_media_list_player_items_queue(const char** argv, int argc)
// Wait until all item are read
wait_queued_items(&check);
- libvlc_media_list_player_stop (mlp);
- while (libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ stop_and_wait (mlp);
libvlc_media_list_player_release (mlp);
libvlc_release (vlc);
@@ -190,36 +206,26 @@ static void test_media_list_player_previous(const char** argv, int argc)
libvlc_media_list_player_play_item (mlp, md);
- while (!libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ wait_playing (mlp);
libvlc_media_release (md);
libvlc_media_list_player_previous (mlp);
- while (!libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ wait_playing (mlp);
libvlc_media_list_player_pause (mlp);
libvlc_media_list_player_previous (mlp);
- while (!libvlc_media_list_player_is_playing (mlp))
- sched_yield();
-
- libvlc_media_list_player_stop (mlp);
+ wait_playing (mlp);
- while (libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ stop_and_wait (mlp);
libvlc_media_list_player_previous (mlp);
- while (!libvlc_media_list_player_is_playing (mlp))
- sched_yield();
-
- libvlc_media_list_player_stop (mlp);
+ wait_playing (mlp);
- while (libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ stop_and_wait (mlp);
libvlc_media_list_player_release (mlp);
libvlc_release (vlc);
@@ -261,33 +267,24 @@ static void test_media_list_player_next(const char** argv, int argc)
libvlc_media_release (md);
- while (!libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ wait_playing (mlp);
libvlc_media_list_player_next (mlp);
- while (!libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ wait_playing (mlp);
libvlc_media_list_player_pause (mlp);
libvlc_media_list_player_next (mlp);
- while (!libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ wait_playing (mlp);
- libvlc_media_list_player_stop (mlp);
-
- while (libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ stop_and_wait (mlp);
libvlc_media_list_player_next (mlp);
- while (!libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ wait_playing (mlp);
- libvlc_media_list_player_stop (mlp);
- while (libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ stop_and_wait (mlp);
libvlc_media_list_player_release (mlp);
libvlc_release (vlc);
@@ -322,14 +319,11 @@ static void test_media_list_player_pause_stop(const char** argv, int argc)
libvlc_media_list_player_play_item( mlp, md );
- while (!libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ wait_playing (mlp);
libvlc_media_list_player_pause (mlp);
- libvlc_media_list_player_stop (mlp);
- while (libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ stop_and_wait (mlp);
libvlc_media_release (md);
libvlc_media_list_player_release (mlp);
@@ -360,20 +354,14 @@ static void test_media_list_player_play_item_at_index(const char** argv, int arg
assert(mlp);
for (unsigned i = 0; i < 5; i++)
- {
libvlc_media_list_add_media( ml, md );
- }
libvlc_media_list_player_set_media_list( mlp, ml );
libvlc_media_list_player_play_item_at_index( mlp, 0 );
- while (!libvlc_media_list_player_is_playing (mlp))
- sched_yield();
-
- libvlc_media_list_player_stop (mlp);
+ wait_playing (mlp);
- while (libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ stop_and_wait (mlp);
libvlc_media_release (md);
libvlc_media_list_player_release (mlp);
@@ -488,8 +476,7 @@ static void test_media_list_player_playback_options (const char** argv, int argc
libvlc_media_list_player_play_item (mlp, md);
- while (!libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ wait_playing (mlp);
libvlc_media_release (md);
libvlc_media_release (md2);
@@ -508,13 +495,9 @@ static void test_media_list_player_playback_options (const char** argv, int argc
libvlc_media_list_player_play_item (mlp, md);
- while (!libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ wait_playing (mlp);
- libvlc_media_list_player_stop (mlp);
-
- while (libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ stop_and_wait (mlp);
// Test repeat playback mode
log ("Testing media player playback option - Repeat\n");
@@ -522,13 +505,9 @@ static void test_media_list_player_playback_options (const char** argv, int argc
libvlc_media_list_player_play_item (mlp, md);
- while (!libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ wait_playing (mlp);
- libvlc_media_list_player_stop (mlp);
-
- while (libvlc_media_list_player_is_playing (mlp))
- sched_yield();
+ stop_and_wait (mlp);
libvlc_media_list_player_release (mlp);
libvlc_release (vlc);
More information about the vlc-devel
mailing list