Added input parameter range check 98/139198/4
authoraravind.gara <aravind.gara@samsung.com>
Tue, 18 Jul 2017 02:23:27 +0000 (11:23 +0900)
committeraravind kumar <aravind.gara@samsung.com>
Wed, 19 Jul 2017 07:13:38 +0000 (07:13 +0000)
[Version] Not changed
[Issue Type] Enhancement and add ACR comments

Change-Id: Ibdae98ae4b8fa696e3aedfabfbb69ec86294788a
Signed-off-by: aravind.gara <aravind.gara@samsung.com>
include/sound_pool.h
src/stream.c

index 53c4dfa..9446665 100644 (file)
@@ -41,11 +41,11 @@ extern "C" {
  * @param [in]  prev_state    Previous pool state
  * @param [in]  cur_state     Current pool state
  * @param [in]  user_data     The user data passed from the code where
- *                            @ref sound_pool_set_state_change_callback() was
+ *                            sound_pool_set_state_change_callback() was
  *                            called.
  *
- * @pre Create sound pool handler by calling @ref sound_pool_create()
- * @pre Call @ref sound_pool_set_state_change_callback()
+ * @pre Create sound pool handler by calling sound_pool_create()
+ * @pre Call sound_pool_set_state_change_callback()
  *
  * @see sound_pool_create()
  * @see sound_pool_set_state_change_callback()
@@ -65,14 +65,14 @@ typedef void (*sound_pool_state_change_cb) (sound_pool_h pool,
  * @param [in]  id          Unique stream identifier
  * @param [in]  prev_state  Previous stream state
  * @param [in]  cur_state   Current stream state
- * @param [in]  data        The user data passed from the code where
- *                          @ref sound_pool_stream_set_state_change_callback()
+ * @param [in]  user_data        The user data passed from the code where
+ *                          sound_pool_stream_set_state_change_callback()
  *                          was called.
  *
- * @pre Create sound pool handler by calling @ref sound_pool_create()
- * @pre Load source to pool by calling @ref sound_pool_load_source_from_file()
- * @pre Start source playback by calling @ref sound_pool_stream_play()
- * @pre Call @ref sound_pool_stream_set_state_change_callback()
+ * @pre Create sound pool handler by calling sound_pool_create()
+ * @pre Load source to pool by calling sound_pool_load_source_from_file()
+ * @pre Start source playback by calling sound_pool_stream_play()
+ * @pre Call sound_pool_stream_set_state_change_callback()
  *
  * @see sound_pool_create()
  * @see sound_pool_load_source_from_file()
@@ -92,7 +92,7 @@ typedef void (*sound_pool_stream_state_change_cb) (sound_pool_h pool,
  *          active.
  * @remarks When pool has been created, pool state is
  *          SOUND_POOL_STATE_INACTIVE. To activate a pool use
- *          @ref sound_pool_activate() function.
+ *          sound_pool_activate() function.
  *
  * @since_tizen 4.0
  * @param [out] pool    The handle to the pool that will be created
@@ -119,7 +119,7 @@ sound_pool_error_e sound_pool_create(sound_pool_h *pool);
  *         Invalid parameter (@a pool is NULL or corrupted)
  * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation
  *
- * @pre Create sound pool handler by calling @ref sound_pool_create()
+ * @pre Create sound pool handler by calling sound_pool_create()
  *
  * @see sound_pool_create()
  */
@@ -144,8 +144,8 @@ sound_pool_error_e sound_pool_destroy(sound_pool_h pool);
  * @retval #SOUND_POOL_ERROR_NO_SUCH_FILE No file determined by @a file_name
  * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation
  *
- * @pre Create sound @a pool handler by calling @ref sound_pool_create()
- * @post Unload source from pool by calling @ref sound_pool_unload_source()
+ * @pre Create sound @a pool handler by calling sound_pool_create()
+ * @post Unload source from pool by calling sound_pool_unload_source()
  *
  * @see sound_pool_create()
  * @see sound_pool_destroy()
@@ -169,8 +169,8 @@ sound_pool_error_e sound_pool_load_source_from_file(sound_pool_h pool,
  * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No sources tagged by @a tag exist
  *         in pool
  *
- * @pre Create sound @a pool handler by calling @ref sound_pool_create()
- * @pre Load source to pool by calling @ref sound_pool_load_source_from_file()
+ * @pre Create sound @a pool handler by calling sound_pool_create()
+ * @pre Load source to pool by calling sound_pool_load_source_from_file()
  *
  * @see sound_pool_create()
  * @see sound_pool_load_source_from_file()
@@ -191,7 +191,7 @@ sound_pool_error_e sound_pool_unload_source(sound_pool_h pool, const char *tag);
  * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation or sound pool
  *         is already in @c SOUND_POOL_STATE_ACTIVE state
  *
- * @pre Create sound @a pool handler by calling @ref sound_pool_create()
+ * @pre Create sound @a pool handler by calling sound_pool_create()
  *
  * @see sound_pool_create()
  * @see sound_pool_get_state()
@@ -214,7 +214,7 @@ sound_pool_error_e sound_pool_activate(sound_pool_h pool);
  * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation or sound pool
  *         is already in @c SOUND_POOL_STATE_INACTIVE state
  *
- * @pre Create sound @a pool handler by calling @ref sound_pool_create()
+ * @pre Create sound @a pool handler by calling sound_pool_create()
  * @pre @a pool has to be in SOUND_POOL_STATE_ACTIVE state
  *
  * @see sound_pool_create()
@@ -239,7 +239,7 @@ sound_pool_error_e sound_pool_deactivate(sound_pool_h pool);
  *         (@a pool is NULL or corrupted, or @a volume isn't in 0.0~1.0 range)
  * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation
  *
- * @pre Create sound @a pool handler by calling @ref sound_pool_create()
+ * @pre Create sound @a pool handler by calling sound_pool_create()
  *
  * @see sound_pool_create()
  */
@@ -255,7 +255,7 @@ sound_pool_error_e sound_pool_set_volume(sound_pool_h pool, float volume);
  * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter
  *         (@a pool is NULL or corrupted, or @a volume is NULL)
  *
- * @pre Create sound @a pool handler by calling @ref sound_pool_create()
+ * @pre Create sound @a pool handler by calling sound_pool_create()
  *
  * @see sound_pool_create()
  */
@@ -271,7 +271,7 @@ sound_pool_error_e sound_pool_get_volume(sound_pool_h pool, float *volume);
  * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER
  *         Invalid parameter (@a pool is NULL or corrupted, @a tag is NULL)
  *
- * @pre Create sound @a pool handler by calling @ref sound_pool_create()
+ * @pre Create sound @a pool handler by calling sound_pool_create()
  *
  * @see sound_pool_create()
  * @see sound_pool_state_e
@@ -292,8 +292,8 @@ sound_pool_error_e sound_pool_get_state(sound_pool_h pool,
  * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter
  *         (@a pool is NULL or corrupted, or @a callback is NULL)
  *
- * @pre Create sound @a pool handler by calling @ref sound_pool_create()
- * @post Use @ref sound_pool_unset_state_change_callback() function to unset the
+ * @pre Create sound @a pool handler by calling sound_pool_create()
+ * @post Use sound_pool_unset_state_change_callback() function to unset the
  *       @a callback
  *
  * @see sound_pool_create()
@@ -311,9 +311,9 @@ sound_pool_error_e sound_pool_set_state_change_callback(sound_pool_h pool,
  * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter
  *         (@a pool is NULL or corrupted)
  *
- * @pre Create sound @a pool handler by calling @ref sound_pool_create()
+ * @pre Create sound @a pool handler by calling sound_pool_create()
  * @pre Set state change callback by calling
- *      @ref sound_pool_set_state_change_callback()
+ *      sound_pool_set_state_change_callback()
  *
  * @see sound_pool_create()
  * @see sound_pool_set_state_change_callback()
@@ -334,11 +334,11 @@ sound_pool_error_e sound_pool_unset_state_change_callback(sound_pool_h pool);
  *                          (pass 0 if stream should be repeated continuously)
  * @param [in]  volume      Stream volume in 0.0~1.0 range
  * @param [in]  priority    Stream priority (0 = lowest priority). Check
- *                          @ref sound_pool_stream_set_priority() documentation
+ *                          sound_pool_stream_set_priority() documentation
  *                          for details on prioritization rules.
  * @param [in]  priority_policy    Stream priority policy.
- *                          (#SOUND_POOL_STREAM_PRIORITY_POLICY_SUSPENDED  Suspended)
  *                          (#SOUND_POOL_STREAM_PRIORITY_POLICY_MUTE Mute)
+ *                          (#SOUND_POOL_STREAM_PRIORITY_POLICY_SUSPENDED  Suspended)
  * @param [in]  callback    The callback that will be called after stream state
  *                          will be changed, or NULL if this callback call
  *                          isn't needed. If @a callback is set, then it will
@@ -356,17 +356,17 @@ sound_pool_error_e sound_pool_unset_state_change_callback(sound_pool_h pool);
  *         sound stream
  * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation
  *
- * @pre Create sound pool handler by calling @ref sound_pool_create()
- * @pre Load source to @a pool by calling @ref sound_pool_load_source_from_file()
- * @post When playback is finished normally (i.e. @ref sound_pool_stream_stop()
+ * @pre Create sound pool handler by calling sound_pool_create()
+ * @pre Load source to @a pool by calling sound_pool_load_source_from_file()
+ * @post When playback is finished normally (i.e. sound_pool_stream_stop()
  *       will be not used for stream termination) state will be changed to
  *       SOUND_POOL_STREAM_STATE_FINISHED and memory will be cleared from the
  *       stream allocated resources automatically
  *
  * @see sound_pool_create()
  * @see sound_pool_load_source_from_file()
- * @see sound_pool_set_volume
- * @see sound_pool_get_volume
+ * @see sound_pool_set_volume()
+ * @see sound_pool_get_volume()
  */
 sound_pool_error_e sound_pool_stream_play(sound_pool_h pool, const char *tag,
                unsigned loop, float volume, unsigned priority,
@@ -390,9 +390,9 @@ sound_pool_error_e sound_pool_stream_play(sound_pool_h pool, const char *tag,
  * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation or stream is in
  *         the state which is not allowed for pause operation
  *
- * @pre Create sound @a pool handler by calling @ref sound_pool_create()
- * @pre Load source to @a pool by calling @ref sound_pool_load_source_from_file()
- * @pre Start stream playback by calling @ref sound_pool_stream_play()
+ * @pre Create sound @a pool handler by calling sound_pool_create()
+ * @pre Load source to @a pool by calling sound_pool_load_source_from_file()
+ * @pre Start stream playback by calling sound_pool_stream_play()
  *
  * @see sound_pool_create()
  * @see sound_pool_load_source_from_file()
@@ -416,10 +416,10 @@ sound_pool_error_e sound_pool_stream_pause(sound_pool_h pool, unsigned id);
  * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation or stream is in
  *         the state which is not allowed for resume operation
  *
- * @pre Create sound @a pool handler by calling @ref sound_pool_create()
- * @pre Load source to @a pool by calling @ref sound_pool_load_source_from_file()
- * @pre Start stream playback by calling @ref sound_pool_stream_play()
- * @pre Pause stream playback by calling @ref sound_pool_stream_pause()
+ * @pre Create sound @a pool handler by calling sound_pool_create()
+ * @pre Load source to @a pool by calling sound_pool_load_source_from_file()
+ * @pre Start stream playback by calling sound_pool_stream_play()
+ * @pre Pause stream playback by calling sound_pool_stream_pause()
  *
  * @see sound_pool_create()
  * @see sound_pool_load_source_from_file()
@@ -447,9 +447,9 @@ sound_pool_error_e sound_pool_stream_resume(sound_pool_h pool, unsigned id);
  * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation or stream is in
  *         the state which is not allowed for stop operation
  *
- * @pre Create sound pool handler by calling @ref sound_pool_create()
- * @pre Load source to @a pool by calling @ref sound_pool_load_source_from_file()
- * @pre Start stream playback by calling @ref sound_pool_stream_play()
+ * @pre Create sound pool handler by calling sound_pool_create()
+ * @pre Load source to @a pool by calling sound_pool_load_source_from_file()
+ * @pre Start stream playback by calling sound_pool_stream_play()
  *
  * @see sound_pool_create()
  * @see sound_pool_load_source_from_file()
@@ -472,9 +472,9 @@ sound_pool_error_e sound_pool_stream_stop(sound_pool_h pool, unsigned id);
  *         exist in pool
  * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation
  *
- * @pre Create sound @a pool handler by calling @ref sound_pool_create()
- * @pre Load source to @a pool by calling @ref sound_pool_load_source_from_file()
- * @pre Start stream playback by calling @ref sound_pool_stream_play()
+ * @pre Create sound @a pool handler by calling sound_pool_create()
+ * @pre Load source to @a pool by calling sound_pool_load_source_from_file()
+ * @pre Start stream playback by calling sound_pool_stream_play()
  *
  * @see sound_pool_create()
  * @see sound_pool_load_source_from_file()
@@ -498,9 +498,9 @@ sound_pool_error_e sound_pool_stream_set_loop(sound_pool_h pool, unsigned id,
  * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No streams identified by @a id
  *         exist in pool
  *
- * @pre Create sound @a pool handler by calling @ref sound_pool_create()
- * @pre Load source to @a pool by calling @ref sound_pool_load_source_from_file()
- * @pre Start source playback by calling @ref sound_pool_stream_play()
+ * @pre Create sound @a pool handler by calling sound_pool_create()
+ * @pre Load source to @a pool by calling sound_pool_load_source_from_file()
+ * @pre Start source playback by calling sound_pool_stream_play()
  *
  * @see sound_pool_create()
  * @see sound_pool_load_source_from_file()
@@ -524,9 +524,9 @@ sound_pool_error_e sound_pool_stream_get_loop(sound_pool_h pool, unsigned id,
  *         exist in pool
  * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation
  *
- * @pre Create sound @a pool handler by calling @ref sound_pool_create()
- * @pre Load source to @a pool by calling @ref sound_pool_load_source_from_file()
- * @pre Start stream playback by calling @ref sound_pool_stream_play()
+ * @pre Create sound @a pool handler by calling sound_pool_create()
+ * @pre Load source to @a pool by calling sound_pool_load_source_from_file()
+ * @pre Start stream playback by calling sound_pool_stream_play()
  *
  * @see sound_pool_create()
  * @see sound_pool_load_source_from_file()
@@ -550,9 +550,9 @@ sound_pool_error_e sound_pool_stream_set_volume(sound_pool_h pool, unsigned id,
  * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No streams identified by @a id
  *         exist in pool
  *
- * @pre Create sound @a pool handler by calling @ref sound_pool_create()
- * @pre Load source to @a pool by calling @ref sound_pool_load_source_from_file()
- * @pre Start stream playback by calling @ref sound_pool_stream_play()
+ * @pre Create sound @a pool handler by calling sound_pool_create()
+ * @pre Load source to @a pool by calling sound_pool_load_source_from_file()
+ * @pre Start stream playback by calling sound_pool_stream_play()
  *
  * @see sound_pool_create()
  * @see sound_pool_load_source_from_file()
@@ -595,9 +595,9 @@ sound_pool_error_e sound_pool_stream_get_volume(sound_pool_h pool, unsigned id,
  *         exist in pool
  * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation
  *
- * @pre Create sound @a pool handler by calling @ref sound_pool_create()
- * @pre Load source to @a pool by calling @ref sound_pool_load_source_from_file()
- * @pre Start stream playback by calling @ref sound_pool_stream_play()
+ * @pre Create sound @a pool handler by calling sound_pool_create()
+ * @pre Load source to @a pool by calling sound_pool_load_source_from_file()
+ * @pre Start stream playback by calling sound_pool_stream_play()
  *
  * @see sound_pool_create()
  * @see sound_pool_load_source_from_file()
@@ -613,7 +613,7 @@ sound_pool_error_e sound_pool_stream_set_priority(sound_pool_h pool, unsigned id
  * @param [in]   pool        The handle to the sound pool
  * @param [in]   id          Unique stream identifier
  * @param [out]  priority    Stream priority (0 = lowest priority). Check
- *                           @ref sound_pool_stream_set_priority() documentation
+ *                           sound_pool_stream_set_priority() documentation
  *                           for details on prioritization rules.
  * @return @c 0 on success, otherwise a negative error value
  * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter
@@ -621,9 +621,9 @@ sound_pool_error_e sound_pool_stream_set_priority(sound_pool_h pool, unsigned id
  * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No streams identified by @a id
  *         exist in pool
  *
- * @pre Create sound @a pool handler by calling @ref sound_pool_create()
- * @pre Load source to @a pool by calling @ref sound_pool_load_source_from_file()
- * @pre Start stream playback by calling @ref sound_pool_stream_play()
+ * @pre Create sound @a pool handler by calling sound_pool_create()
+ * @pre Load source to @a pool by calling sound_pool_load_source_from_file()
+ * @pre Start stream playback by calling sound_pool_stream_play()
  *
  * @see sound_pool_create()
  * @see sound_pool_load_source_from_file()
@@ -645,9 +645,9 @@ sound_pool_error_e sound_pool_stream_get_priority(sound_pool_h pool, unsigned id
  * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No streams identified by @a id
  *         exist in pool
  *
- * @pre Create sound pool handler by calling @ref sound_pool_create()
- * @pre Load source to @a pool by calling @ref sound_pool_load_source_from_file()
- * @pre Start stream playback by calling @ref sound_pool_stream_play()
+ * @pre Create sound pool handler by calling sound_pool_create()
+ * @pre Load source to @a pool by calling sound_pool_load_source_from_file()
+ * @pre Start stream playback by calling sound_pool_stream_play()
  *
  * @see sound_pool_create()
  * @see sound_pool_load_source_from_file()
@@ -674,10 +674,10 @@ sound_pool_error_e sound_pool_stream_get_state(sound_pool_h pool, unsigned id,
  *         exist in pool
  * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation
  *
- * @pre Create sound pool handler by calling @ref sound_pool_create()
- * @pre Load source to pool by calling @ref sound_pool_load_source_from_file()
- * @pre Start source playback by calling @ref sound_pool_stream_play()
- * @post Use @ref sound_pool_stream_unset_state_change_callback() function to
+ * @pre Create sound pool handler by calling sound_pool_create()
+ * @pre Load source to pool by calling sound_pool_load_source_from_file()
+ * @pre Start source playback by calling sound_pool_stream_play()
+ * @post Use sound_pool_stream_unset_state_change_callback() function to
  *       unset the @a callback
  *
  * @see sound_pool_create()
@@ -700,10 +700,10 @@ sound_pool_error_e sound_pool_stream_set_state_change_callback(sound_pool_h pool
  * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No streams identified by @a id
  *         exist in pool
  *
- * @pre Create sound @a pool handler by calling @ref sound_pool_create()
- * @pre Load source to @a pool by calling @ref sound_pool_load_source_from_file()
- * @pre Start stream playback by calling @ref sound_pool_stream_play()
- * @pre Set stream state change callback by calling @ref sound_pool_stream_set_state_change_callback()
+ * @pre Create sound @a pool handler by calling sound_pool_create()
+ * @pre Load source to @a pool by calling sound_pool_load_source_from_file()
+ * @pre Start stream playback by calling sound_pool_stream_play()
+ * @pre Set stream state change callback by calling sound_pool_stream_set_state_change_callback()
  *
  * @see sound_pool_create()
  * @see sound_pool_load_source_from_file()
index 58df7ae..d8ed038 100644 (file)
@@ -582,6 +582,10 @@ sound_pool_error_e _sound_stream_set_priority_policy(sound_stream_t *stream,
        SP_INST_CHECK(stream->parent_source->parent_pool->mgr_priority,
                        SOUND_POOL_ERROR_INVALID_PARAMETER);
 
+       SP_RETVM_IF((priority_policy > SOUND_POOL_STREAM_PRIORITY_POLICY_SUSPENDED),
+                       SOUND_POOL_ERROR_INVALID_PARAMETER,
+                       "Priority policy can be 0 or 1.");
+
 
        stream->priority_policy = priority_policy;