コード例 #1
0
ファイル: carbon.c プロジェクト: omegahat/REventLoop
void
R_runCarbonEventLoop(void)
{
#if 1
  RunApplicationEventLoop();
#else
  RunCurrentEventLoop(kEventDurationForever);
#endif
}
コード例 #2
0
ファイル: aeffguieditor.cpp プロジェクト: DaniM/lyngo
//-----------------------------------------------------------------------------
void AEffGUIEditor::wait (unsigned long ms)
{
	#if MAC
	RunCurrentEventLoop (kEventDurationMillisecond * ms);
	
	#elif WINDOWS
	Sleep (ms);

	#endif
}
コード例 #3
0
ファイル: plugguieditor.cpp プロジェクト: DaniM/lyngo
//-----------------------------------------------------------------------------
void PluginGUIEditor::wait (uint32_t ms)
{
	#if MAC
	RunCurrentEventLoop (kEventDurationMillisecond * ms);
	
	#elif WINDOWS
	Sleep (ms);

	#endif
}
コード例 #4
0
int
IsSkypeAvailable(void)
{
	//is skype available?
	isavailable = 0;
	CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter();

	CFNotificationCenterPostNotification(
		center,
		CFSTR("SKSkypeAPIAvailabilityRequest"),
		NULL,
		NULL,
		TRUE);
	
	//Should only take 1 second or less to reply
	RunCurrentEventLoop(1);
	int avail = isavailable;
	isavailable = 0;
	return avail;
}
コード例 #5
0
ファイル: plugguieditor.cpp プロジェクト: DaniM/lyngo
//-----------------------------------------------------------------------------
void PluginGUIEditor::doIdleStuff ()
{
	// get the current time
	uint32_t currentTicks = getTicks ();

	// YG TEST idle ();
	if (currentTicks < lLastTicks)
	{
		#if (MAC && TARGET_API_MAC_CARBON)
		RunCurrentEventLoop (kEventDurationMillisecond * kIdleRateMin);
		#else
		wait (kIdleRateMin);
		#endif
		currentTicks += kIdleRateMin;
		if (currentTicks < lLastTicks - kIdleRate2)
			return;
	}
	idle (); // TEST

	#if WINDOWS
	struct tagMSG windowsMessage;
	if (PeekMessage (&windowsMessage, NULL, WM_PAINT, WM_PAINT, PM_REMOVE))
		DispatchMessage (&windowsMessage);

	#elif MAC && !__LP64__
	EventRef event;
	EventTypeSpec eventTypes[] = { {kEventClassWindow, kEventWindowUpdate}, {kEventClassWindow, kEventWindowDrawContent} };
	if (ReceiveNextEvent (GetEventTypeCount (eventTypes), eventTypes, kEventDurationNoWait, true, &event) == noErr)
	{
		SendEventToEventTarget (event, GetEventDispatcherTarget ());
		ReleaseEvent (event);
	}
	#endif

	// save the next time
 	lLastTicks = currentTicks + kIdleRate;
}
コード例 #6
0
char *skype_send_message(char *message_format, ...)
{
	static guint next_message_num = 0;
	guint cur_message_num;
	char *message;
	char *return_msg;
	va_list args;
#if __APPLE__ || _WIN32 || __FreeBSD__
	guint timeout = 0;
#else
	gboolean condition_result;
	GTimeVal endtime = {0,0};
#endif
	
	va_start(args, message_format);
	message = g_strdup_vprintf(message_format, args);
	va_end(args);

	if (!message_queue)
		message_queue = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, NULL);
	
	g_static_mutex_lock2(&mutex);
	if (!condition)
		condition = g_cond_new();
	cur_message_num = next_message_num++;
	if (next_message_num == G_MAXUINT)
		next_message_num = 0;
	g_static_mutex_unlock2(&mutex);
	
	//Send message asynchronously
	skype_send_message_nowait("#%u %s", cur_message_num, message);
	g_free(message);

	g_static_mutex_lock2(&mutex);
	//Wait for a response
	while(g_hash_table_lookup(message_queue, &cur_message_num) == NULL)
	{
		g_static_mutex_unlock2(&mutex);
		g_thread_yield();
			
#ifdef __APPLE__
		RunCurrentEventLoop(kEventDurationMillisecond);
		g_static_mutex_lock2(&mutex);

		if (timeout++ == 10000)
#else
#ifdef _WIN32
		Sleep(1);
		g_static_mutex_lock2(&mutex);

		if (timeout++ == 10000)
#else
#ifdef __FreeBSD__
		usleep(1000);
		g_static_mutex_lock2(&mutex);
		
		if (timeout++ == 10000)
#else
		
		//wait for message for a maximum of 10 seconds
		g_get_current_time(&endtime);
		g_time_val_add(&endtime, 10 * G_USEC_PER_SEC);
		condition_result = g_cond_timed_wait(condition, g_static_mutex_get_mutex2(&mutex), &endtime);
		
		//g_cond_timed_wait already locks this mutex
		//g_static_mutex_lock2(&mutex);
		
		if(!condition_result)
#endif
#endif
#endif
		{
			//we timed out while waiting
			g_hash_table_remove(message_queue, &cur_message_num);
			g_static_mutex_unlock2(&mutex);
			return g_strdup("");	
		}
	}
	return_msg = (char *)g_hash_table_lookup(message_queue, &cur_message_num);
	g_hash_table_remove(message_queue, &cur_message_num);
	g_static_mutex_unlock2(&mutex);
	
	if (strncmp(return_msg, "ERROR", 5) == 0)
	{
		g_free(return_msg);
		return g_strdup("");
	}
	return return_msg;
}