Esempio n. 1
0
DrError DrThread::Start(
    LPSECURITY_ATTRIBUTES lpThreadAttributes,
    SIZE_T dwStackSize,
    DWORD dwCreationFlags
)
{
    LogAssert(m_hThread == NULL);
    DWORD dwThreadId;

    HANDLE h = CreateThread(
        lpThreadAttributes,
        dwStackSize,
        ThreadEntryStatic,
        this,
        dwCreationFlags | CREATE_SUSPENDED,
        &dwThreadId);
    if (h == NULL) {
        return DrGetLastError();
    }
    m_hThread = h;
    m_dwThreadId = dwThreadId;

    UpdateTagAndDescription();
    IncRef();  // The win32 thread owns one reference
    if ((dwCreationFlags & CREATE_SUSPENDED) == 0) {
        DWORD ret = ResumeThread(h);
        LogAssert(ret != (DWORD)-1);
    }
    return DrError_OK;
}
Esempio n. 2
0
   SDLMusicChannel(Object *inSound, Mix_Music *inMusic, double inStartTime, int inLoops,
                  const SoundTransform &inTransform)
   {
      mMusic = inMusic;
      mSound = inSound;
      mSound->IncRef();

      mPlaying = false;
      if (mMusic)
      {
         mPlaying = true;
         sUsedMusic = this;
         sDoneMusic = false;
		 mStartTime = SDL_GetTicks ();
		 mLength = 0;
         IncRef();
         Mix_PlayMusic( mMusic, inLoops<0 ? -1 : inLoops==0 ? 0 : inLoops-1 );
         Mix_VolumeMusic( inTransform.volume*MIX_MAX_VOLUME );
         if (inStartTime > 0)
		 {
			 // this is causing crash errors
			 
			 //Mix_RewindMusic();
			 //int seconds = inStartTime / 1000;
			 //Mix_SetMusicPosition(seconds); 
			 //mStartTime = SDL_GetTicks () - inStartTime;
		 }
         // Mix_SetPanning not available for music
      }
   }
Esempio n. 3
0
   SDLSoundChannel(Object *inSound, Mix_Chunk *inChunk, double inStartTime, int inLoops,
                  const SoundTransform &inTransform)
   {
      mChunk = inChunk;
      mSound = inSound;
      mSound->IncRef();

      mChannel = -1;

      // Allocate myself a channel
      if (mChunk)
      {
         for(int i=0;i<sMaxChannels;i++)
            if (!sUsedChannel[i])
            {
               IncRef();
               sDoneChannel[i] = false;
               sUsedChannel[i] = true;
               mChannel = i;
               break;
            }
      }

      if (mChannel>=0)
      {
         Mix_PlayChannel( mChannel , mChunk, inLoops<0 ? -1 : inLoops==0 ? 0 : inLoops-1 );
         Mix_Volume( mChannel, inTransform.volume*MIX_MAX_VOLUME );
         // Mix_SetPanning
      }
   }
Esempio n. 4
0
    void loadWithPath(const std::string &inPath, bool inForceMusic)
    {
        JNIEnv *env = GetEnv();
        IncRef();

        mMode = MODE_UNKNOWN;
        handleID = -1;
        mLength = 0;
        mSoundPath = inPath;

        jclass cls = env->FindClass("org/haxe/nme/Sound");
        jstring path = env->NewStringUTF(mSoundPath.c_str());

        if (!inForceMusic) {
            jmethodID mid = env->GetStaticMethodID(cls, "getSoundHandle", "(Ljava/lang/String;)I");
            if (mid > 0) {
                handleID = env->CallStaticIntMethod(cls, mid, path);
                if (handleID >= 0)
                    mMode = MODE_SOUND_ID;
            }
        }

        //env->ReleaseStringUTFChars(str, inSound.c_str() );

        if (handleID < 0)
            mMode = MODE_MUSIC_PATH;
    }
Esempio n. 5
0
   SDLSoundChannel(const ByteArray &inBytes, const SoundTransform &inTransform)
   {
      Mix_QuerySpec(&mFrequency, &mFormat, &mChannels);
      if (mFrequency!=44100)
         ELOG("Warning - Frequency mismatch %d",mFrequency);
      if (mFormat!=32784)
         ELOG("Warning - Format mismatch    %d",mFormat);
      if (mChannels!=2)
         ELOG("Warning - channe mismatch    %d",mChannels);


      mChunk = 0;
      mDynamicBuffer = new short[BUF_SIZE * STEREO_SAMPLES];
      memset(mDynamicBuffer,0,BUF_SIZE*sizeof(short));
      mSound = 0;
      mChannel = -1;
      mDynamicChunk.allocated = 0;
      mDynamicChunk.abuf = (Uint8 *)mDynamicBuffer;
      mDynamicChunk.alen = BUF_SIZE * sizeof(short) * STEREO_SAMPLES; // bytes
      mDynamicChunk.volume = MIX_MAX_VOLUME;
	  #ifndef WEBOS
	   mDynamicChunk.length_ticks = 0;
	  #endif
      mDynamicFillPos = 0;
      mDynamicStartPos = 0;
      mDynamicDataDue = 0;

      // Allocate myself a channel
      for(int i=0;i<sMaxChannels;i++)
         if (!sUsedChannel[i])
         {
            IncRef();
            sDoneChannel[i] = false;
            sUsedChannel[i] = true;
            mChannel = i;
            break;
         }

      if (mChannel>=0)
      {
         FillBuffer(inBytes);
         // Just once ...
         if (mDynamicFillPos<1024)
         {
            mDynamicDone = true;
            mDynamicChunk.alen = mDynamicFillPos * sizeof(short) * STEREO_SAMPLES;
            Mix_PlayChannel( mChannel , &mDynamicChunk,  0 );
         }
         else
         {
            mDynamicDone = false;
            // TODO: Lock?
            Mix_PlayChannel( mChannel , &mDynamicChunk,  -1 );
            mDynamicStartPos = sSoundPos;
         }

         Mix_Volume( mChannel, inTransform.volume*MIX_MAX_VOLUME );
      }
   }
Esempio n. 6
0
void DrThread::AttachToCurrentThread()
{
    LogAssert(t_pThread.IsNull());
    t_pThread = this;
    m_dwThreadId = GetCurrentThreadId();
    IncRef();
    UpdateTagAndDescription();
    DrLogD( "DrThread::AttachToCurrentThread. %s, pThread=%p", m_strClass.GetString(), this);
}
Esempio n. 7
0
SocketMgr::SocketMgr() : m_threadCount(0), 
#ifdef CONFIG_USE_IOCP
	m_completionPort(nullptr), 
#endif
	m_bWorkerThreadsActive(false),
	m_bShutdown(false)
{
	IncRef();
}
Esempio n. 8
0
nglApplication::nglApplication()
{
  mUseIdle = false;
  mLastIdleCall = 0.0f;
  mExitPosted = false;

  // nglApplication is a kernel's client, just as plugin instances
  IncRef();
}
Esempio n. 9
0
void SerializerLess::SliceBuffer(Serializer& _ser, size_t _size)
{
	assert(_ser.GetBufferSize() - _ser.GetCursor() >= _size);

	m_buffer = _ser.m_buffer + _ser.GetCursor();
	m_buffer_size = _size;

	assert(m_ref == nullptr);
	m_ref = _ser.GetSerializer();
	IncRef();
}
Esempio n. 10
0
   SDLSound(unsigned char *inData, int len)
   {
      IncRef();

      mChunk = Mix_LoadWAV_RW(SDL_RWFromMem(inData, len), 1);
      if ( mChunk == NULL )
      {
         mError = SDL_GetError();
         // ELOG("Error %s (%s)", mError.c_str(), name );
      }
   }
Esempio n. 11
0
   SDLMusic(unsigned char *inData, int len)
   {
      IncRef();

      mMusic = Mix_LoadMUS_RW(SDL_RWFromMem(inData, len));
      if ( mMusic == NULL )
      {
         mError = SDL_GetError();
         ELOG("Error in music with len (%d)", len );
      }
   }
Esempio n. 12
0
XPath_Value *
XPath_Value::ConvertToStringL (XPath_Context *context)
{
  if (type == XP_VALUE_STRING)
    return IncRef (this);
  else
    {
      TempBuffer buffer; ANCHOR (TempBuffer, buffer);
      return MakeStringL (context, AsStringL (buffer));
    }
}
Esempio n. 13
0
void SerializerLess::SliceBuffer(Serializer& _ser, size_t _sizeA, size_t _sizeB)
{
	assert(_sizeB > _sizeA);
	assert(_ser.GetBufferSize() >= _sizeB - _sizeA);

	m_buffer = _ser.m_buffer + _sizeA;
	m_buffer_size = _sizeB - _sizeA;

	assert(m_ref == nullptr);
	m_ref = _ser.GetSerializer();
	IncRef();
}
Esempio n. 14
0
 SDLSound(float *inData, int len)
 {
    IncRef();
    
    #ifndef EMSCRIPTEN
    mChunk = Mix_LoadWAV_RW(SDL_RWFromMem(inData, len), 1);
    if ( mChunk == NULL )
    {
       mError = SDL_GetError();
       // ELOG("Error %s (%s)", mError.c_str(), name );
    }
    #endif
 }
Esempio n. 15
0
 SDLMusic(float *inData, int len)
 {
    IncRef();
    
    #ifndef EMSCRIPTEN
    mMusic = Mix_LoadMUS_RW(SDL_RWFromMem(inData, len));
    if ( mMusic == NULL )
    {
       mError = SDL_GetError();
       ELOG("Error in music with len (%d)", len );
    }
    #endif
 }
Esempio n. 16
0
SocketMgr::SocketMgr() : m_threadCount(0), 
	m_bWorkerThreadsActive(false),
	m_bShutdown(false)
{
	static bool bRefCounterInitialised = false;
	if (!bRefCounterInitialised)
	{
		s_refCounter = 0;
		bRefCounterInitialised = true;
	}

	IncRef();
	Initialise();
}
void OBSBasicStatusBar::StreamStarted(obs_output_t *output)
{
	streamOutput = output;

	signal_handler_connect(obs_output_get_signal_handler(streamOutput),
			"reconnect", OBSOutputReconnect, this);
	signal_handler_connect(obs_output_get_signal_handler(streamOutput),
			"reconnect_success", OBSOutputReconnectSuccess, this);

	retries           = 0;
	lastBytesSent     = 0;
	lastBytesSentTime = os_gettime_ns();
	IncRef();
}
Esempio n. 18
0
File: scf.cpp Progetto: garinh/cs
iBase *scfFactory::CreateInstance ()
{
  IncRef ();
  // If IncRef won't succeed, we'll have a zero reference counter
  if (!scfRefCount)
    return 0;

  iBase *instance = CreateFunc(this);
  csRefTrackerAccess::SetDescriptionWeak (instance, ClassID);

  // No matter whenever we succeeded or not, decrement the refcount
  DecRef ();

  return instance;
}
Esempio n. 19
0
gralloc1_error_t BufferManager::RetainBuffer(private_handle_t const *hnd) {
  if (hnd->flags & private_handle_t::PRIV_FLAGS_CLIENT_ALLOCATED) {
    return GRALLOC1_ERROR_NONE;
  }
  ALOGD_IF(DEBUG, "Retain buffer handle:%p id: %" PRIu64, hnd, hnd->id);
  gralloc1_error_t err = GRALLOC1_ERROR_NONE;
  std::lock_guard<std::mutex> lock(buffer_lock_);
  auto buf = GetBufferFromHandleLocked(hnd);
  if (buf != nullptr) {
    buf->IncRef();
  } else {
    private_handle_t *handle = const_cast<private_handle_t *>(hnd);
    err = ImportHandleLocked(handle);
  }
  return err;
}
Esempio n. 20
0
value &Object::toAbstract()
{
   if (!val)
   {
      val = new emscripten::val( emscripten::val::object() );
      val->set("ptr", (int)this);
      val->set("kind", (int)gObjectKind);
      IncRef();
      gTempRefs.push_back(this);
   }
   // ?
   //IncRef();
   //gTempRefs.push_back(this);

   return *val;
}
Esempio n. 21
0
csRef<iDocumentNode> csXmlReadNode::GetParent ()
{
  csRef<iDocumentNode> child;
  if (use_contents_value)
  {
    // If we use contents value then the parent is actually this object.
    IncRef ();
    return csPtr<iDocumentNode> (this);
  }
  else
  {
    if (!node->Parent ()) return child;
    child = csPtr<iDocumentNode> (GetDoc()->Alloc (node->Parent (), false));
    return child;
  }
  
  return 0;
}
Esempio n. 22
0
   SDLMusic(const std::string &inFilename)
   {
      IncRef();

      #ifdef HX_MACOS
      char name[1024];
      GetBundleFilename(inFilename.c_str(),name,1024);
      #else
      const char *name = inFilename.c_str();
      #endif

      mMusic = Mix_LoadMUS(name);
      if ( mMusic == NULL )
      {
         mError = SDL_GetError();
         printf("Error %s (%s)\n", mError.c_str(), name );
      }
   }
Esempio n. 23
0
   SDLSound(const std::string &inFilename)
   {
      IncRef();

      #ifdef HX_MACOS
      char name[1024];
      GetBundleFilename(inFilename.c_str(),name,1024);
      #else
      const char *name = inFilename.c_str();
      #endif

      mChunk = Mix_LoadWAV(name);
      if ( mChunk == NULL )
      {
         mError = SDL_GetError();
         // printf("Error %s (%s)\n", mError.c_str(), name );
      }
   }
Esempio n. 24
0
/* static */ XPath_Value *
XPath_Value::MakeStringL (XPath_Context *context, const uni_char *string, unsigned length)
{
  if (!string)
    string = UNI_L ("");

  if (length == ~0u)
    length = uni_strlen (string);

  XPath_Value *value = XPath_Value::NewL (context);
  value->refcount = 1;
  XP_ANCHOR_VALUE (context, value);
  value->data.string = 0;
  value->data.string = XPath_Utils::CopyStringL (string, length);
  value->type = XP_VALUE_STRING;

  return IncRef (value);
}
Esempio n. 25
0
   SDLMusicChannel(Object *inSound, Mix_Music *inMusic, double inStartTime, int inLoops,
                  const SoundTransform &inTransform)
   {
      mMusic = inMusic;
      mSound = inSound;
      mSound->IncRef();

      mPlaying = false;
      if (mMusic)
      {
         mPlaying = true;
         sUsedMusic = this;
         sDoneMusic = false;
         IncRef();
         Mix_PlayMusic( mMusic, inLoops<0 ? -1 : inLoops==0 ? 0 : inLoops-1 );
         Mix_VolumeMusic( inTransform.volume*MIX_MAX_VOLUME );
         // Mix_SetPanning
      }
   }
Esempio n. 26
0
/* static */ XPath_Node *
XPath_Node::MakeL (XPath_Context *context, XPath_Node *node, BOOL independent)
{
  if (node->temporary || !independent != !node->independent)
    {
      XPath_Node *copy = NewL (context, node->tree, node->treenode, independent);

      if (node->type == XP_NODE_ATTRIBUTE || node->type == XP_NODE_NAMESPACE)
        {
          copy->type = node->type;
          copy->name.SetL (node->name);
        }

      copy->temporary = FALSE;
      return copy;
    }
  else
    return IncRef (node);
}
Esempio n. 27
0
void CShader::RegisterActivate(){
	// fill the qtexture_t with shader information
	//++timo FIXME: a lot of that won't be necessary, will be stored at IShader* level
//  strcpy (m_pTexture->shadername, m_Name);
	// this flag is set only if we have a shaderfile name
//  if (m_ShaderFileName[0] != '\0')
//    m_pTexture->bFromShader = true;
//  else
//    m_pTexture->bFromShader = false;
	//++timo FIXME: what do we do with that?
	//m_pTexture->fTrans = pInfo->m_fTransValue;
//  m_pTexture->fTrans = 1.0f;	// if != 1.0 it's ot getting drawn in Cam_Draw
//  m_pTexture->nShaderFlags = m_nFlags;
	// store in the active shaders list (if necessary)
	g_ActiveShaders.AddSingle( this );
	// when you activate a shader, it gets displayed in the texture browser
	m_bDisplayed = true;
	IncRef();
}
Esempio n. 28
0
   void RenderData(const HardwareData &inData, const ColorTransform *ctrans,const Trans4x4 &inTrans)
   {
      const uint8 *data = 0;
      if (inData.mVertexBo)
      {
         if (inData.mContextId!=gTextureContextVersion)
         {
            if (inData.mVboOwner)
               inData.mVboOwner->DecRef();
            inData.mVboOwner = 0;
            // Create one right away...
            inData.mRendersWithoutVbo = 5;
            inData.mVertexBo = 0;
            inData.mContextId = 0;
         }
         else
            glBindBuffer(GL_ARRAY_BUFFER, inData.mVertexBo);
      }

      if (!inData.mVertexBo)
      {
         data = &inData.mArray[0];
         #ifndef EMSCRIPTEN
         inData.mRendersWithoutVbo++;
         if ( inData.mRendersWithoutVbo>4)
         #endif
         {
            glGenBuffers(1,&inData.mVertexBo);
            inData.mVboOwner = this;
            IncRef();
            inData.mContextId = gTextureContextVersion;
            glBindBuffer(GL_ARRAY_BUFFER, inData.mVertexBo);
            // printf("VBO DATA %d\n", inData.mArray.size());
            glBufferData(GL_ARRAY_BUFFER, inData.mArray.size(), data, GL_STATIC_DRAW);
            data = 0;
         }
      }

      GPUProg *lastProg = 0;
 
      for(int e=0;e<inData.mElements.size();e++)
      {
         const DrawElement &element = inData.mElements[e];
         int n = element.mCount;
         if (!n)
            continue;

 

         int progId = 0;
         bool premAlpha = false;
         if ((element.mFlags & DRAW_HAS_TEX) && element.mSurface)
         {
            if (element.mSurface->GetFlags() & surfUsePremultipliedAlpha)
               premAlpha = true;
            progId |= PROG_TEXTURE;
            if (element.mSurface->BytesPP()==1)
               progId |= PROG_ALPHA_TEXTURE;
         }

         if (element.mFlags & DRAW_HAS_COLOUR)
            progId |= PROG_COLOUR_PER_VERTEX;

         if (element.mFlags & DRAW_HAS_NORMAL)
            progId |= PROG_NORMAL_DATA;

         if (element.mFlags & DRAW_RADIAL)
         {
            progId |= PROG_RADIAL;
            if (element.mRadialPos!=0)
               progId |= PROG_RADIAL_FOCUS;
         }

         if (ctrans || element.mColour != 0xffffffff)
         {
            progId |= PROG_TINT;
            if (ctrans && ctrans->HasOffset())
               progId |= PROG_COLOUR_OFFSET;
         }

         bool persp = element.mFlags & DRAW_HAS_PERSPECTIVE;

         GPUProg *prog = mProg[progId];
         if (!prog)
             mProg[progId] = prog = GPUProg::create(progId);
         if (!prog)
            continue;

         switch(element.mBlendMode)
         {
            case bmAdd:
               glBlendFunc( GL_SRC_ALPHA, GL_ONE );
               break;
            case bmMultiply:
               glBlendFunc( GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA);
               break;
            case bmScreen:
               glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_COLOR);
               break;
            default:
               glBlendFunc(premAlpha ? GL_ONE : GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
         }


         if (prog!=lastProg)
         {
            if (lastProg)
               lastProg->disableSlots();

            prog->bind();
            prog->setTransform(inTrans);
            lastProg = prog;
         }

         int stride = element.mStride;
         if (prog->vertexSlot >= 0)
         {
            glVertexAttribPointer(prog->vertexSlot, persp ? 4 : 2 , GL_FLOAT, GL_FALSE, stride,
                data + element.mVertexOffset);
            glEnableVertexAttribArray(prog->vertexSlot);
         }

         if (prog->textureSlot >= 0)
         {
            glVertexAttribPointer(prog->textureSlot,  2 , GL_FLOAT, GL_FALSE, stride,
                data + element.mTexOffset);
            glEnableVertexAttribArray(prog->textureSlot);

            if (element.mSurface)
            {
               Texture *boundTexture = element.mSurface->GetTexture(this);
               element.mSurface->Bind(*this,0);
               boundTexture->BindFlags(element.mFlags & DRAW_BMP_REPEAT,element.mFlags & DRAW_BMP_SMOOTH);
            }
         }

         if (prog->colourSlot >= 0)
         {
            glVertexAttribPointer(prog->colourSlot, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride,
                data + element.mColourOffset);
            glEnableVertexAttribArray(prog->colourSlot);
         }

         if (prog->normalSlot >= 0)
         {
            glVertexAttribPointer(prog->normalSlot, 2, GL_FLOAT, GL_FALSE, stride,
                data + element.mNormalOffset);
            glEnableVertexAttribArray(prog->normalSlot);
         }

         if (element.mFlags & DRAW_RADIAL)
         {
            prog->setGradientFocus(element.mRadialPos * one_on_256);
         }

         if (progId & (PROG_TINT | PROG_COLOUR_OFFSET) )
         {
            prog->setColourTransform(ctrans, element.mColour );
         }

         if ( (element.mPrimType == ptLineStrip || element.mPrimType==ptPoints || element.mPrimType==ptLines)
                 && element.mCount>1)
         {
            if (element.mWidth<0)
               SetLineWidth(1.0);
            else if (element.mWidth==0)
               SetLineWidth(0.0);
            else
               switch(element.mScaleMode)
               {
                  case ssmNone: SetLineWidth(element.mWidth); break;
                  case ssmNormal:
                  case ssmOpenGL:
                     if (mLineScaleNormal<0)
                        mLineScaleNormal =
                           sqrt( 0.5*( mModelView.m00*mModelView.m00 + mModelView.m01*mModelView.m01 +
                                          mModelView.m10*mModelView.m10 + mModelView.m11*mModelView.m11 ) );
                     SetLineWidth(element.mWidth*mLineScaleNormal);
                     break;
                  case ssmVertical:
                     if (mLineScaleV<0)
                        mLineScaleV =
                           sqrt( mModelView.m00*mModelView.m00 + mModelView.m01*mModelView.m01 );
                     SetLineWidth(element.mWidth*mLineScaleV);
                     break;

                  case ssmHorizontal:
                     if (mLineScaleH<0)
                        mLineScaleH =
                           sqrt( mModelView.m10*mModelView.m10 + mModelView.m11*mModelView.m11 );
                     SetLineWidth(element.mWidth*mLineScaleH);
                     break;
               }
         }
   
            //printf("glDrawArrays %d : %d x %d\n", element.mPrimType, element.mFirst, element.mCount );

         sgDrawCount++;
         glDrawArrays(sgOpenglType[element.mPrimType], 0, element.mCount );
      }

      if (lastProg)
        lastProg->disableSlots();

      if (inData.mVertexBo)
         glBindBuffer(GL_ARRAY_BUFFER,0);
   }
void OBSBasicStatusBar::RecordingStarted(obs_output_t *output)
{
	recordOutput = output;
	IncRef();
}
Esempio n. 30
0
SocketMgr::SocketMgr() : m_hThreads(NULL), m_threadCount(0), m_completionPort(NULL)
{
	IncRef();
}