[AR7] updated DSL driver and firmware (closes #2532)
[openwrt.git] / package / fonera-mp3 / src / lib / mp3_states.h
1 /*
2 * FOXMP3
3 * Copyright (c) 2006 acmesystems.it - john@acmesystems.it
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
18 *
19 * Feedback, Bugs... info@acmesystems.it
20 *
21 */
22
23 typedef struct _EVENT {
24 unsigned char *name;
25 } EVENT;
26
27 typedef struct _EVENT_PARAM {
28 int numeric;
29 unsigned char *text;
30 } EVENT_PARAM;
31
32 typedef void (*STATE_ENTER)(int state_last, int event, EVENT_PARAM *param);
33 typedef void (*STATE_LEAVE)(int state_new, int event);
34
35 typedef struct _STATE {
36 unsigned char *name;
37 STATE_ENTER enter;
38 STATE_LEAVE leave;
39 } STATE;
40
41 typedef struct _TRANSITION {
42 int old_state;
43 int event;
44 int new_state;
45 } TRANSITION;
46
47 // a = id, b = name, c = enter, d = leave
48 #define STATE_ADD(a, b, c, d) { \
49 if((a > 0) && (a < MAX_STATE_COUNT)){ \
50 states[a].name = strdup(b); \
51 states[a].enter = c; \
52 states[a].leave = d; \
53 } \
54 }
55
56 // a = old, b = event, c = new
57 #define TRANSITION_ADD(a, b, c) { \
58 if((transition_count >= 0) && \
59 (transition_count < MAX_TRANSITION_COUNT)){ \
60 transitions[transition_count].old_state = a; \
61 transitions[transition_count].event = b; \
62 transitions[transition_count].new_state = c; \
63 transition_count++; \
64 } \
65 }
66
67 // a = id, b = name
68 #define EVENT_ADD(a, b) { \
69 if((a > 0) && (a < MAX_EVENT_COUNT)){ \
70 events[a].name = strdup(b); \
71 } \
72 }
73 #define MAX_EVENT_COUNT 20
74 #define MAX_STATE_COUNT 20
75 #define MAX_TRANSITION_COUNT 60
76
77 #define MP3_STATE_NONE 0
78 #define MP3_STATE_STARTUP 1
79 #define MP3_STATE_IDLE 2
80 #define MP3_STATE_FILE_START 3
81 #define MP3_STATE_FILE_HANDLE 4
82 #define MP3_STATE_STREAM_START 5
83 #define MP3_STATE_STREAM_HANDLE 6
84 #define MP3_STATE_ERROR 7
85 #define MP3_STATE_SHUTDOWN 8
86 #define MP3_STATE_DEFAULT 9
87
88 #define MP3_EVENT_TIMEOUT 1
89 #define MP3_EVENT_FILE 2
90 #define MP3_EVENT_STREAM 3
91 #define MP3_EVENT_STOP 4
92 #define MP3_EVENT_ERROR 5
93 #define MP3_EVENT_SHUTDOWN 6
94 #define MP3_EVENT_END 7
95
96 #define MP3_EVENT_GENERIC_VOLUME 0
97 #define MP3_EVENT_GENERIC_STATE 1
98 #define MP3_EVENT_GENERIC_BASS 2
99 #define MP3_EVENT_GENERIC_PLAYTIME 3
100
101 void state_startup_enter(int state_last, int event, EVENT_PARAM *param);
102 void state_idle_enter(int state_last, int event, EVENT_PARAM *param);
103 void state_file_startup_enter(int state_last, int event, EVENT_PARAM *param);
104 void state_file_startup_leave(int state_new, int event);
105 void state_file_handle_enter(int state_last, int event, EVENT_PARAM *param);
106 void state_file_handle_leave(int state_new, int event);
107 void state_stream_startup_enter(int state_last, int event, EVENT_PARAM *param);
108 void state_stream_startup_leave(int state_last, int event);
109 void state_stream_handle_enter(int state_last, int event, EVENT_PARAM *param);
110 void state_stream_handle_leave(int state_new, int event);
111 void state_error_enter(int state_last, int event, EVENT_PARAM *param);
112 void state_shutdown_enter(int state_last, int event, EVENT_PARAM *param);
113 void state_generic_event(unsigned int event, unsigned char in_int,
114 unsigned char *out_uchar);
This page took 0.061297 seconds and 5 git commands to generate.