music_ogg.h
author Ozkan Sezer <sezeroz@gmail.com>
Sun, 28 Oct 2018 09:28:02 +0300
branchSDL-1.2
changeset 920 6d8ba24cbbd6
parent 542 3de4970b36d4
permissions -rw-r--r--
ogg music: #define OV_EXCLUDE_STATIC_CALLBACKS
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@63
    22
#ifdef OGG_MUSIC
slouken@63
    23
slouken@63
    24
/* This file supports Ogg Vorbis music streams */
slouken@63
    25
sezeroz@920
    26
#ifndef OV_EXCLUDE_STATIC_CALLBACKS
sezeroz@920
    27
#define OV_EXCLUDE_STATIC_CALLBACKS
sezeroz@920
    28
#endif
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@521
    36
	SDL_RWops *rw;
slouken@521
    37
	int freerw;
slouken@63
    38
	int playing;
slouken@63
    39
	int volume;
slouken@63
    40
	OggVorbis_File vf;
slouken@63
    41
	int section;
slouken@63
    42
	SDL_AudioCVT cvt;
slouken@63
    43
	int len_available;
slouken@63
    44
	Uint8 *snd_available;
slouken@63
    45
} OGG_music;
slouken@63
    46
slouken@63
    47
/* Initialize the Ogg Vorbis player, with the given mixer settings
slouken@63
    48
   This function returns 0, or -1 if there was an error.
slouken@63
    49
 */
slouken@63
    50
extern int OGG_init(SDL_AudioSpec *mixer);
slouken@63
    51
slouken@63
    52
/* Set the volume for an OGG stream */
slouken@63
    53
extern void OGG_setvolume(OGG_music *music, int volume);
slouken@63
    54
slouken@246
    55
/* Load an OGG stream from an SDL_RWops object */
slouken@521
    56
extern OGG_music *OGG_new_RW(SDL_RWops *rw, int freerw);
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 */