music_mad.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 09 Jan 2012 07:34:10 -0500
changeset 558 7915d5cc775a
parent 542 3de4970b36d4
child 601 05123263dab3
child 930 1f6c6389391a
permissions -rw-r--r--
Fixed version of smpeg.dll that doesn't dynamically link to libstdc++-6.dll
     1 /*
     2   SDL_mixer:  An audio mixer library based on the SDL library
     3   Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     4 
     5   This software is provided 'as-is', without any express or implied
     6   warranty.  In no event will the authors be held liable for any damages
     7   arising from the use of this software.
     8 
     9   Permission is granted to anyone to use this software for any purpose,
    10   including commercial applications, and to alter it and redistribute it
    11   freely, subject to the following restrictions:
    12 
    13   1. The origin of this software must not be misrepresented; you must not
    14      claim that you wrote the original software. If you use this software
    15      in a product, an acknowledgment in the product documentation would be
    16      appreciated but is not required.
    17   2. Altered source versions must be plainly marked as such, and must not be
    18      misrepresented as being the original software.
    19   3. This notice may not be removed or altered from any source distribution.
    20 */
    21 
    22 #ifdef MP3_MAD_MUSIC
    23 
    24 #include "mad.h"
    25 #include "SDL_rwops.h"
    26 #include "SDL_audio.h"
    27 #include "SDL_mixer.h"
    28 
    29 #define MAD_INPUT_BUFFER_SIZE	(5*8192)
    30 #define MAD_OUTPUT_BUFFER_SIZE	8192
    31 
    32 enum {
    33   MS_input_eof    = 0x0001,
    34   MS_input_error  = 0x0001,
    35   MS_decode_eof   = 0x0002,
    36   MS_decode_error = 0x0004,
    37   MS_error_flags  = 0x000f,
    38 
    39   MS_playing      = 0x0100,
    40   MS_cvt_decoded  = 0x0200,
    41 };
    42 
    43 typedef struct {
    44   SDL_RWops *rw;
    45   int freerw;
    46   struct mad_stream stream;
    47   struct mad_frame frame;
    48   struct mad_synth synth;
    49   int frames_read;
    50   mad_timer_t next_frame_start;
    51   int volume;
    52   int status;
    53   int output_begin, output_end;
    54   SDL_AudioSpec mixer;
    55   SDL_AudioCVT cvt;
    56 
    57   unsigned char input_buffer[MAD_INPUT_BUFFER_SIZE + MAD_BUFFER_GUARD];
    58   unsigned char output_buffer[MAD_OUTPUT_BUFFER_SIZE];
    59 } mad_data;
    60 
    61 mad_data *mad_openFileRW(SDL_RWops *rw, SDL_AudioSpec *mixer, int freerw);
    62 void mad_closeFile(mad_data *mp3_mad);
    63 
    64 void mad_start(mad_data *mp3_mad);
    65 void mad_stop(mad_data *mp3_mad);
    66 int mad_isPlaying(mad_data *mp3_mad);
    67 
    68 int mad_getSamples(mad_data *mp3_mad, Uint8 *stream, int len);
    69 void mad_seek(mad_data *mp3_mad, double position);
    70 void mad_setVolume(mad_data *mp3_mad, int volume);
    71 
    72 #endif