Fix Coverity defects
[platform/core/multimedia/libmm-sound.git] / include / mm_sound_device.h
1 /*
2  * libmm-sound
3  *
4  * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Sangchul Lee <sc11.lee@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 /**
23  * @file                mm_sound_device.h
24  * @brief               Application interface library for sound module.
25  * @date
26  *
27  * Application interface library for sound module.
28  */
29
30 #ifndef __MM_SOUND_DEVICE_H__
31 #define __MM_SOUND_DEVICE_H__
32
33 #include <glib.h>
34 #include <stdbool.h>
35
36 #ifdef __cplusplus
37         extern "C" {
38
39 #endif
40 #define MAX_DEVICE_NAME_NUM 256
41 #define MAX_DEVICE_TYPE_STR_LEN 30
42 #define MAX_STREAM_ON_DEVICE 32
43 typedef struct {
44         char type[MAX_DEVICE_TYPE_STR_LEN];
45         int io_direction;
46         int id;
47         char name[MAX_DEVICE_NAME_NUM];
48         int state;
49
50         /* This is filled only when device handle is passed through callback */
51         int stream_id[MAX_STREAM_ON_DEVICE];
52         /* When this value is less than 0, should query to server-side */
53         int stream_num;
54
55         /* For USB device from udev, if not -1 */
56         int vendor_id;
57         int product_id;
58 } mm_sound_device_t;
59
60 typedef struct {
61         GList *list;
62         bool is_new_device_list;
63 } mm_sound_device_list_t;
64
65 typedef enum {
66         DEVICE_IO_DIRECTION_IN = 0x1,
67         DEVICE_IO_DIRECTION_OUT = 0x2,
68         DEVICE_IO_DIRECTION_BOTH = DEVICE_IO_DIRECTION_IN | DEVICE_IO_DIRECTION_OUT,
69 } device_io_direction_e;
70
71 typedef enum {
72         DEVICE_STATE_DEACTIVATED,
73         DEVICE_STATE_ACTIVATED,
74 } device_state_e;
75
76 typedef enum {
77         DEVICE_CHANGED_INFO_STATE,
78         DEVICE_CHANGED_INFO_IO_DIRECTION,
79 } device_changed_info_e;
80
81 typedef enum
82 {
83         DEVICE_UPDATE_STATUS_DISCONNECTED = 0,
84         DEVICE_UPDATE_STATUS_CONNECTED,
85         DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE,
86         DEVICE_UPDATE_STATUS_CHANGED_INFO_IO_DIRECTION,
87 } device_update_status_e;
88
89 typedef enum
90 {
91         DEVICE_TYPE_BUILTIN_SPEAKER,   /**< Built-in speaker. */
92         DEVICE_TYPE_BUILTIN_RECEIVER,  /**< Built-in receiver. */
93         DEVICE_TYPE_BUILTIN_MIC,       /**< Built-in mic. */
94         DEVICE_TYPE_AUDIOJACK,         /**< Audio jack such as headphone, headset, and so on. */
95         DEVICE_TYPE_BLUETOOTH,         /**< Bluetooth */
96         DEVICE_TYPE_HDMI,              /**< HDMI. */
97         DEVICE_TYPE_MIRRORING,         /**< MIRRORING. */
98         DEVICE_TYPE_USB_AUDIO,         /**< USB Audio. */
99 } device_type_e;
100
101 typedef enum {
102         DEVICE_IO_DIRECTION_IN_FLAG      = 0x0001,  /**< Flag for input devices */
103         DEVICE_IO_DIRECTION_OUT_FLAG     = 0x0002,  /**< Flag for output devices */
104         DEVICE_IO_DIRECTION_BOTH_FLAG    = 0x0004,  /**< Flag for input/output devices (both directions are available) */
105         DEVICE_TYPE_INTERNAL_FLAG        = 0x0010,  /**< Flag for built-in devices */
106         DEVICE_TYPE_EXTERNAL_FLAG        = 0x0020,  /**< Flag for external devices */
107         DEVICE_STATE_DEACTIVATED_FLAG    = 0x1000,  /**< Flag for deactivated devices */
108         DEVICE_STATE_ACTIVATED_FLAG      = 0x2000,  /**< Flag for activated devices */
109         DEVICE_ALL_FLAG                  = 0xFFFF,  /**< Flag for all devices */
110 } device_flag_e;
111
112 typedef enum {
113         DEVICE_IO_DIRECTION_FLAGS      = 0x000F,  /**< Flag for io direction */
114         DEVICE_TYPE_FLAGS              = 0x00F0,  /**< Flag for device type */
115         DEVICE_STATE_FLAGS             = 0xF000,  /**< Flag for device state */
116 } device_flags_type_e;
117
118 #define IS_INTERNAL_DEVICE(x_device_type) (((DEVICE_TYPE_BUILTIN_SPEAKER <= x_device_type) && (x_device_type <= DEVICE_TYPE_BUILTIN_MIC)) ? true : false)
119
120 #ifdef __cplusplus
121 }
122 #endif
123
124 #endif  /* __MM_SOUND_DEVICE_H__ */
125