music_mad.c
changeset 625 1d489d8ec2e0
parent 621 944412baab72
child 631 a0d34c8077a1
equal deleted inserted replaced
624:449c261f8480 625:1d489d8ec2e0
    24 #include <string.h>
    24 #include <string.h>
    25 
    25 
    26 #include "music_mad.h"
    26 #include "music_mad.h"
    27 
    27 
    28 mad_data *
    28 mad_data *
    29 mad_openFileRW(SDL_RWops *rw, SDL_AudioSpec *mixer, int freerw)
    29 mad_openFileRW(SDL_RWops *src, SDL_AudioSpec *mixer, int freesrc)
    30 {
    30 {
    31   mad_data *mp3_mad;
    31   mad_data *mp3_mad;
    32 
    32 
    33   mp3_mad = (mad_data *)SDL_malloc(sizeof(mad_data));
    33   mp3_mad = (mad_data *)SDL_malloc(sizeof(mad_data));
    34   if (mp3_mad) {
    34   if (mp3_mad) {
    35     mp3_mad->rw = rw;
    35     mp3_mad->src = src;
    36     mp3_mad->freerw = freerw;
    36     mp3_mad->freesrc = freesrc;
    37     mad_stream_init(&mp3_mad->stream);
    37     mad_stream_init(&mp3_mad->stream);
    38     mad_frame_init(&mp3_mad->frame);
    38     mad_frame_init(&mp3_mad->frame);
    39     mad_synth_init(&mp3_mad->synth);
    39     mad_synth_init(&mp3_mad->synth);
    40     mp3_mad->frames_read = 0;
    40     mp3_mad->frames_read = 0;
    41     mad_timer_reset(&mp3_mad->next_frame_start);
    41     mad_timer_reset(&mp3_mad->next_frame_start);
    53 {
    53 {
    54   mad_stream_finish(&mp3_mad->stream);
    54   mad_stream_finish(&mp3_mad->stream);
    55   mad_frame_finish(&mp3_mad->frame);
    55   mad_frame_finish(&mp3_mad->frame);
    56   mad_synth_finish(&mp3_mad->synth);
    56   mad_synth_finish(&mp3_mad->synth);
    57 
    57 
    58   if (mp3_mad->freerw) {
    58   if (mp3_mad->freesrc) {
    59     SDL_RWclose(mp3_mad->rw);
    59     SDL_RWclose(mp3_mad->src);
    60   }
    60   }
    61   SDL_free(mp3_mad);
    61   SDL_free(mp3_mad);
    62 }
    62 }
    63 
    63 
    64 /* Starts the playback. */
    64 /* Starts the playback. */