Rebase code with tizen 2.3 with following additional changes
[platform/core/multimedia/libmm-sound.git] / include / mm_sound_private.h
1 /*
2  * libmm-sound
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Seungbae Shin <seungbae.shin@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.h
24  * @brief               Application interface library for sound module.
25  * @date
26  * @version             Release
27  *
28  * Application interface library for sound module.
29  */
30
31 #ifndef __MM_SOUND_PRIVATE_H__
32 #define __MM_SOUND_PRIVATE_H__
33
34 #include <mm_types.h>
35 #include <mm_error.h>
36 #include <mm_sound.h>
37
38 #ifdef __cplusplus
39         extern "C" {
40 #endif
41
42 /**
43         @internal
44         @addtogroup SOUND_PRIVATE
45         @{
46
47  */
48
49 #define MM_SOUND_VOLUME_CONFIG_TYPE(vol) (vol & 0x00FF)
50 #define MM_SOUND_VOLUME_CONFIG_GAIN(vol) (vol & 0xFF00)
51
52 enum MMSoundGainType {
53         MM_SOUND_GAIN_KEYTONE = 0,      /**< hw gain configuration for keytone play */
54         MM_SOUND_GAIN_RINGTONE,         /**< hw gain configuration for ringtone play */
55         MM_SOUND_GAIN_ALARMTONE,        /**< hw gain configuration for alarmtone play */
56         MM_SOUND_GAIN_CALLTONE,         /**< hw gain configuration for calltone play */
57         MM_SOUND_GAIN_AUDIOPLAYER,      /**< hw gain configuration for music play */
58         MM_SOUND_GAIN_VIDEOPLAYER,      /**< hw gain configuration for video play */
59         MM_SOUND_GAIN_VOICECALL,        /**< hw gain configuration for voice call */
60         MM_SOUND_GAIN_VIDEOCALL,        /**< hw gain configuration for video call */
61         MM_SOUND_GAIN_FMRADIO,          /**< hw gain configuration for fm radio play */
62         MM_SOUND_GAIN_VOICEREC,         /**< hw gain configuration for voice recording */
63         MM_SOUND_GAIN_CAMCORDER,        /**< hw gain configuration for camcording */
64         MM_SOUND_GAIN_CAMERA,           /**< hw gain configuration for camera shutter sound */
65         MM_SOUND_GAIN_GAME,                     /**< hw gain configuration for game play */
66         MM_SOUND_GAIN_CNT,                      /**< hw gain configuration count */
67         MM_SOUND_GAIN_MUSIC = MM_SOUND_GAIN_AUDIOPLAYER,        /**< remained for legacy application */
68         MM_SOUND_GAIN_VIDEO,                                                    /**< remained for legacy application */
69         MM_SOUND_GAIN_NONE = MM_SOUND_GAIN_KEYTONE,             /**< remained for legacy application */
70 };
71
72 /**
73  * Enumerations for sound path
74  */
75 enum MMSoundPathExType {
76         MM_SOUND_PATH_NONE = 0,         /**< no route path */
77         MM_SOUND_PATH_SPK,                      /**< sound route to speaker */
78         MM_SOUND_PATH_RECV,                     /**< sound route to receiver */
79         MM_SOUND_PATH_HEADSET,          /**< sound route to headset */
80         MM_SOUND_PATH_BTHEADSET,                /**< sound route to bluetooth headset */
81         MM_SOUND_PATH_A2DP,                     /**< not used */
82         MM_SOUND_PATH_HANDSFREE,                /**< not used */
83         MM_SOUND_PATH_HDMI,                     /**< not used */
84         MM_SOUND_PATH_OUTMAX,           /**< output route count */
85         MM_SOUND_PATH_MIC = 1,          /**< sound route from microphone */
86         MM_SOUND_PATH_HEADSETMIC,       /**< sound route from headset microphone */
87         MM_SOUND_PATH_BTMIC,                    /**< sound route from bluetooth microphone */
88         MM_SOUND_PATH_FMINPUT,          /**< sound route from FM radio module */
89         MM_SOUND_PATH_HANDSFREEMIC,     /**< not used */
90         MM_SOUND_PATH_INMAX,                    /**< input route count */
91 };
92
93 /**
94  * Enumerations for sound path option
95  */
96 enum MMSoundPathOptionType {
97         MM_SOUND_PATH_OPTION_NONE                                       = 0x00000000,   /**< no sound path option */
98         MM_SOUND_PATH_OPTION_AUTO_HEADSET_CONTROL       = 0x00000001,   /**< automatic sound path change by earphone event */
99         MM_SOUND_PATH_OPTION_SPEAKER_WITH_HEADSET       = 0x00000002,   /**< play sound via speaker and earphone (if inserted) */
100         MM_SOUND_PATH_OPTION_VOICECALL_REC                      = 0x00000010,   /**< voice call recording option */
101         MM_SOUND_PATH_OPTION_USE_SUB_MIC                                = 0x00000020,   /**< use sub-mic on call and recording */
102 };
103
104
105 enum mm_sound_handle_route_t {
106         MM_SOUND_HANDLE_ROUTE_USING_CURRENT,
107         MM_SOUND_HANDLE_ROUTE_SPEAKER,
108         MM_SOUND_HANDLE_ROUTE_SPEAKER_NO_RESTORE
109 };
110
111 typedef struct {
112         const char                      *filename;              /**< filename to play */
113         bool                            skip_session;   /**< skip session control */
114         int                                     volume;                 /**< relative volume level */
115         int                                     loop;                   /**< loop count */
116         mm_sound_stop_callback_func     callback;               /**< callback function when playing is terminated */
117         void                            *data;                  /**< user data to callback */
118         void                            *mem_ptr;               /**< memory buffer to play */
119         int                                     mem_size;               /**< size of memory buffer */
120         int                                     handle_route;   /**< 1 for speaker, 0 for current */
121         int                                     volume_config;  /**< volume type & volume gain */
122         int                                     priority;               /**< 0 or 1 */
123 } MMSoundPlayParam;
124
125
126 /**
127  * This function is to play system sound with specified parameters.
128  *
129  * @param       param           [in] Reference pointer to MMSoundPlayParam structure
130  * @param       handle  [out] Handle of sound play.
131  *
132  * @return      This function returns MM_ERROR_NONE on success, or negative value
133  *                      with error code.
134  * @remark      When the stop callback is set, it will be called when system sound is
135  *                      terminated. If mm_sound_stop_sound() is called apparently before
136  *                      system sound is terminated, stop_callback will not be called.
137  *                      This function can use various sound route path with mm_sound_set_path
138  * @see         mm_sound_stop_sound mm_sound_set_path
139  * @since               R1, 1.0
140  * @limo
141  */
142 int mm_sound_play_sound_ex(MMSoundPlayParam *param, int *handle);
143
144
145 /**
146  * This function is to play key sound.
147  *
148  * @param       filename                [in] keytone filename to play
149  * @param       volume_config   [in] Volume type & volume gain
150  *
151  * @return      This function returns MM_ERROR_NONE on success, or negative value
152  *                      with error code.
153  *
154  * @remark      This function provide low latency sound play (such as dialer keytone)
155  *                      using fixed spec of wave file (44100Hz, mono channel)
156  * @see         volume_type_t volume_gain_t mm_sound_volume_set_value
157  */
158 int mm_sound_play_keysound(const char *filename, int volume_config);
159
160 int mm_sound_pcm_play_open_ex (MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, int volume_config, int asm_event);
161
162 int mm_sound_boot_ready(int timeout_sec);
163
164 int mm_sound_boot_play_sound(char* path);
165
166 /**
167         @}
168  */
169
170 #ifdef __cplusplus
171 }
172 #endif
173
174 #endif  /* __MM_SOUND_H__ */
175