diff options
author | Seungbae Shin <seungbae.shin@samsung.com> | 2012-08-21 17:59:19 +0900 |
---|---|---|
committer | Seungbae Shin <seungbae.shin@samsung.com> | 2012-08-21 20:51:34 +0900 |
commit | 4b557013c69aba50fe1197bf556d4c24dc9f96e3 (patch) | |
tree | 296377f274d9c20213753ec0710116a18f5745d4 /include | |
parent | 13c42beed719f9c7911c2d82c5c3b6b531a06e55 (diff) | |
download | libmm-sound-4b557013c69aba50fe1197bf556d4c24dc9f96e3.tar.gz libmm-sound-4b557013c69aba50fe1197bf556d4c24dc9f96e3.tar.bz2 libmm-sound-4b557013c69aba50fe1197bf556d4c24dc9f96e3.zip |
2.0 init
Change-Id: I1fccce4dee3e9a772dc8b9b3580296eaad513a77
Diffstat (limited to 'include')
-rw-r--r-- | include/mm_ipc.h | 9 | ||||
-rw-r--r-- | include/mm_sound.h | 296 | ||||
-rw-r--r-- | include/mm_sound_client.h | 10 | ||||
-rw-r--r-- | include/mm_sound_common.h | 6 | ||||
-rw-r--r-- | include/mm_sound_msg.h | 33 | ||||
-rw-r--r-- | include/mm_sound_private.h | 18 | ||||
-rw-r--r-- | include/mm_sound_utils.h | 52 |
7 files changed, 397 insertions, 27 deletions
diff --git a/include/mm_ipc.h b/include/mm_ipc.h index 0e9ae00..744b73b 100644 --- a/include/mm_ipc.h +++ b/include/mm_ipc.h @@ -25,6 +25,8 @@ #include <stdio.h> #include <unistd.h> +#include "mm_sound.h" + #define FILE_PATH 512 typedef enum { @@ -51,6 +53,13 @@ typedef struct int sharedkey; char filename[FILE_PATH]; + /* Device */ + int route; + int device_in; + int device_out; + int is_available; + int route_list[MM_SOUND_ROUTE_NUM]; + /* Common data */ int handle; void *callback; diff --git a/include/mm_sound.h b/include/mm_sound.h index f100f50..148a7b4 100644 --- a/include/mm_sound.h +++ b/include/mm_sound.h @@ -762,6 +762,34 @@ int main(int argc, char* argv[]) int mm_sound_pcm_play_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, const volume_type_t volume); /** + * This function start pcm playback + * + * @param handle [in] handle to start playback + * + * @return This function returns MM_ERROR_NONE on success, or negative value + * with error code. + * @remark + * @see + * @pre PCM playback handle should be allocated. + * @post PCM playback is ready to write. + */ +int mm_sound_pcm_play_start(MMSoundPcmHandle_t handle); + +/** + * This function stop pcm playback + * + * @param handle [in] handle to stop playback + * + * @return This function returns MM_ERROR_NONE on success, or negative value + * with error code. + * @remark + * @see + * @pre PCM playback handle should be allocated. + * @post PCM playback data will not be buffered. + */ +int mm_sound_pcm_play_stop(MMSoundPcmHandle_t handle); + +/** * This function is to play PCM memory buffer. * * @param handle [in] handle to play pcm data @@ -979,6 +1007,34 @@ int main(int argc, char* argv[]) int mm_sound_pcm_capture_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format); /** + * This function start pcm capture + * + * @param handle [in] handle to start capture + * + * @return This function returns read data size on success, or negative value + * with error code. + * @remark + * @see + * @pre PCM capture handle should be allocated. + * @post PCM capture data will be buffered. + */ +int mm_sound_pcm_capture_start(MMSoundPcmHandle_t handle); + +/** + * This function stop pcm capture + * + * @param handle [in] handle to stop capture + * + * @return This function returns read data size on success, or negative value + * with error code. + * @remark + * @see + * @pre PCM capture handle should be allocated. + * @post PCM capture data will not be buffered. + */ +int mm_sound_pcm_capture_stop(MMSoundPcmHandle_t handle); + +/** * This function captures PCM to memory buffer. (Samsung extension) * * @param handle [in] handle to play pcm data @@ -1832,6 +1888,246 @@ int make_callback() * @endcode */ int mm_sound_route_remove_change_callback(void); + +/* + * Enumerations of device & route + */ + +typedef enum{ + MM_SOUND_DEVICE_IN_NONE = 0x00, + MM_SOUND_DEVICE_IN_MIC = 0x01, /**< Device builtin mic. */ + MM_SOUND_DEVICE_IN_WIRED_ACCESSORY = 0x02, /**< Wired input devices */ + MM_SOUND_DEVICE_IN_BT_SCO = 0x04, /**< Bluetooth SCO device */ +} mm_sound_device_in; + +typedef enum{ + MM_SOUND_DEVICE_OUT_NONE = 0x00, + MM_SOUND_DEVICE_OUT_SPEAKER = 0x01<<8, /**< Device builtin speaker */ + MM_SOUND_DEVICE_OUT_RECEIVER = 0x02<<8, /**< Device builtin receiver */ + MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY = 0x04<<8, /**< Wired output devices such as headphone, headset, and so on. */ + MM_SOUND_DEVICE_OUT_BT_SCO = 0x08<<8, /**< Bluetooth SCO device */ + MM_SOUND_DEVICE_OUT_BT_A2DP = 0x10<<8, /**< Bluetooth A2DP device */ +} mm_sound_device_out; + +#define MM_SOUND_ROUTE_NUM 10 + +typedef enum{ + MM_SOUND_ROUTE_OUT_SPEAKER = MM_SOUND_DEVICE_OUT_SPEAKER, /**< Routing audio output to builtin device such as internal speaker. */ + MM_SOUND_ROUTE_OUT_WIRED_ACCESSORY = MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY,/**< Routing audio output to wired accessory such as headphone, headset, and so on. */ + MM_SOUND_ROUTE_OUT_BLUETOOTH = MM_SOUND_DEVICE_OUT_BT_A2DP, /**< Routing audio output to bluetooth A2DP. */ + MM_SOUND_ROUTE_IN_MIC = MM_SOUND_DEVICE_IN_MIC, /**< Routing audio input to device builtin mic. */ + MM_SOUND_ROUTE_IN_WIRED_ACCESSORY = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY, /**< Routing audio input to wired accessory. */ + MM_SOUND_ROUTE_IN_MIC_OUT_RECEIVER = MM_SOUND_DEVICE_IN_MIC | MM_SOUND_DEVICE_OUT_RECEIVER, /**< Routing audio input to device builtin mic and routing audio output to builtin receiver*/ + MM_SOUND_ROUTE_IN_MIC_OUT_SPEAKER = MM_SOUND_DEVICE_IN_MIC | MM_SOUND_DEVICE_OUT_SPEAKER , /**< Routing audio input to device builtin mic and routing audio output to builtin speaker */ + MM_SOUND_ROUTE_IN_MIC_OUT_HEADPHONE = MM_SOUND_DEVICE_IN_MIC | MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY,/**< Routing audio input to device builtin mic and routing audio output to headphone */ + MM_SOUND_ROUTE_INOUT_HEADSET = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY | MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY, /**< Routing audio input and output to headset*/ + MM_SOUND_ROUTE_INOUT_BLUETOOTH = MM_SOUND_DEVICE_IN_BT_SCO | MM_SOUND_DEVICE_OUT_BT_SCO /**< Routing audio input and output to bluetooth SCO */ +} mm_sound_route; + +typedef int (*mm_sound_available_route_cb)(mm_sound_route route, void *user_data); + +int mm_sound_is_route_available(mm_sound_route route, bool *is_available); + +int mm_sound_foreach_available_route_cb(mm_sound_available_route_cb, void *user_data); + +int mm_sound_set_active_route(mm_sound_route route); + +/** + * This function is to get active playback device and capture device. + * + * @param playback_device [out] playback device. + * @param capture_device [out] capture device. + * + * @return This function returns MM_ERROR_NONE on success, or negative value + * with error code. + * @remark None. + * @pre None. + * @post None. + * @see mm_sound_set_active_route mm_sound_device_in mm_sound_device_out + */ +int mm_sound_get_active_device(mm_sound_device_in *device_in, mm_sound_device_out *device_out); + +/** + * Active device changed callback function type. + * + * @param user_data [in] Argument passed when callback has called + * + * @return No return value + * @remark None. + * @see mm_sound_add_active_device_changed_callback mm_sound_remove_active_device_changed_callback + */ +typedef void (*mm_sound_active_device_changed_cb) (mm_sound_device_in device_in, mm_sound_device_out device_out, void *user_data); + +/** + * This function is to add active device callback. + * + * @param func [in] callback function pointer + * @param user_data [in] user data passing to callback function + * + * @return This function returns MM_ERROR_NONE on success, or negative value + * with error code. + * @remark None. + * @see mm_sound_remove_active_device_changed_callback mm_sound_active_device_changed_cb + * @pre None. + * @post None. + * @par Example + * @code + +void __active_device_callback(void *user_data) +{ + printf("Callback function\n"); +} + +int active_device_control() +{ + int ret = 0; + + ret = mm_sound_add_active_device_changed_callback(__active_device_callback, NULL); + if ( MM_ERROR_NONE != ret) + { + printf("Can not add callback\n"); + } + else + { + printf("Add callback success\n"); + } + + return ret; +} + + * @endcode + */ +int mm_sound_add_active_device_changed_callback(mm_sound_active_device_changed_cb func, void *user_data); + +/** + * This function is to remove active device callback. + * + * @return This function returns MM_ERROR_NONE on success, or negative value + * with error code. + * @remark None. + * @pre Active device callback should be registered. + * @post Active device callback deregistered and does not be called anymore. + * @see mm_sound_add_active_device_changed_callback mm_sound_active_device_changed_cb + * @par Example + * @code +void __active_device_callback(void *data) +{ + printf("Callback function\n"); +} + +int active_device_control() +{ + int ret = 0; + + mm_sound_add_active_device_changed_callback(__active_device_callback, NULL); + + ret = mm_sound_remove_active_device_changed_callback(); + if ( MM_ERROR_NONE == ret) + { + printf("Remove callback success\n"); + } + else + { + printf("Remove callback failed\n"); + } + + return ret; +} + + * @endcode + */ +int mm_sound_remove_active_device_changed_callback(void); + +/** + * Available route changed callback function type. + * + * @param user_data [in] Argument passed when callback has called + * + * @return No return value + * @remark None. + * @see mm_sound_add_active_device_changed_callback mm_sound_remove_active_device_changed_callback + */ +typedef void (*mm_sound_available_route_changed_cb) (mm_sound_route route, bool available, void *user_data); + +/** + * This function is to add available device callback. + * + * @param func [in] callback function pointer + * @param user_data [in] user data passing to callback function + * + * @return This function returns MM_ERROR_NONE on success, or negative value + * with error code. + * @remark None. + * @see mm_sound_remove_available_route_changed_callback mm_sound_active_device_changed_cb + * @pre None. + * @post None. + * @par Example + * @code + +void __available_device_callback(void *user_data) +{ + printf("Callback function\n"); +} + +int available_device_control() +{ + int ret = 0; + + ret = mm_sound_add_available_route_changed_callback(__available_device_callback, NULL); + if ( MM_ERROR_NONE != ret) + { + printf("Can not add callback\n"); + } + else + { + printf("Add callback success\n"); + } + + return ret; +} + + * @endcode + */ +int mm_sound_add_available_route_changed_callback(mm_sound_available_route_changed_cb func, void *user_data); + +/** + * This function is to remove available device callback. + * + * @return This function returns MM_ERROR_NONE on success, or negative value + * with error code. + * @remark None. + * @pre available device callback should be registered. + * @post available device callback deregistered and does not be called anymore. + * @see mm_sound_add_available_route_changed_callback mm_sound_active_device_changed_cb + * @par Example + * @code +void __available_device_callback(void *data) +{ + printf("Callback function\n"); +} + +int available_device_control() +{ + int ret = 0; + + mm_sound_add_available_route_changed_callback(__available_device_callback, NULL); + + ret = mm_sound_remove_available_route_changed_callback(); + if ( MM_ERROR_NONE == ret) + { + printf("Remove callback success\n"); + } + else + { + printf("Remove callback failed\n"); + } + + return ret; +} + + * @endcode + */ +int mm_sound_remove_available_route_changed_callback(void); /** @} */ diff --git a/include/mm_sound_client.h b/include/mm_sound_client.h index 90f3b7f..2628e6a 100644 --- a/include/mm_sound_client.h +++ b/include/mm_sound_client.h @@ -31,7 +31,13 @@ int MMSoundClientCallbackFini(void); int MMSoundClientPlayTone(int number, int vol_type, double volume, int time, int *handle); int MMSoundClientPlaySound(MMSoundParamType *param, int tone, int keytone, int *handle); int MMSoundClientStopSound(int handle); -int MMSoundClientIsBtA2dpOn (int* connected, char** bt_name); -int MMSoundClientSetAudioRoute(int route); +int _mm_sound_client_is_route_available(mm_sound_route route, bool *is_available); +int _mm_sound_client_foreach_available_route_cb(mm_sound_available_route_cb, void *user_data); +int _mm_sound_client_set_active_route(mm_sound_route route); +int _mm_sound_client_get_active_device(mm_sound_device_in *device_in, mm_sound_device_out *device_out); +int _mm_sound_client_add_active_device_changed_callback(mm_sound_active_device_changed_cb func, void* user_data); +int _mm_sound_client_remove_active_device_changed_callback(void); +int _mm_sound_client_add_available_route_changed_callback(mm_sound_available_route_changed_cb func, void* user_data); +int _mm_sound_client_remove_available_route_changed_callback(void); #endif /* __MM_SOUND_CLIENT_H__ */ diff --git a/include/mm_sound_common.h b/include/mm_sound_common.h index ff9a712..daa94d3 100644 --- a/include/mm_sound_common.h +++ b/include/mm_sound_common.h @@ -22,12 +22,10 @@ #ifndef __MM_SOUND_COMMON_H__
#define __MM_SOUND_COMMON_H__
-#define ROUTE_VCONF_KEY "memory/Sound/RoutePolicy"
-
///////////////////////////////////
//// MMSOUND VOLUME APIs
///////////////////////////////////
-#define VCONF_KEY_VOLUME_PREFIX "db/volume"
+#define VCONF_KEY_VOLUME_PREFIX "db/private/sound/volume"
#define VCONF_KEY_VOLUME_TYPE_SYSTEM VCONF_KEY_VOLUME_PREFIX"/system"
#define VCONF_KEY_VOLUME_TYPE_NOTIFICATION VCONF_KEY_VOLUME_PREFIX"/notification"
#define VCONF_KEY_VOLUME_TYPE_ALARM VCONF_KEY_VOLUME_PREFIX"/alarm"
@@ -37,6 +35,8 @@ #define VCONF_KEY_VOLUME_TYPE_ANDROID VCONF_KEY_VOLUME_PREFIX"/fixed"
#define VCONF_KEY_VOLUME_TYPE_JAVA VCONF_KEY_VOLUME_PREFIX"/java"
+#define ASM_READY_KEY "memory/Sound/ASMReady"
+
#define MMSOUND_ENTER_CRITICAL_SECTION(x_mutex) \
switch ( pthread_mutex_lock( x_mutex ) ) \
{ \
diff --git a/include/mm_sound_msg.h b/include/mm_sound_msg.h index 3f706e7..e98bf28 100644 --- a/include/mm_sound_msg.h +++ b/include/mm_sound_msg.h @@ -26,16 +26,11 @@ #include <unistd.h> #include <mm_ipc.h> -#define KEY_BASE_PATH "/" -#define SHM_NAME "SHM" +#define KEY_BASE_PATH "/tmp" #define RCV_MSG 0x21 /* rcv key */ #define SND_MSG 0x24 /* snd key */ #define CB_MSG 0x64 /* cb key */ -#define SERVER_RCV_TYPE 100000 /* rcv message type in server */ -#define SERVER_CB_TYPE 200000 /* cb message type in server */ -#define CLIENT_CB_TYPE 300000 /* cb message type in client */ - #define MEMTYPE_SUPPORT_MAX (1024 * 1024) /* 1MB */ enum { @@ -53,15 +48,33 @@ enum { MM_SOUND_MSG_RES_GET_AUDIO_ROUTE = 17, MM_SOUND_MSG_REQ_SET_AUDIO_ROUTE = 18, MM_SOUND_MSG_RES_SET_AUDIO_ROUTE = 19, +#endif // PULSE_CLIENT MM_SOUND_MSG_REQ_IS_BT_A2DP_ON = 20, MM_SOUND_MSG_RES_IS_BT_A2DP_ON = 21, -#endif // PULSE_CLIENT - MM_SOUND_MSG_REQ_DTMF = 22, - MM_SOUND_MSG_RES_DTMF = 23, + MM_SOUND_MSG_REQ_DTMF = 22, + MM_SOUND_MSG_RES_DTMF = 23, + MM_SOUND_MSG_REQ_IS_ROUTE_AVAILABLE, + MM_SOUND_MSG_RES_IS_ROUTE_AVAILABLE, + MM_SOUND_MSG_REQ_FOREACH_AVAILABLE_ROUTE_CB, + MM_SOUND_MSG_RES_FOREACH_AVAILABLE_ROUTE_CB, + MM_SOUND_MSG_INF_FOREACH_AVAILABLE_ROUTE_CB, + MM_SOUND_MSG_REQ_SET_ACTIVE_ROUTE, + MM_SOUND_MSG_RES_SET_ACTIVE_ROUTE, + MM_SOUND_MSG_REQ_GET_ACTIVE_DEVICE, + MM_SOUND_MSG_RES_GET_ACTIVE_DEVICE, + MM_SOUND_MSG_REQ_ADD_ACTIVE_DEVICE_CB, + MM_SOUND_MSG_RES_ADD_ACTIVE_DEVICE_CB, + MM_SOUND_MSG_REQ_REMOVE_ACTIVE_DEVICE_CB, + MM_SOUND_MSG_RES_REMOVE_ACTIVE_DEVICE_CB, + MM_SOUND_MSG_INF_ACTIVE_DEVICE_CB, + MM_SOUND_MSG_REQ_ADD_AVAILABLE_ROUTE_CB, + MM_SOUND_MSG_RES_ADD_AVAILABLE_ROUTE_CB, + MM_SOUND_MSG_REQ_REMOVE_AVAILABLE_ROUTE_CB, + MM_SOUND_MSG_RES_REMOVE_AVAILABLE_ROUTE_CB, + MM_SOUND_MSG_INF_AVAILABLE_ROUTE_CB, }; #define DSIZE sizeof(mm_ipc_msg_t)-sizeof(long) /* data size for rcv & snd */ -#define CONVERT_MSG_REQ_RES(A) ((A) + (MM_SOUND_MSG_RES_NODE - MM_SOUND_MSG_REQ_NODE)) #endif /* __MM_SOUND_MSG_H__ */ diff --git a/include/mm_sound_private.h b/include/mm_sound_private.h index 2534daa..82cda96 100644 --- a/include/mm_sound_private.h +++ b/include/mm_sound_private.h @@ -94,22 +94,16 @@ enum MMSoundPathOptionType { MM_SOUND_PATH_OPTION_NONE = 0x00000000, /**< no sound path option */ MM_SOUND_PATH_OPTION_AUTO_HEADSET_CONTROL = 0x00000001, /**< automatic sound path change by earphone event */ MM_SOUND_PATH_OPTION_SPEAKER_WITH_HEADSET = 0x00000002, /**< play sound via speaker and earphone (if inserted) */ - MM_SOUND_PATH_OPTION_LEFT_SPEAKER_ONLY = 0x00000004, /**< not used */ - MM_SOUND_PATH_OPTION_RIGHT_SPEAKER_ONLY = 0x00000008, /**< not used */ MM_SOUND_PATH_OPTION_VOICECALL_REC = 0x00000010, /**< voice call recording option */ MM_SOUND_PATH_OPTION_USE_SUB_MIC = 0x00000020, /**< use sub-mic on call and recording */ - MM_SOUND_PATH_OPTION_LEGACY_MODE = 0x10000000, /**< not used */ }; -/** - * Sound param - */ -enum { - MMSOUNDPARAM_FOLLOWING_ROUTE_POLICY, - MMSOUNDPARAM_SPEAKER_ONLY, - MMSOUNDPARAM_EARPHONE_AUTO, - MMSOUNDPARAM_SPEAKER_WITH_EARPHONE, + +enum mm_sound_handle_route_t { + MM_SOUND_HANDLE_ROUTE_USING_CURRENT, + MM_SOUND_HANDLE_ROUTE_SPEAKER }; + typedef struct { const char *filename; /**< filename to play */ int volume; /**< relative volume level */ @@ -118,7 +112,7 @@ typedef struct { void *data; /**< user data to callback */ void *mem_ptr; /**< memory buffer to play */ int mem_size; /**< size of memory buffer */ - int bluetooth; /**< 1 for speaker only, 0 for by route policy */ + int handle_route; /**< 1 for speaker, 0 for current */ int volume_table; /**< Volume Type (SW Volume table type) */ int priority; /**< 0 or 1 */ } MMSoundParamType; diff --git a/include/mm_sound_utils.h b/include/mm_sound_utils.h new file mode 100644 index 0000000..aadf9e5 --- /dev/null +++ b/include/mm_sound_utils.h @@ -0,0 +1,52 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin <seungbae.shin@samsung.com> + * + * 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. + * + */ + +/** + * @file mm_sound_utils.h + * @brief Internal utility library for sound module. + * @date + * @version Release + * + * Internal utility library for sound module. + */ + +#ifndef __MM_SOUND_UTILS_H__ +#define __MM_SOUND_UTILS_H__ + +#include <mm_types.h> +#include <mm_error.h> + +#include "../include/mm_sound.h" + +#ifdef __cplusplus + extern "C" { +#endif + +int _mm_sound_get_valid_route_list(mm_sound_route **route_list); +bool _mm_sound_is_route_valid(mm_sound_route route); +void _mm_sound_get_devices_from_route(mm_sound_route route, mm_sound_device_in *device_in, mm_sound_device_out *device_out); + +#ifdef __cplusplus +} +#endif + +#endif /* __MM_SOUND_UTILS_H__ */ + |