summaryrefslogtreecommitdiff
path: root/test/v4l2_videodevice/dequeue_watchdog.cpp
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2022-07-14 20:14:26 +0200
committerJacopo Mondi <jacopo@jmondi.org>2022-07-15 13:43:47 +0200
commite9b6b362820338d0546563444e7b1767f5c7044c (patch)
tree28b91dc512e2bc0deac28db55d8d9b646e3dbcaf /test/v4l2_videodevice/dequeue_watchdog.cpp
parenta5877e03072c9578cd97a84f4db1106f24a588a9 (diff)
cam: sdl: Use uint32_t in place of SDL_PixelFormatEnum
The SDL_PixelFormatEnum type has been introduced in libsdl by 1a4c0d4e17e6 ("Fixed bug 4377 - SDL_PIXELFORMAT enum is anonymous, which prevents its use in a templated function") which is only available after release 2.0.10 of the library. Debian 10 ships libsdl at version 2.0.9 and building cam with sdl support there fails with error: ./src/cam/sdl_texture.h:27:8: error: ‘SDL_PixelFormatEnum’ does not name a type; did you mean ‘SDL_PixelFormat’? Fix that by using the base type uint32_t in place of SDL_PixelFormatEnum. Reported-by: https://buildbot.libcamera.org/#/builders/6/builds/355 Fixes: 11554a259f4e ("cam: sdl_sink: Add SDL sink with initial YUYV support") Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Eric Curtin <ecurtin@redhat.com>
Diffstat (limited to 'test/v4l2_videodevice/dequeue_watchdog.cpp')
0 files changed, 0 insertions, 0 deletions
d='n139' href='#n139'>139 140 141
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * event_notifier.cpp - File descriptor event notifier
 */

#include <libcamera/event_notifier.h>

#include <libcamera/camera_manager.h>
#include <libcamera/event_dispatcher.h>

#include "libcamera/internal/message.h"
#include "libcamera/internal/thread.h"

/**
 * \file event_notifier.h
 * \brief File descriptor event notifier
 */

namespace libcamera {

/**
 * \class EventNotifier
 * \brief Notify of activity on a file descriptor
 *
 * The EventNotifier models a file descriptor event source that can be
 * monitored. It is created with the file descriptor to be monitored and the
 * type of event, and is enabled by default. It will emit the \ref activated
 * signal whenever an event of the monitored type occurs on the file descriptor.
 *
 * Supported type of events are EventNotifier::Read, EventNotifier::Write and
 * EventNotifier::Exception. The type is specified when constructing the
 * notifier, and can be retrieved using the type() function. To listen to
 * multiple event types on the same file descriptor multiple notifiers must be
 * created.
 *
 * The notifier can be disabled with the setEnabled() function. When the notifier
 * is disabled it ignores events and does not emit the \ref activated signal.
 * The notifier can then be re-enabled with the setEnabled() function.
 *
 * Creating multiple notifiers of the same type for the same file descriptor is
 * not allowed and results in undefined behaviour.
 *
 * Notifier events are detected and dispatched from the
 * EventDispatcher::processEvents() function.
 */

/**
 * \enum EventNotifier::Type
 * Type of file descriptor event to listen for.
 * \var EventNotifier::Read
 * Data is available to be read from the file descriptor
 * \var EventNotifier::Write
 * Data can be written to the file descriptor
 * \var EventNotifier::Exception
 * An exception has occurred on the file descriptor
 */

/**
 * \brief Construct an event notifier with a file descriptor and event type
 * \param[in] fd The file descriptor to monitor
 * \param[in] type The event type to monitor
 * \param[in] parent The parent Object
 */
EventNotifier::EventNotifier(int fd, Type type, Object *parent)
	: Object(parent), fd_(fd), type_(type), enabled_(false)
{
	setEnabled(true);
}

EventNotifier::~EventNotifier()
{
	setEnabled(false);
}

/**
 * \fn EventNotifier::type()
 * \brief Retrieve the type of the event being monitored
 * \return The type of the event
 */

/**
 * \fn EventNotifier::fd()
 * \brief Retrieve the file descriptor being monitored
 * \return The file descriptor
 */

/**
 * \fn EventNotifier::enabled()
 * \brief Retrieve the notifier state
 * \return True if the notifier is enabled, or false otherwise
 * \sa setEnabled()
 */

/**
 * \brief Enable or disable the notifier
 * \param[in] enable True to enable the notifier, false to disable it
 *
 * This function enables or disables the notifier. A disabled notifier ignores
 * events and does not emit the \ref activated signal.
 *
 * \context This function is \threadbound.
 */
void EventNotifier::setEnabled(bool enable)
{
	if (enabled_ == enable)
		return;

	enabled_ = enable;

	EventDispatcher *dispatcher = thread()->eventDispatcher();
	if (enable)
		dispatcher->registerEventNotifier(this);
	else
		dispatcher->unregisterEventNotifier(this);
}

/**
 * \var EventNotifier::activated
 * \brief Signal emitted when the event occurs
 *
 * This signal is emitted when the event \ref type() occurs on the file
 * descriptor monitored by the notifier. The notifier pointer is passed as a
 * parameter.
 */

void EventNotifier::message(Message *msg)
{
	if (msg->type() == Message::ThreadMoveMessage) {
		if (enabled_) {
			setEnabled(false);
			invokeMethod(&EventNotifier::setEnabled,
				     ConnectionTypeQueued, true);
		}
	}

	Object::message(msg);
}

} /* namespace libcamera */