1 #ifndef foopulsecardhfoo 2 #define foopulsecardhfoo 3 4 /*** 5 This file is part of PulseAudio. 6 7 Copyright 2009 Lennart Poettering 8 9 PulseAudio is free software; you can redistribute it and/or modify 10 it under the terms of the GNU Lesser General Public License as published 11 by the Free Software Foundation; either version 2.1 of the License, 12 or (at your option) any later version. 13 14 PulseAudio is distributed in the hope that it will be useful, but 15 WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 General Public License for more details. 18 19 You should have received a copy of the GNU Lesser General Public License 20 along with PulseAudio; if not, see <http://www.gnu.org/licenses/>. 21 ***/ 22 23 #include <pulsecore/typedefs.h> 24 #include <pulse/proplist.h> 25 #include <pulsecore/core.h> 26 #include <pulsecore/module.h> 27 #include <pulsecore/idxset.h> 28 29 /* This enum replaces pa_port_available_t (defined in pulse/def.h) for 30 * internal use, so make sure both enum types stay in sync. */ 31 typedef enum pa_available { 32 PA_AVAILABLE_UNKNOWN = 0, 33 PA_AVAILABLE_NO = 1, 34 PA_AVAILABLE_YES = 2, 35 } pa_available_t; 36 37 struct pa_card_profile { 38 pa_card *card; 39 char *name; 40 char *description; 41 42 /* Identifiers for the profile's input and output parts, i e, if two different profiles 43 have the same input_name string, they have the same source(s). 44 Same for output_name and sink(s). 45 Can be NULL (and in case of an input- or output- only profile, the other direction 46 will be NULL). */ 47 char *input_name; 48 char *output_name; 49 50 unsigned priority; 51 pa_available_t available; /* PA_AVAILABLE_UNKNOWN, PA_AVAILABLE_NO or PA_AVAILABLE_YES */ 52 53 /* We probably want to have different properties later on here */ 54 unsigned n_sinks; 55 unsigned n_sources; 56 57 unsigned max_sink_channels; 58 unsigned max_source_channels; 59 60 /* .. followed by some implementation specific data */ 61 }; 62 63 #define PA_CARD_PROFILE_DATA(d) ((void*) ((uint8_t*) d + PA_ALIGN(sizeof(pa_card_profile)))) 64 65 struct pa_card { 66 uint32_t index; 67 pa_core *core; 68 69 char *name; 70 71 pa_proplist *proplist; 72 pa_module *module; 73 char *driver; 74 75 pa_idxset *sinks; 76 pa_idxset *sources; 77 78 pa_hashmap *profiles; 79 pa_card_profile *active_profile; 80 81 pa_hashmap *ports; 82 pa_device_port *preferred_input_port; 83 pa_device_port *preferred_output_port; 84 85 bool save_profile:1; 86 87 pa_suspend_cause_t suspend_cause; 88 89 bool linked; 90 91 void *userdata; 92 93 int (*set_profile)(pa_card *c, pa_card_profile *profile); 94 }; 95 96 typedef struct pa_card_new_data { 97 char *name; 98 pa_proplist *proplist; 99 100 const char *driver; 101 pa_module *module; 102 103 pa_hashmap *profiles; 104 pa_hashmap *ports; 105 pa_device_port *preferred_input_port; 106 pa_device_port *preferred_output_port; 107 108 bool namereg_fail:1; 109 } pa_card_new_data; 110 111 typedef struct { 112 pa_card *card; 113 pa_direction_t direction; 114 } pa_card_preferred_port_changed_hook_data; 115 116 const char *pa_available_to_string(pa_available_t available); 117 118 pa_card_profile *pa_card_profile_new(const char *name, const char *description, size_t extra); 119 void pa_card_profile_free(pa_card_profile *c); 120 121 /* The profile's available status has changed */ 122 void pa_card_profile_set_available(pa_card_profile *c, pa_available_t available); 123 124 pa_card_new_data *pa_card_new_data_init(pa_card_new_data *data); 125 void pa_card_new_data_set_name(pa_card_new_data *data, const char *name); 126 void pa_card_new_data_set_preferred_port(pa_card_new_data *data, pa_direction_t direction, pa_device_port *port); 127 void pa_card_new_data_done(pa_card_new_data *data); 128 129 pa_card *pa_card_new(pa_core *c, pa_card_new_data *data); 130 131 /* Select the initial card profile according to the configured policies. This 132 * must be called between pa_card_new() and pa_card_put(), after the port and 133 * profile availabilities have been initialized. */ 134 void pa_card_choose_initial_profile(pa_card *card); 135 136 void pa_card_put(pa_card *c); 137 void pa_card_free(pa_card *c); 138 139 void pa_card_add_profile(pa_card *c, pa_card_profile *profile); 140 141 int pa_card_set_profile(pa_card *c, pa_card_profile *profile, bool save); 142 143 void pa_card_set_preferred_port(pa_card *c, pa_direction_t direction, pa_device_port *port); 144 145 int pa_card_suspend(pa_card *c, bool suspend, pa_suspend_cause_t cause); 146 147 #endif 148