2.0 init
[framework/api/wav-player.git] / include / wav_player.h
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License. 
15 */
16
17
18
19
20 #ifndef __TIZEN_MEDIA_WAV_PLAYER_H__
21 #define __TIZEN_MEDIA_WAV_PLAYER_H__
22
23 #include <tizen.h>
24 #include <sound_manager.h>
25
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30
31 #define WAV_PLAYER_ERROR_CLASS          TIZEN_ERROR_MULTIMEDIA_CLASS | 0x50
32
33 /**
34  * @file wav_player.h
35  * @brief This file contains the WAV player API
36  */
37
38 /**
39  * @addtogroup CAPI_MEDIA_WAV_PLAYER_MODULE
40  * @{
41  */
42
43 /**
44  * @brief Enumerations of error code for WAV player.
45  */
46 typedef enum
47 {
48     WAV_PLAYER_ERROR_NONE        = TIZEN_ERROR_NONE,                      /**< Successful */
49     WAV_PLAYER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,       /**< Invalid parameter */
50     WAV_PLAYER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION,       /**< Invalid operation */
51     WAV_PLAYER_ERROR_FORMAT_NOT_SUPPORTED = WAV_PLAYER_ERROR_CLASS | 0x01                         /**< Not supported format */
52 } wav_player_error_e;
53
54 /**
55  * @}
56  */
57
58
59 /**
60  * @addtogroup CAPI_MEDIA_WAV_PLAYER_MODULE
61  * @{
62  */
63
64 /**
65  * @brief Called when a WAV file has finished playing.
66  * @details This callback is not invoked by calling wav_player_stop().
67  *
68  * @param[in] id        The completed wav player ID
69  * @param[in] user_data The user data passed from the callback registration function
70  * @see wav_player_start()
71  */
72 typedef void (*wav_player_playback_completed_cb)(int id, void *user_data);
73
74
75 /**
76  * @brief Plays a WAV file.
77  * @param[in] path      The WAV file path to play
78  * @param[in] type      The sound type
79  * @param[in] callback  The callback function to invoke when a WAV file is finished playing
80  * @param[in] user_data The user data to be passed to the callback function
81  * @param[out] id       The WAV player ID ( can be set to NULL )
82  *
83  * @return 0 on success, otherwise a negative error value.
84  * @retval #WAV_PLAYER_ERROR_NONE Successful
85  * @retval #WAV_PLAYER_ERROR_INVALID_PARAMETER Invalid parameter 
86  * @retval #WAV_PLAYER_ERROR_INVALID_OPERATION Invalid operation
87  *
88  * @post        It invokes wav_player_playback_completed_cb() when a WAV file has finished playing.
89  * @see wav_player_stop()
90  * @see wav_player_playback_completed_cb()
91  */
92 int wav_player_start(const char *path, sound_type_e type, wav_player_playback_completed_cb callback, void *user_data, int *id);
93
94 /**
95  * @brief Stops playing the WAV file.
96  *
97  * @param[in] id        The WAV player ID to stop
98  *
99  * @return 0 on success, otherwise a negative error value.
100  * @retval #WAV_PLAYER_ERROR_NONE Successful
101  * @retval #WAV_PLAYER_ERROR_INVALID_PARAMETER Invalid parameter 
102  * @retval #WAV_PLAYER_ERROR_INVALID_OPERATION Invalid operation  
103  *
104  * @see wav_player_start()
105  */
106 int wav_player_stop(int id);
107
108 /**
109  * @}
110  */
111
112 #ifdef __cplusplus
113 }
114 #endif
115
116 #endif /* __TIZEN_MEDIA_WAV_PLAYER_H__ */