Skip to content
Permalink
Browse files

Use RW_SEEK constants for RWseek()

  • Loading branch information
slouken committed Nov 8, 2009
1 parent da4949a commit c15d40c4afdabd2b045dcf78faf984b9216cff77
Showing with 31 additions and 31 deletions.
  1. +2 −2 load_aiff.c
  2. +6 −6 load_flac.c
  3. +2 −2 load_ogg.c
  4. +3 −3 load_voc.c
  5. +1 −1 mixer.c
  6. +1 −1 music.c
  7. +5 −5 music_flac.c
  8. +1 −1 music_mad.c
  9. +2 −2 music_mod.c
  10. +2 −2 native_midi_gpl/native_midi_gpl.c
  11. +3 −3 timidity/readmidi.c
  12. +3 −3 wavestream.c
@@ -177,7 +177,7 @@ SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc,
next_chunk++;
} while ( ( ( (AIFFmagic == AIFF) && ( !found_SSND || !found_COMM ) )
|| ( (AIFFmagic == _8SVX ) && ( !found_VHDR || !found_BODY ) ) )
&& SDL_RWseek(src, next_chunk, SEEK_SET) != 1 );
&& SDL_RWseek(src, next_chunk, RW_SEEK_SET) != 1 );

if ( (AIFFmagic == AIFF) && !found_SSND ) {
SDL_SetError("Bad AIFF (no SSND chunk)");
@@ -227,7 +227,7 @@ SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc,
SDL_SetError("Out of memory");
return(NULL);
}
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
if ( SDL_RWread(src, *audio_buf, *audio_len, 1) != 1 ) {
SDL_SetError("Unable to read audio data");
return(NULL);
@@ -81,7 +81,7 @@ static FLAC__StreamDecoderSeekStatus flac_seek_load_cb(
{
FLAC_SDL_Data *data = (FLAC_SDL_Data *)client_data;

if (SDL_RWseek (data->sdl_src, absolute_byte_offset, SEEK_SET) < 0) {
if (SDL_RWseek (data->sdl_src, absolute_byte_offset, RW_SEEK_SET) < 0) {
return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
}
else {
@@ -115,9 +115,9 @@ static FLAC__StreamDecoderLengthStatus flac_length_load_cb(
FLAC_SDL_Data *data = (FLAC_SDL_Data *)client_data;

int pos = SDL_RWtell (data->sdl_src);
int length = SDL_RWseek (data->sdl_src, 0, SEEK_END);
int length = SDL_RWseek (data->sdl_src, 0, RW_SEEK_END);

if (SDL_RWseek (data->sdl_src, pos, SEEK_SET) != pos || length < 0) {
if (SDL_RWseek (data->sdl_src, pos, RW_SEEK_SET) != pos || length < 0) {
/* there was an error attempting to return the stream to the original
* position, or the length was invalid. */
return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
@@ -134,7 +134,7 @@ static FLAC__bool flac_eof_load_cb(const FLAC__StreamDecoder *decoder,
FLAC_SDL_Data *data = (FLAC_SDL_Data *)client_data;

int pos = SDL_RWtell (data->sdl_src);
int end = SDL_RWseek (data->sdl_src, 0, SEEK_END);
int end = SDL_RWseek (data->sdl_src, 0, RW_SEEK_END);

// was the original position equal to the end (a.k.a. the seek didn't move)?
if (pos == end) {
@@ -143,7 +143,7 @@ static FLAC__bool flac_eof_load_cb(const FLAC__StreamDecoder *decoder,
}
else {
// not EOF, return to the original position
SDL_RWseek (data->sdl_src, pos, SEEK_SET);
SDL_RWseek (data->sdl_src, pos, RW_SEEK_SET);

return false;
}
@@ -328,7 +328,7 @@ SDL_AudioSpec *Mix_LoadFLAC_RW (SDL_RWops *src, int freesrc,
if (freesrc)
SDL_RWclose (src);
else
SDL_RWseek (src, 0, SEEK_SET);
SDL_RWseek (src, 0, RW_SEEK_SET);
}

if (was_error)
@@ -53,7 +53,7 @@ static int sdl_close_func_freesrc(void *datasource)

static int sdl_close_func_nofreesrc(void *datasource)
{
return SDL_RWseek((SDL_RWops*)datasource, 0, SEEK_SET);
return SDL_RWseek((SDL_RWops*)datasource, 0, RW_SEEK_SET);
}

static long sdl_tell_func(void *datasource)
@@ -147,7 +147,7 @@ SDL_AudioSpec *Mix_LoadOGG_RW (SDL_RWops *src, int freesrc,
if (freesrc)
SDL_RWclose(src);
else
SDL_RWseek(src, 0, SEEK_SET);
SDL_RWseek(src, 0, RW_SEEK_SET);
}

if ( was_error )
@@ -92,7 +92,7 @@ static int voc_check_header(SDL_RWops *src)
Uint8 signature[20]; /* "Creative Voice File\032" */
Uint16 datablockofs;

SDL_RWseek(src, 0, SEEK_SET);
SDL_RWseek(src, 0, RW_SEEK_SET);

if (SDL_RWread(src, signature, sizeof (signature), 1) != 1)
return(0);
@@ -108,7 +108,7 @@ static int voc_check_header(SDL_RWops *src)

datablockofs = SDL_SwapLE16(datablockofs);

if (SDL_RWseek(src, datablockofs, SEEK_SET) != datablockofs)
if (SDL_RWseek(src, datablockofs, RW_SEEK_SET) != datablockofs)
return(0);

return(1); /* success! */
@@ -448,7 +448,7 @@ SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc,
if (freesrc)
SDL_RWclose(src);
else
SDL_RWseek(src, 0, SEEK_SET);
SDL_RWseek(src, 0, RW_SEEK_SET);
}

if ( was_error )
@@ -555,7 +555,7 @@ Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc)
/* Find out what kind of audio file this is */
magic = SDL_ReadLE32(src);
/* Seek backwards for compatibility with older loaders */
SDL_RWseek(src, -(int)sizeof(Uint32), SEEK_CUR);
SDL_RWseek(src, -(int)sizeof(Uint32), RW_SEEK_CUR);

switch (magic) {
case WAVE:
@@ -1248,7 +1248,7 @@ Mix_Music *Mix_LoadMUS_RW(SDL_RWops *rw)
Mix_SetError("Couldn't read from RWops");
return NULL;
}
SDL_RWseek(rw, start, SEEK_SET);
SDL_RWseek(rw, start, RW_SEEK_SET);
magic[4]='\0';
moremagic[8] = '\0';

@@ -99,7 +99,7 @@ static FLAC__StreamDecoderSeekStatus flac_seek_music_cb(
{
FLAC_music *data = (FLAC_music*)client_data;

if (SDL_RWseek (data->rwops, absolute_byte_offset, SEEK_SET) < 0) {
if (SDL_RWseek (data->rwops, absolute_byte_offset, RW_SEEK_SET) < 0) {
return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
}
else {
@@ -133,9 +133,9 @@ static FLAC__StreamDecoderLengthStatus flac_length_music_cb (
FLAC_music *data = (FLAC_music*)client_data;

int pos = SDL_RWtell (data->rwops);
int length = SDL_RWseek (data->rwops, 0, SEEK_END);
int length = SDL_RWseek (data->rwops, 0, RW_SEEK_END);

if (SDL_RWseek (data->rwops, pos, SEEK_SET) != pos || length < 0) {
if (SDL_RWseek (data->rwops, pos, RW_SEEK_SET) != pos || length < 0) {
/* there was an error attempting to return the stream to the original
* position, or the length was invalid. */
return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
@@ -153,7 +153,7 @@ static FLAC__bool flac_eof_music_cb(
FLAC_music *data = (FLAC_music*)client_data;

int pos = SDL_RWtell (data->rwops);
int end = SDL_RWseek (data->rwops, 0, SEEK_END);
int end = SDL_RWseek (data->rwops, 0, RW_SEEK_END);

// was the original position equal to the end (a.k.a. the seek didn't move)?
if (pos == end) {
@@ -162,7 +162,7 @@ static FLAC__bool flac_eof_music_cb(
}
else {
// not EOF, return to the original position
SDL_RWseek (data->rwops, pos, SEEK_SET);
SDL_RWseek (data->rwops, pos, RW_SEEK_SET);

return false;
}
@@ -314,7 +314,7 @@ mad_seek(mad_data *mp3_mad, double position) {
mp3_mad->output_begin = 0;
mp3_mad->output_end = 0;

SDL_RWseek(mp3_mad->rw, 0, SEEK_SET);
SDL_RWseek(mp3_mad->rw, 0, RW_SEEK_SET);
}

/* Now we have to skip frames until we come to the right one.
@@ -206,9 +206,9 @@ MODULE *MikMod_LoadSongRW(SDL_RWops *rw, int maxchan)
0
};
lmmmr.offset = SDL_RWtell(rw);
SDL_RWseek(rw, 0, SEEK_END);
SDL_RWseek(rw, 0, RW_SEEK_END);
lmmmr.eof = SDL_RWtell(rw);
SDL_RWseek(rw, lmmmr.offset, SEEK_SET);
SDL_RWseek(rw, lmmmr.offset, RW_SEEK_SET);
lmmmr.rw = rw;
return mikmod.Player_LoadGeneric((MREADER*)&lmmmr, maxchan, 0);
}
@@ -222,9 +222,9 @@ NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *rw)
return NULL;
};

SDL_RWseek(rw, 0, SEEK_END);
SDL_RWseek(rw, 0, RW_SEEK_END);
song->file_size = SDL_RWtell(rw);
SDL_RWseek(rw, 0, SEEK_SET);
SDL_RWseek(rw, 0, RW_SEEK_SET);

song->filebuf = malloc(song->file_size);
if (!song->filebuf) {
@@ -349,7 +349,7 @@ static MidiEventList *read_midi_event(void)
"(MIDI port number %d)", midi_port_number);
midi_port_number &= 0x03;
}
else SDL_RWseek(rw, len, SEEK_CUR);
else SDL_RWseek(rw, len, RW_SEEK_CUR);
break;

case 0x2F: /* End of Track */
@@ -362,7 +362,7 @@ static MidiEventList *read_midi_event(void)
default:
ctl->cmsg(CMSG_INFO, VERB_DEBUG,
"(Meta event type 0x%02x, length %ld)", type, len);
SDL_RWseek(rw, len, SEEK_CUR);
SDL_RWseek(rw, len, RW_SEEK_CUR);
break;
}
}
@@ -1028,7 +1028,7 @@ MidiEvent *read_midi_file(SDL_RWops *mrw, int32 *count, int32 *sp)
ctl->cmsg(CMSG_WARNING, VERB_NORMAL,
"%s: MIDI file header size %ld bytes",
current_filename, len);
SDL_RWseek(rw, len-6, SEEK_CUR); /* skip the excess */
SDL_RWseek(rw, len-6, RW_SEEK_CUR); /* skip the excess */
}
if (format<0 || format >2)
{
@@ -169,7 +169,7 @@ WAVStream *WAVStream_LoadSong_RW(SDL_RWops *rw, const char *magic)
/* Start playback of a given WAV stream */
void WAVStream_Start(WAVStream *wave)
{
SDL_RWseek (wave->rw, wave->start, SEEK_SET);
SDL_RWseek (wave->rw, wave->start, RW_SEEK_SET);
music = wave;
}

@@ -281,7 +281,7 @@ static int ReadChunk(SDL_RWops *src, Chunk *chunk, int read_data)
return(-1);
}
} else {
SDL_RWseek(src, chunk->length, SEEK_CUR);
SDL_RWseek(src, chunk->length, RW_SEEK_CUR);
}
return(chunk->length);
}
@@ -487,7 +487,7 @@ static SDL_RWops *LoadAIFFStream (SDL_RWops *src, SDL_AudioSpec *spec,
break;
}
} while ((!found_SSND || !found_COMM)
&& SDL_RWseek(src, next_chunk, SEEK_SET) != -1);
&& SDL_RWseek(src, next_chunk, RW_SEEK_SET) != -1);

if (!found_SSND) {
Mix_SetError("Bad AIFF file (no SSND chunk)");

0 comments on commit c15d40c

Please sign in to comment.