struct appdata *ad = data;
MP_CHECK_FALSE(ad);
int err = -1,error = -1;
+ sound_stream_focus_state_e state_for_playback;
+ sound_stream_focus_state_e state_for_recording;
+ int ret = -1;
+ ret = sound_manager_get_focus_state(ad->stream_info, &state_for_playback,
+ &state_for_recording);
mp_util_lock_cpu();
if (!mp_player_mgr_is_active()) {
return err;
}
}
-
- error = sound_manager_acquire_focus(ad->stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
- if (error != SOUND_MANAGER_ERROR_NONE) {
- ERROR_TRACE("failed to acquire focus [%x]", error);
+ if (state_for_playback != SOUND_STREAM_FOCUS_STATE_ACQUIRED) {
+ error = sound_manager_acquire_focus(ad->stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
+ if (error != SOUND_MANAGER_ERROR_NONE) {
+ ERROR_TRACE("failed to acquire focus [%x]", error);
+ return error;
+ }
}
sound_manager_get_focus_reacquisition(ad->stream_info, &reacquire_state);
}
}
} else {
- ret = mp_player_mgr_play(ad);
+ mp_play_control_play_pause(ad, true);
}
}