Fix bug that failed to set volume before radio start 01/210301/2 accepted/tizen/unified/20190719.111652 submit/tizen/20190718.054451
authorGilbok Lee <gilbok.lee@samsung.com>
Thu, 18 Jul 2019 02:17:33 +0000 (11:17 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Thu, 18 Jul 2019 02:35:39 +0000 (11:35 +0900)
- 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

configure.ac
packaging/libmm-radio.spec
src/Makefile.am
src/include/mm_radio_priv_hal.h
src/mm_radio_priv_hal.c
unittest/Makefile.am

index 1faaf9f45076eb9d5bda381240c661c7af0c357d..c7d61c11d9ffc11020a62c24b61b0e7ef25f4641 100755 (executable)
@@ -47,6 +47,10 @@ PKG_CHECK_MODULES(DLOG, dlog)
 AC_SUBST(DLOG_CFLAGS)
 AC_SUBST(DLOG_LIBS)
 
+PKG_CHECK_MODULES(SOUNDMGR, capi-media-sound-manager)
+AC_SUBST(SOUNDMGR_CFLAGS)
+AC_SUBST(SOUNDMGR_LIBS)
+
 AC_ARG_ENABLE(emulator, AC_HELP_STRING([--enable-emulator], [using emulator interface]),
 [
  case "${enableval}" in
@@ -67,20 +71,6 @@ if test "x$ENABLE_EMULATOR" == "xyes"; then
   AC_SUBST(GSTAPP_LIBS)
 fi
 
-AC_ARG_ENABLE(sound-vstream, AC_HELP_STRING([--enable-sound-vstream], [using sound virtual stream]),
-[case "${enableval}" in
-  yes) ENABLE_SOUND_VSTREAM=yes ;;
-  no)  ENABLE_SOUND_VSTREAM=no ;;
-  *)   AC_MSG_ERROR(bad value ${enableval} for --enable-sound-vstream) ;;
-esac], [ENABLE_SOUND_VSTREAM=no])
-AM_CONDITIONAL(ENABLE_SOUND_VSTREAM, test "x$ENABLE_SOUND_VSTREAM" = "xyes")
-
-if test "x$ENABLE_SOUND_VSTREAM" == "xyes"; then
-  PKG_CHECK_MODULES(SOUNDMGR, capi-media-sound-manager)
-  AC_SUBST(SOUNDMGR_CFLAGS)
-  AC_SUBST(SOUNDMGR_LIBS)
-fi
-
 AC_ARG_ENABLE(tests, AC_HELP_STRING([--enable-tests], [unittest build]),
 [case "${enableval}" in
   yes) IS_TESTS=yes ;;
index c76a0bdbaad2bbf5c42a9a63e44d49e8aeaf0a66..f5e874806963b0c590f8503b49420710e2ae1c8d 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-radio
 Summary:    Multimedia Framework Radio Library
-Version:    0.2.46
+Version:    0.2.47
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index 9bad76c6d8534ead77013f563ffcf8f10f762d18..c54ffad8e776ec1a1245e82206921b0132dabc8b 100755 (executable)
@@ -9,11 +9,13 @@ libmmfradio_la_CFLAGS = -I. -I./include \
                        $(GTHREAD_CFLAGS) \
                        $(MMCOMMON_CFLAGS) \
                        $(MM_RESOURCE_MANAGER_CFLAGS) \
+                       $(SOUNDMGR_CFLAGS) \
                        $(DLOG_CFLAGS)
 
 libmmfradio_la_LIBADD = $(GTHREAD_LIBS) \
                        $(MMCOMMON_LIBS) \
                        $(MM_RESOURCE_MANAGER_LIBS) \
+                       $(SOUNDMGR_LIBS) \
                        $(DLOG_LIBS)
 
 
@@ -29,10 +31,3 @@ else
 libmmfradio_la_SOURCES += mm_radio_priv_hal.c \
                          radio_hal_interface.c
 endif
-
-if ENABLE_SOUND_VSTREAM
-libmmfradio_la_CFLAGS += $(SOUNDMGR_CFLAGS) \
-                        -DTIZEN_FEATURE_SOUND_VSTREAM
-
-libmmfradio_la_LIBADD += $(SOUNDMGR_LIBS)
-endif
index 6f011e30c4e0cce43a94aa3b4fedae3123ad29a4..a629ad74c7a8dd07bbed10e9d2c7c724e7de86d9 100644 (file)
 #include <mm_types.h>
 #include <mm_message.h>
 #include <media/mm_resource_manager.h>
-
-#ifdef TIZEN_FEATURE_SOUND_VSTREAM
 #include <media/sound_manager.h>
 #include <media/sound_manager_internal.h>
-#endif
 
 #include "mm_radio.h"
 #include "mm_radio_utils.h"
@@ -197,10 +194,9 @@ typedef struct {
 
        MMRadioSeekDirectionType seek_direction;
 
-#ifdef TIZEN_FEATURE_SOUND_VSTREAM
        sound_stream_info_h stream_info;
        virtual_sound_stream_h vstream;
-#endif
+
        int freq;
 
        /* command lock */
index 67d4a0f8fe93c73c62ca686b141856b104dcff46..c26be9a855adea5d3287796c99564eea00985f5e 100644 (file)
@@ -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();
index 841d81fd7f4e62d81e3ccb3fe4d35602f63d1327..d7e451a218b8297c199523530083d1ace4b63a2d 100644 (file)
@@ -9,6 +9,7 @@ gtest_libmm_radio_CXXFLAGS = -I$(top_srcdir)/src/include \
                        $(MM_RESOURCE_MANAGER_CFLAGS) \
                        $(DLOG_CFLAGS) \
                        $(GTESTS_CFLAGS) \
+                       $(SOUNDMGR_CFLAGS) \
                        -Werror -Wno-deprecated -Wno-deprecated-declarations -Wno-cpp
 
 gtest_libmm_radio_DEPENDENCIES = $(top_srcdir)/src/.libs/libmmfradio.la
@@ -18,6 +19,7 @@ gtest_libmm_radio_LDADD = $(GTHREAD_LIBS) \
                        $(MM_RESOURCE_MANAGER_LIBS) \
                        $(DLOG_LIBS) \
                        $(GTESTS_LIBS) \
+                       $(SOUNDMGR_LIBS) \
                        $(top_srcdir)/src/.libs/libmmfradio.la
 
 if ENABLE_EMULATOR
@@ -27,10 +29,3 @@ gtest_libmm_radio_CXXFLAGS += $(GST_CFLAGS) \
 gtest_libmm_radio_LDADD += $(GST_LIBS)  \
                         $(GSTAPP_LIBS)
 endif
-
-if ENABLE_SOUND_VSTREAM
-gtest_libmm_radio_CXXFLAGS += $(SOUNDMGR_CFLAGS) \
-                        -DTIZEN_FEATURE_SOUND_VSTREAM
-
-gtest_libmm_radio_LDADD += $(SOUNDMGR_LIBS)
-endif