virtualcam-module: Don't send frames if stopped
Fixes a bug where frames would continue to send even while stopped
This commit is contained in:
parent
382e37440e
commit
0f08432f53
@ -138,10 +138,23 @@ STDMETHODIMP VCamFilter::Pause()
|
|||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
os_atomic_set_bool(&active, true);
|
||||||
SetEvent(thread_start);
|
SetEvent(thread_start);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP VCamFilter::Run(REFERENCE_TIME tStart)
|
||||||
|
{
|
||||||
|
os_atomic_set_bool(&active, true);
|
||||||
|
return OutputFilter::Run(tStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP VCamFilter::Stop()
|
||||||
|
{
|
||||||
|
os_atomic_set_bool(&active, false);
|
||||||
|
return OutputFilter::Stop();
|
||||||
|
}
|
||||||
|
|
||||||
inline uint64_t VCamFilter::GetTime()
|
inline uint64_t VCamFilter::GetTime()
|
||||||
{
|
{
|
||||||
if (!!clock) {
|
if (!!clock) {
|
||||||
@ -189,6 +202,7 @@ void VCamFilter::Thread()
|
|||||||
UpdatePlaceholder();
|
UpdatePlaceholder();
|
||||||
|
|
||||||
while (!stopped()) {
|
while (!stopped()) {
|
||||||
|
if (os_atomic_load_bool(&active))
|
||||||
Frame(filter_time);
|
Frame(filter_time);
|
||||||
sleepto_100ns(cur_time += interval);
|
sleepto_100ns(cur_time += interval);
|
||||||
filter_time += interval;
|
filter_time += interval;
|
||||||
|
@ -36,6 +36,7 @@ class VCamFilter : public DShow::OutputFilter {
|
|||||||
uint64_t interval = DEFAULT_INTERVAL;
|
uint64_t interval = DEFAULT_INTERVAL;
|
||||||
WinHandle thread_start;
|
WinHandle thread_start;
|
||||||
WinHandle thread_stop;
|
WinHandle thread_stop;
|
||||||
|
volatile bool active = false;
|
||||||
|
|
||||||
nv12_scale_t scaler = {};
|
nv12_scale_t scaler = {};
|
||||||
|
|
||||||
@ -61,4 +62,6 @@ public:
|
|||||||
~VCamFilter() override;
|
~VCamFilter() override;
|
||||||
|
|
||||||
STDMETHODIMP Pause() override;
|
STDMETHODIMP Pause() override;
|
||||||
|
STDMETHODIMP Run(REFERENCE_TIME tStart) override;
|
||||||
|
STDMETHODIMP Stop() override;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user