diff options
author | John Crispin <blogic@openwrt.org> | 2007-08-27 20:10:35 +0000 |
---|---|---|
committer | John Crispin <blogic@openwrt.org> | 2007-08-27 20:10:35 +0000 |
commit | a2c409cda27b6aaae7dc34759ba2c8285ddd01d3 (patch) | |
tree | e77ccd710367d8139ccc8be6145e15c42600060e /package/fonera-mp3/src/lib/mp3_states.h | |
parent | 37266a51f1289f940d571c0871d17dfbe76f7aed (diff) | |
download | upstream-a2c409cda27b6aaae7dc34759ba2c8285ddd01d3.tar.gz upstream-a2c409cda27b6aaae7dc34759ba2c8285ddd01d3.tar.bz2 upstream-a2c409cda27b6aaae7dc34759ba2c8285ddd01d3.zip |
added libjson-c. added driver, webinterface and userspace daemon for the
fonera mp3-hack
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@8509 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/fonera-mp3/src/lib/mp3_states.h')
-rw-r--r-- | package/fonera-mp3/src/lib/mp3_states.h | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/package/fonera-mp3/src/lib/mp3_states.h b/package/fonera-mp3/src/lib/mp3_states.h new file mode 100644 index 0000000000..073c28bb13 --- /dev/null +++ b/package/fonera-mp3/src/lib/mp3_states.h @@ -0,0 +1,114 @@ +/* +* FOXMP3 +* Copyright (c) 2006 acmesystems.it - john@acmesystems.it +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA +* +* Feedback, Bugs... info@acmesystems.it +* +*/ + +typedef struct _EVENT { + unsigned char *name; +} EVENT; + +typedef struct _EVENT_PARAM { + int numeric; + unsigned char *text; +} EVENT_PARAM; + +typedef void (*STATE_ENTER)(int state_last, int event, EVENT_PARAM *param); +typedef void (*STATE_LEAVE)(int state_new, int event); + +typedef struct _STATE { + unsigned char *name; + STATE_ENTER enter; + STATE_LEAVE leave; +} STATE; + +typedef struct _TRANSITION { + int old_state; + int event; + int new_state; +} TRANSITION; + +// a = id, b = name, c = enter, d = leave +#define STATE_ADD(a, b, c, d) { \ + if((a > 0) && (a < MAX_STATE_COUNT)){ \ + states[a].name = strdup(b); \ + states[a].enter = c; \ + states[a].leave = d; \ + } \ + } + +// a = old, b = event, c = new +#define TRANSITION_ADD(a, b, c) { \ + if((transition_count >= 0) && \ + (transition_count < MAX_TRANSITION_COUNT)){ \ + transitions[transition_count].old_state = a; \ + transitions[transition_count].event = b; \ + transitions[transition_count].new_state = c; \ + transition_count++; \ + } \ + } + +// a = id, b = name +#define EVENT_ADD(a, b) { \ + if((a > 0) && (a < MAX_EVENT_COUNT)){ \ + events[a].name = strdup(b); \ + } \ + } +#define MAX_EVENT_COUNT 20 +#define MAX_STATE_COUNT 20 +#define MAX_TRANSITION_COUNT 60 + +#define MP3_STATE_NONE 0 +#define MP3_STATE_STARTUP 1 +#define MP3_STATE_IDLE 2 +#define MP3_STATE_FILE_START 3 +#define MP3_STATE_FILE_HANDLE 4 +#define MP3_STATE_STREAM_START 5 +#define MP3_STATE_STREAM_HANDLE 6 +#define MP3_STATE_ERROR 7 +#define MP3_STATE_SHUTDOWN 8 +#define MP3_STATE_DEFAULT 9 + +#define MP3_EVENT_TIMEOUT 1 +#define MP3_EVENT_FILE 2 +#define MP3_EVENT_STREAM 3 +#define MP3_EVENT_STOP 4 +#define MP3_EVENT_ERROR 5 +#define MP3_EVENT_SHUTDOWN 6 +#define MP3_EVENT_END 7 + +#define MP3_EVENT_GENERIC_VOLUME 0 +#define MP3_EVENT_GENERIC_STATE 1 +#define MP3_EVENT_GENERIC_BASS 2 +#define MP3_EVENT_GENERIC_PLAYTIME 3 + +void state_startup_enter(int state_last, int event, EVENT_PARAM *param); +void state_idle_enter(int state_last, int event, EVENT_PARAM *param); +void state_file_startup_enter(int state_last, int event, EVENT_PARAM *param); +void state_file_startup_leave(int state_new, int event); +void state_file_handle_enter(int state_last, int event, EVENT_PARAM *param); +void state_file_handle_leave(int state_new, int event); +void state_stream_startup_enter(int state_last, int event, EVENT_PARAM *param); +void state_stream_startup_leave(int state_last, int event); +void state_stream_handle_enter(int state_last, int event, EVENT_PARAM *param); +void state_stream_handle_leave(int state_new, int event); +void state_error_enter(int state_last, int event, EVENT_PARAM *param); +void state_shutdown_enter(int state_last, int event, EVENT_PARAM *param); +void state_generic_event(unsigned int event, unsigned char in_int, + unsigned char *out_uchar); |