A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 88 lines 2.5 kB view raw
1/*************************************************************************** 2* __________ __ ___. 3* Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7* \/ \/ \/ \/ \/ 8* $Id$ 9* 10* Copyright (C) 2009 Björn Stenberg 11* 12* This program is free software; you can redistribute it and/or 13* modify it under the terms of the GNU General Public License 14* as published by the Free Software Foundation; either version 2 15* of the License, or (at your option) any later version. 16* 17* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 18* KIND, either express or implied. 19* 20****************************************************************************/ 21 22#include "plugin.h" 23 24 25 26enum plugin_status plugin_start(const void* parameter) 27{ 28 (void)parameter; 29 bool done = false; 30 bool boost = false; 31 int count = 0; 32 int last_count = 0; 33 int last_tick = *rb->current_tick; 34 int per_sec = 0; 35 36 rb->lcd_setfont(FONT_SYSFIXED); 37 38 while (!done) 39 { 40 int j,x; 41 for (j=1; j<100000; j++) 42 x = j*11; 43 (void)x; 44 rb->screens[0]->clear_display(); 45 rb->screens[0]->putsf(0, 0, "%s: %d",boost?"boost":"normal",count); 46 if (TIME_AFTER(*rb->current_tick, last_tick+HZ)) 47 { 48 last_tick = *rb->current_tick; 49 per_sec = count-last_count; 50 last_count = count; 51 } 52 rb->screens[0]->putsf(0, 1, "loops/s: %d", per_sec); 53 rb->screens[0]->update(); 54 count++; 55 56 switch (rb->get_action(CONTEXT_STD, TIMEOUT_NOBLOCK)) 57 { 58#ifdef HAVE_ADJUSTABLE_CPU_FREQ 59 case ACTION_STD_PREV: 60 if (!boost) 61 { 62 rb->cpu_boost(true); 63 boost = true; 64 } 65 break; 66 67 case ACTION_STD_NEXT: 68 if (boost) 69 { 70 rb->cpu_boost(false); 71 boost = false; 72 } 73 break; 74#endif 75 case ACTION_STD_CANCEL: 76#ifdef HAVE_ADJUSTABLE_CPU_FREQ 77 if (boost) 78 { 79 rb->cpu_boost(false); 80 } 81#endif 82 done = true; 83 break; 84 } 85 } 86 87 return PLUGIN_OK; 88}