[0.2.120] check sound stream type before setting offload 06/211006/1
authorEunhye Choi <eunhae1.choi@samsung.com>
Mon, 29 Jul 2019 05:00:16 +0000 (14:00 +0900)
committerEunhye Choi <eunhae1.choi@samsung.com>
Mon, 29 Jul 2019 05:00:46 +0000 (14:00 +0900)
- the sound stream type should be "media" in case of
  audio offload. so set disable the audio offload
  if the sound stream type is not "media".

Change-Id: Id87d49244e563f9fb817a45232a64caa3bac4bbb

legacy/src/legacy_player.c
packaging/mmsvc-player.spec

index 2fb56b3..859150e 100644 (file)
@@ -2437,6 +2437,23 @@ int legacy_player_set_sound_stream_info_for_mused(legacy_player_h player, char *
                return PLAYER_ERROR_INVALID_PARAMETER;
        }
 
+       if (strncmp(stream_type, "media", strlen("media"))) {
+               int enabled = 0;
+
+               ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_AUDIO_OFFLOAD, &enabled, (char *)NULL);
+               if (ret != MM_ERROR_NONE)
+                       return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
+
+               if (enabled) {
+                       LOGW("audio offload will be disabled to support sound stream type: %s", stream_type);
+
+                       /* disable the audio offload */
+                       ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_AUDIO_OFFLOAD, 0, (char *)NULL);
+                       if (ret != MM_ERROR_NONE)
+                               return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
+               }
+       }
+
        ret = mm_player_set_sound_stream_info(handle->mm_handle, stream_type, stream_index);
        if (ret != MM_ERROR_NONE)
                return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
@@ -2870,12 +2887,24 @@ int legacy_player_audio_offload_set_enabled(legacy_player_h player, bool enabled
 {
        legacy_player_t *handle = (legacy_player_t *)player;
        int ret = MM_ERROR_NONE;
-       PLAYER_INSTANCE_CHECK(player);
+       gchar *stream_type = NULL;
+       int len = 0;
 
+       PLAYER_INSTANCE_CHECK(player);
        PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
 
        LOGD("set audio offload %d", enabled);
 
+       /* check sound stream type */
+       ret = mm_player_get_attribute(handle->mm_handle, NULL, "sound_stream_type", &stream_type, &len, (char *)NULL);
+       if (ret != MM_ERROR_NONE)
+               return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
+
+       if (stream_type && strncmp(stream_type, "media", strlen("media"))) {
+               LOGE("not supported sound stream type : %s", stream_type);
+               return PLAYER_ERROR_INVALID_OPERATION;
+       }
+
        ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_AUDIO_OFFLOAD, (int)enabled, (char *)NULL);
        if (ret != MM_ERROR_NONE)
                return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
index 43b8c94..fe41fe6 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mmsvc-player
 Summary:    A Media Player module for muse server
-Version:    0.2.119
+Version:    0.2.120
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0