summaryrefslogtreecommitdiff
path: root/src/mm_radio_priv_hal.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mm_radio_priv_hal.c')
-rw-r--r--src/mm_radio_priv_hal.c89
1 files changed, 52 insertions, 37 deletions
diff --git a/src/mm_radio_priv_hal.c b/src/mm_radio_priv_hal.c
index ae5bca3..0ccd884 100644
--- a/src/mm_radio_priv_hal.c
+++ b/src/mm_radio_priv_hal.c
@@ -34,7 +34,6 @@
#include <errno.h>
#include <mm_error.h>
-#include <mm_debug.h>
#include <mm_message.h>
#include <mm_sound.h>
@@ -169,7 +168,7 @@ int _mmradio_apply_region(mm_radio_t *radio, MMRadioRegionType region, bool upda
}
}
- MMRADIO_LOG_DEBUG("setting region - country: %d, de-emphasis: %d, band range: %d ~ %d KHz",
+ MMRADIO_LOG_INFO("setting region - country: %d, de-emphasis: %d, band range: %d ~ %d KHz",
radio->region_setting.country, radio->region_setting.deemphasis,
radio->region_setting.band_min, radio->region_setting.band_max);
@@ -249,7 +248,7 @@ int _mmradio_realize(mm_radio_t *radio)
ret = pthread_mutex_init(&radio->seek_cancel_mutex, NULL);
if (ret < 0) {
- MMRADIO_LOG_DEBUG("Mutex creation failed %d", ret);
+ MMRADIO_LOG_ERROR("Mutex creation failed %d", ret);
return MM_ERROR_RADIO_INTERNAL;
}
@@ -357,6 +356,18 @@ int _mmradio_destroy(mm_radio_t *radio)
MMRADIO_LOG_ERROR("mmradio hal interface deinit failed");
return ret;
}
+
+ /* destroy command lock */
+ ret = pthread_mutex_destroy(&radio->cmd_lock);
+ if (ret) {
+ MMRADIO_LOG_ERROR("mutex destroy failed\n");
+ }
+
+ ret = pthread_mutex_destroy(&radio->volume_lock);
+ if (ret) {
+ MMRADIO_LOG_ERROR("volume mutex destroy failed\n");
+ }
+
#ifdef TIZEN_FEATURE_SOUND_FOCUS
ret = mmradio_sound_focus_deregister(&radio->sound_focus);
if (ret) {
@@ -379,7 +390,7 @@ int _mmradio_set_frequency(mm_radio_t *radio, int freq)
MMRADIO_CHECK_INSTANCE(radio);
MMRADIO_CHECK_STATE_RETURN_IF_FAIL(radio, MMRADIO_COMMAND_SET_FREQ);
- MMRADIO_LOG_DEBUG("Setting %d frequency", freq);
+ MMRADIO_LOG_INFO("Setting %d frequency", freq);
radio->freq = freq;
@@ -415,6 +426,7 @@ int _mmradio_get_frequency(mm_radio_t *radio, int *pFreq)
}
/* update freq in handle */
+ MMRADIO_LOG_INFO("Updating %d frequency", freq);
radio->freq = freq;
*pFreq = (int)radio->freq;
@@ -442,6 +454,7 @@ int _mmradio_mute(mm_radio_t *radio)
}
radio->is_muted = TRUE;
+ MMRADIO_LOG_INFO("Radio mute state [%d]", radio->is_muted);
MMRADIO_LOG_FLEAVE();
return ret;
@@ -465,7 +478,7 @@ int _mmradio_unmute(mm_radio_t *radio)
}
radio->is_muted = FALSE;
-
+ MMRADIO_LOG_INFO("Radio mute state [%d]", radio->is_muted);
MMRADIO_LOG_FLEAVE();
return ret;
@@ -515,7 +528,7 @@ int _mmradio_start(mm_radio_t *radio)
MMRADIO_CHECK_INSTANCE(radio);
MMRADIO_CHECK_STATE_RETURN_IF_FAIL(radio, MMRADIO_COMMAND_START);
- MMRADIO_LOG_DEBUG("now tune to frequency : %d", radio->freq);
+ MMRADIO_LOG_INFO("now tune to frequency : %d", radio->freq);
#ifdef TIZEN_FEATURE_SOUND_FOCUS
if (radio->sound_focus.handle > 0) {
@@ -691,7 +704,7 @@ int _mmradio_seek(mm_radio_t *radio, MMRadioSeekDirectionType direction)
radio->seek_unmute = TRUE;
}
- MMRADIO_LOG_DEBUG("trying to seek. direction[0:UP/1:DOWN) %d", direction);
+ MMRADIO_LOG_INFO("trying to seek. direction[0:UP/1:DOWN) %d", direction);
radio->seek_direction = direction;
ret = pthread_create(&radio->seek_thread, NULL, (void *)__mmradio_seek_thread, (void *)radio);
@@ -732,9 +745,9 @@ void _mmradio_seek_cancel(mm_radio_t *radio)
ret = pthread_mutex_trylock(&radio->seek_cancel_mutex);
MMRADIO_LOG_DEBUG("try lock ret: %s (%d)", strerror_r(ret, str_error, sizeof(str_error)), ret);
if (ret == EBUSY) { /* it was already locked by other */
- MMRADIO_LOG_DEBUG("send SEEK ABORT with FMRX_PROPERTY_SEARCH_ABORT");
+ MMRADIO_LOG_WARNING("send SEEK ABORT with FMRX_PROPERTY_SEARCH_ABORT");
} else if (ret == 0) {
- MMRADIO_LOG_DEBUG("trylock is successful. unlock now");
+ MMRADIO_LOG_INFO("trylock is successful. unlock now");
pthread_mutex_unlock(&radio->seek_cancel_mutex);
} else {
MMRADIO_LOG_ERROR("trylock is failed but Not EBUSY. ret: %d", ret);
@@ -787,7 +800,7 @@ int _mmradio_start_scan(mm_radio_t *radio)
scan_tr_id = pthread_create(&radio->scan_thread, NULL, (void *)__mmradio_scan_thread, (void *)radio);
if (scan_tr_id != 0) {
- MMRADIO_LOG_DEBUG("failed to create thread : scan");
+ MMRADIO_LOG_ERROR("failed to create thread : scan");
return MM_ERROR_RADIO_NOT_INITIALIZED;
}
@@ -814,9 +827,9 @@ int _mmradio_stop_scan(mm_radio_t *radio)
ret = pthread_mutex_trylock(&radio->seek_cancel_mutex);
MMRADIO_LOG_DEBUG("try lock ret: %s (%d)", strerror_r(ret, str_error, sizeof(str_error)), ret);
if (ret == EBUSY) { /* it was already locked by other */
- MMRADIO_LOG_DEBUG("send SEEK ABORT with FMRX_PROPERTY_SEARCH_ABORT");
+ MMRADIO_LOG_WARNING("send SEEK ABORT with FMRX_PROPERTY_SEARCH_ABORT");
} else if (ret == 0) {
- MMRADIO_LOG_DEBUG("trylock is successful. unlock now");
+ MMRADIO_LOG_INFO("trylock is successful. unlock now");
pthread_mutex_unlock(&radio->seek_cancel_mutex);
} else {
MMRADIO_LOG_ERROR("trylock is failed but Not EBUSY. ret: %d", ret);
@@ -845,7 +858,7 @@ int _mm_radio_get_signal_strength(mm_radio_t *radio, int *value)
if (ret == MM_ERROR_NOT_SUPPORT_API) {
MMRADIO_LOG_WARNING("radio_hal_unmute is not supported");
} else if (ret != MM_ERROR_NONE) {
- debug_error("radio_hal_get_signal_strength error");
+ MMRADIO_LOG_ERROR("radio_hal_get_signal_strength error");
*value = 0;
MMRADIO_LOG_FLEAVE();
return ret;
@@ -888,7 +901,7 @@ void __mmradio_scan_thread(mm_radio_t *radio)
pthread_mutex_lock(&radio->seek_cancel_mutex);
if (radio->stop_scan) {
- MMRADIO_LOG_DEBUG("scan was canceled");
+ MMRADIO_LOG_INFO("scan was canceled");
pthread_mutex_unlock(&radio->seek_cancel_mutex);
goto FINISHED;
}
@@ -910,20 +923,17 @@ void __mmradio_scan_thread(mm_radio_t *radio)
if (ret != MM_ERROR_NONE) {
MMRADIO_LOG_ERROR("failed to get current frequency");
} else {
- if (freq < prev_freq) {
- MMRADIO_LOG_DEBUG("scanning wrapped around. stopping scan");
+ if (freq <= prev_freq) {
+ MMRADIO_LOG_ERROR("frequency is less than previous [%d] -> [%d] we wrapped around, we are finished scanning", prev_freq, freq);
break;
}
- if (freq == prev_freq)
- continue;
-
prev_freq = param.radio_scan.frequency = (int)freq;
- MMRADIO_LOG_DEBUG("scanning : new frequency : [%d]", param.radio_scan.frequency);
+ MMRADIO_LOG_INFO("scanning : new frequency : [%d]", param.radio_scan.frequency);
/* drop if max freq is scanned */
- if (param.radio_scan.frequency == radio->region_setting.band_max) {
- MMRADIO_LOG_DEBUG("%d freq is dropping...and stopping scan", param.radio_scan.frequency);
+ if (param.radio_scan.frequency >= radio->region_setting.band_max) {
+ MMRADIO_LOG_WARNING("%d freq is dropping...and stopping scan", param.radio_scan.frequency);
break;
}
@@ -1028,7 +1038,7 @@ void __mmradio_seek_thread(mm_radio_t *radio)
MMRADIO_LOG_DEBUG("seek start");
if (radio->seek_cancel) {
- MMRADIO_LOG_DEBUG("seek was canceled so we return failure to application");
+ MMRADIO_LOG_INFO("seek was canceled so we return failure to application");
pthread_mutex_unlock(&radio->seek_cancel_mutex);
goto SEEK_FAILED;
}
@@ -1051,7 +1061,7 @@ void __mmradio_seek_thread(mm_radio_t *radio)
/* if same freq is found, ignore it and search next one. */
if (freq == radio->prev_seek_freq) {
- MMRADIO_LOG_DEBUG("It's same with previous found one. So, trying next one.");
+ MMRADIO_LOG_WARNING("It's same with previous found one. So, trying next one.");
goto SEEK_FAILED;
}
@@ -1079,7 +1089,7 @@ void __mmradio_seek_thread(mm_radio_t *radio)
}
param.radio_scan.frequency = radio->prev_seek_freq = (int)freq;
- MMRADIO_LOG_DEBUG("seeking : new frequency : [%d]", param.radio_scan.frequency);
+ MMRADIO_LOG_INFO("seeking : new frequency : [%d]", param.radio_scan.frequency);
MMRADIO_POST_MSG(radio, MM_MESSAGE_RADIO_SEEK_FINISH, &param);
}
@@ -1118,7 +1128,7 @@ static bool __mmradio_post_message(mm_radio_t *radio, enum MMMessageType msgtype
MMRADIO_LOG_FENTER();
if (!radio->msg_cb) {
- debug_warning("failed to post a message");
+ MMRADIO_LOG_WARNING("failed to post a message");
return false;
}
@@ -1141,7 +1151,7 @@ static int __mmradio_check_state(mm_radio_t *radio, MMRadioCommand command)
radio_state = __mmradio_get_state(radio);
- MMRADIO_LOG_DEBUG("incomming command : %d current state : %d", command, radio_state);
+ MMRADIO_LOG_INFO("incomming command : %d current state : %d", command, radio_state);
switch (command) {
case MMRADIO_COMMAND_CREATE:
@@ -1252,13 +1262,13 @@ static int __mmradio_check_state(mm_radio_t *radio, MMRadioCommand command)
return MM_ERROR_NONE;
- INVALID_STATE:
- debug_warning("invalid state. current : %d command : %d", radio_state, command);
+INVALID_STATE:
+ MMRADIO_LOG_WARNING("invalid state. current : %d command : %d", radio_state, command);
MMRADIO_LOG_FLEAVE();
return MM_ERROR_RADIO_INVALID_STATE;
- NO_OP:
- debug_warning("mm-radio is in the desired state(%d). doing noting", radio_state);
+NO_OP:
+ MMRADIO_LOG_WARNING("mm-radio is in the desired state(%d). doing noting", radio_state);
MMRADIO_LOG_FLEAVE();
return MM_ERROR_RADIO_NO_OP;
@@ -1272,12 +1282,12 @@ static bool __mmradio_set_state(mm_radio_t *radio, int new_state)
MMRADIO_LOG_FENTER();
if (!radio) {
- debug_warning("calling set_state with invalid radio handle");
+ MMRADIO_LOG_WARNING("calling set_state with invalid radio handle");
return false;
}
if (radio->current_state == new_state && radio->pending_state == 0) {
- debug_warning("we are in same state");
+ MMRADIO_LOG_WARNING("we are in same state");
return true;
}
@@ -1326,7 +1336,7 @@ static int __mmradio_get_state(mm_radio_t *radio)
{
MMRADIO_CHECK_INSTANCE(radio);
- MMRADIO_LOG_DEBUG("radio state : current : [%d] old : [%d] pending : [%d]",
+ MMRADIO_LOG_INFO("radio state : current : [%d] old : [%d] pending : [%d]",
radio->current_state, radio->old_state, radio->pending_state);
return radio->current_state;
@@ -1344,6 +1354,7 @@ static void __mmradio_sound_focus_cb(int id, mm_sound_focus_type_e focus_type,
MMRADIO_LOG_FENTER();
MMRADIO_CHECK_INSTANCE_RETURN_VOID(radio);
+ MMRADIO_LOG_INFO("focus_state [%d]", focus_state);
mmradio_get_sound_focus_reason(focus_state, reason_for_change, FALSE, &event_source, &postMsg);
radio->sound_focus.event_src = event_source;
@@ -1357,6 +1368,8 @@ static void __mmradio_sound_focus_cb(int id, mm_sound_focus_type_e focus_type,
if (result)
MMRADIO_LOG_ERROR("failed to stop radio");
+ radio->sound_focus.by_focus_cb = MMRADIO_FOCUS_CB_NONE;
+
MMRADIO_LOG_DEBUG("FOCUS_IS_RELEASED cur_focus_type : %d", radio->sound_focus.cur_focus_type);
}
break;
@@ -1396,6 +1409,7 @@ static void __mmradio_sound_focus_watch_cb(int id, mm_sound_focus_type_e focus_t
MMRADIO_LOG_FENTER();
MMRADIO_CHECK_INSTANCE_RETURN_VOID(radio);
+ MMRADIO_LOG_INFO("focus_state [%d]", focus_state);
mmradio_get_sound_focus_reason(focus_state, reason_for_change, TRUE, &event_source, &postMsg);
radio->sound_focus.event_src = event_source;
@@ -1408,6 +1422,7 @@ static void __mmradio_sound_focus_watch_cb(int id, mm_sound_focus_type_e focus_t
result = _mmradio_stop(radio);
if (result)
MMRADIO_LOG_ERROR("failed to stop radio");
+ radio->sound_focus.by_focus_cb = MMRADIO_FOCUS_CB_NONE;
MMRADIO_LOG_DEBUG("FOCUS_IS_RELEASED cur_focus_type : %d\n", radio->sound_focus.cur_focus_type);
}
@@ -1444,7 +1459,7 @@ static void __mmradio_volume_changed_cb(volume_type_t type, unsigned int volume,
int ret = MM_ERROR_NONE;
MMRADIO_CHECK_INSTANCE_RETURN_VOID(radio);
if (type == VOLUME_TYPE_MEDIA) {
- MMRADIO_LOG_DEBUG("Change FM Radio volume to %d", volume);
+ MMRADIO_LOG_INFO("Change FM Radio volume to %d", volume);
ret = __mmradio_set_media_volume(radio, volume);
if (ret != MM_ERROR_NONE)
MMRADIO_LOG_ERROR("__mmradio_set_media_volume error");
@@ -1504,7 +1519,7 @@ int _mmradio_set_volume(mm_radio_t *radio, float volume)
MMRADIO_CHECK_INSTANCE(radio);
MMRADIO_CHECK_STATE_RETURN_IF_FAIL(radio, MMRADIO_COMMAND_SET_VOLUME);
- MMRADIO_LOG_DEBUG("Setting %f volume", volume);
+ MMRADIO_LOG_INFO("Setting %f volume", volume);
MMRADIO_VOLUME_LOCK(radio);
radio->local_volume = volume;
@@ -1556,7 +1571,7 @@ static int __mmradio_set_media_volume(mm_radio_t *radio, unsigned int level)
MMRADIO_CHECK_INSTANCE(radio);
MMRADIO_CHECK_STATE_RETURN_IF_FAIL(radio, MMRADIO_COMMAND_SET_VOLUME);
- MMRADIO_LOG_DEBUG("Setting %d volume", level);
+ MMRADIO_LOG_INFO("Setting %d volume", level);
MMRADIO_VOLUME_LOCK(radio);
radio->media_volume = level;