summaryrefslogtreecommitdiff
path: root/apps/gui/wps.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/wps.c')
-rw-r--r--apps/gui/wps.c57
1 files changed, 32 insertions, 25 deletions
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index 53ece62e9c..2587542b00 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -70,6 +70,8 @@
70 /* 3% of 30min file == 54s step size */ 70 /* 3% of 30min file == 54s step size */
71#define MIN_FF_REWIND_STEP 500 71#define MIN_FF_REWIND_STEP 500
72 72
73static struct wps_state wps_state;
74
73/* initial setup of wps_data */ 75/* initial setup of wps_data */
74static void wps_state_init(void); 76static void wps_state_init(void);
75static void track_info_callback(unsigned short id, void *param); 77static void track_info_callback(unsigned short id, void *param);
@@ -157,6 +159,7 @@ static int skintouch_to_wps(struct wps_data *data)
157{ 159{
158 int offset = 0; 160 int offset = 0;
159 struct touchregion *region; 161 struct touchregion *region;
162 struct wps_state *gstate = get_wps_state();
160 int button = skin_get_touchaction(data, &offset, &region); 163 int button = skin_get_touchaction(data, &offset, &region);
161 switch (button) 164 switch (button)
162 { 165 {
@@ -179,9 +182,9 @@ static int skintouch_to_wps(struct wps_data *data)
179 return ACTION_WPS_HOTKEY; 182 return ACTION_WPS_HOTKEY;
180#endif 183#endif
181 case ACTION_TOUCH_SCROLLBAR: 184 case ACTION_TOUCH_SCROLLBAR:
182 skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->length*offset/1000; 185 gstate->id3->elapsed = gstate->id3->length*offset/1000;
183 audio_pre_ff_rewind(); 186 audio_pre_ff_rewind();
184 audio_ff_rewind(skin_get_global_state()->id3->elapsed); 187 audio_ff_rewind(gstate->id3->elapsed);
185 return ACTION_TOUCHSCREEN; 188 return ACTION_TOUCHSCREEN;
186 case ACTION_TOUCH_VOLUME: 189 case ACTION_TOUCH_VOLUME:
187 { 190 {
@@ -209,6 +212,7 @@ static bool ffwd_rew(int button)
209 bool usb = false; 212 bool usb = false;
210 bool ff_rewind = false; 213 bool ff_rewind = false;
211 const long ff_rw_accel = (global_settings.ff_rewind_accel + 3); 214 const long ff_rw_accel = (global_settings.ff_rewind_accel + 3);
215 struct wps_state *gstate = get_wps_state();
212 216
213 if (button == ACTION_NONE) 217 if (button == ACTION_NONE)
214 { 218 {
@@ -228,15 +232,15 @@ static bool ffwd_rew(int button)
228 if (direction == 1) 232 if (direction == 1)
229 { 233 {
230 /* fast forwarding, calc max step relative to end */ 234 /* fast forwarding, calc max step relative to end */
231 max_step = (skin_get_global_state()->id3->length - 235 max_step = (gstate->id3->length -
232 (skin_get_global_state()->id3->elapsed + 236 (gstate->id3->elapsed +
233 ff_rewind_count)) * 237 ff_rewind_count)) *
234 FF_REWIND_MAX_PERCENT / 100; 238 FF_REWIND_MAX_PERCENT / 100;
235 } 239 }
236 else 240 else
237 { 241 {
238 /* rewinding, calc max step relative to start */ 242 /* rewinding, calc max step relative to start */
239 max_step = (skin_get_global_state()->id3->elapsed + ff_rewind_count) * 243 max_step = (gstate->id3->elapsed + ff_rewind_count) *
240 FF_REWIND_MAX_PERCENT / 100; 244 FF_REWIND_MAX_PERCENT / 100;
241 } 245 }
242 246
@@ -253,7 +257,7 @@ static bool ffwd_rew(int button)
253 else 257 else
254 { 258 {
255 if ( (audio_status() & AUDIO_STATUS_PLAY) && 259 if ( (audio_status() & AUDIO_STATUS_PLAY) &&
256 skin_get_global_state()->id3 && skin_get_global_state()->id3->length ) 260 gstate->id3 && gstate->id3->length )
257 { 261 {
258 audio_pre_ff_rewind(); 262 audio_pre_ff_rewind();
259 if (direction > 0) 263 if (direction > 0)
@@ -270,19 +274,17 @@ static bool ffwd_rew(int button)
270 } 274 }
271 275
272 if (direction > 0) { 276 if (direction > 0) {
273 if ((skin_get_global_state()->id3->elapsed + ff_rewind_count) > 277 if ((gstate->id3->elapsed + ff_rewind_count) > gstate->id3->length)
274 skin_get_global_state()->id3->length) 278 ff_rewind_count = gstate->id3->length - gstate->id3->elapsed;
275 ff_rewind_count = skin_get_global_state()->id3->length -
276 skin_get_global_state()->id3->elapsed;
277 } 279 }
278 else { 280 else {
279 if ((int)(skin_get_global_state()->id3->elapsed + ff_rewind_count) < 0) 281 if ((int)(gstate->id3->elapsed + ff_rewind_count) < 0)
280 ff_rewind_count = -skin_get_global_state()->id3->elapsed; 282 ff_rewind_count = -gstate->id3->elapsed;
281 } 283 }
282 284
283 /* set the wps state ff_rewind_count so the progess info 285 /* set the wps state ff_rewind_count so the progess info
284 displays corectly */ 286 displays corectly */
285 skin_get_global_state()->ff_rewind_count = ff_rewind_count; 287 gstate->ff_rewind_count = ff_rewind_count;
286 288
287 FOR_NB_SCREENS(i) 289 FOR_NB_SCREENS(i)
288 { 290 {
@@ -294,9 +296,9 @@ static bool ffwd_rew(int button)
294 break; 296 break;
295 297
296 case ACTION_WPS_STOPSEEK: 298 case ACTION_WPS_STOPSEEK:
297 skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->elapsed+ff_rewind_count; 299 gstate->id3->elapsed = gstate->id3->elapsed+ff_rewind_count;
298 audio_ff_rewind(skin_get_global_state()->id3->elapsed); 300 audio_ff_rewind(gstate->id3->elapsed);
299 skin_get_global_state()->ff_rewind_count = 0; 301 gstate->ff_rewind_count = 0;
300 ff_rewind = false; 302 ff_rewind = false;
301 status_set_ffmode(0); 303 status_set_ffmode(0);
302 exit = true; 304 exit = true;
@@ -328,7 +330,7 @@ static bool ffwd_rew(int button)
328#if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD) 330#if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
329static void gwps_caption_backlight(struct wps_state *state) 331static void gwps_caption_backlight(struct wps_state *state)
330{ 332{
331 if (state && state->id3) 333 if (state->id3)
332 { 334 {
333#ifdef HAVE_BACKLIGHT 335#ifdef HAVE_BACKLIGHT
334 if (global_settings.caption_backlight) 336 if (global_settings.caption_backlight)
@@ -383,7 +385,7 @@ static void change_dir(int direction)
383 385
384static void prev_track(unsigned long skip_thresh) 386static void prev_track(unsigned long skip_thresh)
385{ 387{
386 struct wps_state *state = skin_get_global_state(); 388 struct wps_state *state = get_wps_state();
387 if (state->id3->elapsed < skip_thresh) 389 if (state->id3->elapsed < skip_thresh)
388 { 390 {
389 audio_prev(); 391 audio_prev();
@@ -404,7 +406,7 @@ static void prev_track(unsigned long skip_thresh)
404 406
405static void next_track(void) 407static void next_track(void)
406{ 408{
407 struct wps_state *state = skin_get_global_state(); 409 struct wps_state *state = get_wps_state();
408 /* take care of if we're playing a cuesheet */ 410 /* take care of if we're playing a cuesheet */
409 if (state->id3->cuesheet) 411 if (state->id3->cuesheet)
410 { 412 {
@@ -421,7 +423,7 @@ static void next_track(void)
421 423
422static void play_hop(int direction) 424static void play_hop(int direction)
423{ 425{
424 struct wps_state *state = skin_get_global_state(); 426 struct wps_state *state = get_wps_state();
425 struct cuesheet *cue = state->id3->cuesheet; 427 struct cuesheet *cue = state->id3->cuesheet;
426 long step = global_settings.skip_length*1000; 428 long step = global_settings.skip_length*1000;
427 long elapsed = state->id3->elapsed; 429 long elapsed = state->id3->elapsed;
@@ -571,7 +573,7 @@ static void gwps_enter_wps(void)
571 573
572void wps_do_playpause(bool updatewps) 574void wps_do_playpause(bool updatewps)
573{ 575{
574 struct wps_state *state = skin_get_global_state(); 576 struct wps_state *state = get_wps_state();
575 if ( state->paused ) 577 if ( state->paused )
576 { 578 {
577 state->paused = false; 579 state->paused = false;
@@ -608,7 +610,7 @@ long gui_wps_show(void)
608 bool update = false; 610 bool update = false;
609 bool vol_changed = false; 611 bool vol_changed = false;
610 long last_left = 0, last_right = 0; 612 long last_left = 0, last_right = 0;
611 struct wps_state *state = skin_get_global_state(); 613 struct wps_state *state = get_wps_state();
612 614
613#ifdef AB_REPEAT_ENABLE 615#ifdef AB_REPEAT_ENABLE
614 ab_repeat_init(); 616 ab_repeat_init();
@@ -1021,10 +1023,15 @@ long gui_wps_show(void)
1021 return GO_TO_ROOT; /* unreachable - just to reduce compiler warnings */ 1023 return GO_TO_ROOT; /* unreachable - just to reduce compiler warnings */
1022} 1024}
1023 1025
1026struct wps_state *get_wps_state(void)
1027{
1028 return &wps_state;
1029}
1030
1024/* this is called from the playback thread so NO DRAWING! */ 1031/* this is called from the playback thread so NO DRAWING! */
1025static void track_info_callback(unsigned short id, void *param) 1032static void track_info_callback(unsigned short id, void *param)
1026{ 1033{
1027 struct wps_state *state = skin_get_global_state(); 1034 struct wps_state *state = get_wps_state();
1028 1035
1029 if (id == PLAYBACK_EVENT_TRACK_CHANGE || id == PLAYBACK_EVENT_CUR_TRACK_READY) 1036 if (id == PLAYBACK_EVENT_TRACK_CHANGE || id == PLAYBACK_EVENT_CUR_TRACK_READY)
1030 { 1037 {
@@ -1040,13 +1047,13 @@ static void track_info_callback(unsigned short id, void *param)
1040 state->id3 = audio_current_track(); 1047 state->id3 = audio_current_track();
1041 } 1048 }
1042#endif 1049#endif
1043 skin_get_global_state()->nid3 = audio_next_track(); 1050 state->nid3 = audio_next_track();
1044 skin_request_full_update(WPS); 1051 skin_request_full_update(WPS);
1045} 1052}
1046 1053
1047static void wps_state_init(void) 1054static void wps_state_init(void)
1048{ 1055{
1049 struct wps_state *state = skin_get_global_state(); 1056 struct wps_state *state = get_wps_state();
1050 state->paused = false; 1057 state->paused = false;
1051 if(audio_status() & AUDIO_STATUS_PLAY) 1058 if(audio_status() & AUDIO_STATUS_PLAY)
1052 { 1059 {