Actualizado jail_audio
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#ifndef __MIPSEL__
|
||||
#include "jail_audio.h"
|
||||
#include "stb_vorbis.c"
|
||||
|
||||
@@ -77,7 +78,7 @@ void JA_Init(const int freq, const SDL_AudioFormat format, const int channels) {
|
||||
|
||||
JA_Music JA_LoadMusic(const char* filename) {
|
||||
int chan, samplerate;
|
||||
JA_Music music = (JA_Music)SDL_malloc(sizeof(JA_Music_t));
|
||||
JA_Music music = new JA_Music_t();
|
||||
music->samples = stb_vorbis_decode_filename(filename, &chan, &samplerate, &music->output);
|
||||
|
||||
SDL_AudioCVT cvt;
|
||||
@@ -129,8 +130,8 @@ JA_Music_state JA_GetMusicState() {
|
||||
|
||||
void JA_DeleteMusic(JA_Music music) {
|
||||
if (current_music == music) current_music = NULL;
|
||||
free(music->output);
|
||||
free(music);
|
||||
SDL_free(music->output);
|
||||
delete music;
|
||||
}
|
||||
|
||||
JA_Sound JA_LoadSound(const char* filename) {
|
||||
@@ -144,7 +145,7 @@ JA_Sound JA_LoadSound(const char* filename) {
|
||||
cvt.buf = (Uint8 *) SDL_malloc(cvt.len * cvt.len_mult);
|
||||
SDL_memcpy(cvt.buf, sound->buffer, sound->length);
|
||||
SDL_ConvertAudio(&cvt);
|
||||
free(sound->buffer);
|
||||
SDL_FreeWAV(sound->buffer);
|
||||
sound->buffer = cvt.buf;
|
||||
sound->length = cvt.len_cvt;
|
||||
|
||||
@@ -167,7 +168,7 @@ void JA_DeleteSound(JA_Sound sound) {
|
||||
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
|
||||
if (channels[i].sound == sound) JA_StopChannel(i);
|
||||
}
|
||||
SDL_FreeWAV(sound->buffer);
|
||||
SDL_free(sound->buffer);
|
||||
delete sound;
|
||||
}
|
||||
|
||||
@@ -209,4 +210,4 @@ JA_Channel_state JA_GetChannelState(const int channel) {
|
||||
if (channel < 0 || channel >= JA_MAX_SIMULTANEOUS_CHANNELS) return JA_CHANNEL_INVALID;
|
||||
return channels[channel].state;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user