Guest User

Untitled

a guest
Aug 17th, 2010
111
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
  2. index 8e08343..3021715 100644
  3. --- a/apps/gui/skin_engine/skin_display.c
  4. +++ b/apps/gui/skin_engine/skin_display.c
  5. @@ -80,7 +80,7 @@ void skin_update(struct gui_wps *gwps, unsigned int update_type)
  6. {
  7. /* This maybe shouldnt be here,
  8. * This is also safe for skined screen which dont use the id3 */
  9. - struct mp3entry *id3 = gwps->state->id3;
  10. + struct mp3entry *id3 = skin_get_global_state()->id3;
  11. bool cuesheet_update = (id3 != NULL ? cuesheet_subtrack_changed(id3) : false);
  12. gwps->sync_data->do_full_update |= cuesheet_update;
  13.  
  14. @@ -126,7 +126,7 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb)
  15. {
  16. struct screen *display = gwps->display;
  17. struct viewport *vp = pb->vp;
  18. - struct wps_state *state = gwps->state;
  19. + struct wps_state *state = skin_get_global_state();
  20. struct mp3entry *id3 = state->id3;
  21. int y = pb->y, height = pb->height;
  22. unsigned long length, end;
  23. @@ -730,11 +730,10 @@ bool skin_has_sbs(enum screen_type screen, struct wps_data *data)
  24.  
  25. /* do the button loop as often as required for the peak meters to update
  26. * with a good refresh rate.
  27. - * gwps is really gwps[NB_SCREENS]! don't wrap this if FOR_NB_SCREENS()
  28. */
  29. -int skin_wait_for_action(struct gui_wps *gwps, int context, int timeout)
  30. +int skin_wait_for_action(enum skinnable_screens skin, int context, int timeout)
  31. {
  32. - (void)gwps; /* silence charcell warning */
  33. + (void)skin; /* silence charcell warning */
  34. int button = ACTION_NONE;
  35. #ifdef HAVE_LCD_BITMAP
  36. int i;
  37. @@ -745,7 +744,7 @@ int skin_wait_for_action(struct gui_wps *gwps, int context, int timeout)
  38. bool pm=false;
  39. FOR_NB_SCREENS(i)
  40. {
  41. - if(gwps[i].data->peak_meter_enabled)
  42. + if(skin_get_gwps(skin, i)->data->peak_meter_enabled)
  43. pm = true;
  44. }
  45.  
  46. @@ -764,8 +763,8 @@ int skin_wait_for_action(struct gui_wps *gwps, int context, int timeout)
  47. if (TIME_AFTER(current_tick, next_refresh)) {
  48. FOR_NB_SCREENS(i)
  49. {
  50. - if(gwps[i].data->peak_meter_enabled)
  51. - skin_update(&gwps[i], SKIN_REFRESH_PEAK_METER);
  52. + if(skin_get_gwps(skin, i)->data->peak_meter_enabled)
  53. + skin_update(skin_get_gwps(skin, i), SKIN_REFRESH_PEAK_METER);
  54. next_refresh += HZ / PEAK_METER_FPS;
  55. }
  56. }
  57. @@ -782,3 +781,109 @@ int skin_wait_for_action(struct gui_wps *gwps, int context, int timeout)
  58. }
  59. return button;
  60. }
  61. +
  62. +char* wps_default_skin(enum screen_type screen);
  63. +char* default_radio_skin(enum screen_type screen);
  64. +int sb_preproccess(enum screen_type screen, struct wps_data *data);
  65. +int sb_postproccess(enum screen_type screen, struct wps_data *data);
  66. +struct wps_state wps_state = { .id3 = NULL };
  67. +static struct gui_skin_helper {
  68. + int (*preproccess)(enum screen_type screen, struct wps_data *data);
  69. + int (*postproccess)(enum screen_type screen, struct wps_data *data);
  70. + char* (*default_skin)(enum screen_type screen);
  71. +} skin_helpers[SKINNABLE_SCREENS_COUNT] = {
  72. + [CUSTOM_STATUSBAR] = { sb_preproccess, sb_postproccess, sb_create_from_settings },
  73. + [WPS] = { NULL, NULL, wps_default_skin },
  74. +#if CONFIG_TUNER
  75. + [FM_SCREEN] = { NULL, NULL, default_radio_skin }
  76. +#endif
  77. +};
  78. +
  79. +struct gui_skin {
  80. + struct gui_wps gui_wps;
  81. + struct wps_data data;
  82. + char *buffer_start;
  83. + size_t buffer_usage;
  84. +} skins[SKINNABLE_SCREENS_COUNT][NB_SCREENS];
  85. +static struct wps_sync_data wps_sync_data[SKINNABLE_SCREENS_COUNT];
  86. +
  87. +
  88. +void gui_sync_skin_init(void)
  89. +{
  90. + int i, j;
  91. + for(j=0; j<SKINNABLE_SCREENS_COUNT; j++)
  92. + {
  93. + FOR_NB_SCREENS(i)
  94. + {
  95. +#ifdef HAVE_ALBUMART
  96. + skins[j][i].data.albumart = NULL;
  97. + skins[j][i].data.playback_aa_slot = -1;
  98. +#endif
  99. + skins[j][i].gui_wps.data = &skins[j][i].data;
  100. + skins[j][i].gui_wps.display = &screens[i];
  101. + /* must point to the same struct for both screens */
  102. + skins[j][i].gui_wps.sync_data = &wps_sync_data[j];
  103. + }
  104. + }
  105. +}
  106. +
  107. +void skin_load(enum skinnable_screens skin, enum screen_type screen,
  108. + const char *buf, bool isfile)
  109. +{
  110. + bool loaded = false;
  111. + int i;
  112. + /* First step should be to unload all skins which are after this one.
  113. + for (i=skin; i<
  114. + */
  115. +
  116. + if (skin_helpers[skin].preproccess)
  117. + skin_helpers[skin].preproccess(screen, &skins[skin][screen].data);
  118. +
  119. + loaded = skin_data_load(screen, &skins[skin][screen].data, buf, isfile);
  120. + if (!loaded)
  121. + loaded = skin_data_load(screen, &skins[skin][screen].data,
  122. + skin_helpers[skin].default_skin(screen), false);
  123. + if (skin_helpers[skin].postproccess)
  124. + skin_helpers[skin].postproccess(screen, &skins[skin][screen].data);
  125. +}
  126. +
  127. +struct gui_wps *skin_get_gwps(enum skinnable_screens skin, enum screen_type screen)
  128. +{
  129. + if (skins[skin][screen].data.wps_loaded == false)
  130. + {
  131. + char buf[MAX_PATH*2], path[MAX_PATH];
  132. + char *setting, *ext;
  133. + switch (skin)
  134. + {
  135. + case CUSTOM_STATUSBAR:
  136. + return &skins[skin][screen].gui_wps;
  137. + break;
  138. + case WPS:
  139. + setting = global_settings.wps_file;
  140. + ext = "wps";
  141. + break;
  142. +#if CONFIG_TUNER
  143. + case FM_SCREEN:
  144. + setting = global_settings.fms_file;
  145. + ext = "fms";
  146. + break;
  147. +#endif
  148. + default:
  149. + return NULL;
  150. + }
  151. + snprintf(buf, sizeof buf, "%s/%s.%s",
  152. + get_user_file_path(WPS_DIR, false, path, sizeof(path)),
  153. + setting, ext);
  154. + skin_load(skin, screen, buf, true);
  155. + }
  156. +
  157. + return &skins[skin][screen].gui_wps;
  158. +}
  159. +
  160. +struct wps_state *skin_get_global_state(void)
  161. +{
  162. + return &wps_state;
  163. +}
  164. +
  165. +
  166. +
  167. diff --git a/apps/gui/skin_engine/skin_engine.h b/apps/gui/skin_engine/skin_engine.h
  168. index 9845d8c..be61414 100644
  169. --- a/apps/gui/skin_engine/skin_engine.h
  170. +++ b/apps/gui/skin_engine/skin_engine.h
  171. @@ -97,7 +97,12 @@ void skin_backdrop_init(void);
  172. * with a good refresh rate.
  173. * gwps is really gwps[NB_SCREENS]! don't wrap this in FOR_NB_SCREENS()
  174. */
  175. -int skin_wait_for_action(struct gui_wps *gwps, int context, int timeout);
  176. +int skin_wait_for_action(enum skinnable_screens skin, int context, int timeout);
  177. #endif
  178.  
  179. +void skin_load(enum skinnable_screens skin, enum screen_type screen,
  180. + const char *buf, bool isfile);
  181. +struct gui_wps *skin_get_gwps(enum skinnable_screens skin, enum screen_type screen);
  182. +struct wps_state *skin_get_global_state(void);
  183. +
  184. #endif
  185. diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c
  186. index 0c18848..5b504f0 100644
  187. --- a/apps/gui/skin_engine/skin_render.c
  188. +++ b/apps/gui/skin_engine/skin_render.c
  189. @@ -706,7 +706,8 @@ static void skin_render_playlistviewer(struct playlistviewer* viewer,
  190. else
  191. #endif
  192. {
  193. - struct cuesheet *cue = gwps->state->id3 ? gwps->state->id3->cuesheet:NULL;
  194. + struct cuesheet *cue = skin_get_global_state()->id3 ?
  195. + skin_get_global_state()->id3->cuesheet : NULL;
  196. cur_pos = playlist_get_display_index();
  197. max = playlist_amount()+1;
  198. if (cue)
  199. diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c
  200. index b555885..82abe62 100644
  201. --- a/apps/gui/skin_engine/skin_tokens.c
  202. +++ b/apps/gui/skin_engine/skin_tokens.c
  203. @@ -517,14 +517,15 @@ static struct mp3entry* get_mp3entry_from_offset(struct gui_wps *gwps,
  204. int offset, char **filename)
  205. {
  206. struct mp3entry* pid3 = NULL;
  207. - struct cuesheet *cue = gwps->state->id3 ? gwps->state->id3->cuesheet:NULL;
  208. + struct wps_state *state = skin_get_global_state();
  209. + struct cuesheet *cue = state->id3 ? state->id3->cuesheet : NULL;
  210. const char *fname = NULL;
  211. if (cue && cue->curr_track_idx + offset < cue->track_count)
  212. - pid3 = gwps->state->id3;
  213. + pid3 = state->id3;
  214. else if (offset == 0)
  215. - pid3 = gwps->state->id3;
  216. + pid3 = state->id3;
  217. else if (offset == 1)
  218. - pid3 = gwps->state->nid3;
  219. + pid3 = state->nid3;
  220. else
  221. {
  222. static char filename_buf[MAX_PATH + 1];
  223. @@ -566,7 +567,7 @@ const char *get_token_value(struct gui_wps *gwps,
  224. return NULL;
  225.  
  226. struct wps_data *data = gwps->data;
  227. - struct wps_state *state = gwps->state;
  228. + struct wps_state *state = skin_get_global_state();
  229. struct mp3entry *id3; /* Think very carefully about using this.
  230. maybe get_id3_token() is the better place? */
  231. const char *out_text = NULL;
  232. diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
  233. index c886a75..62fc62b 100644
  234. --- a/apps/gui/skin_engine/wps_internals.h
  235. +++ b/apps/gui/skin_engine/wps_internals.h
  236. @@ -320,7 +320,6 @@ struct gui_wps
  237. {
  238. struct screen *display;
  239. struct wps_data *data;
  240. - struct wps_state *state;
  241. /* must point to the same struct for all screens */
  242. struct wps_sync_data *sync_data;
  243. };
  244. diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c
  245. index 8928378..48e32b4 100644
  246. --- a/apps/gui/statusbar-skinned.c
  247. +++ b/apps/gui/statusbar-skinned.c
  248. @@ -39,13 +39,6 @@
  249. #include "font.h"
  250. #include "icon.h"
  251.  
  252. -
  253. -/* currently only one wps_state is needed */
  254. -extern struct wps_state wps_state; /* from wps.c */
  255. -static struct gui_wps sb_skin[NB_SCREENS] = {{ .data = NULL }};
  256. -static struct wps_data sb_skin_data[NB_SCREENS] = {{ .wps_loaded = 0 }};
  257. -static struct wps_sync_data sb_skin_sync_data = { .do_full_update = false };
  258. -
  259. /* initial setup of wps_data */
  260. static int update_delay = DEFAULT_UPDATE_DELAY;
  261. static int set_title_worker(char* title, enum themable_icons icon,
  262. @@ -101,26 +94,25 @@ static int set_title_worker(char* title, enum themable_icons icon,
  263.  
  264. bool sb_set_title_text(char* title, enum themable_icons icon, enum screen_type screen)
  265. {
  266. - bool retval = set_title_worker(title, icon, &sb_skin_data[screen],
  267. - sb_skin_data[screen].tree) > 0;
  268. + struct wps_data *data = skin_get_gwps(CUSTOM_STATUSBAR, screen)->data;
  269. + bool retval = set_title_worker(title, icon, data, data->tree) > 0;
  270. return retval;
  271. }
  272.  
  273. -
  274. -void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile)
  275. +int sb_preproccess(enum screen_type screen, struct wps_data *data)
  276. {
  277. - struct wps_data *data = sb_skin[screen].data;
  278. -
  279. - int success;
  280. + (void)data;
  281. /* We need to disable the theme here or else viewport_set_defaults()
  282. * (which is called in the viewport tag parser) will crash because
  283. * the theme is enabled but sb_set_info_vp() isnt set untill after the sbs
  284. * is parsed. This only affects the default viewport which is ignored
  285. * int he sbs anyway */
  286. viewportmanager_theme_enable(screen, false, NULL);
  287. - success = buf && skin_data_load(screen, data, buf, isfile);
  288. -
  289. - if (success)
  290. + return 1;
  291. +}
  292. +int sb_postproccess(enum screen_type screen, struct wps_data *data)
  293. +{
  294. + if (data->wps_loaded)
  295. {
  296. /* hide the sb's default viewport because it has nasty effect with stuff
  297. * not part of the statusbar,
  298. @@ -132,17 +124,20 @@ void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile)
  299. {
  300. if (!next_vp)
  301. { /* no second viewport, let parsing fail */
  302. - success = false;
  303. + return 0;
  304. }
  305. /* hide this viewport, forever */
  306. vp->hidden_flags = VP_NEVER_VISIBLE;
  307. }
  308. sb_set_info_vp(screen, VP_DEFAULT_LABEL);
  309. }
  310. -
  311. - if (!success && isfile)
  312. - sb_create_from_settings(screen);
  313. viewportmanager_theme_undo(screen, false);
  314. + return 1;
  315. +}
  316. +
  317. +void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile)
  318. +{
  319. + skin_load(CUSTOM_STATUSBAR, screen, buf, isfile);
  320. }
  321. static char *infovp_label[NB_SCREENS];
  322. static char *oldinfovp_label[NB_SCREENS];
  323. @@ -153,6 +148,7 @@ void sb_set_info_vp(enum screen_type screen, char *label)
  324.  
  325. struct viewport *sb_skin_get_info_vp(enum screen_type screen)
  326. {
  327. + struct wps_data *data = skin_get_gwps(CUSTOM_STATUSBAR, screen)->data;
  328. if (oldinfovp_label[screen] &&
  329. strcmp(oldinfovp_label[screen], infovp_label[screen]))
  330. {
  331. @@ -161,23 +157,24 @@ struct viewport *sb_skin_get_info_vp(enum screen_type screen)
  332. viewportmanager_theme_enable(screen, false, NULL);
  333. viewportmanager_theme_undo(screen, true);
  334. }
  335. - return &find_viewport(infovp_label[screen], true, sb_skin[screen].data)->vp;
  336. + return &find_viewport(infovp_label[screen], true, data)->vp;
  337. }
  338.  
  339. #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
  340. char* sb_get_backdrop(enum screen_type screen)
  341. {
  342. - return sb_skin[screen].data->backdrop;
  343. + return skin_get_gwps(CUSTOM_STATUSBAR, screen)->data->backdrop;
  344. }
  345.  
  346. bool sb_set_backdrop(enum screen_type screen, char* filename)
  347. {
  348. + struct wps_data *data = skin_get_gwps(CUSTOM_STATUSBAR, screen)->data;
  349. if (!filename)
  350. {
  351. - sb_skin[screen].data->backdrop = NULL;
  352. + data->backdrop = NULL;
  353. return true;
  354. }
  355. - else if (!sb_skin[screen].data->backdrop)
  356. + else if (!data->backdrop)
  357. {
  358. /* need to make room on the buffer */
  359. size_t buf_size;
  360. @@ -187,22 +184,23 @@ bool sb_set_backdrop(enum screen_type screen, char* filename)
  361. else
  362. #endif
  363. buf_size = LCD_BACKDROP_BYTES;
  364. - sb_skin[screen].data->backdrop = (char*)skin_buffer_alloc(buf_size);
  365. - if (!sb_skin[screen].data->backdrop)
  366. + data->backdrop = (char*)skin_buffer_alloc(buf_size);
  367. + if (!data->backdrop)
  368. return false;
  369. }
  370.  
  371. - if (!screens[screen].backdrop_load(filename, sb_skin[screen].data->backdrop))
  372. - sb_skin[screen].data->backdrop = NULL;
  373. - return sb_skin[screen].data->backdrop != NULL;
  374. + if (!screens[screen].backdrop_load(filename, data->backdrop))
  375. + data->backdrop = NULL;
  376. + return data->backdrop != NULL;
  377. }
  378.  
  379. #endif
  380. void sb_skin_update(enum screen_type screen, bool force)
  381. {
  382. + struct wps_data *data = skin_get_gwps(CUSTOM_STATUSBAR, screen)->data;
  383. static long next_update[NB_SCREENS] = {0};
  384. int i = screen;
  385. - if (!sb_skin_data[screen].wps_loaded)
  386. + if (!data->wps_loaded)
  387. return;
  388. if (TIME_AFTER(current_tick, next_update[i]) || force)
  389. {
  390. @@ -212,11 +210,11 @@ void sb_skin_update(enum screen_type screen, bool force)
  391. if (lcd_active() || (i != SCREEN_MAIN))
  392. #endif
  393. {
  394. - bool full_update = sb_skin[i].sync_data->do_full_update;
  395. + bool full_update = skin_get_gwps(CUSTOM_STATUSBAR, screen)->sync_data->do_full_update;
  396. #if NB_SCREENS > 1
  397. - if (i==SCREEN_MAIN && sb_skin[i].sync_data->do_full_update)
  398. + if (i==SCREEN_MAIN && skin_get_gwps(CUSTOM_STATUSBAR, screen)->sync_data->do_full_update)
  399. {
  400. - sb_skin[i].sync_data->do_full_update = false;
  401. + skin_get_gwps(CUSTOM_STATUSBAR, screen)->sync_data->do_full_update = false;
  402. /* we need to make sure the remote gets a full update
  403. * next time it is drawn also. so quick n dirty hack */
  404. next_update[SCREEN_REMOTE] = 0;
  405. @@ -226,9 +224,9 @@ void sb_skin_update(enum screen_type screen, bool force)
  406. full_update = true;
  407. }
  408. #else
  409. - sb_skin[i].sync_data->do_full_update = false;
  410. + skin_get_gwps(CUSTOM_STATUSBAR, screen)->sync_data->do_full_update = false;
  411. #endif
  412. - skin_update(&sb_skin[i], force || full_update?
  413. + skin_update(skin_get_gwps(CUSTOM_STATUSBAR, screen), force || full_update?
  414. SKIN_REFRESH_ALL : SKIN_REFRESH_NON_STATIC);
  415. }
  416. next_update[i] = current_tick + update_delay; /* don't update too often */
  417. @@ -240,7 +238,7 @@ void do_sbs_update_callback(void *param)
  418. (void)param;
  419. /* the WPS handles changing the actual id3 data in the id3 pointers
  420. * we imported, we just want a full update */
  421. - sb_skin_sync_data.do_full_update = true;
  422. + skin_get_gwps(CUSTOM_STATUSBAR, 0)->sync_data->do_full_update = true;
  423. /* force timeout in wps main loop, so that the update is instantly */
  424. queue_post(&button_queue, BUTTON_NONE, 0);
  425. }
  426. @@ -256,9 +254,10 @@ void sb_skin_set_update_delay(int delay)
  427. * - ui viewport
  428. * - backdrop
  429. */
  430. -void sb_create_from_settings(enum screen_type screen)
  431. +char* sb_create_from_settings(enum screen_type screen)
  432. {
  433. - char buf[128], *ptr, *ptr2;
  434. + static char buf[128];
  435. + char *ptr, *ptr2;
  436. int len, remaining = sizeof(buf);
  437. int bar_position = statusbar_position(screen);
  438. ptr = buf;
  439. @@ -328,7 +327,7 @@ void sb_create_from_settings(enum screen_type screen)
  440. len = snprintf(ptr, remaining, "%%ax%%Vi(-,0,%d,-,%d,1)\n",
  441. y, height);
  442. }
  443. - sb_skin_data_load(screen, buf, false);
  444. + return buf;
  445. }
  446.  
  447. void sb_skin_init(void)
  448. @@ -337,16 +336,6 @@ void sb_skin_init(void)
  449. FOR_NB_SCREENS(i)
  450. {
  451. oldinfovp_label[i] = NULL;
  452. -#ifdef HAVE_ALBUMART
  453. - sb_skin_data[i].albumart = NULL;
  454. - sb_skin_data[i].playback_aa_slot = -1;
  455. -#endif
  456. - sb_skin[i].data = &sb_skin_data[i];
  457. - sb_skin[i].display = &screens[i];
  458. - /* Currently no seperate wps_state needed/possible
  459. - so use the only available ( "global" ) one */
  460. - sb_skin[i].state = &wps_state;
  461. - sb_skin[i].sync_data = &sb_skin_sync_data;
  462. }
  463. }
  464.  
  465. @@ -365,9 +354,9 @@ int sb_touch_to_button(int context)
  466. return ACTION_TOUCHSCREEN;
  467.  
  468. if (last_context != context)
  469. - skin_disarm_touchregions(&sb_skin_data[SCREEN_MAIN]);
  470. + skin_disarm_touchregions(skin_get_gwps(CUSTOM_STATUSBAR, SCREEN_MAIN)->data);
  471. last_context = context;
  472. - button = skin_get_touchaction(&sb_skin_data[SCREEN_MAIN], &offset);
  473. + button = skin_get_touchaction(skin_get_gwps(CUSTOM_STATUSBAR, SCREEN_MAIN)->data, &offset);
  474.  
  475. switch (button)
  476. {
  477. diff --git a/apps/gui/statusbar-skinned.h b/apps/gui/statusbar-skinned.h
  478. index 893d489..983b371 100644
  479. --- a/apps/gui/statusbar-skinned.h
  480. +++ b/apps/gui/statusbar-skinned.h
  481. @@ -34,7 +34,7 @@
  482.  
  483. void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile);
  484.  
  485. -void sb_create_from_settings(enum screen_type screen);
  486. +char* sb_create_from_settings(enum screen_type screen);
  487. void sb_skin_init(void) INIT_ATTR;
  488. void sb_set_info_vp(enum screen_type screen, char *label);
  489. struct viewport *sb_skin_get_info_vp(enum screen_type screen);
  490. diff --git a/apps/gui/theme_settings.c b/apps/gui/theme_settings.c
  491. index a975c21..b340a71 100644
  492. --- a/apps/gui/theme_settings.c
  493. +++ b/apps/gui/theme_settings.c
  494. @@ -61,6 +61,7 @@ static const struct skin_load_setting skins[] = {
  495. #ifdef HAVE_LCD_BITMAP
  496. { global_settings.sbs_file, "sbs", sb_skin_data_load},
  497. #endif
  498. +#if 0
  499. { global_settings.wps_file, "wps", wps_data_load},
  500. #if CONFIG_TUNER
  501. { global_settings.fms_file, "fms", fms_data_load},
  502. @@ -72,6 +73,7 @@ static const struct skin_load_setting skins[] = {
  503. { global_settings.rfms_file, "rfms", fms_data_load},
  504. #endif
  505. #endif
  506. +#endif
  507. };
  508.  
  509. void settings_apply_skins(void)
  510. @@ -86,9 +88,6 @@ void settings_apply_skins(void)
  511. skin_backdrop_init();
  512. skin_font_init();
  513. #endif
  514. -#if CONFIG_TUNER
  515. - fms_skin_init();
  516. -#endif
  517. for (i=0; i<ARRAYLEN(skins); i++)
  518. {
  519. #ifdef HAVE_REMOTE_LCD
  520. diff --git a/apps/gui/wps.c b/apps/gui/wps.c
  521. index 6ab016f..a59e1af 100644
  522. --- a/apps/gui/wps.c
  523. +++ b/apps/gui/wps.c
  524. @@ -74,12 +74,6 @@
  525. /* 3% of 30min file == 54s step size */
  526. #define MIN_FF_REWIND_STEP 500
  527.  
  528. -/* currently only one wps_state is needed, initialize to 0 */
  529. - struct wps_state wps_state = { .id3 = NULL };
  530. -static struct gui_wps gui_wps[NB_SCREENS] = {{ .data = NULL }};
  531. -static struct wps_data wps_datas[NB_SCREENS] = {{ .wps_loaded = 0 }};
  532. -static struct wps_sync_data wps_sync_data = { .do_full_update = false };
  533. -
  534. /* initial setup of wps_data */
  535. static void wps_state_init(void);
  536. static void track_changed_callback(void *param);
  537. @@ -94,8 +88,40 @@ static void nextid3available_callback(void* param);
  538. #define DEFAULT_WPS(screen) (WPS_DEFAULTCFG)
  539. #endif
  540.  
  541. +char* wps_default_skin(enum screen_type screen)
  542. +{
  543. + static char *skin_buf[NB_SCREENS] = {
  544. +#ifdef HAVE_LCD_BITMAP
  545. +#if LCD_DEPTH > 1
  546. + "%X(d)\n"
  547. +#endif
  548. + "%s%?it<%?in<%in. |>%it|%fn>\n"
  549. + "%s%?ia<%ia|%?d(2)<%d(2)|%(root%)>>\n"
  550. + "%s%?id<%id|%?d(1)<%d(1)|%(root%)>> %?iy<%(%iy%)|>\n\n"
  551. + "%al%pc/%pt%ar[%pp:%pe]\n"
  552. + "%fbkBit %?fv<avg|> %?iv<%(id3v%iv%)|%(no id3%)>\n"
  553. + "%pb\n%pm\n",
  554. +#else
  555. + "%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d(2)> - %?id<%id|%d(1)>\n"
  556. + "%pc%?ps<*|/>%pt\n",
  557. +#endif
  558. +#ifdef HAVE_REMOTE_LCD
  559. +#if LCD_REMOTE_DEPTH > 1
  560. + "%X(d)\n"
  561. +#endif
  562. + "%s%?ia<%ia|%?d(2)<%d(2)|%(root%)>>\n"
  563. + "%s%?it<%?in<%in. |>%it|%fn>\n"
  564. + "%al%pc/%pt%ar[%pp:%pe]\n"
  565. + "%fbkBit %?fv<avg|> %?iv<%(id3v%iv%)|%(no id3%)>\n"
  566. + "%pb\n",
  567. +#endif
  568. + };
  569. + return skin_buf[screen];
  570. +}
  571. +
  572. void wps_data_load(enum screen_type screen, const char *buf, bool isfile)
  573. {
  574. +#if 0
  575. bool loaded_ok;
  576.  
  577. #ifndef __PCTOOL__
  578. @@ -122,34 +148,11 @@ void wps_data_load(enum screen_type screen, const char *buf, bool isfile)
  579.  
  580. if (!loaded_ok) /* load the hardcoded default */
  581. {
  582. - char *skin_buf[NB_SCREENS] = {
  583. -#ifdef HAVE_LCD_BITMAP
  584. -#if LCD_DEPTH > 1
  585. - "%X(d)\n"
  586. -#endif
  587. - "%s%?it<%?in<%in. |>%it|%fn>\n"
  588. - "%s%?ia<%ia|%?d(2)<%d(2)|%(root%)>>\n"
  589. - "%s%?id<%id|%?d(1)<%d(1)|%(root%)>> %?iy<%(%iy%)|>\n\n"
  590. - "%al%pc/%pt%ar[%pp:%pe]\n"
  591. - "%fbkBit %?fv<avg|> %?iv<%(id3v%iv%)|%(no id3%)>\n"
  592. - "%pb\n%pm\n",
  593. -#else
  594. - "%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d(2)> - %?id<%id|%d(1)>\n"
  595. - "%pc%?ps<*|/>%pt\n",
  596. -#endif
  597. -#ifdef HAVE_REMOTE_LCD
  598. -#if LCD_REMOTE_DEPTH > 1
  599. - "%X(d)\n"
  600. -#endif
  601. - "%s%?ia<%ia|%?d(2)<%d(2)|%(root%)>>\n"
  602. - "%s%?it<%?in<%in. |>%it|%fn>\n"
  603. - "%al%pc/%pt%ar[%pp:%pe]\n"
  604. - "%fbkBit %?fv<avg|> %?iv<%(id3v%iv%)|%(no id3%)>\n"
  605. - "%pb\n",
  606. -#endif
  607. - };
  608. +
  609. skin_data_load(screen, gui_wps[screen].data, skin_buf[screen], false);
  610. }
  611. +#endif
  612. + skin_load(WPS, screen, buf, isfile);
  613. }
  614.  
  615. void fade(bool fade_in, bool updatewps)
  616. @@ -158,7 +161,7 @@ void fade(bool fade_in, bool updatewps)
  617. int fp_min_vol = sound_min(SOUND_VOLUME) << 8;
  618. int fp_step = (fp_global_vol - fp_min_vol) / 30;
  619. int i;
  620. - wps_state.is_fading = !fade_in;
  621. + skin_get_global_state()->is_fading = !fade_in;
  622. if (fade_in) {
  623. /* fade in */
  624. int fp_volume = fp_min_vol;
  625. @@ -175,7 +178,7 @@ void fade(bool fade_in, bool updatewps)
  626. if (updatewps)
  627. {
  628. FOR_NB_SCREENS(i)
  629. - skin_update(&gui_wps[i], SKIN_REFRESH_NON_STATIC);
  630. + skin_update(skin_get_gwps(WPS, i), SKIN_REFRESH_NON_STATIC);
  631. }
  632. sleep(1);
  633. }
  634. @@ -191,12 +194,12 @@ void fade(bool fade_in, bool updatewps)
  635. if (updatewps)
  636. {
  637. FOR_NB_SCREENS(i)
  638. - skin_update(&gui_wps[i], SKIN_REFRESH_NON_STATIC);
  639. + skin_update(skin_get_gwps(WPS, i), SKIN_REFRESH_NON_STATIC);
  640. }
  641. sleep(1);
  642. }
  643. audio_pause();
  644. - wps_state.is_fading = false;
  645. + skin_get_global_state()->is_fading = false;
  646. #if CONFIG_CODEC != SWCODEC
  647. #ifndef SIMULATOR
  648. /* let audio thread run and wait for the mas to run out of data */
  649. @@ -249,16 +252,16 @@ static int skintouch_to_wps(struct wps_data *data)
  650. return ACTION_WPS_HOTKEY;
  651. #endif
  652. case WPS_TOUCHREGION_SCROLLBAR:
  653. - wps_state.id3->elapsed = wps_state.id3->length*offset/100;
  654. - if (!wps_state.paused)
  655. + skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->length*offset/100;
  656. + if (!skin_get_global_state()->paused)
  657. #if (CONFIG_CODEC == SWCODEC)
  658. audio_pre_ff_rewind();
  659. #else
  660. audio_pause();
  661. #endif
  662. - audio_ff_rewind(wps_state.id3->elapsed);
  663. + audio_ff_rewind(skin_get_global_state()->id3->elapsed);
  664. #if (CONFIG_CODEC != SWCODEC)
  665. - if (!wps_state.paused)
  666. + if (!skin_get_global_state()->paused)
  667. audio_resume();
  668. #endif
  669. return ACTION_TOUCHSCREEN;
  670. @@ -299,20 +302,20 @@ bool ffwd_rew(int button)
  671. case ACTION_WPS_SEEKFWD:
  672. direction = 1;
  673. case ACTION_WPS_SEEKBACK:
  674. - if (wps_state.ff_rewind)
  675. + if (skin_get_global_state()->ff_rewind)
  676. {
  677. if (direction == 1)
  678. {
  679. /* fast forwarding, calc max step relative to end */
  680. - max_step = (wps_state.id3->length -
  681. - (wps_state.id3->elapsed +
  682. + max_step = (skin_get_global_state()->id3->length -
  683. + (skin_get_global_state()->id3->elapsed +
  684. ff_rewind_count)) *
  685. FF_REWIND_MAX_PERCENT / 100;
  686. }
  687. else
  688. {
  689. /* rewinding, calc max step relative to start */
  690. - max_step = (wps_state.id3->elapsed + ff_rewind_count) *
  691. + max_step = (skin_get_global_state()->id3->elapsed + ff_rewind_count) *
  692. FF_REWIND_MAX_PERCENT / 100;
  693. }
  694.  
  695. @@ -329,9 +332,9 @@ bool ffwd_rew(int button)
  696. else
  697. {
  698. if ( (audio_status() & AUDIO_STATUS_PLAY) &&
  699. - wps_state.id3 && wps_state.id3->length )
  700. + skin_get_global_state()->id3 && skin_get_global_state()->id3->length )
  701. {
  702. - if (!wps_state.paused)
  703. + if (!skin_get_global_state()->paused)
  704. #if (CONFIG_CODEC == SWCODEC)
  705. audio_pre_ff_rewind();
  706. #else
  707. @@ -339,14 +342,14 @@ bool ffwd_rew(int button)
  708. #endif
  709. #if CONFIG_KEYPAD == PLAYER_PAD
  710. FOR_NB_SCREENS(i)
  711. - gui_wps[i].display->stop_scroll();
  712. + skin_get_gwps(WPS, i)->display->stop_scroll();
  713. #endif
  714. if (direction > 0)
  715. status_set_ffmode(STATUS_FASTFORWARD);
  716. else
  717. status_set_ffmode(STATUS_FASTBACKWARD);
  718.  
  719. - wps_state.ff_rewind = true;
  720. + skin_get_global_state()->ff_rewind = true;
  721.  
  722. step = 1000 * global_settings.ff_rewind_min_step;
  723. }
  724. @@ -355,23 +358,23 @@ bool ffwd_rew(int button)
  725. }
  726.  
  727. if (direction > 0) {
  728. - if ((wps_state.id3->elapsed + ff_rewind_count) >
  729. - wps_state.id3->length)
  730. - ff_rewind_count = wps_state.id3->length -
  731. - wps_state.id3->elapsed;
  732. + if ((skin_get_global_state()->id3->elapsed + ff_rewind_count) >
  733. + skin_get_global_state()->id3->length)
  734. + ff_rewind_count = skin_get_global_state()->id3->length -
  735. + skin_get_global_state()->id3->elapsed;
  736. }
  737. else {
  738. - if ((int)(wps_state.id3->elapsed + ff_rewind_count) < 0)
  739. - ff_rewind_count = -wps_state.id3->elapsed;
  740. + if ((int)(skin_get_global_state()->id3->elapsed + ff_rewind_count) < 0)
  741. + ff_rewind_count = -skin_get_global_state()->id3->elapsed;
  742. }
  743.  
  744. /* set the wps state ff_rewind_count so the progess info
  745. displays corectly */
  746. - wps_state.ff_rewind_count = (wps_state.wps_time_countup == false)?
  747. + skin_get_global_state()->ff_rewind_count = (skin_get_global_state()->wps_time_countup == false)?
  748. ff_rewind_count:-ff_rewind_count;
  749. FOR_NB_SCREENS(i)
  750. {
  751. - skin_update(&gui_wps[i],
  752. + skin_update(skin_get_gwps(WPS, i),
  753. SKIN_REFRESH_PLAYER_PROGRESS |
  754. SKIN_REFRESH_DYNAMIC);
  755. }
  756. @@ -379,18 +382,18 @@ bool ffwd_rew(int button)
  757. break;
  758.  
  759. case ACTION_WPS_STOPSEEK:
  760. - wps_state.id3->elapsed = wps_state.id3->elapsed+ff_rewind_count;
  761. - audio_ff_rewind(wps_state.id3->elapsed);
  762. - wps_state.ff_rewind_count = 0;
  763. - wps_state.ff_rewind = false;
  764. + skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->elapsed+ff_rewind_count;
  765. + audio_ff_rewind(skin_get_global_state()->id3->elapsed);
  766. + skin_get_global_state()->ff_rewind_count = 0;
  767. + skin_get_global_state()->ff_rewind = false;
  768. status_set_ffmode(0);
  769. #if (CONFIG_CODEC != SWCODEC)
  770. - if (!wps_state.paused)
  771. + if (!skin_get_global_state()->paused)
  772. audio_resume();
  773. #endif
  774. #ifdef HAVE_LCD_CHARCELLS
  775. FOR_NB_SCREENS(i)
  776. - skin_update(&gui_wps[i], SKIN_REFRESH_ALL);
  777. + skin_update(skin_get_gwps(WPS, i), SKIN_REFRESH_ALL);
  778. #endif
  779. exit = true;
  780. break;
  781. @@ -408,7 +411,7 @@ bool ffwd_rew(int button)
  782. button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,TIMEOUT_BLOCK);
  783. #ifdef HAVE_TOUCHSCREEN
  784. if (button == ACTION_TOUCHSCREEN)
  785. - button = skintouch_to_wps(gui_wps[SCREEN_MAIN].data);
  786. + button = skintouch_to_wps(skin_get_gwps(WPS, SCREEN_MAIN)->data);
  787. if (button != ACTION_WPS_SEEKFWD &&
  788. button != ACTION_WPS_SEEKBACK)
  789. button = ACTION_WPS_STOPSEEK;
  790. @@ -423,7 +426,7 @@ void display_keylock_text(bool locked)
  791. {
  792. int i;
  793. FOR_NB_SCREENS(i)
  794. - gui_wps[i].display->stop_scroll();
  795. + skin_get_gwps(WPS, i)->display->stop_scroll();
  796.  
  797. splash(HZ, locked ? ID2P(LANG_KEYLOCK_ON) : ID2P(LANG_KEYLOCK_OFF));
  798. }
  799. @@ -489,20 +492,21 @@ static void change_dir(int direction)
  800.  
  801. static void prev_track(unsigned long skip_thresh)
  802. {
  803. - if (wps_state.id3->elapsed < skip_thresh)
  804. + struct wps_state *state = skin_get_global_state();
  805. + if (state->id3->elapsed < skip_thresh)
  806. {
  807. audio_prev();
  808. return;
  809. }
  810. else
  811. {
  812. - if (wps_state.id3->cuesheet)
  813. + if (state->id3->cuesheet)
  814. {
  815. - curr_cuesheet_skip(wps_state.id3->cuesheet, -1, wps_state.id3->elapsed);
  816. + curr_cuesheet_skip(state->id3->cuesheet, -1, state->id3->elapsed);
  817. return;
  818. }
  819.  
  820. - if (!wps_state.paused)
  821. + if (!state->paused)
  822. #if (CONFIG_CODEC == SWCODEC)
  823. audio_pre_ff_rewind();
  824. #else
  825. @@ -512,7 +516,7 @@ static void prev_track(unsigned long skip_thresh)
  826. audio_ff_rewind(0);
  827.  
  828. #if (CONFIG_CODEC != SWCODEC)
  829. - if (!wps_state.paused)
  830. + if (!state->paused)
  831. audio_resume();
  832. #endif
  833. }
  834. @@ -520,10 +524,11 @@ static void prev_track(unsigned long skip_thresh)
  835.  
  836. static void next_track(void)
  837. {
  838. + struct wps_state *state = skin_get_global_state();
  839. /* take care of if we're playing a cuesheet */
  840. - if (wps_state.id3->cuesheet)
  841. + if (state->id3->cuesheet)
  842. {
  843. - if (curr_cuesheet_skip(wps_state.id3->cuesheet, 1, wps_state.id3->elapsed))
  844. + if (curr_cuesheet_skip(state->id3->cuesheet, 1, state->id3->elapsed))
  845. {
  846. /* if the result was false, then we really want
  847. to skip to the next track */
  848. @@ -536,9 +541,10 @@ static void next_track(void)
  849.  
  850. static void play_hop(int direction)
  851. {
  852. + struct wps_state *state = skin_get_global_state();
  853. long step = global_settings.skip_length*1000;
  854. - long elapsed = wps_state.id3->elapsed;
  855. - long remaining = wps_state.id3->length - elapsed;
  856. + long elapsed = state->id3->elapsed;
  857. + long remaining = state->id3->length - elapsed;
  858.  
  859. if (step < 0)
  860. {
  861. @@ -582,7 +588,7 @@ static void play_hop(int direction)
  862. {
  863. elapsed += step * direction;
  864. }
  865. - if((audio_status() & AUDIO_STATUS_PLAY) && !wps_state.paused)
  866. + if((audio_status() & AUDIO_STATUS_PLAY) && !state->paused)
  867. {
  868. #if (CONFIG_CODEC == SWCODEC)
  869. audio_pre_ff_rewind();
  870. @@ -590,9 +596,9 @@ static void play_hop(int direction)
  871. audio_pause();
  872. #endif
  873. }
  874. - audio_ff_rewind(wps_state.id3->elapsed = elapsed);
  875. + audio_ff_rewind(state->id3->elapsed = elapsed);
  876. #if (CONFIG_CODEC != SWCODEC)
  877. - if (!wps_state.paused)
  878. + if (!state->paused)
  879. audio_resume();
  880. #endif
  881. }
  882. @@ -607,7 +613,7 @@ static void play_hop(int direction)
  883. static void wps_lcd_activation_hook(void *param)
  884. {
  885. (void)param;
  886. - wps_sync_data.do_full_update = true;
  887. + skin_get_gwps(WPS, 0)->sync_data->do_full_update = true;
  888. /* force timeout in wps main loop, so that the update is instantly */
  889. queue_post(&button_queue, BUTTON_NONE, 0);
  890. }
  891. @@ -619,11 +625,11 @@ static void gwps_leave_wps(void)
  892.  
  893. FOR_NB_SCREENS(i)
  894. {
  895. - gui_wps[i].display->stop_scroll();
  896. + skin_get_gwps(WPS, i)->display->stop_scroll();
  897. #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
  898. - gui_wps[i].display->backdrop_show(sb_get_backdrop(i));
  899. + skin_get_gwps(WPS, i)->display->backdrop_show(sb_get_backdrop(i));
  900. #endif
  901. - viewportmanager_theme_undo(i, skin_has_sbs(i, gui_wps[i].data));
  902. + viewportmanager_theme_undo(i, skin_has_sbs(i, skin_get_gwps(WPS, i)->data));
  903.  
  904. }
  905.  
  906. @@ -645,10 +651,10 @@ static void gwps_enter_wps(void)
  907. int i;
  908. FOR_NB_SCREENS(i)
  909. {
  910. - struct gui_wps *gwps = &gui_wps[i];
  911. + struct gui_wps *gwps = skin_get_gwps(WPS, i);
  912. struct screen *display = gwps->display;
  913. display->stop_scroll();
  914. - viewportmanager_theme_enable(i, skin_has_sbs(i, gui_wps[i].data), NULL);
  915. + viewportmanager_theme_enable(i, skin_has_sbs(i, skin_get_gwps(WPS, i)->data), NULL);
  916.  
  917. /* Update the values in the first (default) viewport - in case the user
  918. has modified the statusbar or colour settings */
  919. @@ -702,6 +708,7 @@ long gui_wps_show(void)
  920. bool vol_changed = false;
  921. int i;
  922. long last_left = 0, last_right = 0;
  923. + struct wps_state *state = skin_get_global_state();
  924.  
  925. #ifdef HAVE_LCD_CHARCELLS
  926. status_set_audio(true);
  927. @@ -719,19 +726,19 @@ long gui_wps_show(void)
  928. bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false;
  929.  
  930. /* did someone else (i.e power thread) change audio pause mode? */
  931. - if (wps_state.paused != audio_paused) {
  932. - wps_state.paused = audio_paused;
  933. + if (state->paused != audio_paused) {
  934. + state->paused = audio_paused;
  935.  
  936. /* if another thread paused audio, we are probably in car mode,
  937. about to shut down. lets save the settings. */
  938. - if (wps_state.paused) {
  939. + if (state->paused) {
  940. settings_save();
  941. #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
  942. call_storage_idle_notifys(true);
  943. #endif
  944. }
  945. }
  946. - button = skin_wait_for_action(gui_wps, CONTEXT_WPS|ALLOW_SOFTLOCK,
  947. + button = skin_wait_for_action(WPS, CONTEXT_WPS|ALLOW_SOFTLOCK,
  948. restore ? 1 : HZ/5);
  949.  
  950. /* Exit if audio has stopped playing. This happens e.g. at end of
  951. @@ -778,7 +785,7 @@ long gui_wps_show(void)
  952. {
  953. bool hotkey = button == ACTION_WPS_HOTKEY;
  954. gwps_leave_wps();
  955. - int retval = onplay(wps_state.id3->path,
  956. + int retval = onplay(state->id3->path,
  957. FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey);
  958. /* if music is stopped in the context menu we want to exit the wps */
  959. if (retval == ONPLAY_MAINMENU
  960. @@ -807,9 +814,9 @@ long gui_wps_show(void)
  961. case ACTION_WPS_PLAY:
  962. if (global_settings.party_mode)
  963. break;
  964. - if ( wps_state.paused )
  965. + if ( state->paused )
  966. {
  967. - wps_state.paused = false;
  968. + state->paused = false;
  969. if ( global_settings.fade_on_stop )
  970. fade(true, true);
  971. else
  972. @@ -817,7 +824,7 @@ long gui_wps_show(void)
  973. }
  974. else
  975. {
  976. - wps_state.paused = true;
  977. + state->paused = true;
  978. if ( global_settings.fade_on_stop )
  979. fade(false, true);
  980. else
  981. @@ -844,7 +851,7 @@ long gui_wps_show(void)
  982. break;
  983. if (current_tick -last_right < HZ)
  984. {
  985. - if (wps_state.id3->cuesheet)
  986. + if (state->id3->cuesheet)
  987. {
  988. audio_next();
  989. }
  990. @@ -864,9 +871,9 @@ long gui_wps_show(void)
  991. break;
  992. if (current_tick -last_left < HZ)
  993. {
  994. - if (wps_state.id3->cuesheet)
  995. + if (state->id3->cuesheet)
  996. {
  997. - if (!wps_state.paused)
  998. + if (!state->paused)
  999. #if (CONFIG_CODEC == SWCODEC)
  1000. audio_pre_ff_rewind();
  1001. #else
  1002. @@ -894,7 +901,7 @@ long gui_wps_show(void)
  1003. is past the A marker, jump back to the A marker... */
  1004. if ( ab_repeat_mode_enabled() )
  1005. {
  1006. - if ( ab_after_A_marker(wps_state.id3->elapsed) )
  1007. + if ( ab_after_A_marker(state->id3->elapsed) )
  1008. {
  1009. ab_jump_to_A_marker();
  1010. break;
  1011. @@ -917,7 +924,7 @@ long gui_wps_show(void)
  1012. before the A marker, jump to the A marker... */
  1013. if ( ab_repeat_mode_enabled() )
  1014. {
  1015. - if ( ab_before_A_marker(wps_state.id3->elapsed) )
  1016. + if ( ab_before_A_marker(state->id3->elapsed) )
  1017. {
  1018. ab_jump_to_A_marker();
  1019. break;
  1020. @@ -936,7 +943,7 @@ long gui_wps_show(void)
  1021. #if defined(AB_REPEAT_ENABLE)
  1022. if (ab_repeat_mode_enabled())
  1023. {
  1024. - ab_set_B_marker(wps_state.id3->elapsed);
  1025. + ab_set_B_marker(state->id3->elapsed);
  1026. ab_jump_to_A_marker();
  1027. }
  1028. else
  1029. @@ -950,7 +957,7 @@ long gui_wps_show(void)
  1030. break;
  1031. #if defined(AB_REPEAT_ENABLE)
  1032. if (ab_repeat_mode_enabled())
  1033. - ab_set_A_marker(wps_state.id3->elapsed);
  1034. + ab_set_A_marker(state->id3->elapsed);
  1035. else
  1036. #endif
  1037. {
  1038. @@ -1052,7 +1059,7 @@ long gui_wps_show(void)
  1039. /* this case is used by the softlock feature
  1040. * it requests a full update here */
  1041. case ACTION_REDRAW:
  1042. - wps_sync_data.do_full_update = true;
  1043. + skin_get_gwps(WPS, 0)->sync_data->do_full_update = true;
  1044. break;
  1045. case ACTION_NONE: /* Timeout, do a partial update */
  1046. update = true;
  1047. @@ -1087,7 +1094,7 @@ long gui_wps_show(void)
  1048. setvol();
  1049. FOR_NB_SCREENS(i)
  1050. {
  1051. - if(update_onvol_change(&gui_wps[i]))
  1052. + if(update_onvol_change(skin_get_gwps(WPS, i)))
  1053. res = true;
  1054. }
  1055. if (res) {
  1056. @@ -1109,15 +1116,15 @@ long gui_wps_show(void)
  1057. /* we remove the update delay since it's not very usable in the wps,
  1058. * e.g. during volume changing or ffwd/rewind */
  1059. sb_skin_set_update_delay(0);
  1060. - wps_sync_data.do_full_update = update = false;
  1061. + skin_get_gwps(WPS, 0)->sync_data->do_full_update = update = false;
  1062. gwps_enter_wps();
  1063. }
  1064. - else if (wps_sync_data.do_full_update || update)
  1065. + else if (skin_get_gwps(WPS, 0)->sync_data->do_full_update || update)
  1066. {
  1067. #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
  1068. - gwps_caption_backlight(&wps_state);
  1069. + gwps_caption_backlight(state);
  1070. #endif
  1071. - bool full_update = wps_sync_data.do_full_update;
  1072. + bool full_update = skin_get_gwps(WPS, 0)->sync_data->do_full_update;
  1073. FOR_NB_SCREENS(i)
  1074. {
  1075. #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
  1076. @@ -1127,15 +1134,15 @@ long gui_wps_show(void)
  1077. #endif
  1078. {
  1079. #if NB_SCREENS > 1
  1080. - if (i==SCREEN_MAIN && wps_sync_data.do_full_update)
  1081. + if (i==SCREEN_MAIN && skin_get_gwps(WPS, 0)->sync_data->do_full_update)
  1082. {
  1083. - wps_sync_data.do_full_update = false;
  1084. + skin_get_gwps(WPS, 0)->sync_data->do_full_update = false;
  1085. }
  1086.  
  1087. #else
  1088. - wps_sync_data.do_full_update = false;
  1089. + skin_get_gwps(WPS, 0)->sync_data->do_full_update = false;
  1090. #endif
  1091. - skin_update(&gui_wps[i], full_update ?
  1092. + skin_update(skin_get_gwps(WPS, i), full_update ?
  1093. SKIN_REFRESH_ALL : SKIN_REFRESH_NON_STATIC);
  1094. }
  1095. }
  1096. @@ -1175,38 +1182,40 @@ long gui_wps_show(void)
  1097. /* this is called from the playback thread so NO DRAWING! */
  1098. static void track_changed_callback(void *param)
  1099. {
  1100. - wps_state.id3 = (struct mp3entry*)param;
  1101. - wps_state.nid3 = audio_next_track();
  1102. - if (wps_state.id3->cuesheet)
  1103. + struct wps_state *state = skin_get_global_state();
  1104. + state->id3 = (struct mp3entry*)param;
  1105. + state->nid3 = audio_next_track();
  1106. + if (state->id3->cuesheet)
  1107. {
  1108. - cue_find_current_track(wps_state.id3->cuesheet, wps_state.id3->elapsed);
  1109. + cue_find_current_track(state->id3->cuesheet, state->id3->elapsed);
  1110. }
  1111. - wps_sync_data.do_full_update = true;
  1112. + skin_get_gwps(WPS, 0)->sync_data->do_full_update = true;
  1113. }
  1114. static void nextid3available_callback(void* param)
  1115. {
  1116. (void)param;
  1117. - wps_state.nid3 = audio_next_track();
  1118. - wps_sync_data.do_full_update = true;
  1119. + skin_get_global_state()->nid3 = audio_next_track();
  1120. + skin_get_gwps(WPS, 0)->sync_data->do_full_update = true;
  1121. }
  1122.  
  1123.  
  1124. static void wps_state_init(void)
  1125. {
  1126. - wps_state.ff_rewind = false;
  1127. - wps_state.paused = false;
  1128. + struct wps_state *state = skin_get_global_state();
  1129. + state->ff_rewind = false;
  1130. + state->paused = false;
  1131. if(audio_status() & AUDIO_STATUS_PLAY)
  1132. {
  1133. - wps_state.id3 = audio_current_track();
  1134. - wps_state.nid3 = audio_next_track();
  1135. + state->id3 = audio_current_track();
  1136. + state->nid3 = audio_next_track();
  1137. }
  1138. else
  1139. {
  1140. - wps_state.id3 = NULL;
  1141. - wps_state.nid3 = NULL;
  1142. + state->id3 = NULL;
  1143. + state->nid3 = NULL;
  1144. }
  1145. /* We'll be updating due to restore initialized with true */
  1146. - wps_sync_data.do_full_update = false;
  1147. + skin_get_gwps(WPS, 0)->sync_data->do_full_update = true;
  1148. /* add the WPS track event callbacks */
  1149. add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, track_changed_callback);
  1150. add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, false, nextid3available_callback);
  1151. @@ -1215,32 +1224,18 @@ static void wps_state_init(void)
  1152.  
  1153. void gui_sync_wps_init(void)
  1154. {
  1155. - int i;
  1156. - FOR_NB_SCREENS(i)
  1157. - {
  1158. -#ifdef HAVE_ALBUMART
  1159. - wps_datas[i].albumart = NULL;
  1160. - wps_datas[i].playback_aa_slot = -1;
  1161. -#endif
  1162. - gui_wps[i].data = &wps_datas[i];
  1163. - gui_wps[i].display = &screens[i];
  1164. - /* Currently no seperate wps_state needed/possible
  1165. - so use the only available ( "global" ) one */
  1166. - gui_wps[i].state = &wps_state;
  1167. - /* must point to the same struct for both screens */
  1168. - gui_wps[i].sync_data = &wps_sync_data;
  1169. - }
  1170. + gui_sync_skin_init();
  1171. }
  1172.  
  1173.  
  1174. #ifdef IPOD_ACCESSORY_PROTOCOL
  1175. bool is_wps_fading(void)
  1176. {
  1177. - return wps_state.is_fading;
  1178. + return skin_get_global_state()->is_fading;
  1179. }
  1180.  
  1181. int wps_get_ff_rewind_count(void)
  1182. {
  1183. - return wps_state.ff_rewind_count;
  1184. + return skin_get_global_state()->ff_rewind_count;
  1185. }
  1186. #endif
  1187. diff --git a/apps/radio/radio.c b/apps/radio/radio.c
  1188. index 74bdb4b..8c4d88c 100644
  1189. --- a/apps/radio/radio.c
  1190. +++ b/apps/radio/radio.c
  1191. @@ -422,7 +422,7 @@ int radio_screen(void)
  1192. {
  1193. radio_load_presets(global_settings.fmr_file);
  1194. }
  1195. - fms_get(SCREEN_MAIN)->state->id3 = NULL;
  1196. + skin_get_global_state()->id3 = NULL;
  1197. #ifdef HAVE_ALBUMART
  1198. radioart_init(true);
  1199. #endif
  1200. diff --git a/apps/radio/radio.h b/apps/radio/radio.h
  1201. index 7c263ce..f02558f 100644
  1202. --- a/apps/radio/radio.h
  1203. +++ b/apps/radio/radio.h
  1204. @@ -52,7 +52,6 @@ const struct fmstation *radio_get_preset(int preset);
  1205.  
  1206. /* skin functions */
  1207. void fms_data_load(enum screen_type screen, const char *buf, bool isfile);
  1208. -void fms_skin_init(void);
  1209.  
  1210. /* callbacks for the radio settings */
  1211. void set_radio_region(int region);
  1212. diff --git a/apps/radio/radio_skin.c b/apps/radio/radio_skin.c
  1213. index 26e6dac..4697e11 100644
  1214. --- a/apps/radio/radio_skin.c
  1215. +++ b/apps/radio/radio_skin.c
  1216. @@ -32,45 +32,42 @@
  1217. #include "statusbar-skinned.h"
  1218.  
  1219.  
  1220. -extern struct wps_state wps_state; /* from wps.c */
  1221. -static struct gui_wps fms_skin[NB_SCREENS] = {{ .data = NULL }};
  1222. -static struct wps_data fms_skin_data[NB_SCREENS] = {{ .wps_loaded = 0 }};
  1223. -static struct wps_sync_data fms_skin_sync_data = { .do_full_update = false };
  1224. -
  1225. -void fms_data_load(enum screen_type screen, const char *buf, bool isfile)
  1226. +char* default_radio_skin(enum screen_type screen)
  1227. {
  1228. - struct wps_data *data = fms_skin[screen].data;
  1229. - int success;
  1230. - success = buf && skin_data_load(screen, data, buf, isfile);
  1231. -
  1232. - if (!success ) /* load the default */
  1233. - {
  1234. - const char default_fms[] = "%s%?Ti<%Ti. |>%?Tn<%Tn|%Tf>\n"
  1235. - "%Sx(Station:) %tf MHz\n"
  1236. - "%?St(force fm mono)<%Sx(Force Mono)|%?ts<%Sx(Stereo)|%Sx(Mono)>>\n"
  1237. - "%Sx(Mode:) %?tm<%Sx(Scan)|%Sx(Preset)>\n"
  1238. + (void)screen;
  1239. + static char default_fms[] =
  1240. + "%s%?Ti<%Ti. |>%?Tn<%Tn|%Tf>\n"
  1241. + "%Sx(Station:) %tf MHz\n"
  1242. + "%?St(force fm mono)<%Sx(Force Mono)|%?ts<%Sx(Stereo)|%Sx(Mono)>>\n"
  1243. + "%Sx(Mode:) %?tm<%Sx(Scan)|%Sx(Preset)>\n"
  1244. #if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR)
  1245. - "%?Rr<%Sx(Time:) %Rh:%Rn:%Rs|%?St(prerecording time)<%pm|%Sx(Prerecord Time) %Rs>>\n"
  1246. + "%?Rr<%Sx(Time:) %Rh:%Rn:%Rs|%?St(prerecording time)<%pm|%Sx(Prerecord Time) %Rs>>\n"
  1247. #endif
  1248. - "%pb\n"
  1249. + "%pb\n"
  1250. #ifdef HAVE_RDS_CAP
  1251. - "\n%s%ty\n"
  1252. - "%s%tz\n"
  1253. + "\n%s%ty\n"
  1254. + "%s%tz\n"
  1255. #endif
  1256. - ;
  1257. - skin_data_load(screen, data, default_fms, false);
  1258. - }
  1259. + ;
  1260. + return default_fms;
  1261. }
  1262. +
  1263. +void fms_data_load(enum screen_type screen, const char *buf, bool isfile)
  1264. +{
  1265. + skin_load(FM_SCREEN, screen, buf, isfile);
  1266. +}
  1267. +
  1268. void fms_fix_displays(enum fms_exiting toggle_state)
  1269. {
  1270. int i;
  1271. FOR_NB_SCREENS(i)
  1272. {
  1273. + struct wps_data *data = skin_get_gwps(FM_SCREEN, i)->data;
  1274. if (toggle_state == FMS_ENTER)
  1275. {
  1276. - viewportmanager_theme_enable(i, skin_has_sbs(i, fms_skin[i].data), NULL);
  1277. + viewportmanager_theme_enable(i, skin_has_sbs(i, data), NULL);
  1278. #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
  1279. - screens[i].backdrop_show(fms_skin[i].data->backdrop);
  1280. + screens[i].backdrop_show(data->backdrop);
  1281. #endif
  1282. screens[i].clear_display();
  1283. /* force statusbar/skin update since we just cleared the whole screen */
  1284. @@ -82,43 +79,26 @@ void fms_fix_displays(enum fms_exiting toggle_state)
  1285. #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
  1286. screens[i].backdrop_show(sb_get_backdrop(i));
  1287. #endif
  1288. - viewportmanager_theme_undo(i, skin_has_sbs(i, fms_skin[i].data));
  1289. + viewportmanager_theme_undo(i, skin_has_sbs(i, data));
  1290. }
  1291. }
  1292. #ifdef HAVE_TOUCHSCREEN
  1293. - if (!fms_skin[SCREEN_MAIN].data->touchregions)
  1294. + if (i==SCREEN_MAIN && !data->touchregions)
  1295. touchscreen_set_mode(toggle_state == FMS_ENTER ?
  1296. TOUCHSCREEN_BUTTON : global_settings.touch_mode);
  1297. #endif
  1298. }
  1299.  
  1300.  
  1301. -void fms_skin_init(void)
  1302. -{
  1303. - int i;
  1304. - FOR_NB_SCREENS(i)
  1305. - {
  1306. -#ifdef HAVE_ALBUMART
  1307. - fms_skin_data[i].albumart = NULL;
  1308. - fms_skin_data[i].playback_aa_slot = -1;
  1309. -#endif
  1310. - fms_skin[i].data = &fms_skin_data[i];
  1311. - fms_skin[i].display = &screens[i];
  1312. - /* Currently no seperate wps_state needed/possible
  1313. - so use the only available ( "global" ) one */
  1314. - fms_skin[i].state = &wps_state;
  1315. - fms_skin[i].sync_data = &fms_skin_sync_data;
  1316. - }
  1317. -}
  1318. -
  1319. int fms_do_button_loop(bool update_screen)
  1320. {
  1321. - int button = skin_wait_for_action(fms_skin, CONTEXT_FM,
  1322. + int button = skin_wait_for_action(FM_SCREEN, CONTEXT_FM,
  1323. update_screen ? TIMEOUT_NOBLOCK : HZ/5);
  1324. #ifdef HAVE_TOUCHSCREEN
  1325. int offset;
  1326. if (button == ACTION_TOUCHSCREEN)
  1327. - button = skin_get_touchaction(&fms_skin_data[SCREEN_MAIN], &offset);
  1328. + button = skin_get_touchaction(skin_get_gwps(FM_SCREEN, SCREEN_MAIN)->data,
  1329. + &offset);
  1330. switch (button)
  1331. {
  1332. case ACTION_WPS_STOP:
  1333. @@ -143,5 +123,5 @@ int fms_do_button_loop(bool update_screen)
  1334.  
  1335. struct gui_wps *fms_get(enum screen_type screen)
  1336. {
  1337. - return &fms_skin[screen];
  1338. + return skin_get_gwps(FM_SCREEN, screen);
  1339. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×