Module: sems
Branch: master
Commit: b4a78f53256bf9372df3f22c4e039e7cf63a0223
URL: 
https://github.com/sems-server/sems/commit/b4a78f53256bf9372df3f22c4e039e7cf63a0223

Author: Stefan Sayer <stefan.sa...@googlemail.com>
Committer: Stefan Sayer <stefan.sa...@googlemail.com>
Date: 2015-06-09T00:11:30+02:00

core:advanced_audio:mixin: allow generic AmAudio for mixin

---

Modified: core/AmAudioMixIn.cpp
Modified: core/AmAudioMixIn.h

---

Diff:  
https://github.com/sems-server/sems/commit/b4a78f53256bf9372df3f22c4e039e7cf63a0223.diff
Patch: 
https://github.com/sems-server/sems/commit/b4a78f53256bf9372df3f22c4e039e7cf63a0223.patch

---

diff --git a/core/AmAudioMixIn.cpp b/core/AmAudioMixIn.cpp
index 4bfa782..7f35077 100644
--- a/core/AmAudioMixIn.cpp
+++ b/core/AmAudioMixIn.cpp
@@ -30,7 +30,7 @@
 #define IS_ONLY_ONCE       (flags & AUDIO_MIXIN_ONCE)
 #define IS_IMMEDIATE_START (flags & AUDIO_MIXIN_IMMEDIATE_START)
 
-AmAudioMixIn::AmAudioMixIn(AmAudio* A, AmAudioFile* B, 
+AmAudioMixIn::AmAudioMixIn(AmAudio* A, AmAudio* B, 
                           unsigned int s, double l,
                           unsigned int flags) 
   :   A(A),B(B), s(s), l(l), 
@@ -71,10 +71,14 @@ int AmAudioMixIn::get(unsigned long long system_ts, 
unsigned char* buffer,
       if (res <= 0) { // B empty
        res = A->get(system_ts, buffer, output_sample_rate, nb_samples);
        mixing = false;
-       if (IS_ONLY_ONCE)
+       if (IS_ONLY_ONCE) {
          B = NULL;
-       else
-         B->rewind();
+       } else {
+         AmAudioFile* B_file = dynamic_cast<AmAudioFile*>(B);
+         if (NULL != B_file) {
+           B_file->rewind();
+         }
+       }
       }
       B_mut.unlock();
       return  res;
@@ -110,10 +114,14 @@ int AmAudioMixIn::get(unsigned long long system_ts, 
unsigned char* buffer,
       if (len<0) { // B finished
        mixing = false;
        
-       if (IS_ONLY_ONCE)
+       if (IS_ONLY_ONCE) {
          B = NULL;
-       else
-         B->rewind();
+       } else {
+         AmAudioFile* B_file = dynamic_cast<AmAudioFile*>(B);
+         if (NULL != B_file) {
+           B_file->rewind();
+         }
+       }
       } else {
        for (int i=0; i<(PCM16_B2S(len)); i++)  {
          pdest[i]+=(short)(((double)mix_buf[i])*l);
@@ -135,7 +143,7 @@ int AmAudioMixIn::put(unsigned long long system_ts, 
unsigned char* buffer,
   return -1;
 }
 
-void AmAudioMixIn::mixin(AmAudioFile* f) {
+void AmAudioMixIn::mixin(AmAudio* f) {
   B_mut.lock();
   B = f;
   mixing = next_start_ts_i = false; /* so that mix in will re-start */
diff --git a/core/AmAudioMixIn.h b/core/AmAudioMixIn.h
index 59b57d2..e8bfdb8 100644
--- a/core/AmAudioMixIn.h
+++ b/core/AmAudioMixIn.h
@@ -52,7 +52,7 @@
 
 class AmAudioMixIn : public AmAudio {
   AmAudio* A;
-  AmAudioFile* B;
+  AmAudio* B;
   unsigned int s;
   double l;
   int flags;
@@ -68,12 +68,12 @@ class AmAudioMixIn : public AmAudio {
 
 
  public:
-  AmAudioMixIn(AmAudio* A, AmAudioFile* B, 
+  AmAudioMixIn(AmAudio* A, AmAudio* B, 
               unsigned int s, double l, 
               unsigned int flags = 0);
   ~AmAudioMixIn();
 
-  void mixin(AmAudioFile* f);
+  void mixin(AmAudio* f);
 
  protected:
   // not used

_______________________________________________
Semsdev mailing list
Semsdev@lists.iptel.org
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to