]> code.delx.au - pulseaudio/blob - src/pulsecore/device-port.c
Cards now has ports directly, and device port has list of profiles
[pulseaudio] / src / pulsecore / device-port.c
1 /***
2 This file is part of PulseAudio.
3
4 Copyright 2004-2006 Lennart Poettering
5 Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
6 Copyright 2011 David Henningsson, Canonical Ltd.
7
8 PulseAudio is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published
10 by the Free Software Foundation; either version 2.1 of the License,
11 or (at your option) any later version.
12
13 PulseAudio is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with PulseAudio; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 USA.
22 ***/
23
24
25 #include "device-port.h"
26
27 PA_DEFINE_PUBLIC_CLASS(pa_device_port, pa_object);
28
29 static void device_port_free(pa_object *o) {
30 pa_device_port *p = PA_DEVICE_PORT(o);
31
32 pa_assert(p);
33 pa_assert(pa_device_port_refcnt(p) == 0);
34
35 if (p->profiles)
36 pa_hashmap_free(p->profiles, NULL, NULL);
37 pa_xfree(p->name);
38 pa_xfree(p->description);
39 pa_xfree(p);
40 }
41
42
43 pa_device_port *pa_device_port_new(const char *name, const char *description, size_t extra) {
44 pa_device_port *p;
45
46 pa_assert(name);
47
48 p = PA_DEVICE_PORT(pa_object_new_internal(PA_ALIGN(sizeof(pa_device_port)) + extra, pa_device_port_type_id, pa_device_port_check_type));
49 p->parent.free = device_port_free;
50
51 p->name = pa_xstrdup(name);
52 p->description = pa_xstrdup(description);
53 p->priority = 0;
54 p->available = PA_PORT_AVAILABLE_UNKNOWN;
55 p->profiles = NULL;
56 p->is_input = FALSE;
57 p->is_output = FALSE;
58
59 return p;
60 }
61
62 void pa_device_port_hashmap_free(pa_hashmap *h) {
63 pa_device_port *p;
64
65 pa_assert(h);
66
67 while ((p = pa_hashmap_steal_first(h)))
68 pa_device_port_unref(p);
69
70 pa_hashmap_free(h, NULL, NULL);
71 }