music_ogg.h
author Sam Lantinga <slouken@libsdl.org>
Sun, 15 Jul 2007 03:38:33 +0000
changeset 353 21fe62f9c4c6
parent 281 33730d0864d8
child 386 695494546b3c
permissions -rw-r--r--
Fixed bug #297

Philippe Simons - Sat Jul 14 20:33:17 PDT 2007
* Added support for Ogg Vorbis playback with Tremor (an integer decoder)
slouken@63
     1
/*
slouken@138
     2
    SDL_mixer:  An audio mixer library based on the SDL library
slouken@241
     3
    Copyright (C) 1997-2004 Sam Lantinga
slouken@63
     4
slouken@63
     5
    This library is free software; you can redistribute it and/or
slouken@63
     6
    modify it under the terms of the GNU Library General Public
slouken@63
     7
    License as published by the Free Software Foundation; either
slouken@63
     8
    version 2 of the License, or (at your option) any later version.
slouken@63
     9
slouken@63
    10
    This library is distributed in the hope that it will be useful,
slouken@63
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@63
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@63
    13
    Library General Public License for more details.
slouken@63
    14
slouken@63
    15
    You should have received a copy of the GNU Library General Public
slouken@63
    16
    License along with this library; if not, write to the Free
slouken@63
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
slouken@63
    18
slouken@63
    19
    Sam Lantinga
slouken@138
    20
    slouken@libsdl.org
slouken@63
    21
*/
slouken@63
    22
slouken@140
    23
/* $Id$ */
slouken@138
    24
slouken@63
    25
#ifdef OGG_MUSIC
slouken@63
    26
slouken@63
    27
/* This file supports Ogg Vorbis music streams */
slouken@63
    28
slouken@353
    29
#ifdef OGG_USE_TREMOR
slouken@353
    30
#include <tremor/ivorbisfile.h>
slouken@353
    31
#else
slouken@63
    32
#include <vorbis/vorbisfile.h>
slouken@353
    33
#endif
slouken@63
    34
slouken@63
    35
typedef struct {
slouken@63
    36
	int playing;
slouken@63
    37
	int volume;
slouken@63
    38
	OggVorbis_File vf;
slouken@63
    39
	int section;
slouken@63
    40
	SDL_AudioCVT cvt;
slouken@63
    41
	int len_available;
slouken@63
    42
	Uint8 *snd_available;
slouken@63
    43
} OGG_music;
slouken@63
    44
slouken@63
    45
/* Initialize the Ogg Vorbis player, with the given mixer settings
slouken@63
    46
   This function returns 0, or -1 if there was an error.
slouken@63
    47
 */
slouken@63
    48
extern int OGG_init(SDL_AudioSpec *mixer);
slouken@63
    49
slouken@63
    50
/* Set the volume for an OGG stream */
slouken@63
    51
extern void OGG_setvolume(OGG_music *music, int volume);
slouken@63
    52
slouken@63
    53
/* Load an OGG stream from the given file */
slouken@63
    54
extern OGG_music *OGG_new(const char *file);
slouken@63
    55
slouken@246
    56
/* Load an OGG stream from an SDL_RWops object */
slouken@246
    57
extern OGG_music *OGG_new_RW(SDL_RWops *rw);
slouken@246
    58
slouken@63
    59
/* Start playback of a given OGG stream */
slouken@63
    60
extern void OGG_play(OGG_music *music);
slouken@63
    61
slouken@63
    62
/* Return non-zero if a stream is currently playing */
slouken@63
    63
extern int OGG_playing(OGG_music *music);
slouken@63
    64
slouken@63
    65
/* Play some of a stream previously started with OGG_play() */
icculus@281
    66
extern int OGG_playAudio(OGG_music *music, Uint8 *stream, int len);
slouken@63
    67
slouken@63
    68
/* Stop playback of a stream previously started with OGG_play() */
slouken@63
    69
extern void OGG_stop(OGG_music *music);
slouken@63
    70
slouken@63
    71
/* Close the given OGG stream */
slouken@63
    72
extern void OGG_delete(OGG_music *music);
slouken@63
    73
slouken@155
    74
/* Jump (seek) to a given position (time is in seconds) */
slouken@155
    75
extern void OGG_jump_to_time(OGG_music *music, double time);
slouken@155
    76
slouken@63
    77
#endif /* OGG_MUSIC */