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!
slouken@63
     1
/*
slouken@518
     2
  SDL_mixer:  An audio mixer library based on the SDL library
slouken@518
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
slouken@63
     4
slouken@518
     5
  This software is provided 'as-is', without any express or implied
slouken@518
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@518
     7
  arising from the use of this software.
slouken@63
     8
slouken@518
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@518
    10
  including commercial applications, and to alter it and redistribute it
slouken@518
    11
  freely, subject to the following restrictions:
slouken@63
    12
slouken@518
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@518
    14
     claim that you wrote the original software. If you use this software
slouken@518
    15
     in a product, an acknowledgment in the product documentation would be
slouken@518
    16
     appreciated but is not required.
slouken@518
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@518
    18
     misrepresented as being the original software.
slouken@518
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@63
    20
*/
slouken@63
    21
slouken@140
    22
/* $Id$ */
slouken@138
    23
slouken@63
    24
#ifdef OGG_MUSIC
slouken@63
    25
slouken@63
    26
/* This file supports Ogg Vorbis music streams */
slouken@63
    27
slouken@353
    28
#ifdef OGG_USE_TREMOR
slouken@353
    29
#include <tremor/ivorbisfile.h>
slouken@353
    30
#else
slouken@63
    31
#include <vorbis/vorbisfile.h>
slouken@353
    32
#endif
slouken@63
    33
slouken@63
    34
typedef struct {
slouken@63
    35
	int playing;
slouken@63
    36
	int volume;
slouken@63
    37
	OggVorbis_File vf;
slouken@63
    38
	int section;
slouken@63
    39
	SDL_AudioCVT cvt;
slouken@63
    40
	int len_available;
slouken@63
    41
	Uint8 *snd_available;
slouken@63
    42
} OGG_music;
slouken@63
    43
slouken@63
    44
/* Initialize the Ogg Vorbis player, with the given mixer settings
slouken@63
    45
   This function returns 0, or -1 if there was an error.
slouken@63
    46
 */
slouken@63
    47
extern int OGG_init(SDL_AudioSpec *mixer);
slouken@63
    48
slouken@63
    49
/* Set the volume for an OGG stream */
slouken@63
    50
extern void OGG_setvolume(OGG_music *music, int volume);
slouken@63
    51
slouken@63
    52
/* Load an OGG stream from the given file */
slouken@63
    53
extern OGG_music *OGG_new(const char *file);
slouken@63
    54
slouken@246
    55
/* Load an OGG stream from an SDL_RWops object */
slouken@246
    56
extern OGG_music *OGG_new_RW(SDL_RWops *rw);
slouken@246
    57
slouken@63
    58
/* Start playback of a given OGG stream */
slouken@63
    59
extern void OGG_play(OGG_music *music);
slouken@63
    60
slouken@63
    61
/* Return non-zero if a stream is currently playing */
slouken@63
    62
extern int OGG_playing(OGG_music *music);
slouken@63
    63
slouken@63
    64
/* Play some of a stream previously started with OGG_play() */
icculus@281
    65
extern int OGG_playAudio(OGG_music *music, Uint8 *stream, int len);
slouken@63
    66
slouken@63
    67
/* Stop playback of a stream previously started with OGG_play() */
slouken@63
    68
extern void OGG_stop(OGG_music *music);
slouken@63
    69
slouken@63
    70
/* Close the given OGG stream */
slouken@63
    71
extern void OGG_delete(OGG_music *music);
slouken@63
    72
slouken@155
    73
/* Jump (seek) to a given position (time is in seconds) */
slouken@155
    74
extern void OGG_jump_to_time(OGG_music *music, double time);
slouken@155
    75
slouken@63
    76
#endif /* OGG_MUSIC */