From: Sjors Gielen Date: Sun, 8 Jul 2012 21:24:18 +0000 (+0200) Subject: osx: Add a single "On" profile to coreaudio devices. Fixes crash on OS X. X-Git-Tag: v2.99.1~207 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d3cd82d411f9b574678870d8ccd836032a238684;p=platform%2Fupstream%2Fpulseaudio.git osx: Add a single "On" profile to coreaudio devices. Fixes crash on OS X. Since commit 12af302a last month, cards always have at least one profile, so there is also always an active_profile (this makes the code more simple). However, module-coreaudio-device did not create a profile yet, causing a crash of PulseAudio when used on OS X. This patch fixes this crash, by adding a single "On" profile. I've also added a TODO for adding an "Off" profile which removes all sinks and sources -- I can work on resolving this TODO later on. --- diff --git a/src/modules/macosx/module-coreaudio-device.c b/src/modules/macosx/module-coreaudio-device.c index 47fd1e693..6d39158b8 100644 --- a/src/modules/macosx/module-coreaudio-device.c +++ b/src/modules/macosx/module-coreaudio-device.c @@ -22,6 +22,7 @@ /* TODO: - implement hardware volume controls - handle audio device stream format changes (will require changes to the core) + - add an "off" mode that removes all sinks and sources */ #ifdef HAVE_CONFIG_H @@ -43,6 +44,7 @@ #include #include #include +#include #include #include @@ -125,6 +127,10 @@ struct coreaudio_source { PA_LLIST_FIELDS(coreaudio_source); }; +static int card_set_profile(pa_card *c, pa_card_profile *new_profile) { + return 0; +} + static OSStatus io_render_proc (AudioDeviceID device, const AudioTimeStamp *now, const AudioBufferList *inputData, @@ -686,6 +692,7 @@ int pa__init(pa_module *m) { pa_modargs *ma = NULL; char tmp[64]; pa_card_new_data card_new_data; + pa_card_profile *p; coreaudio_sink *ca_sink; coreaudio_source *ca_source; AudioObjectPropertyAddress property_address; @@ -733,6 +740,10 @@ int pa__init(pa_module *m) { if (!err) u->vendor_name = pa_xstrdup(tmp); + /* add on profile */ + p = pa_card_profile_new("on", _("On"), 0); + pa_hashmap_put(card_new_data.profiles, p->name, p); + /* create the card object */ u->card = pa_card_new(m->core, &card_new_data); if (!u->card) { @@ -742,6 +753,7 @@ int pa__init(pa_module *m) { pa_card_new_data_done(&card_new_data); u->card->userdata = u; + u->card->set_profile = card_set_profile; u->rtpoll = pa_rtpoll_new(); pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);