From 8f9b242ff45f74b59df0aaee81431ea078579036 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C3=ABl=20Carr=C3=A9?= Date: Mon, 18 Jan 2010 09:06:49 +0100 Subject: [PATCH] media_list_player test: attempt at fixing test Replace arbitrary sleep delays by active waiting of state change Add state change wait where needed (after play()/next()/previous()) --- test/libvlc/media_list_player.c | 51 +++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/test/libvlc/media_list_player.c b/test/libvlc/media_list_player.c index 3f625f6afe..870875f6d3 100644 --- a/test/libvlc/media_list_player.c +++ b/test/libvlc/media_list_player.c @@ -198,29 +198,35 @@ static void test_media_list_player_previous(const char** argv, int argc) libvlc_media_list_player_play_item (mlp, md, &ex); catch (); - libvlc_media_release (md); + while (!libvlc_media_list_player_is_playing (mlp, &ex)) + catch() ; - msleep(100000); + libvlc_media_release (md); libvlc_media_list_player_previous (mlp, &ex); catch (); + while (!libvlc_media_list_player_is_playing (mlp, &ex)) + catch() ; + libvlc_media_list_player_pause (mlp, &ex); catch(); - msleep(100000); - libvlc_media_list_player_previous (mlp, &ex); catch (); + while (!libvlc_media_list_player_is_playing (mlp, &ex)) + catch() ; + libvlc_media_list_player_stop (mlp, &ex); catch (); - msleep(100000); - libvlc_media_list_player_previous (mlp, &ex); catch (); + while (!libvlc_media_list_player_is_playing (mlp, &ex)) + catch() ; + libvlc_media_list_player_stop (mlp, &ex); catch (); @@ -270,27 +276,33 @@ static void test_media_list_player_next(const char** argv, int argc) libvlc_media_release (md); - msleep(100000); + while (!libvlc_media_list_player_is_playing (mlp, &ex)) + catch() ; libvlc_media_list_player_next (mlp, &ex); catch (); + while (!libvlc_media_list_player_is_playing (mlp, &ex)) + catch() ; + libvlc_media_list_player_pause (mlp, &ex); catch(); - msleep(100000); - libvlc_media_list_player_next (mlp, &ex); catch (); + while (!libvlc_media_list_player_is_playing (mlp, &ex)) + catch() ; + libvlc_media_list_player_stop (mlp, &ex); catch (); - msleep(100000); - libvlc_media_list_player_next (mlp, &ex); catch (); + while (!libvlc_media_list_player_is_playing (mlp, &ex)) + catch() ; + libvlc_media_list_player_stop (mlp, &ex); catch (); @@ -332,6 +344,9 @@ static void test_media_list_player_pause_stop(const char** argv, int argc) libvlc_media_list_player_play_item( mlp, md, &ex ); catch (); + while (!libvlc_media_list_player_is_playing (mlp, &ex)) + catch() ; + libvlc_media_list_player_pause (mlp, &ex); catch(); @@ -381,6 +396,9 @@ static void test_media_list_player_play_item_at_index(const char** argv, int arg libvlc_media_list_player_play_item_at_index( mlp, 0, &ex ); catch (); + while (!libvlc_media_list_player_is_playing (mlp, &ex)) + catch() ; + libvlc_media_list_player_stop (mlp, &ex); catch (); @@ -513,6 +531,9 @@ static void test_media_list_player_playback_options (const char** argv, int argc libvlc_media_list_player_play_item (mlp, md, &ex); catch (); + while (!libvlc_media_list_player_is_playing (mlp, &ex)) + catch() ; + libvlc_media_release (md); catch (); libvlc_media_release (md2); @@ -524,8 +545,6 @@ static void test_media_list_player_playback_options (const char** argv, int argc libvlc_media_release (md5); catch (); - msleep(500000); - libvlc_media_list_player_stop (mlp, &ex); catch (); @@ -537,7 +556,8 @@ static void test_media_list_player_playback_options (const char** argv, int argc libvlc_media_list_player_play_item (mlp, md, &ex); catch (); - msleep(500000); + while (!libvlc_media_list_player_is_playing (mlp, &ex)) + catch() ; libvlc_media_list_player_stop (mlp, &ex); catch (); @@ -550,7 +570,8 @@ static void test_media_list_player_playback_options (const char** argv, int argc libvlc_media_list_player_play_item (mlp, md, &ex); catch (); - msleep(500000); + while (!libvlc_media_list_player_is_playing (mlp, &ex)) + catch() ; libvlc_media_list_player_stop (mlp, &ex); catch (); -- 2.39.2