Turn device ports into reference counted objects

Since both cards and sinks can hold references to a port, it makes
sense to reference count them. Although no current implementation
actually has sinks with ports but without a card, it felt wrong
to make it harder to make such an implementation in the future.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
This commit is contained in:
David Henningsson 2011-11-25 15:17:12 +01:00 committed by Tanu Kaskinen
parent 961ec210a6
commit d9685ec85d
7 changed files with 138 additions and 69 deletions

View file

@ -24,7 +24,6 @@
***/
typedef struct pa_sink pa_sink;
typedef struct pa_device_port pa_device_port;
typedef struct pa_sink_volume_change pa_sink_volume_change;
#include <inttypes.h>
@ -43,6 +42,7 @@ typedef struct pa_sink_volume_change pa_sink_volume_change;
#include <pulsecore/asyncmsgq.h>
#include <pulsecore/msgobject.h>
#include <pulsecore/rtpoll.h>
#include <pulsecore/device-port.h>
#include <pulsecore/card.h>
#include <pulsecore/queue.h>
#include <pulsecore/thread-mq.h>
@ -55,18 +55,6 @@ static inline pa_bool_t PA_SINK_IS_LINKED(pa_sink_state_t x) {
return x == PA_SINK_RUNNING || x == PA_SINK_IDLE || x == PA_SINK_SUSPENDED;
}
struct pa_device_port {
char *name;
char *description;
unsigned priority;
pa_port_available_t available; /* PA_PORT_AVAILABLE_UNKNOWN, PA_PORT_AVAILABLE_NO or PA_PORT_AVAILABLE_YES */
/* .. followed by some implementation specific data */
};
#define PA_DEVICE_PORT_DATA(d) ((void*) ((uint8_t*) d + PA_ALIGN(sizeof(pa_device_port))))
/* A generic definition for void callback functions */
typedef void(*pa_sink_cb_t)(pa_sink *s);
@ -500,9 +488,6 @@ void pa_sink_invalidate_requested_latency(pa_sink *s, pa_bool_t dynamic);
pa_usec_t pa_sink_get_latency_within_thread(pa_sink *s);
pa_device_port *pa_device_port_new(const char *name, const char *description, size_t extra);
void pa_device_port_free(pa_device_port *p);
/* Verify that we called in IO context (aka 'thread context), or that
* the sink is not yet set up, i.e. the thread not set up yet. See
* pa_assert_io_context() in thread-mq.h for more information. */