ekiga r7120 - in branches/gnome-2-24: . lib/engine/videoinput/skel
- From: mschneid svn gnome org
- To: svn-commits-list gnome org
- Subject: ekiga r7120 - in branches/gnome-2-24: . lib/engine/videoinput/skel
- Date: Sun, 28 Sep 2008 21:23:50 +0000 (UTC)
Author: mschneid
Date: Sun Sep 28 21:23:50 2008
New Revision: 7120
URL: http://svn.gnome.org/viewvc/ekiga?rev=7120&view=rev
Log:
Keep the preview thread for the lifetime of Ekiga.
Windows does not like rapid deletion and recreation of threads.
Modified:
branches/gnome-2-24/ChangeLog
branches/gnome-2-24/NEWS
branches/gnome-2-24/lib/engine/videoinput/skel/videoinput-core.cpp
branches/gnome-2-24/lib/engine/videoinput/skel/videoinput-core.h
Modified: branches/gnome-2-24/NEWS
==============================================================================
--- branches/gnome-2-24/NEWS (original)
+++ branches/gnome-2-24/NEWS Sun Sep 28 21:23:50 2008
@@ -1,4 +1,5 @@
Changes since Ekiga 3.00
+- Keep the preview thread for the lifetime of Ekiga. Windows does not like rapid deletion and recreation of threads.
- Fix flickering of PIP on windows.
- Fix possible X timing issue
- Fix message box when device was unplugged in out-of-call state (#552262)
Modified: branches/gnome-2-24/lib/engine/videoinput/skel/videoinput-core.cpp
==============================================================================
--- branches/gnome-2-24/lib/engine/videoinput/skel/videoinput-core.cpp (original)
+++ branches/gnome-2-24/lib/engine/videoinput/skel/videoinput-core.cpp Sun Sep 28 21:23:50 2008
@@ -49,18 +49,22 @@
videoinput_core (_videoinput_core),
videooutput_core (_videooutput_core)
{
+ pause_thread = true;
end_thread = false;
frame = NULL;
// Since windows does not like to restart a thread that
// was never started, we do so here
this->Resume ();
- PWaitAndSignal m(thread_ended);
+ thread_paused.Wait();
}
VideoInputCore::VideoPreviewManager::~VideoPreviewManager ()
{
- if (!end_thread)
+ if (!pause_thread)
stop();
+ end_thread = true;
+ run_thread.Signal();
+ thread_ended.Wait();
}
void VideoInputCore::VideoPreviewManager::start (unsigned width, unsigned height)
@@ -70,17 +74,15 @@
frame = (char*) malloc (unsigned (width * height * 3 / 2));
videooutput_core.start();
- this->Restart ();
- thread_created.Wait ();
+ pause_thread = false;
+ run_thread.Signal();
}
void VideoInputCore::VideoPreviewManager::stop ()
{
PTRACE(4, "PreviewManager\tStopping Preview");
- end_thread = true;
-
- /* Wait for the Main () method to be terminated */
- PWaitAndSignal m(thread_ended);
+ pause_thread = true;
+ thread_paused.Wait();
if (frame) {
free (frame);
@@ -92,22 +94,24 @@
void VideoInputCore::VideoPreviewManager::Main ()
{
PWaitAndSignal m(thread_ended);
- thread_created.Signal ();
- if (!frame)
- return;
-
unsigned width = 176;
unsigned height = 144;;
while (!end_thread) {
- videoinput_core.get_frame_data(frame, width, height);
- videooutput_core.set_frame_data(frame, width, height, true, 1);
+ thread_paused.Signal ();
+ run_thread.Wait ();
- // We have to sleep some time outside the mutex lock
- // to give other threads time to get the mutex
- // It will be taken into account by PAdaptiveDelay
- Current()->Sleep (5);
+ while (!pause_thread) {
+ if (frame) {
+ videoinput_core.get_frame_data(frame, width, height);
+ videooutput_core.set_frame_data(frame, width, height, true, 1);
+ }
+ // We have to sleep some time outside the mutex lock
+ // to give other threads time to get the mutex
+ // It will be taken into account by PAdaptiveDelay
+ Current()->Sleep (5);
+ }
}
}
Modified: branches/gnome-2-24/lib/engine/videoinput/skel/videoinput-core.h
==============================================================================
--- branches/gnome-2-24/lib/engine/videoinput/skel/videoinput-core.h (original)
+++ branches/gnome-2-24/lib/engine/videoinput/skel/videoinput-core.h Sun Sep 28 21:23:50 2008
@@ -358,8 +358,10 @@
char* frame;
bool end_thread;
+ bool pause_thread;
PMutex thread_ended;
- PSyncPoint thread_created;
+ PSyncPoint thread_paused;
+ PSyncPoint run_thread;
VideoInputCore & videoinput_core;
VideoOutputCore & videooutput_core;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]