diff options
author | Stepan Moskovchenko <stevenm@rockbox.org> | 2006-05-08 02:43:29 +0000 |
---|---|---|
committer | Stepan Moskovchenko <stevenm@rockbox.org> | 2006-05-08 02:43:29 +0000 |
commit | b9b2bcd9b9706abe5898813ac26c33d02ba1a996 (patch) | |
tree | 372ffcd7b2db5ac39000c8fd2ebf597ebb7e26f4 | |
parent | 1d085333775768f3f6a45c67187b9cae514e1e32 (diff) | |
download | rockbox-b9b2bcd9b9706abe5898813ac26c33d02ba1a996.tar.gz rockbox-b9b2bcd9b9706abe5898813ac26c33d02ba1a996.zip |
Fixed freezing after loader error messages.
Added RMID (Windows MIDI) header support. Added .RMI extension to
viewers.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9888 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/plugins/midi/midifile.c | 45 | ||||
-rw-r--r-- | apps/plugins/midi/midiutil.c | 2 | ||||
-rw-r--r-- | apps/plugins/midiplay.c | 5 | ||||
-rw-r--r-- | apps/plugins/viewers.config | 1 |
4 files changed, 40 insertions, 13 deletions
diff --git a/apps/plugins/midi/midifile.c b/apps/plugins/midi/midifile.c index 11f81b1fd6..1a778a7299 100644 --- a/apps/plugins/midi/midifile.c +++ b/apps/plugins/midi/midifile.c | |||
@@ -22,7 +22,6 @@ extern struct plugin_api * rb; | |||
22 | 22 | ||
23 | struct Track * readTrack(int file); | 23 | struct Track * readTrack(int file); |
24 | int readID(int file); | 24 | int readID(int file); |
25 | void bail(const char *); | ||
26 | 25 | ||
27 | struct MIDIfile * loadFile(char * filename) | 26 | struct MIDIfile * loadFile(char * filename) |
28 | { | 27 | { |
@@ -31,7 +30,8 @@ struct MIDIfile * loadFile(char * filename) | |||
31 | 30 | ||
32 | if(file==-1) | 31 | if(file==-1) |
33 | { | 32 | { |
34 | bail("Could not open file\n"); | 33 | printf("Could not open file\n"); |
34 | return NULL; | ||
35 | } | 35 | } |
36 | 36 | ||
37 | mfload = (struct MIDIfile*)malloc(sizeof(struct MIDIfile)); | 37 | mfload = (struct MIDIfile*)malloc(sizeof(struct MIDIfile)); |
@@ -39,27 +39,48 @@ struct MIDIfile * loadFile(char * filename) | |||
39 | if(mfload==NULL) | 39 | if(mfload==NULL) |
40 | { | 40 | { |
41 | rb->close(file); | 41 | rb->close(file); |
42 | bail("Could not allocate memory for MIDIfile struct\n"); | 42 | printf("Could not allocate memory for MIDIfile struct\n"); |
43 | return NULL; | ||
43 | } | 44 | } |
44 | 45 | ||
45 | rb->memset(mfload, 0, sizeof(struct MIDIfile)); | 46 | rb->memset(mfload, 0, sizeof(struct MIDIfile)); |
46 | 47 | ||
47 | if(readID(file) != ID_MTHD) | 48 | int fileID = readID(file); |
49 | if(fileID != ID_MTHD) | ||
48 | { | 50 | { |
49 | rb->close(file); | 51 | if(fileID == ID_RIFF) |
50 | bail("Invalid file header chunk."); | 52 | { |
53 | printf("\nDetected RMID file"); | ||
54 | printf("\nLooking for MThd header"); | ||
55 | char dummy[17]; | ||
56 | rb->read(file, &dummy, 16); | ||
57 | if(readID(file) != ID_MTHD) | ||
58 | { | ||
59 | rb->close(file); | ||
60 | printf("Invalid MIDI header within RIFF."); | ||
61 | return NULL; | ||
62 | } | ||
63 | |||
64 | } else | ||
65 | { | ||
66 | rb->close(file); | ||
67 | printf("Invalid file header chunk."); | ||
68 | return NULL; | ||
69 | } | ||
51 | } | 70 | } |
52 | 71 | ||
53 | if(readFourBytes(file)!=6) | 72 | if(readFourBytes(file)!=6) |
54 | { | 73 | { |
55 | rb->close(file); | 74 | rb->close(file); |
56 | bail("Header chunk size invalid."); | 75 | printf("Header chunk size invalid."); |
76 | return NULL; | ||
57 | } | 77 | } |
58 | 78 | ||
59 | if(readTwoBytes(file)==2) | 79 | if(readTwoBytes(file)==2) |
60 | { | 80 | { |
61 | rb->close(file); | 81 | rb->close(file); |
62 | bail("MIDI file type not supported"); | 82 | printf("MIDI file type 2 not supported"); |
83 | return NULL; | ||
63 | } | 84 | } |
64 | 85 | ||
65 | mfload->numTracks = readTwoBytes(file); | 86 | mfload->numTracks = readTwoBytes(file); |
@@ -231,6 +252,8 @@ int readID(int file) | |||
231 | return ID_MTHD; | 252 | return ID_MTHD; |
232 | if(rb->strcmp(id, "MTrk")==0) | 253 | if(rb->strcmp(id, "MTrk")==0) |
233 | return ID_MTRK; | 254 | return ID_MTRK; |
255 | if(rb->strcmp(id, "RIFF")==0) | ||
256 | return ID_RIFF; | ||
234 | return ID_UNKNOWN; | 257 | return ID_UNKNOWN; |
235 | } | 258 | } |
236 | 259 | ||
@@ -294,9 +317,5 @@ void unloadFile(struct MIDIfile * mf) | |||
294 | free(mf); //Unload the main struct | 317 | free(mf); //Unload the main struct |
295 | } | 318 | } |
296 | */ | 319 | */ |
297 | void bail(const char * err) | 320 | |
298 | { | ||
299 | rb->splash(HZ*3, true, err); | ||
300 | exit(0); | ||
301 | } | ||
302 | 321 | ||
diff --git a/apps/plugins/midi/midiutil.c b/apps/plugins/midi/midiutil.c index 08e6dbac65..4562089578 100644 --- a/apps/plugins/midi/midiutil.c +++ b/apps/plugins/midi/midiutil.c | |||
@@ -24,6 +24,8 @@ | |||
24 | #define ID_MTHD 1 | 24 | #define ID_MTHD 1 |
25 | #define ID_MTRK 2 | 25 | #define ID_MTRK 2 |
26 | #define ID_EOF 3 | 26 | #define ID_EOF 3 |
27 | #define ID_RIFF 4 | ||
28 | |||
27 | 29 | ||
28 | //MIDI Commands | 30 | //MIDI Commands |
29 | #define MIDI_NOTE_OFF 128 | 31 | #define MIDI_NOTE_OFF 128 |
diff --git a/apps/plugins/midiplay.c b/apps/plugins/midiplay.c index 4814897906..51882212c7 100644 --- a/apps/plugins/midiplay.c +++ b/apps/plugins/midiplay.c | |||
@@ -208,6 +208,11 @@ int midimain(void * filename) | |||
208 | printf("\nLoading file"); | 208 | printf("\nLoading file"); |
209 | mf= loadFile(filename); | 209 | mf= loadFile(filename); |
210 | 210 | ||
211 | if(mf == NULL) | ||
212 | { | ||
213 | printf("\nError loading file."); | ||
214 | return -1; | ||
215 | } | ||
211 | 216 | ||
212 | if (initSynth(mf, "/.rockbox/patchset/patchset.cfg", "/.rockbox/patchset/drums.cfg") == -1) | 217 | if (initSynth(mf, "/.rockbox/patchset/patchset.cfg", "/.rockbox/patchset/drums.cfg") == -1) |
213 | return -1; | 218 | return -1; |
diff --git a/apps/plugins/viewers.config b/apps/plugins/viewers.config index afab02278b..a731d64c25 100644 --- a/apps/plugins/viewers.config +++ b/apps/plugins/viewers.config | |||
@@ -12,6 +12,7 @@ gb,viewers/rockboy, 0C 2A 59 7A 2E 0C | |||
12 | gbc,viewers/rockboy, 0C 2A 59 7A 2E 0C | 12 | gbc,viewers/rockboy, 0C 2A 59 7A 2E 0C |
13 | m3u,viewers/iriverify,00 00 00 00 00 00 | 13 | m3u,viewers/iriverify,00 00 00 00 00 00 |
14 | mid,viewers/midiplay, 20 70 70 3F 00 00 | 14 | mid,viewers/midiplay, 20 70 70 3F 00 00 |
15 | rmi,viewers/midiplay, 20 70 70 3F 00 00 | ||
15 | rsp,viewers/searchengine, 0e 11 11 31 7e 60 | 16 | rsp,viewers/searchengine, 0e 11 11 31 7e 60 |
16 | ss,rocks/sudoku, 55 55 55 55 55 55 | 17 | ss,rocks/sudoku, 55 55 55 55 55 55 |
17 | wav,viewers/wav2wv, 00 00 00 00 00 00 | 18 | wav,viewers/wav2wv, 00 00 00 00 00 00 |