Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Dec 2007 21:06:23 +0000
From:      Sergio Lenzi <lenzi.sergio@gmail.com>
To:        usleepless@gmail.com, questions@freebsd.org
Subject:   Re: Ekiga runs but hangs
Message-ID:  <1198875983.1311.11.camel@localhost>
In-Reply-To: <c39ec84c0712280317r42d1f218yb3c491645f09f3d6@mail.gmail.com>
References:  <c39ec84c0712280317r42d1f218yb3c491645f09f3d6@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

Em Sex, 2007-12-28 às 12:17 +0100, usleepless@gmail.com escreveu:

> Hello All,
> 
> is anyone using ekiga? ekiga runs and connects to 500@ekiga.net ( test number ).
> 
> but when i hang up, or change volume using the ekiga-controls, the UI freezes.
> 
> #FreeBSD host 7.0-BETA2 FreeBSD 7.0-BETA2 #4
> 
> i would love to hear succes or failures.
> 
> regards,
> 
> usleep

it happens with me too. the problem is in the
module sound-oss in the pwlib 
the module that deals with oss (the freebsd sound system...) 
tries to resample the stream and than loops... consuming all the cpu.

the folowing patch solves the problem for me....
name this file to patch-oss and put it in /usr/ports/devel/pwlib/files
and than... cd /usr/ports/devel/pwlib 
make clean deinstall package

=========================================================
--- plugins/sound_oss/sound_oss.cxx.orig	
+++plugins/sound_oss/sound_oss.cxx	
@@ -565,7 +565,6 @@
     entry->bitsPerSample = mBitsPerSample   = _bitsPerSample;
     entry->isInitialised = FALSE;
     entry->fragmentValue = 0x7fff0008;
-    entry->resampleRate  = 0;
   }
    
   // save the direction and device
@@ -602,7 +601,6 @@
   // do not re-initialise initialised devices
   if (entry.isInitialised) {
     PTRACE(6, "OSS\tSkipping setup for " << device << " as already
initialised");
-    resampleRate = entry.resampleRate;
 
   } else {
     PTRACE(6, "OSS\tInitialising " << device << "(" << (void *)(&entry)
<< ")");
@@ -646,17 +644,6 @@
           arg = val = entry.sampleRate;
           if (ConvertOSError(::ioctl(os_handle, SNDCTL_DSP_SPEED,
&arg))) {
             stat = TRUE;
-
-            // detect cases where the hardware can't do the actual rate
we need, but can do a simple multiple
-            if (arg != (int)entry.sampleRate) {
-              if (((arg / entry.sampleRate) * entry.sampleRate) ==
(unsigned)arg) {
-                PTRACE(3, "Resampling data at " << entry.sampleRate <<
" to match hardware rate of " << arg);
-                resampleRate = entry.resampleRate = arg /
entry.sampleRate;
-              } else {
-                PTRACE_IF(4, actualSampleRate != (unsigned)val, "Actual
sample rate selected is " << actualSampleRate << ", not " <<
entry.sampleRate);
-                actualSampleRate = arg;
-              }
-            }
           }
         }
       }
@@ -724,42 +711,10 @@
   if (!Setup() || os_handle < 0)
     return FALSE;
 
-  if (resampleRate == 0) {
-    while (!ConvertOSError(::write(os_handle, (void *)buf, len))) 
-      if (GetErrorCode() != Interrupted)
-        return FALSE;
-    lastWriteCount += len;
-  }
-
-  else {
-    // cut the data into 1K blocks and upsample it
-    lastWriteCount = 0;
-    BYTE resampleBuffer[1024];
-    const BYTE * src    = (const BYTE *)buf;
-    const BYTE * srcEnd = src + len;
-    while (src < srcEnd) {
-
-      // expand the data by the appropriate sample ratio
-      BYTE * dst = resampleBuffer;
-      const BYTE * srcStart = src;
-      unsigned j;
-       
-      while ((src < srcEnd) && (dst < (resampleBuffer +
sizeof(resampleBuffer) - resampleRate*2))) {
-        for (j = 0; j < resampleRate; ++j) {
-          memcpy(dst, src, 2);
-          dst += 2 ;
-        }
-        src += 2;
-      }
-      lastWriteCount += src - srcStart;
-      while (!ConvertOSError(::write(os_handle, resampleBuffer, dst -
resampleBuffer))) {
-        if (GetErrorCode() != Interrupted) 
-          return FALSE;
-      }
-    }
-
-  }
-
+  while (!ConvertOSError(::write(os_handle, (void *)buf, len))) 
+    if (GetErrorCode() != Interrupted)
+      return FALSE;
+  lastWriteCount += len;
   return TRUE;
 }
 
@@ -770,72 +725,26 @@
   if (!Setup() || os_handle < 0)
     return FALSE;
 
-  if (resampleRate == 0) {
-
-    PINDEX total = 0;
-    while (total < len) {
-      PINDEX bytes = 0;
-      while (!ConvertOSError(bytes = ::read(os_handle, (void
*)(((unsigned char *)buf) + total), len-total))) {
-        if (GetErrorCode() != Interrupted) {
-          PTRACE(6, "OSS\tRead failed");
-          return FALSE;
-        }
-        PTRACE(6, "OSS\tRead interrupted");
-      }
-      total += bytes;
-      if (total != len)
-        PTRACE(6, "OSS\tRead completed short - " << total << " vs " <<
len << ". Reading more data");
-    }
-    lastReadCount = total;
-  }
-
-  else {
-
-    // downsample the data
-
-    BYTE * dst    = (BYTE *)buf;
-    BYTE * dstEnd = dst + len;
-    lastReadCount = 0;
-
-    PBYTEArray resampleBuffer((1024 / resampleRate) * resampleRate);
-
-    // downsample the data into 1K blocks 
-    while (dst < dstEnd) {
-
-
-      // calculate number of source bytes needed to fill the buffer
-      PINDEX srcBytes = resampleRate * (dstEnd - dst);
-      PINDEX bytes;
-
-      {
-        PINDEX bufLen = PMIN(resampleBuffer.GetSize(), srcBytes);
-        while (!ConvertOSError(bytes = ::read(os_handle,
resampleBuffer.GetPointer(), bufLen))) {
-          if (GetErrorCode() != Interrupted) 
-            return FALSE;
-        }
-      }
-
-      // use an average, not just a single sample
-      const BYTE * src = resampleBuffer;
-      while ( ((src - resampleBuffer) < bytes) && (dst < dstEnd)) {
-        int sample = 0;
-        unsigned j;
-        for (j = 0; j < resampleRate; ++j) {
-          sample += *(PUInt16l *)src;
-          src += 2;
-        }
-        *(PUInt16l *)dst = sample / resampleRate;
-        dst +=2 ;
-        lastReadCount += 2;
+  PINDEX total = 0;
+  while (total < len) {
+    PINDEX bytes = 0;
+    while (!ConvertOSError(bytes = ::read(os_handle, (void
*)(((unsigned char *)buf) + total), len-total))) {
+      if (GetErrorCode() != Interrupted) {
+        PTRACE(6, "OSS\tRead failed");
+        return FALSE;
       }
+      PTRACE(6, "OSS\tRead interrupted");
     }
+    total += bytes;
+    if (total != len)
+      PTRACE(6, "OSS\tRead completed short - " << total << " vs " <<
len << ". Reading more data");
   }
+  lastReadCount = total;
 
   if (lastReadCount != len)
     PTRACE(6, "OSS\tRead completed short - " << lastReadCount << " vs "
<< len);
   else
     PTRACE(6, "OSS\tRead completed");
-
   return TRUE;
 }
 
--- plugins/sound_oss/sound_oss.h.orig	2007-12-03 03:31:15.000000000
+0000
+++ plugins/sound_oss/sound_oss.h	2007-12-03 03:31:29.000000000 +0000
@@ -42,7 +42,6 @@
     unsigned bitsPerSample;
     unsigned fragmentValue;
     BOOL isInitialised;
-    unsigned resampleRate;
 };
 
 class PSoundChannelOSS: public PSoundChannel
@@ -99,5 +98,4 @@
     Directions direction;
     PString device;
     BOOL isInitialised;
-    unsigned resampleRate;
 };
=============================================================



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1198875983.1311.11.camel>