From: aravind.gara Date: Thu, 20 Jul 2017 07:07:08 +0000 (+0900) Subject: Modified as per ACR comments X-Git-Tag: accepted/tizen/4.0/unified/20170816.011957^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=54d538e29835dae1c6ba1f19e98b1e3f28a46807;p=platform%2Fcore%2Fapi%2Fsound-pool.git Modified as per ACR comments http://suprem.sec.samsung.net/jira/browse/ACR-971 Change-Id: I12f63dedffea8e8b3705a4ff87fe78e782842221 Signed-off-by: aravind.gara --- diff --git a/include/internal/soundpool.h b/include/internal/soundpool.h index de9c9cf..12fba91 100644 --- a/include/internal/soundpool.h +++ b/include/internal/soundpool.h @@ -47,7 +47,7 @@ typedef struct sound_pool_s { sound_pool_state_e state; struct { - sound_pool_state_change_cb callback; + sound_pool_state_changed_cb callback; void *user_data; } state_cb_info; @@ -73,7 +73,7 @@ sound_pool_error_e _sound_pool_set_volume(sound_pool_t *pool, float volume); sound_pool_error_e _sound_pool_get_volume(sound_pool_t *pool, float *volume); sound_pool_error_e _sound_pool_set_callback(sound_pool_t *pool, - sound_pool_state_change_cb callback, void *data); + sound_pool_state_changed_cb callback, void *data); sound_pool_error_e _sound_pool_unset_callback(sound_pool_t *pool); diff --git a/include/internal/stream.h b/include/internal/stream.h index bfaad54..43e0c34 100644 --- a/include/internal/stream.h +++ b/include/internal/stream.h @@ -50,7 +50,7 @@ typedef struct sound_stream_s { gboolean suspended; struct { - sound_pool_stream_state_change_cb callback; + sound_pool_stream_state_changed_cb callback; void *user_data; } state_cb_info; @@ -59,7 +59,7 @@ typedef struct sound_stream_s { sound_pool_error_e _sound_stream_create(sound_source_t *src, unsigned loop, float volume, unsigned priority, sound_pool_stream_priority_policy_e priority_policy, - sound_pool_stream_state_change_cb cb, void *data, sound_stream_t **stream); + sound_pool_stream_state_changed_cb cb, void *data, sound_stream_t **stream); sound_pool_error_e _sound_stream_destroy(sound_stream_t *src); @@ -92,7 +92,7 @@ sound_pool_error_e _sound_stream_get_state(sound_stream_t *stream, sound_pool_stream_state_e *state); sound_pool_error_e _sound_stream_set_callback(sound_stream_t *stream, - sound_pool_stream_state_change_cb callback, void *data); + sound_pool_stream_state_changed_cb callback, void *data); sound_pool_error_e _sound_stream_unset_callback(sound_stream_t *stream); diff --git a/include/sound_pool.h b/include/sound_pool.h index 9446665..bb00208 100644 --- a/include/sound_pool.h +++ b/include/sound_pool.h @@ -17,7 +17,7 @@ #ifndef __TIZEN_SOUND_POOL_H__ #define __TIZEN_SOUND_POOL_H__ -#include "sound_pool_type.h" +#include #ifdef __cplusplus extern "C" { @@ -34,333 +34,349 @@ extern "C" { */ /** - * @brief Called when sound pool state is changed. + * @brief Called when the sound pool state is changed. * * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @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 - * sound_pool_set_state_change_callback() was - * called. + * @remarks @a pool is the object for which the callback was set. + * @param[in] pool The sound pool handle + * @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 + * sound_pool_set_state_changed_cb() was + * called. * - * @pre Create sound pool handler by calling sound_pool_create() - * @pre Call sound_pool_set_state_change_callback() + * @pre Create sound pool handle by calling sound_pool_create() + * @pre Call sound_pool_set_state_changed_cb() * * @see sound_pool_create() - * @see sound_pool_set_state_change_callback() + * @see sound_pool_set_state_changed_cb() * @see sound_pool_state_e */ -typedef void (*sound_pool_state_change_cb) (sound_pool_h pool, +typedef void (*sound_pool_state_changed_cb) (sound_pool_h pool, sound_pool_state_e prev_state, sound_pool_state_e cur_state, void *user_data); /** - * @brief Called when sound pool stream state is changed. + * @brief Called when the sound pool stream state is changed. * * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [in] tag Unique string that identifies source which was used - * for stream creation - * @param [in] id Unique stream identifier - * @param [in] prev_state Previous stream state - * @param [in] cur_state Current stream state - * @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 sound_pool_create() + * @remarks @a pool is the object for which the callback was set. + * @param[in] pool The sound pool handle + * @param[in] id Unique stream identifier + * @param[in] prev_state Previous stream state + * @param[in] cur_state Current stream state + * @param[in] user_data The user data passed to the callback + * + * @pre Create sound pool handle 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() * @see sound_pool_stream_play() - * @see sound_pool_stream_set_state_change_callback() * @see sound_pool_stream_state_e */ -typedef void (*sound_pool_stream_state_change_cb) (sound_pool_h pool, - const char *tag, unsigned id, sound_pool_stream_state_e prev_state, +typedef void (*sound_pool_stream_state_changed_cb) (sound_pool_h pool, + unsigned id, sound_pool_stream_state_e prev_state, sound_pool_stream_state_e cur_state, void *user_data); /** - * @brief Creates sound pool instance that can be used for sound sources + * @brief Creates a sound pool instance that can be used for sound sources * loading/unloading. * @details Up to 32 sound pools can be created. Several pools can be active * at the same time. Streams can be in playing state only when pool is * active. + * @since_tizen 4.0 * @remarks When pool has been created, pool state is - * SOUND_POOL_STATE_INACTIVE. To activate a pool use + * #SOUND_POOL_STATE_INACTIVE. To activate the pool use * sound_pool_activate() function. + * When no longer needed, @a pool should be destroyed with sound_pool_destroy(). * - * @since_tizen 4.0 - * @param [out] pool The handle to the pool that will be created + * @param[out] pool The created sound pool handle * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER * Invalid parameter (@a pool is NULL) * @retval #SOUND_POOL_ERROR_OUT_OF_MEMORY * Not enough memory to create sound pool * @retval #SOUND_POOL_ERROR_INVALID_OPERATION - * Maximal amount of sound pools is exceeded (usually, 32 pools allowed) + * Maximal amount of sound pools is exceeded (maximum 32 pools allowed) * * @see sound_pool_destroy() */ -sound_pool_error_e sound_pool_create(sound_pool_h *pool); +int sound_pool_create(sound_pool_h *pool); /** - * @brief Destroys sound pool and cleans allocated memory. + * @brief Destroys a sound pool and cleans allocated memory. * @details Stops all streams and unloads all sources associated with pool. * * @since_tizen 4.0 - * @param [in] pool The handle to the pool that will be destroyed + * @remarks @a pool should be destroyed with sound_pool_destroy(). + * @param[in] pool The sound pool handle will be destroyed * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER * Invalid parameter (@a pool is NULL or corrupted) * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation * - * @pre Create sound pool handler by calling sound_pool_create() + * @pre Create sound pool handle by calling sound_pool_create() * * @see sound_pool_create() */ -sound_pool_error_e sound_pool_destroy(sound_pool_h pool); +int sound_pool_destroy(sound_pool_h pool); /** - * @brief Loads sound source data from file to pool. + * @brief Loads sound source data from a file to the pool. * @details After calling this routine the source can be accessed by its @a tag. + * @since_tizen 4.0 * @remarks Input data can be either raw or encoded. * Each of loaded sources must have unique @a tag * It is synchronous operation. * - * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [in] file_name The name of file that contains sound data - * @param [in] tag Unique string that will be used to identify source + * @param[in] pool The sound pool handle + * @param[in] file_name The name of the file that contains sound data + * @param[in] tag Unique string that will be used to identify source * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER * Invalid parameter (@a pool is NULL or corrupted, @a file_name is * NULL, @a tag is NULL or @a tag/@a file_name length is too long) - * @retval #SOUND_POOL_ERROR_OUT_OF_MEMORY Not enough memory to allocate source - * @retval #SOUND_POOL_ERROR_NO_SUCH_FILE No file determined by @a file_name + * @retval #SOUND_POOL_ERROR_OUT_OF_MEMORY Not enough memory to allocate source + * @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 sound_pool_create() - * @post Unload source from pool by calling sound_pool_unload_source() + * @pre Create a sound @a pool handle by calling sound_pool_create() + * @post Unload source from the pool by calling sound_pool_unload_source() * * @see sound_pool_create() * @see sound_pool_destroy() * @see sound_pool_unload_source() */ -sound_pool_error_e sound_pool_load_source_from_file(sound_pool_h pool, +int sound_pool_load_source_from_file(sound_pool_h pool, const char *file_name, const char *tag); /** - * @brief Unloads source from @a pool. - * @details Cleans memory. It is synchronous operation. + * @brief Unloads source from the @a pool. + * @details Cleans memory. This operation is synchronous. + * @since_tizen 4.0 * @remarks The usage of @a tag name that was associated with unloaded source * has no effect. It can be reused as well. * - * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [in] tag Unique string that identifies source + * @param[in] pool The sound pool handle + * @param[in] tag Unique string that identifies the source * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER * Invalid parameter (@a pool is NULL or corrupted, @a tag is NULL) * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No sources tagged by @a tag exist - * in pool + * in the pool * - * @pre Create sound @a pool handler by calling sound_pool_create() - * @pre Load source to pool by calling sound_pool_load_source_from_file() + * @pre Create a sound @a pool handle by calling sound_pool_create() + * @pre Load source to the pool by calling sound_pool_load_source_from_file() * * @see sound_pool_create() * @see sound_pool_load_source_from_file() */ -sound_pool_error_e sound_pool_unload_source(sound_pool_h pool, const char *tag); +int sound_pool_unload_source(sound_pool_h pool, const char *tag); /** - * @brief Changes current @a state of @a pool to SOUND_POOL_STATE_ACTIVE. + * @brief Changes the current @a state of a @a pool to #SOUND_POOL_STATE_ACTIVE. + * @since_tizen 4.0 * @remarks When activation is performed, all suspended streams with highest * priority in the pool will resume their playback. Paused streams will * remain their state. * - * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool + * @param[in] pool The sound pool handle * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter * (@a pool is NULL or corrupted) * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation or sound pool - * is already in @c SOUND_POOL_STATE_ACTIVE state + * is already in #SOUND_POOL_STATE_ACTIVE state * - * @pre Create sound @a pool handler by calling sound_pool_create() + * @pre Create a sound @a pool handle by calling sound_pool_create() * * @see sound_pool_create() * @see sound_pool_get_state() * @see sound_pool_deactivate() * @see sound_pool_state_e */ -sound_pool_error_e sound_pool_activate(sound_pool_h pool); +int sound_pool_activate(sound_pool_h pool); /** - * @brief Changes current @a state of @a pool to SOUND_POOL_STATE_INACTIVE. + * @brief Changes the current @a state of a @a pool to #SOUND_POOL_STATE_INACTIVE. + * @since_tizen 4.0 * @remarks When deactivation is performed, all playing streams in the pool will - * be suspended (change state to SOUND_POOL_STREAM_STATE_SUSPENDED). - * Paused streams will remain their state. + * be suspended (change state to #SOUND_POOL_STREAM_STATE_SUSPENDED). + * Paused streams will remain in their state. * - * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool + * @param[in] pool The sound pool handle * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter * (@a pool is NULL or corrupted) * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation or sound pool - * is already in @c SOUND_POOL_STATE_INACTIVE state + * is already in @c #SOUND_POOL_STATE_INACTIVE state * - * @pre Create sound @a pool handler by calling sound_pool_create() - * @pre @a pool has to be in SOUND_POOL_STATE_ACTIVE state + * @pre Create a sound @a pool handle by calling sound_pool_create() + * @pre @a pool has to be in #SOUND_POOL_STATE_ACTIVE state * * @see sound_pool_create() * @see sound_pool_get_state() * @see sound_pool_activate() * @see sound_pool_state_e */ -sound_pool_error_e sound_pool_deactivate(sound_pool_h pool); +int sound_pool_deactivate(sound_pool_h pool); /** - * @brief Sets pool global volume parameter. - * @details Volume of all streams related to @a pool will be scaled + * @brief Sets the pool's global volume parameter. + * @details Volume of all streams related to the @a pool will be scaled * in accordance to global pool volume parameter * (i.e. [stream real volume] = [global volume] * [stream volume], * where [stream volume] is the volume parameter of arbitrary stream). * * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [in] volume Pool global volume in 0.0~1.0 range + * @param[in] pool The sound pool handle + * @param[in] volume Pool global volume in 0.0~1.0 range * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter * (@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 sound_pool_create() + * @pre Create a sound @a pool handle by calling sound_pool_create() * * @see sound_pool_create() */ -sound_pool_error_e sound_pool_set_volume(sound_pool_h pool, float volume); +int sound_pool_set_volume(sound_pool_h pool, float volume); /** - * @brief Gets pool global volume parameter. + * @brief Gets the pool's global volume parameter. * * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [out] volume Pool global volume in 0.0~1.0 range + * @param[in] pool The sound pool handle + * @param[out] volume Pool global volume in 0.0~1.0 range * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @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 sound_pool_create() + * @pre Create a sound @a pool handle by calling sound_pool_create() * * @see sound_pool_create() */ -sound_pool_error_e sound_pool_get_volume(sound_pool_h pool, float *volume); +int sound_pool_get_volume(sound_pool_h pool, float *volume); /** - * @brief Gets current @a state of @a pool. + * @brief Gets the current @a state of @a pool. * * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [out] state Current state of @a pool + * @param[in] pool The sound pool handle + * @param[out] state Current state of @a pool * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @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 sound_pool_create() + * @pre Create a sound @a pool handle by calling sound_pool_create() * * @see sound_pool_create() * @see sound_pool_state_e */ -sound_pool_error_e sound_pool_get_state(sound_pool_h pool, +int sound_pool_get_state(sound_pool_h pool, sound_pool_state_e *state); /** - * @brief Sets callback for handling sound @a pool state change. + * @brief Sets the callback for handling sound @a pool state change. * * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [in] callback The callback that will be called after pool state - * will be changed. @a callback will be called - * synchronously - * @param [in] user_data The user data to be passed to the @a callback + * @param[in] pool The sound pool handle + * @param[in] callback The callback that will be called after pool state + * will be changed. @a callback will be called + * synchronously + * @param[in] user_data The user data to be passed to the @a callback * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @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 sound_pool_create() - * @post Use sound_pool_unset_state_change_callback() function to unset the + * @pre Create a sound @a pool handle by calling sound_pool_create() + * @post Use sound_pool_unset_state_changed_cb() function to unset the * @a callback * * @see sound_pool_create() * @see sound_pool_pool_state_change_cb */ -sound_pool_error_e sound_pool_set_state_change_callback(sound_pool_h pool, - sound_pool_state_change_cb callback, void *user_data); +int sound_pool_set_state_changed_cb(sound_pool_h pool, + sound_pool_state_changed_cb callback, void *user_data); /** - * @brief Unsets callback for handling sound @a pool state change. + * @brief Unsets the callback for handling sound @a pool state change. * * @since_tizen 4.0 - * @param [in] pool The handle to the pool + * @param[in] pool The sound pool handle * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter * (@a pool is NULL or corrupted) * - * @pre Create sound @a pool handler by calling sound_pool_create() + * @pre Create a sound @a pool handle by calling sound_pool_create() * @pre Set state change callback by calling - * sound_pool_set_state_change_callback() + * sound_pool_set_state_changed_cb() * * @see sound_pool_create() - * @see sound_pool_set_state_change_callback() + * @see sound_pool_set_state_changed_cb() */ -sound_pool_error_e sound_pool_unset_state_change_callback(sound_pool_h pool); +int sound_pool_unset_state_changed_cb(sound_pool_h pool); /** - * @brief Plays source by @a tag. + * @brief Plays a source by @a tag. * @details Creates stream with @a id that can be used to change parameters and * get additional information. - * Sets stream state to SOUND_POOL_STREAM_STATE_PLAYING + * Sets stream state to #SOUND_POOL_STREAM_STATE_PLAYING. + * If a callback is set with sound_pool_stream_play(), and another + * callback is set with sound_pool_stream_set_state_changed_cb(), + * the second callback will overwrite the first one. + * @since_tizen 4.0 * @remarks Resultant stream volume will depend on global pool volume. * - * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [in] tag Unique string that identifies source - * @param [in] loop Number of times stream will be repeated - * (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 - * sound_pool_stream_set_priority() documentation - * for details on prioritization rules. - * @param [in] priority_policy Stream priority policy. - * (#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 - * be called asynchronously - * @param [in] user_data The user data to be passed to the @a callback - * @param [out] id Unique stream identifier that can be used to - * change parameters and get additional information + * @param[in] pool The sound pool handle + * @param[in] tag Unique string that identifies source + * @param[in] loop Number of times stream will be repeated + * (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 + * sound_pool_stream_set_priority() documentation + * for details on prioritization rules. + * @param[in] priority_policy Stream priority policy.\n + * (#SOUND_POOL_STREAM_PRIORITY_POLICY_MUTE - Mute)\n + * (#SOUND_POOL_STREAM_PRIORITY_POLICY_SUSPENDED - Suspended)\n + * If priority_policy is set to Mute, the stream will be + * playing with mute even in the presence of high priority + * stream and it will not be 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 + * be called asynchronously. + * @param[in] user_data The user data to be passed to the @a callback + * @param[out] id Unique stream identifier that can be used to + * change parameters and get additional information * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter * (@a pool is NULL or corrupted, @a tag is NULL, @a volume is out of * 0.0~1.0 range, or @a id is NULL) * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No sources tagged by @a tag exist - * in pool + * in the pool * @retval #SOUND_POOL_ERROR_OUT_OF_MEMORY Not enough memory to allocate new * sound stream * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation * - * @pre Create sound pool handler by calling sound_pool_create() + * @pre Create sound pool handle 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 + * #SOUND_POOL_STREAM_STATE_FINISHED and memory will be cleared from the * stream allocated resources automatically * * @see sound_pool_create() @@ -368,29 +384,30 @@ sound_pool_error_e sound_pool_unset_state_change_callback(sound_pool_h pool); * @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, +int sound_pool_stream_play(sound_pool_h pool, const char *tag, unsigned loop, float volume, unsigned priority, sound_pool_stream_priority_policy_e priority_policy, - sound_pool_stream_state_change_cb callback, void *user_data, + sound_pool_stream_state_changed_cb callback, void *user_data, unsigned *id); /** - * @brief Pauses stream by @a id. - * @details Sets stream state to SOUND_POOL_STREAM_STATE_PAUSED. - * @remarks Stream state has to be SOUND_POOL_STATE_PLAYING - * + * @brief Pauses a stream by @a id. + * @details Sets stream state to #SOUND_POOL_STREAM_STATE_PAUSED. * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [in] id Unique stream identifier + * @remarks Stream state has to be #SOUND_POOL_STATE_PLAYING + * + * @param[in] pool The sound pool handle + * @param[in] id Unique stream identifier * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter * (@a pool is NULL or corrupted) * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No streams identified by @a id - * exist in pool + * exist in the pool * @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 sound_pool_create() + * @pre Create a sound @a pool handle 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() * @@ -398,25 +415,26 @@ sound_pool_error_e sound_pool_stream_play(sound_pool_h pool, const char *tag, * @see sound_pool_load_source_from_file() * @see sound_pool_stream_play() */ -sound_pool_error_e sound_pool_stream_pause(sound_pool_h pool, unsigned id); +int sound_pool_stream_pause(sound_pool_h pool, unsigned id); /** - * @brief Resumes stream by @a id. - * @details Sets stream state to SOUND_POOL_STREAM_STATE_PLAYING. - * @remarks Stream state has to be SOUND_POOL_STATE_PAUSED - * + * @brief Resumes a stream by @a id. + * @details Sets stream state to #SOUND_POOL_STREAM_STATE_PLAYING. * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [in] id Unique stream identifier + * @remarks Stream state has to be #SOUND_POOL_STATE_PAUSED + * + * @param[in] pool The sound pool handle + * @param[in] id Unique stream identifier * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter * (@a pool is NULL or corrupted) * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No streams identified by @a id - * exist in pool + * exist in the pool * @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 sound_pool_create() + * @pre Create a sound @a pool handle 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() @@ -426,28 +444,29 @@ sound_pool_error_e sound_pool_stream_pause(sound_pool_h pool, unsigned id); * @see sound_pool_stream_play() * @see sound_pool_stream_pause() */ -sound_pool_error_e sound_pool_stream_resume(sound_pool_h pool, unsigned id); +int sound_pool_stream_resume(sound_pool_h pool, unsigned id); /** - * @brief Stops stream by @a id. - * @details Sets stream state to SOUND_POOL_STREAM_STATE_STOPPED. + * @brief Stops a stream by @a id. + * @details Sets stream state to #SOUND_POOL_STREAM_STATE_STOPPED. * After stream was stopped it can not be resumed and @a id value * becomes invalid. Moreover, stream will never gets - * @c SOUND_POOL_STREAM_STATE_FINISHED state as it will be terminated + * #SOUND_POOL_STREAM_STATE_FINISHED state as it will be terminated * after this function call. * * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [in] id Unique stream identifier + * @param[in] pool The sound pool handle + * @param[in] id Unique stream identifier * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter * (@a pool is NULL or corrupted) * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No streams identified by @a id - * exist in pool + * exist in the pool * @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 sound_pool_create() + * @pre Create sound pool handle 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() * @@ -455,76 +474,25 @@ sound_pool_error_e sound_pool_stream_resume(sound_pool_h pool, unsigned id); * @see sound_pool_load_source_from_file() * @see sound_pool_stream_play() */ -sound_pool_error_e sound_pool_stream_stop(sound_pool_h pool, unsigned id); +int sound_pool_stream_stop(sound_pool_h pool, unsigned id); /** - * @brief Sets stream @a loop parameter by stream @a id. - * + * @brief Sets the stream's volume parameters by stream @a id. * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [in] id Unique stream identifier - * @param [in] loop Number of times stream will be repeated - * (pass 0 if stream should be repeated continuously) - * @return @c 0 on success, otherwise a negative error value - * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter - * (@a pool is NULL or corrupted) - * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No streams identified by @a id - * exist in pool - * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation - * - * @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() - * @see sound_pool_stream_play() - */ -sound_pool_error_e sound_pool_stream_set_loop(sound_pool_h pool, unsigned id, - unsigned loop); - -/** - * @brief Gets stream @a loop parameter by stream @a id. - * - * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [in] id Unique stream identifier - * @param [out] loop Number of times stream will be repeated before - * finishing (getting state SOUND_POOL_STREAM_STATE_FINISHED) - * and releasing of the memory and resources - * @return @c 0 on success, otherwise a negative error value - * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter - * (@a pool is NULL or corrupted, or @a loop is NULL) - * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No streams identified by @a id - * exist in pool - * - * @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() - * @see sound_pool_stream_play() - */ -sound_pool_error_e sound_pool_stream_get_loop(sound_pool_h pool, unsigned id, - unsigned *loop); - -/** - * @brief Sets stream volume parameters by stream @a id. * @remarks Resultant stream volume will depend on global pool volume. * - * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [in] id Unique stream identifier - * @param [in] volume Stream volume in 0.0~1.0 range + * @param[in] pool The sound pool handle + * @param[in] id Unique stream identifier + * @param[in] volume Stream volume in 0.0~1.0 range * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter * (@a pool is NULL or corrupted, or @a volume isn't in 0.0~1.0 range) * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No streams identified by @a id - * exist in pool + * exist in the pool * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation * - * @pre Create sound @a pool handler by calling sound_pool_create() + * @pre Create a sound @a pool handle 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() * @@ -534,23 +502,24 @@ sound_pool_error_e sound_pool_stream_get_loop(sound_pool_h pool, unsigned id, * @see sound_pool_set_volume * @see sound_pool_get_volume */ -sound_pool_error_e sound_pool_stream_set_volume(sound_pool_h pool, unsigned id, +int sound_pool_stream_set_volume(sound_pool_h pool, unsigned id, float volume); /** - * @brief Gets stream volume parameters by stream @a id. + * @brief Gets the stream's volume parameters by stream @a id. * * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [in] id Unique stream identifier - * @param [out] volume Stream volume in 0.0~1.0 range + * @param[in] pool The sound pool handle + * @param[in] id Unique stream identifier + * @param[out] volume Stream volume in 0.0~1.0 range * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter * (@a pool is NULL or corrupted, or @a volume is NULL) * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No streams identified by @a id - * exist in pool + * exist in the pool * - * @pre Create sound @a pool handler by calling sound_pool_create() + * @pre Create a sound @a pool handle 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() * @@ -558,44 +527,54 @@ sound_pool_error_e sound_pool_stream_set_volume(sound_pool_h pool, unsigned id, * @see sound_pool_load_source_from_file() * @see sound_pool_stream_play() */ -sound_pool_error_e sound_pool_stream_get_volume(sound_pool_h pool, unsigned id, +int sound_pool_stream_get_volume(sound_pool_h pool, unsigned id, float *volume); /** - * @brief Sets stream priority parameter by stream @a id. - * @remarks Only streams with highest priority in the active Sound Pool can be - * played. If at least one stream with highest priority gets - * #SOUND_POOL_STREAM_STATE_PLAYING state, then all has been playing - * streams with lower priorities will be transfered to the - * #SOUND_POOL_STREAM_STATE_SUSPENDED state. If there is no more - * playing streams in some priority group (group of streams with the - * same priority), then all suspended previously streams in the group - * with one level lower priority will be resumed. For example, if we - * have N suspended streams in 'LOW' group, M suspended streams in - * 'MEDIUM' group and K playing streams in 'HIGH' group then the - * following rules are valid: When all K streams in HIGH priority group - * will be finished, paused, or stopped and Sound Pool is in active - * state, only then M streams from MEDIUM priority group will be - * resumed. When all M+K streams from HIGH and MEDIUM priority groups - * will be finished, paused or stopped and Sound Pool is in active - * state, only then N streams from LOW priority group will be resumed. - * Transfering at least one stream from higher priority group will lead + * @brief Sets the stream's priority parameter by stream @a id. + * @since_tizen 4.0 + * @details The below rules are applicable for streams with priority policy + * #SOUND_POOL_STREAM_PRIORITY_POLICY_SUSPENDED. + * Only streams with highest priority in the active Sound Pool can be + * played. If at least one stream with highest priority enters + * #SOUND_POOL_STREAM_STATE_PLAYING state, then all streams currently + * being played with lower priorities will be transferred to the + * #SOUND_POOL_STREAM_STATE_SUSPENDED state. If there are no more + * playing streams in a given priority group (group of streams with the + * same priority), then all previously suspended streams in the group + * with one level lower priority will be resumed. + * + * For example, if we have N suspended streams in 'LOW' group, M + * suspended streams in 'MEDIUM' group and K playing streams in 'HIGH' + * group. Then the following rules are valid: When all K streams in HIGH + * priority group will be finished, paused, or stopped and Sound Pool is + * in active state, only then M streams from MEDIUM priority group will + * be resumed. When all M+K streams from HIGH and MEDIUM priority groups + * are finished, paused or stopped and Sound Pool is in active state, + * only then N streams from LOW priority group will be resumed. + * Transferring at least one stream from higher priority group will lead * to suspending of all the streams from lower priorities group(s). - * Priorities don't make any effect in inactive Sound Pools. But after + * + * Priorities don't take any effect in inactive Sound Pools. But after * pool activation, all mentioned rules will be applied. * - * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [in] id Unique stream identifier - * @param [in] priority Stream priority (0 = lowest priority) + * If stream priority policy is set to mute + * #SOUND_POOL_STREAM_PRIORITY_POLICY_MUTE, all above rules are not valid + * for the stream and it will be played with mute even in the presence + * of high priority steams. + * streams. + * @param[in] pool The sound pool handle + * @param[in] id Unique stream identifier + * @param[in] priority Stream priority (0 = lowest priority) * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter * (@a pool is NULL or corrupted) * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No streams identified by @a id - * exist in pool + * exist in the pool * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation * - * @pre Create sound @a pool handler by calling sound_pool_create() + * @pre Create a sound @a pool handle 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() * @@ -603,25 +582,26 @@ sound_pool_error_e sound_pool_stream_get_volume(sound_pool_h pool, unsigned id, * @see sound_pool_load_source_from_file() * @see sound_pool_stream_play() */ -sound_pool_error_e sound_pool_stream_set_priority(sound_pool_h pool, unsigned id, +int sound_pool_stream_set_priority(sound_pool_h pool, unsigned id, unsigned priority); /** - * @brief Gets stream priority parameter by stream @a id. + * @brief Gets the stream's priority parameter by stream @a id. * * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [in] id Unique stream identifier - * @param [out] priority Stream priority (0 = lowest priority). Check - * sound_pool_stream_set_priority() documentation - * for details on prioritization rules. + * @param[in] pool The sound pool handle + * @param[in] id Unique stream identifier + * @param[out] priority Stream priority (0 = lowest priority). Check + * 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_NONE Successful * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter * (@a pool is NULL or corrupted, or @a priority is NULL) * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No streams identified by @a id - * exist in pool + * exist in the pool * - * @pre Create sound @a pool handler by calling sound_pool_create() + * @pre Create a sound @a pool handle 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() * @@ -629,23 +609,24 @@ sound_pool_error_e sound_pool_stream_set_priority(sound_pool_h pool, unsigned id * @see sound_pool_load_source_from_file() * @see sound_pool_stream_play() */ -sound_pool_error_e sound_pool_stream_get_priority(sound_pool_h pool, unsigned id, +int sound_pool_stream_get_priority(sound_pool_h pool, unsigned id, unsigned *priority); /** - * @brief Gets current @a state of stream by @a id. + * @brief Gets the current @a state of stream by @a id. * * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [in] id Unique stream identifier - * @param [out] state Current state of stream + * @param[in] pool The sound pool handle + * @param[in] id Unique stream identifier + * @param[out] state Current state of stream * @return @c 0 on success, otherwise a negative error value + * @retval #SOUND_POOL_ERROR_NONE Successful * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter * (@a pool is NULL or corrupted, or @a state is NULL) * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No streams identified by @a id - * exist in pool + * exist in the pool * - * @pre Create sound pool handler by calling sound_pool_create() + * @pre Create sound pool handle 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() * @@ -654,65 +635,8 @@ sound_pool_error_e sound_pool_stream_get_priority(sound_pool_h pool, unsigned id * @see sound_pool_stream_play() * @see sound_pool_stream_state_e */ -sound_pool_error_e sound_pool_stream_get_state(sound_pool_h pool, unsigned id, +int sound_pool_stream_get_state(sound_pool_h pool, unsigned id, sound_pool_stream_state_e *state); - -/** - * @brief Sets callback for handling stream state change events. - * - * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [in] id Unique stream identifier - * @param [in] callback The callback that will be called after stream state - * will be changed. @a callback will be called - * asynchronously - * @param [in] user_data The user data to be passed to the @a callback - * @return @c 0 on success, otherwise a negative error value - * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter - * (@a pool is NULL or corrupted, or @a callback is NULL) - * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No streams identified by @a id - * exist in pool - * @retval #SOUND_POOL_ERROR_INVALID_OPERATION Invalid operation - * - * @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() - * @see sound_pool_load_source_from_file() - * @see sound_pool_stream_play() - * @see sound_pool_stream_state_change_cb - */ -sound_pool_error_e sound_pool_stream_set_state_change_callback(sound_pool_h pool, - unsigned id, sound_pool_stream_state_change_cb callback, void *user_data); - -/** - * @brief Unsets callback for handling stream state change events. - * - * @since_tizen 4.0 - * @param [in] pool The handle to the sound pool - * @param [in] id Unique stream identifier - * @return @c 0 on success, otherwise a negative error value - * @retval #SOUND_POOL_ERROR_INVALID_PARAMETER Invalid parameter - * (@a pool is NULL or corrupted) - * @retval #SOUND_POOL_ERROR_KEY_NOT_AVAILABLE No streams identified by @a id - * exist in pool - * - * @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() - * @see sound_pool_stream_play() - * @see sound_pool_stream_state_change_cb - */ -sound_pool_error_e sound_pool_stream_unset_state_change_callback(sound_pool_h pool, - unsigned id); - /** * @} */ diff --git a/include/sound_pool_type.h b/include/sound_pool_type.h index 40fc6f7..e5d209d 100644 --- a/include/sound_pool_type.h +++ b/include/sound_pool_type.h @@ -17,7 +17,7 @@ #ifndef __TIZEN_SOUND_POOL_TYPE_H__ #define __TIZEN_SOUND_POOL_TYPE_H__ -#include "tizen.h" +#include #ifdef __cplusplus extern "C" { @@ -42,12 +42,6 @@ extern "C" { typedef enum { SOUND_POOL_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - SOUND_POOL_ERROR_NOT_SUPPORTED - = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */ - SOUND_POOL_ERROR_MSG_TOO_LONG - = TIZEN_ERROR_MSG_TOO_LONG, /**< Message too long */ - SOUND_POOL_ERROR_NO_DATA - = TIZEN_ERROR_NO_DATA, /**< No data */ SOUND_POOL_ERROR_KEY_NOT_AVAILABLE = TIZEN_ERROR_KEY_NOT_AVAILABLE, /**< Key not available */ SOUND_POOL_ERROR_OUT_OF_MEMORY @@ -56,7 +50,7 @@ typedef enum { = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ SOUND_POOL_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */ - SOUND_POOL_ERROR_PERMISSION_DENIED + SOUND_POOL_ERROR_NOT_PERMITTED = TIZEN_ERROR_NOT_PERMITTED, /**< Not permitted */ SOUND_POOL_ERROR_NO_SUCH_FILE = TIZEN_ERROR_NO_SUCH_FILE, /**< File not found */ @@ -90,7 +84,7 @@ typedef enum { * @since_tizen 4.0 */ typedef enum { - SOUND_POOL_STREAM_PRIORITY_POLICY_MUTE, /**< Stream priority policy is mute */ + SOUND_POOL_STREAM_PRIORITY_POLICY_MUTE, /**< Stream priority policy is mute */ SOUND_POOL_STREAM_PRIORITY_POLICY_SUSPENDED /**< Stream priority policy is suspended */ } sound_pool_stream_priority_policy_e; diff --git a/src/sound_pool.c b/src/sound_pool.c index 1cb7e77..398da4e 100644 --- a/src/sound_pool.c +++ b/src/sound_pool.c @@ -172,8 +172,8 @@ sound_pool_error_e sound_pool_get_state(sound_pool_h pool, sound_pool_state_e *s return ret; } -sound_pool_error_e sound_pool_set_state_change_callback(sound_pool_h pool, - sound_pool_state_change_cb callback, void *data) +sound_pool_error_e sound_pool_set_state_changed_cb(sound_pool_h pool, + sound_pool_state_changed_cb callback, void *data) { SP_DEBUG_FENTER(); @@ -185,7 +185,7 @@ sound_pool_error_e sound_pool_set_state_change_callback(sound_pool_h pool, return ret; } -sound_pool_error_e sound_pool_unset_state_change_callback(sound_pool_h pool) +sound_pool_error_e sound_pool_unset_state_changed_cb(sound_pool_h pool) { SP_DEBUG_FENTER(); @@ -202,7 +202,7 @@ sound_pool_error_e sound_pool_unset_state_change_callback(sound_pool_h pool) sound_pool_error_e sound_pool_stream_play(sound_pool_h pool, const char *tag, unsigned loop, float volume, unsigned priority, sound_pool_stream_priority_policy_e priority_policy, - sound_pool_stream_state_change_cb callback, void *data, unsigned *id) + sound_pool_stream_state_changed_cb callback, void *data, unsigned *id) { SP_DEBUG_FENTER(); SP_INST_CHECK(id, SOUND_POOL_ERROR_INVALID_PARAMETER); @@ -282,44 +282,6 @@ sound_pool_error_e sound_pool_stream_stop(sound_pool_h pool, unsigned id) return ret; } -sound_pool_error_e sound_pool_stream_set_loop(sound_pool_h pool, unsigned id, - unsigned loop) -{ - SP_DEBUG_FENTER(); - - sound_pool_t *_pool = (sound_pool_t *)pool; - sound_stream_t *_stream = NULL; - sound_pool_error_e ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); - SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " - "getting sound stream [%u] from the sound pool", id); - - ret = _sound_stream_set_loop(_stream, loop); - SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " - "setting sound stream [%u] loop parameter", id); - - SP_DEBUG_FLEAVE(); - return ret; -} - -sound_pool_error_e sound_pool_stream_get_loop(sound_pool_h pool, unsigned id, - unsigned *loop) -{ - SP_DEBUG_FENTER(); - - sound_pool_t *_pool = (sound_pool_t *)pool; - sound_stream_t *_stream = NULL; - sound_pool_error_e ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); - SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " - "getting sound stream [%u] from the sound pool", id); - - ret = _sound_stream_get_loop(_stream, loop); - SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " - "getting sound stream [%u] loop parameter", id); - - SP_DEBUG_FLEAVE(); - return ret; -} - sound_pool_error_e sound_pool_stream_set_volume(sound_pool_h pool, unsigned id, float volume) { @@ -414,42 +376,3 @@ sound_pool_error_e sound_pool_stream_get_state(sound_pool_h pool, unsigned id, SP_DEBUG_FLEAVE(); return ret; } - -sound_pool_error_e sound_pool_stream_set_state_change_callback( - sound_pool_h pool, unsigned id, - sound_pool_stream_state_change_cb callback, void *data) -{ - SP_DEBUG_FENTER(); - - sound_pool_t *_pool = (sound_pool_t *)pool; - sound_stream_t *_stream = NULL; - sound_pool_error_e ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); - SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " - "getting sound stream [%u] from the sound pool", id); - - ret = _sound_stream_set_callback(_stream, callback, data); - SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " - "setting sound stream [%u] state changing callback", id); - - SP_DEBUG_FLEAVE(); - return ret; -} - -sound_pool_error_e sound_pool_stream_unset_state_change_callback( - sound_pool_h pool, unsigned id) -{ - SP_DEBUG_FENTER(); - - sound_pool_t *_pool = (sound_pool_t *)pool; - sound_stream_t *_stream = NULL; - sound_pool_error_e ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); - SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " - "getting sound stream [%u] from the sound pool", id); - - ret = _sound_stream_unset_callback(_stream); - SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " - "unsetting sound stream [%u] state changing callback", id); - - SP_DEBUG_FLEAVE(); - return ret; -} diff --git a/src/soundpool.c b/src/soundpool.c index bbcd013..bcaf35c 100644 --- a/src/soundpool.c +++ b/src/soundpool.c @@ -289,7 +289,7 @@ sound_pool_error_e _sound_pool_get_volume(sound_pool_t *pool, float *volume) } sound_pool_error_e _sound_pool_set_callback(sound_pool_t *pool, - sound_pool_state_change_cb callback, void *data) + sound_pool_state_changed_cb callback, void *data) { SP_DEBUG_FENTER(); SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER); diff --git a/src/source.c b/src/source.c index 21de78d..733cd2d 100644 --- a/src/source.c +++ b/src/source.c @@ -103,7 +103,7 @@ static sound_pool_error_e __probe_file_access(const char *file, int amode) strerror_r(errno, errmsg, sizeof(errmsg)); SP_ERROR("Couldn`t open file in [%i] mode, reason [%s].", amode, errmsg); if (EACCES == errno) - ret = SOUND_POOL_ERROR_PERMISSION_DENIED; + ret = SOUND_POOL_ERROR_NOT_PERMITTED; else if (ENOENT == errno) ret = SOUND_POOL_ERROR_NO_SUCH_FILE; else diff --git a/src/stream.c b/src/stream.c index d8ed038..3d879c8 100644 --- a/src/stream.c +++ b/src/stream.c @@ -160,7 +160,7 @@ static sound_pool_error_e __sound_pool_remove_stream(sound_pool_t *pool, sound_s static sound_pool_error_e __sound_stream_init(sound_stream_t *stream, unsigned loop, float volume, unsigned priority, sound_pool_stream_priority_policy_e priority_policy, - sound_pool_stream_state_change_cb cb, void *data) + sound_pool_stream_state_changed_cb cb, void *data) { SP_DEBUG_FENTER(); sound_pool_error_e ret = SOUND_POOL_ERROR_NONE; @@ -193,7 +193,7 @@ static sound_pool_error_e __sound_stream_init(sound_stream_t *stream, sound_pool_error_e _sound_stream_create(sound_source_t *src, unsigned loop, float volume, unsigned priority, sound_pool_stream_priority_policy_e priority_policy, - sound_pool_stream_state_change_cb cb, + sound_pool_stream_state_changed_cb cb, void *data, sound_stream_t **stream) { SP_DEBUG_FENTER(); @@ -608,7 +608,7 @@ sound_pool_error_e _sound_stream_get_priority(sound_stream_t *stream, } sound_pool_error_e _sound_stream_set_callback(sound_stream_t *stream, - sound_pool_stream_state_change_cb callback, void *data) + sound_pool_stream_state_changed_cb callback, void *data) { SP_DEBUG_FENTER(); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); diff --git a/src/stream_cb_manager.c b/src/stream_cb_manager.c index 329b022..fa9e1f0 100644 --- a/src/stream_cb_manager.c +++ b/src/stream_cb_manager.c @@ -81,7 +81,6 @@ static gpointer __sound_pool_callback_isolator(gpointer user_data) sound_pool_t* _pool = cbmgr->pool; if (NULL != event_data->stream->state_cb_info.callback) { event_data->stream->state_cb_info.callback(_pool, - event_data->stream->parent_source->tag_name, event_data->stream->id, event_data->state_previous, event_data->state, event_data->stream->state_cb_info.user_data); diff --git a/test/proxy/proxy.h b/test/proxy/proxy.h index 3cdc86e..3ae2e44 100644 --- a/test/proxy/proxy.h +++ b/test/proxy/proxy.h @@ -41,18 +41,13 @@ #define CMD_RESUME_STREAM "stream resume" /* 19 */ #define CMD_SET_STREAM_VOLUME "stream set volume" /* 20 */ #define CMD_GET_STREAM_VOLUME "stream get volume" /* 21 */ -#define CMD_SET_STREAM_LOOP "stream set loop" /* 22 */ -#define CMD_GET_STREAM_LOOP "stream get loop" /* 23 */ -#define CMD_SET_STREAM_PRIORITY "stream set priority" /* 24 */ -#define CMD_GET_STREAM_PRIORITY "stream get priority" /* 25 */ -#define CMD_GET_STREAM_STATE "stream get state" /* 26 */ -#define CMD_SET_STREAM_CB_MSG "stream set callback message" /* 27 */ -#define CMD_SET_STREAM_CB_SCRIPT "stream set callback script" /* 28 */ -#define CMD_UNSET_STREAM_CB "stream unset callback" /* 29 */ -#define CMD_EXECUTE_SCRIPT "script execute" /* 30 */ -#define CMD_SLEEP "sleep" /* 31 */ +#define CMD_SET_STREAM_PRIORITY "stream set priority" /* 22 */ +#define CMD_GET_STREAM_PRIORITY "stream get priority" /* 23 */ +#define CMD_GET_STREAM_STATE "stream get state" /* 24 */ +#define CMD_EXECUTE_SCRIPT "script execute" /* 25 */ +#define CMD_SLEEP "sleep" /* 26 */ -#define CMD_COUNT 32 +#define CMD_COUNT 27 /* Command execution results list */ #define OK +1 @@ -67,10 +62,10 @@ static char *cmd_list[MAX_COMMAND_LINE_LEN] = { CMD_EXIT, CMD_HELP, CMD_UNSET_POOL_CB, CMD_LIST_POOL, CMD_LOAD_SOURCE, CMD_LOAD_MEDIA_PACKAGE, CMD_UNLOAD_SOURCE, CMD_PLAY_STREAM, CMD_STOP_STREAM, CMD_PAUSE_STREAM, CMD_RESUME_STREAM, - CMD_SET_STREAM_VOLUME, CMD_GET_STREAM_VOLUME, CMD_SET_STREAM_LOOP, - CMD_GET_STREAM_LOOP, CMD_SET_STREAM_PRIORITY, CMD_GET_STREAM_PRIORITY, - CMD_GET_STREAM_STATE, CMD_SET_STREAM_CB_MSG, CMD_SET_STREAM_CB_SCRIPT, - CMD_UNSET_STREAM_CB, CMD_EXECUTE_SCRIPT, CMD_SLEEP }; + CMD_SET_STREAM_VOLUME, CMD_GET_STREAM_VOLUME, + CMD_SET_STREAM_PRIORITY, CMD_GET_STREAM_PRIORITY, + CMD_GET_STREAM_STATE, + CMD_EXECUTE_SCRIPT, CMD_SLEEP }; void print_cmd_help_msg(); diff --git a/test/proxy/src/proxy.c b/test/proxy/src/proxy.c index 75ba4a8..f1a2a25 100644 --- a/test/proxy/src/proxy.c +++ b/test/proxy/src/proxy.c @@ -35,10 +35,6 @@ static char *messages[MAX_POOL_CNT] = { NULL }; static char *scripts[MAX_POOL_CNT] = { NULL }; #define MAX_STREAM_CNT 1000 -/* Messages to be used for callbacks output (for pool state changing) */ -static char *stream_messages[MAX_POOL_CNT][MAX_STREAM_CNT] = { { NULL } }; -/* Messages to be used for callbacks output (for stream state changing) */ -static char *stream_scripts[MAX_POOL_CNT][MAX_STREAM_CNT] = { { NULL } }; static const char *__stringify_sound_pool_error(sound_pool_error_e error); static int __proxy_sound_pool_execute_script(const char *pars); @@ -49,15 +45,6 @@ static const char *__stringify_sound_pool_error(sound_pool_error_e error) case SOUND_POOL_ERROR_NONE: return "SOUND_POOL_ERROR_NONE"; break; - case SOUND_POOL_ERROR_NOT_SUPPORTED: - return "SOUND_POOL_ERROR_NOT_SUPPORTED"; - break; - case SOUND_POOL_ERROR_MSG_TOO_LONG: - return "SOUND_POOL_ERROR_MSG_TOO_LONG"; - break; - case SOUND_POOL_ERROR_NO_DATA: - return "SOUND_POOL_ERROR_NO_DATA"; - break; case SOUND_POOL_ERROR_KEY_NOT_AVAILABLE: return "SOUND_POOL_ERROR_KEY_NOT_AVAILABLE"; break; @@ -70,8 +57,8 @@ static const char *__stringify_sound_pool_error(sound_pool_error_e error) case SOUND_POOL_ERROR_INVALID_OPERATION: return "SOUND_POOL_ERROR_INVALID_OPERATION"; break; - case SOUND_POOL_ERROR_PERMISSION_DENIED: - return "SOUND_POOL_ERROR_PERMISSION_DENIED"; + case SOUND_POOL_ERROR_NOT_PERMITTED: + return "SOUND_POOL_ERROR_NOT_PERMITTED"; break; case SOUND_POOL_ERROR_NO_SUCH_FILE: return "SOUND_POOL_ERROR_NO_SUCH_FILE"; @@ -139,7 +126,7 @@ static void __sp_cb_scr(sound_pool_h pool, sound_pool_state_e prev_state, __proxy_sound_pool_execute_script(scr); } -static void __s_cb_msg(sound_pool_h pool, const char *tag, unsigned id, +static void __s_cb_msg(sound_pool_h pool, unsigned id, sound_pool_stream_state_e prev_state, sound_pool_stream_state_e cur_state, void *data) { @@ -150,18 +137,6 @@ static void __s_cb_msg(sound_pool_h pool, const char *tag, unsigned id, msg ? msg : "No message"); } -static void __s_cb_scr(sound_pool_h pool, const char *tag, unsigned id, - sound_pool_stream_state_e prev_state, - sound_pool_stream_state_e cur_state, void *data) -{ - const char *scr = (const char *)data; - _logger_log_info("Sound pool state was changing from %s to %s; " - "Executing: %s...", __stringify_stream_state(prev_state), - __stringify_stream_state(cur_state), - scr ? scr : "No script"); - __proxy_sound_pool_execute_script(scr); -} - /* CMD_EXIT */ static int __exit() { @@ -201,10 +176,6 @@ static int __print_cmd_help_msg() printf("\t- sets callback which will show the message when sound pool " "state is changed.\n"); - printf(CMD_SET_POOL_CB_SCRIPT "\n"); - printf("\t- sets callback which will execute the script when sound pool " - "state is changed.\n"); - printf(CMD_UNSET_POOL_CB "\n"); printf("\t- unsets the callback for the sound pool.\n"); @@ -240,13 +211,6 @@ static int __print_cmd_help_msg() printf("\t- shows volume of the stream in the pool with specified " "identifiers.\n"); - printf(CMD_SET_STREAM_LOOP "\n"); - printf("\t- use this command to set loop parameter of the stream.\n"); - - printf(CMD_GET_STREAM_LOOP "\n"); - printf("\t- shows loop count of the stream in the pool with specified " - "identifiers.\n"); - printf(CMD_SET_STREAM_PRIORITY "\n"); printf("\t- use this command to set priority parameter of the stream. " "0 is the lowest priority.\n"); @@ -259,17 +223,6 @@ static int __print_cmd_help_msg() printf("\t- shows state of the stream in the pool with specified " "identifiers.\n"); - printf(CMD_SET_STREAM_CB_MSG "\n"); - printf("\t- sets callback which will show the message when sound stream " - "state is changed.\n"); - - printf(CMD_SET_STREAM_CB_SCRIPT "\n"); - printf("\t- sets callback which will execute the script (from file) when " - "sound stream state is changed.\n"); - - printf(CMD_UNSET_STREAM_CB "\n"); - printf("\t- unsets the callback for the sound stream.\n"); - printf(CMD_EXECUTE_SCRIPT "\n"); printf("\t- executes the script from the file in filesystem. Script has to\n" "\t be compiled with commands supported by testsuite, one command\n" @@ -569,7 +522,7 @@ static int __proxy_sound_pool_get_volume(const char *pars) } /* CMD_SET_POOL_CB_MSG */ -static int __proxy_sound_pool_set_state_change_callback_message(const char *pars) +static int __proxy_sound_pool_set_state_changed_cb_message(const char *pars) { size_t idx = 0; @@ -600,21 +553,21 @@ static int __proxy_sound_pool_set_state_change_callback_message(const char *pars free(messages[idx]); messages[idx] = strndup(msg, MAX_MSG_LEN); - int ret = sound_pool_set_state_change_callback(pools[idx], __sp_cb_msg, + int ret = sound_pool_set_state_changed_cb(pools[idx], __sp_cb_msg, messages[idx]); if (ret == SOUND_POOL_ERROR_NONE) - _logger_log_info("sound_pool_set_state_change_callback(pool, cb, " + _logger_log_info("sound_pool_set_state_changed_cb(pool, cb, " "\"%s\") returned %s value", msg, __stringify_sound_pool_error(ret)); else - _logger_log_err("sound_pool_set_state_change_callback(pool, cb, " + _logger_log_err("sound_pool_set_state_changed_cb(pool, cb, " "\"%s\") returned %s value", msg, __stringify_sound_pool_error(ret)); return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL); } /* CMD_SET_POOL_CB_SCRIPT */ -static int __proxy_sound_pool_set_state_change_callback_script(const char *pars) +static int __proxy_sound_pool_set_state_changed_cb_script(const char *pars) { size_t idx = 0; @@ -645,21 +598,21 @@ static int __proxy_sound_pool_set_state_change_callback_script(const char *pars) free(scripts[idx]); scripts[idx] = strndup(scr, MAX_MSG_LEN); - int ret = sound_pool_set_state_change_callback(pools[idx], __sp_cb_scr, + int ret = sound_pool_set_state_changed_cb(pools[idx], __sp_cb_scr, scripts[idx]); if (ret == SOUND_POOL_ERROR_NONE) - _logger_log_info("sound_pool_set_state_change_callback(pool, cb, " + _logger_log_info("sound_pool_set_state_changed_cb(pool, cb, " "\"%s\") returned %s value", scr, __stringify_sound_pool_error(ret)); else - _logger_log_err("sound_pool_set_state_change_callback(pool, cb, " + _logger_log_err("sound_pool_set_state_changed_cb(pool, cb, " "\"%s\") returned %s value", scr, __stringify_sound_pool_error(ret)); return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL); } /* CMD_UNSET_POOL_CB */ -static int __proxy_sound_pool_unset_state_change_callback(const char *pars) +static int __proxy_sound_pool_unset_state_changed_cb(const char *pars) { size_t idx = 0; if ((pars == NULL) || (sscanf(pars, " %zu", &idx) < 1)) { @@ -681,7 +634,7 @@ static int __proxy_sound_pool_unset_state_change_callback(const char *pars) if (pools[idx] == NULL) _logger_log_warn("Pool to unset callback for is NULL"); - int ret = sound_pool_unset_state_change_callback(pools[idx]); + int ret = sound_pool_unset_state_changed_cb(pools[idx]); if (messages[idx] != NULL) free(messages[idx]); @@ -692,10 +645,10 @@ static int __proxy_sound_pool_unset_state_change_callback(const char *pars) scripts[idx] = NULL; if (ret == SOUND_POOL_ERROR_NONE) - _logger_log_info("sound_pool_unset_state_change_callback(pool) " + _logger_log_info("sound_pool_unset_state_changed_cb(pool) " "returned %s value", __stringify_sound_pool_error(ret)); else - _logger_log_err("sound_pool_unset_state_change_callback(pool) " + _logger_log_err("sound_pool_unset_state_changed_cb(pool) " "returned %s value", __stringify_sound_pool_error(ret)); return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL); @@ -1064,90 +1017,6 @@ static int __proxy_sound_pool_stream_get_volume(const char *pars) return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL); } -/* CMD_SET_STREAM_LOOP */ -static int __proxy_sound_pool_stream_set_loop(const char *pars) -{ - size_t idx = 0; - size_t stream_idx = 0; - int loop_val = 1; - - if ((pars == NULL) - || (sscanf(pars, " %zu %zu %i", &idx, &stream_idx, &loop_val) < 3)) { - _printf(CMD_COLOR_RED, "You have to specify all following parameters: " - "pool identifier, stream identifier, and loop number! Format: " - CMD_SET_STREAM_LOOP " \n"); - return FAIL; - } - - if (idx > (MAX_POOL_CNT - 1)) { - _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n", - MAX_POOL_CNT - 1); - return FAIL; - } - - if (pools[idx] == NULL) - _logger_log_warn("Pool with specified identifier is NULL"); - - if (loop_val < 0) - _logger_log_warn("Loop number should to be greater than 0, but it's" - "value is %i", loop_val); - - _logger_log_info(CMD_SET_STREAM_LOOP " command was called"); - - int ret = sound_pool_stream_set_loop(pools[idx], stream_idx, loop_val); - - if (ret == SOUND_POOL_ERROR_NONE) - _logger_log_info("sound_pool_stream_set_loop(pool, %zu, %i) " - "returned %s value", stream_idx, loop_val, - __stringify_sound_pool_error(ret)); - else - _logger_log_err("sound_pool_stream_set_loop(pool, %zu, %i) " - "returned %s value", stream_idx, loop_val, - __stringify_sound_pool_error(ret)); - - return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL); -} - -/* CMD_GET_STREAM_LOOP */ -static int __proxy_sound_pool_stream_get_loop(const char *pars) -{ - size_t idx = 0; - size_t stream_idx = 0; - if ((pars == NULL) || (sscanf(pars, " %zu %zu", &idx, &stream_idx) < 2)) { - _printf(CMD_COLOR_RED, "You have to specify both pool and stream " - "identifiers after command name! Format: " - CMD_GET_STREAM_LOOP " \n"); - return FAIL; - } - - if (idx > (MAX_POOL_CNT - 1)) { - _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n", - MAX_POOL_CNT - 1); - return FAIL; - } - - _logger_log_info(CMD_GET_STREAM_LOOP " command was called"); - _logger_log_info("Getting the stream state by %zu identifier in %zu " - "pool...", stream_idx, idx); - - if (pools[idx] == NULL) - _logger_log_warn("Pool where stream should be located is NULL"); - - unsigned loop = 0; - int ret = sound_pool_stream_get_loop(pools[idx], stream_idx, &loop); - - if (ret == SOUND_POOL_ERROR_NONE) - _logger_log_info("sound_pool_stream_get_loop(pool, %zu, loop) " - "returned %s value, loop value is %i", stream_idx, - __stringify_sound_pool_error(ret), loop); - else - _logger_log_err("sound_pool_stream_get_loop(pool, %zu, loop) " - "returned %s value, loop value is %i", stream_idx, - __stringify_sound_pool_error(ret), loop); - - return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL); -} - /* CMD_SET_STREAM_PRIORITY */ static int __proxy_sound_pool_stream_set_priority(const char *pars) { @@ -1270,171 +1139,6 @@ static int __proxy_sound_pool_get_stream_state(const char *pars) return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL); } -/* CMD_SET_STREAM_CB_MSG */ -static int __proxy_sound_pool_set_stream_state_change_callback_message(const char *pars) -{ - size_t idx = 0; - size_t stream_idx = 0; - - char msg[MAX_MSG_LEN] = { '\0' }; - - if ((pars == NULL) || sscanf(pars, " %zu %zu %"MAX_MSG_LEN_STR"[^ ]", - &idx, &stream_idx, msg) < 3) { - _printf(CMD_COLOR_RED, "You have to specify both identifier of the " - "pool and stream, plus message to be shown each time when " - "state of the stream is changed! Message should be a single " - "word. Format: " - CMD_SET_STREAM_CB_MSG " \n"); - return FAIL; - } - - if (idx > (MAX_POOL_CNT - 1)) { - _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n", - MAX_POOL_CNT - 1); - return FAIL; - } - - if (stream_idx > (MAX_STREAM_CNT - 1)) { - _printf(CMD_COLOR_RED, "Stream identifier value can't be greater than %d\n", - MAX_STREAM_CNT - 1); - return FAIL; - } - - _logger_log_info(CMD_SET_STREAM_CB_MSG " command was called"); - _logger_log_info("Set state changing callback (%s message) for stream %zu " - "in pool with %zu identifier...", msg, stream_idx, idx); - - if (pools[idx] == NULL) - _logger_log_warn("Pool with stream to set callback for is NULL"); - - if (stream_messages[idx][stream_idx]) - free(stream_messages[idx][stream_idx]); - stream_messages[idx][stream_idx] = strndup(msg, MAX_MSG_LEN); - - int ret = sound_pool_stream_set_state_change_callback(pools[idx], stream_idx, - __s_cb_msg, stream_messages[idx][stream_idx]); - - if (ret == SOUND_POOL_ERROR_NONE) - _logger_log_info("sound_pool_set_stream_state_change_callback(pool, " - "%zu, cb, \"%s\") returned %s value", stream_idx, msg, - __stringify_sound_pool_error(ret)); - else - _logger_log_err("sound_pool_set_stream_state_change_callback(pool, " - "%zu, cb, \"%s\") returned %s value", stream_idx, msg, - __stringify_sound_pool_error(ret)); - - return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL); -} - -/* CMD_SET_STREAM_CB_SCRIPT */ -static int __proxy_sound_pool_set_stream_state_change_callback_script(const char *pars) -{ - size_t idx = 0; - size_t stream_idx = 0; - - char scr[MAX_MSG_LEN] = { '\0' }; - - if ((pars == NULL) || sscanf(pars, " %zu %zu %"MAX_MSG_LEN_STR"[^ ]", - &idx, &stream_idx, scr) < 3) { - _printf(CMD_COLOR_RED, "You have to specify both identifier of the " - "pool and stream, plus file with script to be executed each " - "time when state of the stream is changed! Message should be a " - "single word. Format: " CMD_SET_STREAM_CB_SCRIPT - "