Skip to content

Commit

Permalink
performance: implement automatic switch and title display
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Bourdeauducq committed Jun 8, 2011
1 parent 007009f commit 5213f6a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
10 changes: 6 additions & 4 deletions src/cp.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ static void cp_callback(mtk_event *e, void *arg)
open_firstpatch_window(); open_firstpatch_window();
break; break;
case CP_ITEM_START: case CP_ITEM_START:
start_performance(false); start_performance(0, 0, 0);
break; break;
case CP_ITEM_STARTSIMPLE: case CP_ITEM_STARTSIMPLE:
start_performance(true); start_performance(1, 1, 0);
break; break;


case CP_ITEM_FILEMANAGER: case CP_ITEM_FILEMANAGER:
Expand Down Expand Up @@ -374,12 +374,14 @@ void init_cp()
void cp_autostart() void cp_autostart()
{ {
char autostart[256]; char autostart[256];
int dt, as;


switch(sysconfig_get_autostart_mode()) { switch(sysconfig_get_autostart_mode()) {
case SC_AUTOSTART_NONE: case SC_AUTOSTART_NONE:
break; break;
case SC_AUTOSTART_SIMPLE: case SC_AUTOSTART_SIMPLE:
start_performance(true); sysconfig_get_autostart_mode_simple(&dt, &as);
start_performance(1, dt, as);
break; break;
case SC_AUTOSTART_FILE: case SC_AUTOSTART_FILE:
sysconfig_get_autostart(autostart); sysconfig_get_autostart(autostart);
Expand All @@ -394,7 +396,7 @@ void cp_autostart()
return; return;
} }
on_config_change(); on_config_change();
start_performance(false); start_performance(0, 0, 0);
break; break;
} }
} }
32 changes: 26 additions & 6 deletions src/performance.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ static int npatches;
static int current_patch; static int current_patch;
static struct patch_info patches[MAX_PATCHES]; static struct patch_info patches[MAX_PATCHES];
static bool simple_mode; static bool simple_mode;
static int dt_mode;
static int as_mode;


static int add_patch(const char *filename) static int add_patch(const char *filename)
{ {
Expand Down Expand Up @@ -283,21 +285,37 @@ static int keycode_to_index(int keycode)
} }
} }


static rtems_interval next_as_time;

static void event_callback(mtk_event *e, int count) static void event_callback(mtk_event *e, int count)
{ {
int i; int i;
int index; int index;
int next;
rtems_interval t;


index = -1; index = -1;
if(simple_mode) { if(simple_mode) {
next = 0;
for(i=0;i<count;i++) { for(i=0;i<count;i++) {
if((e[i].type == EVENT_TYPE_PRESS) && (e[i].press.code == MTK_KEY_F11)) { if((e[i].type == EVENT_TYPE_PRESS) && (e[i].press.code == MTK_KEY_F11))
current_patch++; next = 1;
if(current_patch == npatches) }
current_patch = 0; if(as_mode) {
index = current_patch; t = rtems_clock_get_ticks_since_boot();
if(t >= next_as_time) {
next = 1;
next_as_time = t + 3000;
} }
} }
if(next) {
current_patch++;
if(current_patch == npatches)
current_patch = 0;
index = current_patch;
}
if(dt_mode && (index != -1))
osd_event(patches[index].filename);
} else { } else {
for(i=0;i<count;i++) { for(i=0;i<count;i++) {
if(e[i].type == EVENT_TYPE_PRESS) { if(e[i].type == EVENT_TYPE_PRESS) {
Expand Down Expand Up @@ -370,7 +388,7 @@ static void refresh_callback(mtk_event *e, int count)


static rtems_id comp_task_id; static rtems_id comp_task_id;


void start_performance(bool simple) void start_performance(int simple, int dt, int as)
{ {
rtems_status_code sc; rtems_status_code sc;


Expand All @@ -379,6 +397,8 @@ void start_performance(bool simple)


/* build patch list */ /* build patch list */
simple_mode = simple; simple_mode = simple;
dt_mode = dt;
as_mode = as;
npatches = 0; npatches = 0;
current_patch = 0; current_patch = 0;
if(simple) { if(simple) {
Expand Down
2 changes: 1 addition & 1 deletion src/performance.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
#define SIMPLE_PATCHES_FOLDER "/ssd/patchpool/" #define SIMPLE_PATCHES_FOLDER "/ssd/patchpool/"


void init_performance(); void init_performance();
void start_performance(bool simple); void start_performance(int simple, int dt, int as);


#endif /* __PERFORMANCE_H */ #endif /* __PERFORMANCE_H */

0 comments on commit 5213f6a

Please sign in to comment.