Fix the coding style errors (bt-service)
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / bt-service-audio.c
old mode 100644 (file)
new mode 100755 (executable)
index 9bda3f2..9d4eca6
@@ -1,11 +1,5 @@
 /*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
- *              Girishashok Joshi <girish.joshi@samsung.com>
- *              Chanyeol Park <chanyeol.park@samsung.com>
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -470,7 +464,7 @@ void _bt_add_headset_to_list(int type, int status, const char *address)
        }
 
        connected_device->device_state = status;
-       if (status == BT_STATE_CONNECTED)
+       if ((status == BT_STATE_CONNECTED) || (status == BT_STATE_CONNECTING))
                connected_device->type |= type;
        g_strlcpy(connected_device->device_address, address,
                        sizeof(connected_device->device_address));
@@ -550,19 +544,21 @@ static gboolean __bt_device_support_uuid(char *remote_address,
                                bt_audio_type_t type)
 {
        GArray *dev_list = NULL;
-       int size,i,j;
+       int size;
+       int i;
+       int j;
        bluetooth_device_info_t info;
        char bond_address[BT_ADDRESS_STRING_SIZE] = { 0 };
        gboolean ret = FALSE;
 
        BT_DBG("+");
 
-       dev_list = g_array_new (FALSE, FALSE, sizeof(gchar));
+       dev_list = g_array_new(FALSE, FALSE, sizeof(gchar));
 
        _bt_get_bonded_devices(&dev_list);
        size = (dev_list->len) / sizeof(bluetooth_device_info_t);
 
-       for (i=0; i < size; i++) {
+       for (i = 0; i < size; i++) {
                info = g_array_index(dev_list, bluetooth_device_info_t, i);
                _bt_convert_addr_type_to_string(bond_address,
                                info.device_address.addr);
@@ -667,8 +663,10 @@ int _bt_audio_connect(int request_id, int type,
                if (__bt_device_support_uuid(address, BT_AUDIO_HSP)) {
                        uuid = HFP_HS_UUID;
                        func_data->pending = BT_PENDING_CONNECT;
+                       type = BT_AUDIO_HSP;
                } else if (__bt_device_support_uuid(address, BT_AUDIO_A2DP)) {
                        uuid = A2DP_SINK_UUID;
+                       type = BT_AUDIO_A2DP;
                } else {
                        BT_ERR("No audio role supported");
                        result = BLUETOOTH_ERROR_SERVICE_NOT_FOUND;
@@ -735,6 +733,7 @@ int _bt_audio_disconnect(int request_id, int type,
        _bt_convert_addr_type_to_string(address, device_address->addr);
 
        func_data = g_malloc0(sizeof(bt_audio_function_data_t));
+       retv_if(func_data == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;