Better locking: CamDevice::Start/StopTransfer() should be called with lock held.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21125 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -172,7 +172,12 @@ CamDevice::StopTransfer()
|
|||||||
if (err < B_OK)
|
if (err < B_OK)
|
||||||
return err;
|
return err;
|
||||||
fTransferEnabled = false;
|
fTransferEnabled = false;
|
||||||
|
|
||||||
|
// the thread itself might Lock()
|
||||||
|
fLocker.Unlock();
|
||||||
wait_for_thread(fPumpThread, &err);
|
wait_for_thread(fPumpThread, &err);
|
||||||
|
fLocker.Lock();
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -494,6 +494,12 @@ VideoProducer::Disconnect(const media_source &source,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* Some dumb apps don't stop nodes before disconnecting... */
|
||||||
|
if (fRunning)
|
||||||
|
HandleStop();
|
||||||
|
#endif
|
||||||
|
|
||||||
fEnabled = false;
|
fEnabled = false;
|
||||||
fOutput.destination = media_destination::null;
|
fOutput.destination = media_destination::null;
|
||||||
|
|
||||||
@@ -616,7 +622,10 @@ VideoProducer::HandleStart(bigtime_t performance_time)
|
|||||||
|
|
||||||
resume_thread(fThread);
|
resume_thread(fThread);
|
||||||
|
|
||||||
fCamDevice->StartTransfer();
|
{
|
||||||
|
BAutolock lock(fCamDevice->Locker());
|
||||||
|
fCamDevice->StartTransfer();
|
||||||
|
}
|
||||||
|
|
||||||
fRunning = true;
|
fRunning = true;
|
||||||
return;
|
return;
|
||||||
@@ -640,6 +649,7 @@ VideoProducer::HandleStop(void)
|
|||||||
delete_sem(fFrameSync);
|
delete_sem(fFrameSync);
|
||||||
wait_for_thread(fThread, &fThread);
|
wait_for_thread(fThread, &fThread);
|
||||||
|
|
||||||
|
BAutolock lock(fCamDevice->Locker());
|
||||||
fCamDevice->StopTransfer();
|
fCamDevice->StopTransfer();
|
||||||
|
|
||||||
fRunning = false;
|
fRunning = false;
|
||||||
@@ -673,6 +683,7 @@ VideoProducer::FrameGenerator()
|
|||||||
bigtime_t wait_until = system_time();
|
bigtime_t wait_until = system_time();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
PRINTF(1, ("FrameGenerator: acquire_sem_etc() until %Ldµs (in %Ldµs)\n", wait_until, wait_until - system_time()));
|
||||||
status_t err = acquire_sem_etc(fFrameSync, 1, B_ABSOLUTE_TIMEOUT,
|
status_t err = acquire_sem_etc(fFrameSync, 1, B_ABSOLUTE_TIMEOUT,
|
||||||
wait_until);
|
wait_until);
|
||||||
|
|
||||||
@@ -697,6 +708,12 @@ VideoProducer::FrameGenerator()
|
|||||||
if (wait_until < system_time())
|
if (wait_until < system_time())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
PRINTF(1, ("FrameGenerator: wait until %Ld, %ctimed out, %crunning, %cenabled.\n",
|
||||||
|
wait_until,
|
||||||
|
(err == B_OK)?'!':' ',
|
||||||
|
(fRunning)?' ':'!',
|
||||||
|
(fEnabled)?' ':'!'));
|
||||||
|
|
||||||
/* If the semaphore was acquired successfully, it means something
|
/* If the semaphore was acquired successfully, it means something
|
||||||
* changed the timing information (see VideoProducer::Connect()) and
|
* changed the timing information (see VideoProducer::Connect()) and
|
||||||
* so the thread should go back to sleep until the newly-calculated
|
* so the thread should go back to sleep until the newly-calculated
|
||||||
@@ -751,6 +768,9 @@ VideoProducer::FrameGenerator()
|
|||||||
*(p++) = ((((x+y)^0^x)+fFrame) & 0xff) * (0x01010101 & fColor);
|
*(p++) = ((((x+y)^0^x)+fFrame) & 0xff) * (0x01010101 & fColor);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//NO! must be called without lock!
|
||||||
|
//BAutolock lock(fCamDevice->Locker());
|
||||||
|
|
||||||
//#ifdef UseFillFrameBuffer
|
//#ifdef UseFillFrameBuffer
|
||||||
err = fCamDevice->FillFrameBuffer(buffer);
|
err = fCamDevice->FillFrameBuffer(buffer);
|
||||||
if (err < B_OK) {
|
if (err < B_OK) {
|
||||||
@@ -765,6 +785,7 @@ VideoProducer::FrameGenerator()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
PRINTF(1, ("FrameGenerator: SendBuffer...\n"));
|
||||||
/* Send the buffer on down to the consumer */
|
/* Send the buffer on down to the consumer */
|
||||||
if (SendBuffer(buffer, fOutput.destination) < B_OK) {
|
if (SendBuffer(buffer, fOutput.destination) < B_OK) {
|
||||||
PRINTF(-1, ("FrameGenerator: Error sending buffer\n"));
|
PRINTF(-1, ("FrameGenerator: Error sending buffer\n"));
|
||||||
@@ -774,6 +795,7 @@ VideoProducer::FrameGenerator()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRINTF(1, ("FrameGenerator: thread existed.\n"));
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user