2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #define LOG_TAG "CAPI_MEDIA_WAV_PLAYER"
21 #include <mm_sound_private.h>
27 #include "wav_player.h"
28 #include "wav_player_private.h"
32 int wav_player_start(const char *path, sound_type_e type, wav_player_playback_completed_cb cb, void *user_data, int * id)
34 int ret = MM_ERROR_NONE;
36 char m_path[PATH_MAX];
37 void (*_completed_cb)(void *, int);
39 _cb_data *cb_data = NULL;
43 return __convert_wav_player_error_code(__func__, WAV_PLAYER_ERROR_INVALID_PARAMETER);
45 if( type < SOUND_TYPE_SYSTEM || type >= SOUND_TYPE_NUM )
46 return __convert_wav_player_error_code(__func__, WAV_PLAYER_ERROR_INVALID_PARAMETER);
51 if( getcwd(m_path, PATH_MAX) != NULL){
52 strncat(m_path, "/",PATH_MAX-strlen(m_path) );
55 strncat(m_path, path, PATH_MAX-strlen(m_path));
58 _completed_cb = __internal_complete_cb;
59 cb_data = (_cb_data *)malloc(sizeof(_cb_data));
61 return __convert_wav_player_error_code(__func__, WAV_PLAYER_ERROR_INVALID_OPERATION);
63 cb_data->user_data = user_data;
67 ret = mm_sound_play_sound(m_path, type, _completed_cb , cb_data, &player);
69 if( ret == 0 && id != NULL){
73 if( ret != 0 && cb_data != NULL)
76 return __convert_wav_player_error_code(__func__, ret);
79 int wav_player_stop(int id)
81 return __convert_wav_player_error_code(__func__, mm_sound_stop_sound(id));