int main (int argc, char** argv) { ui_t *ui = NULL; sink_t *sink = NULL; GThread *sink_thread = NULL; GAsyncQueue *queue = NULL; g_thread_init (NULL); queue = g_async_queue_new (); if (!(sink = sink_init (queue))) return EXIT_FAILURE; if(!(ui = ui_init (queue, &argc, &argv))) return EXIT_FAILURE; g_async_queue_unref (queue); sink_thread = g_thread_create (sink_run, (gpointer) sink, TRUE, NULL); ui_run(ui); g_thread_join (sink_thread); ui_cleanup (ui); sink_cleanup (sink); g_printf ("So long, and thanks for the fish !\n"); return EXIT_SUCCESS; }
static int a2dp_sink_probe(struct btd_service *service) { struct btd_device *dev = btd_service_get_device(service); DBG("path %s", device_get_path(dev)); return sink_init(service); }
int audio_init(int sink_id) { // Get sink if(sink_id < 0 || sink_id >= SINK_COUNT) { return 1; } struct sink_info_t si = sinks[sink_id]; // Inform user INFO("Initializing audio sink '%s'.", audio_get_sink_name(sink_id)); // Init sink _global_sink = malloc(sizeof(audio_sink)); sink_init(_global_sink); if(si.sink_init_fn(_global_sink) != 0) { free(_global_sink); _global_sink = NULL; return 1; } // Success return 0; }
static void handle_uuid(const char *uuidstr, struct audio_device *device) { uuid_t uuid; uint16_t uuid16; if (bt_string2uuid(&uuid, uuidstr) < 0) { error("%s not detected as an UUID-128", uuidstr); return; } if (!sdp_uuid128_to_uuid(&uuid) && uuid.type != SDP_UUID16) { error("Could not convert %s to a UUID-16", uuidstr); return; } uuid16 = uuid.value.uuid16; if (!server_is_enabled(&device->src, uuid16)) { DBG("server not enabled for %s (0x%04x)", uuidstr, uuid16); return; } switch (uuid16) { case HEADSET_SVCLASS_ID: DBG("Found Headset record"); if (device->headset) headset_update(device, uuid16, uuidstr); else device->headset = headset_init(device, uuid16, uuidstr); break; case HEADSET_AGW_SVCLASS_ID: DBG("Found Headset AG record"); break; case HANDSFREE_SVCLASS_ID: DBG("Found Handsfree record"); if (device->headset) headset_update(device, uuid16, uuidstr); else device->headset = headset_init(device, uuid16, uuidstr); break; case HANDSFREE_AGW_SVCLASS_ID: DBG("Found Handsfree AG record"); if (enabled.gateway && (device->gateway == NULL)) device->gateway = gateway_init(device); break; case AUDIO_SINK_SVCLASS_ID: DBG("Found Audio Sink"); if (device->sink == NULL) device->sink = sink_init(device); break; case AUDIO_SOURCE_SVCLASS_ID: DBG("Found Audio Source"); if (device->source == NULL) device->source = source_init(device); break; case AV_REMOTE_SVCLASS_ID: case AV_REMOTE_TARGET_SVCLASS_ID: DBG("Found AV %s", uuid16 == AV_REMOTE_SVCLASS_ID ? "Remote" : "Target"); if (device->control) control_update(device, uuid16); else device->control = control_init(device, uuid16); /* SS_Bluetooth(sunjo4.kim) 2012.2.16 - add for a2dp connect fail */ //if (device->sink && sink_is_active(device)) // avrcp_connect(device); /* SS_Bluetooth(sunjo4.kim) End */ break; default: DBG("Unrecognized UUID: 0x%04X", uuid16); break; } }