コード例 #1
0
ファイル: MpBuf.cpp プロジェクト: Konnekt/lib-sipx
MpBufPtr MpBuf_allowMods(MpBufPtr b)
{
   MpBufPtr t;

   if (NULL == b) {
      return NULL;
   }

   if (MpBuf_invalid(b, FALSE, TRUE)) {
      Zprintf("MpBuf_allowMod(0x%X): invalid!\n", (int) b, 0,0,0,0,0);
      return NULL;
   }

   if (1 == b->refCnt) {
      return b;
   }

   t = MpBuf_getBuf(b->pPool, MpBuf_getNumSamples(b),
                    MpBuf_getOffset(b), MpBuf_getFormat(b));

   if (NULL == t) {
      return NULL;
   }

   memcpy((void*) MpBuf_getSamples(t),
          (void*) MpBuf_getSamples(b),
          MpBuf_getByteLen(t));

   MpBuf_setOsTC(t, MpBuf_getOsTC(b));
   MpBuf_setContentLen(t, MpBuf_getContentLen(b));
   MpBuf_delRef(b);
   return t;

} /* MpBuf_allowMods */
コード例 #2
0
ファイル: SpeakerThreadWnt.cpp プロジェクト: mranga/sipxecs
static MpBufPtr conceal(MpBufPtr prev, int concealed)
{
#ifdef XXX_DEBUG_WINDOZE /* [ */
   MpBufPtr ret;
   Sample* src;
   Sample* dst;
   int len;
   int halfLen;
   int i;

   if (NULL == prev) {
      ret = MpBuf_getFgSilence();
      return ret;
   }
   len = MpBuf_getNumSamples(prev);
   ret = MpBuf_getBuf(MpBuf_getPool(prev), len, 0, MpBuf_getFormat(prev));
   src = MpBuf_getSamples(prev);
   dst = MpBuf_getSamples(ret);
   halfLen = (len + 1) >> 1;
   for (i=0; i<halfLen; i++) {
      dst[i] = src[len - i];
   }
   for (i=halfLen; i<len; i++) {
      dst[i] = src[i];
   }
   if (concealed > 2) {
      for (i=0; i<len; i++) {
         dst[i] = dst[i] >> 1; // attenuate
      }
   }
   return ret;
#else /* DEBUG_WINDOZE ] [ */
   return MpBuf_getFgSilence();
#endif /* DEBUG_WINDOZE ] */
}