Mercurial > SDL_sound_CoreAudio
annotate decoders/mikmod.c @ 207:857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Thu, 10 Jan 2002 01:16:24 +0000 |
parents | |
children | b35c04e4691e |
rev | line source |
---|---|
207
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
1 /* |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
2 * SDL_sound -- An abstract sound format decoding API. |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
3 * Copyright (C) 2001 Ryan C. Gordon. |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
4 * |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
5 * This library is free software; you can redistribute it and/or |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
6 * modify it under the terms of the GNU Lesser General Public |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
7 * License as published by the Free Software Foundation; either |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
8 * version 2.1 of the License, or (at your option) any later version. |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
9 * |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
10 * This library is distributed in the hope that it will be useful, |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
13 * Lesser General Public License for more details. |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
14 * |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU Lesser General Public |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
16 * License along with this library; if not, write to the Free Software |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
18 */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
19 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
20 /* |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
21 * Module player for SDL_sound. This driver handles anything MikMod does, and |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
22 * is based on SDL_mixer. |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
23 * |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
24 * Please see the file COPYING in the source's root directory. |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
25 * |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
26 * This file written by Torbjörn Andersson (d91tan@Update.UU.SE) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
27 */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
28 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
29 #if HAVE_CONFIG_H |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
30 # include <config.h> |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
31 #endif |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
32 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
33 #ifdef SOUND_SUPPORTS_MIKMOD |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
34 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
35 #include <stdio.h> |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
36 #include <stdlib.h> |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
37 #include <string.h> |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
38 #include <assert.h> |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
39 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
40 #include "SDL_sound.h" |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
41 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
42 #define __SDL_SOUND_INTERNAL__ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
43 #include "SDL_sound_internal.h" |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
44 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
45 #include "mikmod.h" |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
46 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
47 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
48 static int MIKMOD_init(void); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
49 static void MIKMOD_quit(void); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
50 static int MIKMOD_open(Sound_Sample *sample, const char *ext); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
51 static void MIKMOD_close(Sound_Sample *sample); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
52 static Uint32 MIKMOD_read(Sound_Sample *sample); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
53 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
54 static const char *extensions_mikmod[] = |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
55 { |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
56 "MOD", "IT", "XM", "S3M", "MTM", "669", "STM", "ULT", |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
57 "FAR", "MED", "AMF", "DSM", "IMF", "GDM", "STX", "OKT", |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
58 NULL |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
59 }; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
60 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
61 const Sound_DecoderFunctions __Sound_DecoderFunctions_MIKMOD = |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
62 { |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
63 { |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
64 extensions_mikmod, |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
65 "Play modules through MikMod", |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
66 "Torbjörn Andersson <d91tan@Update.UU.SE>", |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
67 "http://www.mikmod.org/" |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
68 }, |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
69 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
70 MIKMOD_init, /* init() method */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
71 MIKMOD_quit, /* quit() method */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
72 MIKMOD_open, /* open() method */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
73 MIKMOD_close, /* close() method */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
74 MIKMOD_read /* read() method */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
75 }; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
76 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
77 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
78 /* Make MikMod read from a RWops... */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
79 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
80 typedef struct MRWOPSREADER { |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
81 MREADER core; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
82 Sound_Sample *sample; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
83 int end; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
84 } MRWOPSREADER; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
85 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
86 static BOOL _mm_RWopsReader_eof(MREADER *reader) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
87 { |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
88 MRWOPSREADER *rwops_reader = (MRWOPSREADER *) reader; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
89 Sound_Sample *sample = rwops_reader->sample; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
90 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
91 int pos = SDL_RWtell(internal->rw); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
92 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
93 if (rwops_reader->end == pos) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
94 return(1); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
95 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
96 return(0); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
97 } /* _mm_RWopsReader_eof */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
98 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
99 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
100 static BOOL _mm_RWopsReader_read(MREADER *reader, void *ptr, size_t size) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
101 { |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
102 MRWOPSREADER *rwops_reader = (MRWOPSREADER *) reader; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
103 Sound_Sample *sample = rwops_reader->sample; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
104 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
105 return(SDL_RWread(internal->rw, ptr, size, 1)); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
106 } /* _mm_RWopsReader_Read */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
107 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
108 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
109 static int _mm_RWopsReader_get(MREADER *reader) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
110 { |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
111 char buf; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
112 MRWOPSREADER *rwops_reader = (MRWOPSREADER *) reader; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
113 Sound_Sample *sample = rwops_reader->sample; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
114 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
115 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
116 if (SDL_RWread(internal->rw, &buf, 1, 1) != 1) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
117 return(EOF); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
118 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
119 return((int) buf); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
120 } /* _mm_RWopsReader_get */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
121 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
122 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
123 static BOOL _mm_RWopsReader_seek(MREADER *reader, long offset, int whence) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
124 { |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
125 MRWOPSREADER *rwops_reader = (MRWOPSREADER *) reader; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
126 Sound_Sample *sample = rwops_reader->sample; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
127 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
128 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
129 return(SDL_RWseek(internal->rw, offset, whence)); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
130 } /* _mm_RWopsReader_seek */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
131 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
132 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
133 static long _mm_RWopsReader_tell(MREADER *reader) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
134 { |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
135 MRWOPSREADER *rwops_reader = (MRWOPSREADER *) reader; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
136 Sound_Sample *sample = rwops_reader->sample; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
137 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
138 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
139 return(SDL_RWtell(internal->rw)); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
140 } /* _mm_RWopsReader_tell */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
141 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
142 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
143 static MREADER *_mm_new_rwops_reader(Sound_Sample *sample) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
144 { |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
145 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
146 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
147 MRWOPSREADER *reader = (MRWOPSREADER *) malloc(sizeof (MRWOPSREADER)); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
148 if (reader != NULL) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
149 { |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
150 int here; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
151 reader->core.Eof = _mm_RWopsReader_eof; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
152 reader->core.Read = _mm_RWopsReader_read; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
153 reader->core.Get = _mm_RWopsReader_get; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
154 reader->core.Seek = _mm_RWopsReader_seek; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
155 reader->core.Tell = _mm_RWopsReader_tell; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
156 reader->sample = sample; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
157 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
158 /* RWops does not explicitly support an eof check, so we shall find |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
159 the end manually - this requires seek support for the RWop */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
160 here = SDL_RWtell(internal->rw); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
161 reader->end = SDL_RWseek(internal->rw, 0, SEEK_END); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
162 SDL_RWseek(internal->rw, here, SEEK_SET); /* Move back */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
163 /* !!! FIXME: What happens if the seek fails? */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
164 } /* if */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
165 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
166 return((MREADER *) reader); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
167 } /* _mm_new_rwops_reader */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
168 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
169 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
170 static void _mm_delete_rwops_reader(MREADER *reader) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
171 { |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
172 /* SDL_sound will delete the RWops and sample at a higher level... */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
173 if (reader != NULL) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
174 free(reader); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
175 } /* _mm_delete_rwops_reader */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
176 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
177 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
178 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
179 static int MIKMOD_init(void) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
180 { |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
181 MikMod_RegisterDriver(&drv_nos); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
182 MikMod_RegisterAllLoaders(); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
183 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
184 /* |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
185 * Both DMODE_SOFT_MUSIC and DMODE_16BITS should be set by default, |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
186 * so this is just for clarity. I haven't experimented with any of |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
187 * the other flags. There are a few which are said to give better |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
188 * sound quality. |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
189 */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
190 md_mode |= (DMODE_SOFT_MUSIC | DMODE_16BITS); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
191 md_mixfreq = 0; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
192 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
193 BAIL_IF_MACRO(MikMod_Init(""), MikMod_strerror(MikMod_errno), 0); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
194 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
195 return(1); /* success. */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
196 } /* MIKMOD_init */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
197 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
198 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
199 static void MIKMOD_quit(void) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
200 { |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
201 MikMod_Exit(); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
202 md_mixfreq = 0; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
203 } /* MIKMOD_quit */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
204 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
205 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
206 static int MIKMOD_open(Sound_Sample *sample, const char *ext) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
207 { |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
208 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
209 MREADER *reader; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
210 MODULE *module; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
211 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
212 reader = _mm_new_rwops_reader(sample); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
213 BAIL_IF_MACRO(reader == NULL, ERR_OUT_OF_MEMORY, 0); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
214 module = Player_LoadGeneric(reader, 64, 0); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
215 _mm_delete_rwops_reader(reader); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
216 BAIL_IF_MACRO(module == NULL, "MIKMOD: Not a module file.", 0); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
217 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
218 module->extspd = 1; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
219 module->panflag = 1; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
220 module->wrap = 0; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
221 module->loop = 0; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
222 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
223 if (md_mixfreq == 0) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
224 md_mixfreq = (!sample->desired.rate) ? 44100 : sample->desired.rate; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
225 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
226 sample->actual.channels = 2; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
227 sample->actual.rate = md_mixfreq; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
228 sample->actual.format = AUDIO_S16SYS; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
229 internal->decoder_private = (void *) module; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
230 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
231 Player_Start(module); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
232 Player_SetPosition(0); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
233 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
234 /* !!! FIXME: A little late to be giving this information... */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
235 sample->flags = SOUND_SAMPLEFLAG_NEEDSEEK; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
236 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
237 SNDDBG(("MIKMOD: Name: %s\n", module->songname)); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
238 SNDDBG(("MIKMOD: Type: %s\n", module->modtype)); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
239 SNDDBG(("MIKMOD: Accepting data stream\n")); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
240 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
241 return(1); /* we'll handle this data. */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
242 } /* MIKMOD_open */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
243 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
244 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
245 static void MIKMOD_close(Sound_Sample *sample) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
246 { |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
247 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
248 MODULE *module = (MODULE *) internal->decoder_private; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
249 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
250 Player_Free(module); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
251 } /* MIKMOD_close */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
252 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
253 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
254 static Uint32 MIKMOD_read(Sound_Sample *sample) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
255 { |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
256 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
257 MODULE *module = (MODULE *) internal->decoder_private; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
258 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
259 /* Switch to the current module, stopping any previous one. */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
260 Player_Start(module); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
261 if (!Player_Active()) |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
262 { |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
263 sample->flags |= SOUND_SAMPLEFLAG_EOF; |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
264 return(0); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
265 } /* if */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
266 return((Uint32) VC_WriteBytes(internal->buffer, internal->buffer_size)); |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
267 } /* MIKMOD_read */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
268 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
269 #endif /* SOUND_SUPPORTS_MIKMOD */ |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
270 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
271 |
857e53c5a2da
Renamed from mod.c (see modplug.c for the OTHER mod decoder).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
272 /* end of mikmod.c ... */ |