Mercurial > SDL_sound_CoreAudio
comparison decoders/raw.c @ 306:c97be6e1bd27
Added framework for Sound_Seek() support.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sun, 21 Apr 2002 18:39:47 +0000 |
parents | c9772a9f5271 |
children | cbb15ecf423a |
comparison
equal
deleted
inserted
replaced
305:c345a40a8a99 | 306:c97be6e1bd27 |
---|---|
58 static void RAW_quit(void); | 58 static void RAW_quit(void); |
59 static int RAW_open(Sound_Sample *sample, const char *ext); | 59 static int RAW_open(Sound_Sample *sample, const char *ext); |
60 static void RAW_close(Sound_Sample *sample); | 60 static void RAW_close(Sound_Sample *sample); |
61 static Uint32 RAW_read(Sound_Sample *sample); | 61 static Uint32 RAW_read(Sound_Sample *sample); |
62 static int RAW_rewind(Sound_Sample *sample); | 62 static int RAW_rewind(Sound_Sample *sample); |
63 static int RAW_seek(Sound_Sample *sample, Uint32 ms); | |
63 | 64 |
64 static const char *extensions_raw[] = { "RAW", NULL }; | 65 static const char *extensions_raw[] = { "RAW", NULL }; |
65 const Sound_DecoderFunctions __Sound_DecoderFunctions_RAW = | 66 const Sound_DecoderFunctions __Sound_DecoderFunctions_RAW = |
66 { | 67 { |
67 { | 68 { |
74 RAW_init, /* init() method */ | 75 RAW_init, /* init() method */ |
75 RAW_quit, /* quit() method */ | 76 RAW_quit, /* quit() method */ |
76 RAW_open, /* open() method */ | 77 RAW_open, /* open() method */ |
77 RAW_close, /* close() method */ | 78 RAW_close, /* close() method */ |
78 RAW_read, /* read() method */ | 79 RAW_read, /* read() method */ |
79 RAW_rewind /* rewind() method */ | 80 RAW_rewind, /* rewind() method */ |
81 RAW_seek /* seek() method */ | |
80 }; | 82 }; |
81 | 83 |
82 | 84 |
83 static int RAW_init(void) | 85 static int RAW_init(void) |
84 { | 86 { |
121 | 123 |
122 /* | 124 /* |
123 * We never convert raw samples; what you ask for is what you get. | 125 * We never convert raw samples; what you ask for is what you get. |
124 */ | 126 */ |
125 memcpy(&sample->actual, &sample->desired, sizeof (Sound_AudioInfo)); | 127 memcpy(&sample->actual, &sample->desired, sizeof (Sound_AudioInfo)); |
126 sample->flags = SOUND_SAMPLEFLAG_NONE; | 128 sample->flags = SOUND_SAMPLEFLAG_CANSEEK; |
127 | 129 |
128 return(1); /* we'll handle this data. */ | 130 return(1); /* we'll handle this data. */ |
129 } /* RAW_open */ | 131 } /* RAW_open */ |
130 | 132 |
131 | 133 |
168 BAIL_IF_MACRO(SDL_RWseek(internal->rw, 0, SEEK_SET) != 0, ERR_IO_ERROR, 0); | 170 BAIL_IF_MACRO(SDL_RWseek(internal->rw, 0, SEEK_SET) != 0, ERR_IO_ERROR, 0); |
169 return(1); | 171 return(1); |
170 } /* RAW_rewind */ | 172 } /* RAW_rewind */ |
171 | 173 |
172 | 174 |
175 static int RAW_seek(Sound_Sample *sample, Uint32 ms) | |
176 { | |
177 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; | |
178 int pos = (int) __Sound_convertMsToBytePos(&sample->actual, ms); | |
179 int err = (SDL_RWseek(internal->rw, pos, SEEK_SET) != pos); | |
180 BAIL_IF_MACRO(err, ERR_IO_ERROR, 0); | |
181 return(1); | |
182 } /* RAW_seek */ | |
183 | |
184 | |
173 #endif /* SOUND_SUPPORTS_RAW */ | 185 #endif /* SOUND_SUPPORTS_RAW */ |
174 | 186 |
175 | 187 |
176 /* end of raw.c ... */ | 188 /* end of raw.c ... */ |
177 | 189 |