Beispiel #1
0
DWORD __stdcall Mine_MsgWaitForMultipleObjects(DWORD nCount,CONST HANDLE *lpHandles,BOOL bWaitAll,DWORD dwMilliseconds,DWORD dwWakeMask)
{
  // infinite waits are always passed through
  if(dwMilliseconds >= 0x7fffffff)
    return Real_MsgWaitForMultipleObjects(nCount,lpHandles,bWaitAll,dwMilliseconds,dwWakeMask);
  else
  {
    // waitalls are harder to fake, so we just clamp them to timeout 0.
    if(bWaitAll)
      return Real_MsgWaitForMultipleObjects(nCount,lpHandles,TRUE,0,dwWakeMask);
    else
    {
      // we can't use new/delete, this might be called from a context
      // where they don't work (such as after clib deinit)
      HANDLE *handles = (HANDLE *) _alloca((nCount + 1) * sizeof(HANDLE));
      memcpy(handles,lpHandles,nCount*sizeof(HANDLE));
      handles[nCount] = nextFrameEvent;

      Real_WaitForSingleObject(resyncEvent,INFINITE);
      IncrementWaiting();
  
      DWORD result = Real_MsgWaitForMultipleObjects(nCount+1,handles,FALSE,dwMilliseconds,dwWakeMask);
      if(result == WAIT_OBJECT_0+nCount)
        result = WAIT_TIMEOUT;

      DecrementWaiting();
  
      return result;
    }
  }
}
	void BaseSimilarArtists::handleInfoReplyError ()
	{
		auto reply = qobject_cast<QNetworkReply*> (sender ());
		reply->deleteLater ();

		qWarning () << Q_FUNC_INFO
				<< reply->errorString ();

		DecrementWaiting ();
	}
	void BaseSimilarArtists::handleInfoReplyFinished ()
	{
		auto reply = qobject_cast<QNetworkReply*> (sender ());
		reply->deleteLater ();

		const int similarity = reply->property ("Similarity").toInt ();
		const auto& similarTo = reply->property ("SimilarTo").toStringList ();

		QDomDocument doc;
		if (!doc.setContent (reply->readAll ()))
		{
			qWarning () << Q_FUNC_INFO
					<< "unable to parse response";
			DecrementWaiting ();
			return;
		}

		const auto& info = GetArtistInfo (doc.documentElement ().firstChildElement ("artist"));
		Similar_ << Media::SimilarityInfo { info, similarity, similarTo };

		DecrementWaiting ();
	}
	void HypedArtistsFetcher::pendingBioReady ()
	{
		auto pendingBio = qobject_cast<PendingArtistBio*> (sender ());
		pendingBio->deleteLater ();

		const auto& info = pendingBio->GetArtistBio ();
		const auto pos = std::find_if (Infos_.begin (), Infos_.end (),
				[&info] (decltype (Infos_.at (0)) thatInfo) { return thatInfo.Info_.Name_ == info.BasicInfo_.Name_; });
		if (pos != Infos_.end ())
			pos->Info_ = info.BasicInfo_;

		DecrementWaiting ();
	}
Beispiel #5
0
VOID __stdcall Mine_Sleep(DWORD dwMilliseconds)
{
  if(dwMilliseconds)
  {
    Real_WaitForSingleObject(resyncEvent,INFINITE);

    IncrementWaiting();
    if(params.MakeSleepsLastOneFrame)
      Real_WaitForSingleObject(nextFrameEvent,dwMilliseconds);
    else
      Real_WaitForSingleObject(nextFrameEvent,params.SleepTimeout);
    DecrementWaiting();
  }
  else
    Real_Sleep(0);
}
	void PendingSimilarArtists::handleTagsReplyFinished ()
	{
		auto reply = qobject_cast<QNetworkReply*> (sender ());
		reply->deleteLater ();

		const auto& tags = lastfm::Tag::list (reply).values ();
		Media::TagInfos_t infos;
		std::transform (tags.begin (), tags.end (), std::back_inserter (infos),
				[] (const QString& name) { Media::TagInfo info = { name }; return info; });

		const int pos = reply->property ("Position").toInt ();
		if (Similar_.size () > pos && pos >= 0)
			Similar_ [pos].first.Tags_ = infos;

		DecrementWaiting ();
	}
Beispiel #7
0
DWORD __stdcall Mine_WaitForSingleObject(HANDLE hHandle,DWORD dwMilliseconds)
{
  if(dwMilliseconds <= 0x7fffffff)
  {
    Real_WaitForSingleObject(resyncEvent,INFINITE);
    IncrementWaiting();

    HANDLE handles[] = { hHandle, nextFrameEvent };
    DWORD result = Real_WaitForMultipleObjects(2,handles,FALSE,dwMilliseconds);

    DecrementWaiting();

    if(result == WAIT_OBJECT_0+1)
      result = WAIT_TIMEOUT;

    return result;
  }
  else
    return Real_WaitForSingleObject(hHandle,dwMilliseconds);
}
	void HypedArtistsFetcher::pendingBioError ()
	{
		sender ()->deleteLater ();

		DecrementWaiting ();
	}