extern _session_mode_e g_cached_session_mode;
extern int g_cached_voip_device_id;
extern int g_cached_voip_device_id2;
-extern _focus_watch_info_s focus_watch_info_arr[SOUND_STREAM_INFO_ARR_MAX];
-sound_stream_info_s *sound_stream_info_arr[SOUND_STREAM_INFO_ARR_MAX];
sound_stream_info_s *g_voip_stream_info = NULL;
sound_stream_info_s *g_voip_ringtone_stream_info = NULL;
virtual_sound_stream_info_s *g_voip_vstream_h = NULL;
void _focus_state_change_callback(int index, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason, int option, const char *extra_info, void *user_data)
{
int ret = MM_ERROR_NONE;
- int i = 0;
sound_stream_focus_change_reason_e change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA;
+ sound_stream_info_s *stream_info;
LOGI(">> enter");
- ret = _convert_stream_type_to_change_reason(reason, &change_reason);
- if (ret) {
- LOGE("failed to _convert_stream_type_to_enum(), reason(%s), err(0x%08x)", reason, ret);
+ if (!user_data) {
+ LOGE("user_data is null");
goto LEAVE;
}
- for (i = 0; i < SOUND_STREAM_INFO_ARR_MAX; i++) {
- if (sound_stream_info_arr[i] && sound_stream_info_arr[i]->index == index) {
- if (state == FOCUS_IS_RELEASED)
- sound_stream_info_arr[i]->acquired_focus &= ~focus_type;
- else if (state == FOCUS_IS_ACQUIRED)
- sound_stream_info_arr[i]->acquired_focus |= focus_type;
-
- LOGI("[FOCUS USER CALLBACK(%p) START]", sound_stream_info_arr[i]->user_cb);
- sound_stream_info_arr[i]->user_cb((sound_stream_info_h)sound_stream_info_arr[i],
- focus_type, state, change_reason, option, extra_info, sound_stream_info_arr[i]->user_data);
- LOGI("[FOCUS USER CALLBACK(%p) END]", sound_stream_info_arr[i]->user_cb);
- _update_focus_status(sound_stream_info_arr[i]->index, (unsigned int)sound_stream_info_arr[i]->acquired_focus);
- break;
- }
+ stream_info = (sound_stream_info_s *)user_data;
+ if (stream_info->index != index) {
+ LOGE("index is not valid, (%d, %d)", stream_info->index, index);
+ goto LEAVE;
+ }
+
+ if ((ret = _convert_stream_type_to_change_reason(reason, &change_reason))) {
+ LOGE("failed to _convert_stream_type_to_enum(), reason(%s), err(0x%08x)", reason, ret);
+ goto LEAVE;
}
- if (i == SOUND_STREAM_INFO_ARR_MAX)
- LOGE("could not find index(%d), failed to call user callback", index);
+
+ if (state == FOCUS_IS_RELEASED)
+ stream_info->acquired_focus &= ~focus_type;
+ else if (state == FOCUS_IS_ACQUIRED)
+ stream_info->acquired_focus |= focus_type;
+
+ LOGI("[FOCUS USER CALLBACK(%p) START]", stream_info->user_cb);
+ stream_info->user_cb((sound_stream_info_h)stream_info, focus_type, state, change_reason,
+ option, extra_info, stream_info->user_data);
+ LOGI("[FOCUS USER CALLBACK(%p) END]", stream_info->user_cb);
+ _update_focus_status(stream_info->index, (unsigned int)stream_info->acquired_focus);
LEAVE:
LOGI("<< leave");
void _focus_watch_callback(int index, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason, const char *extra_info, void *user_data)
{
int ret = MM_ERROR_NONE;
- int i = 0;
sound_stream_focus_change_reason_e change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA;
+ _focus_watch_info_s *watch_info;
- ret = _convert_stream_type_to_change_reason(reason, &change_reason);
- if (ret) {
- LOGE("failed to _convert_stream_type_to_enum(), reason(%s), err(0x%08x)", reason, ret);
+ if (!user_data) {
+ LOGE("user_data is null");
goto LEAVE;
}
- for (i = 0; i < SOUND_STREAM_INFO_ARR_MAX; i++) {
- if ((focus_watch_info_arr[i].id > 0) && (focus_watch_info_arr[i].id == index)) {
- LOGI("[FOCUS WATCH USER CALLBACK(%p, id:%d) START]", focus_watch_info_arr[i].user_cb, index);
- focus_watch_info_arr[i].user_cb(index, focus_type, state, change_reason, extra_info, focus_watch_info_arr[i].user_data);
- LOGI("[FOCUS WATCH USER CALLBACK(%p) END]", focus_watch_info_arr[i].user_cb);
- break;
- }
+ watch_info = (_focus_watch_info_s *)user_data;
+ if (watch_info->id != index) {
+ LOGE("index is not valid, (%d, %d)", watch_info->id, index);
+ goto LEAVE;
+ }
+
+ if ((ret = _convert_stream_type_to_change_reason(reason, &change_reason))) {
+ LOGE("failed to _convert_stream_type_to_enum(), reason(%s), err(0x%08x)", reason, ret);
+ goto LEAVE;
}
- if (i == SOUND_STREAM_INFO_ARR_MAX)
- LOGE("could not find index(%d), failed to call user callback", index);
+
+ LOGI("[FOCUS WATCH USER CALLBACK(%p, id:%d) START]", watch_info->user_cb, index);
+ watch_info->user_cb(index, focus_type, state, change_reason, extra_info, watch_info->user_data);
+ LOGI("[FOCUS WATCH USER CALLBACK(%p) END]", watch_info->user_cb);
LEAVE:
LOGI("<< leave");
if (is_focus_cb_thread)
return MM_ERROR_SOUND_INVALID_OPERATION;
- if (!stream_h->is_focus_unavailable) {
- for (i = 0; i < SOUND_STREAM_INFO_ARR_MAX; i++)
- if (sound_stream_info_arr[i] == NULL)
- break;
- if (i == SOUND_STREAM_INFO_ARR_MAX) {
- LOGE("client sound stream info array is full");
- goto PA_ERROR;
- }
- }
-
/* get configuration information of this stream type */
if ((ret = _get_stream_conf_info(stream_h->stream_type, &stream_h->stream_conf_info)))
return ret;
/* register focus */
if (!stream_h->is_focus_unavailable) {
if (is_for_session)
- ret = mm_sound_register_focus_for_session(stream_h->index, getpid(), stream_h->stream_type, _focus_state_change_callback, user_data);
+ ret = mm_sound_register_focus_for_session(stream_h->index, getpid(), stream_h->stream_type, _focus_state_change_callback, stream_h);
else
- ret = mm_sound_register_focus(stream_h->index, stream_h->stream_type, _focus_state_change_callback, user_data);
+ ret = mm_sound_register_focus(stream_h->index, stream_h->stream_type, _focus_state_change_callback, stream_h);
if (ret == MM_ERROR_NONE) {
stream_h->user_cb = callback;
stream_h->user_data = user_data;
- sound_stream_info_arr[i] = stream_h;
} else {
LOGE("failed to register focus, ret(0x%x)", ret);
/* disconnect */
SM_SAFE_FREE(stream_h->stream_conf_info.volume_type);
- for (i = 0; i < SOUND_STREAM_INFO_ARR_MAX; i++) {
- if (sound_stream_info_arr[i] && sound_stream_info_arr[i]->index == stream_h->index) {
- sound_stream_info_arr[i] = NULL;
- break;
- }
- }
-
return ret;
}