Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/qcap/v4l.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/dlls/qcap/v4l.c b/dlls/qcap/v4l.c index 809ce7a406..752751a97b 100644 --- a/dlls/qcap/v4l.c +++ b/dlls/qcap/v4l.c @@ -131,11 +131,6 @@ static HRESULT V4l_Prepare(Capture *device) return S_OK; }
-static void V4l_Unprepare(Capture *device) -{ - heap_free(device->image_data); -} - HRESULT qcap_driver_destroy(Capture *capBox) { TRACE("%p\n", capBox); @@ -439,7 +434,7 @@ static DWORD WINAPI ReadThread(LPVOID lParam) if (FAILED(hr) && hr != VFW_E_NOT_CONNECTED) { TRACE("Return %x, stop IFilterGraph\n", hr); - V4l_Unprepare(capBox); + heap_free(capBox->image_data); capBox->thread = 0; capBox->stopped = TRUE; break; @@ -559,7 +554,7 @@ HRESULT qcap_driver_stop(Capture *capBox, FILTER_STATE *state) if (hr != S_OK && hr != VFW_E_NOT_COMMITTED) WARN("Decommitting allocator: %x\n", hr); } - V4l_Unprepare(capBox); + heap_free(capBox->image_data); }
*state = State_Stopped;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/qcap/v4l.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/dlls/qcap/v4l.c b/dlls/qcap/v4l.c index 752751a97b..ab39b71b82 100644 --- a/dlls/qcap/v4l.c +++ b/dlls/qcap/v4l.c @@ -122,15 +122,6 @@ static int xioctl(int fd, int request, void * arg) return r; }
-/* Prepare the capture buffers */ -static HRESULT V4l_Prepare(Capture *device) -{ - device->image_size = device->height * device->width * 3; - if (!(device->image_data = heap_alloc(device->image_size))) - return E_OUTOFMEMORY; - return S_OK; -} - HRESULT qcap_driver_destroy(Capture *capBox) { TRACE("%p\n", capBox); @@ -392,10 +383,10 @@ static DWORD WINAPI ReadThread(LPVOID lParam) ULONG framecount = 0; unsigned char *pTarget, *pInput, *pOutput;
- hr = V4l_Prepare(capBox); - if (FAILED(hr)) + capBox->image_size = capBox->height * capBox->width * 3; + if (!(capBox->image_data = heap_alloc(capBox->image_size))) { - ERR("Stop IFilterGraph: %x\n", hr); + ERR("Failed to allocate memory.\n"); capBox->thread = 0; capBox->stopped = TRUE; return 0;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/qcap/v4l.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-)
diff --git a/dlls/qcap/v4l.c b/dlls/qcap/v4l.c index ab39b71b82..fb10cce283 100644 --- a/dlls/qcap/v4l.c +++ b/dlls/qcap/v4l.c @@ -361,27 +361,13 @@ static void Resize(const Capture * capBox, LPBYTE output, const BYTE *input) } }
-static void V4l_GetFrame(Capture *device, unsigned char **buffer) -{ - while (video_read(device->fd, device->image_data, device->image_size) == -1) - { - if (errno != EAGAIN) - { - ERR("Failed to read frame: %s\n", strerror(errno)); - break; - } - } - TRACE("Successfully read a frame.\n"); - *buffer = device->image_data; -} - static DWORD WINAPI ReadThread(LPVOID lParam) { Capture * capBox = lParam; HRESULT hr; IMediaSample *pSample = NULL; ULONG framecount = 0; - unsigned char *pTarget, *pInput, *pOutput; + unsigned char *pTarget, *pOutput;
capBox->image_size = capBox->height * capBox->width * 3; if (!(capBox->image_data = heap_alloc(capBox->image_size))) @@ -414,9 +400,17 @@ static DWORD WINAPI ReadThread(LPVOID lParam) TRACE("Data length: %d KB\n", len / 1024);
IMediaSample_GetPointer(pSample, &pTarget); - /* FIXME: Check return values.. */ - V4l_GetFrame(capBox, &pInput); - memcpy(pOutput, pInput, len); + + while (video_read(capBox->fd, capBox->image_data, capBox->image_size) == -1) + { + if (errno != EAGAIN) + { + ERR("Failed to read frame: %s\n", strerror(errno)); + break; + } + } + + memcpy(pOutput, capBox->image_data, len); Resize(capBox, pTarget, pOutput); hr = BaseOutputPinImpl_Deliver((BaseOutputPin *)capBox->pOut, pSample); TRACE("%p -> Frame %u: %x\n", capBox, ++framecount, hr);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/qcap/v4l.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/dlls/qcap/v4l.c b/dlls/qcap/v4l.c index fb10cce283..74443291c9 100644 --- a/dlls/qcap/v4l.c +++ b/dlls/qcap/v4l.c @@ -367,7 +367,7 @@ static DWORD WINAPI ReadThread(LPVOID lParam) HRESULT hr; IMediaSample *pSample = NULL; ULONG framecount = 0; - unsigned char *pTarget, *pOutput; + unsigned char *pTarget;
capBox->image_size = capBox->height * capBox->width * 3; if (!(capBox->image_data = heap_alloc(capBox->image_size))) @@ -378,8 +378,6 @@ static DWORD WINAPI ReadThread(LPVOID lParam) return 0; }
- pOutput = CoTaskMemAlloc(capBox->width * capBox->height * capBox->bitDepth / 8); - while (1) { EnterCriticalSection(&capBox->CritSect); @@ -410,8 +408,7 @@ static DWORD WINAPI ReadThread(LPVOID lParam) } }
- memcpy(pOutput, capBox->image_data, len); - Resize(capBox, pTarget, pOutput); + Resize(capBox, pTarget, capBox->image_data); hr = BaseOutputPinImpl_Deliver((BaseOutputPin *)capBox->pOut, pSample); TRACE("%p -> Frame %u: %x\n", capBox, ++framecount, hr); IMediaSample_Release(pSample); @@ -428,7 +425,6 @@ static DWORD WINAPI ReadThread(LPVOID lParam) }
LeaveCriticalSection(&capBox->CritSect); - CoTaskMemFree(pOutput); return 0; }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/qcap/v4l.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/dlls/qcap/v4l.c b/dlls/qcap/v4l.c index 74443291c9..32c2c02512 100644 --- a/dlls/qcap/v4l.c +++ b/dlls/qcap/v4l.c @@ -105,9 +105,6 @@ struct _Capture int fd, mmap; BOOL iscommitted, stopped;
- int image_size; - unsigned char *image_data; - HANDLE thread; };
@@ -367,10 +364,11 @@ static DWORD WINAPI ReadThread(LPVOID lParam) HRESULT hr; IMediaSample *pSample = NULL; ULONG framecount = 0; - unsigned char *pTarget; + unsigned char *pTarget, *image_data; + unsigned int image_size;
- capBox->image_size = capBox->height * capBox->width * 3; - if (!(capBox->image_data = heap_alloc(capBox->image_size))) + image_size = capBox->height * capBox->width * 3; + if (!(image_data = heap_alloc(image_size))) { ERR("Failed to allocate memory.\n"); capBox->thread = 0; @@ -399,7 +397,7 @@ static DWORD WINAPI ReadThread(LPVOID lParam)
IMediaSample_GetPointer(pSample, &pTarget);
- while (video_read(capBox->fd, capBox->image_data, capBox->image_size) == -1) + while (video_read(capBox->fd, image_data, image_size) == -1) { if (errno != EAGAIN) { @@ -408,7 +406,7 @@ static DWORD WINAPI ReadThread(LPVOID lParam) } }
- Resize(capBox, pTarget, capBox->image_data); + Resize(capBox, pTarget, image_data); hr = BaseOutputPinImpl_Deliver((BaseOutputPin *)capBox->pOut, pSample); TRACE("%p -> Frame %u: %x\n", capBox, ++framecount, hr); IMediaSample_Release(pSample); @@ -416,7 +414,6 @@ static DWORD WINAPI ReadThread(LPVOID lParam) if (FAILED(hr) && hr != VFW_E_NOT_CONNECTED) { TRACE("Return %x, stop IFilterGraph\n", hr); - heap_free(capBox->image_data); capBox->thread = 0; capBox->stopped = TRUE; break; @@ -425,6 +422,7 @@ static DWORD WINAPI ReadThread(LPVOID lParam) }
LeaveCriticalSection(&capBox->CritSect); + heap_free(image_data); return 0; }
@@ -535,7 +533,6 @@ HRESULT qcap_driver_stop(Capture *capBox, FILTER_STATE *state) if (hr != S_OK && hr != VFW_E_NOT_COMMITTED) WARN("Decommitting allocator: %x\n", hr); } - heap_free(capBox->image_data); }
*state = State_Stopped;