{
int ret = MM_ERROR_NONE;
bool is_focus_cb_thread = false;
+ bool is_focus_watch_cb_thread = false;
sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
LOGI(">> enter");
SM_INSTANCE_CHECK(stream_h);
- if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread)))
+ if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, &is_focus_watch_cb_thread)))
return _convert_sound_manager_error_code(__func__, ret);
if (stream_h->is_focus_unavailable) {
SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_cb_mutex, MM_ERROR_SOUND_INTERNAL);
SM_ENTER_CRITICAL_SECTION_WITH_UNLOCK_AND_RETURN(&stream_h->focus_state_mutex, &stream_h->focus_cb_mutex, MM_ERROR_SOUND_INTERNAL);
} else {
+ /* If it is inside of the watch cb and if the previous request of this process has not been finished yet,
+ * the focus state mutex could be still locked. Therefore, it returns error here. */
+ if (is_focus_watch_cb_thread && stream_h->is_requesting) {
+ LOGE("It is not allowed in watch cb thread during the previous request has not been finished yet");
+ return _convert_sound_manager_error_code(__func__, MM_ERROR_SOUND_INVALID_OPERATION);
+ }
SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_state_mutex, MM_ERROR_SOUND_INTERNAL);
}
goto LEAVE;
}
+ stream_h->is_requesting = true;
+
ret = mm_sound_acquire_focus_with_option(stream_h->focus_id, (mm_sound_focus_type_e)focus_mask, sound_behavior, extra_info);
if (ret == MM_ERROR_NONE) {
stream_h->acquired_focus |= focus_mask;
LOGI("acquired_focus[0x%x], prev[0x%x]", stream_h->acquired_focus, stream_h->prev_acquired_focus);
LEAVE:
+ stream_h->is_requesting = false;
SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_state_mutex);
if (!is_focus_cb_thread)
SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_cb_mutex);
{
int ret = MM_ERROR_NONE;
bool is_focus_cb_thread = false;
+ bool is_focus_watch_cb_thread = false;
sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
LOGI(">> enter");
SM_INSTANCE_CHECK(stream_h);
- if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread)))
+ if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, &is_focus_watch_cb_thread)))
return _convert_sound_manager_error_code(__func__, ret);
if (!is_focus_cb_thread) {
SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_cb_mutex, MM_ERROR_SOUND_INTERNAL);
SM_ENTER_CRITICAL_SECTION_WITH_UNLOCK_AND_RETURN(&stream_h->focus_state_mutex, &stream_h->focus_cb_mutex, MM_ERROR_SOUND_INTERNAL);
} else {
+ /* If it is inside of the watch cb and if the previous request of this process has not been finished yet,
+ * the focus state mutex could be still locked. Therefore, it returns error here. */
+ if (is_focus_watch_cb_thread && stream_h->is_requesting) {
+ LOGE("It is not allowed in watch cb thread during the previous request has not been finished yet");
+ return _convert_sound_manager_error_code(__func__, MM_ERROR_SOUND_INVALID_OPERATION);
+ }
SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_state_mutex, MM_ERROR_SOUND_INTERNAL);
}
goto LEAVE;
}
+ stream_h->is_requesting = true;
+
ret = mm_sound_release_focus_with_option(stream_h->focus_id, (mm_sound_focus_type_e)focus_mask, sound_behavior, extra_info);
if (ret == MM_ERROR_NONE) {
stream_h->acquired_focus &= ~focus_mask;
LOGI("acquired_focus[0x%x], prev[0x%x]", stream_h->acquired_focus, stream_h->prev_acquired_focus);
LEAVE:
+ stream_h->is_requesting = false;
SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_state_mutex);
if (!is_focus_cb_thread)
SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_cb_mutex);
int ret = MM_ERROR_NONE;
int focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH;
bool is_focus_cb_thread = false;
+ bool is_focus_watch_cb_thread = false;
sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
LOGI(">> enter");
SM_INSTANCE_CHECK(stream_h);
- if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread)))
+ if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, &is_focus_watch_cb_thread)))
return _convert_sound_manager_error_code(__func__, ret);
if (stream_h->is_focus_unavailable) {
SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_cb_mutex, MM_ERROR_SOUND_INTERNAL);
SM_ENTER_CRITICAL_SECTION_WITH_UNLOCK_AND_RETURN(&stream_h->focus_state_mutex, &stream_h->focus_cb_mutex, MM_ERROR_SOUND_INTERNAL);
} else {
+ /* If it is inside of the watch cb and if the previous request of this process has not been finished yet,
+ * the focus state mutex could be still locked. Therefore, it returns error here. */
+ if (is_focus_watch_cb_thread && stream_h->is_requesting) {
+ LOGE("It is not allowed in watch cb thread during the previous request has not been finished yet");
+ return _convert_sound_manager_error_code(__func__, MM_ERROR_SOUND_INVALID_OPERATION);
+ }
SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_state_mutex, MM_ERROR_SOUND_INTERNAL);
}
goto LEAVE;
}
+ stream_h->is_requesting = true;
+
ret = mm_sound_acquire_focus_with_option(stream_h->focus_id, (mm_sound_focus_type_e)focus_mask, sound_behavior, extra_info);
if (ret == MM_ERROR_NONE) {
stream_h->acquired_focus |= focus_mask;
}
LEAVE:
+ stream_h->is_requesting = false;
SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_state_mutex);
if (!is_focus_cb_thread)
SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_cb_mutex);
{
int ret = MM_ERROR_NONE;
bool is_focus_cb_thread = false;
+ bool is_focus_watch_cb_thread = false;
sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
LOGI(">> enter");
SM_INSTANCE_CHECK(stream_h);
- if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread)))
+ if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, &is_focus_watch_cb_thread)))
return _convert_sound_manager_error_code(__func__, ret);
if (!is_focus_cb_thread) {
SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_cb_mutex, MM_ERROR_SOUND_INTERNAL);
SM_ENTER_CRITICAL_SECTION_WITH_UNLOCK_AND_RETURN(&stream_h->focus_state_mutex, &stream_h->focus_cb_mutex, MM_ERROR_SOUND_INTERNAL);
} else {
+ /* If it is inside of the watch cb and if the previous request of this process has not been finished yet,
+ * the focus state mutex could be still locked. Therefore, it returns error here. */
+ if (is_focus_watch_cb_thread && stream_h->is_requesting) {
+ LOGE("It is not allowed in watch cb thread during the previous request has not been finished yet");
+ return _convert_sound_manager_error_code(__func__, MM_ERROR_SOUND_INVALID_OPERATION);
+ }
SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_state_mutex, MM_ERROR_SOUND_INTERNAL);
}
goto LEAVE;
}
+ stream_h->is_requesting = true;
+
ret = mm_sound_release_focus_with_option(stream_h->focus_id, (mm_sound_focus_type_e)stream_h->acquired_focus, sound_behavior, extra_info);
if (ret == MM_ERROR_NONE) {
stream_h->acquired_focus = 0;
}
LEAVE:
+ stream_h->is_requesting = false;
SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_state_mutex);
if (!is_focus_cb_thread)
SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_cb_mutex);
SM_INSTANCE_CHECK(src_stream_h);
SM_INSTANCE_CHECK(dst_stream_h);
- if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread)))
+ if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, NULL)))
return _convert_sound_manager_error_code(__func__, ret);
if (is_focus_cb_thread) {
SM_NULL_ARG_CHECK(acquired_by);
SM_NULL_ARG_CHECK(flags);
- if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread)))
+ if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, NULL)))
return _convert_sound_manager_error_code(__func__, ret);
if (is_focus_cb_thread) {
SM_NULL_ARG_CHECK(acquired_by);
SM_NULL_ARG_CHECK(flags);
- if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread)))
+ if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, NULL)))
return _convert_sound_manager_error_code(__func__, ret);
if (is_focus_cb_thread) {