music_flac.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 19 Oct 2009 01:03:40 +0000
changeset 462 028b317d01d2
parent 386 695494546b3c
child 518 8bc9b5fd2aae
permissions -rw-r--r--
Added the AudioUnit framework for the native MIDI code.
     1 /*
     2     SDL_mixer:  An audio mixer library based on the SDL library
     3     Copyright (C) 1997-2009 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Library General Public
     7     License as published by the Free Software Foundation; either
     8     version 2 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Library General Public License for more details.
    14 
    15     You should have received a copy of the GNU Library General Public
    16     License along with this library; if not, write to the Free
    17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 
    22     Header to handle loading FLAC music files in SDL.
    23 	    									~ Austen Dicken (admin@cvpcs.org)
    24 */
    25 
    26 /* $Id:  $ */
    27 
    28 #ifdef FLAC_MUSIC
    29 
    30 #include <FLAC/stream_decoder.h>
    31 
    32 typedef struct {
    33 	FLAC__uint64 sample_size;
    34 	unsigned sample_rate;
    35 	unsigned channels;
    36 	unsigned bits_per_sample;
    37 	FLAC__uint64 total_samples;
    38 
    39 	// the following are used to handle the callback nature of the writer
    40 	int max_to_read;
    41 	char *data;				// pointer to beginning of data array
    42 	int data_len;			// size of data array
    43 	int data_read;			// amount of data array used
    44 	char *overflow;			// pointer to beginning of overflow array
    45 	int overflow_len;		// size of overflow array
    46 	int overflow_read;		// amount of overflow array used
    47 } FLAC_Data;
    48 
    49 typedef struct {
    50 	int playing;
    51 	int volume;
    52 	int section;
    53 	FLAC__StreamDecoder *flac_decoder;
    54 	FLAC_Data flac_data;
    55 	SDL_RWops *rwops;
    56 	SDL_AudioCVT cvt;
    57 	int len_available;
    58 	Uint8 *snd_available;
    59 } FLAC_music;
    60 
    61 /* Initialize the FLAC player, with the given mixer settings
    62    This function returns 0, or -1 if there was an error.
    63  */
    64 extern int FLAC_init(SDL_AudioSpec *mixer);
    65 
    66 /* Set the volume for a FLAC stream */
    67 extern void FLAC_setvolume(FLAC_music *music, int volume);
    68 
    69 /* Load a FLAC stream from the given file */
    70 extern FLAC_music *FLAC_new(const char *file);
    71 
    72 /* Load an FLAC stream from an SDL_RWops object */
    73 extern FLAC_music *FLAC_new_RW(SDL_RWops *rw);
    74 
    75 /* Start playback of a given FLAC stream */
    76 extern void FLAC_play(FLAC_music *music);
    77 
    78 /* Return non-zero if a stream is currently playing */
    79 extern int FLAC_playing(FLAC_music *music);
    80 
    81 /* Play some of a stream previously started with FLAC_play() */
    82 extern int FLAC_playAudio(FLAC_music *music, Uint8 *stream, int len);
    83 
    84 /* Stop playback of a stream previously started with FLAC_play() */
    85 extern void FLAC_stop(FLAC_music *music);
    86 
    87 /* Close the given FLAC stream */
    88 extern void FLAC_delete(FLAC_music *music);
    89 
    90 /* Jump (seek) to a given position (time is in seconds) */
    91 extern void FLAC_jump_to_time(FLAC_music *music, double time);
    92 
    93 #endif /* FLAC_MUSIC */