mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	monitor: fix some leaks
This commit is contained in:
		
							parent
							
								
									c25834a692
								
							
						
					
					
						commit
						80cf20a255
					
				
					 2 changed files with 34 additions and 6 deletions
				
			
		| 
						 | 
					@ -374,12 +374,13 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
 | 
				
			||||||
		if ((res = impl_udev_open(this)) < 0)
 | 
							if ((res = impl_udev_open(this)) < 0)
 | 
				
			||||||
			return res;
 | 
								return res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (this->umonitor)
 | 
				
			||||||
 | 
								udev_monitor_unref(this->umonitor);
 | 
				
			||||||
		this->umonitor = udev_monitor_new_from_netlink(this->udev, "udev");
 | 
							this->umonitor = udev_monitor_new_from_netlink(this->udev, "udev");
 | 
				
			||||||
		if (!this->umonitor)
 | 
							if (this->umonitor == NULL)
 | 
				
			||||||
			return SPA_RESULT_ERROR;
 | 
								return SPA_RESULT_ERROR;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		udev_monitor_filter_add_match_subsystem_devtype(this->umonitor, "sound", NULL);
 | 
							udev_monitor_filter_add_match_subsystem_devtype(this->umonitor, "sound", NULL);
 | 
				
			||||||
 | 
					 | 
				
			||||||
		udev_monitor_enable_receiving(this->umonitor);
 | 
							udev_monitor_enable_receiving(this->umonitor);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		this->source.func = impl_on_fd_events;
 | 
							this->source.func = impl_on_fd_events;
 | 
				
			||||||
| 
						 | 
					@ -441,6 +442,7 @@ static int impl_monitor_enum_items(struct spa_monitor *monitor,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (get_next_device(this, this->dev) < 0) {
 | 
						if (get_next_device(this, this->dev) < 0) {
 | 
				
			||||||
 | 
							udev_device_unref(this->dev);
 | 
				
			||||||
		close_card(this);
 | 
							close_card(this);
 | 
				
			||||||
		goto next;
 | 
							goto next;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -478,6 +480,17 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int impl_clear(struct spa_handle *handle)
 | 
					static int impl_clear(struct spa_handle *handle)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					        struct impl *this = (struct impl *) handle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (this->dev)
 | 
				
			||||||
 | 
							udev_device_unref(this->dev);
 | 
				
			||||||
 | 
					        if (this->enumerate)
 | 
				
			||||||
 | 
					                udev_enumerate_unref(this->enumerate);
 | 
				
			||||||
 | 
					        if (this->umonitor)
 | 
				
			||||||
 | 
					                udev_monitor_unref(this->umonitor);
 | 
				
			||||||
 | 
					        if (this->udev)
 | 
				
			||||||
 | 
					                udev_unref(this->udev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return SPA_RESULT_OK;
 | 
						return SPA_RESULT_OK;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -495,7 +508,9 @@ impl_init(const struct spa_handle_factory *factory,
 | 
				
			||||||
	spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
 | 
						spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	handle->get_interface = impl_get_interface;
 | 
						handle->get_interface = impl_get_interface;
 | 
				
			||||||
	handle->clear = impl_clear, this = (struct impl *) handle;
 | 
						handle->clear = impl_clear;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this = (struct impl *) handle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i < n_support; i++) {
 | 
						for (i = 0; i < n_support; i++) {
 | 
				
			||||||
		if (strcmp(support[i].type, SPA_TYPE__TypeMap) == 0)
 | 
							if (strcmp(support[i].type, SPA_TYPE__TypeMap) == 0)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -252,14 +252,16 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
 | 
				
			||||||
		if ((res = impl_udev_open(this)) < 0)
 | 
							if ((res = impl_udev_open(this)) < 0)
 | 
				
			||||||
			return res;
 | 
								return res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (this->umonitor)
 | 
				
			||||||
 | 
								udev_monitor_unref(this->umonitor);
 | 
				
			||||||
		this->umonitor = udev_monitor_new_from_netlink(this->udev, "udev");
 | 
							this->umonitor = udev_monitor_new_from_netlink(this->udev, "udev");
 | 
				
			||||||
		if (!this->umonitor)
 | 
							if (this->umonitor == NULL)
 | 
				
			||||||
			return SPA_RESULT_ERROR;
 | 
								return SPA_RESULT_ERROR;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		udev_monitor_filter_add_match_subsystem_devtype(this->umonitor,
 | 
							udev_monitor_filter_add_match_subsystem_devtype(this->umonitor,
 | 
				
			||||||
								"video4linux", NULL);
 | 
													"video4linux", NULL);
 | 
				
			||||||
 | 
					 | 
				
			||||||
		udev_monitor_enable_receiving(this->umonitor);
 | 
							udev_monitor_enable_receiving(this->umonitor);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		this->source.func = impl_on_fd_events;
 | 
							this->source.func = impl_on_fd_events;
 | 
				
			||||||
		this->source.data = this;
 | 
							this->source.data = this;
 | 
				
			||||||
		this->source.fd = udev_monitor_get_fd(this->umonitor);;
 | 
							this->source.fd = udev_monitor_get_fd(this->umonitor);;
 | 
				
			||||||
| 
						 | 
					@ -348,6 +350,15 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int impl_clear(struct spa_handle *handle)
 | 
					static int impl_clear(struct spa_handle *handle)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						struct impl *this = (struct impl *) handle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (this->enumerate)
 | 
				
			||||||
 | 
							udev_enumerate_unref(this->enumerate);
 | 
				
			||||||
 | 
						if (this->umonitor)
 | 
				
			||||||
 | 
							udev_monitor_unref(this->umonitor);
 | 
				
			||||||
 | 
						if (this->udev)
 | 
				
			||||||
 | 
							udev_unref(this->udev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return SPA_RESULT_OK;
 | 
						return SPA_RESULT_OK;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -365,7 +376,9 @@ impl_init(const struct spa_handle_factory *factory,
 | 
				
			||||||
	spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
 | 
						spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	handle->get_interface = impl_get_interface;
 | 
						handle->get_interface = impl_get_interface;
 | 
				
			||||||
	handle->clear = impl_clear, this = (struct impl *) handle;
 | 
						handle->clear = impl_clear;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this = (struct impl *) handle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i < n_support; i++) {
 | 
						for (i = 0; i < n_support; i++) {
 | 
				
			||||||
		if (strcmp(support[i].type, SPA_TYPE__TypeMap) == 0)
 | 
							if (strcmp(support[i].type, SPA_TYPE__TypeMap) == 0)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue