void KinectAudioEventNotifier::ProcessEvents()
{
	bool processing = true;

	AudioData* currentData = NULL;

	while (processing)
	{
		processing = speechDataToProcess.try_pop(currentData);
		
		if(processing)
		{
			for (int j = 0; j < listeners.size(); j++)
			{
				if(listeners[j]->Enabled)
					listeners[j]->AudioDataReceived(currentData);
			}
			
			if(currentData)
			{
				delete currentData;
				currentData = NULL;
			}
		}
	}
}
Esempio n. 2
0
		bool start_message_loop()
		{
			if(thread.get_id() != std::thread::id())
				return false;

			thread = std::thread([this](){
				if(::CoInitialize(nullptr))
					return;

				::quote::win32::message_loop([this](){
					if(queue.empty()){
						::Sleep(1);
						return;
					}

					std::shared_ptr<async_message> message;
					if(queue.try_pop(message)){
						switch(message->message){
						case async_message::message_type::create:
							{
								auto param = reinterpret_cast<creation_params*>(message->data.get());
								HWND hwnd = ::CreateWindowExW(
									param->exstyle,
									param->classname,
									param->title,
									param->style,
									param->x,
									param->y,
									param->w,
									param->h,
									param->hparent,
									nullptr,
									::GetModuleHandleW(nullptr),
									param->data);
								message->result = hwnd != nullptr;

								std::lock_guard<std::mutex> lock(message->mutex);
								message->cv.notify_one();
							}
							break;
						case async_message::message_type::destroy:
							{
								message->result = ::DestroyWindow(reinterpret_cast<HWND>(message->data.get())) != 0;

								std::lock_guard<std::mutex> lock(message->mutex);
								message->cv.notify_one();
							}
							break;
						}
					}
				});

				::CoUninitialize();
			});

			return true;
		}