Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use RW_SEEK constants for RWseek()
  • Loading branch information
slouken committed Nov 8, 2009
1 parent da4949a commit c15d40c
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions load_aiff.c
Expand Up @@ -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)");
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions load_flac.c
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions load_ogg.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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 )
Expand Down
6 changes: 3 additions & 3 deletions load_voc.c
Expand Up @@ -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);
Expand All @@ -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! */
Expand Down Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion mixer.c
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion music.c
Expand Up @@ -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';

Expand Down
10 changes: 5 additions & 5 deletions music_flac.c
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion music_mad.c
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions music_mod.c
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions native_midi_gpl/native_midi_gpl.c
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions timidity/readmidi.c
Expand Up @@ -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 */
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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)
{
Expand Down
6 changes: 3 additions & 3 deletions wavestream.c
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)");
Expand Down

0 comments on commit c15d40c

Please sign in to comment.