Lines 26-31
Link Here
|
26 |
#include <pulsecore/module.h> |
26 |
#include <pulsecore/module.h> |
27 |
#include <pulsecore/core-util.h> |
27 |
#include <pulsecore/core-util.h> |
28 |
#include <pulsecore/modargs.h> |
28 |
#include <pulsecore/modargs.h> |
|
|
29 |
#include <pulsecore/namereg.h> |
29 |
#include <pulsecore/log.h> |
30 |
#include <pulsecore/log.h> |
30 |
#include <pulsecore/llist.h> |
31 |
#include <pulsecore/llist.h> |
31 |
|
32 |
|
Lines 115-120
static int ca_update_device_list(struct pa_module *m) {
Link Here
|
115 |
OSStatus err; |
116 |
OSStatus err; |
116 |
UInt32 i, size, num_devices; |
117 |
UInt32 i, size, num_devices; |
117 |
AudioDeviceID *device_id; |
118 |
AudioDeviceID *device_id; |
|
|
119 |
AudioDeviceID default_id; |
118 |
struct ca_device *dev; |
120 |
struct ca_device *dev; |
119 |
struct userdata *u; |
121 |
struct userdata *u; |
120 |
|
122 |
|
Lines 178-183
scan_removed:
Link Here
|
178 |
} |
180 |
} |
179 |
} |
181 |
} |
180 |
|
182 |
|
|
|
183 |
/* configure the default source */ |
184 |
|
185 |
property_address.mSelector = kAudioHardwarePropertyDefaultInputDevice; |
186 |
property_address.mScope = kAudioObjectPropertyScopeGlobal; |
187 |
property_address.mElement = kAudioObjectPropertyElementMaster; |
188 |
|
189 |
size = sizeof(AudioDeviceID); |
190 |
err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property_address, 0, NULL, &size, &default_id); |
191 |
if (err) { |
192 |
pa_log("Unable to get kAudioHardwarePropertyDefaultInputDevice."); |
193 |
} else { |
194 |
PA_LLIST_FOREACH(dev, u->devices) { |
195 |
pa_source *source; |
196 |
uint32_t idx; |
197 |
|
198 |
if (dev->id != default_id) |
199 |
continue; |
200 |
|
201 |
PA_IDXSET_FOREACH(source, m->core->sources, idx) { |
202 |
if (source->monitor_of) |
203 |
continue; |
204 |
if (!source->module || source->module->index != dev->module_index) |
205 |
continue; |
206 |
|
207 |
pa_namereg_set_default_source(m->core, source); |
208 |
break; |
209 |
} |
210 |
|
211 |
break; |
212 |
} |
213 |
} |
214 |
|
215 |
/* configure the default source */ |
216 |
|
217 |
property_address.mSelector = kAudioHardwarePropertyDefaultOutputDevice; |
218 |
property_address.mScope = kAudioObjectPropertyScopeGlobal; |
219 |
property_address.mElement = kAudioObjectPropertyElementMaster; |
220 |
|
221 |
size = sizeof(AudioDeviceID); |
222 |
err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property_address, 0, NULL, &size, &default_id); |
223 |
if (err) { |
224 |
pa_log("Unable to get kAudioHardwarePropertyDefaultOutputDevice."); |
225 |
} else { |
226 |
PA_LLIST_FOREACH(dev, u->devices) { |
227 |
pa_sink *sink; |
228 |
uint32_t idx; |
229 |
|
230 |
if (dev->id != default_id) |
231 |
continue; |
232 |
|
233 |
PA_IDXSET_FOREACH(sink, m->core->sinks, idx) { |
234 |
if (!sink->module || sink->module->index != dev->module_index) |
235 |
continue; |
236 |
|
237 |
pa_namereg_set_default_sink(m->core, sink); |
238 |
break; |
239 |
} |
240 |
|
241 |
break; |
242 |
} |
243 |
} |
244 |
|
181 |
pa_xfree(device_id); |
245 |
pa_xfree(device_id); |
182 |
return 0; |
246 |
return 0; |
183 |
} |
247 |
} |
Lines 231-236
int pa__init(pa_module *m) {
Link Here
|
231 |
goto fail; |
295 |
goto fail; |
232 |
} |
296 |
} |
233 |
|
297 |
|
|
|
298 |
property_address.mSelector = kAudioHardwarePropertyDefaultInputDevice; |
299 |
property_address.mScope = kAudioObjectPropertyScopeGlobal; |
300 |
property_address.mElement = kAudioObjectPropertyElementMaster; |
301 |
|
302 |
if (AudioObjectAddPropertyListener(kAudioObjectSystemObject, &property_address, property_listener_proc, u)) { |
303 |
pa_log("AudioObjectAddPropertyListener() failed."); |
304 |
goto fail; |
305 |
} |
306 |
|
307 |
property_address.mSelector = kAudioHardwarePropertyDefaultOutputDevice; |
308 |
property_address.mScope = kAudioObjectPropertyScopeGlobal; |
309 |
property_address.mElement = kAudioObjectPropertyElementMaster; |
310 |
|
311 |
if (AudioObjectAddPropertyListener(kAudioObjectSystemObject, &property_address, property_listener_proc, u)) { |
312 |
pa_log("AudioObjectAddPropertyListener() failed."); |
313 |
goto fail; |
314 |
} |
315 |
|
234 |
if (ca_update_device_list(m)) |
316 |
if (ca_update_device_list(m)) |
235 |
goto fail; |
317 |
goto fail; |
236 |
|
318 |
|
Lines 260-265
void pa__done(pa_module *m) {
Link Here
|
260 |
|
342 |
|
261 |
AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &property_address, property_listener_proc, u); |
343 |
AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &property_address, property_listener_proc, u); |
262 |
|
344 |
|
|
|
345 |
property_address.mSelector = kAudioHardwarePropertyDefaultInputDevice; |
346 |
property_address.mScope = kAudioObjectPropertyScopeGlobal; |
347 |
property_address.mElement = kAudioObjectPropertyElementMaster; |
348 |
|
349 |
AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &property_address, property_listener_proc, u); |
350 |
|
351 |
property_address.mSelector = kAudioHardwarePropertyDefaultOutputDevice; |
352 |
property_address.mScope = kAudioObjectPropertyScopeGlobal; |
353 |
property_address.mElement = kAudioObjectPropertyElementMaster; |
354 |
|
355 |
AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &property_address, property_listener_proc, u); |
356 |
|
263 |
while (dev) { |
357 |
while (dev) { |
264 |
struct ca_device *next = dev->next; |
358 |
struct ca_device *next = dev->next; |
265 |
|
359 |
|