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 bool profile_is_sticky:1; 87 88 pa_suspend_cause_t suspend_cause; 89 90 bool linked; 91 92 void *userdata; 93 94 int (*set_profile)(pa_card *c, pa_card_profile *profile); 95 }; 96 97 typedef struct pa_card_new_data { 98 char *name; 99 pa_proplist *proplist; 100 101 const char *driver; 102 pa_module *module; 103 104 pa_hashmap *profiles; 105 pa_hashmap *ports; 106 pa_device_port *preferred_input_port; 107 pa_device_port *preferred_output_port; 108 109 bool namereg_fail:1; 110 } pa_card_new_data; 111 112 typedef struct { 113 pa_card *card; 114 pa_direction_t direction; 115 } pa_card_preferred_port_changed_hook_data; 116 117 const char *pa_available_to_string(pa_available_t available); 118 119 pa_card_profile *pa_card_profile_new(const char *name, const char *description, size_t extra); 120 void pa_card_profile_free(pa_card_profile *c); 121 122 /* The profile's available status has changed */ 123 void pa_card_profile_set_available(pa_card_profile *c, pa_available_t available); 124 125 pa_card_new_data *pa_card_new_data_init(pa_card_new_data *data); 126 void pa_card_new_data_set_name(pa_card_new_data *data, const char *name); 127 void pa_card_new_data_set_preferred_port(pa_card_new_data *data, pa_direction_t direction, pa_device_port *port); 128 void pa_card_new_data_done(pa_card_new_data *data); 129 130 pa_card *pa_card_new(pa_core *c, pa_card_new_data *data); 131 132 /* Select the initial card profile according to the configured policies. This 133 * must be called between pa_card_new() and pa_card_put(), after the port and 134 * profile availabilities have been initialized. */ 135 void pa_card_choose_initial_profile(pa_card *card); 136 137 void pa_card_put(pa_card *c); 138 void pa_card_free(pa_card *c); 139 140 void pa_card_add_profile(pa_card *c, pa_card_profile *profile); 141 142 int pa_card_set_profile(pa_card *c, pa_card_profile *profile, bool save); 143 144 void pa_card_set_preferred_port(pa_card *c, pa_direction_t direction, pa_device_port *port); 145 146 int pa_card_suspend(pa_card *c, bool suspend, pa_suspend_cause_t cause); 147 148 #endif 149