summaryrefslogtreecommitdiff
path: root/src/client/snd_dma.c
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2009-10-03 11:52:53 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:15:28 +0000
commitb47a49a03370e7ea42f47623b9f72a5ca799f0e7 (patch)
tree9d64d778ded2971d7ebd05970d903d886bd81436 /src/client/snd_dma.c
parent09ceb08b95978feb0a9b737f22ac0f662c7465d6 (diff)
* Merge ioq3-r1423
+ IPv6 + VoIP + Stereo rendering + Other minor stuff
Diffstat (limited to 'src/client/snd_dma.c')
-rw-r--r--src/client/snd_dma.c126
1 files changed, 86 insertions, 40 deletions
diff --git a/src/client/snd_dma.c b/src/client/snd_dma.c
index 749be017..d9fea8d4 100644
--- a/src/client/snd_dma.c
+++ b/src/client/snd_dma.c
@@ -91,8 +91,8 @@ cvar_t *s_mixPreStep;
static loopSound_t loopSounds[MAX_GENTITIES];
static channel_t *freelist = NULL;
-int s_rawend;
-portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];
+int s_rawend[MAX_RAW_STREAMS];
+portable_samplepair_t s_rawsamples[MAX_RAW_STREAMS][MAX_RAW_SAMPLES];
// ====================================================================
@@ -121,6 +121,42 @@ void S_Base_SoundInfo(void) {
Com_Printf("----------------------\n" );
}
+
+#ifdef USE_VOIP
+static
+void S_Base_StartCapture( void )
+{
+ // !!! FIXME: write me.
+}
+
+static
+int S_Base_AvailableCaptureSamples( void )
+{
+ // !!! FIXME: write me.
+ return 0;
+}
+
+static
+void S_Base_Capture( int samples, byte *data )
+{
+ // !!! FIXME: write me.
+}
+
+static
+void S_Base_StopCapture( void )
+{
+ // !!! FIXME: write me.
+}
+
+static
+void S_Base_MasterGain( float val )
+{
+ // !!! FIXME: write me.
+}
+#endif
+
+
+
/*
=================
S_Base_SoundList
@@ -624,7 +660,7 @@ void S_Base_ClearSoundBuffer( void ) {
S_ChannelSetup();
- s_rawend = 0;
+ Com_Memset(s_rawend, '\0', sizeof (s_rawend));
if (dma.samplebits == 8)
clear = 0x80;
@@ -895,10 +931,6 @@ void S_ByteSwapRawSamples( int samples, int width, int s_channels, const byte *d
}
}
-portable_samplepair_t *S_GetRawSamplePointer( void ) {
- return s_rawsamples;
-}
-
/*
============
S_RawSamples
@@ -906,36 +938,42 @@ S_RawSamples
Music streaming
============
*/
-void S_Base_RawSamples( int samples, int rate, int width, int s_channels, const byte *data, float volume ) {
+void S_Base_RawSamples( int stream, int samples, int rate, int width, int s_channels, const byte *data, float volume ) {
int i;
int src, dst;
float scale;
int intVolume;
+ portable_samplepair_t *rawsamples;
if ( !s_soundStarted || s_soundMuted ) {
return;
}
+ if ( (stream < 0) || (stream >= MAX_RAW_STREAMS) ) {
+ return;
+ }
+ rawsamples = s_rawsamples[stream];
+
intVolume = 256 * volume;
- if ( s_rawend < s_soundtime ) {
- Com_DPrintf( "S_RawSamples: resetting minimum: %i < %i\n", s_rawend, s_soundtime );
- s_rawend = s_soundtime;
+ if ( s_rawend[stream] < s_soundtime ) {
+ Com_DPrintf( "S_RawSamples: resetting minimum: %i < %i\n", s_rawend[stream], s_soundtime );
+ s_rawend[stream] = s_soundtime;
}
scale = (float)rate / dma.speed;
-//Com_Printf ("%i < %i < %i\n", s_soundtime, s_paintedtime, s_rawend);
+//Com_Printf ("%i < %i < %i\n", s_soundtime, s_paintedtime, s_rawend[stream]);
if (s_channels == 2 && width == 2)
{
if (scale == 1.0)
{ // optimized case
for (i=0 ; i<samples ; i++)
{
- dst = s_rawend&(MAX_RAW_SAMPLES-1);
- s_rawend++;
- s_rawsamples[dst].left = ((short *)data)[i*2] * intVolume;
- s_rawsamples[dst].right = ((short *)data)[i*2+1] * intVolume;
+ dst = s_rawend[stream]&(MAX_RAW_SAMPLES-1);
+ s_rawend[stream]++;
+ rawsamples[dst].left = ((short *)data)[i*2] * intVolume;
+ rawsamples[dst].right = ((short *)data)[i*2+1] * intVolume;
}
}
else
@@ -945,10 +983,10 @@ void S_Base_RawSamples( int samples, int rate, int width, int s_channels, const
src = i*scale;
if (src >= samples)
break;
- dst = s_rawend&(MAX_RAW_SAMPLES-1);
- s_rawend++;
- s_rawsamples[dst].left = ((short *)data)[src*2] * intVolume;
- s_rawsamples[dst].right = ((short *)data)[src*2+1] * intVolume;
+ dst = s_rawend[stream]&(MAX_RAW_SAMPLES-1);
+ s_rawend[stream]++;
+ rawsamples[dst].left = ((short *)data)[src*2] * intVolume;
+ rawsamples[dst].right = ((short *)data)[src*2+1] * intVolume;
}
}
}
@@ -959,10 +997,10 @@ void S_Base_RawSamples( int samples, int rate, int width, int s_channels, const
src = i*scale;
if (src >= samples)
break;
- dst = s_rawend&(MAX_RAW_SAMPLES-1);
- s_rawend++;
- s_rawsamples[dst].left = ((short *)data)[src] * intVolume;
- s_rawsamples[dst].right = ((short *)data)[src] * intVolume;
+ dst = s_rawend[stream]&(MAX_RAW_SAMPLES-1);
+ s_rawend[stream]++;
+ rawsamples[dst].left = ((short *)data)[src] * intVolume;
+ rawsamples[dst].right = ((short *)data)[src] * intVolume;
}
}
else if (s_channels == 2 && width == 1)
@@ -974,10 +1012,10 @@ void S_Base_RawSamples( int samples, int rate, int width, int s_channels, const
src = i*scale;
if (src >= samples)
break;
- dst = s_rawend&(MAX_RAW_SAMPLES-1);
- s_rawend++;
- s_rawsamples[dst].left = ((char *)data)[src*2] * intVolume;
- s_rawsamples[dst].right = ((char *)data)[src*2+1] * intVolume;
+ dst = s_rawend[stream]&(MAX_RAW_SAMPLES-1);
+ s_rawend[stream]++;
+ rawsamples[dst].left = ((char *)data)[src*2] * intVolume;
+ rawsamples[dst].right = ((char *)data)[src*2+1] * intVolume;
}
}
else if (s_channels == 1 && width == 1)
@@ -989,15 +1027,15 @@ void S_Base_RawSamples( int samples, int rate, int width, int s_channels, const
src = i*scale;
if (src >= samples)
break;
- dst = s_rawend&(MAX_RAW_SAMPLES-1);
- s_rawend++;
- s_rawsamples[dst].left = (((byte *)data)[src]-128) * intVolume;
- s_rawsamples[dst].right = (((byte *)data)[src]-128) * intVolume;
+ dst = s_rawend[stream]&(MAX_RAW_SAMPLES-1);
+ s_rawend[stream]++;
+ rawsamples[dst].left = (((byte *)data)[src]-128) * intVolume;
+ rawsamples[dst].right = (((byte *)data)[src]-128) * intVolume;
}
}
- if ( s_rawend > s_soundtime + MAX_RAW_SAMPLES ) {
- Com_DPrintf( "S_RawSamples: overflowed %i > %i\n", s_rawend, s_soundtime );
+ if ( s_rawend[stream] > s_soundtime + MAX_RAW_SAMPLES ) {
+ Com_DPrintf( "S_RawSamples: overflowed %i > %i\n", s_rawend[stream], s_soundtime );
}
}
@@ -1274,7 +1312,7 @@ void S_Base_StopBackgroundTrack( void ) {
return;
S_CodecCloseStream(s_backgroundStream);
s_backgroundStream = NULL;
- s_rawend = 0;
+ s_rawend[0] = 0;
}
/*
@@ -1347,12 +1385,12 @@ void S_UpdateBackgroundTrack( void ) {
}
// see how many samples should be copied into the raw buffer
- if ( s_rawend < s_soundtime ) {
- s_rawend = s_soundtime;
+ if ( s_rawend[0] < s_soundtime ) {
+ s_rawend[0] = s_soundtime;
}
- while ( s_rawend < s_soundtime + MAX_RAW_SAMPLES ) {
- bufferSamples = MAX_RAW_SAMPLES - (s_rawend - s_soundtime);
+ while ( s_rawend[0] < s_soundtime + MAX_RAW_SAMPLES ) {
+ bufferSamples = MAX_RAW_SAMPLES - (s_rawend[0] - s_soundtime);
// decide how much data needs to be read from the file
fileSamples = bufferSamples * s_backgroundStream->info.rate / dma.speed;
@@ -1375,7 +1413,7 @@ void S_UpdateBackgroundTrack( void ) {
if(r > 0)
{
// add to raw buffer
- S_Base_RawSamples( fileSamples, s_backgroundStream->info.rate,
+ S_Base_RawSamples( 0, fileSamples, s_backgroundStream->info.rate,
s_backgroundStream->info.width, s_backgroundStream->info.channels, raw, musicVolume );
}
else
@@ -1509,5 +1547,13 @@ qboolean S_Base_Init( soundInterface_t *si ) {
si->SoundInfo = S_Base_SoundInfo;
si->SoundList = S_Base_SoundList;
+#ifdef USE_VOIP
+ si->StartCapture = S_Base_StartCapture;
+ si->AvailableCaptureSamples = S_Base_AvailableCaptureSamples;
+ si->Capture = S_Base_Capture;
+ si->StopCapture = S_Base_StopCapture;
+ si->MasterGain = S_Base_MasterGain;
+#endif
+
return qtrue;
}