diff decoders/mpglib/decode_i386.c @ 279:52b9f37998db

Removed global state variable; should be thread safe now.
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 14 Mar 2002 16:38:59 +0000
parents 9b6e82f7c853
children
line wrap: on
line diff
--- a/decoders/mpglib/decode_i386.c	Thu Mar 14 16:38:32 2002 +0000
+++ b/decoders/mpglib/decode_i386.c	Thu Mar 14 16:38:59 2002 +0000
@@ -17,22 +17,21 @@
 #include "mpg123_sdlsound.h"
 #include "mpglib_sdlsound.h"
 
-extern struct mpstr *gmp;
-
  /* old WRITE_SAMPLE */
 #define WRITE_SAMPLE(samples,sum,clip) \
   if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \
   else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
   else { *(samples) = sum; }
 
-int synth_1to1_mono(real *bandPtr,unsigned char *samples,int *pnt)
+int synth_1to1_mono(real *bandPtr,unsigned char *samples,
+                    int *pnt, struct mpstr *mp)
 {
   short samples_tmp[64];
   short *tmp1 = samples_tmp;
   int i,ret;
   int pnt1 = 0;
 
-  ret = synth_1to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
+  ret = synth_1to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1,mp);
   samples += *pnt;
 
   for(i=0;i<32;i++) {
@@ -46,7 +45,8 @@
 }
 
 
-int synth_1to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
+int synth_1to1(real *bandPtr,int channel,unsigned char *out,
+               int *pnt, struct mpstr *mp)
 {
   static const int step = 2;
   int bo;
@@ -56,16 +56,16 @@
   int clip = 0; 
   int bo1;
 
-  bo = gmp->synth_bo;
+  bo = mp->synth_bo;
 
   if(!channel) {
     bo--;
     bo &= 0xf;
-    buf = gmp->synth_buffs[0];
+    buf = mp->synth_buffs[0];
   }
   else {
     samples++;
-    buf = gmp->synth_buffs[1];
+    buf = mp->synth_buffs[1];
   }
 
   if(bo & 0x1) {
@@ -79,7 +79,7 @@
     dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
   }
 
-  gmp->synth_bo = bo;
+  mp->synth_bo = bo;
   
   {
     register int j;