Beispiel #1
0
void CMMSoundSubSystem::fillNextBuffer(void) {

		// check if the buffer is already prepared (should not !)
		if (m_waveHeader[m_currentBuffer].dwFlags&WHDR_PREPARED) {
			waveOutUnprepareHeader(m_hWaveOut,&m_waveHeader[m_currentBuffer],sizeof(WAVEHDR));
		}
		// Call the user function to fill the buffer with anything you want ! :-)
		if (m_pUserCallback) {
			m_pUserCallback(m_pSoundBuffer[m_currentBuffer],m_bufferSize);
		}
		// Prepare the buffer to be sent to the WaveOut API
		m_waveHeader[m_currentBuffer].lpData = (char*)m_pSoundBuffer[m_currentBuffer];
		m_waveHeader[m_currentBuffer].dwBufferLength = m_bufferSize;
		waveOutPrepareHeader(m_hWaveOut,&m_waveHeader[m_currentBuffer],sizeof(WAVEHDR));
		// Send the buffer the the WaveOut queue
		waveOutWrite(m_hWaveOut,&m_waveHeader[m_currentBuffer],sizeof(WAVEHDR));
		m_currentBuffer++;
		if (m_currentBuffer >= REPLAY_NBSOUNDBUFFER) m_currentBuffer = 0;
}
//  ---------------------------------------------------------------------------
void CUIWidgetManager::Update()
{
	CUIMessage	 message;
	
	CUILinkList	*pList = NULL;
	CUIListNode	*pNode;
	CUIBase		*pWidget, *pRootWidget;
	
	int32		result = CUIR_MESSAGE_NOT_HANDLED;

	if (!m_bInitted) {
		CUI_ERR("WidgetManager was never Initialized!\n");
		return;
	}

	// process messages 
	while (CUIR_OK == m_pMessageQueue->DequeueMessage(&message)) {		

		//CUIMessageQueue::DisplayMessage(NULL, &message);

		// handle widget-manager level messages here, and pass on
		// to topmost widgets.  We look for certain internal messages
		// before honoring the user-defined callback (if any)

				switch (message.m_Message) {
				
			case CUIM_WIDGET_SCHEDULE_FOR_DESTROY:
				m_pDestroyList->Add(message.m_pSender);
				break;

			default:
					
				// has the user requested callbacks from the WidgetManager?
				if (m_pUserCallback) {
					message.m_pUserObject = m_pUserCallbackObject;
					message.m_pUserData   = m_pUserCallbackData;

					result = m_pUserCallback(&message);
				}

				// if the user handled the message, I'm done
				if (result != CUIR_MESSAGE_NOT_HANDLED) continue;

				// messages that are "system" messages (CUIM_WIDGET_ON_DESTROY, etc.)
				// should not be sent to widgets.
				if (message.m_Message < CUIM_SYSTEM_THRESHOLD) continue;

				// else, send the message to my top-level widget, who will propagate it
				pRootWidget = this->GetRootWidget();
				
				if (!pRootWidget) {
					// uh-oh!  no desktop widget
					continue;
				}

				pRootWidget->HandleMessage(&message);
				
		}	// switch (message.m_Message)

	}
	
	// render the ui system
	this->Render();	

	this->DebugShowFocusWidget();
	
	// once all the messages have been processed, it's safe to
	// handle the destroy queue.
	pList = m_pDestroyList;
	pNode = pList->GetHead();
	
	while (pNode) {
		pWidget = (CUIBase*)pList->GetData(pNode);
		//CUI_DBG("Destroy widget: %x\n", pWidget);
		this->InternalDestroyWidget(pWidget);
		pList->Remove(pNode);
		pNode = pList->GetHead();
	}
}