Fix build error due to -Wformat
[platform/core/api/audio-io.git] / src / cpp / CAudioSessionHandler.cpp
1 /*
2  * Copyright (c) 2015 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 #include <unistd.h>
19 #include <mm_error.h>
20 #include "CAudioIODef.h"
21
22
23 using namespace std;
24 using namespace tizen_media_audio;
25
26
27 /**
28  * class CAudioSessionHandler
29  */
30 int CAudioSessionHandler::__sCaptureRef = 0;
31
32 int CAudioSessionHandler::__pcmCaptureCountInc() {
33     int actual;
34     do {
35         actual = __sCaptureRef;
36     } while (!__sync_bool_compare_and_swap(&__sCaptureRef, actual, actual + 1));
37     AUDIO_IO_LOGD("CaptureRefCount+1 > [%d]", __sCaptureRef);
38     return __sCaptureRef;
39 }
40
41 int CAudioSessionHandler::__pcmCaptureCountDec() {
42     int actual;
43     do {
44         actual = __sCaptureRef;
45     } while (!__sync_bool_compare_and_swap(&__sCaptureRef, actual, actual - 1));
46     AUDIO_IO_LOGD("CaptureRefCount-1 > [%d]", __sCaptureRef);
47     if (__sCaptureRef < 0) {
48         AUDIO_IO_LOGE("A CaptureRef[%d] is not valid! Something is wrong!", __sCaptureRef);
49         __sCaptureRef = 0;
50     }
51     return __sCaptureRef;
52 }
53
54 int CAudioSessionHandler::__pcmCaptureCountGet() {
55     AUDIO_IO_LOGD("CaptureRefCount > [%d]", __sCaptureRef);
56     return __sCaptureRef;
57 }
58
59 int CAudioSessionHandler::__sFocusRef = 0;
60
61 int CAudioSessionHandler::__focusIdCountInc() {
62     int actual;
63     do {
64         actual = __sFocusRef;
65     } while (!__sync_bool_compare_and_swap(&__sFocusRef, actual, actual + 1));
66     AUDIO_IO_LOGD("FocusRefCount+1 > [%d]", __sFocusRef);
67     return __sFocusRef;
68 }
69
70 int CAudioSessionHandler::__focusIdCountDec() {
71     int actual;
72     do {
73         actual = __sFocusRef;
74     } while (!__sync_bool_compare_and_swap(&__sFocusRef, actual, actual - 1));
75     AUDIO_IO_LOGD("FocusRefCount-1 > [%d]", __sFocusRef);
76     return __sFocusRef;
77 }
78
79 int CAudioSessionHandler::__focusIdCountGet() {
80     /* AUDIO_IO_LOGD("FocusRefCount > [%d]", __sFocusRef); */
81     return __sFocusRef;
82 }
83
84 CAudioSessionHandler::CAudioSessionHandler(EAudioSessionType sessionType, CAudioInfo& audioInfo, IAudioSessionEventListener* listener) :
85     __mId(-1),
86     __mOptions(0),
87     __mAudioSession(sessionType),
88     __mMultimediaSession(MM_SESSION_TYPE_MEDIA),
89     __mpEventListener(listener),
90     __mIsInit(false),
91     __mSubscribeId(0),
92     __mUseFocus(false),
93     __mAcquiredFocus(FOCUS_NONE),
94     __mReasonForChange(NULL),
95     __mAdditionalInfo(NULL) {
96     __mAudioInfo = audioInfo;
97 }
98
99 CAudioSessionHandler::~CAudioSessionHandler() {
100 }
101
102 CAudioError CAudioSessionHandler::__convertStreamType(EAudioSessionType type1, MMSessionType type2, int *index) {
103     unsigned int i;
104     int idx = -1;
105
106     assert(index != NULL);
107
108     if (type1 == EAudioSessionType::AUDIO_SESSION_TYPE_CAPTURE) {
109         for (i = 0 ; i < sizeof(__STREAM_TYPE_TABLE_IN) / sizeof(__STREAM_TYPE_TABLE_IN[0]) ; i++) {
110             if (__STREAM_TYPE_TABLE_IN[i].type == type2) {
111                 idx = i;
112                 break;
113             }
114         }
115     } else {
116         for (i = 0 ; i < sizeof(__STREAM_TYPE_TABLE_OUT) / sizeof(__STREAM_TYPE_TABLE_OUT[0]) ; i++) {
117             if (__STREAM_TYPE_TABLE_OUT[i].type == type2) {
118                 idx = i;
119                 break;
120             }
121         }
122     }
123
124     if (idx < 0) {
125         RET_ERROR_MSG(CAudioError::EError::ERROR_NOT_SUPPORTED, "Does not support session type.");
126     }
127     *index = idx;
128     RET_ERROR(CAudioError::EError::ERROR_NONE);
129 }
130
131 CAudioError CAudioSessionHandler::__getAsmInformation(MMSessionType *type, int *options) {
132     assert(type != NULL);
133     assert(options != NULL);
134
135     MMSessionType currentSession = MM_SESSION_TYPE_MEDIA;
136     int           sessionOptions = 0;
137
138     /* Read session information */
139     int ret = 0;
140     if ((ret = _mm_session_util_read_information(-1, (int*)&currentSession, &sessionOptions)) < 0) {
141         if (ret == (int) MM_ERROR_INVALID_HANDLE) {
142             RET_ERROR_MSG(CAudioError::EError::ERROR_INVALID_HANDLE, "Failed _mm_session_util_read_information(). Invalid handle");
143         } else {
144             RET_ERROR_MSG(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed _mm_session_util_read_information(). Not exist");
145         }
146     }
147
148     *type    = currentSession;
149     *options = sessionOptions;
150
151     RET_ERROR(CAudioError::EError::ERROR_NONE);
152 }
153
154 bool CAudioSessionHandler::__isFocusRequired(MMSessionType type, int options) {
155     if ((options & MM_SESSION_OPTION_PAUSE_OTHERS)
156         || ((type != MM_SESSION_TYPE_MEDIA) && (type != MM_SESSION_TYPE_MEDIA_RECORD)))
157         return true;
158     else
159         return false;
160 }
161
162 bool CAudioSessionHandler::__isFocusDisableReacquisitionRequired(MMSessionType type, int options) {
163     if ((type == MM_SESSION_TYPE_MEDIA) &&
164         !(options & MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED))
165         return true;
166
167     return false;
168 }
169
170 int CAudioSessionHandler::getId() {
171     return __mId;
172 }
173
174 int CAudioSessionHandler::getOptions() {
175     return __mOptions;
176 }
177
178 CAudioSessionHandler::EAudioSessionType CAudioSessionHandler::getAudioSession() {
179     return __mAudioSession;
180 }
181
182 MMSessionType CAudioSessionHandler::getMultimediaSession() {
183     return __mMultimediaSession;
184 }
185
186 void CAudioSessionHandler::getInternalVoipStreamInfo(sound_stream_info_h *stream_info) {
187     int ret;
188
189     if ((ret = sound_manager_get_internal_voip_stream_information(stream_info))) {
190         if (ret == SOUND_MANAGER_ERROR_NO_DATA) {
191             AUDIO_IO_LOGW("there's no internal voip stream info.");
192         } else {
193             AUDIO_IO_LOGE("failed to sound_manager_get_internal_voip_stream_information(), ret(0x%x)", ret);
194         }
195     }
196     return;
197 }
198
199 unsigned int CAudioSessionHandler::getSubscribeId() {
200     return __mSubscribeId;
201 }
202
203 CAudioInfo CAudioSessionHandler::getAudioInfo() {
204     return __mAudioInfo;
205 }
206
207 void CAudioSessionHandler::__sound_pcm_signal_cb(mm_sound_signal_name_t signal, int value, void *user_data) {
208     assert(user_data);
209
210     AUDIO_IO_LOGD("[signal:%d], [value:%d], [user_data:%p]", signal, value, user_data);
211
212     CAudioSessionHandler* pHandler = static_cast<CAudioSessionHandler*>(user_data);
213     if (pHandler->__mpEventListener != NULL)
214         pHandler->__mpEventListener->onSignal(pHandler, signal, value);
215 }
216
217 void CAudioSessionHandler::initialize() throw(CAudioError) {
218     AUDIO_IO_LOGD("");
219     if (__mIsInit == true) {
220         return;
221     }
222
223     MMSessionType currentSession = MM_SESSION_TYPE_MEDIA;
224     int           sessionOptions = 0;  // Mix with others by default
225
226     CAudioError err = __getAsmInformation(&currentSession, &sessionOptions);
227     if (err == CAudioError::EError::ERROR_NONE) {
228         if (currentSession == MM_SESSION_TYPE_REPLACED_BY_STREAM) {
229             __mUseFocus = false;
230             AUDIO_IO_LOGD("Stream info. was created outside, skip audio focus concept internally!");
231         } else {
232             // Session was configured before, use focus callback
233             __mUseFocus = true;
234             AUDIO_IO_LOGD("Use audio focus concept internally!");
235         }
236     } else {
237         if (err == CAudioError::EError::ERROR_INVALID_HANDLE) {
238             // No session, No stream_info, No focus watch callback before
239             // Use focus watch callback with signal subscribe
240
241             int errorCode = mm_sound_subscribe_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &__mSubscribeId, __sound_pcm_signal_cb, static_cast<void*>(this));
242             if (errorCode != MM_ERROR_NONE || __mSubscribeId == 0) {
243                 THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed mm_sound_subscribe_signal() err:0x%x, __mSubscribeId:%u",
244                                        errorCode, __mSubscribeId);
245             }
246
247             AUDIO_IO_LOGD("Subscribed mm_sound signal [id:%d]", __mSubscribeId);
248
249             sessionOptions = 0;  // Mix with others by default
250             __mUseFocus = true;
251             AUDIO_IO_LOGD("Use audio focus(watch) concept internally!");
252         } else {
253             __mUseFocus = false;
254             AUDIO_IO_LOGD("Skip audio focus concept!");
255         }
256
257         if (__mAudioSession == EAudioSessionType::AUDIO_SESSION_TYPE_CAPTURE) {
258             AUDIO_IO_LOGD("Set default \"Media_Record\" type");
259             currentSession = MM_SESSION_TYPE_MEDIA_RECORD;
260         } else {
261             AUDIO_IO_LOGD("Set default \"Media\" type");
262             currentSession = MM_SESSION_TYPE_MEDIA;
263         }
264     }
265
266     // Updates session information
267     __mMultimediaSession = currentSession;
268     __mOptions           = sessionOptions;
269
270     if (this->__mAudioSession == EAudioSessionType::AUDIO_SESSION_TYPE_CAPTURE) {
271         __pcmCaptureCountInc();
272     }
273
274     __mIsInit = true;
275 }
276
277 void CAudioSessionHandler::finalize() {
278     AUDIO_IO_LOGD("");
279     if (__mIsInit == false) {
280         return;
281     }
282
283     if (__mAudioSession == EAudioSessionType::AUDIO_SESSION_TYPE_CAPTURE) {
284         __pcmCaptureCountDec();
285     }
286
287     if (__mSubscribeId > 0) {
288         AUDIO_IO_LOGD("Unsubscribed mm_sound signal [id:%d]", __mSubscribeId);
289         mm_sound_unsubscribe_signal(__mSubscribeId);
290         __mSubscribeId = 0;
291     }
292
293     __mpEventListener = NULL;
294
295     __mIsInit = false;
296 }
297
298 bool CAudioSessionHandler::isSkipSession() {
299     if (__mMultimediaSession == MM_SESSION_TYPE_REPLACED_BY_STREAM ||
300         __mMultimediaSession == MM_SESSION_TYPE_VOIP ||
301         __mMultimediaSession == MM_SESSION_TYPE_CALL ||
302         __mMultimediaSession == MM_SESSION_TYPE_VIDEOCALL) {
303         AUDIO_IO_LOGD("__mMultimediaSession is [%d], skip session", __mMultimediaSession);
304         return true;
305     }
306
307     return false;
308 }
309
310 void CAudioSessionHandler::__sound_pcm_focus_cb(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state,
311                                                 const char *reason_for_change, int option, const char *additional_info, void *user_data) {
312     assert(user_data);
313
314     AUDIO_IO_LOGD("[id:%d], [focus_type:%d], [state:%d], [reason_for_change:%s], [additional_info:%s], [user_data:%p]",
315                   id, focus_type, state, reason_for_change, additional_info, user_data);
316
317 /* FIXME: disable it temporarily */
318 #ifndef DISABLE_SESSION_BACK_COMP
319
320     CAudioSessionHandler* pHandler = static_cast<CAudioSessionHandler*>(user_data);
321
322     if (state == FOCUS_IS_RELEASED)
323         pHandler->__mAcquiredFocus &= ~focus_type;
324     else if (state == FOCUS_IS_ACQUIRED)
325         pHandler->__mAcquiredFocus |= focus_type;
326     pHandler->__mReasonForChange = (char *)reason_for_change;
327     pHandler->__mAdditionalInfo  = (char *)additional_info;
328
329     if (pHandler->__mpEventListener != NULL)
330         pHandler->__mpEventListener->onInterrupt(pHandler, id, focus_type, state, reason_for_change, additional_info);
331 #endif
332     return;
333 }
334
335 void CAudioSessionHandler::__sound_pcm_focus_watch_cb(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state,
336                                                       const char *reason_for_change, const char *additional_info, void *user_data) {
337     AUDIO_IO_LOGD("[id:%d], [focus_type:%d], [state:%d], [reason_for_change:%s], [additional_info:%s], [user_data:%p]",
338                   id, focus_type, state, reason_for_change, additional_info, user_data);
339
340     CAudioSessionHandler::__sound_pcm_focus_cb(-1, focus_type, state, reason_for_change, 0, additional_info, user_data);
341
342     return;
343 }
344
345 void CAudioSessionHandler::registerSound() throw(CAudioError) {
346     if (__mIsInit == false) {
347         THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioSessionHandler");
348     }
349
350     if (__mUseFocus == true) {
351         if (__mId >= 0) {
352             THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_POLICY_BLOCKED, "Already registered [id:%d]", __mId);
353         }
354
355         int errorCode = 0;
356
357         if (__isFocusRequired(__mMultimediaSession, __mOptions)) {
358             int index = 0;
359             CAudioError err = __convertStreamType(__mAudioSession, __mMultimediaSession, &index);
360             if (err != CAudioError::EError::ERROR_NONE) {
361                 throw err;
362             }
363
364             errorCode = mm_sound_focus_get_id(&__mId);
365             if (errorCode != MM_ERROR_NONE) {
366                 THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed mm_sound_focus_get_id() err:0x%x", errorCode);
367             }
368
369             // Register focus callback
370             errorCode = mm_sound_register_focus_for_session(__mId,
371                                                 getpid(),
372                                                 __mAudioSession == EAudioSessionType::AUDIO_SESSION_TYPE_CAPTURE ? __STREAM_TYPE_TABLE_IN[index].name : __STREAM_TYPE_TABLE_OUT[index].name,
373                                                 __sound_pcm_focus_cb,
374                                                 static_cast<void*>(this));
375             if (errorCode != MM_ERROR_NONE) {
376                 THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed mm_sound_register_focus_for_session() err:0x%x", errorCode);
377             }
378
379             if (__isFocusDisableReacquisitionRequired(__mMultimediaSession, __mOptions)) {
380                 errorCode = mm_sound_set_focus_reacquisition_for_session(__mId, false);
381                 if (errorCode != MM_ERROR_NONE) {
382                     THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed mm_sound_set_focus_reacquisition() err:0x%x", errorCode);
383                 }
384             }
385
386             __focusIdCountInc();
387
388             AUDIO_IO_LOGD("Focus callback registered successfully [id:%d]", __mId);
389         } else if (!(__mOptions & MM_SESSION_OPTION_UNINTERRUPTIBLE)) {
390             // Register focus watch callback
391             errorCode = mm_sound_set_focus_watch_callback_for_session(getpid(), FOCUS_FOR_BOTH, __sound_pcm_focus_watch_cb, static_cast<void*>(this), &__mId);
392             if (errorCode < 0) {
393                 THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed mm_sound_set_focus_watch_callback_for_session() err:0x%x", errorCode);
394             }
395
396             __focusIdCountInc();
397
398             AUDIO_IO_LOGD("Focus watch callback registered successfully [id:%d]", __mId);
399         }
400     }
401 }
402
403 void CAudioSessionHandler::unregisterSound() throw(CAudioError) {
404     if (__mIsInit == false) {
405         THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioSessionHandler");
406     }
407
408     if (__mUseFocus == true && __mId >= 0) {
409         int errorCode = 0;
410
411         if (__isFocusRequired(__mMultimediaSession, __mOptions)) {
412             // Unregister focus callback
413             errorCode = mm_sound_unregister_focus(__mId);
414             if (errorCode != MM_ERROR_NONE) {
415                 THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed mm_sound_unregister_focus() err:0x%x", errorCode);
416             }
417
418             __focusIdCountDec();
419
420             AUDIO_IO_LOGD("Focus callback unregistered successfully [id:%d]", __mId);
421             __mId = -1;
422         } else if (!(__mOptions & MM_SESSION_OPTION_UNINTERRUPTIBLE)) {
423             // Unregister focus watch callback.
424             errorCode = mm_sound_unset_focus_watch_callback(__mId);
425             if (errorCode < 0) {
426                 THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed mm_sound_unset_focus_watch_callback() err:0x%x", errorCode);
427             }
428
429             __focusIdCountDec();
430
431             AUDIO_IO_LOGD("Focus watch callback unregistered successfully [id:%d]", __mId);
432             __mId = -1;
433         }
434         __mAcquiredFocus = FOCUS_NONE;
435     }
436 }
437
438 void CAudioSessionHandler::updatePlaying() throw(CAudioError) {
439     if (__mIsInit == false) {
440         THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioSessionHandler");
441     }
442
443     if (__mUseFocus && __isFocusRequired(__mMultimediaSession, __mOptions)) {
444         if (__mId >= 0) {
445             int ret = MM_ERROR_NONE;
446             int focus_type = 0;
447             if (__mAcquiredFocus == FOCUS_FOR_BOTH) {
448                 AUDIO_IO_LOGW("Focus was already acquired, skip it...");
449                 return;
450             }
451             focus_type |= (FOCUS_FOR_BOTH & ~__mAcquiredFocus);
452             if (__mMultimediaSession == MM_SESSION_TYPE_MEDIA)
453                 ret = mm_sound_acquire_focus_with_option(__mId, (mm_sound_focus_type_e)focus_type, 1, "audio-io acquire focus"); /* option: 1 for no-resume */
454             else
455                 ret = mm_sound_acquire_focus(__mId, (mm_sound_focus_type_e)focus_type, "audio-io acquire focus");
456             if (ret != MM_ERROR_NONE) {
457                 THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_POLICY_BLOCKED, "Failed mm_sound_acquire_focus() err:0x%x", ret);
458             }
459             __mAcquiredFocus = FOCUS_FOR_BOTH;
460             AUDIO_IO_LOGD("Focus acquired successfully [id:%d]", __mId);
461         }
462     }
463 }
464
465 void CAudioSessionHandler::updateStop() throw(CAudioError) {
466     if (__mIsInit == false) {
467         THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioSessionHandler");
468     }
469
470     if (__mUseFocus && __isFocusRequired(__mMultimediaSession, __mOptions)) {
471         if (__mId >= 0) {
472             int ret = MM_ERROR_NONE;
473             if (__mAcquiredFocus == FOCUS_NONE) {
474                 AUDIO_IO_LOGW("Focus was already released, skip it...");
475                 return;
476             }
477             if (__mMultimediaSession == MM_SESSION_TYPE_MEDIA)
478                 ret = mm_sound_release_focus_with_option(__mId, (mm_sound_focus_type_e)__mAcquiredFocus, 1, "audio-io release focus"); /* option: 1 for no-resume */
479             else
480                 ret = mm_sound_release_focus(__mId, (mm_sound_focus_type_e)__mAcquiredFocus, "audio-io release focus");
481             if (ret != MM_ERROR_NONE) {
482                 THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed mm_sound_release_focus() err:0x%x", ret);
483             }
484             __mAcquiredFocus = FOCUS_NONE;
485             AUDIO_IO_LOGD("Focus released successfully [id:%d]", __mId);
486         }
487     }
488 }
489
490 void CAudioSessionHandler::disableSessionHandler() throw(CAudioError) {
491     CAudioSessionHandler::updateStop();
492     CAudioSessionHandler::unregisterSound();
493
494     CAudioSessionHandler::__mUseFocus = false;
495 }
496
497 /**
498  * class IAudioSessionEventListener
499  */
500 IAudioSessionEventListener::EInterruptCode IAudioSessionEventListener::convertInterruptedCode(int code, const char *reason_for_change) {
501     EInterruptCode e = EInterruptCode::INTERRUPT_BY_MEDIA;
502
503     switch (code) {
504     case FOCUS_IS_ACQUIRED:
505         e = EInterruptCode::INTERRUPT_COMPLETED;
506         break;
507
508     case FOCUS_IS_RELEASED:
509         if (!strcmp(reason_for_change, "media"))              e = EInterruptCode::INTERRUPT_BY_MEDIA;
510         if (!strcmp(reason_for_change, "radio"))              e = EInterruptCode::INTERRUPT_BY_MEDIA;
511         if (!strcmp(reason_for_change, "loopback"))           e = EInterruptCode::INTERRUPT_BY_MEDIA;
512         if (!strcmp(reason_for_change, "system"))             e = EInterruptCode::INTERRUPT_BY_MEDIA;
513         if (!strcmp(reason_for_change, "alarm"))              e = EInterruptCode::INTERRUPT_BY_ALARM;
514         if (!strcmp(reason_for_change, "notification"))       e = EInterruptCode::INTERRUPT_BY_NOTIFICATION;
515         if (!strcmp(reason_for_change, "emergency"))          e = EInterruptCode::INTERRUPT_BY_EMERGENCY;
516         if (!strcmp(reason_for_change, "voice-information"))  e = EInterruptCode::INTERRUPT_BY_MEDIA;
517         if (!strcmp(reason_for_change, "voice-recognition"))  e = EInterruptCode::INTERRUPT_BY_MEDIA;
518         if (!strcmp(reason_for_change, "ringtone-voip"))      e = EInterruptCode::INTERRUPT_BY_CALL;
519         if (!strcmp(reason_for_change, "ringtone-call"))      e = EInterruptCode::INTERRUPT_BY_CALL;
520         if (!strcmp(reason_for_change, "voip"))               e = EInterruptCode::INTERRUPT_BY_CALL;
521         if (!strcmp(reason_for_change, "call-voice"))         e = EInterruptCode::INTERRUPT_BY_CALL;
522         if (!strcmp(reason_for_change, "call-video"))         e = EInterruptCode::INTERRUPT_BY_CALL;
523         break;
524     }
525
526     return e;
527 }