[sip-comm-dev] Re: svn commit: r7275 - trunk/src/native: . portaudio windows/directshow


#1

Hi Seb,

I'm afraid initializing AudioQualityImprovement_sharedInstancesMutex
like that on Windows will lead to undefined behavior. The goal of the
sharedInstanceMutex is to protect the sharedInstances when they are
accessed by multiple threads. If both threads determine that
!initialized and consequently determine that they need to mutex_init
i.e. InitializeCriticalSection, you'll get "A critical section object
must be deleted before it can be reinitialized. Initializing a
critical section that has already been initialized results in
undefined behavior."

Regards,
Lubo

···

On Fri, Jun 18, 2010 at 12:56 PM, <s_vincent@dev.java.net> wrote:

@@ -98,7 +104,15 @@
{
AudioQualityImprovement *theSharedInstance = NULL;

- if (!pthread_mutex_lock(&AudioQualityImprovement_sharedInstancesMutex))
+#ifdef _WIN32
+ if(!initialized)
+ {
+ mutex_init(&AudioQualityImprovement_sharedInstancesMutex, NULL);
+ initialized = 1;
+ }
+#endif
+
+ if (!mutex_lock(&AudioQualityImprovement_sharedInstancesMutex))

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#2

Hi Lubomir,

Thanks for report, the main problem here is to initialize CRITICAL_SECTION static global variable but yesterday I thought too quickly and do the "if(!initilized)" way. Now after googling a bit, I found that apparently {(void*)-1, -1, 0, 0, 0, 0} can initialize CRITICAL_SECTION (like PTHREAD_MUTEX_INITIALIZER do for pthread_mutex_t). I will test it as soon as I can when I will reboot to Windows.

Thanks again.

Regards,

···

--
Seb

Le 19/06/2010 09:25, Lubomir Marinov a �crit :

On Fri, Jun 18, 2010 at 12:56 PM,<s_vincent@dev.java.net> wrote:
   

@@ -98,7 +104,15 @@
  {
     AudioQualityImprovement *theSharedInstance = NULL;

- if (!pthread_mutex_lock(&AudioQualityImprovement_sharedInstancesMutex))
+#ifdef _WIN32
+ if(!initialized)
+ {
+ mutex_init(&AudioQualityImprovement_sharedInstancesMutex, NULL);
+ initialized = 1;
+ }
+#endif
+
+ if (!mutex_lock(&AudioQualityImprovement_sharedInstancesMutex))
     

Hi Seb,

I'm afraid initializing AudioQualityImprovement_sharedInstancesMutex
like that on Windows will lead to undefined behavior. The goal of the
sharedInstanceMutex is to protect the sharedInstances when they are
accessed by multiple threads. If both threads determine that
!initialized and consequently determine that they need to mutex_init
i.e. InitializeCriticalSection, you'll get "A critical section object
must be deleted before it can be reinitialized. Initializing a
critical section that has already been initialized results in
undefined behavior."

Regards,
Lubo

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net