NS_IMETHODIMP
MIDIBackgroundRunnable::Run() {
  AssertIsOnBackgroundThread();
  if (!MIDIPlatformService::IsRunning()) {
    return NS_OK;
  }
  RunInternal();
  return NS_OK;
}
Esempio n. 2
0
//-----------------------------------------------------------------------------
void tIMX51Video::SetColourKey(const QColor &key)
{
    m_ColourKey = key;

    if( m_RunningInternal )
    {
        StopInternal();
        RunInternal();
    }
}
NS_IMETHODIMP
nsDOMWorkerScriptLoader::Run()
{
  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");

  // We may have been canceled already.
  if (mCanceled) {
    return NS_BINDING_ABORTED;
  }

  nsresult rv = RunInternal();
  if (NS_SUCCEEDED(rv)) {
    return rv;
  }

  // Ok, something failed beyond a normal cancel.

  // If necko is holding a ref to us then we'll end up notifying in the
  // OnStreamComplete method, not here.
  PRBool needsNotify = PR_TRUE;

  // Cancel any async channels that were already opened.
  for (PRUint32 index = 0; index < mScriptCount; index++) {
    ScriptLoadInfo& loadInfo = mLoadInfos[index];

    nsIRequest* request = static_cast<nsIRequest*>(loadInfo.channel.get());
    if (request) {
#ifdef DEBUG
      nsresult rvInner =
#endif
      request->Cancel(NS_BINDING_ABORTED);
      NS_WARN_IF_FALSE(NS_SUCCEEDED(rvInner), "Failed to cancel channel!");

      // Necko is holding a ref to us so make sure that the OnStreamComplete
      // code sends the done event.
      needsNotify = PR_FALSE;
    }
    else {
      // Make sure to set this so that the OnStreamComplete code will dispatch
      // the done event.
      loadInfo.done = PR_TRUE;
    }
  }

  if (needsNotify) {
    NotifyDone();
  }

  return rv;
}
Esempio n. 4
0
//-----------------------------------------------------------------------------
void tIMX51Video::SetGeometryInternal()
{
    UpdateVideoGeometry();
    if( m_RunningInternal )
    {
        StopInternal();
        RunInternal();
    }
    else if(m_pGstSource)
    {
        g_object_set(m_pGstSource, "capture-width", m_VideoGeometry.width(), NULL);
        g_object_set(m_pGstSource, "capture-height", m_VideoGeometry.height(), NULL);
        g_object_set(m_pGstSource, "preview-width", m_VideoGeometry.width(), NULL);
        g_object_set(m_pGstSource, "preview-height", m_VideoGeometry.height(), NULL);
        g_object_set(m_pGstSource, "preview-top", m_VideoGeometry.top(), NULL);
        g_object_set(m_pGstSource, "preview-left", m_VideoGeometry.left(), NULL);
    }
}
Esempio n. 5
0
bool SHM_MsgReplyConnection::Run(bool runFull)
{ 
  if (m_has_had_error) return true;

  if (runFull) return RunInternal(); 

  m_shmmutex.Enter();
  int s=m_shm->Run();
  if (m_shm->send_queue.Available() > m_maxqueuesize) s=-1;
  m_shmmutex.Leave();
  
  if (s<0) m_has_had_error=true;
  else if (m_shm && m_shm->WantSendKeepAlive()) 
  {
    int zer=0;
    Send(0,NULL,0,NULL,0,&zer);
  }

  return s<0;
} 
Esempio n. 6
0
status_t
AbstractProcess::Run()
{
	{
		AutoLocker<BLocker> locker(&fLock);

		if (ProcessState() != PROCESS_INITIAL) {
			printf("cannot start process as it is not idle");
			return B_NOT_ALLOWED;
		}

		if (fWasStopped) {
			printf("cannot start process as it was stopped");
			return B_CANCELED;
		}

		fProcessState = PROCESS_RUNNING;
	}

	status_t runResult = RunInternal();

	if (runResult != B_OK)
		printf("[%s] an error has arisen; %s\n", Name(), strerror(runResult));

	AbstractProcessListener* listener;

	{
		AutoLocker<BLocker> locker(&fLock);
		fProcessState = PROCESS_COMPLETE;
		fErrorStatus = runResult;
		listener = fListener;
	}

	// this process may be part of a larger bulk-load process and
	// if so, the process orchestration needs to know when this
	// process has completed.
	if (listener != NULL)
		listener->ProcessExited();

	return runResult;
}
Esempio n. 7
0
//-----------------------------------------------------------------------------
void tIMX51Video::timerEvent(QTimerEvent *)
{
    if(m_EosReceived)
    {
        if(m_RunningInternal)
        {
            // There is a bug in the ipu that causes playback to fail. This then seems to cause an EOS event
            // to be posted along the pipeline and then to the application. Detect this and restart the 
            // playback
            qDebug() << "tHalVideoSr2::HandleEosEvent unexpected EOS event. Restarting video playback";

            m_RunningInternal = false;
            killTimer(m_TimerId);
            gst_element_set_state( m_pGstPipeline, GST_STATE_NULL );
            gst_element_get_state( m_pGstPipeline, NULL, NULL, 3000000000ULL );
            gst_object_unref( GST_OBJECT( m_pGstPipeline ) );    
            m_pGstPipeline = 0;

            RunInternal();
        }
        m_EosReceived = false;
    }
}
Esempio n. 8
0
Result<ExitCode> ProcessWithLogon::Run(const Settings& settings, ProcessTracker& processTracker) const
{
	Trace trace(settings.GetLogLevel());
	trace < L"ProcessWithLogon::Run";
	if (_changeIntegrityLevel)
	{
		trace << L" elevated";
	}
	
	Environment callingProcessEnvironment;
	Environment targetUserEnvironment;
	Environment environment;
	if (settings.GetInheritanceMode() != INHERITANCE_MODE_OFF)
	{
		trace < L"ProcessWithLogon::Get calling process Environment";
		auto callingProcessEnvironmentResult = Environment::CreateForCurrentProcess(trace);
		if (callingProcessEnvironmentResult.HasError())
		{
			return Result<ExitCode>(callingProcessEnvironmentResult.GetError());
		}

		callingProcessEnvironment = callingProcessEnvironmentResult.GetResultValue();
		environment = callingProcessEnvironment;
	}

	if (settings.GetInheritanceMode() != INHERITANCE_MODE_ON)
	{		
		trace < L"ProcessWithLogon::Get target user environment";
		Settings getEnvVarsProcessSettings(
			settings.GetUserName(),
			settings.GetDomain(),
			settings.GetPassword(),
			L"cmd.exe",
			settings.GetWorkingDirectory(),
			EXIT_CODE_BASE,
			{ L"/U", L"/C", L"SET" },
			{ },
			INHERITANCE_MODE_OFF,
			INTEGRITY_LEVEL_AUTO,			
			SHOW_MODE_HIDE,
			false);

		if(settings.GetLogLevel() == LOG_LEVEL_DEBUG)
		{
			getEnvVarsProcessSettings.SetLogLevel(LOG_LEVEL_DEBUG);
		}
		else
		{
			getEnvVarsProcessSettings.SetLogLevel(LOG_LEVEL_OFF);
		}

		wstringstream getEnvVarsStream;
		StringWriter getEnvVarsWriter(getEnvVarsStream);
		StubWriter nullWriter;
		ProcessTracker getEnvVarsProcessTracker(getEnvVarsWriter, nullWriter);
		auto getEnvVarsResult = RunInternal(trace, getEnvVarsProcessSettings, getEnvVarsProcessTracker, targetUserEnvironment, false);
		if (getEnvVarsResult.HasError() || getEnvVarsResult.GetResultValue() != 0)
		{
			return getEnvVarsResult;
		}

		targetUserEnvironment = Environment::CreateFormString(getEnvVarsStream.str(), trace);
		environment = targetUserEnvironment;
	}

	if (settings.GetInheritanceMode() == INHERITANCE_MODE_AUTO)
	{
		environment = Environment::Override(callingProcessEnvironment, targetUserEnvironment, trace);
	}

	environment = Environment::Apply(environment, Environment::CreateFormList(settings.GetEnvironmentVariables(), L"from command line", trace), trace);
	return RunInternal(trace, settings, processTracker, environment, _changeIntegrityLevel);
}
Esempio n. 9
0
int SHM_MsgReplyConnection::Send(int type, const void *msg, int msglen,  
                           void *replybuf, int maxretbuflen, const int *forceMsgID,
                           const void *secondchunk, int secondchunklen,
                           WDL_HeapBuf *hbreplyout)
{
  if (!m_shm||m_has_had_error) return -1;

  if (secondchunk && secondchunklen>0) msglen+=secondchunklen;
  else secondchunklen=0;

  int msgid;
  {
    WDL_MutexLock lock(&m_shmmutex);
    m_shm->send_queue.AddDataToLE(&type,4,4);

    if (forceMsgID) msgid = *forceMsgID;
    else
    {
      if (!replybuf&&!hbreplyout) msgid=0;
      else if (!(msgid = ++m_lastmsgid)) msgid = ++m_lastmsgid;
    }

    m_shm->send_queue.AddDataToLE(&msgid,4,4);
    m_shm->send_queue.AddDataToLE(&msglen,4,4);
    if (msglen>secondchunklen) m_shm->send_queue.Add(msg,msglen-secondchunklen);
    if (secondchunklen>0) m_shm->send_queue.Add(secondchunk,secondchunklen);

#ifdef VERIFY_MESSAGES
    WDL_SHA1 t;
    t.add(&type,4);
    t.add(&msgid,4);
    t.add(&msglen,4);
    if (msglen>secondchunklen) t.add(msg,msglen-secondchunklen);
    if (secondchunklen>0) t.add(secondchunk,secondchunklen);

    char tb[WDL_SHA1SIZE];
    t.result(tb);
    m_shm->send_queue.Add(tb,sizeof(tb));
#endif


    if ((!replybuf && !hbreplyout) || !msgid) m_shm->Run(); // get this reply out ASAP
  }

  if ((hbreplyout||replybuf) && msgid)
  {
    int wait_cnt=30; // dont run idleproc for first Xms or so

    while (!m_has_had_error)
    {
      if (wait_cnt<=0 && IdleProc && IdleProc(this))
      {
        m_has_had_error=true;
        break;
      }

      WaitingMessage *msg=NULL;
      bool r = RunInternal(msgid,&msg);

      if (msg)
      {
        int rv = msg->m_msgdata.GetSize();

        if (hbreplyout)
        {
          memcpy(hbreplyout->Resize(rv,false),msg->m_msgdata.Get(),rv);
        }

        if (replybuf)
        {
          if (rv > maxretbuflen) rv=maxretbuflen;
          if (rv>0) memcpy(replybuf,msg->m_msgdata.Get(),rv);
        }

        m_shmmutex.Enter();
        msg->_next = m_spares;
        m_spares=msg;
        m_shmmutex.Leave();
        return rv;
      }
      else if (r) break;


      if (wait_cnt>0) wait_cnt--;

      HANDLE evt=m_shm->GetWaitEvent();
      if (evt) WaitForSingleObject(evt,1);
      else Sleep(1);

    }
  }

  if (hbreplyout) hbreplyout->Resize(0,false);

  return -1;
}
Esempio n. 10
0
	void MessageLoop::RunAllPending() {
		assert(this == current());
		state_->quit_received_ = true;
		RunInternal();
	}
Esempio n. 11
0
	void MessageLoop::Run() {
		assert(this == current());
		AutoRunState auto_state(this);
		RunInternal();
	}