diff options
-rw-r--r-- | android/avd/hardware-properties.ini | 4 | ||||
-rw-r--r-- | android/camera/camera-capture-linux.c | 55 | ||||
-rw-r--r-- | android/camera/camera-capture-mac.c | 4 | ||||
-rwxr-xr-x | android/camera/camera-capture-windows.c | 105 | ||||
-rwxr-xr-x | android/camera/camera-common.h | 26 | ||||
-rwxr-xr-x | android/camera/camera-format-converters.c | 5 | ||||
-rw-r--r-- | android/camera/camera-service.c | 80 | ||||
-rw-r--r-- | hw/goldfish_pipe.c | 19 |
8 files changed, 64 insertions, 234 deletions
diff --git a/android/avd/hardware-properties.ini b/android/avd/hardware-properties.ini index 8fb51b4..fb53536 100644 --- a/android/avd/hardware-properties.ini +++ b/android/avd/hardware-properties.ini @@ -305,12 +305,10 @@ abstract = 1-st emulated web camera direction description = Direction of the 1-st emulated web camera # Defines direction of the emulated webcam with index 1 -# Note that first two cameras must face in opposite directions in order to enable -# camera switch in the camera application. # name = hw.webcam.1.direction type = string -default = back +default = front abstract = 2-nd emulated web camera direction description = Direction of the 2-nd emulated web camera diff --git a/android/camera/camera-capture-linux.c b/android/camera/camera-capture-linux.c index 8a96c0c..895690d 100644 --- a/android/camera/camera-capture-linux.c +++ b/android/camera/camera-capture-linux.c @@ -26,9 +26,9 @@ #include "android/camera/camera-capture.h" #include "android/camera/camera-format-converters.h" -#define E(...) derror(__VA_ARGS__) -#define W(...) dwarning(__VA_ARGS__) #define D(...) VERBOSE_PRINT(camera,__VA_ARGS__) +#define W(...) VERBOSE_PRINT(camera,__VA_ARGS__) +#define E(...) VERBOSE_PRINT(camera,__VA_ARGS__) #define D_ACTIVE VERBOSE_CHECK(camera) /* the T(...) macro is used to dump traffic */ @@ -282,38 +282,6 @@ _camera_device_free(LinuxCameraDevice* lcd) } } -/* Resets camera device after capturing. - * Since new capture request may require different frame dimensions we must - * reset camera device by reopening its handle. Otherwise attempts to set up new - * frame properties (different from the previous one) may fail. */ -static void -_camera_device_reset(LinuxCameraDevice* cd) -{ - struct v4l2_cropcap cropcap; - struct v4l2_crop crop; - - /* Free capturing framebuffers first. */ - if (cd->framebuffers != NULL) { - _free_framebuffers(cd->framebuffers, cd->framebuffer_num, cd->io_type); - free(cd->framebuffers); - cd->framebuffers = NULL; - cd->framebuffer_num = 0; - } - - /* Reset device handle. */ - close(cd->handle); - cd->handle = open(cd->device_name, O_RDWR | O_NONBLOCK, 0); - - if (cd->handle >= 0) { - /* Select video input, video standard and tune here. */ - cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - _xioctl(cd->handle, VIDIOC_CROPCAP, &cropcap); - crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - crop.c = cropcap.defrect; /* reset to default */ - _xioctl (cd->handle, VIDIOC_S_CROP, &crop); - } -} - /* Memory maps buffers and shares mapped memory with the device. * Return: * 0 Framebuffers have been mapped. @@ -498,6 +466,8 @@ _camera_device_open(LinuxCameraDevice* cd) struct stat st; if (stat(cd->device_name, &st)) { + E("%s: Cannot identify camera device '%s': %s", + __FUNCTION__, cd->device_name, strerror(errno)); return -1; } @@ -855,7 +825,6 @@ camera_device_start_capturing(CameraDevice* ccd, fmt_str[4] = '\0'; E("%s: Camera '%s' does not support pixel format '%s' with dimensions %dx%d", __FUNCTION__, cd->device_name, fmt_str, frame_width, frame_height); - _camera_device_reset(cd); return -1; } /* VIDIOC_S_FMT may has changed some properties of the structure. Make sure @@ -865,7 +834,6 @@ camera_device_start_capturing(CameraDevice* ccd, fmt_str[4] = '\0'; E("%s: Dimensions %dx%d are wrong for pixel format '%s'", __FUNCTION__, frame_width, frame_height, fmt_str); - _camera_device_reset(cd); return -1; } memcpy(&cd->actual_pixel_format, &fmt.fmt.pix, sizeof(struct v4l2_pix_format)); @@ -879,7 +847,6 @@ camera_device_start_capturing(CameraDevice* ccd, r = _camera_device_mmap_framebuffer(cd); if (r < 0) { /* Some critical error has ocurred. Bail out. */ - _camera_device_reset(cd); return -1; } else if (r > 0) { /* Device doesn't support memory mapping. Retrieve to the next performant @@ -887,20 +854,17 @@ camera_device_start_capturing(CameraDevice* ccd, r = _camera_device_user_framebuffer(cd); if (r < 0) { /* Some critical error has ocurred. Bail out. */ - _camera_device_reset(cd); return -1; } else if (r > 0) { /* The only thing left for us is direct reading from the device. */ if (!(cd->caps.capabilities & V4L2_CAP_READWRITE)) { E("%s: Don't know how to access frames on device '%s'", __FUNCTION__, cd->device_name); - _camera_device_reset(cd); return -1; } r = _camera_device_direct_framebuffer(cd); if (r != 0) { /* Any error at this point is a critical one. */ - _camera_device_reset(cd); return -1; } } @@ -913,7 +877,6 @@ camera_device_start_capturing(CameraDevice* ccd, if (_xioctl (cd->handle, VIDIOC_STREAMON, &type) < 0) { E("%s: VIDIOC_STREAMON on camera '%s' has failed: %s", __FUNCTION__, cd->device_name, strerror(errno)); - _camera_device_reset(cd); return -1; } } @@ -956,10 +919,18 @@ camera_device_stop_capturing(CameraDevice* ccd) return -1; } + if (cd->framebuffers != NULL) { + _free_framebuffers(cd->framebuffers, cd->framebuffer_num, cd->io_type); + free(cd->framebuffers); + cd->framebuffers = NULL; + cd->framebuffer_num = 0; + } + /* Reopen the device to reset its internal state. It seems that if we don't * do that, an attempt to reinit the device with different frame dimensions * would fail. */ - _camera_device_reset(cd); + close(cd->handle); + cd->handle = open(cd->device_name, O_RDWR | O_NONBLOCK, 0); return 0; } diff --git a/android/camera/camera-capture-mac.c b/android/camera/camera-capture-mac.c index 764a055..8a793c1 100644 --- a/android/camera/camera-capture-mac.c +++ b/android/camera/camera-capture-mac.c @@ -21,9 +21,9 @@ #include "android/camera/camera-capture.h" -#define E(...) derror(__VA_ARGS__) -#define W(...) dwarning(__VA_ARGS__) #define D(...) VERBOSE_PRINT(camera,__VA_ARGS__) +#define W(...) VERBOSE_PRINT(camera,__VA_ARGS__) +#define E(...) VERBOSE_PRINT(camera,__VA_ARGS__) #define D_ACTIVE VERBOSE_CHECK(camera) /* the T(...) macro is used to dump traffic */ diff --git a/android/camera/camera-capture-windows.c b/android/camera/camera-capture-windows.c index 28820a8..0fb172e 100755 --- a/android/camera/camera-capture-windows.c +++ b/android/camera/camera-capture-windows.c @@ -23,9 +23,9 @@ #include "android/camera/camera-capture.h" #include "android/camera/camera-format-converters.h" -#define E(...) derror(__VA_ARGS__) -#define W(...) dwarning(__VA_ARGS__) #define D(...) VERBOSE_PRINT(camera,__VA_ARGS__) +#define W(...) VERBOSE_PRINT(camera,__VA_ARGS__) +#define E(...) VERBOSE_PRINT(camera,__VA_ARGS__) #define D_ACTIVE VERBOSE_CHECK(camera) /* the T(...) macro is used to dump traffic */ @@ -145,46 +145,6 @@ _camera_device_free(WndCameraDevice* cd) } } -/* Resets camera device after capturing. - * Since new capture request may require different frame dimensions we must - * reset frame info cached in the capture window. The only way to do that would - * be closing, and reopening it again. */ -static void -_camera_device_reset(WndCameraDevice* cd) -{ - if (cd != NULL && cd->cap_window != NULL) { - capDriverDisconnect(cd->cap_window); - if (cd->dc != NULL) { - ReleaseDC(cd->cap_window, cd->dc); - cd->dc = NULL; - } - if (cd->gdi_bitmap != NULL) { - free(cd->gdi_bitmap); - cd->gdi_bitmap = NULL; - } - if (cd->frame_bitmap != NULL) { - free(cd->frame_bitmap); - cd->frame_bitmap = NULL; - } - if (cd->framebuffer != NULL) { - free(cd->framebuffer); - cd->framebuffer = NULL; - } - - /* Recreate the capturing window. */ - DestroyWindow(cd->cap_window); - cd->cap_window = capCreateCaptureWindow(cd->window_name, WS_CHILD, 0, 0, - 0, 0, HWND_MESSAGE, 1); - } -} - -/* Gets an absolute value out of a signed integer. */ -static __inline__ int -_abs(int val) -{ - return (val < 0) ? -val : val; -} - /******************************************************************************* * CameraDevice API ******************************************************************************/ @@ -252,54 +212,29 @@ camera_device_start_capturing(CameraDevice* cd, /* Connect capture window to the video capture driver. */ if (!capDriverConnect(wcd->cap_window, wcd->input_channel)) { + E("%s: Unable to connect to the video capturing driver #%d: %d", + __FUNCTION__, wcd->input_channel, GetLastError()); return -1; } - /* Get current frame information from the driver. */ + /* Get frame information from the driver. */ format_info_size = capGetVideoFormatSize(wcd->cap_window); if (format_info_size == 0) { E("%s: Unable to get video format size: %d", __FUNCTION__, GetLastError()); - _camera_device_reset(wcd); return -1; } wcd->frame_bitmap = (BITMAPINFO*)malloc(format_info_size); if (wcd->frame_bitmap == NULL) { E("%s: Unable to allocate frame bitmap info buffer", __FUNCTION__); - _camera_device_reset(wcd); return -1; } if (!capGetVideoFormat(wcd->cap_window, wcd->frame_bitmap, format_info_size)) { E("%s: Unable to obtain video format: %d", __FUNCTION__, GetLastError()); - _camera_device_reset(wcd); return -1; } - /* Lets see if we need to set different frame dimensions */ - if (wcd->frame_bitmap->bmiHeader.biWidth != frame_width || - abs(wcd->frame_bitmap->bmiHeader.biHeight) != frame_height) { - /* Dimensions don't match. Set new frame info. */ - wcd->frame_bitmap->bmiHeader.biWidth = frame_width; - wcd->frame_bitmap->bmiHeader.biHeight = frame_height; - /* We need to recalculate image size, since the capture window / driver - * will use image size provided by us. */ - if (wcd->frame_bitmap->bmiHeader.biBitCount == 24) { - /* Special case that may require WORD boundary alignment. */ - uint32_t bpl = (frame_width * 3 + 1) & ~1; - wcd->frame_bitmap->bmiHeader.biSizeImage = bpl * frame_height; - } else { - wcd->frame_bitmap->bmiHeader.biSizeImage = - (frame_width * frame_height * wcd->frame_bitmap->bmiHeader.biBitCount) / 8; - } - if (!capSetVideoFormat(wcd->cap_window, wcd->frame_bitmap, - format_info_size)) { - E("%s: Unable to set video format: %d", __FUNCTION__, GetLastError()); - _camera_device_reset(wcd); - return -1; - } - } - if (wcd->frame_bitmap->bmiHeader.biCompression > BI_PNG) { D("%s: Video capturing driver has reported pixel format %.4s", __FUNCTION__, (const char*)&wcd->frame_bitmap->bmiHeader.biCompression); @@ -318,13 +253,22 @@ camera_device_start_capturing(CameraDevice* cd, wcd->is_top_down = 0; } + /* Make sure that frame dimensions match. */ + if (frame_width != wcd->frame_bitmap->bmiHeader.biWidth || + frame_height != wcd->frame_bitmap->bmiHeader.biHeight) { + E("%s: Requested dimensions %dx%d do not match the actual %dx%d", + __FUNCTION__, frame_width, frame_height, + wcd->frame_bitmap->bmiHeader.biWidth, + wcd->frame_bitmap->bmiHeader.biHeight); + return -1; + } + /* Get DC for the capturing window that will be used when we deal with * bitmaps obtained from the camera device during frame capturing. */ wcd->dc = GetDC(wcd->cap_window); if (wcd->dc == NULL) { E("%s: Unable to obtain DC for %s: %d", __FUNCTION__, wcd->window_name, GetLastError()); - _camera_device_reset(wcd); return -1; } @@ -342,7 +286,6 @@ camera_device_start_capturing(CameraDevice* cd, !OpenClipboard(wcd->cap_window)) { E("%s: Device '%s' is unable to save frame to the clipboard: %d", __FUNCTION__, wcd->window_name, GetLastError()); - _camera_device_reset(wcd); return -1; } @@ -353,7 +296,6 @@ camera_device_start_capturing(CameraDevice* cd, E("%s: Device '%s' is unable to obtain frame from the clipboard: %d", __FUNCTION__, wcd->window_name, GetLastError()); CloseClipboard(); - _camera_device_reset(wcd); return -1; } @@ -362,7 +304,6 @@ camera_device_start_capturing(CameraDevice* cd, E("%s: Device '%s' is unable to obtain frame's bitmap: %d", __FUNCTION__, wcd->window_name, GetLastError()); CloseClipboard(); - _camera_device_reset(wcd); return -1; } @@ -376,7 +317,6 @@ camera_device_start_capturing(CameraDevice* cd, __FUNCTION__, frame_width, frame_height, wcd->frame_bitmap->bmiHeader.biWidth, wcd->frame_bitmap->bmiHeader.biHeight); - _camera_device_reset(wcd); return -1; } @@ -384,7 +324,6 @@ camera_device_start_capturing(CameraDevice* cd, wcd->gdi_bitmap = (BITMAPINFO*)malloc(wcd->frame_bitmap->bmiHeader.biSize); if (wcd->gdi_bitmap == NULL) { E("%s: Unable to allocate gdi bitmap info", __FUNCTION__); - _camera_device_reset(wcd); return -1; } memcpy(wcd->gdi_bitmap, wcd->frame_bitmap, @@ -411,7 +350,6 @@ camera_device_start_capturing(CameraDevice* cd, if (wcd->framebuffer == NULL) { E("%s: Unable to allocate %d bytes for framebuffer", __FUNCTION__, wcd->gdi_bitmap->bmiHeader.biSizeImage); - _camera_device_reset(wcd); return -1; } @@ -419,17 +357,16 @@ camera_device_start_capturing(CameraDevice* cd, if (wcd->gdi_bitmap->bmiHeader.biBitCount == 16) { wcd->pixel_format = V4L2_PIX_FMT_RGB565; } else if (wcd->gdi_bitmap->bmiHeader.biBitCount == 24) { - wcd->pixel_format = V4L2_PIX_FMT_BGR24; + wcd->pixel_format = V4L2_PIX_FMT_RGB24; } else if (wcd->gdi_bitmap->bmiHeader.biBitCount == 32) { - wcd->pixel_format = V4L2_PIX_FMT_BGR32; + wcd->pixel_format = V4L2_PIX_FMT_RGB32; } else { E("%s: Unsupported number of bits per pixel %d", __FUNCTION__, wcd->gdi_bitmap->bmiHeader.biBitCount); - _camera_device_reset(wcd); return -1; } - D("%s: Capturing device '%s': %d bits per pixel in %.4s [%dx%d] frame", + D("%s: Capturing device '%s': %d bytes in %.4s [%dx%d] frame", __FUNCTION__, wcd->window_name, wcd->gdi_bitmap->bmiHeader.biBitCount, (const char*)&wcd->pixel_format, wcd->frame_bitmap->bmiHeader.biWidth, wcd->frame_bitmap->bmiHeader.biHeight); @@ -456,8 +393,8 @@ camera_device_stop_capturing(CameraDevice* cd) ReleaseDC(wcd->cap_window, wcd->dc); wcd->dc = NULL; - /* Reset the device in preparation for the next capture. */ - _camera_device_reset(wcd); + /* Disconnect from the driver. */ + capDriverDisconnect(wcd->cap_window); return 0; } @@ -562,6 +499,7 @@ enumerate_camera_devices(CameraInfo* cis, int max) * the course of the routine. Also note that on Windows all frames will be * 640x480. */ if (!camera_device_start_capturing(cd, V4L2_PIX_FMT_RGB32, 640, 480)) { + camera_device_stop_capturing(cd); /* capXxx API supports only single frame size (always observed 640x480, * but the actual numbers may vary). */ cis[found].frame_sizes = (CameraFrameDim*)malloc(sizeof(CameraFrameDim)); @@ -581,7 +519,6 @@ enumerate_camera_devices(CameraInfo* cis, int max) } else { E("%s: Unable to allocate dimensions", __FUNCTION__); } - camera_device_stop_capturing(cd); } else { /* No more cameras. */ camera_device_close(cd); diff --git a/android/camera/camera-common.h b/android/camera/camera-common.h index de09045..126b3ed 100755 --- a/android/camera/camera-common.h +++ b/android/camera/camera-common.h @@ -176,31 +176,5 @@ typedef struct CameraDevice { /* Opaque pointer used by the camera capturing API. */ void* opaque; } CameraDevice; - -/* Returns current time in microseconds. */ -static __inline__ uint64_t -_get_timestamp(void) -{ - struct timeval t; - t.tv_sec = t.tv_usec = 0; - gettimeofday(&t, NULL); - return (uint64_t)t.tv_sec * 1000000LL + t.tv_usec; -} - -/* Sleeps for the given amount of milliseconds */ -static __inline__ void -_camera_sleep(int millisec) -{ - struct timeval t; - const uint64_t wake_at = _get_timestamp() + (uint64_t)millisec * 1000; - do { - const uint64_t stamp = _get_timestamp(); - if ((stamp / 1000) >= (wake_at / 1000)) { - break; - } - t.tv_sec = (wake_at - stamp) / 1000000; - t.tv_usec = (wake_at - stamp) - (uint64_t)t.tv_sec * 1000000; - } while (select(0, NULL, NULL, NULL, &t) < 0 && errno == EINTR); -} #endif /* ANDROID_CAMERA_CAMERA_COMMON_H_ */ diff --git a/android/camera/camera-format-converters.c b/android/camera/camera-format-converters.c index 3366a44..c675f15 100755 --- a/android/camera/camera-format-converters.c +++ b/android/camera/camera-format-converters.c @@ -24,10 +24,9 @@ #endif #include "android/camera/camera-format-converters.h"
-#define E(...) derror(__VA_ARGS__) -#define W(...) dwarning(__VA_ARGS__) #define D(...) VERBOSE_PRINT(camera,__VA_ARGS__) -#define D_ACTIVE VERBOSE_CHECK(camera) +#define W(...) VERBOSE_PRINT(camera,__VA_ARGS__) +#define E(...) VERBOSE_PRINT(camera,__VA_ARGS__) /* * NOTE: RGB and big/little endian considerations. Wherewer in this code RGB diff --git a/android/camera/camera-service.c b/android/camera/camera-service.c index ee3ea6e..282acb4 100644 --- a/android/camera/camera-service.c +++ b/android/camera/camera-service.c @@ -28,9 +28,9 @@ #include "android/camera/camera-format-converters.h" #include "android/camera/camera-service.h" -#define E(...) derror(__VA_ARGS__) -#define W(...) dwarning(__VA_ARGS__) #define D(...) VERBOSE_PRINT(camera,__VA_ARGS__) +#define W(...) VERBOSE_PRINT(camera,__VA_ARGS__) +#define E(...) VERBOSE_PRINT(camera,__VA_ARGS__) #define D_ACTIVE VERBOSE_CHECK(camera) /* the T(...) macro is used to dump traffic */ @@ -445,11 +445,8 @@ _camera_service_init(CameraServiceDesc* csd) } /* For each webcam declared in hw.ini find an actual camera information - * descriptor, and save it into the service descriptor for the emulation. - * Stop the loop when all the connected cameras have been added to the - * service. */ - for (i = 0; i < android_hw->hw_webcam_count && - csd->camera_count < connected_cnt; i++) { + * descriptor, and save it into the service descriptor for the emulation. */ + for (i = 0; i < android_hw->hw_webcam_count; i++) { const char* disp_name; const char* dir; CameraInfo* found; @@ -500,32 +497,9 @@ _camera_service_init(CameraServiceDesc* csd) csd->camera_count++; memset(found, 0, sizeof(CameraInfo)); } else { - W("Camera name '%s' is not found in the list of connected cameras.\n" - "Use '-webcam list' emulator option to obtain the list of connected camera names.\n", - disp_name); - } - } - - /* Make sure that camera 0 and camera 1 are facing in opposite directions. - * If they don't the camera application will crash on an attempt to switch - * cameras. */ - if (csd->camera_count > 0) { - const char* cam2_dir = NULL; - const char* cam2_name = NULL; - if (csd->camera_count >= 2) { - cam2_dir = csd->camera_info[1].direction; - cam2_name = csd->camera_info[1].display_name; - } else if (strcmp(android_hw->hw_fakeCamera, "off")) { - cam2_dir = android_hw->hw_fakeCamera; - cam2_name = "fake camera"; - } - if (cam2_dir != NULL && !strcmp(csd->camera_info[0].direction, cam2_dir)) { - W("Cameras '%s' and '%s' are both facing %s.\n" - "It is required by the camera application that first two emulated cameras\n" - "are facing in opposite directions. If they both are facing in the same direction,\n" - "the camera application will crash on an attempt to switch the camera.\n", - csd->camera_info[0].display_name, cam2_name, cam2_dir); - + dwarning("Camera name '%s' is not found in the list of connected cameras.\n" + "Use -webcam-list emulator option to obtain the list of connected camera names\n\n", + disp_name); } } } @@ -778,6 +752,10 @@ struct CameraClient * Note that memory allocated for this buffer * also contains preview framebuffer. */ uint8_t* video_frame; + /* Point to Cb pane inside the video frame buffer. */ + uint8_t* video_frame_Cb; + /* Point to Cr pane inside the video frame buffer. */ + uint8_t* video_frame_Cr; /* Preview frame buffer. * This address points inside the 'video_frame' buffer. */ uint16_t* preview_frame; @@ -1112,6 +1090,11 @@ _camera_client_query_start(CameraClient* cc, QemudClient* qc, const char* param) /* Set framebuffer pointers. */ cc->preview_frame = (uint16_t*)(cc->video_frame + cc->video_frame_size); + /* TODO: Get rid if this! It assumes that client's framebuffer is YV12. Let + * the camera do the conversion. All we need is to ensure that framebuffers + * allocated here are large enough! */ + cc->video_frame_Cb = cc->video_frame + cc->pixel_num; + cc->video_frame_Cr = cc->video_frame_Cb + cc->pixel_num / 4; /* Start the camera. */ if (camera_device_start_capturing(cc->camera, cc->camera_info->pixel_format, @@ -1181,7 +1164,6 @@ _camera_client_query_frame(CameraClient* cc, QemudClient* qc, const char* param) ClientFrameBuffer fbs[2]; int fbs_num = 0; size_t payload_size; - uint64_t tick; /* Sanity check. */ if (cc->video_frame == NULL) { @@ -1230,41 +1212,25 @@ _camera_client_query_frame(CameraClient* cc, QemudClient* qc, const char* param) } /* Capture new frame. */ - tick = _get_timestamp(); repeat = camera_device_read_frame(cc->camera, fbs, fbs_num); /* Note that there is no (known) way how to wait on next frame being - * available, so we could dequeue frame buffer from the device only when we - * know it's available. Instead we're shooting in the dark, and quite often + * available, so we dequeue frame buffer from the device only when we know + * it's available. Instead we're shooting in the dark, and quite often * device will response with EAGAIN, indicating that it doesn't have frame * ready. In turn, it means that the last frame we have obtained from the * device is still good, and we can reply with the cached frames. The only * case when we need to keep trying to obtain a new frame is when frame cache - * is empty. To prevent ourselves from an indefinite loop in case device got - * stuck on something (observed with some Microsoft devices) we will limit - * the loop by 2 second time period (which is more than enough to obtain - * something from the device) */ - while (repeat == 1 && !cc->frames_cached && - (_get_timestamp() - tick) < 2000000LL) { - /* Sleep for 10 millisec before repeating the attempt. */ - _camera_sleep(10); + * is empty. */ + while (repeat == 1 && !cc->frames_cached) { repeat = camera_device_read_frame(cc->camera, fbs, fbs_num); } - if (repeat == 1 && !cc->frames_cached) { - /* Waited too long for the first frame. */ - E("%s: Unable to obtain first video frame from the camera '%s' in %d milliseconds: %s.", - __FUNCTION__, cc->device_name, - (uint32_t)(_get_timestamp() - tick) / 1000, strerror(errno)); - _qemu_client_reply_ko(qc, "Unable to obtain video frame from the camera"); - return; - } else if (repeat < 0) { - /* An I/O error. */ - E("%s: Unable to obtain video frame from the camera '%s': %s.", + if (repeat < 0) { + E("%s: Unable to obtain video frame from the camera '%s': %s", __FUNCTION__, cc->device_name, strerror(errno)); - _qemu_client_reply_ko(qc, strerror(errno)); + _qemu_client_reply_ko(qc, "Unable to obtain video frame from the camera"); return; } - /* We have cached something... */ cc->frames_cached = 1; diff --git a/hw/goldfish_pipe.c b/hw/goldfish_pipe.c index b3c6975..2227093 100644 --- a/hw/goldfish_pipe.c +++ b/hw/goldfish_pipe.c @@ -14,9 +14,6 @@ #include "hw/goldfish_pipe.h" #include "hw/goldfish_device.h" #include "qemu-timer.h" -#ifdef CONFIG_KVM -#include "kvm.h" -#endif #define DEBUG 0 @@ -878,13 +875,7 @@ pipeDevice_doCommand( PipeDevice* dev, uint32_t command ) GoldfishPipeBuffer buffer; uint32_t address = dev->address; uint32_t page = address & TARGET_PAGE_MASK; - target_phys_addr_t phys; -#ifdef CONFIG_KVM - if(kvm_enabled()) { - cpu_synchronize_state(env, 0); - } -#endif - phys = cpu_get_phys_page_debug(env, page); + target_phys_addr_t phys = cpu_get_phys_page_debug(env, page); buffer.data = qemu_get_ram_ptr(phys) + (address - page); buffer.size = dev->size; dev->status = pipe->funcs->recvBuffers(pipe->opaque, &buffer, 1); @@ -898,13 +889,7 @@ pipeDevice_doCommand( PipeDevice* dev, uint32_t command ) GoldfishPipeBuffer buffer; uint32_t address = dev->address; uint32_t page = address & TARGET_PAGE_MASK; - target_phys_addr_t phys; -#ifdef CONFIG_KVM - if(kvm_enabled()) { - cpu_synchronize_state(env, 0); - } -#endif - phys = cpu_get_phys_page_debug(env, page); + target_phys_addr_t phys = cpu_get_phys_page_debug(env, page); buffer.data = qemu_get_ram_ptr(phys) + (address - page); buffer.size = dev->size; dev->status = pipe->funcs->sendBuffers(pipe->opaque, &buffer, 1); |