diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2006-03-26 22:33:25 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2006-03-26 22:33:25 +0000 |
commit | 6f4d721d23946632d2a428884ee990e61f43434e (patch) | |
tree | c718808a35ab00d7e8b189d4e52690621dfbcbcb | |
parent | b76e4ec5f27086b8c3b08ef4b2c90d94d93ca83b (diff) | |
download | rockbox-6f4d721d23946632d2a428884ee990e61f43434e.tar.gz rockbox-6f4d721d23946632d2a428884ee990e61f43434e.zip |
Basic plugin playback control menu by Jonathan Gordon (Patch #4874)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9269 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/plugin.c | 3 | ||||
-rw-r--r-- | apps/plugin.h | 2 | ||||
-rw-r--r-- | apps/plugins/lib/SOURCES | 1 | ||||
-rw-r--r-- | apps/plugins/lib/playback_control.c | 114 | ||||
-rw-r--r-- | apps/plugins/lib/playback_control.h | 24 | ||||
-rw-r--r-- | apps/sound_menu.h | 1 |
6 files changed, 144 insertions, 1 deletions
diff --git a/apps/plugin.c b/apps/plugin.c index 51e071020a..f78644f73b 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #include "backlight.h" | 43 | #include "backlight.h" |
44 | #include "ata.h" | 44 | #include "ata.h" |
45 | #include "talk.h" | 45 | #include "talk.h" |
46 | #include "sound_menu.h" | ||
46 | #include "mp3data.h" | 47 | #include "mp3data.h" |
47 | #include "powermgmt.h" | 48 | #include "powermgmt.h" |
48 | #include "system.h" | 49 | #include "system.h" |
@@ -401,7 +402,7 @@ static const struct plugin_api rockbox_api = { | |||
401 | 402 | ||
402 | /* new stuff at the end, sort into place next time | 403 | /* new stuff at the end, sort into place next time |
403 | the API gets incompatible */ | 404 | the API gets incompatible */ |
404 | 405 | set_sound, | |
405 | }; | 406 | }; |
406 | 407 | ||
407 | int plugin_load(const char* plugin, void* parameter) | 408 | int plugin_load(const char* plugin, void* parameter) |
diff --git a/apps/plugin.h b/apps/plugin.h index 99dd3dc6ea..f046dee50e 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -470,6 +470,8 @@ struct plugin_api { | |||
470 | 470 | ||
471 | /* new stuff at the end, sort into place next time | 471 | /* new stuff at the end, sort into place next time |
472 | the API gets incompatible */ | 472 | the API gets incompatible */ |
473 | bool (*set_sound)(const unsigned char * string, | ||
474 | int* variable, int setting); | ||
473 | 475 | ||
474 | }; | 476 | }; |
475 | 477 | ||
diff --git a/apps/plugins/lib/SOURCES b/apps/plugins/lib/SOURCES index f0930269f7..81cdc8c944 100644 --- a/apps/plugins/lib/SOURCES +++ b/apps/plugins/lib/SOURCES | |||
@@ -1,4 +1,5 @@ | |||
1 | configfile.c | 1 | configfile.c |
2 | playback_control.c | ||
2 | #if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) && (CONFIG_LCD != LCD_IPOD2BPP) | 3 | #if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) && (CONFIG_LCD != LCD_IPOD2BPP) |
3 | gray_core.c | 4 | gray_core.c |
4 | gray_draw.c | 5 | gray_draw.c |
diff --git a/apps/plugins/lib/playback_control.c b/apps/plugins/lib/playback_control.c new file mode 100644 index 0000000000..e034ecf120 --- /dev/null +++ b/apps/plugins/lib/playback_control.c | |||
@@ -0,0 +1,114 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 Jonathan Gordon | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "plugin.h" | ||
21 | |||
22 | struct plugin_api* api = 0; | ||
23 | |||
24 | bool prevtrack(void) | ||
25 | { | ||
26 | api->audio_prev(); | ||
27 | return false; | ||
28 | } | ||
29 | |||
30 | bool play(void) | ||
31 | { | ||
32 | if (api->audio_status() & AUDIO_STATUS_PAUSE) | ||
33 | api->audio_resume(); | ||
34 | else | ||
35 | api->audio_pause(); | ||
36 | return false; | ||
37 | } | ||
38 | |||
39 | bool stop(void) | ||
40 | { | ||
41 | api->audio_stop(); | ||
42 | return false; | ||
43 | } | ||
44 | |||
45 | bool nexttrack(void) | ||
46 | { | ||
47 | api->audio_next(); | ||
48 | return false; | ||
49 | } | ||
50 | |||
51 | static bool volume(void) | ||
52 | { | ||
53 | return api->set_sound("Volume", &api->global_settings->volume, | ||
54 | SOUND_VOLUME); | ||
55 | } | ||
56 | |||
57 | static bool shuffle(void) | ||
58 | { | ||
59 | struct opt_items names[] = { | ||
60 | {"No", NULL}, | ||
61 | {"Yes", NULL} | ||
62 | }; | ||
63 | return api->set_option("Shuffle", &api->global_settings->playlist_shuffle, | ||
64 | BOOL, names, 2,NULL); | ||
65 | } | ||
66 | |||
67 | static bool repeat_mode(void) | ||
68 | { | ||
69 | bool result; | ||
70 | static const struct opt_items names[] = { | ||
71 | { "Off", NULL }, | ||
72 | { "Repeat All", NULL }, | ||
73 | { "Repeat One", NULL }, | ||
74 | { "Repeat Shuffle", NULL }, | ||
75 | #ifdef AB_REPEAT_ENABLE | ||
76 | { "Repeat A-B", NULL } | ||
77 | #endif | ||
78 | }; | ||
79 | |||
80 | int old_repeat = api->global_settings->repeat_mode; | ||
81 | |||
82 | result = api->set_option( "Repeat Mode", | ||
83 | &api->global_settings->repeat_mode, | ||
84 | INT, names, NUM_REPEAT_MODES, NULL ); | ||
85 | |||
86 | if (old_repeat != api->global_settings->repeat_mode && | ||
87 | (api->audio_status() & AUDIO_STATUS_PLAY)) | ||
88 | api->audio_flush_and_reload_tracks(); | ||
89 | |||
90 | return result; | ||
91 | } | ||
92 | |||
93 | bool playback_control(struct plugin_api* newapi) | ||
94 | { | ||
95 | int m; | ||
96 | api = newapi; | ||
97 | bool result; | ||
98 | |||
99 | static struct menu_item items[] = { | ||
100 | { "Previous Track", prevtrack }, | ||
101 | { "Pause / Play", play }, | ||
102 | { "Stop Playback", stop }, | ||
103 | { "Next Track", nexttrack }, | ||
104 | { "Change Volume", volume }, | ||
105 | { "Enable/Disable Shuffle", shuffle }, | ||
106 | { "change Repeat Mode", repeat_mode }, | ||
107 | }; | ||
108 | |||
109 | m=api->menu_init( items, sizeof(items) / sizeof(*items), NULL, | ||
110 | NULL, NULL, NULL); | ||
111 | result = api->menu_run(m); | ||
112 | api->menu_exit(m); | ||
113 | return result; | ||
114 | } | ||
diff --git a/apps/plugins/lib/playback_control.h b/apps/plugins/lib/playback_control.h new file mode 100644 index 0000000000..a259fc9194 --- /dev/null +++ b/apps/plugins/lib/playback_control.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 Jonathan Gordon | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #ifndef __PLAYBACK_CONTROL_H__ | ||
20 | #define __PLAYBACK_CONTROL_H__ | ||
21 | |||
22 | bool playback_control(struct plugin_api* api); | ||
23 | |||
24 | #endif /* __PLAYBACK_CONTROL_H__ */ | ||
diff --git a/apps/sound_menu.h b/apps/sound_menu.h index 4d295b0a70..4e85b9c03c 100644 --- a/apps/sound_menu.h +++ b/apps/sound_menu.h | |||
@@ -24,5 +24,6 @@ | |||
24 | bool sound_menu(void); | 24 | bool sound_menu(void); |
25 | bool recording_menu(bool no_source); | 25 | bool recording_menu(bool no_source); |
26 | bool rectrigger(void); | 26 | bool rectrigger(void); |
27 | bool set_sound(const unsigned char * string, int* variable, int setting); | ||
27 | 28 | ||
28 | #endif | 29 | #endif |