[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-multimedia
Subject:    [PATCH] mpeglib has less segfaults
From:       Martin Vogt <mvogt () rhrk ! uni-kl ! de>
Date:       2000-08-30 19:55:32
[Download RAW message or body]

Hello,

I was wrong the memleak and segfault was caused by mpeglib
not by artsd.
Ok. This pacth (its huge) fixes this in many cases.
But it still seems that the mp3 decoder produces segfaults
on buggy mp3. 
For "good" mp3 I have tested 10.000 create/destroy cycles
with mpeglibartsplay.

I will commit the patch soon. Its big, but does not _change_
how mpeglib works. Its only a big bugfix.

a.patch is against mpeglib
b.patch for artspluggy



Martin



["a.patch" (text/plain)]

? a.patch
? example/yaf/yafyuv/yaf-yuv
Index: lib/decoder/decoderPlugin.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib/lib/decoder/decoderPlugin.cpp,v
retrieving revision 1.4
diff -u -r1.4 decoderPlugin.cpp
--- lib/decoder/decoderPlugin.cpp	2000/08/29 16:10:32	1.4
+++ lib/decoder/decoderPlugin.cpp	2000/08/30 19:49:52
@@ -419,13 +419,13 @@
     break;
   case _COMMAND_SEEK: {
     if (streamState==_STREAM_STATE_FIRST_INIT) {
-      command->print("ignore command in _STREAM_STATE_FIRST_INIT");
+      command->print("ignore command seek in _STREAM_STATE_FIRST_INIT");
     } else {
       intArg=command->getIntArg();
       cout << "_COMMAND_SEEK:"<<intArg<<endl;
       seek_impl(intArg);
-      break;
     }
+    break;
   }
   case _COMMAND_CLOSE:
     cout << "_COMMAND_CLOSE";
Index: lib/input/bufferInputStream.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib/lib/input/bufferInputStream.cpp,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 bufferInputStream.cpp
--- lib/input/bufferInputStream.cpp	2000/07/04 19:22:09	1.1.1.1
+++ lib/input/bufferInputStream.cpp	2000/08/30 19:49:52
@@ -19,34 +19,29 @@
 				     const char* name) {
   ringBuffer=new SimpleRingBuffer(size,minlinSize);
   leof=false;
-  this->name=name;
   bytePos=0;
   fillgrade=0;
   setUrl(name);
   lLock=false;
   abs_thread_mutex_init(&writeInMut);
-  abs_thread_mutex_init(&resizeMut);
 }
 
 
 BufferInputStream::~BufferInputStream() {
   delete ringBuffer;
   abs_thread_mutex_destroy(&writeInMut);
-  abs_thread_mutex_destroy(&resizeMut);
 }
 
 
-int BufferInputStream::open(const char* name) {
+int BufferInputStream::open(const char*) {
   leof=false;
   setBlocking(true);
-  setUrl(name);
   return true;
 }
 
 void BufferInputStream::close() {
   leof=true;
   setBlocking(false);
-  setUrl(NULL);
 }
 
 int BufferInputStream::eof() {
@@ -81,7 +76,6 @@
   int n=size;
   int canCopy=n;
   char* readPtr;
-  lockResizeBuffer();
   // here we read even if leof is true
   // we make sure that we empty the whole buffer!
   while((eof()==false) && (n > 0)) {
@@ -104,7 +98,6 @@
     fillgrade-=canCopy;
     unlockBuffer();
   }
-  unlockResizeBuffer();
   return i;
 }
 
@@ -199,7 +192,7 @@
 }
 
 
-int BufferInputStream::getFreeWrite() {
+int BufferInputStream::getFreeSpace() {
   return ringBuffer->getFreeWrite();
 }
 
@@ -237,12 +230,10 @@
 
 
 // remote read extension
-int BufferInputStream::readRemote(char* &ptr,int size) {
+int BufferInputStream::readRemote(char** ptr,int size) {
   int n=0;
   char* readPtr;
-  lockResizeBuffer();
   while((eof()==false)) {
-
     n=size;
     ringBuffer->getReadArea(readPtr,n);
     if (n < size){
@@ -254,7 +245,7 @@
     }
     break;
   }
-  ptr=readPtr;
+  *ptr=readPtr;
   return n;
 }
 
@@ -268,7 +259,6 @@
   fillgrade-=bytes;
   unlockBuffer();
   getTimeStamp(bytePos);
-  unlockResizeBuffer();
 }
  
 
@@ -286,23 +276,9 @@
   abs_thread_mutex_unlock(&writeInMut); 
 }
 
-void BufferInputStream::lockResizeBuffer() {
-  abs_thread_mutex_lock(&resizeMut);
-}
-
-
-void BufferInputStream::unlockResizeBuffer() {
-  abs_thread_mutex_unlock(&resizeMut); 
-}
 
 int BufferInputStream::getSize() {
   return ringBuffer->getSize();
 }
  
-void BufferInputStream::resizeBuffer(int changeSize) {
-  lockResizeBuffer();
-  lockBuffer();
-  ringBuffer->resizeBuffer(changeSize);
-  unlockBuffer();
-  unlockResizeBuffer();
-}
+
Index: lib/input/bufferInputStream.h
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib/lib/input/bufferInputStream.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 bufferInputStream.h
--- lib/input/bufferInputStream.h	2000/07/04 19:22:13	1.1.1.1
+++ lib/input/bufferInputStream.h	2000/08/30 19:49:52
@@ -24,14 +24,11 @@
 
   SimpleRingBuffer* ringBuffer;
   int leof;
-  const char* name;
   long bytePos;
   int fillgrade;
   int lLock;
   abs_thread_mutex_t writeInMut;
-  abs_thread_mutex_t resizeMut;
 
-
  public:
   BufferInputStream(int size,int minlinSize,const char* name);
   ~BufferInputStream();
@@ -62,7 +59,7 @@
   int getFillgrade();
   int getSize();
   int getFreeRead();
-  int getFreeWrite();
+  int getFreeSpace();
 
   void clear();
 
@@ -70,7 +67,7 @@
   // Note you _need_ to call always both methods
   // readRemote and forwardReadPtr even if bytes==0!!!
   // (we hold a resizeLock during this operation)
-  int readRemote(char* &ptr,int size);
+  int readRemote(char** ptr,int size);
   void forwardReadPtr(int bytes);
   void setCanWaitForData(int lBlock);
 
@@ -86,10 +83,6 @@
  private:
   void lockBuffer();
   void unlockBuffer();
-
-  void lockResizeBuffer();
-  void unlockResizeBuffer();
-
 
 };
 #endif
Index: lib/input/fileInputStream.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib/lib/input/fileInputStream.cpp,v
retrieving revision 1.2
diff -u -r1.2 fileInputStream.cpp
--- lib/input/fileInputStream.cpp	2000/08/29 16:10:32	1.2
+++ lib/input/fileInputStream.cpp	2000/08/30 19:49:53
@@ -18,12 +18,14 @@
 FileInputStream::FileInputStream() {
   file=NULL;
   lopen=false;
-  name=NULL;
+  fileLen=0;
+  abs_thread_mutex_init(&fileMut);
 }
 
 
 FileInputStream::~FileInputStream() {
   close();
+  abs_thread_mutex_destroy(&fileMut);
 }
 
 
@@ -37,7 +39,9 @@
   setUrl(dest);
   if (strlen(dest) == 1) {
     if (strncmp(dest,"-",1)==0) {
+      lockFile();
       file=::fdopen(0,"r");
+      unlockFile();
     }
   }
   // load out of current dir if no full path is given
@@ -53,30 +57,35 @@
     }
   }
   cout << "open:"<<filename<<endl;
+  lockFile();
   if (file == NULL) {
     file=fopen(filename,"r");
   }
+  fileLen=0;
   if (file == NULL) {
     cout << dest<<endl;
     perror("cannot open file");
   } else {
     lopen=true;
-    name=strdup(filename);
+    struct stat fileStat;
+    stat(filename,&fileStat);
+    fileLen=(long)fileStat.st_size;
   }
+  int back=(file!=NULL);
+  unlockFile();
   delete filename;
-  return (file!=NULL);
+  return back;
 }
 
 
 void FileInputStream::close() {
   if (isOpen()) {
-    delete name;  // correct: allocated with strdup
-    name=NULL;
+    lockFile();
     ::fclose(file);
     file=NULL;
+    unlockFile();
   }
   lopen=false;
-  setUrl(NULL);
 }
 
 
@@ -89,24 +98,37 @@
   if (isOpen()==false){
     return true;
   }
-  return feof(file);
+  int back=true;
+  lockFile();
+  if (file != NULL) {
+    back=feof(file);
+  }
+  unlockFile();
+  return back;
 }
 
 
 int FileInputStream::read(char* ptr,int size) {
-  int bytesRead=0;
+  int bytesRead=-1;
   if (isOpen()) {
     if (size < 0) {
       cout << "size is < 0!"<<endl;
       return 0;
     }
-    bytesRead=fread(ptr, 1,size, file);
+    lockFile();
+    int fd=-1;
+    if (file != NULL) {
+      fd=fileno(file);
+    }
+    bytesRead=::read(fd,ptr,size);
+    unlockFile();
   } else {
     cerr << "read on not open file want:"<<size<<endl;
     return 0;
   }
-  if (bytesRead == 0){
+  if (bytesRead == -1){
     perror("zero bytes fread");
+    bytesRead=0;
   }
   return bytesRead;
 }
@@ -117,8 +139,15 @@
   long pos;
   if (isOpen()==false) {
     return false;
+  }
+  lockFile();
+  int fd=-1;
+  if (file != NULL) {
+    fd=fileno(file);
   }
-  pos=fseek(file, posInBytes,SEEK_SET);
+  pos=lseek(fd,posInBytes,SEEK_SET);
+  unlockFile();
+
   if (pos < 0) {
     perror("seek in setBytePos");
     back=false;
@@ -128,28 +157,36 @@
 
 
 long FileInputStream::getByteLength() {
-  long back=0;
-  if (isOpen()) {
-    struct stat fileStat;
-    stat(name,&fileStat);
-    back=(long)fileStat.st_size;
-  }
-  return back;
+  return fileLen;
 }
 
 
 long FileInputStream::getBytePosition() {
+  int back=0;
   if (isOpen()) {
-    return ftell(file);
+    lockFile();
+    if (file != NULL) {
+      back=ftell(file);
+    }
+    unlockFile();
   }
-  return 0;
+  return back;
 }
 
 
 
 void FileInputStream::print() {
-  printf("pos in file:%8x\n",(int)ftell(file));
+  printf("pos in file:%8x\n",(int)getBytePosition());
+}
+
+
+void FileInputStream::lockFile() {
+  abs_thread_mutex_lock(&fileMut);
 }
 
+
+
+void FileInputStream::unlockFile() {
+  abs_thread_mutex_unlock(&fileMut);
+}
 
- 
Index: lib/input/fileInputStream.h
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib/lib/input/fileInputStream.h,v
retrieving revision 1.2
diff -u -r1.2 fileInputStream.h
--- lib/input/fileInputStream.h	2000/07/27 15:24:54	1.2
+++ lib/input/fileInputStream.h	2000/08/30 19:49:53
@@ -21,11 +21,11 @@
 
 
 class FileInputStream : public InputStream{
-
+  
+  abs_thread_mutex_t fileMut; 
   FILE* file;
   int lopen;
-  char* name;
-  
+  long fileLen;
  public:
   FileInputStream();
   ~FileInputStream();
@@ -42,6 +42,8 @@
   long getBytePosition();
 
   void print();
-
+  void lockFile();
+  void unlockFile();
+  
 };
 #endif
Index: lib/mpegplay/mpegSystemStream.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib/lib/mpegplay/mpegSystemStream.cpp,v
retrieving revision 1.3
diff -u -r1.3 mpegSystemStream.cpp
--- lib/mpegplay/mpegSystemStream.cpp	2000/07/17 15:40:07	1.3
+++ lib/mpegplay/mpegSystemStream.cpp	2000/08/30 19:49:54
@@ -671,6 +671,7 @@
 int MpegSystemStream::processPacketHeader(MpegSystemHeader* mpegHeader) {
   unsigned char nextByte;
   int pos;
+  int val;
   unsigned char scratch[10];
 
 
@@ -681,7 +682,10 @@
   pos = 1;
   while (nextByte & 0x80) {
     ++pos;
-    scratch[0]=getByteDirect();
+    val=getByteDirect();
+    if (val == -1) return false;
+    scratch[0]=val;
+    
     nextByte=scratch[0];
   }
   if ((nextByte >> 6) == 0x01) {
Index: lib/mpgplayer/mpegStreamPlayer.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib/lib/mpgplayer/mpegStreamPlayer.cpp,v
retrieving revision 1.3
diff -u -r1.3 mpegStreamPlayer.cpp
--- lib/mpgplayer/mpegStreamPlayer.cpp	2000/08/06 18:55:20	1.3
+++ lib/mpgplayer/mpegStreamPlayer.cpp	2000/08/30 19:49:55
@@ -44,9 +44,10 @@
      here we set the plugins in autoPlay mode.
      because we handle all commands over the loopback buffer.
   */
+  /*
   audioDecoder->config("-y","on",NULL);
   videoDecoder->config("-y","on",NULL);
-
+  */
 
   audioInput=new BufferInputStream(1024*_BUFFER_CHUNK_SIZE,
 				   1024*200,"audioInput");
Index: lib/output/artsOutputStream.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib/lib/output/artsOutputStream.cpp,v
retrieving revision 1.4
diff -u -r1.4 artsOutputStream.cpp
--- lib/output/artsOutputStream.cpp	2000/08/29 16:10:32	1.4
+++ lib/output/artsOutputStream.cpp	2000/08/30 19:49:55
@@ -33,7 +33,7 @@
   // from /dev/dsp + connected nodes
   // or arts need a video interface
   cout << "buffer"<<endl;
-  stream=new BufferInputStream(privateBufferSize,1024*64,"artsstream");
+  stream=new BufferInputStream(privateBufferSize,1024*64,"artsLoopback");
   cout << "AVSyncer"<<endl;
   avSyncer=new AVSyncer(privateBufferSize);
 
@@ -43,11 +43,15 @@
 
 
 ArtsOutputStream::~ArtsOutputStream() {
+  cout << "~stream"<<endl;
   delete stream;
+  cout << "~audioTime"<<endl;
   delete audioTime;
-
+  cout << "~x11Window"<<endl;
   delete x11Window;
+  cout << "~avSyncer"<<endl;
   delete avSyncer;
+  cout << "~ArtsOutputStream end"<<endl;
 }
 
 
@@ -92,11 +96,8 @@
 
 int ArtsOutputStream::audioPlay(TimeStamp* startStamp,
 				TimeStamp* endStamp,char *buffer, int size) {
-  int write;
+  int write=size;
 
-  if (stream->isOpen()==false) {
-    audioTime->sleepWrite(size);
-  }
 
   // we call this for stream state handling
   OutputStream::audioPlay(startStamp,endStamp,buffer,size);
@@ -106,13 +107,17 @@
   
 
   // here we simulate our own blocking audio device
-  write=stream->write(buffer,size,startStamp);
+  if (stream->isOpen()==false) {
+    audioTime->sleepWrite(size);
+  } else {
+    write=stream->write(buffer,size,startStamp);
+  }
   return write;
 
 }
 
 
-int ArtsOutputStream::read(char* &buffer,int bytes) {
+int ArtsOutputStream::read(char** buffer,int bytes) {
   int back=stream->readRemote(buffer,bytes);
   return back;
 }
Index: lib/output/artsOutputStream.h
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib/lib/output/artsOutputStream.h,v
retrieving revision 1.2
diff -u -r1.2 artsOutputStream.h
--- lib/output/artsOutputStream.h	2000/07/17 15:40:07	1.2
+++ lib/output/artsOutputStream.h	2000/08/30 19:49:56
@@ -104,7 +104,7 @@
 
   // Remote read extension
 
-  int read(char* &buffer,int bytes);
+  int read(char** buffer,int bytes);
   void forwardReadPtr(int bytes);
 
   // buffer control
Index: lib/output/audioData.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib/lib/output/audioData.cpp,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 audioData.cpp
--- lib/output/audioData.cpp	2000/07/04 19:22:14	1.1.1.1
+++ lib/output/audioData.cpp	2000/08/30 19:49:56
@@ -30,6 +30,7 @@
   delete audioTime;
   delete start;
   delete end;
+  delete writeStamp;
 }
  
 
Index: lib/output/audioDataArray.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib/lib/output/audioDataArray.cpp,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 audioDataArray.cpp
--- lib/output/audioDataArray.cpp	2000/07/04 19:22:15	1.1.1.1
+++ lib/output/audioDataArray.cpp	2000/08/30 19:49:56
@@ -24,6 +24,8 @@
   readPos=0;
   writePos=0;
   pcmSum=0;
+  abs_thread_mutex_init(&writeInMut);
+  abs_thread_mutex_init(&changeMut);
 
   audioDataArray=new AudioData*[entries];
 
@@ -35,18 +37,19 @@
   abs_thread_mutex_init(&writeInMut);
   abs_thread_mutex_init(&changeMut);
 
-  
-
 }
 
 AudioDataArray::~AudioDataArray() {
+
   int i;
   for(i=0;i<entries;i++) {
     delete audioDataArray[i];
   } 
+
   delete audioDataArray;
-  abs_thread_mutex_init(&writeInMut);
-  abs_thread_mutex_init(&changeMut);
+
+  abs_thread_mutex_destroy(&writeInMut);
+  abs_thread_mutex_destroy(&changeMut);
 
 }
 
Index: lib/splay/mpegAudioBitWindow.h
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib/lib/splay/mpegAudioBitWindow.h,v
retrieving revision 1.2
diff -u -r1.2 mpegAudioBitWindow.h
--- lib/splay/mpegAudioBitWindow.h	2000/07/27 15:24:55	1.2
+++ lib/splay/mpegAudioBitWindow.h	2000/08/30 19:49:56
@@ -29,7 +29,9 @@
 
 
 #define WINDOWSIZE    4096
+#define BITWINDOWSIZE    (WINDOWSIZE*8)
 
+
 class MpegAudioBitWindow {
 
   int  point,bitindex;
@@ -48,7 +50,7 @@
   int  getbit(void);
   int  getbits9(int bits);
   int  getbits(int bits);
-
+  
 
 };
 #endif
Index: lib/splay/mpegAudioHeader.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib/lib/splay/mpegAudioHeader.cpp,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 mpegAudioHeader.cpp
--- lib/splay/mpegAudioHeader.cpp	2000/07/04 19:22:17	1.1.1.1
+++ lib/splay/mpegAudioHeader.cpp	2000/08/30 19:49:57
@@ -50,6 +50,7 @@
   header[1]=buf[1];
   header[2]=buf[2];
   header[3]=buf[3];
+
   c=buf[1];
   c&=0xf;
   protection=c&1;
@@ -130,7 +131,6 @@
     }
     framesize=(144000*bitrate[version][layer-1][bitrateindex])/freq;
 
-
     if(padding)framesize++;
     if(layer==3) {
       if(version)
@@ -194,3 +194,10 @@
   cout << "MpegAudioHeader [END]:"<<name<<endl;
  
 }
+
+
+
+
+
+
+
Index: lib/splay/mpegAudioStream.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib/lib/splay/mpegAudioStream.cpp,v
retrieving revision 1.2
diff -u -r1.2 mpegAudioStream.cpp
--- lib/splay/mpegAudioStream.cpp	2000/08/29 16:10:32	1.2
+++ lib/splay/mpegAudioStream.cpp	2000/08/30 19:49:57
@@ -102,13 +102,16 @@
   int back=false;
   resetBitIndex();
   if (size >= maxSize) {
+    cout << "size:"<<size<<endl;
     return false;
   }
   if (size < 0) {
+    cout << "size:"<<size<<endl;
     return false;
   }
   back=input->read(getBuffer(),size);
   if (back!=size) {
+    perror("fillbuffer");
     return false;
   }
   if(mpegHeaderInfo->getProtection()==false)   {
Index: lib/splay/mpeglayer3.cc
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib/lib/splay/mpeglayer3.cc,v
retrieving revision 1.3
diff -u -r1.3 mpeglayer3.cc
--- lib/splay/mpeglayer3.cc	2000/08/16 16:35:07	1.3
+++ lib/splay/mpeglayer3.cc	2000/08/30 19:50:00
@@ -241,6 +241,11 @@
 
       gi->part2_3_length       =getbits(12);
       gi->big_values           =getbits(9);
+      if(gi->big_values > 288) {
+	fprintf(stderr,"big_values too large!\n");
+	gi->big_values = 288;
+      }
+
       gi->global_gain          =getbits(8);
       gi->scalefac_compress    =getbits(4);
       gi->window_switching_flag=getbit();
@@ -300,6 +305,11 @@
 
     gi->part2_3_length       =getbits(12);
     gi->big_values           =getbits(9);
+    if(gi->big_values > 288) {
+      fprintf(stderr,"big_values too large!\n");
+      gi->big_values = 288;
+    }
+
     gi->global_gain          =getbits(8);
     gi->scalefac_compress    =getbits(9);
     gi->window_switching_flag=getbit();
@@ -773,10 +783,10 @@
 
     if(h->treelen) {
       while(i<end)
-      {
-	huffmandecoder_1(h,&out[0][i],&out[0][i+1]);
-	i+=2;
-      }
+	{
+	  huffmandecoder_1(h,&out[0][i],&out[0][i+1]);
+	  i+=2;
+	}
     } else {
       for(;i<end;i+=2)
 	out[0][i]  =
@@ -1752,12 +1762,14 @@
     {
       int  is      [SBLIMIT][SSLIMIT];
       REAL hin  [2][SBLIMIT][SSLIMIT];
+      REAL  secureSpace1 [4][SBLIMIT][SSLIMIT];
     }b1;
     union
     {
       REAL ro   [2][SBLIMIT][SSLIMIT];
       REAL lr   [2][SBLIMIT][SSLIMIT];
       REAL hout [2][SSLIMIT][SBLIMIT];
+      REAL  secureSpace2 [4][SBLIMIT][SSLIMIT];
     }b2;
 
     layer3part2start=bitwindow.gettotalbit();
Index: lib/splay/mpegtoraw.cc
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib/lib/splay/mpegtoraw.cc,v
retrieving revision 1.4
diff -u -r1.4 mpegtoraw.cc
--- lib/splay/mpegtoraw.cc	2000/08/06 18:55:20	1.4
+++ lib/splay/mpegtoraw.cc	2000/08/30 19:50:00
@@ -84,6 +84,8 @@
 
   delete bufferInputStream;
   delete lastAudioStamp;
+  delete commandPipe;
+  
 }
 
 
@@ -160,7 +162,10 @@
   // the kernel schedular
 
 #ifdef PTHREADEDMPEG
-  while(bufferInputStream->getFreeWrite() < rawdataoffset*2) {
+  int freeWrite=bufferInputStream->getFreeSpace();
+
+  while(freeWrite < rawdataoffset*2) {
+    freeWrite=bufferInputStream->getFreeSpace();
     dosleep(10000);
   }
   
Index: lib/splay/splayPlugin.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib/lib/splay/splayPlugin.cpp,v
retrieving revision 1.4
diff -u -r1.4 splayPlugin.cpp
--- lib/splay/splayPlugin.cpp	2000/08/29 16:10:32	1.4
+++ lib/splay/splayPlugin.cpp	2000/08/30 19:50:00
@@ -82,7 +82,7 @@
       cout << "_STREAM_STATE_FIRST_INIT"<<endl;
       if (mpegAudioStream->firstInitialize(currentHeader)==false) {
       } else {
-	
+	cout << "splay has init"<<endl;
 	server = new Mpegtoraw(mpegAudioStream,currentHeader,output);
 	server->setdownfrequency(downSampleFlag);
 	server->setforcetomono(monoFlag);

["b.patch" (text/plain)]

? b.diff
? mvogt@aixd1.rhrk.uni-kl.de
? decoderBaseObject.h
? decoderBaseObject.cc
? b.patch
Index: Makefile.am
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib_artsplug/Makefile.am,v
retrieving revision 1.4
diff -u -r1.4 Makefile.am
--- Makefile.am	2000/07/10 14:14:02	1.4
+++ Makefile.am	2000/08/30 19:53:25
@@ -51,11 +51,11 @@
 
 
 libarts_mpeglib_la_SOURCES	=	$(BUILT_SOURCES) \
+					decoderBaseObject_impl.cpp \
 					oggPlayObject_impl.cpp \
 					mpgPlayObject_impl.cpp \
 					wavPlayObject_impl.cpp \
-					mp3PlayObject_impl.cpp \
-					decoderBaseObject_impl.cpp 
+					mp3PlayObject_impl.cpp
 
 
 libarts_mpeglib_la_LDFLAGS	=	$(all_libraries) \
@@ -81,6 +81,9 @@
 					-lkmedia2_idl \
 					-lartsflow_idl \
 					-lmcop
+
+
+
 
 
 
Index: decoderBaseObject_impl.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib_artsplug/decoderBaseObject_impl.cpp,v
retrieving revision 1.11
diff -u -r1.11 decoderBaseObject_impl.cpp
--- decoderBaseObject_impl.cpp	2000/08/29 17:12:42	1.11
+++ decoderBaseObject_impl.cpp	2000/08/30 19:53:26
@@ -12,6 +12,7 @@
 
 #include "decoderBaseObject_impl.h"
 #include "../mpeglib/lib/decoder/decoderPlugin.h"
+#include "../mpeglib/lib/splay/splayPlugin.h"
 
 // define this to run the playobject without the
 // arts backend. (usefull to check if a bug is in arts or mpeglib)
@@ -40,26 +41,28 @@
 DecoderBaseObject_impl::~DecoderBaseObject_impl() {
   cout << "~DecoderBaseObject_impl -s"<<endl;
   shudownPlugins();
-  if (outputStream != NULL) {
-    cout << "delete outputStream"<<endl;
-    delete outputStream;
-    outputStream=NULL;
-  }
+
   if (decoderPlugin != NULL) {
     cout << "delete decoderPlugin"<<endl;
     delete decoderPlugin;
     decoderPlugin=NULL;
   }
+  if (outputStream != NULL) {
+    cout << "delete outputStream"<<endl;
+    delete outputStream;
+    outputStream=NULL;
+  }
 }
 
 
 DecoderPlugin* DecoderBaseObject_impl::createPlugin() {
   cout << "direct virtual call DecoderBaseObject_impl::getPlugin"<<endl;
   exit(0);
+  return NULL;
 }
 
 
-InputStream* DecoderBaseObject_impl::createInputStream(char* url) {
+InputStream* DecoderBaseObject_impl::createInputStream(const char* url) {
   InputStream* back=InputPlugin::createInputStream(url);
   return back;
 }
@@ -93,12 +96,13 @@
   return true;
 #endif
 
-  inputStream=createInputStream((char *)filename.c_str());
+  inputStream=createInputStream(filename.c_str());
 
   // the plugin does not open the stream!
   // we do it.
   back=inputStream->open((char*)filename.c_str());
   setStreamState(_THREADSTATE_OPENED);
+
   // we are still in posIdle here
   outputStream->audioOpen();
 
@@ -139,7 +143,6 @@
   time.seconds=(long)(currentTime);
   time.ms=(long) (1000.0*(currentTime-(float)time.seconds));
   cout << "currentTime :"<<time.seconds<<endl;
-
   return time;
 }
 
@@ -280,10 +283,10 @@
     outputStream->setAudioBufferSize(bufferSize);
   }
   if(_state == posPlaying) {
-    /*
-     * since the samplingrate of the MP3 and the samplingrate of the output
-     * device (soundcard) are not necessarily the same, it's a bit tricky
-     */
+    //
+    // since the samplingrate of the MP3 and the samplingrate of the output
+    // device (soundcard) are not necessarily the same, it's a bit tricky
+    //
     
     // calculate "how fast" we consume input samples (2.0 means, we need 2
     // input samples to generate one output sample)
@@ -296,13 +299,8 @@
 
     // convert that into bytes and try to read that many bytes
     wantBytes=(int) (wantWavSamples*byteMultiplikator);
-    hasBytes=outputStream->read(buffer,wantBytes);
+    hasBytes=outputStream->read(&buffer,wantBytes);
 
-    /*
-    if (flpos != 0.0) {
-      cout << "flpos:"<<flpos<<endl;
-    }
-    */
     // convert those bytes into the suitable output form
     haveSamples = uni_convert_stereo_2float(samples, (unsigned char *)buffer,
 					    hasBytes, wav_channelCount, 
@@ -338,10 +336,10 @@
   return samples;
 }
 
-
 void DecoderBaseObject_impl::calculateBlock(unsigned long samples,
 					    float* left , float* right) {
 
+
 #ifndef _STRIP_ZERO  
 
   int audioState=outputStream->waitStreamState(_OUTPUT_WAIT_METHOD_POLL,
@@ -425,14 +423,6 @@
   // because of the asyncCommand above.
   if (decoderPlugin != NULL) {
     decoderPlugin->close();
-  }
-
-  // as long as the decoder is not delete
-  // we cannot close the Window!!!!
-  // this demonstrate that it even works _with_ closing the window
-  // (I hacked it for convinience)
-  if (outputStream != NULL) {
-    outputStream->closeWindow();
   }
 
 
Index: decoderBaseObject_impl.h
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib_artsplug/decoderBaseObject_impl.h,v
retrieving revision 1.5
diff -u -r1.5 decoderBaseObject_impl.h
--- decoderBaseObject_impl.h	2000/08/24 14:52:09	1.5
+++ decoderBaseObject_impl.h	2000/08/30 19:53:26
@@ -37,10 +37,11 @@
 class InputStream;
 class ArtsOutputStream;
 
+
 using namespace std;
 using namespace Arts;
 
-class DecoderBaseObject_impl:
+class DecoderBaseObject_impl :
   virtual public Arts::StdSynthModule,
   virtual public DecoderBaseObject_skel {
 
@@ -61,7 +62,7 @@
   virtual ~DecoderBaseObject_impl();
 
   virtual DecoderPlugin* createPlugin();
-  virtual InputStream* createInputStream(char* url);
+  virtual InputStream* createInputStream(const char* url);
 
   bool loadMedia(const string &filename);
   string description();
Index: mpeglibartsplay.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/mpeglib_artsplug/mpeglibartsplay.cpp,v
retrieving revision 1.5
diff -u -r1.5 mpeglibartsplay.cpp
--- mpeglibartsplay.cpp	2000/08/29 17:12:42	1.5
+++ mpeglibartsplay.cpp	2000/08/30 19:53:26
@@ -165,7 +165,6 @@
       *play3=server->createPlayObject(filename1);
     }
     play3->play();
-    usleep(1000);
     Arts::poTime l_t_zero(0,0,0,"samples");
     play3->seek(l_t_zero);
 

_______________________________________________
Kde-multimedia mailing list
Kde-multimedia@master.kde.org
http://master.kde.org/mailman/listinfo/kde-multimedia


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic