浏览代码

Fix for no sound output under Linux

Levitator1 10 年之前
父节点
当前提交
f3199b04e4
共有 2 个文件被更改,包括 9 次插入4 次删除
  1. 4 2
      Engine/source/platform/platformIntrinsics.gcc.h
  2. 5 2
      Engine/source/platform/threads/threadPool.cpp

+ 4 - 2
Engine/source/platform/platformIntrinsics.gcc.h

@@ -42,7 +42,8 @@ inline void dFetchAndAdd( volatile U32& ref, U32 val )
    #if defined(TORQUE_OS_PS3)
       cellAtomicAdd32( (std::uint32_t *)&ref, val );
    #elif !defined(TORQUE_OS_MAC)
-      __sync_fetch_and_add( ( volatile long* ) &ref, val );
+      //__sync_fetch_and_add( ( volatile long* ) &ref, val );
+      __sync_fetch_and_add(&ref, val );
    #else
       OSAtomicAdd32( val, (int32_t* ) &ref);
    #endif
@@ -53,7 +54,8 @@ inline void dFetchAndAdd( volatile S32& ref, S32 val )
    #if defined(TORQUE_OS_PS3)
       cellAtomicAdd32( (std::uint32_t *)&ref, val );
    #elif !defined(TORQUE_OS_MAC)
-      __sync_fetch_and_add( ( volatile long* ) &ref, val );
+      //__sync_fetch_and_add( ( volatile long* ) &ref, val );
+      __sync_fetch_and_add( &ref, val );
    #else
       OSAtomicAdd32( val, (int32_t* ) &ref);
    #endif

+ 5 - 2
Engine/source/platform/threads/threadPool.cpp

@@ -418,8 +418,11 @@ void ThreadPool::queueWorkItem( WorkItem* item )
       // thread's run function.  This may lead us to release
       // the semaphore more often than necessary, but it avoids
       // a race condition.
-
-      if( !dCompareAndSwap( mNumThreadsReady, mNumThreads, mNumThreads ) )
+      
+      //Wasn't there still a race condition? Why not rely entirely on the semaphore?
+      //For example, mNumThreadsReady initializes equalto mNumThreads, which could cause
+      //initial work items to hang.
+      //if( !dCompareAndSwap( mNumThreadsReady, mNumThreads, mNumThreads ) )
          mSemaphore.release();
    }
 }