music_ogg.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 31 Dec 2011 10:27:48 -0500
changeset 518 8bc9b5fd2aae
parent 386 695494546b3c
child 521 565549e046b0
permissions -rw-r--r--
Happy New Year!
     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 /* $Id$ */
    23 
    24 #ifdef OGG_MUSIC
    25 
    26 /* This file supports Ogg Vorbis music streams */
    27 
    28 #ifdef OGG_USE_TREMOR
    29 #include <tremor/ivorbisfile.h>
    30 #else
    31 #include <vorbis/vorbisfile.h>
    32 #endif
    33 
    34 typedef struct {
    35 	int playing;
    36 	int volume;
    37 	OggVorbis_File vf;
    38 	int section;
    39 	SDL_AudioCVT cvt;
    40 	int len_available;
    41 	Uint8 *snd_available;
    42 } OGG_music;
    43 
    44 /* Initialize the Ogg Vorbis player, with the given mixer settings
    45    This function returns 0, or -1 if there was an error.
    46  */
    47 extern int OGG_init(SDL_AudioSpec *mixer);
    48 
    49 /* Set the volume for an OGG stream */
    50 extern void OGG_setvolume(OGG_music *music, int volume);
    51 
    52 /* Load an OGG stream from the given file */
    53 extern OGG_music *OGG_new(const char *file);
    54 
    55 /* Load an OGG stream from an SDL_RWops object */
    56 extern OGG_music *OGG_new_RW(SDL_RWops *rw);
    57 
    58 /* Start playback of a given OGG stream */
    59 extern void OGG_play(OGG_music *music);
    60 
    61 /* Return non-zero if a stream is currently playing */
    62 extern int OGG_playing(OGG_music *music);
    63 
    64 /* Play some of a stream previously started with OGG_play() */
    65 extern int OGG_playAudio(OGG_music *music, Uint8 *stream, int len);
    66 
    67 /* Stop playback of a stream previously started with OGG_play() */
    68 extern void OGG_stop(OGG_music *music);
    69 
    70 /* Close the given OGG stream */
    71 extern void OGG_delete(OGG_music *music);
    72 
    73 /* Jump (seek) to a given position (time is in seconds) */
    74 extern void OGG_jump_to_time(OGG_music *music, double time);
    75 
    76 #endif /* OGG_MUSIC */