ekiga r7392 - in trunk: lib/engine/audioinput/null lib/engine/audioinput/ptlib lib/engine/audiooutput/null lib/engine/audiooutput/ptlib lib/engine/components/opal lib/engine/gui/gtk-core lib/engine/videoinput/mlogo lib/engine/videoinput/ptlib lib/engine/videooutput/common lib/gmref src/devices src/gui
- From: jpuydt svn gnome org
- To: svn-commits-list gnome org
- Subject: ekiga r7392 - in trunk: lib/engine/audioinput/null lib/engine/audioinput/ptlib lib/engine/audiooutput/null lib/engine/audiooutput/ptlib lib/engine/components/opal lib/engine/gui/gtk-core lib/engine/videoinput/mlogo lib/engine/videoinput/ptlib lib/engine/videooutput/common lib/gmref src/devices src/gui
- Date: Thu, 20 Nov 2008 21:36:31 +0000 (UTC)
Author: jpuydt
Date: Thu Nov 20 21:36:31 2008
New Revision: 7392
URL: http://svn.gnome.org/viewvc/ekiga?rev=7392&view=rev
Log:
Modified gmref's code : store the reference within each object and make gmref_ptr only require the base class to have reference/unreference methods : should be lighter
Modified:
trunk/lib/engine/audioinput/null/audioinput-manager-null.cpp
trunk/lib/engine/audioinput/ptlib/audioinput-manager-ptlib.cpp
trunk/lib/engine/audiooutput/null/audiooutput-manager-null.cpp
trunk/lib/engine/audiooutput/ptlib/audiooutput-manager-ptlib.cpp
trunk/lib/engine/components/opal/h323-endpoint.cpp
trunk/lib/engine/components/opal/h323-endpoint.h
trunk/lib/engine/components/opal/opal-call-manager.cpp
trunk/lib/engine/components/opal/opal-call.cpp
trunk/lib/engine/components/opal/sip-endpoint.cpp
trunk/lib/engine/gui/gtk-core/Makefile.am
trunk/lib/engine/videoinput/mlogo/videoinput-manager-mlogo.cpp
trunk/lib/engine/videoinput/ptlib/videoinput-manager-ptlib.cpp
trunk/lib/engine/videooutput/common/videooutput-manager-common.cpp
trunk/lib/gmref/Makefile.am
trunk/lib/gmref/gmref.h
trunk/src/devices/videoinput.cpp
trunk/src/devices/videooutput.cpp
trunk/src/gui/main.cpp
Modified: trunk/lib/engine/audioinput/null/audioinput-manager-null.cpp
==============================================================================
--- trunk/lib/engine/audioinput/null/audioinput-manager-null.cpp (original)
+++ trunk/lib/engine/audioinput/null/audioinput-manager-null.cpp Thu Nov 20 21:36:31 2008
@@ -43,14 +43,14 @@
: core (_core)
{
gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
- gmref_inc (smart); // take a reference in the main thread
+ smart->reference (); // take a reference in the main thread
runtime = &*smart;
current_state.opened = false;
}
GMAudioInputManager_null::~GMAudioInputManager_null ()
{
- gmref_dec (runtime); // leave a reference in the main thread
+ runtime->unreference (); // leave a reference in the main thread
}
void GMAudioInputManager_null::get_devices(std::vector <Ekiga::AudioInputDevice> & devices)
Modified: trunk/lib/engine/audioinput/ptlib/audioinput-manager-ptlib.cpp
==============================================================================
--- trunk/lib/engine/audioinput/ptlib/audioinput-manager-ptlib.cpp (original)
+++ trunk/lib/engine/audioinput/ptlib/audioinput-manager-ptlib.cpp Thu Nov 20 21:36:31 2008
@@ -45,7 +45,7 @@
: core (_core)
{
gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
- gmref_inc (smart); // take a reference in the main thread
+ smart->reference (); // take a reference in the main thread
runtime = &*smart;
current_state.opened = false;
input_device = NULL;
@@ -54,7 +54,7 @@
GMAudioInputManager_ptlib::~GMAudioInputManager_ptlib ()
{
- gmref_dec (runtime); // leave a reference in the main thread
+ runtime->unreference (); // leave a reference in the main thread
}
void GMAudioInputManager_ptlib::get_devices(std::vector <Ekiga::AudioInputDevice> & devices)
Modified: trunk/lib/engine/audiooutput/null/audiooutput-manager-null.cpp
==============================================================================
--- trunk/lib/engine/audiooutput/null/audiooutput-manager-null.cpp (original)
+++ trunk/lib/engine/audiooutput/null/audiooutput-manager-null.cpp Thu Nov 20 21:36:31 2008
@@ -42,7 +42,7 @@
: core (_core)
{
gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
- gmref_inc (smart); // take a reference in the main thread
+ smart->reference (); // take a reference in the main thread
runtime = &*smart;
current_state[Ekiga::primary].opened = false;
current_state[Ekiga::secondary].opened = false;
@@ -50,7 +50,7 @@
GMAudioOutputManager_null::~GMAudioOutputManager_null ()
{
- gmref_dec (runtime); // leave a reference in the main thread
+ runtime->unreference (); // leave a reference in the main thread
}
void GMAudioOutputManager_null::get_devices(std::vector <Ekiga::AudioOutputDevice> & devices)
Modified: trunk/lib/engine/audiooutput/ptlib/audiooutput-manager-ptlib.cpp
==============================================================================
--- trunk/lib/engine/audiooutput/ptlib/audiooutput-manager-ptlib.cpp (original)
+++ trunk/lib/engine/audiooutput/ptlib/audiooutput-manager-ptlib.cpp Thu Nov 20 21:36:31 2008
@@ -44,7 +44,7 @@
: core (_core)
{
gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
- gmref_inc (smart); // take a reference in the main thread
+ smart->reference (); // take a reference in the main thread
runtime = &*smart;
current_state[Ekiga::primary].opened = false;
current_state[Ekiga::secondary].opened = false;
@@ -54,7 +54,7 @@
GMAudioOutputManager_ptlib::~GMAudioOutputManager_ptlib ()
{
- gmref_dec (runtime); // leave a reference in the main thread
+ runtime->unreference (); // leave a reference in the main thread
}
void GMAudioOutputManager_ptlib::get_devices(std::vector <Ekiga::AudioOutputDevice> & devices)
Modified: trunk/lib/engine/components/opal/h323-endpoint.cpp
==============================================================================
--- trunk/lib/engine/components/opal/h323-endpoint.cpp (original)
+++ trunk/lib/engine/components/opal/h323-endpoint.cpp Thu Nov 20 21:36:31 2008
@@ -88,7 +88,7 @@
{
gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
- gmref_inc (smart); // take a reference in the main thread
+ smart->reference (); // take a reference in the main thread
runtime = &*smart;
}
@@ -103,6 +103,10 @@
manager.AddRouteEntry("pc:.* = h323:<da>");
}
+Opal::H323::EndPoint::~EndPoint ()
+{
+ runtime->unreference ();
+}
bool Opal::H323::EndPoint::populate_menu (gmref_ptr<Ekiga::Contact> contact,
std::string uri,
Modified: trunk/lib/engine/components/opal/h323-endpoint.h
==============================================================================
--- trunk/lib/engine/components/opal/h323-endpoint.h (original)
+++ trunk/lib/engine/components/opal/h323-endpoint.h Thu Nov 20 21:36:31 2008
@@ -67,6 +67,7 @@
public:
EndPoint (CallManager &_manager, Ekiga::ServiceCore & core, unsigned listen_port);
+ ~EndPoint ();
/* ContactDecorator and PresentityDecorator */
bool populate_menu (gmref_ptr<Ekiga::Contact> contact,
Modified: trunk/lib/engine/components/opal/opal-call-manager.cpp
==============================================================================
--- trunk/lib/engine/components/opal/opal-call-manager.cpp (original)
+++ trunk/lib/engine/components/opal/opal-call-manager.cpp Thu Nov 20 21:36:31 2008
@@ -141,7 +141,7 @@
call_core = core.get ("call-core");
{
gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
- gmref_inc (smart); // take a reference in the main thread
+ smart->reference (); // take a reference in the main thread
runtime = &*smart;
}
@@ -161,7 +161,7 @@
ClearAllCalls (OpalConnection::EndedByLocalUser, true);
g_async_queue_unref (queue);
- gmref_dec (runtime);
+ runtime->unreference ();
std::cout << "bye callmanager" << std::endl << std::flush;
}
Modified: trunk/lib/engine/components/opal/opal-call.cpp
==============================================================================
--- trunk/lib/engine/components/opal/opal-call.cpp (original)
+++ trunk/lib/engine/components/opal/opal-call.cpp Thu Nov 20 21:36:31 2008
@@ -54,7 +54,7 @@
{
{
gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
- gmref_inc (smart); // take a reference in the main thread
+ smart->reference (); // take a reference in the main thread
runtime = &*smart;
}
re_a_bytes = tr_a_bytes = re_v_bytes = tr_v_bytes = 0.0;
@@ -76,7 +76,7 @@
Opal::Call::~Call ()
{
- gmref_dec (runtime); // leave a reference in the main thead
+ runtime->unreference (); // leave a reference in the main thead
}
Modified: trunk/lib/engine/components/opal/sip-endpoint.cpp
==============================================================================
--- trunk/lib/engine/components/opal/sip-endpoint.cpp (original)
+++ trunk/lib/engine/components/opal/sip-endpoint.cpp Thu Nov 20 21:36:31 2008
@@ -125,12 +125,12 @@
{
gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
- gmref_inc (smart); // take a reference in the main thread
+ smart->reference (); // take a reference in the main thread
runtime = &*smart;
}
{
gmref_ptr<Ekiga::AccountCore> smart = core.get ("account-core");
- gmref_inc (smart); // take a reference in the main thread
+ smart->reference (); // take a reference in the main thread
account_core = &*smart;
}
@@ -169,8 +169,8 @@
Opal::Sip::EndPoint::~EndPoint ()
{
- gmref_dec (runtime); // leave a reference in the main thread
- gmref_dec (account_core); // leave a reference in the main thread
+ runtime->unreference (); // leave a reference in the main thread
+ account_core->unreference (); // leave a reference in the main thread
delete dialect;
}
Modified: trunk/lib/engine/gui/gtk-core/Makefile.am
==============================================================================
--- trunk/lib/engine/gui/gtk-core/Makefile.am (original)
+++ trunk/lib/engine/gui/gtk-core/Makefile.am Thu Nov 20 21:36:31 2008
@@ -20,8 +20,6 @@
$(gtk_core_dir)/menu-builder-gtk.cpp \
$(gtk_core_dir)/form-dialog-gtk.h \
$(gtk_core_dir)/form-dialog-gtk.cpp \
- $(gtk_core_dir)/gm-refcounted-boxed.h \
- $(gtk_core_dir)/gm-refcounted-boxed.cpp \
$(gtk_core_dir)/gtk-core.h \
$(gtk_core_dir)/gtk-core.cpp \
$(gtk_core_dir)/gtk-core-main.h \
Modified: trunk/lib/engine/videoinput/mlogo/videoinput-manager-mlogo.cpp
==============================================================================
--- trunk/lib/engine/videoinput/mlogo/videoinput-manager-mlogo.cpp (original)
+++ trunk/lib/engine/videoinput/mlogo/videoinput-manager-mlogo.cpp Thu Nov 20 21:36:31 2008
@@ -45,14 +45,14 @@
: core (_core)
{
gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
- gmref_inc (smart); // keep a reference in the main thread
+ smart->reference (); // keep a reference in the main thread
runtime = &*smart;
current_state.opened = false;
}
GMVideoInputManager_mlogo::~GMVideoInputManager_mlogo ()
{
- gmref_dec (runtime);
+ runtime->unreference ();
}
void GMVideoInputManager_mlogo::get_devices(std::vector <Ekiga::VideoInputDevice> & devices)
Modified: trunk/lib/engine/videoinput/ptlib/videoinput-manager-ptlib.cpp
==============================================================================
--- trunk/lib/engine/videoinput/ptlib/videoinput-manager-ptlib.cpp (original)
+++ trunk/lib/engine/videoinput/ptlib/videoinput-manager-ptlib.cpp Thu Nov 20 21:36:31 2008
@@ -44,7 +44,7 @@
: core (_core)
{
gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
- gmref_inc (smart); // take a reference in the main thread
+ smart->reference (); // take a reference in the main thread
runtime = &*smart;
current_state.opened = false;
input_device = NULL;
@@ -53,7 +53,7 @@
GMVideoInputManager_ptlib::~GMVideoInputManager_ptlib ()
{
- gmref_dec (runtime); // leave a reference in the main thread
+ runtime->unreference (); // leave a reference in the main thread
}
void GMVideoInputManager_ptlib::get_devices(std::vector <Ekiga::VideoInputDevice> & devices)
Modified: trunk/lib/engine/videooutput/common/videooutput-manager-common.cpp
==============================================================================
--- trunk/lib/engine/videooutput/common/videooutput-manager-common.cpp (original)
+++ trunk/lib/engine/videooutput/common/videooutput-manager-common.cpp Thu Nov 20 21:36:31 2008
@@ -51,13 +51,13 @@
core (_core)
{
gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
- gmref_inc (smart); // take a reference on smart in the main thread
+ smart->reference (); // take a reference on smart in the main thread
runtime = &*smart;
}
GMVideoOutputManager::~GMVideoOutputManager ()
{
- gmref_dec (runtime); // leave a reference on smart in the main thread
+ runtime->unreference (); // leave a reference on smart in the main thread
}
void GMVideoOutputManager::open ()
Modified: trunk/lib/gmref/Makefile.am
==============================================================================
--- trunk/lib/gmref/Makefile.am (original)
+++ trunk/lib/gmref/Makefile.am Thu Nov 20 21:36:31 2008
@@ -1,6 +1,6 @@
noinst_LTLIBRARIES = libgmref.la
-libgmref_la_SOURCES = gmref.h gmref.cpp
+libgmref_la_SOURCES = gmref.h
libgmref_la_LDFLAGS = -export-dynamic $(AM_LIBS)
Modified: trunk/lib/gmref/gmref.h
==============================================================================
--- trunk/lib/gmref/gmref.h (original)
+++ trunk/lib/gmref/gmref.h Thu Nov 20 21:36:31 2008
@@ -47,21 +47,13 @@
virtual ~GmRefCounted ()
{}
-private:
- int refcount;
-
- friend void gmref_inc (GmRefCounted* obj);
- friend void gmref_dec (GmRefCounted* obj);
- friend int gmref_count (GmRefCounted* obj);
-};
-
+ void reference () const { ++refcount; }
-/* base api */
+ void unreference () const { if (--refcount == 0) delete this; }
-void gmref_init ();
-void gmref_inc (GmRefCounted* obj);
-void gmref_dec (GmRefCounted* obj);
-int gmref_count (GmRefCounted* obj);
+private:
+ mutable int refcount;
+};
/* reference-counted pointer class */
@@ -110,10 +102,6 @@
template<typename T> bool operator<(const gmref_ptr<T>& a,
const gmref_ptr<T>& b);
-
-template<typename T> void gmref_inc (const gmref_ptr<T>& obj);
-template<typename T> void gmref_dec (const gmref_ptr<T>& obj);
-
/* implementation of the templates */
template<typename T>
@@ -130,20 +118,23 @@
template<typename T>
gmref_ptr<T>::gmref_ptr (T* obj_): obj(obj_)
{
- gmref_inc (obj);
+ if (obj != 0)
+ obj->reference ();
}
template<typename T>
gmref_ptr<T>::gmref_ptr (const gmref_ptr<T>& ptr): obj(ptr.obj)
{
- gmref_inc (obj);
+ if (obj != 0)
+ obj->reference ();
}
template<typename T>
template<typename Tprim>
gmref_ptr<T>::gmref_ptr (const gmref_ptr<Tprim>& ptr): obj(dynamic_cast<T*>(ptr.obj))
{
- gmref_inc (obj);
+ if (obj != 0)
+ obj->reference ();
}
template<typename T>
@@ -196,7 +187,8 @@
void
gmref_ptr<T>::reset ()
{
- gmref_dec (obj);
+ if (obj != 0)
+ obj->unreference ();
obj = 0;
}
@@ -223,16 +215,4 @@
return a.get () < b.get ();
}
-template<typename T>
-void gmref_inc (const gmref_ptr<T>& obj)
-{
- gmref_inc (obj.get ());
-}
-
-template<typename T>
-void gmref_dec (const gmref_ptr<T>& obj)
-{
- gmref_dec (obj.get ());
-}
-
#endif
Modified: trunk/src/devices/videoinput.cpp
==============================================================================
--- trunk/src/devices/videoinput.cpp (original)
+++ trunk/src/devices/videoinput.cpp Thu Nov 20 21:36:31 2008
@@ -73,7 +73,7 @@
{
{
gmref_ptr<Ekiga::VideoInputCore> smart = core.get ("videoinput-core");
- gmref_inc (smart); // take a reference in the main thread
+ smart->reference (); // take a reference in the main thread
videoinput_core = &*smart;
}
opened = false;
@@ -84,7 +84,7 @@
PVideoInputDevice_EKIGA::~PVideoInputDevice_EKIGA ()
{
Close ();
- gmref_dec (videoinput_core); // leave a reference in the main thread
+ videoinput_core->unreference (); // leave a reference in the main thread
}
bool
Modified: trunk/src/devices/videooutput.cpp
==============================================================================
--- trunk/src/devices/videooutput.cpp (original)
+++ trunk/src/devices/videooutput.cpp Thu Nov 20 21:36:31 2008
@@ -88,7 +88,7 @@
{
gmref_ptr<Ekiga::VideoOutputCore> smart = core.get ("videooutput-core");
- gmref_inc (smart); // take a reference in the main thread
+ smart->reference (); // take a reference in the main thread
videooutput_core = &*smart;
}
@@ -106,7 +106,7 @@
* have played with 'core' from a thread
*/
- gmref_dec (videooutput_core); // leave a reference in the main thread
+ videooutput_core-> unreference (); // leave a reference in the main thread
if (is_active) {
devices_nbr--;
Modified: trunk/src/gui/main.cpp
==============================================================================
--- trunk/src/gui/main.cpp (original)
+++ trunk/src/gui/main.cpp Thu Nov 20 21:36:31 2008
@@ -4364,9 +4364,6 @@
/* initialize platform-specific code */
gm_platform_init ();
- /* Memory management helpers */
- gmref_init ();
-
/* Configuration backend initialization */
gm_conf_init ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]