mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	spa: libcamera: use nullptr instead of NULL
				
					
				
			This commit is contained in:
		
							parent
							
								
									4fa11619a2
								
							
						
					
					
						commit
						db3d91ebeb
					
				
					 3 changed files with 65 additions and 65 deletions
				
			
		| 
						 | 
					@ -186,8 +186,8 @@ int impl_add_listener(void *object,
 | 
				
			||||||
	struct spa_hook_list save;
 | 
						struct spa_hook_list save;
 | 
				
			||||||
	int res = 0;
 | 
						int res = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(impl != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(impl != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(events != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(events != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_hook_list_isolate(&impl->hooks, &save, listener, events, data);
 | 
						spa_hook_list_isolate(&impl->hooks, &save, listener, events, data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -203,9 +203,9 @@ int impl_sync(void *object, int seq)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct impl *impl = (struct impl*) object;
 | 
						struct impl *impl = (struct impl*) object;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(impl != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(impl != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_device_emit_result(&impl->hooks, seq, 0, 0, NULL);
 | 
						spa_device_emit_result(&impl->hooks, seq, 0, 0, nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -236,8 +236,8 @@ int impl_get_interface(struct spa_handle *handle, const char *type, void **inter
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	auto *impl = reinterpret_cast<struct impl *>(handle);
 | 
						auto *impl = reinterpret_cast<struct impl *>(handle);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(handle != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(handle != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(interface != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(interface != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (spa_streq(type, SPA_TYPE_INTERFACE_Device))
 | 
						if (spa_streq(type, SPA_TYPE_INTERFACE_Device))
 | 
				
			||||||
		*interface = &impl->device;
 | 
							*interface = &impl->device;
 | 
				
			||||||
| 
						 | 
					@ -290,8 +290,8 @@ impl_init(const struct spa_handle_factory *factory,
 | 
				
			||||||
	const char *str;
 | 
						const char *str;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(factory != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(factory != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(handle != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(handle != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto log = static_cast<spa_log *>(spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log));
 | 
						auto log = static_cast<spa_log *>(spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -324,9 +324,9 @@ int impl_enum_interface_info(const struct spa_handle_factory *factory,
 | 
				
			||||||
			     const struct spa_interface_info **info,
 | 
								     const struct spa_interface_info **info,
 | 
				
			||||||
			     uint32_t *index)
 | 
								     uint32_t *index)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	spa_return_val_if_fail(factory != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(factory != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(info != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(info != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(index != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(index != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (*index >= SPA_N_ELEMENTS(impl_interfaces))
 | 
						if (*index >= SPA_N_ELEMENTS(impl_interfaces))
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
| 
						 | 
					@ -341,7 +341,7 @@ extern "C" {
 | 
				
			||||||
const struct spa_handle_factory spa_libcamera_device_factory = {
 | 
					const struct spa_handle_factory spa_libcamera_device_factory = {
 | 
				
			||||||
	SPA_VERSION_HANDLE_FACTORY,
 | 
						SPA_VERSION_HANDLE_FACTORY,
 | 
				
			||||||
	SPA_NAME_API_LIBCAMERA_DEVICE,
 | 
						SPA_NAME_API_LIBCAMERA_DEVICE,
 | 
				
			||||||
	NULL,
 | 
						nullptr,
 | 
				
			||||||
	impl_get_size,
 | 
						impl_get_size,
 | 
				
			||||||
	impl_init,
 | 
						impl_init,
 | 
				
			||||||
	impl_enum_interface_info,
 | 
						impl_enum_interface_info,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -86,7 +86,7 @@ struct device *add_device(struct impl *impl, std::shared_ptr<Camera> camera)
 | 
				
			||||||
	uint32_t id;
 | 
						uint32_t id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (impl->n_devices >= MAX_DEVICES)
 | 
						if (impl->n_devices >= MAX_DEVICES)
 | 
				
			||||||
		return NULL;
 | 
							return nullptr;
 | 
				
			||||||
	id = get_free_id(impl);
 | 
						id = get_free_id(impl);
 | 
				
			||||||
	device = &impl->devices[id];
 | 
						device = &impl->devices[id];
 | 
				
			||||||
	device->id = id;
 | 
						device->id = id;
 | 
				
			||||||
| 
						 | 
					@ -102,7 +102,7 @@ struct device *find_device(struct impl *impl, const Camera *camera)
 | 
				
			||||||
		if (impl->devices[i].camera.get() == camera)
 | 
							if (impl->devices[i].camera.get() == camera)
 | 
				
			||||||
			return &impl->devices[i];
 | 
								return &impl->devices[i];
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return NULL;
 | 
						return nullptr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void remove_device(struct impl *impl, struct device *device)
 | 
					void remove_device(struct impl *impl, struct device *device)
 | 
				
			||||||
| 
						 | 
					@ -153,10 +153,10 @@ void try_add_camera(struct impl *impl, std::shared_ptr<Camera> camera)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct device *device;
 | 
						struct device *device;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((device = find_device(impl, camera.get())) != NULL)
 | 
						if ((device = find_device(impl, camera.get())) != nullptr)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((device = add_device(impl, std::move(camera))) == NULL)
 | 
						if ((device = add_device(impl, std::move(camera))) == nullptr)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_log_info(impl->log, "camera added: id:%d %s", device->id,
 | 
						spa_log_info(impl->log, "camera added: id:%d %s", device->id,
 | 
				
			||||||
| 
						 | 
					@ -168,12 +168,12 @@ void try_remove_camera(struct impl *impl, const Camera *camera)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct device *device;
 | 
						struct device *device;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((device = find_device(impl, camera)) == NULL)
 | 
						if ((device = find_device(impl, camera)) == nullptr)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_log_info(impl->log, "camera removed: id:%d %s", device->id,
 | 
						spa_log_info(impl->log, "camera removed: id:%d %s", device->id,
 | 
				
			||||||
			device->camera->id().c_str());
 | 
								device->camera->id().c_str());
 | 
				
			||||||
	spa_device_emit_object_info(&impl->hooks, device->id, NULL);
 | 
						spa_device_emit_object_info(&impl->hooks, device->id, nullptr);
 | 
				
			||||||
	remove_device(impl, device);
 | 
						remove_device(impl, device);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -297,8 +297,8 @@ impl_device_add_listener(void *object, struct spa_hook *listener,
 | 
				
			||||||
	struct spa_hook_list save;
 | 
						struct spa_hook_list save;
 | 
				
			||||||
	bool had_manager = !!impl->manager;
 | 
						bool had_manager = !!impl->manager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(impl != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(impl != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(events != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(events != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!impl->manager && !(impl->manager = libcamera_manager_acquire(res)))
 | 
						if (!impl->manager && !(impl->manager = libcamera_manager_acquire(res)))
 | 
				
			||||||
		return res;
 | 
							return res;
 | 
				
			||||||
| 
						 | 
					@ -333,8 +333,8 @@ int impl_get_interface(struct spa_handle *handle, const char *type, void **inter
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	auto *impl = reinterpret_cast<struct impl *>(handle);
 | 
						auto *impl = reinterpret_cast<struct impl *>(handle);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(handle != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(handle != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(interface != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(interface != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (spa_streq(type, SPA_TYPE_INTERFACE_Device))
 | 
						if (spa_streq(type, SPA_TYPE_INTERFACE_Device))
 | 
				
			||||||
		*interface = &impl->device;
 | 
							*interface = &impl->device;
 | 
				
			||||||
| 
						 | 
					@ -384,8 +384,8 @@ impl_init(const struct spa_handle_factory *factory,
 | 
				
			||||||
	  const struct spa_support *support,
 | 
						  const struct spa_support *support,
 | 
				
			||||||
	  uint32_t n_support)
 | 
						  uint32_t n_support)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	spa_return_val_if_fail(factory != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(factory != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(handle != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(handle != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto log = static_cast<spa_log *>(spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log));
 | 
						auto log = static_cast<spa_log *>(spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -416,9 +416,9 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
 | 
				
			||||||
			 const struct spa_interface_info **info,
 | 
								 const struct spa_interface_info **info,
 | 
				
			||||||
			 uint32_t *index)
 | 
								 uint32_t *index)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	spa_return_val_if_fail(factory != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(factory != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(info != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(info != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(index != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(index != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (*index >= SPA_N_ELEMENTS(impl_interfaces))
 | 
						if (*index >= SPA_N_ELEMENTS(impl_interfaces))
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
| 
						 | 
					@ -433,7 +433,7 @@ extern "C" {
 | 
				
			||||||
const struct spa_handle_factory spa_libcamera_manager_factory = {
 | 
					const struct spa_handle_factory spa_libcamera_manager_factory = {
 | 
				
			||||||
	SPA_VERSION_HANDLE_FACTORY,
 | 
						SPA_VERSION_HANDLE_FACTORY,
 | 
				
			||||||
	SPA_NAME_API_LIBCAMERA_ENUM_MANAGER,
 | 
						SPA_NAME_API_LIBCAMERA_ENUM_MANAGER,
 | 
				
			||||||
	NULL,
 | 
						nullptr,
 | 
				
			||||||
	impl_get_size,
 | 
						impl_get_size,
 | 
				
			||||||
	impl_init,
 | 
						impl_init,
 | 
				
			||||||
	impl_enum_interface_info,
 | 
						impl_enum_interface_info,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -537,7 +537,7 @@ next_fmt:
 | 
				
			||||||
	spa_log_debug(impl->log, "format: %s", format.toString().c_str());
 | 
						spa_log_debug(impl->log, "format: %s", format.toString().c_str());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const auto *info = video_format_to_info(format);
 | 
						const auto *info = video_format_to_info(format);
 | 
				
			||||||
	if (info == NULL) {
 | 
						if (info == nullptr) {
 | 
				
			||||||
		spa_log_debug(impl->log, "unknown format");
 | 
							spa_log_debug(impl->log, "unknown format");
 | 
				
			||||||
		port->fmt_index++;
 | 
							port->fmt_index++;
 | 
				
			||||||
		goto next_fmt;
 | 
							goto next_fmt;
 | 
				
			||||||
| 
						 | 
					@ -642,10 +642,10 @@ next_fmt:
 | 
				
			||||||
int spa_libcamera_set_format(struct impl *impl, struct port *port,
 | 
					int spa_libcamera_set_format(struct impl *impl, struct port *port,
 | 
				
			||||||
		struct spa_video_info *format, bool try_only)
 | 
							struct spa_video_info *format, bool try_only)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const struct format_info *info = NULL;
 | 
						const struct format_info *info = nullptr;
 | 
				
			||||||
	uint32_t video_format;
 | 
						uint32_t video_format;
 | 
				
			||||||
	struct spa_rectangle *size = NULL;
 | 
						struct spa_rectangle *size = nullptr;
 | 
				
			||||||
	struct spa_fraction *framerate = NULL;
 | 
						struct spa_fraction *framerate = nullptr;
 | 
				
			||||||
	CameraConfiguration::Status validation;
 | 
						CameraConfiguration::Status validation;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -673,7 +673,7 @@ int spa_libcamera_set_format(struct impl *impl, struct port *port,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	info = find_format_info_by_media_type(format->media_type,
 | 
						info = find_format_info_by_media_type(format->media_type,
 | 
				
			||||||
					      format->media_subtype, video_format);
 | 
										      format->media_subtype, video_format);
 | 
				
			||||||
	if (info == NULL || size == NULL || framerate == NULL) {
 | 
						if (info == nullptr || size == nullptr || framerate == nullptr) {
 | 
				
			||||||
		spa_log_error(impl->log, "unknown media type %d %d %d", format->media_type,
 | 
							spa_log_error(impl->log, "unknown media type %d %d %d", format->media_type,
 | 
				
			||||||
			      format->media_subtype, video_format);
 | 
								      format->media_subtype, video_format);
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
| 
						 | 
					@ -977,7 +977,7 @@ void libcamera_on_fd_events(struct spa_source *source)
 | 
				
			||||||
	spa_list_append(&port->queue, &b->link);
 | 
						spa_list_append(&port->queue, &b->link);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	io = port->io;
 | 
						io = port->io;
 | 
				
			||||||
	if (io == NULL) {
 | 
						if (io == nullptr) {
 | 
				
			||||||
		b = spa_list_first(&port->queue, struct buffer, link);
 | 
							b = spa_list_first(&port->queue, struct buffer, link);
 | 
				
			||||||
		spa_list_remove(&b->link);
 | 
							spa_list_remove(&b->link);
 | 
				
			||||||
		SPA_FLAG_SET(b->flags, BUFFER_FLAG_OUTSTANDING);
 | 
							SPA_FLAG_SET(b->flags, BUFFER_FLAG_OUTSTANDING);
 | 
				
			||||||
| 
						 | 
					@ -1119,12 +1119,12 @@ spa_libcamera_alloc_buffers(struct impl *impl, struct port *port,
 | 
				
			||||||
				d[j].flags |= SPA_DATA_FLAG_MAPPABLE;
 | 
									d[j].flags |= SPA_DATA_FLAG_MAPPABLE;
 | 
				
			||||||
				d[j].fd = bufs[i]->planes()[j].fd.get();
 | 
									d[j].fd = bufs[i]->planes()[j].fd.get();
 | 
				
			||||||
				spa_log_debug(impl->log, "Got fd = %" PRId64 " for buffer: #%d", d[j].fd, i);
 | 
									spa_log_debug(impl->log, "Got fd = %" PRId64 " for buffer: #%d", d[j].fd, i);
 | 
				
			||||||
				d[j].data = NULL;
 | 
									d[j].data = nullptr;
 | 
				
			||||||
				SPA_FLAG_SET(b->flags, BUFFER_FLAG_ALLOCATED);
 | 
									SPA_FLAG_SET(b->flags, BUFFER_FLAG_ALLOCATED);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			else if (port->memtype == SPA_DATA_MemPtr) {
 | 
								else if (port->memtype == SPA_DATA_MemPtr) {
 | 
				
			||||||
				d[j].fd = -1;
 | 
									d[j].fd = -1;
 | 
				
			||||||
				d[j].data = mmap(NULL,
 | 
									d[j].data = mmap(nullptr,
 | 
				
			||||||
						d[j].maxsize + d[j].mapoffset,
 | 
											d[j].maxsize + d[j].mapoffset,
 | 
				
			||||||
						PROT_READ, MAP_SHARED,
 | 
											PROT_READ, MAP_SHARED,
 | 
				
			||||||
						bufs[i]->planes()[j].fd.get(),
 | 
											bufs[i]->planes()[j].fd.get(),
 | 
				
			||||||
| 
						 | 
					@ -1310,7 +1310,7 @@ int spa_libcamera_stream_off(struct impl *impl)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	impl->camera->requestCompleted.disconnect(impl, &impl::requestComplete);
 | 
						impl->camera->requestCompleted.disconnect(impl, &impl::requestComplete);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_loop_locked(impl->data_loop, do_remove_source, 0, NULL, 0, impl);
 | 
						spa_loop_locked(impl->data_loop, do_remove_source, 0, nullptr, 0, impl);
 | 
				
			||||||
	if (impl->source.fd >= 0)  {
 | 
						if (impl->source.fd >= 0)  {
 | 
				
			||||||
		spa_system_close(impl->system, impl->source.fd);
 | 
							spa_system_close(impl->system, impl->source.fd);
 | 
				
			||||||
		impl->source.fd = -1;
 | 
							impl->source.fd = -1;
 | 
				
			||||||
| 
						 | 
					@ -1382,7 +1382,7 @@ int impl_node_enum_params(void *object, int seq,
 | 
				
			||||||
	uint32_t count = 0;
 | 
						uint32_t count = 0;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(impl != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(impl != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(num != 0, -EINVAL);
 | 
						spa_return_val_if_fail(num != 0, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	result.id = id;
 | 
						result.id = id;
 | 
				
			||||||
| 
						 | 
					@ -1459,7 +1459,7 @@ int impl_node_set_param(void *object,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	auto *impl = static_cast<struct impl *>(object);
 | 
						auto *impl = static_cast<struct impl *>(object);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(impl != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(impl != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (id) {
 | 
						switch (id) {
 | 
				
			||||||
	case SPA_PARAM_Props:
 | 
						case SPA_PARAM_Props:
 | 
				
			||||||
| 
						 | 
					@ -1467,7 +1467,7 @@ int impl_node_set_param(void *object,
 | 
				
			||||||
		const auto *obj = reinterpret_cast<const spa_pod_object *>(param);
 | 
							const auto *obj = reinterpret_cast<const spa_pod_object *>(param);
 | 
				
			||||||
		const struct spa_pod_prop *prop;
 | 
							const struct spa_pod_prop *prop;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (param == NULL) {
 | 
							if (param == nullptr) {
 | 
				
			||||||
			impl->device_id.clear();
 | 
								impl->device_id.clear();
 | 
				
			||||||
			impl->device_name.clear();
 | 
								impl->device_name.clear();
 | 
				
			||||||
			return 0;
 | 
								return 0;
 | 
				
			||||||
| 
						 | 
					@ -1499,7 +1499,7 @@ int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct impl *impl = (struct impl*)object;
 | 
						struct impl *impl = (struct impl*)object;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(impl != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(impl != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (id) {
 | 
						switch (id) {
 | 
				
			||||||
	case SPA_IO_Clock:
 | 
						case SPA_IO_Clock:
 | 
				
			||||||
| 
						 | 
					@ -1521,8 +1521,8 @@ int impl_node_send_command(void *object, const struct spa_command *command)
 | 
				
			||||||
	struct impl *impl = (struct impl*)object;
 | 
						struct impl *impl = (struct impl*)object;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(impl != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(impl != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(command != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(command != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (SPA_NODE_COMMAND_ID(command)) {
 | 
						switch (SPA_NODE_COMMAND_ID(command)) {
 | 
				
			||||||
	case SPA_NODE_COMMAND_Start:
 | 
						case SPA_NODE_COMMAND_Start:
 | 
				
			||||||
| 
						 | 
					@ -1595,7 +1595,7 @@ impl_node_add_listener(void *object,
 | 
				
			||||||
	struct impl *impl = (struct impl*)object;
 | 
						struct impl *impl = (struct impl*)object;
 | 
				
			||||||
	struct spa_hook_list save;
 | 
						struct spa_hook_list save;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(impl != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(impl != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_hook_list_isolate(&impl->hooks, &save, listener, events, data);
 | 
						spa_hook_list_isolate(&impl->hooks, &save, listener, events, data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1613,7 +1613,7 @@ int impl_node_set_callbacks(void *object,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct impl *impl = (struct impl*)object;
 | 
						struct impl *impl = (struct impl*)object;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(impl != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(impl != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	impl->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
 | 
						impl->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1624,9 +1624,9 @@ int impl_node_sync(void *object, int seq)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct impl *impl = (struct impl*)object;
 | 
						struct impl *impl = (struct impl*)object;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(impl != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(impl != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_node_emit_result(&impl->hooks, seq, 0, 0, NULL);
 | 
						spa_node_emit_result(&impl->hooks, seq, 0, 0, nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1661,7 +1661,7 @@ int impl_node_port_enum_params(void *object, int seq,
 | 
				
			||||||
	uint32_t count = 0;
 | 
						uint32_t count = 0;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(impl != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(impl != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(num != 0, -EINVAL);
 | 
						spa_return_val_if_fail(num != 0, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(CHECK_PORT(impl, direction, port_id), -EINVAL);
 | 
						spa_return_val_if_fail(CHECK_PORT(impl, direction, port_id), -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1777,7 +1777,7 @@ int port_set_format(struct impl *impl, struct port *port,
 | 
				
			||||||
	struct spa_video_info info;
 | 
						struct spa_video_info info;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (format == NULL) {
 | 
						if (format == nullptr) {
 | 
				
			||||||
		if (!port->current_format)
 | 
							if (!port->current_format)
 | 
				
			||||||
			return 0;
 | 
								return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1840,7 +1840,7 @@ int port_set_format(struct impl *impl, struct port *port,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (port->current_format && !(flags & SPA_NODE_PARAM_FLAG_TEST_ONLY)) {
 | 
						if (port->current_format && !(flags & SPA_NODE_PARAM_FLAG_TEST_ONLY)) {
 | 
				
			||||||
		spa_libcamera_use_buffers(impl, port, NULL, 0);
 | 
							spa_libcamera_use_buffers(impl, port, nullptr, 0);
 | 
				
			||||||
		port->current_format.reset();
 | 
							port->current_format.reset();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1878,7 +1878,7 @@ int impl_node_port_set_param(void *object,
 | 
				
			||||||
	struct port *port;
 | 
						struct port *port;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(object != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(object != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(CHECK_PORT(impl, direction, port_id), -EINVAL);
 | 
						spa_return_val_if_fail(CHECK_PORT(impl, direction, port_id), -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	port = GET_PORT(impl, direction, port_id);
 | 
						port = GET_PORT(impl, direction, port_id);
 | 
				
			||||||
| 
						 | 
					@ -1904,7 +1904,7 @@ int impl_node_port_use_buffers(void *object,
 | 
				
			||||||
	struct port *port;
 | 
						struct port *port;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(impl != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(impl != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(CHECK_PORT(impl, direction, port_id), -EINVAL);
 | 
						spa_return_val_if_fail(CHECK_PORT(impl, direction, port_id), -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	port = GET_PORT(impl, direction, port_id);
 | 
						port = GET_PORT(impl, direction, port_id);
 | 
				
			||||||
| 
						 | 
					@ -1918,7 +1918,7 @@ int impl_node_port_use_buffers(void *object,
 | 
				
			||||||
		return -EIO;
 | 
							return -EIO;
 | 
				
			||||||
	if (n_buffers > MAX_BUFFERS)
 | 
						if (n_buffers > MAX_BUFFERS)
 | 
				
			||||||
		return -ENOSPC;
 | 
							return -ENOSPC;
 | 
				
			||||||
	if (buffers == NULL)
 | 
						if (buffers == nullptr)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (flags & SPA_NODE_BUFFERS_FLAG_ALLOC) {
 | 
						if (flags & SPA_NODE_BUFFERS_FLAG_ALLOC) {
 | 
				
			||||||
| 
						 | 
					@ -1938,7 +1938,7 @@ int impl_node_port_set_io(void *object,
 | 
				
			||||||
	struct impl *impl = (struct impl*)object;
 | 
						struct impl *impl = (struct impl*)object;
 | 
				
			||||||
	struct port *port;
 | 
						struct port *port;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(impl != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(impl != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(CHECK_PORT(impl, direction, port_id), -EINVAL);
 | 
						spa_return_val_if_fail(CHECK_PORT(impl, direction, port_id), -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	port = GET_PORT(impl, direction, port_id);
 | 
						port = GET_PORT(impl, direction, port_id);
 | 
				
			||||||
| 
						 | 
					@ -1964,7 +1964,7 @@ int impl_node_port_reuse_buffer(void *object,
 | 
				
			||||||
	struct port *port;
 | 
						struct port *port;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(impl != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(impl != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(port_id == 0, -EINVAL);
 | 
						spa_return_val_if_fail(port_id == 0, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	port = GET_OUT_PORT(impl, port_id);
 | 
						port = GET_OUT_PORT(impl, port_id);
 | 
				
			||||||
| 
						 | 
					@ -2007,10 +2007,10 @@ int impl_node_process(void *object)
 | 
				
			||||||
	struct port *port;
 | 
						struct port *port;
 | 
				
			||||||
	struct buffer *b;
 | 
						struct buffer *b;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(impl != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(impl != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	port = GET_OUT_PORT(impl, 0);
 | 
						port = GET_OUT_PORT(impl, 0);
 | 
				
			||||||
	if ((io = port->io) == NULL)
 | 
						if ((io = port->io) == nullptr)
 | 
				
			||||||
		return -EIO;
 | 
							return -EIO;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (port->control)
 | 
						if (port->control)
 | 
				
			||||||
| 
						 | 
					@ -2068,8 +2068,8 @@ int impl_get_interface(struct spa_handle *handle, const char *type, void **inter
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	auto *impl = reinterpret_cast<struct impl *>(handle);
 | 
						auto *impl = reinterpret_cast<struct impl *>(handle);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(handle != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(handle != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(interface != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(interface != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (spa_streq(type, SPA_TYPE_INTERFACE_Node))
 | 
						if (spa_streq(type, SPA_TYPE_INTERFACE_Node))
 | 
				
			||||||
		*interface = &impl->node;
 | 
							*interface = &impl->node;
 | 
				
			||||||
| 
						 | 
					@ -2136,8 +2136,8 @@ impl_init(const struct spa_handle_factory *factory,
 | 
				
			||||||
	const char *str;
 | 
						const char *str;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(factory != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(factory != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(handle != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(handle != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto log = static_cast<spa_log *>(spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log));
 | 
						auto log = static_cast<spa_log *>(spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log));
 | 
				
			||||||
	auto data_loop = static_cast<spa_loop *>(spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DataLoop));
 | 
						auto data_loop = static_cast<spa_loop *>(spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DataLoop));
 | 
				
			||||||
| 
						 | 
					@ -2183,9 +2183,9 @@ int impl_enum_interface_info(const struct spa_handle_factory *factory,
 | 
				
			||||||
			     const struct spa_interface_info **info,
 | 
								     const struct spa_interface_info **info,
 | 
				
			||||||
			     uint32_t *index)
 | 
								     uint32_t *index)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	spa_return_val_if_fail(factory != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(factory != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(info != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(info != nullptr, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(index != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(index != nullptr, -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (*index >= SPA_N_ELEMENTS(impl_interfaces))
 | 
						if (*index >= SPA_N_ELEMENTS(impl_interfaces))
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
| 
						 | 
					@ -2200,7 +2200,7 @@ extern "C" {
 | 
				
			||||||
const struct spa_handle_factory spa_libcamera_source_factory = {
 | 
					const struct spa_handle_factory spa_libcamera_source_factory = {
 | 
				
			||||||
	SPA_VERSION_HANDLE_FACTORY,
 | 
						SPA_VERSION_HANDLE_FACTORY,
 | 
				
			||||||
	SPA_NAME_API_LIBCAMERA_SOURCE,
 | 
						SPA_NAME_API_LIBCAMERA_SOURCE,
 | 
				
			||||||
	NULL,
 | 
						nullptr,
 | 
				
			||||||
	impl_get_size,
 | 
						impl_get_size,
 | 
				
			||||||
	impl_init,
 | 
						impl_init,
 | 
				
			||||||
	impl_enum_interface_info,
 | 
						impl_enum_interface_info,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue