* 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.
+* limitations under the License.
*/
*/
/**
- * @brief Enumerations of error code for WAV player.
+ * @brief Enumeration of error codes for WAV player.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
- WAV_PLAYER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
- WAV_PLAYER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- WAV_PLAYER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
- WAV_PLAYER_ERROR_FORMAT_NOT_SUPPORTED = WAV_PLAYER_ERROR_CLASS | 0x01 /**< Not supported format */
+ WAV_PLAYER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ WAV_PLAYER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ WAV_PLAYER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
+ WAV_PLAYER_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported (Since 3.0) */
+ WAV_PLAYER_ERROR_FORMAT_NOT_SUPPORTED = TIZEN_ERROR_WAV_PLAYER | 0x01 /**< Format not supported */
} wav_player_error_e;
/**
/**
* @brief Called when a WAV file has finished playing.
* @details This callback is not invoked by calling wav_player_stop().
- *
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @param[in] id The completed wav player ID
* @param[in] user_data The user data passed from the callback registration function
* @see wav_player_start()
/**
+ * @deprecated Deprecated since 3.0. Use wav_player_start_with_stream_info() instead.
* @brief Plays a WAV file.
- * @param[in] path The WAV file path to play
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @remarks Sound can be mixed with other sounds if you don't control the sound session in sound-manager module since 3.0.\n
+ * You can refer to @ref CAPI_MEDIA_SUOND_MANAGER_MODULE.
+ *
+ * @param[in] path The file path to play
* @param[in] type The sound type
* @param[in] callback The callback function to invoke when a WAV file is finished playing
* @param[in] user_data The user data to be passed to the callback function
* @param[out] id The WAV player ID ( can be set to NULL )
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #WAV_PLAYER_ERROR_NONE Successful
- * @retval #WAV_PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WAV_PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #WAV_PLAYER_ERROR_INVALID_OPERATION Invalid operation
*
* @post It invokes wav_player_playback_completed_cb() when a WAV file has finished playing.
int wav_player_start(const char *path, sound_type_e type, wav_player_playback_completed_cb callback, void *user_data, int *id);
/**
- * @brief Stops playing the WAV file.
+ * @brief Plays a WAV file with stream information of sound-manager.
+ * @since_tizen 3.0
+ * @param[in] path The file path to play
+ * @param[in] stream_info The sound stream information handle
+ * @param[in] callback The callback function to be invoked when a WAV file is no longer being played
+ * @param[in] user_data The user data to be passed to the callback function
+ * @param[out] id The WAV player ID (can be set to @c NULL)
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #WAV_PLAYER_ERROR_NONE Successful
+ * @retval #WAV_PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WAV_PLAYER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WAV_PLAYER_ERROR_NOT_SUPPORTED Not supported
*
+ * @post It invokes wav_player_playback_completed_cb() when a WAV file is no longer being played.
+ * @see wav_player_stop()
+ * @see wav_player_playback_completed_cb()
+ * @see sound_manager_create_stream_information()
+ * @see sound_manager_destroy_stream_information()
+ */
+int wav_player_start_with_stream_info(const char *path, sound_stream_info_h stream_info, wav_player_playback_completed_cb callback, void *user_data, int *id);
+
+/**
+ * @brief Stops playing the WAV file.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @param[in] id The WAV player ID to stop
*
* @return 0 on success, otherwise a negative error value.
* @retval #WAV_PLAYER_ERROR_NONE Successful
- * @retval #WAV_PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #WAV_PLAYER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WAV_PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WAV_PLAYER_ERROR_INVALID_OPERATION Invalid operation
*
* @see wav_player_start()
*/
* 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.
+* limitations under the License.
*/
#define LOG_TAG "CAPI_MEDIA_WAV_PLAYER"
+#include <sound_manager.h>
+#include <sound_manager_internal.h>
#include <mm_sound.h>
#include <mm_sound_private.h>
#include <stdio.h>
return __convert_wav_player_error_code(__func__, ret);
}
+int wav_player_start_with_stream_info(const char *path, sound_stream_info_h stream_info, wav_player_playback_completed_cb cb, void *user_data, int *id)
+{
+ int ret = MM_ERROR_NONE;
+ int player = -1;
+ char m_path[PATH_MAX];
+ void (*_completed_cb)(void *, int);
+ _completed_cb = NULL;
+ _cb_data *cb_data = NULL;
+ char *stream_type = NULL;
+ int stream_id;
+
+ if( path == NULL)
+ return __convert_wav_player_error_code(__func__, WAV_PLAYER_ERROR_INVALID_PARAMETER);
+
+ ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type);
+ if( ret )
+ return __convert_wav_player_error_code(__func__, ret);
+ ret = sound_manager_get_index_from_stream_information(stream_info, &stream_id);
+ if( ret )
+ return __convert_wav_player_error_code(__func__, ret);
+
+ m_path[0] = '\0';
+ if( path[0] != '/' ){
+
+ if( getcwd(m_path, PATH_MAX) != NULL){
+ strncat(m_path, "/",PATH_MAX-strlen(m_path) );
+ }
+ }
+ strncat(m_path, path, PATH_MAX-strlen(m_path));
+
+ if( cb ){
+ _completed_cb = __internal_complete_cb;
+ cb_data = (_cb_data *)malloc(sizeof(_cb_data));
+ if(cb_data == NULL )
+ return __convert_wav_player_error_code(__func__, WAV_PLAYER_ERROR_INVALID_OPERATION);
+ cb_data->cb = cb;
+ cb_data->user_data = user_data;
+ }
+
+
+ ret = mm_sound_play_sound_with_stream_info(m_path, stream_type, stream_id, _completed_cb , cb_data, &player);
+
+ if( ret == 0 && id != NULL){
+ *id = player;
+ }
+
+ if( ret != 0 && cb_data != NULL)
+ free(cb_data);
+
+ return __convert_wav_player_error_code(__func__, ret);
+
+}
+
int wav_player_stop(int id)
{
return __convert_wav_player_error_code(__func__, mm_sound_stop_sound(id));
* 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.
+* limitations under the License.
*/
int ret=0;
int id;
int i;
- for(i =0 ; i < 100; i++){
+ for(i =0 ; i < 100; i++){
ret = wav_player_start("test.wav", SOUND_TYPE_MEDIA, _player_stop_cb,(void*)i, &id);
printf("wav_player_start(%d)(id=%d) ret = %d\n",i,id, ret);
}
void audio_io_test(){
-
+
}
int main(int argc, char**argv)
{
- if( !g_thread_supported() )
- {
- g_thread_init(NULL);
- }
-
- GError *gerr = NULL;
- event_thread = g_thread_create(GmainThread, NULL, 1, &gerr);
+ event_thread = g_thread_new("WavPlayerTest", GmainThread, NULL);
wav_play_test();
return 0;