summaryrefslogtreecommitdiff
path: root/apps/plugins/midi/midiplay.c
diff options
context:
space:
mode:
authorSebastian Leonhardt <sebastian.leonhardt@web.de>2016-09-23 17:45:44 +0200
committerSebastian Leonhardt <sebastian.leonhardt@web.de>2017-01-06 21:39:56 +0100
commit1728565e243300b5f50d56399931fa19169031d5 (patch)
tree7afe8619e2d4937dd53980e5ba37299f30db0d18 /apps/plugins/midi/midiplay.c
parent5279d60e0afb13b39efdcd21585baa251d0133a6 (diff)
downloadrockbox-1728565e243300b5f50d56399931fa19169031d5.tar.gz
rockbox-1728565e243300b5f50d56399931fa19169031d5.zip
Midiplay: only boost cpu in sensible code parts
Change-Id: I9aaf7f2844e9f90030dbf0a63ebec80db4851e18
Diffstat (limited to 'apps/plugins/midi/midiplay.c')
-rw-r--r--apps/plugins/midi/midiplay.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/apps/plugins/midi/midiplay.c b/apps/plugins/midi/midiplay.c
index 344efd317e..2fac06f9c5 100644
--- a/apps/plugins/midi/midiplay.c
+++ b/apps/plugins/midi/midiplay.c
@@ -333,6 +333,9 @@ static inline void synthbuf(void)
333 int32_t *outptr; 333 int32_t *outptr;
334 int i = BUF_SIZE; 334 int i = BUF_SIZE;
335 335
336#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
337 rb->cpu_boost(true);
338#endif
336#ifndef SYNC 339#ifndef SYNC
337 if (lastswap == swap) 340 if (lastswap == swap)
338 return; 341 return;
@@ -363,6 +366,9 @@ static inline void synthbuf(void)
363 366
364 /* how many samples did we write to the buffer? */ 367 /* how many samples did we write to the buffer? */
365 samples_in_buf = BUF_SIZE-i; 368 samples_in_buf = BUF_SIZE-i;
369#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
370 rb->cpu_boost(false);
371#endif
366} 372}
367 373
368static void get_more(const void** start, size_t* size) 374static void get_more(const void** start, size_t* size)
@@ -395,18 +401,29 @@ static int midimain(const void * filename)
395 int a, notes_used, vol; 401 int a, notes_used, vol;
396 bool is_playing = true; /* false = paused */ 402 bool is_playing = true; /* false = paused */
397 403
404#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
405 rb->cpu_boost(true);
406#endif
398 midi_debug("Loading file"); 407 midi_debug("Loading file");
399 mf = loadFile(filename); 408 mf = loadFile(filename);
400 409
401 if (mf == NULL) 410 if (mf == NULL)
402 { 411 {
403 midi_debug("Error loading file."); 412 midi_debug("Error loading file.");
413#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
414 rb->cpu_boost(false);
415#endif
404 return -1; 416 return -1;
405 } 417 }
406 418
407 if (initSynth(mf, ROCKBOX_DIR "/patchset/patchset.cfg", 419 if (initSynth(mf, ROCKBOX_DIR "/patchset/patchset.cfg",
408 ROCKBOX_DIR "/patchset/drums.cfg") == -1) 420 ROCKBOX_DIR "/patchset/drums.cfg") == -1)
421 {
422#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
423 rb->cpu_boost(false);
424#endif
409 return -1; 425 return -1;
426 }
410 427
411 rb->pcm_play_stop(); 428 rb->pcm_play_stop();
412#if INPUT_SRC_CAPS != 0 429#if INPUT_SRC_CAPS != 0
@@ -442,6 +459,10 @@ static int midimain(const void * filename)
442 tick(); 459 tick();
443 } while (notes_used == 0); 460 } while (notes_used == 0);
444 461
462#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
463 rb->cpu_boost(false);
464#endif
465
445 playing_time = 0; 466 playing_time = 0;
446 samples_this_second = 0; 467 samples_this_second = 0;
447 468
@@ -492,7 +513,13 @@ static int midimain(const void * filename)
492 /* Rewinding is tricky. Basically start the file over */ 513 /* Rewinding is tricky. Basically start the file over */
493 /* but run through the tracks without the synth running */ 514 /* but run through the tracks without the synth running */
494 rb->pcm_play_stop(); 515 rb->pcm_play_stop();
516#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
517 rb->cpu_boost(true);
518#endif
495 seekBackward(5); 519 seekBackward(5);
520#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
521 rb->cpu_boost(false);
522#endif
496 lastswap = !swap; 523 lastswap = !swap;
497 synthbuf(); 524 synthbuf();
498 midi_debug("Rewind to %d:%02d\n", playing_time/60, playing_time%60); 525 midi_debug("Rewind to %d:%02d\n", playing_time/60, playing_time%60);
@@ -550,10 +577,6 @@ enum plugin_status plugin_start(const void* parameter)
550 } 577 }
551 rb->lcd_setfont(FONT_SYSFIXED); 578 rb->lcd_setfont(FONT_SYSFIXED);
552 579
553#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
554 rb->cpu_boost(true);
555#endif
556
557 midi_debug("%s", parameter); 580 midi_debug("%s", parameter);
558 /* rb->splash(HZ, true, parameter); */ 581 /* rb->splash(HZ, true, parameter); */
559 582
@@ -570,9 +593,6 @@ enum plugin_status plugin_start(const void* parameter)
570 rb->pcm_play_stop(); 593 rb->pcm_play_stop();
571 rb->pcm_set_frequency(HW_SAMPR_DEFAULT); 594 rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
572 595
573#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
574 rb->cpu_boost(false);
575#endif
576 rb->splash(HZ, "FINISHED PLAYING"); 596 rb->splash(HZ, "FINISHED PLAYING");
577 597
578 if (retval == -1) 598 if (retval == -1)