mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
Add Demand Feed audio streaming support back to ASS audiolib. This is from the Rise of the Triad source release.
This commit is contained in:
parent
77a2625a85
commit
a191faf175
5 changed files with 140 additions and 0 deletions
|
@ -69,6 +69,8 @@ int FX_PlayRaw(char *ptr, uint32_t ptrlength, int rate, int pitchoffset, int vol
|
|||
int FX_PlayLoopedRaw(char *ptr, uint32_t ptrlength, char *loopstart, char *loopend, int rate,
|
||||
int pitchoffset, int vol, int left, int right, int priority, float volume, intptr_t callbackval);
|
||||
|
||||
int FX_StartDemandFeedPlayback(void (*function)(const char** ptr, uint32_t* length), int rate, int pitchoffset,
|
||||
int vol, int left, int right, int priority, fix16_t volume, uint32_t callbackval);
|
||||
|
||||
int FX_SetPrintf(void(*function)(const char *, ...));
|
||||
|
||||
|
|
|
@ -105,6 +105,9 @@ int MV_PlayVOC3D(char *ptr, uint32_t length, int loophow, int pitchoffset, int a
|
|||
int MV_PlayVOC(char *ptr, uint32_t length, int loopstart, int loopend, int pitchoffset, int vol,
|
||||
int left, int right, int priority, float volume, intptr_t callbackval);
|
||||
|
||||
int MV_StartDemandFeedPlayback(void (*function)(const char** ptr, uint32_t* length), int rate,
|
||||
int pitchoffset, int vol, int left, int right, int priority, fix16_t volume, uint32_t callbackval);
|
||||
|
||||
decltype(MV_PlayVOC3D) MV_PlayWAV3D;
|
||||
decltype(MV_PlayVOC) MV_PlayWAV;
|
||||
decltype(MV_PlayVOC3D) MV_PlayVorbis3D;
|
||||
|
|
|
@ -158,6 +158,8 @@ typedef struct VoiceNode
|
|||
|
||||
uint32_t (*mix)(struct VoiceNode *, uint32_t);
|
||||
|
||||
void (*DemandFeed)(const char** ptr, uint32_t* length);
|
||||
|
||||
const char *sound;
|
||||
|
||||
float LeftVolume, LeftVolumeDest;
|
||||
|
|
|
@ -225,3 +225,36 @@ int FX_SetPrintf(void (*function)(const char *, ...))
|
|||
|
||||
return FX_Ok;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
Function: FX_StartDemandFeedPlayback
|
||||
|
||||
Plays a digitized sound from a user controlled buffering system.
|
||||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_StartDemandFeedPlayback
|
||||
(
|
||||
void (*function)(const char** ptr, uint32_t* length),
|
||||
int rate,
|
||||
int pitchoffset,
|
||||
int vol,
|
||||
int left,
|
||||
int right,
|
||||
int priority,
|
||||
fix16_t volume,
|
||||
uint32_t callbackval
|
||||
)
|
||||
|
||||
{
|
||||
int handle;
|
||||
|
||||
handle = MV_StartDemandFeedPlayback(function, rate,
|
||||
pitchoffset, vol, left, right, priority, volume, callbackval);
|
||||
if (handle < MV_Ok)
|
||||
{
|
||||
FX_SetErrorCode(FX_MultiVocError);
|
||||
handle = FX_Warning;
|
||||
}
|
||||
|
||||
return(handle);
|
||||
}
|
|
@ -899,3 +899,103 @@ const char *MV_ErrorString(int ErrorNumber)
|
|||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
Function: MV_GetNextDemandFeedBlock
|
||||
|
||||
Controls playback of demand fed data.
|
||||
---------------------------------------------------------------------*/
|
||||
|
||||
playbackstatus MV_GetNextDemandFeedBlock
|
||||
(
|
||||
VoiceNode* voice
|
||||
)
|
||||
|
||||
{
|
||||
if (voice->BlockLength > 0)
|
||||
{
|
||||
voice->position -= voice->length;
|
||||
voice->sound += voice->length >> 16;
|
||||
voice->length = min(voice->BlockLength, 0x8000u);
|
||||
voice->BlockLength -= voice->length;
|
||||
voice->length <<= 16;
|
||||
|
||||
return(KeepPlaying);
|
||||
}
|
||||
|
||||
if (voice->DemandFeed == NULL)
|
||||
{
|
||||
return(NoMoreData);
|
||||
}
|
||||
|
||||
voice->position = 0;
|
||||
(voice->DemandFeed)(&voice->sound, &voice->BlockLength);
|
||||
voice->length = min(voice->BlockLength, 0x8000u);
|
||||
voice->BlockLength -= voice->length;
|
||||
voice->length <<= 16;
|
||||
|
||||
if ((voice->length > 0) && (voice->sound != NULL))
|
||||
{
|
||||
return(KeepPlaying);
|
||||
}
|
||||
return(NoMoreData);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
Function: MV_StartDemandFeedPlayback
|
||||
|
||||
Plays a digitized sound from a user controlled buffering system.
|
||||
---------------------------------------------------------------------*/
|
||||
|
||||
int MV_StartDemandFeedPlayback
|
||||
(
|
||||
void (*function)(const char** ptr, uint32_t* length),
|
||||
int rate,
|
||||
int pitchoffset,
|
||||
int vol,
|
||||
int left,
|
||||
int right,
|
||||
int priority,
|
||||
fix16_t volume,
|
||||
uint32_t callbackval
|
||||
)
|
||||
|
||||
{
|
||||
VoiceNode* voice;
|
||||
|
||||
if (!MV_Installed)
|
||||
{
|
||||
MV_SetErrorCode(MV_NotInstalled);
|
||||
return(MV_Error);
|
||||
}
|
||||
|
||||
// Request a voice from the voice pool
|
||||
voice = MV_AllocVoice(priority);
|
||||
if (voice == NULL)
|
||||
{
|
||||
MV_SetErrorCode(MV_NoVoices);
|
||||
return(MV_Error);
|
||||
}
|
||||
|
||||
// voice->wavetype = FMT_DEMANDFED;
|
||||
voice->bits = 8;
|
||||
voice->channels = 1;
|
||||
voice->GetSound = MV_GetNextDemandFeedBlock;
|
||||
voice->NextBlock = NULL;
|
||||
voice->DemandFeed = function;
|
||||
voice->LoopStart = NULL;
|
||||
voice->LoopCount = 0;
|
||||
voice->BlockLength = 0;
|
||||
voice->position = 0;
|
||||
voice->sound = NULL;
|
||||
voice->length = 0;
|
||||
voice->next = NULL;
|
||||
voice->prev = NULL;
|
||||
voice->priority = priority;
|
||||
voice->callbackval = callbackval;
|
||||
|
||||
MV_SetVoicePitch(voice, rate, pitchoffset);
|
||||
MV_SetVoiceVolume(voice, vol, left, right, volume);
|
||||
MV_PlayVoice(voice);
|
||||
|
||||
return(voice->handle);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue