uint32_t dst_width;
uint32_t dst_height;
uint32_t dst_fmt;
- void *buf;
} MCBackendWin;
/*
ULONG dwSize, BYTE *pBuffer)
{
void *tmp_buf;
- uint32_t imgsize;
MCBackendWin *backend = (MCBackendWin *)(state->backend);
- imgsize = get_sizeimage(backend->dst_fmt,
- backend->dst_width,
- backend->dst_height);
-
- if (imgsize > (uint32_t)dwSize) {
+ if (state->buf_size > (uint32_t)dwSize) {
ERR("Image size is mismatched\n");
return E_FAIL;
}
- if (convert_frame(backend->src_fmt, backend->dst_fmt,
- backend->dst_width, backend->dst_height,
- (size_t)dwSize, pBuffer, backend->buf, true) > 0) {
- return E_FAIL;
- }
-
qemu_mutex_lock(&state->thread_mutex);
if (state->streamon) {
if (backend->ready_count < MARUCAM_SKIPFRAMES) {
return S_OK;
}
tmp_buf = state->fb_ptr + state->buf_size * (state->req_frame - 1);
- memcpy(tmp_buf, backend->buf, state->buf_size);
+ if (convert_frame(backend->src_fmt, backend->dst_fmt,
+ backend->dst_width, backend->dst_height,
+ (size_t)dwSize, pBuffer, tmp_buf, true) > 0) {
+ state->req_frame = 0; /* clear request */
+ state->isr |= 0x08; /* set a error flag of rasing a interrupt */
+ qemu_bh_schedule(state->tx_bh);
+ qemu_mutex_unlock(&state->thread_mutex);
+ return E_FAIL;
+ }
state->req_frame = 0; /* clear request */
state->isr |= 0x01; /* set a flag of rasing a interrupt */
qemu_bh_schedule(state->tx_bh);
static void backend_win_stream_on(MaruCamState *state)
{
HRESULT hr;
- uint32_t pixfmt, width, height;
MCBackendWin *backend = (MCBackendWin *)(state->backend);
backend->ready_count = 0;
- width = backend->dst_width;
- height = backend->dst_height;
- pixfmt = backend->dst_fmt;
- state->buf_size = get_sizeimage(pixfmt, width, height);
-
- INFO("Pixfmt(%c%c%c%c), W:H(%d:%d), buf size(%u)\n",
- (char)(pixfmt), (char)(pixfmt >> 8),
- (char)(pixfmt >> 16), (char)(pixfmt >> 24),
- width, height, state->buf_size);
+ state->buf_size = get_sizeimage(backend->dst_fmt,
+ backend->dst_width,
+ backend->dst_height);
+
+ INFO("Pixfmt(%.4s), W:H(%d:%d), buf size(%u)\n",
+ (const char *)&backend->dst_fmt, backend->dst_width,
+ backend->dst_height, state->buf_size);
INFO("Starting preview\n");
assert(backend->pCallback != NULL);
return;
}
- if (backend->buf) {
- g_free(backend->buf);
- backend->buf = NULL;
- }
- backend->buf = (void *)g_malloc0(state->buf_size);
- if (backend->buf == NULL) {
- state->ret_val = ENOMEM;
- return;
- }
-
hr = IMediaControl_Run(backend->pMC);
if (FAILED(hr)) {
ERR("Failed to run media control. hr=0x%x\n", hr);
return;
}
- if (backend->buf) {
- g_free(backend->buf);
- backend->buf = NULL;
- }
state->buf_size = 0;
INFO("Stopping preview\n");
return;
}
- if ((backend->dst_width != f->width) &&
- (backend->dst_height != f->height)) {
+ if (backend->dst_width != f->width ||
+ backend->dst_height != f->height ||
+ backend->dst_fmt != f->pixelformat) {
HRESULT hr = SetFormat(backend, f->width, f->height, f->pixelformat);
if (FAILED(hr)) {
state->ret_val = EINVAL;