static void wait_for_async()
{
- GMainContext *context = g_main_context_new();
- GSource *source = g_timeout_source_new(5000);
-
- /* attach source to context */
- g_source_attach (source, context);
-
- g_mainloop = g_main_loop_new(context, FALSE);
-
- /* set the callback for this source */
- g_source_set_callback (source, timeout_func, g_mainloop, NULL);
-
- g_main_loop_run(g_mainloop);
-
- /* after attaching with the GSource, destroy() is needed */
- g_source_destroy(source);
-
- /* unref the last reference we got for GSource */
- g_source_unref(source);
-
- /* main loop should be destroyed before unref the context */
- g_main_loop_unref(g_mainloop);
- g_main_context_unref(context);
+ int timeout_id;
+ g_mainloop = g_main_loop_new(NULL, FALSE);
+
+ timeout_id = g_timeout_add(5000, timeout_func, g_mainloop);
+ g_main_loop_run(g_mainloop);
+ g_source_remove(timeout_id);
+ g_main_loop_unref(g_mainloop);
+ g_mainloop = NULL;
}
static void seek_completed_cb(void *user_data)
*/
int utc_player_set_media_stream_seek_cb_p(void)
{
+#define PREPARE_MAX_TIMEOUT 5
+
assert(!_is_broken);
int ret = 0;
+ int repeat = 0;
player_state_e state;
ret = player_get_state (player, &state);
return 0;
}
- usleep(500 * 1000);
+ for (repeat = 0; repeat < PREPARE_MAX_TIMEOUT; repeat++) {
+ wait_for_async();
+ }
+
pthread_join(feeding_thread_id, NULL);
assert_eq(g_ret, PLAYER_ERROR_NONE);
usleep(1000);
return FALSE;
}
-static void wait_for_async()
+static void wait_for_async(bool custom)
{
GMainContext *context = g_main_context_new();
GSource *source = g_timeout_source_new(5000);
/* attach source to context */
g_source_attach (source, context);
- g_mainloop = g_main_loop_new(context, FALSE);
+ if (custom) {
+ g_mainloop = g_main_loop_new(context, FALSE);
- /* set the callback for this source */
- g_source_set_callback (source, timeout_func, g_mainloop, NULL);
+ /* set the callback for this source */
+ g_source_set_callback (source, timeout_func, g_mainloop, NULL);
- g_main_loop_run(g_mainloop);
+ g_main_loop_run(g_mainloop);
+
+ } else {
+ int timeout_id;
+
+ g_mainloop = g_main_loop_new(NULL, FALSE);
+ timeout_id = g_timeout_add(5000, timeout_func, g_mainloop);
+
+ g_main_loop_run(g_mainloop);
+ g_source_remove(timeout_id);
+ }
/* after attaching with the GSource, destroy() is needed */
g_source_destroy(source);
/* main loop should be destroyed before unref the context */
g_main_loop_unref(g_mainloop);
g_main_context_unref(context);
+
+ g_mainloop = NULL;
}
void focus_cb(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state,
int ret = player_set_play_position(player, position, TRUE, player_seek_completed_cb_func, NULL);
assert_eq(ret, PLAYER_ERROR_NONE);
- wait_for_async();
+ wait_for_async(FALSE);
int millisecond;
int ret2 = player_get_play_position(player, &millisecond);
assert_eq(ret, PLAYER_ERROR_NONE);
player_start(player);
assert_eq(ret, PLAYER_ERROR_NONE);
- wait_for_async();
+ wait_for_async(TRUE);
ret = sound_manager_get_current_sound_type(&type);
assert_eq(ret, SOUND_MANAGER_ERROR_NONE);
assert_eq(SOUND_TYPE_MEDIA, type);
ret = player_prepare_async(player, player_prepared_cb_func, NULL);
assert_eq(ret, PLAYER_ERROR_NONE);
- for(repeat=0; repeat<5; repeat++) {
- wait_for_async();
+ for(repeat=0; repeat<PREPARE_MAX_TIMEOUT; repeat++) {
+ wait_for_async(FALSE);
if(_is_pass)
break;
}