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