music_ogg.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 02 Jan 2016 22:12:31 -0800
changeset 712 7e59d684b070
parent 711 f40c5ac95b12
child 725 bdf7b8d20566
permissions -rw-r--r--
Updated to version 2.0.1
     1 /*
     2   SDL_mixer:  An audio mixer library based on the SDL library
     3   Copyright (C) 1997-2016 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 #if defined(OGG_HEADER)
    29 #include OGG_HEADER
    30 #elif defined(OGG_USE_TREMOR)
    31 #include <tremor/ivorbisfile.h>
    32 #else
    33 #include <vorbis/vorbisfile.h>
    34 #endif
    35 
    36 typedef struct {
    37     SDL_RWops *src;
    38     int freesrc;
    39     int playing;
    40     int volume;
    41     OggVorbis_File vf;
    42     int section;
    43     SDL_AudioCVT cvt;
    44     int len_available;
    45     Uint8 *snd_available;
    46 } OGG_music;
    47 
    48 /* Initialize the Ogg Vorbis player, with the given mixer settings
    49    This function returns 0, or -1 if there was an error.
    50  */
    51 extern int OGG_init(SDL_AudioSpec *mixer);
    52 
    53 /* Set the volume for an OGG stream */
    54 extern void OGG_setvolume(OGG_music *music, int volume);
    55 
    56 /* Load an OGG stream from an SDL_RWops object */
    57 extern OGG_music *OGG_new_RW(SDL_RWops *src, int freesrc);
    58 
    59 /* Start playback of a given OGG stream */
    60 extern void OGG_play(OGG_music *music);
    61 
    62 /* Return non-zero if a stream is currently playing */
    63 extern int OGG_playing(OGG_music *music);
    64 
    65 /* Play some of a stream previously started with OGG_play() */
    66 extern int OGG_playAudio(OGG_music *music, Uint8 *stream, int len);
    67 
    68 /* Stop playback of a stream previously started with OGG_play() */
    69 extern void OGG_stop(OGG_music *music);
    70 
    71 /* Close the given OGG stream */
    72 extern void OGG_delete(OGG_music *music);
    73 
    74 /* Jump (seek) to a given position (time is in seconds) */
    75 extern void OGG_jump_to_time(OGG_music *music, double time);
    76 
    77 #endif /* OGG_MUSIC */