int sound_manager_get_focus_state(sound_stream_info_h stream_info, sound_stream_focus_state_e *state_for_playback, sound_stream_focus_state_e *state_for_recording)
{
sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
+ bool is_focus_cb_thread = false;
+ int mm_ret = MM_ERROR_NONE;
SM_ARG_CHECK(stream_h);
SM_ARG_CHECK(state_for_playback || state_for_recording);
LOGI("stream_info[%p, type:%s, focus_id:%d]", stream_info, stream_h->stream_type, stream_h->focus_id);
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_state_mutex, SOUND_MANAGER_ERROR_INTERNAL);
+ if ((mm_ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, NULL)) != MM_ERROR_NONE)
+ return _convert_sound_manager_error_code(__func__, mm_ret);
+
+ if (!is_focus_cb_thread)
+ SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_state_mutex, SOUND_MANAGER_ERROR_INTERNAL);
if (state_for_playback)
*state_for_playback = ((stream_h->acquired_focus & SOUND_STREAM_FOCUS_FOR_PLAYBACK) ? (SOUND_STREAM_FOCUS_STATE_ACQUIRED) : (SOUND_STREAM_FOCUS_STATE_RELEASED));
LOGI("acquired_focus(0x%x)", stream_h->acquired_focus);
- SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_state_mutex);
+ if (!is_focus_cb_thread)
+ SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_state_mutex);
return SOUND_MANAGER_ERROR_NONE;
}