Re: [Ekiga-devel-list] Win32 Opal datasize, please help



Damien Sandras schrieb:
Michael,

Le mercredi 15 juillet 2009 à 21:47 +0200, Michael Rickmann a écrit :

[...]

[...]

This patch should fix the problem:
http://opalvoip.svn.sourceforge.net/viewvc/opalvoip?view=rev&revision=23106

However, I'm not sure any patch is still required in Ekiga.
In any case, I will probably remove the check for the read/expected data
in Ekiga.

But first, could you test the above patch without any modification in
Ekiga and tell me if it works better ?

Thank you,

PS: the above patch is for TRUNK, not STABLE, but it should be
backported easily.

Last night I was fooling myself after having taken out all patches.
I applied the Opal commit as a patch to Ekiga stable (attached for easier reference). Apparently Opal respects now what we have read and continues until it has all the data it wants. The first test without patch to Ekiga resulted in piling up Windows again. So I made a new patch (ekiga_framesize.diff, attached) which is far less obtrusive than the last one. It reutilizes expectedFrameSize which was unused in Ekiga to do a bit of checking, though it may have different semantics now. We have to check for data != 0 and size != 0 as Opal may send that through. The Ekiga::Runtime::run_in_main...AI_ERROR_READ we certainly do not want for Win32. The overall result is really good. Audio latency when calling 500 ekiga net is small, less than 1/2 sec. Video is almost simultaneous when tapping the microphone. At least I could not determine whether it was faster or slower than audio.
Thanks for your help.
Michael
diff -x .svn -ur opal-23105/src/opal/mediastrm.cxx opal-23106/src/opal/mediastrm.cxx
--- opal-23105/src/opal/mediastrm.cxx	2009-07-17 07:30:33.000000000 +0200
+++ opal-23106/src/opal/mediastrm.cxx	2009-07-17 14:57:42.000000000 +0200
@@ -740,13 +740,21 @@
   if (!IsOpen() || m_channel == NULL)
     return false;
 
-  if (!m_channel->Read(buffer, size))
-    return false;
+  if (buffer == NULL || size == 0)
+    return m_channel->Read(buffer, size);
+
+  while (size > 0) {
+    if (!m_channel->Read(buffer, size))
+      return false;
+
+    PINDEX lastReadCount = m_channel->GetLastReadCount();
+    CollectAverage(buffer, lastReadCount);
 
-  length = m_channel->GetLastReadCount();
+    buffer += lastReadCount;
+    length += lastReadCount;
+    size -= lastReadCount;
+  }
 
-  if (buffer != NULL)
-    CollectAverage(buffer, length);
 
   return true;
 }
diff -ur ekiga-3.2.5.orig/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp ekiga-3.2.5/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp
--- ekiga-3.2.5.orig/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp	2009-07-17 17:07:45.000000000 +0200
+++ ekiga-3.2.5/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp	2009-07-17 17:10:39.000000000 +0200
@@ -160,8 +160,10 @@
 {
   PTRACE(4, "GMAudioInputManager_ptlib\tSetting buffer size to " << buffer_size << "/" <<  num_buffers);
 
-  if (input_device)
+  if (input_device) {
     input_device->SetBuffers (buffer_size, num_buffers);
+    expectedFrameSize = buffer_size;
+  }
 }
 
 
@@ -172,6 +174,11 @@
   bool ret = false;
   bytes_read = 0;
 
+  if (data == NULL || size == 0) {
+    PTRACE(1, "GMAudioInputManager_ptlib\tError, will not read " << size << " bytes to buffer at " << data);
+    return false;
+  }
+
   if (!current_state.opened) {
     PTRACE(1, "GMAudioInputManager_ptlib\tTrying to get frame from closed device");
     return false;
@@ -182,9 +189,11 @@
     if (ret) {
       bytes_read = input_device->GetLastReadCount();
     }
-    if (bytes_read != size) {
-      PTRACE(1, "GMAudioInputManager_ptlib\tEncountered error while trying to read data");
+    if (bytes_read < expectedFrameSize) {
+      PTRACE(1, "GMAudioInputManager_ptlib\tError while trying to read data, read " << bytes_read << " instead of expected " << expectedFrameSize);
+#ifndef WIN32
       Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this, &GMAudioInputManager_ptlib::device_error_in_main), current_state.device, Ekiga::AI_ERROR_READ));
+#endif
     }
   }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]