Adopt stream-based routing 34/41734/2 accepted/tizen/mobile/20150717.002856 accepted/tizen/tv/20150717.002911 accepted/tizen/wearable/20150717.002926 submit/tizen/20150715.092047 submit/tizen/20150716.043920
authoryoungseok7.lee <youngseok7.lee@samsung.com>
Sat, 28 Mar 2015 10:33:37 +0000 (19:33 +0900)
committerJeongho Mok <jho.mok@samsung.com>
Thu, 25 Jun 2015 05:40:00 +0000 (14:40 +0900)
Change-Id: Ia14c6492821bc659b7c784fdd93918557f38371e
Signed-off-by: Jeongho Mok <jho.mok@samsung.com>
include/tone_player.h
packaging/capi-media-tone-player.spec
src/tone_player.c
test/CMakeLists.txt
test/multimedia_tone_player_test.c

index 6089933..53d8f7c 100755 (executable)
@@ -11,7 +11,7 @@
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
-* limitations under the License. 
+* limitations under the License.
 */
 
 
@@ -41,17 +41,20 @@ extern "C"
  */
 
 /**
- * @brief Enumerations of error codes for wav player
+ * @brief Enumeration of error codes for wav player.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  */
 typedef enum
 {
-    TONE_PLAYER_ERROR_NONE        = TIZEN_ERROR_NONE,                      /**< Successful */
+    TONE_PLAYER_ERROR_NONE              = TIZEN_ERROR_NONE,                    /**< Successful */
     TONE_PLAYER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,       /**< Invalid parameter */
     TONE_PLAYER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION,       /**< Invalid operation */
+    TONE_PLAYER_ERROR_NOT_SUPPORTED     = TIZEN_ERROR_NOT_SUPPORTED,           /**< Not supported (Since 3.0) */
 } tone_player_error_e;
 
 /**
- * @brief Enumerations of tone
+ * @brief Enumeration of tone.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  */
 typedef enum
 {
@@ -69,8 +72,8 @@ typedef enum
        TONE_TYPE_DTMF_S,                          /**< Predefined DTMF Star - Asterisk (*) */
        TONE_TYPE_DTMF_P,                               /**< Predefined DTMF sharP (#) */
        TONE_TYPE_DTMF_A,                               /**< Predefined DTMF A (A) */
-       TONE_TYPE_DTMF_B,                               /**< Predefined DTMF B (B) */   
-       TONE_TYPE_DTMF_C,                               /**< Predefined DTMF C (C) */   
+       TONE_TYPE_DTMF_B,                               /**< Predefined DTMF B (B) */
+       TONE_TYPE_DTMF_C,                               /**< Predefined DTMF C (C) */
        TONE_TYPE_DTMF_D,                               /**< Predefined DTMF D (D) */
        TONE_TYPE_SUP_DIAL,     /**< Call supervisory tone, Dial tone: CEPT: 425Hz, continuous */
        TONE_TYPE_ANSI_DIAL,    /**< Call supervisory tone, Dial tone: ANSI (IS-95): 350Hz+440Hz, continuous */
@@ -181,17 +184,24 @@ typedef enum
 
 
 /**
+ * @deprecated Deprecated since 3.0. Use tone_player_start_with_stream_info() instead.
  * @brief Plays a tone.
  *
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @remarks Sound can be mixed with other sounds if you don't control the sound session in sound-manager module since 3.0.\n
+ *     You can refer to @ref CAPI_MEDIA_SUOND_MANAGER_MODULE.
+ *
  * @param[in] tone     The tone type to play
  * @param[in] type     The sound type
- * @param[in] duration_ms      The tone duration in milliseconds\n
- *             -1 indicates an infinite duration
- * @param[out] id      The tone player ID ( can be set to NULL ) 
- * 
- * @return 0 on success, otherwise a negative error value.
+ * @param[in] duration_ms      The tone duration in milliseconds \n
+ *                                 @c -1 indicates an infinite duration.
+ * @param[out] id      The tone player ID ( can be set to @c NULL )
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
  * @retval #TONE_PLAYER_ERROR_NONE Successful
- * @retval #TONE_PLAYER_ERROR_INVALID_PARAMETER Invalid parameter 
+ * @retval #TONE_PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #TONE_PLAYER_ERROR_INVALID_OPERATION Invalid operation
  *
  * @see tone_player_stop()
@@ -199,14 +209,40 @@ typedef enum
 int tone_player_start(tone_type_e tone, sound_type_e type, int duration_ms, int *id);
 
 /**
+ * @brief Plays a tone with stream information of sound-manager.
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] tone     The tone type to play
+ * @param[in] stream_info      The sound stream information handle
+ * @param[in] duration_ms      The tone duration in milliseconds \n
+ *                                 @c -1 indicates an infinite duration.
+ * @param[out] id      The tone player ID ( can be set to @c NULL )
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TONE_PLAYER_ERROR_NONE Successful
+ * @retval #TONE_PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TONE_PLAYER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #TONE_PLAYER_ERROR_NOT_SUPPORTED Not supported
+ *
+ * @see tone_player_stop()
+ * @see sound_manager_create_stream_information()
+ * @see sound_manager_destroy_stream_information()
+ */
+int tone_player_start_with_stream_info(tone_type_e tone, sound_stream_info_h stream_info, int duration_ms, int *id);
+
+/**
  * @brief Stops playing the tone.
  *
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
  * @param[in] id       The tone player ID to stop
  *
  * @return 0 on success, otherwise a negative error value.
  * @retval #TONE_PLAYER_ERROR_NONE Successful
- * @retval #TONE_PLAYER_ERROR_INVALID_PARAMETER Invalid parameter 
- * @retval #TONE_PLAYER_ERROR_INVALID_OPERATION Invalid operation  
+ * @retval #TONE_PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TONE_PLAYER_ERROR_INVALID_OPERATION Invalid operation
  *
  * @see tone_player_start()
  */
index 1b0b46c..360f7b5 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-tone-player
 Summary:    A tone player library in Tizen C API
-Version:    0.1.1
+Version:    0.1.3
 Release:    16
 Group:      Multimedia/API
 License:    Apache-2.0
index 8447e30..08b72ec 100755 (executable)
@@ -11,7 +11,7 @@
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
-* limitations under the License. 
+* limitations under the License.
 */
 
 
@@ -20,6 +20,7 @@
 #define LOG_TAG "CAPI_MEDIA_TONE_PLAYER"
 
 #include <sound_manager.h>
+#include <sound_manager_internal.h>
 #include <tone_player.h>
 #include <mm_sound.h>
 #include <mm_sound_private.h>
@@ -40,7 +41,7 @@ static int __convert_tone_player_error_code(const char *func, int code){
                        errorstr = "ERROR_NONE";
                        break;
                case TONE_PLAYER_ERROR_INVALID_PARAMETER:
-               case MM_ERROR_INVALID_ARGUMENT: 
+               case MM_ERROR_INVALID_ARGUMENT:
                case MM_ERROR_SOUND_INVALID_POINTER:
                        ret = TONE_PLAYER_ERROR_INVALID_PARAMETER;
                        errorstr = "INVALID_PARAMETER";
@@ -67,6 +68,32 @@ int tone_player_start(tone_type_e tone, sound_type_e type, int duration, int *id
         return __convert_tone_player_error_code(__func__, ret);
 }
 
+int tone_player_start_with_stream_info(tone_type_e tone, sound_stream_info_h stream_info, int duration, int * id){
+       int ret;
+       int player;
+       double vol = 1.0;
+       char *stream_type = NULL;
+       int stream_id;
+
+       if( tone < TONE_TYPE_DEFAULT || tone > TONE_TYPE_USER_DEFINED_HIGH_FRE )
+               return __convert_tone_player_error_code(__func__, TONE_PLAYER_ERROR_INVALID_PARAMETER);
+
+       ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type);
+       if( ret )
+               return __convert_tone_player_error_code(__func__, ret);
+       ret = sound_manager_get_index_from_stream_information(stream_info, &stream_id);
+       if( ret )
+               return __convert_tone_player_error_code(__func__, ret);
+
+       ret = mm_sound_play_tone_with_stream_info(tone, stream_type, stream_id, vol, duration, &player);
+
+       if( ret == 0 && id != NULL)
+               *id = player;
+
+       return __convert_tone_player_error_code(__func__, ret);
+
+
+}
 
 int tone_player_stop(int id){
        return __convert_tone_player_error_code(__func__, mm_sound_stop_sound(id));
index 353da53..74802de 100644 (file)
@@ -7,7 +7,7 @@ FOREACH(flag ${${fw_test}_CFLAGS})
     MESSAGE(${flag})
 ENDFOREACH()
 
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -pie")
 
 #ADD_EXECUTABLE("system-sensor" system-sensor.c)
 #TARGET_LINK_LIBRARIES("system-sensor" ${fw_name} ${${fw_test}_LDFLAGS})
index 01a1710..0de8b91 100755 (executable)
@@ -11,7 +11,7 @@
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
-* limitations under the License. 
+* limitations under the License.
 */
 
 
@@ -35,7 +35,7 @@ gpointer GmainThread(gpointer data){
 
 void tone_play_test(){
        int i ;
-       
+
        for( i =0 ; i <= 106 ; i++){
                printf("play %d sound\n", i);
                tone_player_start(i, SOUND_TYPE_MEDIA ,500,NULL);
@@ -43,7 +43,7 @@ void tone_play_test(){
 
        }
 
-//     tone_player_start(SOUND_TONE_DTMF_C, SOUND_TYPE_MEDIA ,100000,NULL);    
+//     tone_player_start(SOUND_TONE_DTMF_C, SOUND_TYPE_MEDIA ,100000,NULL);
        sleep(1000);
 }