Languages

Menu
Sites
Language
Performance problem of doing rotation animation while playing mp3 audio on emulator.

I have a button in main ui layout.

When user click this button, the application should playing a mp3 music and rotating the button until the music playing completted.

The music heard normally if only playing it without button rotation.

But i almost can't hear the music if playing it while rotating the button.

I found the rotating animation consumed most part of cpu time.

What's the matter regarding performance?

Are there some way to send the music player to another thread?

Perhaps, i should send the buttion animation to another thread?

 

PS:

I have no real device, just test on emulator.

I tried two method to implement rotation animation, neither get ideal performance result:

1,  ecore_animator_xxx;

2, elm_transit_effect_rotation_xxx;

Edited by: roc john on 27 May, 2015

Responses

8 Replies
daniel kim

Hi,

How about you run your test code in real Z1?  here, we can run it through RTL.

    http://developer.samsung.com/remotetestlab/rtlDeviceList.action

Regards,

roc john

Thank you! I will try RTL later~

roc john

I found the RTL client doesn't support audio output~

I can hear nothing...

Jean Yang

Hello, 

I think it's worth to try put the button rotation in other thread, you can have look in IDE sample, search below content in IDE help:

[UI Sample] Ecore Thread 1 Sample Overview

roc john

Thank you!

Could you  please show me some links or some samples ?

Jin Yoon

File > New > Tizen Native Project > Sample > Mobile-2.3 > Native UIFW Samples > Ecore Thread 2 UI sample application

I attach some codes below.

static pthread_t thread_id;
static Eina_Bool thread_finish = EINA_FALSE;

void *
thread_safe_call_sync_cb(void *data)
{
    //This function is in critical section.

	user_data *ud = data;
	evas_object_move(ud->btn, ud->x, ud->y);

	//Return value passes to ecore_main_loop_thread_safe_call_sync() return value
	return NULL;
}

static void *
thread_run(void *arg)
{
	Evas_Object *btn = arg;
	double t = 0.0;
	Evas_Coord x, y;

	while (!thread_finish) {
		x = 150 + (150 * sin(t));
		y = 200 + (150 * cos(t));

		user_data data;
		data.btn = btn;
		data.x = x;
		data.y = y;
		ecore_main_loop_thread_safe_call_sync(thread_safe_call_sync_cb,
				&data);
		usleep(1000);
		t += 0.001;
	}

	pthread_exit(NULL);

	return NULL;
}

static void
win_del_cb(void *data, Evas_Object *obj, void *event_info)
{
    void *thread_result;
	thread_finish = EINA_TRUE;
	pthread_join(thread_id, &thread_result);
	ui_app_exit();
}

static void
create_base_gui(appdata_s *ad)
{
	/* Window */
	ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
	elm_win_autodel_set(ad->win, EINA_TRUE);

	if (elm_win_wm_rotation_supported_get(ad->win)) {
		int rots[4] = { 0, 90, 180, 270 };
		elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
	}

	evas_object_smart_callback_add(ad->win, "delete,request", win_del_cb, NULL);
	eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad);

	/* Conformant */
	Evas_Object *conform = elm_conformant_add(ad->win);
	elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
	elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE);
	evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	elm_win_resize_object_add(ad->win, conform);
	evas_object_show(conform);

	/* ecore_main_loop_thread_safe_call_sync() */
	Evas_Object *btn;

	//Create a Button
	btn = elm_button_add(conform);
	elm_object_text_set(btn, "Thread<br>Safe<br>Sync");
	evas_object_resize(btn, ELM_SCALE_SIZE(100), ELM_SCALE_SIZE(140));
	evas_object_show(btn);

	//Create a thread
	if (!pthread_create(&thread_id, NULL, thread_run, btn))
		perror("pthread_create!\n");

	/* Show window after base gui is set up */
	evas_object_show(ad->win);
}

 

Best regards, Jin.

roc john

Thank you very much Jin~

I will try your code and feedback later~

roc john

Hi, Jin~

I tried some codes like your tips.

It has no effect on improve the peformance of the application.

The critical point is the usleep interval in the main loop of the worker thread,

if i decrease the interval, the main thread will be broken very frequently, the music playing unsmooth,

if i increase the interval, the main thread have less chance to playing animation. the animation playing unsmooth.

:-(

I think this result due to the emulator's single cpu core, Perhaps, there are no problem on the real device at all.