More beauty tinkering: decorate the 'start' pointer of the mixing functions

and some VoiceNode struct members with a const, commit forgotten vorbis.c
changes.

git-svn-id: https://svn.eduke32.com/eduke32@2100 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-11-01 22:02:37 +00:00
parent a9278e1977
commit fdd84d1870
5 changed files with 63 additions and 71 deletions

View file

@ -120,11 +120,11 @@ typedef struct VoiceNode
playbackstatus ( *GetSound )( struct VoiceNode *voice ); playbackstatus ( *GetSound )( struct VoiceNode *voice );
void ( *mix )( uint32_t position, uint32_t rate, void ( *mix )( uint32_t position, uint32_t rate,
char *start, uint32_t length ); const char *start, uint32_t length );
char *NextBlock; const char *NextBlock;
char *LoopStart; const char *LoopStart;
char *LoopEnd; const char *LoopEnd;
unsigned LoopCount; unsigned LoopCount;
uint32_t LoopSize; uint32_t LoopSize;
uint32_t BlockLength; uint32_t BlockLength;
@ -132,7 +132,7 @@ typedef struct VoiceNode
uint32_t PitchScale; uint32_t PitchScale;
uint32_t FixedPointBufferSize; uint32_t FixedPointBufferSize;
char *sound; const char *sound;
uint32_t length; uint32_t length;
uint32_t SamplingRate; uint32_t SamplingRate;
uint32_t RateScale; uint32_t RateScale;
@ -146,8 +146,8 @@ typedef struct VoiceNode
void ( *DemandFeed )( char **ptr, uint32_t *length ); void ( *DemandFeed )( char **ptr, uint32_t *length );
void *extra; void *extra;
int16_t *LeftVolume; const int16_t *LeftVolume;
int16_t *RightVolume; const int16_t *RightVolume;
uint32_t callbackval; uint32_t callbackval;
@ -240,28 +240,28 @@ void MV_ReleaseVorbisVoice( VoiceNode * voice );
void ClearBuffer_DW( void *ptr, unsigned data, int32_t length ); void ClearBuffer_DW( void *ptr, unsigned data, int32_t length );
void MV_Mix8BitMono( uint32_t position, uint32_t rate, void MV_Mix8BitMono( uint32_t position, uint32_t rate,
char *start, uint32_t length ); const char *start, uint32_t length );
void MV_Mix8BitStereo( uint32_t position, void MV_Mix8BitStereo( uint32_t position,
uint32_t rate, char *start, uint32_t length ); uint32_t rate, const char *start, uint32_t length );
void MV_Mix16BitMono( uint32_t position, void MV_Mix16BitMono( uint32_t position,
uint32_t rate, char *start, uint32_t length ); uint32_t rate, const char *start, uint32_t length );
void MV_Mix16BitStereo( uint32_t position, void MV_Mix16BitStereo( uint32_t position,
uint32_t rate, char *start, uint32_t length ); uint32_t rate, const char *start, uint32_t length );
void MV_Mix16BitMono16( uint32_t position, void MV_Mix16BitMono16( uint32_t position,
uint32_t rate, char *start, uint32_t length ); uint32_t rate, const char *start, uint32_t length );
void MV_Mix8BitMono16( uint32_t position, uint32_t rate, void MV_Mix8BitMono16( uint32_t position, uint32_t rate,
char *start, uint32_t length ); const char *start, uint32_t length );
void MV_Mix8BitStereo16( uint32_t position, void MV_Mix8BitStereo16( uint32_t position,
uint32_t rate, char *start, uint32_t length ); uint32_t rate, const char *start, uint32_t length );
void MV_Mix16BitStereo16( uint32_t position, void MV_Mix16BitStereo16( uint32_t position,
uint32_t rate, char *start, uint32_t length ); uint32_t rate, const char *start, uint32_t length );
void MV_16BitReverb( char *src, char *dest, VOLUME16 *volume, int32_t count ); void MV_16BitReverb( char *src, char *dest, VOLUME16 *volume, int32_t count );
@ -275,27 +275,40 @@ void MV_8BitReverbFast( int8_t *src, int8_t *dest, int32_t count, int32_t shift
void ClearBuffer_DW( void *ptr, unsigned data, int32_t length ); void ClearBuffer_DW( void *ptr, unsigned data, int32_t length );
void MV_Mix8BitMono8Stereo( uint32_t position, uint32_t rate, void MV_Mix8BitMono8Stereo( uint32_t position, uint32_t rate,
char *start, uint32_t length ); const char *start, uint32_t length );
void MV_Mix8BitStereo8Stereo( uint32_t position, void MV_Mix8BitStereo8Stereo( uint32_t position,
uint32_t rate, char *start, uint32_t length ); uint32_t rate, const char *start, uint32_t length );
void MV_Mix16BitMono8Stereo( uint32_t position, void MV_Mix16BitMono8Stereo( uint32_t position,
uint32_t rate, char *start, uint32_t length ); uint32_t rate, const char *start, uint32_t length );
void MV_Mix16BitStereo8Stereo( uint32_t position, void MV_Mix16BitStereo8Stereo( uint32_t position,
uint32_t rate, char *start, uint32_t length ); uint32_t rate, const char *start, uint32_t length );
void MV_Mix16BitMono16Stereo( uint32_t position, void MV_Mix16BitMono16Stereo( uint32_t position,
uint32_t rate, char *start, uint32_t length ); uint32_t rate, const char *start, uint32_t length );
void MV_Mix8BitMono16Stereo( uint32_t position, uint32_t rate, void MV_Mix8BitMono16Stereo( uint32_t position, uint32_t rate,
char *start, uint32_t length ); const char *start, uint32_t length );
void MV_Mix8BitStereo16Stereo( uint32_t position, void MV_Mix8BitStereo16Stereo( uint32_t position,
uint32_t rate, char *start, uint32_t length ); uint32_t rate, const char *start, uint32_t length );
void MV_Mix16BitStereo16Stereo( uint32_t position, void MV_Mix16BitStereo16Stereo( uint32_t position,
uint32_t rate, char *start, uint32_t length ); uint32_t rate, const char *start, uint32_t length );
extern char *MV_HarshClipTable;
extern char *MV_MixDestination; // pointer to the next output sample
extern uint32_t MV_MixPosition; // return value of where the source pointer got to
extern const int16_t *MV_LeftVolume;
extern const int16_t *MV_RightVolume;
extern int32_t MV_SampleSize;
extern int32_t MV_RightChannelOffset;
#ifdef __POWERPC__
# define BIGENDIAN
#endif
#endif #endif

View file

@ -20,17 +20,6 @@
#include "_multivc.h" #include "_multivc.h"
extern char *MV_HarshClipTable;
extern char *MV_MixDestination; // pointer to the next output sample
extern uint32_t MV_MixPosition; // return value of where the source pointer got to
extern int16_t *MV_LeftVolume;
extern int16_t *MV_RightVolume;
extern int32_t MV_SampleSize;
extern int32_t MV_RightChannelOffset;
#ifdef __POWERPC__
# define BIGENDIAN
#endif
void ClearBuffer_DW( void *ptr, unsigned data, int32_t length ) void ClearBuffer_DW( void *ptr, unsigned data, int32_t length )
{ {
@ -51,7 +40,7 @@ void ClearBuffer_DW( void *ptr, unsigned data, int32_t length )
// 8-bit mono source, 8-bit mono output // 8-bit mono source, 8-bit mono output
void MV_Mix8BitMono( uint32_t position, uint32_t rate, void MV_Mix8BitMono( uint32_t position, uint32_t rate,
char *start, uint32_t length ) const char *start, uint32_t length )
{ {
uint8_t *source = (uint8_t *) start; uint8_t *source = (uint8_t *) start;
uint8_t *dest = (uint8_t *) MV_MixDestination; uint8_t *dest = (uint8_t *) MV_MixDestination;
@ -75,7 +64,7 @@ void MV_Mix8BitMono( uint32_t position, uint32_t rate,
// 8-bit mono source, 8-bit stereo output // 8-bit mono source, 8-bit stereo output
void MV_Mix8BitStereo( uint32_t position, uint32_t rate, void MV_Mix8BitStereo( uint32_t position, uint32_t rate,
char *start, uint32_t length ) const char *start, uint32_t length )
{ {
uint8_t *source = (uint8_t *) start; uint8_t *source = (uint8_t *) start;
uint8_t *dest = (uint8_t *) MV_MixDestination; uint8_t *dest = (uint8_t *) MV_MixDestination;
@ -103,7 +92,7 @@ void MV_Mix8BitStereo( uint32_t position, uint32_t rate,
// 8-bit mono source, 16-bit mono output // 8-bit mono source, 16-bit mono output
void MV_Mix16BitMono( uint32_t position, uint32_t rate, void MV_Mix16BitMono( uint32_t position, uint32_t rate,
char *start, uint32_t length ) const char *start, uint32_t length )
{ {
uint8_t *source = (uint8_t *) start; uint8_t *source = (uint8_t *) start;
int16_t *dest = (int16_t *) MV_MixDestination; int16_t *dest = (int16_t *) MV_MixDestination;
@ -128,7 +117,7 @@ void MV_Mix16BitMono( uint32_t position, uint32_t rate,
// 8-bit mono source, 16-bit stereo output // 8-bit mono source, 16-bit stereo output
void MV_Mix16BitStereo( uint32_t position, uint32_t rate, void MV_Mix16BitStereo( uint32_t position, uint32_t rate,
char *start, uint32_t length ) const char *start, uint32_t length )
{ {
uint8_t *source = (uint8_t *) start; uint8_t *source = (uint8_t *) start;
int16_t *dest = (int16_t *) MV_MixDestination; int16_t *dest = (int16_t *) MV_MixDestination;
@ -158,7 +147,7 @@ void MV_Mix16BitStereo( uint32_t position, uint32_t rate,
// 16-bit mono source, 16-bit mono output // 16-bit mono source, 16-bit mono output
void MV_Mix16BitMono16( uint32_t position, uint32_t rate, void MV_Mix16BitMono16( uint32_t position, uint32_t rate,
char *start, uint32_t length ) const char *start, uint32_t length )
{ {
uint16_t *source = (uint16_t *) start; uint16_t *source = (uint16_t *) start;
int16_t *dest = (int16_t *) MV_MixDestination; int16_t *dest = (int16_t *) MV_MixDestination;
@ -192,7 +181,7 @@ void MV_Mix16BitMono16( uint32_t position, uint32_t rate,
// 16-bit mono source, 8-bit mono output // 16-bit mono source, 8-bit mono output
void MV_Mix8BitMono16( uint32_t position, uint32_t rate, void MV_Mix8BitMono16( uint32_t position, uint32_t rate,
char *start, uint32_t length ) const char *start, uint32_t length )
{ {
int8_t *source = (int8_t *) start + 1; int8_t *source = (int8_t *) start + 1;
uint8_t *dest = (uint8_t *) MV_MixDestination; uint8_t *dest = (uint8_t *) MV_MixDestination;
@ -216,7 +205,7 @@ void MV_Mix8BitMono16( uint32_t position, uint32_t rate,
// 16-bit mono source, 8-bit stereo output // 16-bit mono source, 8-bit stereo output
void MV_Mix8BitStereo16( uint32_t position, uint32_t rate, void MV_Mix8BitStereo16( uint32_t position, uint32_t rate,
char *start, uint32_t length ) const char *start, uint32_t length )
{ {
int8_t *source = (int8_t *) start + 1; int8_t *source = (int8_t *) start + 1;
uint8_t *dest = (uint8_t *) MV_MixDestination; uint8_t *dest = (uint8_t *) MV_MixDestination;
@ -244,7 +233,7 @@ void MV_Mix8BitStereo16( uint32_t position, uint32_t rate,
// 16-bit mono source, 16-bit stereo output // 16-bit mono source, 16-bit stereo output
void MV_Mix16BitStereo16( uint32_t position, uint32_t rate, void MV_Mix16BitStereo16( uint32_t position, uint32_t rate,
char *start, uint32_t length ) const char *start, uint32_t length )
{ {
uint16_t *source = (uint16_t *) start; uint16_t *source = (uint16_t *) start;
int16_t *dest = (int16_t *) MV_MixDestination; int16_t *dest = (int16_t *) MV_MixDestination;

View file

@ -20,17 +20,6 @@
#include "_multivc.h" #include "_multivc.h"
extern char *MV_HarshClipTable;
extern char *MV_MixDestination; // pointer to the next output sample
extern uint32_t MV_MixPosition; // return value of where the source pointer got to
extern int16_t *MV_LeftVolume;
extern int16_t *MV_RightVolume;
extern int32_t MV_SampleSize;
extern int32_t MV_RightChannelOffset;
#ifdef __POWERPC__
# define BIGENDIAN
#endif
/* /*
JBF: JBF:
@ -43,7 +32,7 @@ extern int32_t MV_RightChannelOffset;
// 8-bit stereo source, 8-bit mono output // 8-bit stereo source, 8-bit mono output
void MV_Mix8BitMono8Stereo( uint32_t position, uint32_t rate, void MV_Mix8BitMono8Stereo( uint32_t position, uint32_t rate,
char *start, uint32_t length ) const char *start, uint32_t length )
{ {
uint8_t *source = (uint8_t *) start; uint8_t *source = (uint8_t *) start;
uint8_t *dest = (uint8_t *) MV_MixDestination; uint8_t *dest = (uint8_t *) MV_MixDestination;
@ -68,7 +57,7 @@ void MV_Mix8BitMono8Stereo( uint32_t position, uint32_t rate,
// 8-bit stereo source, 8-bit stereo output // 8-bit stereo source, 8-bit stereo output
void MV_Mix8BitStereo8Stereo( uint32_t position, uint32_t rate, void MV_Mix8BitStereo8Stereo( uint32_t position, uint32_t rate,
char *start, uint32_t length ) const char *start, uint32_t length )
{ {
uint8_t *source = (uint8_t *) start; uint8_t *source = (uint8_t *) start;
uint8_t *dest = (uint8_t *) MV_MixDestination; uint8_t *dest = (uint8_t *) MV_MixDestination;
@ -96,7 +85,7 @@ void MV_Mix8BitStereo8Stereo( uint32_t position, uint32_t rate,
// 8-bit stereo source, 16-bit mono output // 8-bit stereo source, 16-bit mono output
void MV_Mix16BitMono8Stereo( uint32_t position, uint32_t rate, void MV_Mix16BitMono8Stereo( uint32_t position, uint32_t rate,
char *start, uint32_t length ) const char *start, uint32_t length )
{ {
uint8_t *source = (uint8_t *) start; uint8_t *source = (uint8_t *) start;
int16_t *dest = (int16_t *) MV_MixDestination; int16_t *dest = (int16_t *) MV_MixDestination;
@ -122,7 +111,7 @@ void MV_Mix16BitMono8Stereo( uint32_t position, uint32_t rate,
// 8-bit stereo source, 16-bit stereo output // 8-bit stereo source, 16-bit stereo output
void MV_Mix16BitStereo8Stereo( uint32_t position, uint32_t rate, void MV_Mix16BitStereo8Stereo( uint32_t position, uint32_t rate,
char *start, uint32_t length ) const char *start, uint32_t length )
{ {
uint8_t *source = (uint8_t *) start; uint8_t *source = (uint8_t *) start;
int16_t *dest = (int16_t *) MV_MixDestination; int16_t *dest = (int16_t *) MV_MixDestination;
@ -152,7 +141,7 @@ void MV_Mix16BitStereo8Stereo( uint32_t position, uint32_t rate,
// 16-bit stereo source, 16-bit mono output // 16-bit stereo source, 16-bit mono output
void MV_Mix16BitMono16Stereo( uint32_t position, uint32_t rate, void MV_Mix16BitMono16Stereo( uint32_t position, uint32_t rate,
char *start, uint32_t length ) const char *start, uint32_t length )
{ {
uint16_t *source = (uint16_t *) start; uint16_t *source = (uint16_t *) start;
int16_t *dest = (int16_t *) MV_MixDestination; int16_t *dest = (int16_t *) MV_MixDestination;
@ -197,7 +186,7 @@ void MV_Mix16BitMono16Stereo( uint32_t position, uint32_t rate,
// 16-bit stereo source, 8-bit mono output // 16-bit stereo source, 8-bit mono output
void MV_Mix8BitMono16Stereo( uint32_t position, uint32_t rate, void MV_Mix8BitMono16Stereo( uint32_t position, uint32_t rate,
char *start, uint32_t length ) const char *start, uint32_t length )
{ {
int8_t *source = (int8_t *) start + 1; int8_t *source = (int8_t *) start + 1;
uint8_t *dest = (uint8_t *) MV_MixDestination; uint8_t *dest = (uint8_t *) MV_MixDestination;
@ -224,7 +213,7 @@ void MV_Mix8BitMono16Stereo( uint32_t position, uint32_t rate,
// 16-bit stereo source, 8-bit stereo output // 16-bit stereo source, 8-bit stereo output
void MV_Mix8BitStereo16Stereo( uint32_t position, uint32_t rate, void MV_Mix8BitStereo16Stereo( uint32_t position, uint32_t rate,
char *start, uint32_t length ) const char *start, uint32_t length )
{ {
int8_t *source = (int8_t *) start + 1; int8_t *source = (int8_t *) start + 1;
uint8_t *dest = (uint8_t *) MV_MixDestination; uint8_t *dest = (uint8_t *) MV_MixDestination;
@ -252,7 +241,7 @@ void MV_Mix8BitStereo16Stereo( uint32_t position, uint32_t rate,
// 16-bit stereo source, 16-bit stereo output // 16-bit stereo source, 16-bit stereo output
void MV_Mix16BitStereo16Stereo( uint32_t position, uint32_t rate, void MV_Mix16BitStereo16Stereo( uint32_t position, uint32_t rate,
char *start, uint32_t length ) const char *start, uint32_t length )
{ {
uint16_t *source = (uint16_t *) start; uint16_t *source = (uint16_t *) start;
int16_t *dest = (int16_t *) MV_MixDestination; int16_t *dest = (int16_t *) MV_MixDestination;

View file

@ -143,8 +143,8 @@ static void (*MV_MixFunction)(VoiceNode *voice, int32_t buffer);
char *MV_HarshClipTable; char *MV_HarshClipTable;
char *MV_MixDestination; char *MV_MixDestination;
int16_t *MV_LeftVolume; const int16_t *MV_LeftVolume;
int16_t *MV_RightVolume; const int16_t *MV_RightVolume;
int32_t MV_SampleSize = 1; int32_t MV_SampleSize = 1;
int32_t MV_RightChannelOffset; int32_t MV_RightChannelOffset;
@ -232,7 +232,7 @@ const char *MV_ErrorString(int32_t ErrorNumber)
static void MV_Mix(VoiceNode *voice,int32_t buffer) static void MV_Mix(VoiceNode *voice,int32_t buffer)
{ {
char *start; const char *start;
int32_t length; int32_t length;
int32_t voclength; int32_t voclength;
uint32_t position; uint32_t position;
@ -751,7 +751,8 @@ static playbackstatus MV_GetNextDemandFeedBlock(VoiceNode *voice)
return(NoMoreData); return(NoMoreData);
voice->position = 0; voice->position = 0;
(voice->DemandFeed)(&voice->sound, &voice->BlockLength); // TODO: learn how to properly attach the 'const' in pointer-pointers :O
(voice->DemandFeed)((char **)&voice->sound, &voice->BlockLength);
voice->length = min(voice->BlockLength, 0x8000); voice->length = min(voice->BlockLength, 0x8000);
voice->BlockLength -= voice->length; voice->BlockLength -= voice->length;
voice->length <<= 16; voice->length <<= 16;
@ -2189,7 +2190,7 @@ int32_t MV_PlayVOC3D
volume = MIX_VOLUME(distance); volume = MIX_VOLUME(distance);
// Ensure angle is within 0 - 31 // Ensure angle is within 0 - 127
angle &= MV_MAXPANPOSITION; angle &= MV_MAXPANPOSITION;
left = MV_PanTable[ angle ][ volume ].left; left = MV_PanTable[ angle ][ volume ].left;

View file

@ -195,7 +195,7 @@ static playbackstatus MV_GetNextVorbisBlock
voice->channels = vi->channels; voice->channels = vi->channels;
voice->SamplingRate = vi->rate; voice->SamplingRate = vi->rate;
voice->RateScale = ( voice->SamplingRate * voice->PitchScale ) / MV_MixRate; voice->RateScale = ( voice->SamplingRate * voice->PitchScale ) / MV_MixRate;
voice->FixedPointBufferSize = ( voice->RateScale * MixBufferSize ) - voice->RateScale; voice->FixedPointBufferSize = ( voice->RateScale * MV_MIXBUFFERSIZE ) - voice->RateScale;
MV_SetVoiceMixMode( voice ); MV_SetVoiceMixMode( voice );
vd->lastbitstream = bitstream; vd->lastbitstream = bitstream;
} }
@ -245,13 +245,13 @@ int32_t MV_PlayVorbis3D
if ( distance < 0 ) if ( distance < 0 )
{ {
distance = -distance; distance = -distance;
angle += MV_NumPanPositions / 2; angle += MV_NUMPANPOSITIONS / 2;
} }
volume = MIX_VOLUME( distance ); volume = MIX_VOLUME( distance );
// Ensure angle is within 0 - 31 // Ensure angle is within 0 - 127
angle &= MV_MaxPanPosition; angle &= MV_MAXPANPOSITION;
left = MV_PanTable[ angle ][ volume ].left; left = MV_PanTable[ angle ][ volume ].left;
right = MV_PanTable[ angle ][ volume ].right; right = MV_PanTable[ angle ][ volume ].right;
@ -395,7 +395,7 @@ int32_t MV_PlayLoopedVorbis
voice->SamplingRate = vi->rate; voice->SamplingRate = vi->rate;
voice->RateScale = ( voice->SamplingRate * voice->PitchScale ) / MV_MixRate; voice->RateScale = ( voice->SamplingRate * voice->PitchScale ) / MV_MixRate;
voice->FixedPointBufferSize = ( voice->RateScale * MixBufferSize ) - voice->FixedPointBufferSize = ( voice->RateScale * MV_MIXBUFFERSIZE ) -
voice->RateScale; voice->RateScale;
MV_SetVoiceMixMode( voice ); MV_SetVoiceMixMode( voice );