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.
17 #include <sound_manager.h>
18 #include <sound_manager_private.h>
23 extern _session_interrupt_info_s g_session_interrupt_cb_table;
25 int __convert_sound_manager_error_code(const char *func, int code) {
26 int ret = SOUND_MANAGER_ERROR_NONE;
27 char *errorstr = NULL;
31 case MM_ERROR_FILE_WRITE:
32 case MM_ERROR_INVALID_HANDLE:
33 ret = SOUND_MANAGER_ERROR_INVALID_OPERATION;
34 errorstr = "INVALID_OPERATION";
37 ret = SOUND_MANAGER_ERROR_NONE;
38 errorstr = "ERROR_NONE";
40 case MM_ERROR_INVALID_ARGUMENT:
41 case MM_ERROR_SOUND_INVALID_POINTER:
42 ret = SOUND_MANAGER_ERROR_INVALID_PARAMETER;
43 errorstr = "INVALID_PARAMETER";
45 case MM_ERROR_SOUND_PERMISSION_DENIED:
46 ret = SOUND_MANAGER_ERROR_PERMISSION_DENIED;
47 errorstr = "PERMISSION_DENIED";
49 case MM_ERROR_SOUND_NO_DATA:
50 ret = SOUND_MANAGER_ERROR_NO_DATA;
53 case MM_ERROR_SOUND_INTERNAL:
54 case MM_ERROR_SOUND_VOLUME_CAPTURE_ONLY:
55 ret = SOUND_MANAGER_ERROR_INTERNAL;
56 errorstr = "INTERNAL";
58 case MM_ERROR_POLICY_DUPLICATED:
59 case MM_ERROR_POLICY_INTERNAL:
60 case MM_ERROR_POLICY_BLOCKED:
61 ret = SOUND_MANAGER_ERROR_POLICY;
64 case MM_ERROR_SOUND_VOLUME_NO_INSTANCE:
65 ret = SOUND_MANAGER_ERROR_NO_PLAYING_SOUND;
66 errorstr = "NO_PLAYING_SOUND";
69 LOGE("[%s] %s(0x%08x) : core frameworks error code(0x%08x)",func, errorstr, ret, code);
73 void __session_interrupt_cb(session_msg_t msg, session_event_t event, void *user_data){
74 if( g_session_interrupt_cb_table.user_cb ){
75 sound_session_interrupted_code_e e = SOUND_SESSION_INTERRUPTED_COMPLETED;
76 if( msg == MM_SESSION_MSG_RESUME )
77 e = SOUND_SESSION_INTERRUPTED_COMPLETED;
80 case MM_SESSION_EVENT_MEDIA :
81 e = SOUND_SESSION_INTERRUPTED_BY_MEDIA;
83 case MM_SESSION_EVENT_CALL :
84 e = SOUND_SESSION_INTERRUPTED_BY_CALL;
86 case MM_SESSION_EVENT_ALARM :
87 e = SOUND_SESSION_INTERRUPTED_BY_ALARM;
89 case MM_SESSION_EVENT_EARJACK_UNPLUG:
90 e = SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG;
92 case MM_SESSION_EVENT_RESOURCE_CONFLICT:
93 e = SOUND_SESSION_INTERRUPTED_BY_RESOURCE_CONFLICT;
95 case MM_SESSION_EVENT_EMERGENCY:
96 e = SOUND_SESSION_INTERRUPTED_BY_EMERGENCY;
98 case MM_SESSION_EVENT_NOTIFICATION :
99 e = SOUND_SESSION_INTERRUPTED_BY_NOTIFICATION;
102 e = SOUND_SESSION_INTERRUPTED_BY_MEDIA;
106 g_session_interrupt_cb_table.user_cb(e, g_session_interrupt_cb_table.user_data);