wrong codec initialization in AmAudioFileFormat cunstructor for non Wav
Mu-law files:

1. AmAudioFileFormat inherits AmAudioFormat
2. there is no explicit AmAudioFormat constructor call in
AmAudioFileFormat that's why it is called with default parameters:
   codec_id = CODEC_PCM16,
   unsigned int rate = SYSTEM_SAMPLECLOCK_RATE
3. AmAudioFormat constructor initializes CODEC_PCM16
4. AmAudioFileFormat constructor calls getCodec(), but codec already
initialized

result: uninitialized codec and wrong codec_id for non Wav Mu-law files

patch in attach ensures consistency between p_subtype codec_id and
active codec_id

-- 
Best Regards
Michael Furmur
diff --git a/core/AmAudioFile.cpp b/core/AmAudioFile.cpp
index 6f7c9f3..32bc6ed 100644
--- a/core/AmAudioFile.cpp
+++ b/core/AmAudioFile.cpp
@@ -44,6 +44,15 @@ AmAudioFileFormat::AmAudioFileFormat(const string& name, int subtype)
   } 
 }
 
+amci_codec_t* AmAudioFileFormat::getCodec()
+{
+  if(p_subtype && p_subtype->codec_id != codec_id){
+    codec_id = p_subtype->codec_id;
+    destroyCodec();
+  }
+  return AmAudioFormat::getCodec();
+}
+
 void AmAudioFileFormat::setSubtypeId(int subtype_id)  { 
   if (subtype != subtype_id) {
     DBG("changing file subtype to ID %d\n", subtype_id);
diff --git a/core/AmAudioFile.h b/core/AmAudioFile.h
index daecf8b..3a06c56 100644
--- a/core/AmAudioFile.h
+++ b/core/AmAudioFile.h
@@ -57,6 +57,8 @@ public:
 
   virtual ~AmAudioFileFormat()  { }
 
+  virtual amci_codec_t* getCodec();
+
   /** @return Format name. */
   string        getName() { return name; }
   /** @return Format subtype. */

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to