Many signals used in internal and public APIs carry the emitter pointer as a signal argument. This was done to allow slots connected to multiple signal instances to differentiate between emitters. While starting from a good intention of facilitating the implementation of slots, it turned out to be a bad API design as the signal isn't meant to know what it will be connected to, and thus shouldn't carry parameters that are solely meant to support a use case specific to the connected slot. These pointers turn out to be unused in all slots but one. In the only case where it is needed, it can be obtained by wrapping the slot in a lambda function when connecting the signal. Do so, and drop the emitter pointer from all signals. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
61 lines
1.1 KiB
C++
61 lines
1.1 KiB
C++
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
/*
|
|
* Copyright (C) 2019, Google Inc.
|
|
*
|
|
* ipc_unixsocket.h - IPC mechanism based on Unix sockets
|
|
*/
|
|
|
|
#ifndef __LIBCAMERA_INTERNAL_IPC_UNIXSOCKET_H__
|
|
#define __LIBCAMERA_INTERNAL_IPC_UNIXSOCKET_H__
|
|
|
|
#include <stdint.h>
|
|
#include <sys/types.h>
|
|
#include <vector>
|
|
|
|
#include <libcamera/base/signal.h>
|
|
|
|
namespace libcamera {
|
|
|
|
class EventNotifier;
|
|
|
|
class IPCUnixSocket
|
|
{
|
|
public:
|
|
struct Payload {
|
|
std::vector<uint8_t> data;
|
|
std::vector<int32_t> fds;
|
|
};
|
|
|
|
IPCUnixSocket();
|
|
~IPCUnixSocket();
|
|
|
|
int create();
|
|
int bind(int fd);
|
|
void close();
|
|
bool isBound() const;
|
|
|
|
int send(const Payload &payload);
|
|
int receive(Payload *payload);
|
|
|
|
Signal<> readyRead;
|
|
|
|
private:
|
|
struct Header {
|
|
uint32_t data;
|
|
uint8_t fds;
|
|
};
|
|
|
|
int sendData(const void *buffer, size_t length, const int32_t *fds, unsigned int num);
|
|
int recvData(void *buffer, size_t length, int32_t *fds, unsigned int num);
|
|
|
|
void dataNotifier();
|
|
|
|
int fd_;
|
|
bool headerReceived_;
|
|
struct Header header_;
|
|
EventNotifier *notifier_;
|
|
};
|
|
|
|
} /* namespace libcamera */
|
|
|
|
#endif /* __LIBCAMERA_INTERNAL_IPC_UNIXSOCKET_H__ */
|