41db071ada88ed209cefe28b99cf245bef8e3f17
[platform/core/multimedia/avsystem.git] / include / avsys-audio-handle.h
1 /*
2  * avsystem
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jonghyuk Choi <jhchoi.choi@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 #ifndef __AVSYS_AUDIO_HANDLE_H__
23 #define __AVSYS_AUDIO_HANDLE_H__
24
25 #include <pthread.h>
26 #include "avsys-audio-logical-volume.h"
27
28 #define AVSYS_AUDIO_HANDLE_MAX 64 /* this is related with allocated bit size in avsys_audio_handle_info_t*/
29 #define AVSYS_AUDIO_LOCK_SLOT_MAX 4
30
31 enum {
32         AVSYS_AUDIO_PRIMARY_VOLUME_CLEAR = 0,
33         AVSYS_AUDIO_PRIMARY_VOLUME_SET
34 };
35
36 enum {
37         AVSYS_AUDIO_HANDLE_PRIORITY_TYPE_0 = 0, /**< normal */
38         AVSYS_AUDIO_HANDLE_PRIORITY_TYPE_1,             /**< solo */
39         AVSYS_AUDIO_HANDLE_PRIORITY_TYPE_2,             /**< solo with transition effect */
40         AVSYS_AUDIO_HANDLE_PRIORITY_TYPE_MAX,
41 };
42
43 enum {
44         AVSYS_AUDIO_HANDLE_EXT_DEV_NONE         = 0x00000000,
45         AVSYS_AUDIO_HANDLE_EXT_DEV_FMRADIO      = 0x00000001,
46 };
47
48 typedef struct {
49         /* common base */
50         int mode;
51         int channels;
52         int mute;
53         int format;
54         int samplerate;
55         int period;
56         int msec_per_period;
57         int pid;
58         int tid;
59         int priority;
60
61         /* logical volume */
62         avsys_audio_volume_setting_t gain_setting;
63         avsys_audio_volume_t setting_vol;
64         avsys_audio_volume_t working_vol;
65         int fadeup_vol;
66         int fadeup_multiplier;
67         char dirty_volume;
68
69         /* routing information */
70         char during_cp_audio;/* if this value set 1, this handle created during cp audio status (means call) */
71         char path_off;
72         int     stream_index;
73         int handle_route;
74
75         /* backend specific */
76         void    *device;
77 } avsys_audio_handle_t;
78
79 typedef struct {
80         long long int allocated;
81         int handle_amp; /* 1 for unmute, 0 for mute per each handle*/
82         int ext_device_amp;
83         int ext_device_status;
84         int volume_value[AVSYS_AUDIO_VOLUME_TYPE_MAX];
85         int primary_volume_type;
86         pid_t primary_volume_pid;
87         char handle_priority[AVSYS_AUDIO_HANDLE_MAX];
88         pid_t handlelock_pid[AVSYS_AUDIO_LOCK_SLOT_MAX];
89         avsys_audio_handle_t handles[AVSYS_AUDIO_HANDLE_MAX];
90 } avsys_audio_handle_info_t;
91
92 enum {
93         HANDLE_PTR_MODE_NORMAL,
94         HANDLE_PTR_MODE_FAST,
95         HANDLE_PTR_MODE_NUM,
96 };
97
98 int avsys_audio_handle_init(void);
99 int avsys_audio_handle_fini(void);
100 int avsys_audio_handle_reset(int *volume_value);
101 int avsys_audio_handle_dump(void);
102 int avsys_audio_handle_rejuvenation(void);
103 int avsys_audio_handle_alloc(int *handle);
104 int avsys_audio_handle_free(int handle);
105 int avsys_audio_handle_get_ptr(int handle, avsys_audio_handle_t **ptr, const int mode);
106 int avsys_audio_handle_release_ptr(int handle, const int mode);
107 int avsys_audio_handle_set_mute(int handle, int mute);
108 int avsys_audio_handle_ext_dev_set_mute(avsysaudio_ext_device_t device_type, int mute);
109 int avsys_audio_handle_ext_dev_status(avsysaudio_ext_device_t device_type, int *onoff);
110 int avsys_audio_handle_ext_dev_status_update(avsysaudio_ext_device_t device_type, int onoff);
111 int avsys_audio_handle_current_playing_volume_type(int *type);
112 int avsys_audio_handle_update_volume(avsys_audio_handle_t *p, const int volume_config);
113 int avsys_audio_handle_update_volume_by_type(const int volume_type, const int volume_value);
114 int avsys_audio_handle_set_primary_volume_type(const int pid, const int type, const int command);
115 int avsys_audio_handle_update_priority(int handle, int priority, int handle_route, int cmd);
116 int avsys_audio_handle_current_capture_status(int *on_capture);
117 #endif /* __AVSYS_AUDIO_HANDLE_H__ */