ekiga r7121 - in trunk: . lib/engine/videoinput/skel
- From: mschneid svn gnome org
- To: svn-commits-list gnome org
- Subject: ekiga r7121 - in trunk: . lib/engine/videoinput/skel
- Date: Sun, 28 Sep 2008 21:25:30 +0000 (UTC)
Author: mschneid
Date: Sun Sep 28 21:25:30 2008
New Revision: 7121
URL: http://svn.gnome.org/viewvc/ekiga?rev=7121&view=rev
Log:
Keep the preview thread for the lifetime of Ekiga.
Windows does not like rapid deletion and recreation of threads.
Modified:
trunk/ChangeLog
trunk/lib/engine/videoinput/skel/videoinput-core.cpp
trunk/lib/engine/videoinput/skel/videoinput-core.h
Modified: trunk/lib/engine/videoinput/skel/videoinput-core.cpp
==============================================================================
--- trunk/lib/engine/videoinput/skel/videoinput-core.cpp (original)
+++ trunk/lib/engine/videoinput/skel/videoinput-core.cpp Sun Sep 28 21:25:30 2008
@@ -51,18 +51,22 @@
{
width = 176;
height = 144;;
+ 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)
@@ -74,17 +78,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);
@@ -96,20 +98,24 @@
void VideoInputCore::VideoPreviewManager::Main ()
{
PWaitAndSignal m(thread_ended);
- thread_created.Signal ();
- if (!frame)
- return;
while (!end_thread) {
- videoinput_core.get_frame_data(frame);
- videooutput_core.set_frame_data(frame, width, height, true, 1);
+ thread_paused.Signal ();
+ run_thread.Wait ();
+
+ while (!pause_thread) {
+ if (frame) {
+ videoinput_core.get_frame_data(frame);
+ 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);
+ }
- // 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: trunk/lib/engine/videoinput/skel/videoinput-core.h
==============================================================================
--- trunk/lib/engine/videoinput/skel/videoinput-core.h (original)
+++ trunk/lib/engine/videoinput/skel/videoinput-core.h Sun Sep 28 21:25:30 2008
@@ -351,8 +351,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]