2009-07-27 05:47:50 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2009 Jonathon Fowler <jf@jonof.id.au>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* OggVorbis source support for MultiVoc
|
|
|
|
*/
|
|
|
|
|
2009-10-03 14:34:05 +00:00
|
|
|
#ifdef HAVE_VORBIS
|
|
|
|
|
2011-01-16 07:20:11 +00:00
|
|
|
#define OV_EXCLUDE_STATIC_CALLBACKS
|
|
|
|
|
2009-07-27 05:47:50 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
# include <vorbis/vorbisfile.h>
|
|
|
|
#else
|
|
|
|
# include "vorbis/vorbisfile.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2009-10-03 14:34:05 +00:00
|
|
|
#ifndef _MSC_VER
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2009-07-27 05:47:50 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include "pitch.h"
|
|
|
|
#include "multivoc.h"
|
|
|
|
#include "_multivc.h"
|
|
|
|
|
2011-01-16 07:20:11 +00:00
|
|
|
#ifndef min
|
|
|
|
#define min(x,y) ((x) < (y) ? (x) : (y))
|
|
|
|
#endif
|
|
|
|
#ifndef max
|
|
|
|
#define max(x,y) ((x) > (y) ? (x) : (y))
|
|
|
|
#endif
|
2009-10-03 14:34:05 +00:00
|
|
|
|
|
|
|
#define BLOCKSIZE 0x8000
|
2009-07-27 05:47:50 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
void * ptr;
|
|
|
|
size_t length;
|
|
|
|
size_t pos;
|
|
|
|
|
|
|
|
OggVorbis_File vf;
|
|
|
|
|
2009-10-03 14:34:05 +00:00
|
|
|
char block[BLOCKSIZE];
|
2009-07-27 05:47:50 +00:00
|
|
|
int32_t lastbitstream;
|
|
|
|
} vorbis_data;
|
|
|
|
|
2009-10-03 14:34:05 +00:00
|
|
|
|
2009-07-29 20:26:03 +00:00
|
|
|
static size_t read_vorbis(void * ptr, size_t size, size_t nmemb, void * datasource)
|
2009-07-27 05:47:50 +00:00
|
|
|
{
|
|
|
|
vorbis_data * vorb = (vorbis_data *) datasource;
|
|
|
|
size_t nread = 0;
|
|
|
|
size_t bytes;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
|
|
|
|
if (vorb->length == vorb->pos) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; nmemb > 0; nmemb--, nread++) {
|
|
|
|
bytes = vorb->length - vorb->pos;
|
|
|
|
if (size < bytes) {
|
|
|
|
bytes = size;
|
|
|
|
}
|
|
|
|
|
2011-01-16 07:20:11 +00:00
|
|
|
memcpy(ptr, (uint8_t *)vorb->ptr + vorb->pos, bytes);
|
|
|
|
vorb->pos += bytes;
|
|
|
|
ptr = (uint8_t *)ptr + bytes;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
|
|
|
if (vorb->length == vorb->pos) {
|
|
|
|
nread++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nread;
|
|
|
|
}
|
|
|
|
|
2009-10-03 14:34:05 +00:00
|
|
|
|
2009-07-27 05:47:50 +00:00
|
|
|
static int32_t seek_vorbis(void * datasource, ogg_int64_t offset, int32_t whence)
|
|
|
|
{
|
|
|
|
vorbis_data * vorb = (vorbis_data *) datasource;
|
|
|
|
|
|
|
|
switch (whence) {
|
|
|
|
case SEEK_SET: vorb->pos = 0; break;
|
|
|
|
case SEEK_CUR: break;
|
|
|
|
case SEEK_END: vorb->pos = vorb->length; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
vorb->pos += offset;
|
2009-10-03 14:34:05 +00:00
|
|
|
|
|
|
|
if (vorb->pos > vorb->length) {
|
2009-07-27 05:47:50 +00:00
|
|
|
vorb->pos = vorb->length;
|
|
|
|
}
|
|
|
|
|
|
|
|
return vorb->pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int32_t close_vorbis(void * datasource)
|
|
|
|
{
|
2010-06-22 21:50:01 +00:00
|
|
|
UNREFERENCED_PARAMETER(datasource);
|
2009-07-27 05:47:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-27 10:46:42 +00:00
|
|
|
static long tell_vorbis(void * datasource)
|
2009-07-27 05:47:50 +00:00
|
|
|
{
|
|
|
|
vorbis_data * vorb = (vorbis_data *) datasource;
|
|
|
|
|
|
|
|
return vorb->pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ov_callbacks vorbis_callbacks = {
|
|
|
|
read_vorbis,
|
|
|
|
seek_vorbis,
|
|
|
|
close_vorbis,
|
|
|
|
tell_vorbis
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------
|
|
|
|
Function: MV_GetNextVorbisBlock
|
|
|
|
|
|
|
|
Controls playback of OggVorbis data
|
|
|
|
---------------------------------------------------------------------*/
|
|
|
|
|
2009-10-03 14:34:05 +00:00
|
|
|
static playbackstatus MV_GetNextVorbisBlock
|
2009-07-27 05:47:50 +00:00
|
|
|
(
|
|
|
|
VoiceNode *voice
|
|
|
|
)
|
|
|
|
|
|
|
|
{
|
|
|
|
vorbis_data * vd = (vorbis_data *) voice->extra;
|
|
|
|
int32_t bytes, bytesread;
|
|
|
|
int32_t bitstream, err;
|
|
|
|
|
|
|
|
voice->Playing = TRUE;
|
|
|
|
|
|
|
|
bytesread = 0;
|
|
|
|
do {
|
2009-10-03 14:34:05 +00:00
|
|
|
bytes = ov_read(&vd->vf, vd->block + bytesread, BLOCKSIZE - bytesread, 0, 2, 1, &bitstream);
|
|
|
|
//fprintf(stderr, "ov_read = %d\n", bytes);
|
2012-11-24 09:12:15 +00:00
|
|
|
if (bytes > 0) {
|
|
|
|
bytesread += bytes;
|
|
|
|
if ((ogg_int64_t)(intptr_t)voice->LoopEnd > 0
|
|
|
|
&& ov_pcm_tell(&vd->vf) >= (ogg_int64_t)(intptr_t)voice->LoopEnd) {
|
|
|
|
err = ov_pcm_seek(&vd->vf,(ogg_int64_t)(intptr_t)voice->LoopStart);
|
|
|
|
if (err != 0) {
|
|
|
|
MV_Printf("MV_GetNextVorbisBlock ov_pcm_seek: LOOP_START %l, LOOP_END %l, err %d\n",
|
|
|
|
(ogg_int64_t)(intptr_t)voice->LoopStart, (ogg_int64_t)(intptr_t)voice->LoopEnd, err);
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2009-10-03 14:34:05 +00:00
|
|
|
else if (bytes == OV_HOLE) continue;
|
|
|
|
else if (bytes == 0) {
|
2012-11-24 09:12:15 +00:00
|
|
|
if (voice->LoopSize > 0) {
|
|
|
|
err = ov_pcm_seek(&vd->vf,(ogg_int64_t)(intptr_t)voice->LoopStart);
|
2009-10-03 14:34:05 +00:00
|
|
|
if (err != 0) {
|
2012-11-24 09:12:15 +00:00
|
|
|
MV_Printf("MV_GetNextVorbisBlock ov_pcm_seek: LOOP_START %l, err %d\n",
|
|
|
|
(ogg_int64_t)(intptr_t)voice->LoopStart, err);
|
2009-10-03 14:34:05 +00:00
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (bytes < 0) {
|
2010-06-22 21:50:01 +00:00
|
|
|
MV_Printf("MV_GetNextVorbisBlock ov_read: err %d\n", bytes);
|
2009-10-03 14:34:05 +00:00
|
|
|
voice->Playing = FALSE;
|
|
|
|
return NoMoreData;
|
|
|
|
}
|
|
|
|
} while (bytesread < BLOCKSIZE);
|
2009-07-27 05:47:50 +00:00
|
|
|
|
|
|
|
if (bytesread == 0) {
|
|
|
|
voice->Playing = FALSE;
|
|
|
|
return NoMoreData;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bitstream != vd->lastbitstream) {
|
|
|
|
vorbis_info * vi = 0;
|
|
|
|
|
|
|
|
vi = ov_info(&vd->vf, -1);
|
2009-10-03 14:34:05 +00:00
|
|
|
if (!vi || (vi->channels != 1 && vi->channels != 2)) {
|
2009-07-27 05:47:50 +00:00
|
|
|
voice->Playing = FALSE;
|
|
|
|
return NoMoreData;
|
|
|
|
}
|
|
|
|
|
|
|
|
voice->channels = vi->channels;
|
|
|
|
voice->SamplingRate = vi->rate;
|
|
|
|
voice->RateScale = ( voice->SamplingRate * voice->PitchScale ) / MV_MixRate;
|
2011-11-01 22:02:37 +00:00
|
|
|
voice->FixedPointBufferSize = ( voice->RateScale * MV_MIXBUFFERSIZE ) - voice->RateScale;
|
2009-07-27 05:47:50 +00:00
|
|
|
MV_SetVoiceMixMode( voice );
|
2009-10-03 14:34:05 +00:00
|
|
|
vd->lastbitstream = bitstream;
|
2009-07-27 05:47:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bytesread /= 2 * voice->channels;
|
|
|
|
|
|
|
|
voice->position = 0;
|
|
|
|
voice->sound = vd->block;
|
2009-10-03 14:34:05 +00:00
|
|
|
voice->BlockLength = 0;
|
|
|
|
voice->length = bytesread << 16;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
|
|
|
return( KeepPlaying );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------
|
|
|
|
Function: MV_PlayVorbis3D
|
|
|
|
|
|
|
|
Begin playback of sound data at specified angle and distance
|
|
|
|
from listener.
|
|
|
|
---------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
int32_t MV_PlayVorbis3D
|
|
|
|
(
|
|
|
|
char *ptr,
|
|
|
|
uint32_t ptrlength,
|
|
|
|
int32_t pitchoffset,
|
|
|
|
int32_t angle,
|
|
|
|
int32_t distance,
|
|
|
|
int32_t priority,
|
|
|
|
uint32_t callbackval
|
|
|
|
)
|
|
|
|
|
|
|
|
{
|
|
|
|
int32_t left;
|
|
|
|
int32_t right;
|
|
|
|
int32_t mid;
|
|
|
|
int32_t volume;
|
|
|
|
int32_t status;
|
|
|
|
|
|
|
|
if ( !MV_Installed )
|
|
|
|
{
|
|
|
|
MV_SetErrorCode( MV_NotInstalled );
|
|
|
|
return( MV_Error );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( distance < 0 )
|
|
|
|
{
|
|
|
|
distance = -distance;
|
2011-11-01 22:02:37 +00:00
|
|
|
angle += MV_NUMPANPOSITIONS / 2;
|
2009-07-27 05:47:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
volume = MIX_VOLUME( distance );
|
|
|
|
|
2011-11-01 22:02:37 +00:00
|
|
|
// Ensure angle is within 0 - 127
|
|
|
|
angle &= MV_MAXPANPOSITION;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
|
|
|
left = MV_PanTable[ angle ][ volume ].left;
|
|
|
|
right = MV_PanTable[ angle ][ volume ].right;
|
|
|
|
mid = max( 0, 255 - distance );
|
|
|
|
|
|
|
|
status = MV_PlayVorbis( ptr, ptrlength, pitchoffset, mid, left, right, priority,
|
|
|
|
callbackval );
|
|
|
|
|
|
|
|
return( status );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------
|
|
|
|
Function: MV_PlayVorbis
|
|
|
|
|
|
|
|
Begin playback of sound data with the given sound levels and
|
|
|
|
priority.
|
|
|
|
---------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
int32_t MV_PlayVorbis
|
|
|
|
(
|
|
|
|
char *ptr,
|
|
|
|
uint32_t ptrlength,
|
|
|
|
int32_t pitchoffset,
|
|
|
|
int32_t vol,
|
|
|
|
int32_t left,
|
|
|
|
int32_t right,
|
|
|
|
int32_t priority,
|
|
|
|
uint32_t callbackval
|
|
|
|
)
|
|
|
|
|
|
|
|
{
|
|
|
|
int32_t status;
|
|
|
|
|
|
|
|
status = MV_PlayLoopedVorbis( ptr, ptrlength, -1, -1, pitchoffset, vol, left, right,
|
|
|
|
priority, callbackval );
|
|
|
|
|
|
|
|
return( status );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------
|
|
|
|
Function: MV_PlayLoopedVorbis
|
|
|
|
|
|
|
|
Begin playback of sound data with the given sound levels and
|
|
|
|
priority.
|
|
|
|
---------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
int32_t MV_PlayLoopedVorbis
|
|
|
|
(
|
|
|
|
char *ptr,
|
|
|
|
uint32_t ptrlength,
|
|
|
|
int32_t loopstart,
|
|
|
|
int32_t loopend,
|
|
|
|
int32_t pitchoffset,
|
|
|
|
int32_t vol,
|
|
|
|
int32_t left,
|
|
|
|
int32_t right,
|
|
|
|
int32_t priority,
|
|
|
|
uint32_t callbackval
|
|
|
|
)
|
|
|
|
|
|
|
|
{
|
|
|
|
VoiceNode *voice;
|
|
|
|
int32_t status;
|
|
|
|
vorbis_data * vd = 0;
|
|
|
|
vorbis_info * vi = 0;
|
2010-06-22 21:50:01 +00:00
|
|
|
|
2009-07-27 05:47:50 +00:00
|
|
|
if ( !MV_Installed )
|
|
|
|
{
|
|
|
|
MV_SetErrorCode( MV_NotInstalled );
|
|
|
|
return( MV_Error );
|
|
|
|
}
|
|
|
|
|
|
|
|
vd = (vorbis_data *) malloc( sizeof(vorbis_data) );
|
|
|
|
if (!vd) {
|
|
|
|
MV_SetErrorCode( MV_InvalidVorbisFile );
|
|
|
|
return MV_Error;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(vd, 0, sizeof(vorbis_data));
|
|
|
|
vd->ptr = ptr;
|
|
|
|
vd->pos = 0;
|
|
|
|
vd->length = ptrlength;
|
|
|
|
vd->lastbitstream = -1;
|
|
|
|
|
|
|
|
status = ov_open_callbacks((void *) vd, &vd->vf, 0, 0, vorbis_callbacks);
|
|
|
|
if (status < 0) {
|
2010-06-22 21:50:01 +00:00
|
|
|
MV_Printf("MV_PlayLoopedVorbis: err %d\n", status);
|
2009-07-27 05:47:50 +00:00
|
|
|
MV_SetErrorCode( MV_InvalidVorbisFile );
|
|
|
|
return MV_Error;
|
|
|
|
}
|
|
|
|
|
|
|
|
vi = ov_info(&vd->vf, 0);
|
|
|
|
if (!vi) {
|
|
|
|
ov_clear(&vd->vf);
|
|
|
|
free(vd);
|
|
|
|
MV_SetErrorCode( MV_InvalidVorbisFile );
|
|
|
|
return MV_Error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vi->channels != 1 && vi->channels != 2) {
|
|
|
|
ov_clear(&vd->vf);
|
|
|
|
free(vd);
|
|
|
|
MV_SetErrorCode( MV_InvalidVorbisFile );
|
|
|
|
return MV_Error;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Request a voice from the voice pool
|
|
|
|
voice = MV_AllocVoice( priority );
|
|
|
|
if ( voice == NULL )
|
|
|
|
{
|
|
|
|
ov_clear(&vd->vf);
|
|
|
|
free(vd);
|
|
|
|
MV_SetErrorCode( MV_NoVoices );
|
|
|
|
return( MV_Error );
|
|
|
|
}
|
|
|
|
|
|
|
|
voice->wavetype = Vorbis;
|
|
|
|
voice->bits = 16;
|
|
|
|
voice->channels = vi->channels;
|
|
|
|
voice->extra = (void *) vd;
|
|
|
|
voice->GetSound = MV_GetNextVorbisBlock;
|
|
|
|
voice->NextBlock = vd->block;
|
|
|
|
voice->DemandFeed = NULL;
|
|
|
|
voice->LoopCount = 0;
|
|
|
|
voice->BlockLength = 0;
|
|
|
|
voice->PitchScale = PITCH_GetScale( pitchoffset );
|
|
|
|
voice->length = 0;
|
|
|
|
voice->next = NULL;
|
|
|
|
voice->prev = NULL;
|
|
|
|
voice->priority = priority;
|
|
|
|
voice->callbackval = callbackval;
|
2012-11-24 09:12:15 +00:00
|
|
|
|
|
|
|
voice->LoopStart = (char *) (intptr_t)(loopstart >= 0 ? loopstart : 0);
|
|
|
|
voice->LoopEnd = (char *) (intptr_t)(loopstart >= 0 && loopend > 0 ? loopend : 0);
|
|
|
|
voice->LoopSize = (loopstart >= 0 ? 1 : 0);
|
|
|
|
|
|
|
|
// load loop tags from metadata
|
|
|
|
if (loopstart < 1)
|
|
|
|
{
|
|
|
|
vorbis_comment * vc = ov_comment(&vd->vf, 0);
|
|
|
|
if (vc != NULL)
|
|
|
|
{
|
2012-12-13 02:33:23 +00:00
|
|
|
int loopTagCount;
|
|
|
|
|
|
|
|
static const char *loopStartTags[] = {
|
|
|
|
"LOOP_START",
|
|
|
|
"LOOPSTART"
|
|
|
|
};
|
|
|
|
|
|
|
|
char *vc_loopstart = NULL;
|
|
|
|
|
|
|
|
for (loopTagCount = 0; loopTagCount < 2 && vc_loopstart == NULL; ++loopTagCount)
|
|
|
|
vc_loopstart = vorbis_comment_query(vc, loopStartTags[loopTagCount], 0);
|
|
|
|
|
2012-11-24 09:12:15 +00:00
|
|
|
if (vc_loopstart != NULL)
|
|
|
|
{
|
|
|
|
ogg_int64_t ov_loopstart = atol(vc_loopstart);
|
2012-12-13 02:33:23 +00:00
|
|
|
if (ov_loopstart >= 0) // a loop starting at 0 is valid
|
2012-11-24 09:12:15 +00:00
|
|
|
{
|
2012-12-13 02:33:23 +00:00
|
|
|
static const char *loopEndTags[] = {
|
|
|
|
"LOOP_END",
|
|
|
|
"LOOPEND"
|
|
|
|
};
|
|
|
|
|
|
|
|
char *vc_loopend = NULL;
|
2012-11-24 09:12:15 +00:00
|
|
|
|
|
|
|
voice->LoopStart = (char *) (intptr_t) ov_loopstart;
|
|
|
|
voice->LoopSize = 1;
|
|
|
|
|
2012-12-13 02:33:23 +00:00
|
|
|
for (loopTagCount = 0; loopTagCount < 2 && vc_loopend == NULL; ++loopTagCount)
|
|
|
|
vc_loopend = vorbis_comment_query(vc, loopEndTags[loopTagCount], 0);
|
|
|
|
|
2012-11-24 09:12:15 +00:00
|
|
|
if (vc_loopend != NULL)
|
|
|
|
{
|
|
|
|
ogg_int64_t ov_loopend = atol(vc_loopend);
|
2012-12-13 02:33:23 +00:00
|
|
|
if (ov_loopend > 0) // a loop ending at 0 is invalid
|
2012-11-24 09:12:15 +00:00
|
|
|
voice->LoopEnd = (char *) (intptr_t) ov_loopend;
|
|
|
|
}
|
2012-12-13 02:33:23 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
static const char *loopLengthTags[] = {
|
|
|
|
"LOOP_LENGTH",
|
|
|
|
"LOOPLENGTH"
|
|
|
|
};
|
|
|
|
|
|
|
|
char *vc_looplength = NULL;
|
|
|
|
|
|
|
|
for (loopTagCount = 0; loopTagCount < 2 && vc_looplength == NULL; ++loopTagCount)
|
|
|
|
vc_looplength = vorbis_comment_query(vc, loopLengthTags[loopTagCount], 0);
|
|
|
|
|
|
|
|
if (vc_looplength != NULL)
|
|
|
|
{
|
|
|
|
ogg_int64_t ov_looplength = atol(vc_looplength);
|
|
|
|
if (ov_looplength > 0) // a loop of length 0 is invalid
|
|
|
|
voice->LoopEnd = (char *) (intptr_t) (ov_looplength + ov_loopstart);
|
|
|
|
}
|
|
|
|
}
|
2012-11-24 09:12:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-03 14:34:05 +00:00
|
|
|
voice->Playing = TRUE;
|
|
|
|
voice->Paused = FALSE;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
|
|
|
voice->SamplingRate = vi->rate;
|
|
|
|
voice->RateScale = ( voice->SamplingRate * voice->PitchScale ) / MV_MixRate;
|
2011-11-01 22:02:37 +00:00
|
|
|
voice->FixedPointBufferSize = ( voice->RateScale * MV_MIXBUFFERSIZE ) -
|
2009-10-03 14:34:05 +00:00
|
|
|
voice->RateScale;
|
2009-07-27 05:47:50 +00:00
|
|
|
MV_SetVoiceMixMode( voice );
|
|
|
|
|
|
|
|
MV_SetVoiceVolume( voice, vol, left, right );
|
|
|
|
MV_PlayVoice( voice );
|
|
|
|
|
|
|
|
return( voice->handle );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MV_ReleaseVorbisVoice( VoiceNode * voice )
|
|
|
|
{
|
|
|
|
vorbis_data * vd = (vorbis_data *) voice->extra;
|
|
|
|
|
|
|
|
if (voice->wavetype != Vorbis) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ov_clear(&vd->vf);
|
|
|
|
free(vd);
|
|
|
|
|
|
|
|
voice->extra = 0;
|
|
|
|
}
|
|
|
|
|
2009-10-03 14:34:05 +00:00
|
|
|
#endif //HAVE_VORBIS
|