Skip to content

Commit

Permalink
some more cleanups after commit 9781cbae
Browse files Browse the repository at this point in the history
  • Loading branch information
sezero committed Nov 18, 2019
1 parent 440bca2 commit d5505b3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
6 changes: 3 additions & 3 deletions music_ogg.c
Expand Up @@ -226,7 +226,7 @@ static int OGG_UpdateSection(OGG_music *music)

/* Parse time string of the form HH:MM:SS.mmm and return equivalent sample
* position */
static ogg_int64_t parse_time(char *time, ogg_int64_t samplerate_hz)
static ogg_int64_t parse_time(char *time, long samplerate_hz)
{
char *num_start, *p;
ogg_int64_t result = 0;
Expand Down Expand Up @@ -263,10 +263,10 @@ static void *OGG_CreateFromRW(SDL_RWops *src, int freesrc)
OGG_music *music;
ov_callbacks callbacks;
vorbis_comment *vc;
int i;
long rate;
ogg_int64_t full_length;
SDL_bool is_loop_length = SDL_FALSE;
long rate;
int i;

music = (OGG_music *)SDL_calloc(1, sizeof *music);
if (!music) {
Expand Down
35 changes: 17 additions & 18 deletions music_wav.c
Expand Up @@ -36,15 +36,15 @@ typedef struct {

typedef struct {
SDL_RWops *src;
SDL_bool freesrc;
int freesrc;
SDL_AudioSpec spec;
int volume;
int play_count;
Sint64 start;
Sint64 stop;
Uint8 *buffer;
SDL_AudioStream *stream;
int numloops;
unsigned int numloops;
WAVLoopPoint *loops;
} WAV_Music;

Expand Down Expand Up @@ -163,7 +163,7 @@ static void *WAV_CreateFromRW(SDL_RWops *src, int freesrc)
return NULL;
}

music->freesrc = (SDL_bool)freesrc;
music->freesrc = freesrc;
return music;
}

Expand All @@ -177,7 +177,7 @@ static void WAV_SetVolume(void *context, int volume)
static int WAV_Play(void *context, int play_count)
{
WAV_Music *music = (WAV_Music *)context;
int i;
unsigned int i;
for (i = 0; i < music->numloops; ++i) {
WAVLoopPoint *loop = &music->loops[i];
loop->active = SDL_TRUE;
Expand All @@ -199,7 +199,7 @@ static int WAV_GetSome(void *context, void *data, int bytes, SDL_bool *done)
Sint64 loop_start;
Sint64 loop_stop;
SDL_bool looped = SDL_FALSE;
int i;
unsigned int i;
int filled, amount, result;

filled = SDL_AudioStreamGet(music->stream, data, bytes);
Expand All @@ -222,8 +222,7 @@ static int WAV_GetSome(void *context, void *data, int bytes, SDL_bool *done)
const int bytes_per_sample = (SDL_AUDIO_BITSIZE(music->spec.format) / 8) * music->spec.channels;
loop_start = music->start + loop->start * bytes_per_sample;
loop_stop = music->start + (loop->stop + 1) * bytes_per_sample;
if (pos >= loop_start && pos < loop_stop)
{
if (pos >= loop_start && pos < loop_stop) {
stop = loop_stop;
break;
}
Expand Down Expand Up @@ -252,7 +251,7 @@ static int WAV_GetSome(void *context, void *data, int bytes, SDL_bool *done)
if (loop->current_play_count > 0) {
--loop->current_play_count;
}
SDL_RWseek(music->src, (Sint64)loop_start, RW_SEEK_SET);
SDL_RWseek(music->src, loop_start, RW_SEEK_SET);
looped = SDL_TRUE;
}
}
Expand Down Expand Up @@ -372,7 +371,7 @@ static SDL_bool ParseDATA(WAV_Music *wave, Uint32 chunk_length)
static SDL_bool AddLoopPoint(WAV_Music *wave, Uint32 play_count, Uint32 start, Uint32 stop)
{
WAVLoopPoint *loop;
WAVLoopPoint *loops = SDL_realloc(wave->loops, (size_t)(wave->numloops + 1) * sizeof(*wave->loops));
WAVLoopPoint *loops = SDL_realloc(wave->loops, (wave->numloops + 1) * sizeof(*wave->loops));
if (!loops) {
Mix_SetError("Out of memory");
return SDL_FALSE;
Expand Down Expand Up @@ -594,15 +593,15 @@ static SDL_bool LoadAIFFMusic(WAV_Music *wave)
SDL_memset(spec, 0, (sizeof *spec));
spec->freq = frequency;
switch (samplesize) {
case 8:
spec->format = AUDIO_S8;
break;
case 16:
spec->format = AUDIO_S16MSB;
break;
default:
Mix_SetError("Unknown samplesize in data format");
return SDL_FALSE;
case 8:
spec->format = AUDIO_S8;
break;
case 16:
spec->format = AUDIO_S16MSB;
break;
default:
Mix_SetError("Unknown samplesize in data format");
return SDL_FALSE;
}
spec->channels = (Uint8) channels;
spec->samples = 4096; /* Good default buffer size */
Expand Down

0 comments on commit d5505b3

Please sign in to comment.