Пример #1
0
void
xmmsc_ipc_result_register (xmmsc_ipc_t *ipc, xmmsc_result_t *res)
{
	x_return_if_fail (ipc);
	x_return_if_fail (res);

	xmmsc_ipc_lock (ipc);
	ipc->results_list = x_list_prepend (ipc->results_list, res);
	xmmsc_ipc_unlock (ipc);
}
Пример #2
0
/**
 * Replace all attributes in the given collection.
 *
 * @param coll The collection in which to set the attribute.
 * @param attributes The new attributes.
 */
void
xmmsv_coll_attributes_set (xmmsv_t *coll, xmmsv_t *attributes)
{
	xmmsv_t *old;

	x_return_if_fail (coll);
	x_return_if_fail (attributes);
	x_return_if_fail (xmmsv_is_type (attributes, XMMSV_TYPE_DICT));

	old = coll->value.coll->attributes;
	coll->value.coll->attributes = xmmsv_ref (attributes);
	xmmsv_unref (old);
}
Пример #3
0
/**
 * Replace all operands in the given collection.
 *
 * @param coll The collection in which to set the operands.
 * @param operands The new operands.
 */
void
xmmsv_coll_operands_set (xmmsv_t *coll, xmmsv_t *operands)
{
	xmmsv_t *old;

	x_return_if_fail (coll);
	x_return_if_fail (operands);
	x_return_if_fail (xmmsv_list_restrict_type (operands, XMMSV_TYPE_COLL));

	old = coll->value.coll->operands;
	coll->value.coll->operands = xmmsv_ref (operands);
	xmmsv_unref (old);
}
Пример #4
0
/**
 * Replace the idlist in the given collection.
 *
 * @param coll The collection in which to set the idlist.
 * @param operands The new idlist.
 */
void
xmmsv_coll_idlist_set (xmmsv_t *coll, xmmsv_t *idlist)
{
	xmmsv_t *old;

	x_return_if_fail (coll);
	x_return_if_fail (idlist);
	x_return_if_fail (xmmsv_list_restrict_type (idlist, XMMSV_TYPE_INT64));

	old = coll->value.coll->idlist;
	coll->value.coll->idlist = xmmsv_ref (idlist);
	xmmsv_unref (old);
}
Пример #5
0
void x_mutex_free(xMutex *mutex)
{
	x_return_if_fail(mutex);
	x_mutex_unlock(mutex);
	CloseHandle(mutex->handle);
	free(mutex);
}
Пример #6
0
void x_mutex_lock(xMutex *mutex)
{
	x_return_if_fail(mutex);

	if (mutex->handle != INVALID_HANDLE_VALUE)
		mutex->ret = WaitForSingleObject(mutex->handle, INFINITE);
}
Пример #7
0
void x_serialport_free(xSerialPort *port)
{
	x_return_if_fail(port);
	x_serialport_close(port);
	x_string_free(port->port_name, TRUE);
	x_serialport_platform_free(port->platform);
	free(port);
}
Пример #8
0
void
xmmsc_ipc_disconnect_set (xmmsc_ipc_t *ipc, void (*disconnect_callback) (void *), void *userdata, xmmsc_user_data_free_func_t free_func)
{
	x_return_if_fail (ipc);
	ipc->disconnect_callback = disconnect_callback;
	ipc->disconnect_data = userdata;
	ipc->disconnect_data_free_func = free_func;
}
Пример #9
0
void
xmmsc_ipc_need_out_callback_set (xmmsc_ipc_t *ipc, void (*callback) (int, void *), void *userdata, xmmsc_user_data_free_func_t free_func)
{
	x_return_if_fail (ipc);
	ipc->need_out_callback = callback;
	ipc->need_out_data = userdata;
	ipc->need_out_data_free_func = free_func;
}
Пример #10
0
void
xmms_ipc_msg_destroy (xmms_ipc_msg_t *msg)
{
	x_return_if_fail (msg);

	xmmsv_unref (msg->bb);
	free (msg);
}
Пример #11
0
/**
 * Remove all the occurences of the operand in the given collection.
 * @param coll  The collection to remove the operand from.
 * @param op    The operand to remove.
 */
void
xmmsv_coll_remove_operand (xmmsv_t *coll, xmmsv_t *op)
{
	xmmsv_list_iter_t *it;

	x_return_if_fail (coll);
	x_return_if_fail (op);

	if (!xmmsv_get_list_iter (coll->value.coll->operands, &it))
		return;

	if (_xmmsv_coll_operand_find (it, op)) {
		xmmsv_list_iter_remove (it);
	} else {
		x_api_warning ("with an operand not in operand list");
	}
	xmmsv_list_iter_explicit_destroy (it);
}
Пример #12
0
void
x_queue_free (x_queue_t *queue)
{
	x_return_if_fail (queue);

	x_list_free (queue->head);

	free (queue);
}
Пример #13
0
static void
xmms_ipc_msg_set_object (xmms_ipc_msg_t *msg, uint32_t object)
{
	x_return_if_fail (msg);

	xmmsv_bitbuffer_goto (msg->bb, 0);
	xmmsv_bitbuffer_put_bits (msg->bb, 32, object);
	xmmsv_bitbuffer_end (msg->bb);
}
Пример #14
0
void
xmms_ipc_transport_destroy (xmms_ipc_transport_t *ipct)
{
	x_return_if_fail (ipct);

	ipct->destroy_func (ipct);

	free (ipct);
}
Пример #15
0
static void
xmms_ipc_msg_set_cmd (xmms_ipc_msg_t *msg, uint32_t cmd)
{
	x_return_if_fail (msg);

	xmmsv_bitbuffer_goto (msg->bb, 4 * 8);
	xmmsv_bitbuffer_put_bits (msg->bb, 32, cmd);
	xmmsv_bitbuffer_end (msg->bb);
}
Пример #16
0
void x_mutex_unlock(xMutex *mutex)
{
	x_return_if_fail(mutex);

	/* Release owenship of the mutex object */
	if (!ReleaseMutex(mutex->handle))
	{
		/* Handle error */
	}
}
Пример #17
0
void x_mutex_free(xMutex *mutex)
{
	x_return_if_fail(mutex);
	
	x_mutex_unlock(mutex);

	pthread_mutex_destroy(&(mutex->handle));

	free(mutex);
}
Пример #18
0
void
xmmsc_ipc_result_unregister (xmmsc_ipc_t *ipc, xmmsc_result_t *res)
{
	x_list_t *n;

	x_return_if_fail (ipc);
	x_return_if_fail (res);

	xmmsc_ipc_lock (ipc);

	for (n = ipc->results_list; n; n = x_list_next (n)) {
		xmmsc_result_t *tmp = n->data;

		if (xmmsc_result_cookie_get (res) == xmmsc_result_cookie_get (tmp)) {
			ipc->results_list = x_list_delete_link (ipc->results_list, n);
			break;
		}
	}

	xmmsc_ipc_unlock (ipc);
}
Пример #19
0
/**
 * Free the memory owned by the collection.
 * You probably want to use #xmmsv_coll_unref instead, which handles
 * reference counting.
 *
 * @param coll the collection to free.
 */
void
_xmmsv_coll_free (xmmsv_coll_internal_t *coll)
{
	x_return_if_fail (coll);

	/* Unref all the operands and attributes */
	xmmsv_unref (coll->operands);
	xmmsv_unref (coll->attributes);
	xmmsv_unref (coll->idlist);

	free (coll);
}
Пример #20
0
/**
 * Add the operand to the given collection.
 * @param coll  The collection to add the operand to.
 * @param op    The operand to add.
 */
void
xmmsv_coll_add_operand (xmmsv_t *coll, xmmsv_t *op)
{
	xmmsv_list_iter_t *it;
	x_return_if_fail (coll);
	x_return_if_fail (op);

	/* we used to check if it already existed here before */
	if (!xmmsv_get_list_iter (coll->value.coll->operands, &it))
		return;

	if (_xmmsv_coll_operand_find (it, op)) {
		x_api_warning ("with an operand already in operand list");
		xmmsv_list_iter_explicit_destroy (it);
		return;
	}

	xmmsv_list_iter_explicit_destroy (it);

	xmmsv_list_append (coll->value.coll->operands, op);
}
Пример #21
0
void
x_queue_push_head (x_queue_t *queue, void *data)
{
	x_return_if_fail (queue);

	queue->head = x_list_prepend (queue->head, data);

	if (!queue->tail)
		queue->tail = queue->head;

	queue->length++;
}
Пример #22
0
static void
_internal_put_on_bb_append_coll_attr (const char *key, xmmsv_t *value, void *userdata)
{
	xmmsv_t *bb = (xmmsv_t *)userdata;
	const char *s;
	int r;

	r = xmmsv_get_string (value, &s);
	x_return_if_fail (r);

	_internal_put_on_bb_string (bb, key);
	_internal_put_on_bb_string (bb, s);
}
Пример #23
0
void
x_queue_push_tail (x_queue_t *queue, void *data)
{
	x_return_if_fail (queue);

	queue->tail = x_list_append (queue->tail, data);

	if (queue->tail->next)
		queue->tail = queue->tail->next;
	else
		queue->head = queue->tail;

	queue->length++;
}
Пример #24
0
void
xmmsc_ipc_wait_for_event (xmmsc_ipc_t *ipc, unsigned int timeout)
{
	fd_set rfdset;
	fd_set wfdset;
	struct timeval tmout;
	xmms_socket_t fd;

	x_return_if_fail (ipc);
	x_return_if_fail (!ipc->disconnect);

	tmout.tv_sec = timeout;
	tmout.tv_usec = 0;

	fd = xmms_ipc_transport_fd_get (ipc->transport);

	FD_ZERO (&rfdset);
	FD_SET (fd, &rfdset);

	FD_ZERO (&wfdset);
	if (xmmsc_ipc_io_out (ipc)) {
		FD_SET (fd, &wfdset);
	}

	if (select (fd + 1, &rfdset, &wfdset, NULL, &tmout) == SOCKET_ERROR) {
		return;
	}

	if (FD_ISSET (fd, &rfdset)) {
		if (!xmmsc_ipc_io_in_callback (ipc)) {
			return;
		}
	}
	if (FD_ISSET (fd, &wfdset)) {
		xmmsc_ipc_io_out_callback (ipc);
	}
}
Пример #25
0
void x_mutex_unlock(xMutex *mutex)
{
	x_return_if_fail(mutex);

	pthread_mutex_unlock(&(mutex->handle));
}
Пример #26
0
/**
 * Set an attribute in the given collection.
 *
 * @param coll The collection in which to set the attribute.
 * @param key  The name of the attribute to set.
 * @param value The value of the attribute.
 */
void
xmmsv_coll_attribute_set_value (xmmsv_t *coll, const char *key, xmmsv_t *value)
{
	x_return_if_fail (xmmsv_is_type (coll, XMMSV_TYPE_COLL));
	xmmsv_dict_set (coll->value.coll->attributes, key, value);
}
Пример #27
0
void
xmmsc_ipc_error_set (xmmsc_ipc_t *ipc, char *error)
{
	x_return_if_fail (ipc);
	ipc->error = error;
}