Click here to Skip to main content
15,903,175 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: calling OnDraw() Pin
susanne14-Jul-09 7:05
susanne14-Jul-09 7:05 
GeneralRe: calling OnDraw() Pin
Stuart Dootson4-Jul-09 7:33
professionalStuart Dootson4-Jul-09 7:33 
Questionwhat is the entry id for junk mail Pin
santhosh-padamatinti3-Jul-09 3:54
santhosh-padamatinti3-Jul-09 3:54 
Questionxmlhttp improper response Pin
Ash_VCPP3-Jul-09 2:28
Ash_VCPP3-Jul-09 2:28 
AnswerRe: xmlhttp improper response Pin
Stuart Dootson3-Jul-09 3:34
professionalStuart Dootson3-Jul-09 3:34 
Questionthreads and their time slots. [modified] Pin
Souldrift2-Jul-09 23:45
Souldrift2-Jul-09 23:45 
AnswerRe: threads and their time slots. Pin
Stuart Dootson3-Jul-09 0:31
professionalStuart Dootson3-Jul-09 0:31 
GeneralRe: threads and their time slots. [modified] Pin
Souldrift3-Jul-09 1:17
Souldrift3-Jul-09 1:17 
Thanks for the idea. I tried it (very exitedly). But I´m running into the same problem.
My new code is:

int RTPEngine::SendRTPPacket( BYTE* data, int size )
{
	if( data && size > 0 && m_pHeader )
	{
		m_pLogger->Out(Logger::DEBUG, "RTPEngine: Sending data package with size %d (excluding header).\n", size);

		BYTE* packet = new BYTE[size+12];
		BYTE* headerBytes = m_pHeader->GetInc();

		for( int i = 0; i < 12; i++ )
		{
			packet[i] = headerBytes[i];
		}
		for( int i = 0; i < size; i++ )
		{
			packet[i+12] = data[i];
		}

		double now = 0.0; // milliseconds
		if( m_dPacketSendTime != 0.0 )
		{
			now = ((double) clock() / CLK_TCK) * 1000; // milliseconds
			m_pLogger->Out( Logger::DEBUG, "RTPEngine: Time now = %f.\n", now );
			double dueMS = m_dPacketSendTime-now; // relative time to wait in ms
			if( dueMS > 0 )
			{
				HANDLE hTimer = 0;
				LARGE_INTEGER liDueTime;
				hTimer = ::CreateWaitableTimer(0, TRUE, L"WaitableTimer");
				liDueTime.QuadPart = -((int)dueMS * 10000); // relative waitin time converted to '100-nanoseconds'
				SetWaitableTimer(hTimer, &liDueTime, 0, NULL, NULL, FALSE);
				::WaitForSingleObject(hTimer, INFINITE);
			}
		}

		now = ((double) clock() / CLK_TCK) * 1000;
		int rc=sendto(m_oUDPSocket,(char*)packet,size+12,0,(SOCKADDR*)&m_oUDPAddress,sizeof(SOCKADDR_IN));

		m_pLogger->Out( Logger::DEBUG, "RTPEngine: Packet sent at = %f.\n", now );

		m_dPacketSendTime = ((double) clock() / CLK_TCK) * 1000; // milliseconds
		m_dPacketSendTime += (m_dPacketLengthMillis*(1.0 - m_dRTPOverlap));
		m_pLogger->Out( Logger::DEBUG, "RTPEngine: Next send time = %f.\n", m_dPacketSendTime );

		return size;
	}
	else
		return 0;
}


I´m at a loss ...

Souldrift

Edit:

Actually I just found that this doesn´t work as expected. The output is:

RTPEngine: Next send time = 3009.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Time now = 3000.
RTPEngine: Packet sent at = 3000.
RTPEngine: Next send time = 3009.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Time now = 3000.
RTPEngine: Packet sent at = 3000.
RTPEngine: Next send time = 3009.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Time now = 3000.
RTPEngine: Packet sent at = 3000.

It doesn´t wait at all ??

modified on Friday, July 3, 2009 7:34 AM

GeneralRe: threads and their time slots. Pin
Stuart Dootson3-Jul-09 1:58
professionalStuart Dootson3-Jul-09 1:58 
GeneralRe: threads and their time slots. Pin
Souldrift3-Jul-09 2:43
Souldrift3-Jul-09 2:43 
GeneralRe: threads and their time slots. Pin
Stuart Dootson3-Jul-09 3:30
professionalStuart Dootson3-Jul-09 3:30 
GeneralRe: threads and their time slots. Pin
Souldrift3-Jul-09 5:44
Souldrift3-Jul-09 5:44 
AnswerRe: threads and their time slots. Pin
Roger Stoltz3-Jul-09 2:09
Roger Stoltz3-Jul-09 2:09 
GeneralRe: threads and their time slots. Pin
Souldrift3-Jul-09 2:50
Souldrift3-Jul-09 2:50 
AnswerRe: threads and their time slots. Pin
Keith Worden3-Jul-09 5:29
Keith Worden3-Jul-09 5:29 
GeneralRe: threads and their time slots. Pin
Souldrift3-Jul-09 6:04
Souldrift3-Jul-09 6:04 
AnswerRe: threads and their time slots. Pin
Souldrift3-Jul-09 6:07
Souldrift3-Jul-09 6:07 
GeneralRe: threads and their time slots. Pin
Keith Worden3-Jul-09 6:18
Keith Worden3-Jul-09 6:18 
GeneralRe: threads and their time slots. Pin
Souldrift3-Jul-09 6:39
Souldrift3-Jul-09 6:39 
AnswerRe: threads and their time slots. Pin
Souldrift3-Jul-09 6:48
Souldrift3-Jul-09 6:48 
AnswerRe: threads and their time slots. Pin
Souldrift3-Jul-09 7:34
Souldrift3-Jul-09 7:34 
GeneralRe: threads and their time slots. Pin
Stuart Dootson3-Jul-09 8:33
professionalStuart Dootson3-Jul-09 8:33 
GeneralRe: threads and their time slots. Pin
Roger Stoltz3-Jul-09 8:41
Roger Stoltz3-Jul-09 8:41 
GeneralRe: threads and their time slots. Pin
Stuart Dootson3-Jul-09 8:50
professionalStuart Dootson3-Jul-09 8:50 
GeneralRe: threads and their time slots. Pin
Roger Stoltz3-Jul-09 8:55
Roger Stoltz3-Jul-09 8:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.