summaryrefslogtreecommitdiff
path: root/src/mm_radio_priv_hal.c
diff options
context:
space:
mode:
authorGilbok Lee <gilbok.lee@samsung.com>2019-07-18 11:17:33 +0900
committerGilbok Lee <gilbok.lee@samsung.com>2019-07-18 11:35:39 +0900
commit2da5251b2a727ee17cdd1988c869195d316d788d (patch)
treea28c1e6ec4dfbee6d2ce0c57942c7107e3b8486c /src/mm_radio_priv_hal.c
parentafb640dea119e62254ecf245250b0905c9a7514b (diff)
downloadlibmm-radio-2da5251b2a727ee17cdd1988c869195d316d788d.tar.gz
libmm-radio-2da5251b2a727ee17cdd1988c869195d316d788d.tar.bz2
libmm-radio-2da5251b2a727ee17cdd1988c869195d316d788d.zip
Fix bug that failed to set volume before radio startsubmit/tizen/20190718.054451accepted/tizen/unified/20190719.111652
- sound_manager_set_virtual_stream_volume returned invalid state error. - remove TIZEN_FEATURE_SOUND_VSTREAM define [Version] 0.2.47 [Issue Type] Fix bugs Change-Id: I1e1f133029fcf8e3f53af5aded0c1b4eda4fc3ae
Diffstat (limited to 'src/mm_radio_priv_hal.c')
-rw-r--r--src/mm_radio_priv_hal.c100
1 files changed, 34 insertions, 66 deletions
diff --git a/src/mm_radio_priv_hal.c b/src/mm_radio_priv_hal.c
index 67d4a0f..c26be9a 100644
--- a/src/mm_radio_priv_hal.c
+++ b/src/mm_radio_priv_hal.c
@@ -318,7 +318,6 @@ int _mmradio_realize(mm_radio_t *radio)
ret = _mmradio_apply_region(radio, region, update);
-#ifdef TIZEN_FEATURE_SOUND_VSTREAM
ret = sound_manager_create_stream_information_internal(SOUND_STREAM_TYPE_RADIO, NULL, radio, &radio->stream_info);
if (ret != MM_ERROR_NONE) {
MMRADIO_LOG_ERROR("failed to create stream information");
@@ -331,7 +330,7 @@ int _mmradio_realize(mm_radio_t *radio)
MMRADIO_LOG_FLEAVE();
return ret;
}
-#endif
+
MMRADIO_SET_STATE(radio, MM_RADIO_STATE_READY);
MMRADIO_LOG_FLEAVE();
@@ -354,7 +353,6 @@ int _mmradio_unrealize(mm_radio_t *radio)
/*Stop radio if started*/
_mmradio_stop(radio);
-#ifdef TIZEN_FEATURE_SOUND_VSTREAM
if (radio->vstream) {
sound_manager_destroy_virtual_stream(radio->vstream);
radio->vstream = NULL;
@@ -363,7 +361,6 @@ int _mmradio_unrealize(mm_radio_t *radio)
sound_manager_destroy_stream_information(radio->stream_info);
radio->stream_info = NULL;
}
-#endif
MMRADIO_SET_STATE(radio, MM_RADIO_STATE_NULL);
@@ -462,21 +459,13 @@ int _mmradio_get_frequency(mm_radio_t *radio, int *pFreq)
int _mmradio_mute(mm_radio_t *radio)
{
- int ret = MM_ERROR_NONE;
MMRADIO_LOG_FENTER();
MMRADIO_CHECK_INSTANCE(radio);
MMRADIO_CHECK_STATE_RETURN_IF_FAIL(radio, MMRADIO_COMMAND_MUTE);
- ret = radio_hal_mute(radio->hal_inf);
- if (ret) {
- ret = __convert_error_code(ret, (char *)__FUNCTION__);
- if (ret == MM_ERROR_NOT_IMPLEMENTED)
- MMRADIO_LOG_WARNING("radio_hal_mute is not supported");
- else
- MMRADIO_LOG_ERROR("failed to set radio hal mute");
- return ret;
- }
+ if (radio->vstream)
+ sound_manager_set_virtual_stream_volume(radio->vstream, 0);
radio->is_muted = true;
MMRADIO_LOG_INFO("Radio mute state [%d]", radio->is_muted);
@@ -487,21 +476,15 @@ int _mmradio_mute(mm_radio_t *radio)
int _mmradio_unmute(mm_radio_t *radio)
{
- int ret = MM_ERROR_NONE;
MMRADIO_LOG_FENTER();
MMRADIO_CHECK_INSTANCE(radio);
MMRADIO_CHECK_STATE_RETURN_IF_FAIL(radio, MMRADIO_COMMAND_UNMUTE);
- ret = radio_hal_unmute(radio->hal_inf);
- if (ret) {
- ret = __convert_error_code(ret, (char *)__FUNCTION__);
- if (ret == MM_ERROR_NOT_IMPLEMENTED)
- MMRADIO_LOG_WARNING("radio_hal_unmute is not supported");
- else
- MMRADIO_LOG_ERROR("failed to set radio hal unmute");
- return ret;
- }
+ if (radio->vstream)
+ sound_manager_set_virtual_stream_volume(radio->vstream,
+ (double)radio->local_volume);
+
radio->is_muted = false;
MMRADIO_LOG_INFO("Radio mute state [%d]", radio->is_muted);
@@ -619,13 +602,19 @@ int _mmradio_start(mm_radio_t *radio)
goto error1;
}
-#ifdef TIZEN_FEATURE_SOUND_VSTREAM
ret = sound_manager_start_virtual_stream(radio->vstream);
if (ret) {
MMRADIO_LOG_ERROR("failed to start sound manager virtual stream");
goto error1;
}
-#endif
+
+ if (radio->vstream) {
+ double set_volume = 0;
+ if (!radio->is_muted)
+ set_volume = (double)radio->local_volume;
+ sound_manager_set_virtual_stream_volume(radio->vstream,
+ (double)set_volume);
+ }
MMRADIO_SET_STATE(radio, MM_RADIO_STATE_PLAYING);
@@ -652,19 +641,18 @@ int _mmradio_stop(mm_radio_t *radio)
/*cancel if any seek*/
_mmradio_seek_cancel(radio);
-#ifdef TIZEN_FEATURE_SOUND_VSTREAM
+
ret = sound_manager_stop_virtual_stream(radio->vstream);
if (ret != MM_ERROR_NONE) {
MMRADIO_LOG_ERROR("failed to stop virtual_stream");
return ret;
}
-#endif
ret = radio_hal_stop(radio->hal_inf);
if (ret) {
ret = __convert_error_code(ret, (char *)__FUNCTION__);
if (ret == MM_ERROR_NOT_IMPLEMENTED) {
- MMRADIO_LOG_WARNING("radio_hal_unmute is not supported");
+ MMRADIO_LOG_WARNING("radio_hal_stop is not supported");
} else {
MMRADIO_LOG_ERROR("failed to stop radio hal");
return ret;
@@ -740,15 +728,10 @@ int _mmradio_seek(mm_radio_t *radio, MMRadioSeekDirectionType direction)
radio->seek_unmute = false;
if (!radio->is_muted) {
- ret = radio_hal_mute(radio->hal_inf);
+ ret = _mmradio_mute(radio);
if (ret) {
- ret = __convert_error_code(ret, (char *)__FUNCTION__);
- if (ret == MM_ERROR_NOT_IMPLEMENTED) {
- MMRADIO_LOG_WARNING("radio_hal_mute is not supported");
- } else {
- MMRADIO_LOG_ERROR("failed to set radio hal mute");
- return ret;
- }
+ MMRADIO_LOG_ERROR("failed to set radio mute");
+ return ret;
}
radio->seek_unmute = true;
}
@@ -923,15 +906,10 @@ void __mmradio_scan_thread(mm_radio_t *radio)
}
if (radio->old_state == MM_RADIO_STATE_PLAYING) {
- ret = radio_hal_mute(radio->hal_inf);
+ ret = _mmradio_mute(radio);
if (ret) {
- ret = __convert_error_code(ret, (char *)__FUNCTION__);
- if (ret == MM_ERROR_NOT_IMPLEMENTED) {
- MMRADIO_LOG_WARNING("radio_hal_mute is not supported");
- } else {
- MMRADIO_LOG_ERROR("faied to set radio hal mute");
- goto FINISHED;
- }
+ MMRADIO_LOG_ERROR("failed to set radio mute");
+ goto FINISHED;
}
}
@@ -1009,15 +987,10 @@ FINISHED:
MMRADIO_LOG_DEBUG("old state is ready");
} else if (radio->old_state == MM_RADIO_STATE_PLAYING) {
MMRADIO_LOG_DEBUG("old state is playing");
- ret = radio_hal_unmute(radio->hal_inf);
+ ret = _mmradio_unmute(radio);
if (ret) {
- ret = __convert_error_code(ret, (char *)__FUNCTION__);
- if (ret == MM_ERROR_NOT_IMPLEMENTED) {
- MMRADIO_LOG_WARNING("radio_hal_unmute is not supported");
- } else {
- MMRADIO_LOG_ERROR("failed to set radio hal unmute");
- goto FINISHED_ERR;
- }
+ MMRADIO_LOG_ERROR("failed to set radio unmute");
+ goto FINISHED_ERR;
}
ret = radio_hal_set_frequency(radio->hal_inf, prev_freq);
if (ret) {
@@ -1163,15 +1136,10 @@ void __mmradio_seek_thread(mm_radio_t *radio)
* In the case of limit freq, tuner should be unmuted.
* Otherwise, sound can't output even though application set new frequency.
*/
- ret = radio_hal_unmute(radio->hal_inf);
+ ret = _mmradio_unmute(radio);
if (ret) {
- ret = __convert_error_code(ret, (char *)__FUNCTION__);
- if (ret == MM_ERROR_NOT_IMPLEMENTED) {
- MMRADIO_LOG_WARNING("radio_hal_unmute is not supported");
- } else {
- MMRADIO_LOG_ERROR("failed to set radio hal unmute");
- goto SEEK_FAILED;
- }
+ MMRADIO_LOG_ERROR("failed to set radio unmute");
+ goto SEEK_FAILED;
}
radio->seek_unmute = false;
}
@@ -1188,9 +1156,9 @@ SEEK_FAILED:
* In the case of limit freq, tuner should be unmuted.
* Otherwise, sound can't output even though application set new frequency.
*/
- ret = radio_hal_unmute(radio->hal_inf);
+ ret = _mmradio_unmute(radio);
if (ret)
- MMRADIO_LOG_ERROR("failed to set unmute radio hal");
+ MMRADIO_LOG_ERROR("failed to set radio unmute");
radio->seek_unmute = false;
}
p_thread->is_running = false;
@@ -1464,10 +1432,10 @@ int _mmradio_set_volume(mm_radio_t *radio, float volume)
MMRADIO_VOLUME_LOCK(radio);
radio->local_volume = volume;
-#ifdef TIZEN_FEATURE_SOUND_VSTREAM
if (radio->vstream)
- ret = sound_manager_set_virtual_stream_volume(radio->vstream, (double)radio->local_volume);
-#endif
+ sound_manager_set_virtual_stream_volume(radio->vstream,
+ (double)radio->local_volume);
+
MMRADIO_VOLUME_UNLOCK(radio);
MMRADIO_LOG_FLEAVE();