wavestream.h
author Sam Lantinga <slouken@libsdl.org>
Tue, 26 Feb 2008 11:46:22 +0000
changeset 381 2064088ea781
parent 241 503416fca921
child 386 695494546b3c
permissions -rw-r--r--
Date: Sat, 16 Feb 2008 20:59:24 +0100
From: Tilman Sauerbeck
Subject: [PATCH] Allow SDL_mixer to open wave streams via SDL_rwops

the current version of SDL_mixer can only load WAVE streams directly
from files. In my application I have the need to load them from an
SDL_RWops structure. The attached patch adds that feature to SDL_mixer.
slouken@0
     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@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@0
     6
    modify it under the terms of the GNU Library General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@0
     8
    version 2 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@0
    13
    Library General Public License for more details.
slouken@0
    14
slouken@0
    15
    You should have received a copy of the GNU Library General Public
slouken@0
    16
    License along with this library; if not, write to the Free
slouken@0
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@138
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@0
    22
slouken@140
    23
/* $Id$ */
slouken@138
    24
slouken@0
    25
/* This file supports streaming WAV files, without volume adjustment */
slouken@0
    26
slouken@0
    27
#include <stdio.h>
slouken@0
    28
slouken@0
    29
typedef struct {
slouken@381
    30
	SDL_RWops *rw;
slouken@381
    31
	SDL_bool freerw;
slouken@0
    32
	long  start;
slouken@0
    33
	long  stop;
slouken@0
    34
	SDL_AudioCVT cvt;
slouken@0
    35
} WAVStream;
slouken@0
    36
slouken@0
    37
/* Initialize the WAVStream player, with the given mixer settings
slouken@0
    38
   This function returns 0, or -1 if there was an error.
slouken@0
    39
 */
slouken@0
    40
extern int WAVStream_Init(SDL_AudioSpec *mixer);
slouken@0
    41
slouken@0
    42
/* Unimplemented */
slouken@0
    43
extern void WAVStream_SetVolume(int volume);
slouken@0
    44
slouken@0
    45
/* Load a WAV stream from the given file */
slouken@0
    46
extern WAVStream *WAVStream_LoadSong(const char *file, const char *magic);
slouken@0
    47
slouken@381
    48
/* Load a WAV stream from an SDL_RWops object */
slouken@381
    49
extern WAVStream *WAVStream_LoadSong_RW(SDL_RWops *rw, const char *magic);
slouken@381
    50
slouken@0
    51
/* Start playback of a given WAV stream */
slouken@0
    52
extern void WAVStream_Start(WAVStream *wave);
slouken@0
    53
slouken@0
    54
/* Play some of a stream previously started with WAVStream_Start() */
slouken@64
    55
extern void WAVStream_PlaySome(Uint8 *stream, int len);
slouken@0
    56
slouken@0
    57
/* Stop playback of a stream previously started with WAVStream_Start() */
slouken@0
    58
extern void WAVStream_Stop(void);
slouken@0
    59
slouken@0
    60
/* Close the given WAV stream */
slouken@0
    61
extern void WAVStream_FreeSong(WAVStream *wave);
slouken@0
    62
slouken@0
    63
/* Return non-zero if a stream is currently playing */
slouken@64
    64
extern int WAVStream_Active(void);