Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CSourceStream - wait for request - stuck on specific resolutions

37 views
Skip to first unread message

Mechi

unread,
Aug 3, 2009, 10:11:03 AM8/3/09
to
Hi!
Sometimes when I try different resolutions, my SourceThread freezes at the
second
cmd = GetRequest(); (in source.cpp - in ThreadProc() below)
and therefore never gets to DoProcessingLoop().

The stack of the thread brings me to wxutil.h - class CAMEvent -
BOOL Wait(DWORD dwTimeout = INFINITE) {
return (WaitForSingleObject(m_hEvent, dwTimeout) ==
WAIT_OBJECT_0);
};

The data is coming in OK, just this thread, which shou8ld be delivering it
has a problem. It has to do with frame size/resolution - how can I fix it?

Thanks,
mechi

DWORD CSourceStream::ThreadProc(void) {

HRESULT hr; // the return code from calls
Command com;

do {
com = GetRequest();
if (com != CMD_INIT) {
DbgLog((LOG_ERROR, 1, TEXT("Thread expected init command")));
Reply((DWORD) E_UNEXPECTED);
}
} while (com != CMD_INIT);

DbgLog((LOG_TRACE, 1, TEXT("CSourceStream worker thread initializing")));

hr = OnThreadCreate(); // perform set up tasks
if (FAILED(hr)) {
DbgLog((LOG_ERROR, 1, TEXT("CSourceStream::OnThreadCreate failed.
Aborting thread.")));
OnThreadDestroy();
Reply(hr); // send failed return code from OnThreadCreate
return 1;
}

// Initialisation suceeded
Reply(NOERROR);

Command cmd;
do {
cmd = GetRequest(); // here's where it freezes

switch (cmd) {

case CMD_EXIT:
Reply(NOERROR);
break;

case CMD_RUN:
DbgLog((LOG_ERROR, 1, TEXT("CMD_RUN received before a CMD_PAUSE???")));
// !!! fall through???

case CMD_PAUSE:
Reply(NOERROR);
DoBufferProcessingLoop();
break;

case CMD_STOP:
Reply(NOERROR);
break;

default:
DbgLog((LOG_ERROR, 1, TEXT("Unknown command %d received!"), cmd));
Reply((DWORD) E_NOTIMPL);
break;
}
} while (cmd != CMD_EXIT);

hr = OnThreadDestroy(); // tidy up.
if (FAILED(hr)) {
DbgLog((LOG_ERROR, 1, TEXT("CSourceStream::OnThreadDestroy failed.
Exiting thread.")));
return 1;
}

DbgLog((LOG_TRACE, 1, TEXT("CSourceStream worker thread exiting")));
return 0;
}


Chris P.

unread,
Aug 3, 2009, 1:27:31 PM8/3/09
to
On Mon, 3 Aug 2009 07:11:03 -0700, Mechi wrote:

> Sometimes when I try different resolutions, my SourceThread freezes at the
> second
> cmd = GetRequest(); (in source.cpp - in ThreadProc() below)
> and therefore never gets to DoProcessingLoop().
>
> The stack of the thread brings me to wxutil.h - class CAMEvent -
> BOOL Wait(DWORD dwTimeout = INFINITE) {
> return (WaitForSingleObject(m_hEvent, dwTimeout) ==
> WAIT_OBJECT_0);
> };
>
> The data is coming in OK, just this thread, which shou8ld be delivering it
> has a problem. It has to do with frame size/resolution - how can I fix it?

It would seem as though your filter is never getting the pause/run request,
which more than likely means that one of the other filters in the graph
after yours failed to transition state. Put a breakpoint in
CBaseMediaFilter::Pause() to confirm.

--
http://www.chrisnet.net/code.htm
[MS MVP for DirectShow / MediaFoundation]

Mechi

unread,
Aug 4, 2009, 9:31:02 AM8/4/09
to

"Chris P." wrote:

> It would seem as though your filter is never getting the pause/run request,
> which more than likely means that one of the other filters in the graph
> after yours failed to transition state. Put a breakpoint in
> CBaseMediaFilter::Pause() to confirm.
>

Hi!
I put breakpoints all over...
After changing resolutions, GetMediatype and SetMediaType get called many
times with the new resolution and frame size.
Then the overload VCam::Pause() got called, DoBufferProcessingLoop() got
called, FillBuffer got called ONCE and then the thread is stuck at

DWORD CAMThread::GetRequest()
{
m_EventSend.Wait(); // doesn't return from here
return m_dwParam;
}

The thread which is receiving frames from the camera is working fine - data
is constantly coming in and being buffered in a circular buffer.

I tried frame resolution of 1000x800.

Thanks for any ideas
Mechi

Chris P.

unread,
Aug 4, 2009, 10:14:02 AM8/4/09
to
On Tue, 4 Aug 2009 06:31:02 -0700, Mechi wrote:

> Hi!
> I put breakpoints all over...
> After changing resolutions, GetMediatype and SetMediaType get called many
> times with the new resolution and frame size.
> Then the overload VCam::Pause() got called, DoBufferProcessingLoop() got
> called, FillBuffer got called ONCE and then the thread is stuck at
>
> DWORD CAMThread::GetRequest()
> {
> m_EventSend.Wait(); // doesn't return from here
> return m_dwParam;
> }

That thread is supposed to be stuck there. This is the thread that waits
for commands to start or stop DoBufferProcessingLoop().



> The thread which is receiving frames from the camera is working fine - data
> is constantly coming in and being buffered in a circular buffer.
>
> I tried frame resolution of 1000x800.

Either your DoBufferProcessingLoop() is getting stuck in
GetDeliveryBuffer() waiting for a free sample or Deliver() never returns.
If it is the first then there may be a bad time stamp attached to the
sample which is causing the renderer to wait for the presentation time to
be met. If it gets hung in Deliver() then you may have a filter downstream
that is failing to handle the large sample correctly.

Mechi

unread,
Aug 4, 2009, 10:55:01 AM8/4/09
to

> Either your DoBufferProcessingLoop() is getting stuck in
> GetDeliveryBuffer() waiting for a free sample or Deliver() never returns.
> If it is the first then there may be a bad time stamp attached to the
> sample which is causing the renderer to wait for the presentation time to
> be met. If it gets hung in Deliver() then you may have a filter downstream
> that is failing to handle the large sample correctly.
>

Thanks so much!
I found it!
It was being stuck in Deliver() - because i hadn't correctly updated the
buffer size to the new size according to the new resolution. I did it by
hand and it worked - so I found the appropriate place in the code and updated
it there.
Now I can see all types of resolutions (rectangles of all shapes and sizes)!
Thanks again!

0 new messages