remove ucm feature 46/56846/3 accepted/tizen/tv/20160114.013241 submit/tizen_tv/20160113.084722
authorMok Jeongho <jho.mok@samsung.com>
Wed, 13 Jan 2016 05:37:44 +0000 (14:37 +0900)
committerMok Jeongho <jho.mok@samsung.com>
Wed, 13 Jan 2016 08:39:31 +0000 (17:39 +0900)
[Version] 0.1.8
[Profile] TV
[Issue Type] Remove Feature

Change-Id: Idb260e328ed7a64bcd7f6fe14f8419e6085f3f05

Makefile.am
packaging/audio-hal-hawkp.spec
tizen-audio-device.c
tizen-audio-internal.h
tizen-audio-ucm.c [deleted file]
tizen-audio.c

index 1145f10..4fdba48 100644 (file)
@@ -3,7 +3,6 @@ lib_LTLIBRARIES = libtizen-audio.la
 libtizen_audio_la_SOURCES = tizen-audio.c \
                tizen-audio-device.c \
                tizen-audio-volume.c \
-               tizen-audio-ucm.c \
                tizen-audio-util.c
 libtizen_audio_la_LDFLAGS = $(AM_LDFLAGS) -disable-static -avoid-version
 if USE_TINYALSA
index d52d422..b756b8b 100644 (file)
@@ -1,6 +1,6 @@
 Name:       audio-hal-hawkp
 Summary:    TIZEN Audio HAL for Hawkp
-Version:    0.1.7
+Version:    0.1.8
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index 49b01ee..d628ed2 100644 (file)
@@ -46,10 +46,6 @@ static device_type_t inDeviceTypes[] = {
     { 0, 0 },
 };
 
-static const char* mode_to_verb_str[] = {
-    AUDIO_USE_CASE_VERB_HIFI,
-};
-
 static uint32_t convert_device_string_to_enum(const char* device_str, uint32_t direction)
 {
     uint32_t device = 0;
@@ -79,7 +75,7 @@ static uint32_t convert_device_string_to_enum(const char* device_str, uint32_t d
     return device;
 }
 
-static audio_return_t set_devices(audio_hal_t *ah, const char *verb, device_info_t *devices, uint32_t num_of_devices)
+static audio_return_t set_devices(audio_hal_t *ah, device_info_t *devices, uint32_t num_of_devices)
 {
     audio_return_t audio_ret = AUDIO_RET_OK;
     uint32_t new_device = 0;
@@ -140,12 +136,6 @@ static audio_return_t set_devices(audio_hal_t *ah, const char *verb, device_info
         return AUDIO_ERR_PARAMETER;
     }
 
-#ifdef USE_UCM
-    audio_ret = _audio_ucm_set_devices(ah, verb, active_devices);
-    if (audio_ret)
-        AUDIO_LOG_ERROR("Failed to set device: error = %d", audio_ret);
-#endif
-
     return audio_ret;
 }
 
@@ -157,7 +147,6 @@ audio_return_t _audio_device_init(audio_hal_t *ah)
     ah->device.active_out = 0x0;
     ah->device.pcm_in = NULL;
     ah->device.pcm_out = NULL;
-    ah->device.mode = VERB_NORMAL;
     pthread_mutex_init(&ah->device.pcm_lock, NULL);
     ah->device.pcm_count = 0;
 
@@ -175,43 +164,19 @@ static audio_return_t _do_route_ap_playback_capture(audio_hal_t *ah, audio_route
 {
     audio_return_t audio_ret = AUDIO_RET_OK;
     device_info_t *devices = NULL;
-    const char *verb = mode_to_verb_str[VERB_NORMAL];
 
     AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
     AUDIO_RETURN_VAL_IF_FAIL(route_info, AUDIO_ERR_PARAMETER);
 
     devices = route_info->device_infos;
 
-    /* To Do: Set modifiers */
-    /* int mod_idx = 0; */
-    /* const char *modifiers[MAX_MODIFIERS] = {NULL,}; */
-
     AUDIO_LOG_INFO("do_route_ap_playback_capture++ ");
 
-    audio_ret = set_devices(ah, verb, devices, route_info->num_of_devices);
+    audio_ret = set_devices(ah, devices, route_info->num_of_devices);
     if (audio_ret) {
         AUDIO_LOG_ERROR("Failed to set devices: error = 0x%x", audio_ret);
         return audio_ret;
     }
-    ah->device.mode = VERB_NORMAL;
-
-    /* To Do: Set modifiers */
-    /*
-    if (!strncmp("voice_recognition", route_info->role, MAX_NAME_LEN)) {
-        modifiers[mod_idx++] = AUDIO_USE_CASE_MODIFIER_VOICESEARCH;
-    } else if ((!strncmp("alarm", route_info->role, MAX_NAME_LEN))||(!strncmp("notifiication", route_info->role, MAX_NAME_LEN))) {
-        if (ah->device.active_out &= AUDIO_DEVICE_OUT_JACK)
-            modifiers[mod_idx++] = AUDIO_USE_CASE_MODIFIER_DUAL_MEDIA;
-        else
-            modifiers[mod_idx++] = AUDIO_USE_CASE_MODIFIER_MEDIA;
-    } else {
-        if (ah->device.active_in)
-            modifiers[mod_idx++] = AUDIO_USE_CASE_MODIFIER_CAMCORDING;
-        else
-            modifiers[mod_idx++] = AUDIO_USE_CASE_MODIFIER_MEDIA;
-    }
-    audio_ret = _audio_ucm_set_modifiers (ah, verb, modifiers);
-    */
 
     return audio_ret;
 }
@@ -219,22 +184,18 @@ static audio_return_t _do_route_ap_playback_capture(audio_hal_t *ah, audio_route
 static audio_return_t _do_route_voip(audio_hal_t *ah, device_info_t *devices, int32_t num_of_devices)
 {
     audio_return_t audio_ret = AUDIO_RET_OK;
-    const char *verb = mode_to_verb_str[VERB_NORMAL];
 
     AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
     AUDIO_RETURN_VAL_IF_FAIL(devices, AUDIO_ERR_PARAMETER);
 
     AUDIO_LOG_INFO("do_route_voip++");
 
-    audio_ret = set_devices(ah, verb, devices, num_of_devices);
+    audio_ret = set_devices(ah, devices, num_of_devices);
     if (audio_ret) {
         AUDIO_LOG_ERROR("Failed to set devices: error = 0x%x", audio_ret);
         return audio_ret;
     }
-    /* FIXME. If necessary, set VERB_VOIP */
-    ah->device.mode = VERB_NORMAL;
 
-    /* TO DO: Set modifiers */
     return audio_ret;
 }
 
@@ -244,10 +205,6 @@ static audio_return_t _do_route_reset(audio_hal_t *ah, uint32_t direction)
     const char *active_devices[MAX_DEVICES] = {NULL,};
     int i = 0, dev_idx = 0;
 
-    /* FIXME: If you need to reset, set verb inactive */
-    /* const char *verb = NULL; */
-    /* verb = AUDIO_USE_CASE_VERB_INACTIVE; */
-
     AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
 
     AUDIO_LOG_INFO("do_route_reset++, direction(0x%x)", direction);
@@ -281,12 +238,6 @@ static audio_return_t _do_route_reset(audio_hal_t *ah, uint32_t direction)
         return AUDIO_RET_OK;
     }
 
-#ifdef USE_UCM
-    audio_ret = _audio_ucm_set_devices(ah, mode_to_verb_str[ah->device.mode], active_devices);
-    if (audio_ret)
-        AUDIO_LOG_ERROR("Failed to set device: error = %d", audio_ret);
-#endif
-
     return audio_ret;
 }
 
index ccb2965..c91f0f9 100644 (file)
@@ -120,16 +120,6 @@ typedef struct device_type {
     const char *name;
 } device_type_t;
 
-/* Verbs */
-#define AUDIO_USE_CASE_VERB_INACTIVE                "Inactive"
-#define AUDIO_USE_CASE_VERB_HIFI                    "HiFi"
-
-/* Modifiers */
-#define AUDIO_USE_CASE_MODIFIER_VOICESEARCH              "VoiceSearch"
-#define AUDIO_USE_CASE_MODIFIER_CAMCORDING               "Camcording"
-#define AUDIO_USE_CASE_MODIFIER_MEDIA                    "Media"
-#define AUDIO_USE_CASE_MODIFIER_DUAL_MEDIA               "DualMedia"
-
 #define streq !strcmp
 #define strneq strcmp
 
@@ -148,7 +138,6 @@ typedef struct device_type {
 #define CAPTURE_PCM_DEVICE_ID   0
 
 #define MAX_DEVICES             5
-#define MAX_MODIFIERS           5
 #define MAX_NAME_LEN           32
 
 /* type definitions */
@@ -190,10 +179,6 @@ typedef struct audio_device_info {
     };
 } audio_device_info_t;
 
-typedef enum audio_route_mode {
-    VERB_NORMAL,
-} audio_route_mode_t;
-
 typedef struct audio_hal_device {
     uint32_t active_in;
     uint32_t active_out;
@@ -201,7 +186,6 @@ typedef struct audio_hal_device {
     snd_pcm_t *pcm_out;
     pthread_mutex_t pcm_lock;
     uint32_t pcm_count;
-    audio_route_mode_t mode;
 } audio_hal_device_t;
 
 /* Stream */
@@ -251,10 +235,6 @@ typedef struct audio_hal_volume {
     audio_volume_value_table_t *volume_value_table;
 } audio_hal_volume_t;
 
-typedef struct audio_hal_ucm {
-    snd_use_case_mgr_t* uc_mgr;
-} audio_hal_ucm_t;
-
 typedef struct audio_hal_mixer {
     snd_mixer_t *mixer;
     pthread_mutex_t mutex;
@@ -288,7 +268,6 @@ typedef enum audio_sample_format {
 typedef struct audio_hal {
     audio_hal_device_t device;
     audio_hal_volume_t volume;
-    audio_hal_ucm_t ucm;
     audio_hal_mixer_t mixer;
 } audio_hal_t;
 
@@ -309,19 +288,6 @@ audio_return_t _audio_volume_deinit(audio_hal_t *ah);
 audio_return_t _audio_device_init(audio_hal_t *ah);
 audio_return_t _audio_device_deinit(audio_hal_t *ah);
 
-#ifdef USE_UCM
-audio_return_t _audio_ucm_init(audio_hal_t *ah);
-audio_return_t _audio_ucm_deinit(audio_hal_t *ah);
-void _audio_ucm_get_device_name(audio_hal_t *ah, const char *use_case, audio_direction_t direction, const char **value);
-#define _audio_ucm_update_use_case _audio_ucm_set_use_case
-audio_return_t _audio_ucm_set_use_case(audio_hal_t *ah, const char *verb, const char *devices[], const char *modifiers[]);
-audio_return_t _audio_ucm_set_devices(audio_hal_t *ah, const char *verb, const char *devices[]);
-audio_return_t _audio_ucm_set_modifiers(audio_hal_t *ah, const char *verb, const char *modifiers[]);
-int _audio_ucm_fill_device_info_list(audio_hal_t *ah, audio_device_info_t *device_info_list, const char *verb);
-audio_return_t _audio_ucm_get_verb(audio_hal_t *ah, const char **value);
-audio_return_t _audio_ucm_reset_use_case(audio_hal_t *ah);
-#endif
-
 audio_return_t _audio_util_init(audio_hal_t *ah);
 audio_return_t _audio_util_deinit(audio_hal_t *ah);
 audio_return_t _audio_mixer_control_set_param(audio_hal_t *ah, const char* ctl_name, snd_ctl_elem_value_t* value, int size);
diff --git a/tizen-audio-ucm.c b/tizen-audio-ucm.c
deleted file mode 100644 (file)
index 2bc1aa4..0000000
+++ /dev/null
@@ -1,719 +0,0 @@
-/*
- * audio-hal
- *
- * Copyright (c) 2000 - 2013 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifdef ALSA_UCM_DEBUG_TIME
-#include <sys/time.h>
-#include <time.h>
-#endif
-
-#include "tizen-audio-internal.h"
-
-#ifdef ALSA_UCM_DEBUG_TIME
-#define SND_USE_CASE_SET __set_use_case_with_time
-#else
-#define SND_USE_CASE_SET snd_use_case_set
-#endif
-
-#define UCM_PREFIX_CURRENT   ">>> UCM current"
-#define UCM_PREFIX_REQUESTED "> UCM requested"
-#define UCM_PREFIX_CHANGED   "<<< UCM changed"
-
-audio_return_t _audio_ucm_init(audio_hal_t *ah)
-{
-    AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
-
-    snd_use_case_mgr_open(&ah->ucm.uc_mgr, ALSA_DEFAULT_CARD);
-
-    if (!ah->ucm.uc_mgr) {
-        AUDIO_LOG_ERROR("uc_mgr open failed");
-        return AUDIO_ERR_RESOURCE;
-    }
-    return AUDIO_RET_OK;
-}
-
-audio_return_t _audio_ucm_deinit(audio_hal_t *ah)
-{
-    AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
-    AUDIO_RETURN_VAL_IF_FAIL(ah->ucm.uc_mgr, AUDIO_ERR_PARAMETER);
-
-    snd_use_case_mgr_close(ah->ucm.uc_mgr);
-    ah->ucm.uc_mgr = NULL;
-
-    return AUDIO_RET_OK;
-}
-
-void _audio_ucm_get_device_name(audio_hal_t *ah, const char *use_case, audio_direction_t direction, const char **value)
-{
-    char identifier[70] = { 0, };
-
-    AUDIO_RETURN_IF_FAIL(ah);
-    AUDIO_RETURN_IF_FAIL(ah->ucm.uc_mgr);
-
-    snprintf(identifier, sizeof(identifier), "%sPCM//%s",
-             (direction == AUDIO_DIRECTION_IN) ? "Capture" : "Playback", use_case);
-
-    snd_use_case_get(ah->ucm.uc_mgr, identifier, value);
-}
-
-static inline void __add_ucm_device_info(audio_hal_t *ah, const char *use_case, audio_direction_t direction, audio_device_info_t *device_info_list, int *device_info_count)
-{
-    audio_device_info_t *device_info;
-    const char *device_name = NULL;
-    char *needle = NULL;
-
-    AUDIO_RETURN_IF_FAIL(ah);
-    AUDIO_RETURN_IF_FAIL(ah->ucm.uc_mgr);
-    AUDIO_RETURN_IF_FAIL(device_info_list);
-    AUDIO_RETURN_IF_FAIL(device_info_count);
-
-    _audio_ucm_get_device_name(ah, use_case, direction, &device_name);
-    if (device_name) {
-        device_info = &device_info_list[(*device_info_count)++];
-
-        memset(device_info, 0x00, sizeof(audio_device_info_t));
-        device_info->api = AUDIO_DEVICE_API_ALSA;
-        device_info->direction = direction;
-        needle = strstr(&device_name[3], ",");
-        if (needle) {
-            device_info->alsa.device_idx = *(needle+1) - '0';
-            device_info->alsa.card_name = strndup(&device_name[3], needle - (device_name+3));
-            device_info->alsa.card_idx = snd_card_get_index(device_info->alsa.card_name);
-            AUDIO_LOG_DEBUG("Card name: %s", device_info->alsa.card_name);
-        }
-
-        free((void *)device_name);
-    }
-}
-
-int _audio_ucm_fill_device_info_list(audio_hal_t *ah, audio_device_info_t *device_info_list, const char *verb)
-{
-    int device_info_count = 0;
-    const char *curr_verb = NULL;
-
-    AUDIO_RETURN_VAL_IF_FAIL(ah, device_info_count);
-    AUDIO_RETURN_VAL_IF_FAIL(ah->ucm.uc_mgr, device_info_count);
-    AUDIO_RETURN_VAL_IF_FAIL(device_info_list, device_info_count);
-
-    if (!verb) {
-        snd_use_case_get(ah->ucm.uc_mgr, "_verb", &curr_verb);
-        verb = curr_verb;
-    }
-
-    if (verb) {
-        __add_ucm_device_info(ah, verb, AUDIO_DIRECTION_IN, device_info_list, &device_info_count);
-        __add_ucm_device_info(ah, verb, AUDIO_DIRECTION_OUT, device_info_list, &device_info_count);
-
-        if (curr_verb)
-            free((void *)curr_verb);
-    }
-
-    return device_info_count;
-}
-
-#define DUMP_LEN 512
-
-static void __dump_use_case(const char* prefix, const char *verb, const char *devices[], int dev_count, const char *modifiers[], int mod_count)
-{
-    int i;
-    dump_data_t* dump = NULL;
-
-    if (!(dump = dump_new(DUMP_LEN))) {
-        AUDIO_LOG_ERROR("Failed to create dump string...");
-        return;
-    }
-
-    /* Verb */
-    dump_add_str(dump, "Verb [ %s ] Devices [ ", verb ? verb : AUDIO_USE_CASE_VERB_INACTIVE);
-
-    /* Devices */
-    if (devices) {
-        for (i = 0; i < dev_count; i++) {
-            dump_add_str(dump, (i != dev_count - 1) ? "%s, " : "%s", devices[i]);
-        }
-    }
-    dump_add_str(dump, " ] Modifier [ ");
-
-    /* Modifiers */
-    if (modifiers) {
-        for (i = 0; i < mod_count; i++) {
-            dump_add_str(dump, (i != mod_count - 1) ? "%s, " : "%s", modifiers[i]);
-        }
-    }
-    dump_add_str(dump, " ]");
-
-    AUDIO_LOG_INFO("TEST %s : %s", prefix, dump_get_str(dump));
-
-    dump_free(dump);
-}
-
-#ifdef ALSA_UCM_DEBUG_TIME
-static inline int __set_use_case_with_time(snd_use_case_mgr_t *uc_mgr, const char *identifier, const char *value)
-{
-    int ret = 0;
-    struct timeval t_start, t_stop;
-    unsigned long long t_diff = 0;
-
-    gettimeofday(&t_start, NULL);
-    ret = snd_use_case_set(uc_mgr, identifier, value);
-    gettimeofday(&t_stop, NULL);
-    if (t_start.tv_sec < t_stop.tv_sec)
-        t_diff = (t_stop.tv_sec - t_start.tv_sec) * 1000000;
-    t_diff += (t_stop.tv_usec - t_start.tv_usec);
-    AUDIO_LOG_DEBUG("identifier %s value %s takes %lluusec", identifier, value, t_diff);
-
-    return ret;
-}
-#endif
-
-/* UCM sequence
-    1) If verb is null or verb is not changed
-    1-1) If device is changed
-         (If there is request for same device, it will be ignored)
-         -> Set "Inactive" verb, disable modifiers & devices, set current verb again, enable devices & modifiers
-            (playback/capture device will be enabled again if there is no request for playback/capture device)
-    1-2) If device is not changed
-     1-2-1) If modifier is changed
-            (If there is request for same modifier, it will be ignored)
-            -> Disable modifiers, enable modifiers
-   2) If verb is changed
-      -> Reset, set new verb, enable devices & modifiers
- */
-audio_return_t _audio_ucm_set_use_case(audio_hal_t *ah, const char *verb, const char *devices[], const char *modifiers[])
-{
-    audio_return_t audio_ret = AUDIO_RET_OK;
-    int is_verb_changed = 0, is_dev_changed = 0, is_mod_changed = 0;
-    const char *old_verb = NULL, **old_dev_list = NULL, **old_mod_list = NULL;
-    int old_dev_count = 0, dev_count = 0;
-    int old_mod_count = 0, mod_count = 0;
-    const char **dis_dev_list = NULL, **ena_dev_list = NULL;
-    const char **dis_mod_list = NULL, **ena_mod_list = NULL;
-    int dis_dev_count = 0, ena_dev_count = 0;
-    int dis_mod_count = 0, ena_mod_count = 0;
-    int i = 0, j = 0;
-
-    AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
-    AUDIO_RETURN_VAL_IF_FAIL(ah->ucm.uc_mgr, AUDIO_ERR_PARAMETER);
-    AUDIO_RETURN_VAL_IF_FAIL(verb, AUDIO_ERR_PARAMETER);
-
-    snd_use_case_get(ah->ucm.uc_mgr, "_verb", &old_verb);
-    old_dev_count = snd_use_case_get_list(ah->ucm.uc_mgr, "_enadevs", &old_dev_list);
-    old_mod_count = snd_use_case_get_list(ah->ucm.uc_mgr, "_enamods", &old_mod_list);
-    __dump_use_case(UCM_PREFIX_CURRENT, old_verb, old_dev_list, old_dev_count, old_mod_list, old_mod_count);
-
-    if (devices) {
-        for (dev_count = 0; devices[dev_count]; dev_count++);
-    }
-    if (modifiers) {
-        for (mod_count = 0; modifiers[mod_count]; mod_count++);
-    }
-
-    __dump_use_case(UCM_PREFIX_REQUESTED, verb, devices, dev_count, modifiers, mod_count);
-
-    if (old_verb && streq(verb, old_verb)) {
-        AUDIO_LOG_DEBUG("current verb and new verb is same. No need to change verb, disable devices explicitely");
-
-        if (old_dev_count > 0) {
-            dis_dev_list = (const char **)malloc(sizeof(const char *) * old_dev_count);
-            for (i = 0; i < old_dev_count; i++) {
-                dis_dev_list[i] = NULL;
-            }
-        }
-        if (dev_count > 0) {
-            ena_dev_list = (const char **)malloc(sizeof(const char *) * dev_count);
-            for (i = 0; i < dev_count; i++) {
-                ena_dev_list[i] = NULL;
-            }
-        }
-        if (old_mod_count > 0) {
-            dis_mod_list = (const char **)malloc(sizeof(const char *) * old_mod_count);
-            for (i = 0; i < old_mod_count; i++) {
-                dis_mod_list[i] = NULL;
-            }
-        }
-        if (mod_count > 0) {
-            ena_mod_list = (const char **)malloc(sizeof(const char *) * mod_count);
-            for (i = 0; i < mod_count; i++) {
-                ena_mod_list[i] = NULL;
-            }
-        }
-
-        /* update disable modifiers list which are not present in new modifier list */
-        for (i = 0; i < old_mod_count; i++) {
-            int need_disable_mod = 1;
-
-            for (j = 0; j < mod_count; j++) {
-                if (streq(old_mod_list[i], modifiers[j])) {
-                    need_disable_mod = 0;
-                    break;
-                }
-            }
-            if (need_disable_mod) {
-                if (is_mod_changed == 0)
-                    is_mod_changed = 1;
-                dis_mod_list[dis_mod_count++] = old_mod_list[i];
-            }
-        }
-
-        /* update disable devices list which are not present in new device list */
-        for (i = 0; i < old_dev_count; i++) {
-            int need_disable_dev = 1;
-
-            for (j = 0; j < dev_count; j++) {
-                if (streq(old_dev_list[i], devices[j])) {
-                    need_disable_dev = 0;
-                    break;
-                }
-            }
-            if (need_disable_dev) {
-                if (is_dev_changed == 0)
-                    is_dev_changed = 1;
-                dis_dev_list[dis_dev_count++] = old_dev_list[i];
-            }
-        }
-
-        /* update enable devices list which are not present in old device list */
-        for (i = 0; i < dev_count; i++) {
-            int need_enable_dev = 1;
-
-            for (j = 0; j < old_dev_count; j++) {
-                if (streq(devices[i], old_dev_list[j])) {
-                    need_enable_dev = 0;
-                    break;
-                }
-            }
-            if (need_enable_dev) {
-                if (is_dev_changed == 0)
-                    is_dev_changed = 1;
-                ena_dev_list[ena_dev_count++] = devices[i];
-            }
-        }
-
-        /* update enable modifiers list which are not present in old modifier list */
-        for (i = 0; i < mod_count; i++) {
-            int need_enable_mod = 1;
-
-            for (j = 0; j < old_mod_count; j++) {
-                if (streq(modifiers[i], old_mod_list[j])) {
-                    need_enable_mod = 0;
-                    break;
-                }
-            }
-            if (need_enable_mod) {
-                if (is_mod_changed == 0)
-                    is_mod_changed = 1;
-                ena_mod_list[ena_mod_count++] = modifiers[i];
-            }
-        }
-
-        /* disable modifiers */
-        for (i = 0; i < dis_mod_count; i++) {
-            AUDIO_LOG_INFO("Disable modifier : %s", dis_mod_list[i]);
-            if (snd_use_case_set(ah->ucm.uc_mgr, "_dismod", dis_mod_list[i]) < 0)
-                AUDIO_LOG_ERROR("disable %s modifier failed", dis_mod_list[i]);
-        }
-
-        /* disable devices */
-        for (i = 0; i < dis_dev_count; i++) {
-            AUDIO_LOG_INFO("Disable device : %s", dis_dev_list[i]);
-            if (snd_use_case_set(ah->ucm.uc_mgr, "_disdev", dis_dev_list[i]) < 0)
-                AUDIO_LOG_ERROR("disable %s device failed", dis_dev_list[i]);
-        }
-
-        /* enable devices */
-        for (i = 0; i < ena_dev_count; i++) {
-            AUDIO_LOG_INFO("Enable device : %s", ena_dev_list[i]);
-            if (snd_use_case_set(ah->ucm.uc_mgr, "_enadev", ena_dev_list[i]) < 0)
-                AUDIO_LOG_ERROR("enable %s device failed", ena_dev_list[i]);
-        }
-
-        /* enable modifiers */
-        for (i = 0; i < ena_mod_count; i++) {
-            AUDIO_LOG_INFO("Enable modifier : %s", ena_mod_list[i]);
-            if (snd_use_case_set(ah->ucm.uc_mgr, "_enamod", ena_mod_list[i]) < 0)
-                AUDIO_LOG_ERROR("enable %s modifier failed", ena_mod_list[i]);
-        }
-    } else {
-        is_verb_changed = 1;
-
-        AUDIO_LOG_DEBUG("Setting new verb: %s", verb);
-        /* set new verb */
-        if (snd_use_case_set(ah->ucm.uc_mgr, "_verb", verb) < 0) {
-            AUDIO_LOG_ERROR("Setting verb %s failed", verb);
-            audio_ret = AUDIO_ERR_UNDEFINED;
-            goto exit;
-        }
-        /* enable devices */
-        for (i = 0; i < dev_count; i++) {
-            AUDIO_LOG_DEBUG("Enable device : %s", devices[i]);
-            if (snd_use_case_set(ah->ucm.uc_mgr, "_enadev", devices[i]) < 0)
-                AUDIO_LOG_ERROR("Enable %s device failed", devices[i]);
-        }
-        /* enable modifiers */
-        for (i = 0; i < mod_count; i++) {
-            AUDIO_LOG_DEBUG("Enable modifier : %s", modifiers[i]);
-            if (snd_use_case_set(ah->ucm.uc_mgr, "_enamod", modifiers[i]) < 0)
-                AUDIO_LOG_ERROR("Enable %s modifier failed", modifiers[i]);
-        }
-    }
-
-exit:
-    if (old_verb)
-        free((void *)old_verb);
-    if (old_dev_list)
-        snd_use_case_free_list(old_dev_list, old_dev_count);
-    if (old_mod_list)
-        snd_use_case_free_list(old_mod_list, old_mod_count);
-    if (dis_dev_list)
-        free((void *)dis_dev_list);
-    if (ena_dev_list)
-        free((void *)ena_dev_list);
-    if (dis_mod_list)
-        free((void *)dis_mod_list);
-    if (ena_mod_list)
-        free((void *)ena_mod_list);
-
-    if (is_verb_changed == 1 || is_dev_changed == 1 || is_mod_changed == 1) {
-        const char *new_verb = NULL, **new_dev_list = NULL, **new_mod_list = NULL;
-        int new_dev_count = 0, new_mod_count = 0;
-
-        snd_use_case_get(ah->ucm.uc_mgr, "_verb", &new_verb);
-        new_dev_count = snd_use_case_get_list(ah->ucm.uc_mgr, "_enadevs", &new_dev_list);
-        new_mod_count = snd_use_case_get_list(ah->ucm.uc_mgr, "_enamods", &new_mod_list);
-        __dump_use_case(UCM_PREFIX_CHANGED, new_verb, new_dev_list, new_dev_count, new_mod_list, new_mod_count);
-
-        if (new_verb)
-            free((void *)new_verb);
-        if (new_dev_list)
-            snd_use_case_free_list(new_dev_list, new_dev_count);
-        if (new_mod_list)
-            snd_use_case_free_list(new_mod_list, new_mod_count);
-    }
-
-    return audio_ret;
-}
-
-audio_return_t _audio_ucm_set_devices(audio_hal_t *ah, const char *verb, const char *devices[])
-{
-    audio_return_t audio_ret = AUDIO_RET_OK;
-    int is_verb_changed = 0, is_dev_changed = 0;
-    const char *old_verb = NULL, **old_dev_list = NULL;
-    int old_dev_count = 0, dev_count = 0;
-    const char **dis_dev_list = NULL, **ena_dev_list = NULL;
-    int dis_dev_count = 0, ena_dev_count = 0;
-    int i = 0, j = 0;
-
-    AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
-    AUDIO_RETURN_VAL_IF_FAIL(ah->ucm.uc_mgr, AUDIO_ERR_PARAMETER);
-    AUDIO_RETURN_VAL_IF_FAIL(verb, AUDIO_ERR_PARAMETER);
-    AUDIO_RETURN_VAL_IF_FAIL(devices, AUDIO_ERR_PARAMETER);
-
-    snd_use_case_get(ah->ucm.uc_mgr, "_verb", &old_verb);
-    old_dev_count = snd_use_case_get_list(ah->ucm.uc_mgr, "_enadevs", &old_dev_list);
-    __dump_use_case(UCM_PREFIX_CURRENT, old_verb, old_dev_list, old_dev_count, NULL, 0);
-
-    if (devices) {
-        for (dev_count = 0; devices[dev_count]; dev_count++);
-    }
-
-    __dump_use_case(UCM_PREFIX_REQUESTED, verb, devices, dev_count, NULL, 0);
-
-    if (old_verb && streq(verb, old_verb)) {
-        AUDIO_LOG_DEBUG("current verb and new verb is same. No need to change verb, disable devices explicitely");
-
-        if (old_dev_count > 0) {
-            dis_dev_list = (const char **)malloc(sizeof(const char *) * old_dev_count);
-            for (i = 0; i < old_dev_count; i++) {
-                dis_dev_list[i] = NULL;
-            }
-        }
-        if (dev_count > 0) {
-            ena_dev_list = (const char **)malloc(sizeof(const char *) * dev_count);
-            for (i = 0; i < dev_count; i++) {
-                ena_dev_list[i] = NULL;
-            }
-        }
-
-        /* update disable devices list which are not present in new device list */
-        for (i = 0; i < old_dev_count; i++) {
-            int need_disable_dev = 1;
-
-            for (j = 0; j < dev_count; j++) {
-                if (streq(old_dev_list[i], devices[j])) {
-                    need_disable_dev = 0;
-                    break;
-                }
-            }
-            if (need_disable_dev) {
-                if (is_dev_changed == 0)
-                    is_dev_changed = 1;
-                dis_dev_list[dis_dev_count++] = old_dev_list[i];
-            }
-        }
-
-        /* update enable devices list which are not present in old device list */
-        for (i = 0; i < dev_count; i++) {
-            int need_enable_dev = 1;
-
-            for (j = 0; j < old_dev_count; j++) {
-                if (streq(devices[i], old_dev_list[j])) {
-                    need_enable_dev = 0;
-                    break;
-                }
-            }
-            if (need_enable_dev) {
-                if (is_dev_changed == 0)
-                    is_dev_changed = 1;
-                ena_dev_list[ena_dev_count++] = devices[i];
-            }
-        }
-
-        /* disable devices */
-        for (i = 0; i < dis_dev_count; i++) {
-            AUDIO_LOG_INFO("Disable device : %s", dis_dev_list[i]);
-            if (snd_use_case_set(ah->ucm.uc_mgr, "_disdev", dis_dev_list[i]) < 0)
-                AUDIO_LOG_ERROR("disable %s device failed", dis_dev_list[i]);
-        }
-
-        /* enable devices */
-        for (i = 0; i < ena_dev_count; i++) {
-            AUDIO_LOG_INFO("Enable device : %s", ena_dev_list[i]);
-            if (snd_use_case_set(ah->ucm.uc_mgr, "_enadev", ena_dev_list[i]) < 0)
-                AUDIO_LOG_ERROR("enable %s device failed", ena_dev_list[i]);
-        }
-
-    } else {
-        is_verb_changed = 1;
-
-        AUDIO_LOG_DEBUG("Setting new verb: %s", verb);
-        /* set new verb */
-        if (snd_use_case_set(ah->ucm.uc_mgr, "_verb", verb) < 0) {
-            AUDIO_LOG_ERROR("Setting verb %s failed", verb);
-            audio_ret = AUDIO_ERR_UNDEFINED;
-            goto exit;
-        }
-        /* enable devices */
-        for (i = 0; i < dev_count; i++) {
-            AUDIO_LOG_DEBUG("Enable device : %s", devices[i]);
-            if (snd_use_case_set(ah->ucm.uc_mgr, "_enadev", devices[i]) < 0)
-                AUDIO_LOG_ERROR("Enable %s device failed", devices[i]);
-        }
-    }
-
-exit:
-    if (old_verb)
-        free((void *)old_verb);
-    if (old_dev_list)
-        snd_use_case_free_list(old_dev_list, old_dev_count);
-    if (dis_dev_list)
-        free((void *)dis_dev_list);
-    if (ena_dev_list)
-        free((void *)ena_dev_list);
-
-    if (is_verb_changed == 1 || is_dev_changed == 1) {
-        const char *new_verb = NULL, **new_dev_list = NULL;
-        int new_dev_count = 0;
-
-        snd_use_case_get(ah->ucm.uc_mgr, "_verb", &new_verb);
-        new_dev_count = snd_use_case_get_list(ah->ucm.uc_mgr, "_enadevs", &new_dev_list);
-        __dump_use_case(UCM_PREFIX_CHANGED, new_verb, new_dev_list, new_dev_count, NULL, 0);
-
-        if (new_verb)
-            free((void *)new_verb);
-        if (new_dev_list)
-            snd_use_case_free_list(new_dev_list, new_dev_count);
-    }
-
-    return audio_ret;
-
-}
-
-audio_return_t _audio_ucm_set_modifiers(audio_hal_t *ah, const char *verb, const char *modifiers[])
-{
-    audio_return_t audio_ret = AUDIO_RET_OK;
-    int is_verb_changed = 0, is_mod_changed = 0;
-    const char *old_verb = NULL, **old_mod_list = NULL;
-    int old_mod_count = 0, mod_count = 0;
-    const char **dis_mod_list = NULL, **ena_mod_list = NULL;
-    int dis_mod_count = 0, ena_mod_count = 0;
-    int i = 0, j = 0;
-
-    AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
-    AUDIO_RETURN_VAL_IF_FAIL(ah->ucm.uc_mgr, AUDIO_ERR_PARAMETER);
-    AUDIO_RETURN_VAL_IF_FAIL(verb, AUDIO_ERR_PARAMETER);
-    AUDIO_RETURN_VAL_IF_FAIL(modifiers, AUDIO_ERR_PARAMETER);
-
-    snd_use_case_get(ah->ucm.uc_mgr, "_verb", &old_verb);
-    old_mod_count = snd_use_case_get_list(ah->ucm.uc_mgr, "_enamods", &old_mod_list);
-    __dump_use_case(UCM_PREFIX_CURRENT, old_verb, NULL, 0, old_mod_list, old_mod_count);
-
-    if (modifiers) {
-        for (mod_count = 0; modifiers[mod_count]; mod_count++);
-    }
-
-    __dump_use_case(UCM_PREFIX_REQUESTED, verb, NULL, 0, modifiers, mod_count);
-
-    if (old_verb && streq(verb, old_verb)) {
-        AUDIO_LOG_DEBUG("current verb and new verb is same. No need to change verb, disable devices explicitely");
-
-        if (old_mod_count > 0) {
-            dis_mod_list = (const char **)malloc(sizeof(const char *) * old_mod_count);
-            for (i = 0; i < old_mod_count; i++) {
-                dis_mod_list[i] = NULL;
-            }
-        }
-        if (mod_count > 0) {
-            ena_mod_list = (const char **)malloc(sizeof(const char *) * mod_count);
-            for (i = 0; i < mod_count; i++) {
-                ena_mod_list[i] = NULL;
-            }
-        }
-
-        /* update disable modifiers list which are not present in new modifier list */
-        for (i = 0; i < old_mod_count; i++) {
-            int need_disable_mod = 1;
-
-            for (j = 0; j < mod_count; j++) {
-                if (streq(old_mod_list[i], modifiers[j])) {
-                    need_disable_mod = 0;
-                    break;
-                }
-            }
-            if (need_disable_mod) {
-                if (is_mod_changed == 0)
-                    is_mod_changed = 1;
-                dis_mod_list[dis_mod_count++] = old_mod_list[i];
-            }
-        }
-
-        /* update enable modifiers list which are not present in old modifier list */
-        for (i = 0; i < mod_count; i++) {
-            int need_enable_mod = 1;
-
-            for (j = 0; j < old_mod_count; j++) {
-                if (streq(modifiers[i], old_mod_list[j])) {
-                    need_enable_mod = 0;
-                    break;
-                }
-            }
-            if (need_enable_mod) {
-                if (is_mod_changed == 0)
-                    is_mod_changed = 1;
-                ena_mod_list[ena_mod_count++] = modifiers[i];
-            }
-        }
-
-        /* disable modifiers */
-        for (i = 0; i < dis_mod_count; i++) {
-            AUDIO_LOG_INFO("Disable modifier : %s", dis_mod_list[i]);
-            if (snd_use_case_set(ah->ucm.uc_mgr, "_dismod", dis_mod_list[i]) < 0)
-                AUDIO_LOG_ERROR("disable %s modifier failed", dis_mod_list[i]);
-        }
-
-        /* enable modifiers */
-        for (i = 0; i < ena_mod_count; i++) {
-            AUDIO_LOG_INFO("Enable modifier : %s", ena_mod_list[i]);
-            if (snd_use_case_set(ah->ucm.uc_mgr, "_enamod", ena_mod_list[i]) < 0)
-                AUDIO_LOG_ERROR("enable %s modifier failed", ena_mod_list[i]);
-        }
-    } else {
-        is_verb_changed = 1;
-
-        AUDIO_LOG_DEBUG("Setting new verb: %s", verb);
-        /* set new verb */
-        if (snd_use_case_set(ah->ucm.uc_mgr, "_verb", verb) < 0) {
-            AUDIO_LOG_ERROR("Setting verb %s failed", verb);
-            audio_ret = AUDIO_ERR_UNDEFINED;
-            goto exit;
-        }
-        /* enable modifiers */
-        for (i = 0; i < mod_count; i++) {
-            AUDIO_LOG_DEBUG("Enable modifier : %s", modifiers[i]);
-            if (snd_use_case_set(ah->ucm.uc_mgr, "_enamod", modifiers[i]) < 0)
-                AUDIO_LOG_ERROR("Enable %s modifier failed", modifiers[i]);
-        }
-    }
-
-exit:
-    if (old_verb)
-        free((void *)old_verb);
-    if (old_mod_list)
-        snd_use_case_free_list(old_mod_list, old_mod_count);
-    if (dis_mod_list)
-        free((void *)dis_mod_list);
-    if (ena_mod_list)
-        free((void *)ena_mod_list);
-
-    if (is_verb_changed == 1 || is_mod_changed == 1) {
-        const char *new_verb = NULL, **new_mod_list = NULL;
-        int new_mod_count = 0;
-
-        snd_use_case_get(ah->ucm.uc_mgr, "_verb", &new_verb);
-        new_mod_count = snd_use_case_get_list(ah->ucm.uc_mgr, "_enamods", &new_mod_list);
-        __dump_use_case(UCM_PREFIX_CHANGED, new_verb, NULL, 0, new_mod_list, new_mod_count);
-
-        if (new_verb)
-            free((void *)new_verb);
-        if (new_mod_list)
-            snd_use_case_free_list(new_mod_list, new_mod_count);
-    }
-
-    return audio_ret;
-}
-
-audio_return_t _audio_ucm_get_verb(audio_hal_t *ah, const char **value)
-{
-    audio_return_t ret = AUDIO_RET_OK;
-
-    AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
-    AUDIO_RETURN_VAL_IF_FAIL(ah->ucm.uc_mgr, AUDIO_ERR_PARAMETER);
-    AUDIO_RETURN_VAL_IF_FAIL(value, AUDIO_ERR_PARAMETER);
-
-    if ((ret = snd_use_case_get(ah->ucm.uc_mgr, "_verb", value)) < 0) {
-        AUDIO_LOG_ERROR("Getting current verb failed: Reason %d", ret);
-        ret = AUDIO_ERR_UNDEFINED;
-    }
-
-    return ret;
-}
-
-
-audio_return_t _audio_ucm_reset_use_case(audio_hal_t *ah)
-{
-    audio_return_t ret = AUDIO_RET_OK;
-
-    AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
-    AUDIO_RETURN_VAL_IF_FAIL(ah->ucm.uc_mgr, AUDIO_ERR_PARAMETER);
-
-    AUDIO_LOG_INFO(">>> UCM reset Verb [ %s ]", AUDIO_USE_CASE_VERB_INACTIVE);
-
-    if ((ret = snd_use_case_set(ah->ucm.uc_mgr, "_verb", AUDIO_USE_CASE_VERB_INACTIVE)) < 0) {
-        AUDIO_LOG_ERROR("Reset use case failed: Reason %d", ret);
-        ret = AUDIO_ERR_UNDEFINED;
-    }
-
-    return ret;
-}
-
index 2c91e81..20f865c 100644 (file)
@@ -67,12 +67,6 @@ audio_return_t audio_init(void **audio_handle)
         AUDIO_LOG_ERROR("stream init failed");
         goto error_exit;
     }
-#ifdef USE_UCM
-    if (AUDIO_IS_ERROR((ret = _audio_ucm_init(ah)))) {
-        AUDIO_LOG_ERROR("ucm init failed");
-        goto error_exit;
-    }
-#endif
     if (AUDIO_IS_ERROR((ret = _audio_util_init(ah)))) {
         AUDIO_LOG_ERROR("util init failed");
         goto error_exit;
@@ -101,9 +95,6 @@ audio_return_t audio_deinit(void *audio_handle)
 
     _audio_device_deinit(ah);
     _audio_volume_deinit(ah);
-#ifdef USE_UCM
-    _audio_ucm_deinit(ah);
-#endif
     _audio_util_deinit(ah);
     free(ah);
     ah = NULL;