tizen 2.3 release
[framework/api/wav-player.git] / src / wav_player_private.c
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 #define LOG_TAG "CAPI_MEDIA_WAV_PLAYER"
19
20 #include <mm_sound.h>
21 #include <mm_sound_private.h>
22 #include <stdio.h>
23 #include <limits.h>
24 #include <string.h>
25 #include <unistd.h>
26 #include <dlog.h>
27 #include <stdlib.h>
28 #include "wav_player_private.h"
29
30 int __convert_wav_player_error_code(const char *func, int code)
31 {
32         int ret = WAV_PLAYER_ERROR_INVALID_OPERATION;
33         char *errorstr = NULL;
34         switch(code)
35         {
36                 case MM_ERROR_NONE:
37                         ret = WAV_PLAYER_ERROR_NONE;
38                         errorstr = "ERROR_NONE";
39                         break;
40                 case MM_ERROR_INVALID_ARGUMENT:
41                 case MM_ERROR_SOUND_INVALID_POINTER:
42                 case WAV_PLAYER_ERROR_INVALID_PARAMETER:
43                         ret = WAV_PLAYER_ERROR_INVALID_PARAMETER;
44                         errorstr = "INVALID_PARAMETER";
45                         break;
46                 case MM_ERROR_SOUND_INTERNAL:
47                         ret = WAV_PLAYER_ERROR_INVALID_OPERATION;
48                         errorstr = "INVALID_OPERATION";
49                         break;
50                 case MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE:
51                         ret = WAV_PLAYER_ERROR_FORMAT_NOT_SUPPORTED;
52                         errorstr = "FORMAT_NOT_SUPPORTED";
53                         break;
54                 default:
55                         ret = WAV_PLAYER_ERROR_INVALID_OPERATION;
56                         errorstr = "INVALID_OPERATION";
57                         break;
58         }
59         LOGE( "[%s] %s(0x%08x)",func, errorstr, ret);
60         return ret;
61 }
62
63
64 void __internal_complete_cb(void *user_data, int id)
65 {
66         _cb_data * cb_data = (_cb_data*)user_data;
67         if(!cb_data)
68                 return;
69
70         if( cb_data->cb ){
71                 LOGD( "user callback for handle %d call", id);
72                 cb_data->cb(id, cb_data->user_data);
73         }
74         free(cb_data);
75 }
76