}
#ifdef __TIZEN__
-static void stream_success_cb (pa_stream *s, int success, void *userdata)
+static void stream_success_cb(pa_stream *stream, int success, void *userdata)
{
- ALCpulsePlayback *self = userdata;
+ ALCpulsePlayback *self = userdata;
if(!self)
{
return;
}
- TRACE("context_success_cb(success:%d)\n", success);
+ TRACE("context_success_cb(stream:%p, success:%d)\n", stream, success);
ppa_threaded_mainloop_signal(self->loop, 0);
}
#endif
return 0;
}
#ifdef __TIZEN__
-void focus_cb(int index, mm_sound_focus_type_e type, mm_sound_focus_state_e state, const char *reason_for_change, const char *ext_info, void *user_data)
+static int g_acquired_focus_type;
+static void focus_cb(int index, mm_sound_focus_type_e type, mm_sound_focus_state_e state, const char *reason_for_change, int option, const char *ext_info, void *user_data)
{
- static ALCboolean play_or_capture_acquired,play_released,capture_released;
- TRACE("focus_cb is called \n");
+ TRACE("focus_cb is called, index(%d), type(%d), state(%d), reason_for_change(%s), option(%d), ext_info(%s), user_data(%p)\n",
+ index, type, state, reason_for_change, option, ext_info, user_data);
if(g_session_options & MM_SESSION_OPTION_UNINTERRUPTIBLE)
{
- TRACE("Session uninterruptaible\n");
+ TRACE("Session uninterruptible\n");
}
else
{
- TRACE("Session interruptaible\n");
- if(state == FOCUS_IS_RELEASED)
+ TRACE("Session interruptible\n");
+ if (state == FOCUS_IS_RELEASED)
{
- if(type == FOCUS_FOR_PLAYBACK)
- {
- play_released = ALC_TRUE;
- }
- else if(type == FOCUS_FOR_CAPTURE)
- {
- capture_released = ALC_TRUE;
- }
- else if(type == FOCUS_FOR_BOTH)
- {
- play_released = ALC_TRUE;
- capture_released = ALC_TRUE;
- }
- else
- {
- TRACE("Invalid focus type\n");
- return;
- }
- g_mute = ALC_TRUE;
- TRACE("focus state is released so Set mute \n");
+ g_acquired_focus_type &= ~type;
+ if (g_acquired_focus_type != FOCUS_FOR_BOTH)
+ g_mute = ALC_TRUE;
+ TRACE("focus state is released, g_acquired_focus_type(%d), g_mute(%d)\n", g_acquired_focus_type, g_mute);
}
else
{
- if(type == FOCUS_FOR_BOTH)
- {
+ g_acquired_focus_type |= type;
+ if (g_acquired_focus_type == FOCUS_FOR_BOTH)
g_mute = ALC_FALSE;
- TRACE("focus type is both so UnSet mute \n");
- play_released = ALC_FALSE;
- capture_released = ALC_FALSE;
- play_or_capture_acquired = ALC_FALSE;
-
- }
- else
- {
- TRACE("focus type is not both , it is %d \n",type);
- if(type == FOCUS_FOR_PLAYBACK)
- {
- if(play_or_capture_acquired)
- {
- g_mute = ALC_FALSE;
- play_or_capture_acquired = ALC_FALSE;
- play_released = ALC_FALSE;
- capture_released = ALC_FALSE;
- TRACE("focus type is capture and playback so UnSet mute \n");
- }
- else
- {
- if(play_released && !capture_released)
- {
- g_mute = ALC_FALSE;
- play_or_capture_acquired = ALC_FALSE;
- play_released = ALC_FALSE;
- TRACE("only play released previoulsy, so UnSet mute \n");
- }
- else
- {
- play_or_capture_acquired = ALC_TRUE;
- TRACE("flag play_or_capture_aquired set \n");
- }
- }
- }
- else if(type == FOCUS_FOR_CAPTURE)
- {
- if(play_or_capture_acquired)
- {
- g_mute = ALC_FALSE;
- play_or_capture_acquired = ALC_FALSE;
- play_released = ALC_FALSE;
- capture_released = ALC_FALSE;
- TRACE("focus type is play and capture , so UnSet mute \n");
- }
- else
- {
- if(capture_released && !play_released)
- {
- g_mute = ALC_FALSE;
- play_or_capture_acquired = ALC_FALSE;
- capture_released = ALC_FALSE;
- TRACE("only capture released previously, UnSet mute \n");
- }
- else
- {
- play_or_capture_acquired = ALC_TRUE;
- TRACE("flag play_or_capture_acquired set \n");
- }
- }
- }
- else
- {
- TRACE("focus type is none ,should not come here. is its %d \n", type);
- }
- }
+ TRACE("focus state is acquired, g_acquired_focus_type(%d), g_mute(%d)\n", g_acquired_focus_type, g_mute);
}
}
-
}
-void focus_watch_cb(int index, mm_sound_focus_type_e type, mm_sound_focus_state_e state, const char *reason_for_change, const char *ext_info, void *user_data)
+static void focus_watch_cb(int index, mm_sound_focus_type_e type, mm_sound_focus_state_e state, const char *reason_for_change, const char *ext_info, void *user_data)
{
- static ALCboolean play_or_capture_released,play_acquired,capture_acquired;
-
- TRACE("focus_watch_cb is called \n");
+ TRACE("focus_watch_cb is called, index(%d), type(%d), state(%d), reason_for_change(%s), ext_info(%s), user_data(%p)\n",
+ index, type, state, reason_for_change, ext_info, user_data);
if(g_session_options & MM_SESSION_OPTION_UNINTERRUPTIBLE)
{
- TRACE("Session uninterruptaible\n");
+ TRACE("Session uninterruptible\n");
}
else
{
- TRACE("Session interruptaible\n");
- if(state == FOCUS_IS_ACQUIRED)
+ TRACE("Session interruptible\n");
+ if (state == FOCUS_IS_RELEASED)
{
- if(type == FOCUS_FOR_PLAYBACK)
- {
- play_acquired = ALC_TRUE;
- }
- else if(type == FOCUS_FOR_CAPTURE)
- {
- capture_acquired = ALC_TRUE;
- }
- else if(type == FOCUS_FOR_BOTH)
- {
- play_acquired = ALC_TRUE;
- capture_acquired = ALC_TRUE;
- }
- else
- {
- TRACE("Invalid focus type\n");
- return;
- }
-
- g_mute = ALC_TRUE;
- TRACE("focus state is acquired so Set mute \n");
+ g_acquired_focus_type &= ~type;
+ if (g_acquired_focus_type == FOCUS_NONE)
+ g_mute = ALC_FALSE;
+ TRACE("focus state is released, g_acquired_focus_type(%d), g_mute(%d)\n", g_acquired_focus_type, g_mute);
}
else
{
- if(type == FOCUS_FOR_BOTH)
- {
- g_mute = ALC_FALSE;
- TRACE("focus type is both so UnSet mute\n");
- play_acquired = ALC_FALSE;
- capture_acquired = ALC_FALSE;
- play_or_capture_released = ALC_FALSE;
-
- }
- else
- {
- TRACE("focus type is not both , it is %d \n",type);
- if(type == FOCUS_FOR_PLAYBACK)
- {
- if(play_or_capture_released)
- {
- g_mute = ALC_FALSE;
- play_or_capture_released = ALC_FALSE;
- play_acquired = ALC_FALSE;
- capture_acquired = ALC_FALSE;
- TRACE("focus type is capture and playback so UnSet mute \n");
- }
- else
- {
- if(play_acquired && !capture_acquired)
- {
- g_mute = ALC_FALSE;
- play_or_capture_released = ALC_FALSE;
- play_acquired = ALC_FALSE;
- TRACE("only play acquired previoulsy, so UnSet mute \n");
- }
- else
- {
- play_or_capture_released = ALC_TRUE;
- TRACE("flag play_or_capture_released set \n");
- }
- }
- }
- else if(type == FOCUS_FOR_CAPTURE)
- {
- if(play_or_capture_released)
- {
- g_mute = ALC_FALSE;
- play_or_capture_released = ALC_FALSE;
- play_acquired = ALC_FALSE;
- capture_acquired = ALC_FALSE;
- TRACE("focus type is play and capture , so UnSet mute \n");
- }
- else
- {
- if(capture_acquired && !play_acquired)
- {
- g_mute = ALC_FALSE;
- play_or_capture_released = ALC_FALSE;
- capture_acquired = ALC_FALSE;
- TRACE("only capture acqired previously, UnSet mute \n");
- }
- else
- {
- play_or_capture_released = ALC_TRUE;
- TRACE("flag play_or_capture_released set \n");
- }
- }
- }
- else
- {
- TRACE("focus type is none ,should not come here. is its %d \n", type);
- }
- }
+ g_acquired_focus_type |= type;
+ if (g_acquired_focus_type != FOCUS_NONE)
+ g_mute = ALC_TRUE;
+ TRACE("focus state is acquired, g_acquired_focus_type(%d), g_mute(%d)\n", g_acquired_focus_type, g_mute);
}
}
}
{
int ret = MM_ERROR_NONE;
int session_type = 0;
- const char *user_data = "NULL";
/* read session information */
ret = _mm_session_util_read_information(-1, &session_type, &g_session_options);
{
TRACE(" No session presnt, Registering focus_watch_cb() function \n");
/* case 1. if there is no session */
- ret = mm_sound_set_focus_watch_callback_for_session(getpid(), FOCUS_FOR_BOTH, focus_watch_cb, (void*)user_data, &g_focus_watch_id);
+ ret = mm_sound_set_focus_watch_callback_for_session(getpid(), FOCUS_FOR_BOTH, focus_watch_cb, NULL, &g_focus_watch_id);
if(ret!= MM_ERROR_NONE)
{
ERR("failed to mm_sound_set_focus_watch_callback(), ret[0x%x]\n", ret);
{
if(g_session_options == 0)
{
- ret = mm_sound_set_focus_watch_callback_for_session(getpid(), FOCUS_FOR_BOTH, focus_watch_cb, (void*)user_data, &g_focus_watch_id);
+ ret = mm_sound_set_focus_watch_callback_for_session(getpid(), FOCUS_FOR_BOTH, focus_watch_cb, NULL, &g_focus_watch_id);
TRACE(" mm_sound_set_focus_watch_callback_for_session ret value is %x \n", ret);
if(ret!= MM_ERROR_NONE)
{
return -1;
}
/* register sound focus callback */
- ret = mm_sound_register_focus_for_session(g_focus_handle_id, getpid(), "media", focus_cb, (void*)user_data);
+ ret = mm_sound_register_focus_for_session(g_focus_handle_id, getpid(), "media", focus_cb, NULL);
if(ret != MM_ERROR_NONE)
{
ERR("mm_sound_register_focus is failed\n");
static void focus_unregister(void)
{
int ret = MM_ERROR_NONE;
+ g_acquired_focus_type = FOCUS_NONE;
if(g_focus_handle_id > 0)
{
ret = mm_sound_unregister_focus(g_focus_handle_id);
if(ret)
{
ERR("failed to mm_sound_acquire_focus(), ret[0x%x]\n", ret);
+ focus_unregister();
+ pa_threaded_mainloop_unlock(self->loop);
+ return ALC_FALSE;
}
+ g_acquired_focus_type = FOCUS_FOR_BOTH;
}
#endif
TRACE("Connecting to \"%s\"\n", pulse_name ? pulse_name : "(default)");