static void play_file(const char *filepath, bool_t unsupported_format, bool_t seeking_test, bool_t play_twice, int timeout) { bool_t succeed; Eof eof; MSMediaPlayer *file_player = NULL; MSSndCard *snd_card = ms_snd_card_manager_get_default_card(ms_snd_card_manager_get()); const char *display_name = video_stream_get_default_video_renderer(); eof_init(&eof); file_player = ms_media_player_new(snd_card, display_name, NULL); CU_ASSERT_PTR_NOT_NULL(file_player); if(file_player == NULL) return; CU_ASSERT_EQUAL(ms_media_player_get_state(file_player), MSPlayerClosed); ms_media_player_set_eof_callback(file_player, eof_callback, &eof); succeed = ms_media_player_open(file_player, filepath); if(unsupported_format) { CU_ASSERT_FALSE(succeed); CU_ASSERT_EQUAL(ms_media_player_get_state(file_player), MSPlayerClosed); } else { CU_ASSERT_TRUE(succeed); CU_ASSERT_EQUAL(ms_media_player_get_state(file_player), MSPlayerPaused); } if(!succeed) { ms_media_player_free(file_player); return; } succeed = ms_media_player_start(file_player); CU_ASSERT_TRUE(succeed); CU_ASSERT_EQUAL(ms_media_player_get_state(file_player), MSPlayerPlaying); if(seeking_test) { CU_ASSERT_TRUE(ms_media_player_seek(file_player, 5000)); } if(succeed) { wait_for_eof(&eof, 100, timeout); CU_ASSERT_TRUE(eof.eof); } ms_media_player_close(file_player); CU_ASSERT_EQUAL(ms_media_player_get_state(file_player), MSPlayerClosed); if(play_twice) { eof_init(&eof); CU_ASSERT_TRUE(ms_media_player_open(file_player, filepath)); CU_ASSERT_TRUE(ms_media_player_start(file_player)); wait_for_eof(&eof, 100, timeout); ms_media_player_close(file_player); CU_ASSERT_TRUE(eof.eof); } ms_media_player_free(file_player); }
static void play_file(const char *filepath, bool_t unsupported_format, bool_t seeking_test, bool_t play_twice) { bool_t succeed; Eof eof; MSMediaPlayer *file_player = NULL; MSSndCard *snd_card = ms_snd_card_manager_get_default_playback_card(ms_snd_card_manager_get()); const char *display_name = video_stream_get_default_video_renderer(); int duration, timeout; const int seek_time = 6100; const double timeout_prec = 0.05; eof_init(&eof); BC_ASSERT_PTR_NOT_NULL(snd_card); file_player = ms_media_player_new(snd_card, display_name, 0); BC_ASSERT_PTR_NOT_NULL(file_player); if(file_player == NULL) return; BC_ASSERT_EQUAL(ms_media_player_get_state(file_player), MSPlayerClosed, int, "%d"); ms_media_player_set_eof_callback(file_player, eof_callback, &eof); succeed = ms_media_player_open(file_player, filepath); if(unsupported_format) { BC_ASSERT_FALSE(succeed); BC_ASSERT_EQUAL(ms_media_player_get_state(file_player), MSPlayerClosed, int, "%d"); } else {