From 6a096293542e8cb545934e440dac9206db419820 Mon Sep 17 00:00:00 2001 From: Hyunil Park Date: Thu, 9 Jul 2015 11:19:04 +0900 Subject: [PATCH] move param for webaudio Change-Id: I57bd4caa4663684b4050a462d2f8b10836efd3b7 Signed-off-by: Hyunil Park --- include/mobile/player_internal.h | 4 ++-- include/wearable/player_internal.h | 4 ++-- src/player_internal.c | 23 +++++++++++++++++++---- test/player_test.c | 4 ++-- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/include/mobile/player_internal.h b/include/mobile/player_internal.h index 34d07c5..c724bd0 100755 --- a/include/mobile/player_internal.h +++ b/include/mobile/player_internal.h @@ -76,7 +76,7 @@ typedef void (*player_audio_pcm_extraction_cb)(player_audio_raw_data_s *audio_ra * @post player_audio_pcm_extraction_cb() will be invoked. * @see player_unset_audio_frame_decoded_cb_ex() */ -int player_set_pcm_extraction_mode(player_h player, bool sync, const char *format, player_audio_pcm_extraction_cb callback, void *user_data); +int player_set_pcm_extraction_mode(player_h player, bool sync, player_audio_pcm_extraction_cb callback, void *user_data); /** * @brief Set pcm mode spec. Samplerate, channel is needed. @@ -94,7 +94,7 @@ int player_set_pcm_extraction_mode(player_h player, bool sync, const char *forma * @pre The player state must be #PLAYER_STATE_IDLE by player_create() or player_unprepare(). * @see player_set_pcm_extraction_mode() */ -int player_set_pcm_spec(player_h player, int samplerate, int channel); +int player_set_pcm_spec(player_h player, const char *format, int samplerate, int channel); /** * @} */ diff --git a/include/wearable/player_internal.h b/include/wearable/player_internal.h index 014ad4d..31e4c17 100644 --- a/include/wearable/player_internal.h +++ b/include/wearable/player_internal.h @@ -75,7 +75,7 @@ typedef void (*player_audio_pcm_extraction_cb)(player_audio_raw_data_s *audio_ra * @pre The player state must be #PLAYER_STATE_IDLE by player_create() or player_unprepare(). * @post player_audio_pcm_extraction_cb() will be invoked. */ -int player_set_pcm_extraction_mode(player_h player, bool sync, const char *format, player_audio_pcm_extraction_cb callback, void *user_data); +int player_set_pcm_extraction_mode(player_h player, bool sync, player_audio_pcm_extraction_cb callback, void *user_data); /** * @brief Set pcm mode spec. Samplerate, channel is needed. * @since_tizen 2.4 @@ -92,7 +92,7 @@ int player_set_pcm_extraction_mode(player_h player, bool sync, const char *forma * @pre The player state must be #PLAYER_STATE_IDLE by player_create() or player_unprepare(). * @see player_set_pcm_extraction_mode() */ -int player_set_pcm_spec(player_h player, int samplerate, int channel); +int player_set_pcm_spec(player_h player, const char *format, int samplerate, int channel); /** * @} diff --git a/src/player_internal.c b/src/player_internal.c index a10288e..bef6e82 100755 --- a/src/player_internal.c +++ b/src/player_internal.c @@ -58,27 +58,42 @@ bool __audio_stream_callback_ex(MMPlayerAudioStreamDataType *stream, void *user return TRUE; } -int player_set_pcm_extraction_mode(player_h player, bool sync, const char *format, player_audio_pcm_extraction_cb callback, void *user_data) +int player_set_pcm_extraction_mode(player_h player, bool sync, player_audio_pcm_extraction_cb callback, void *user_data) { PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(callback); player_s * handle = (player_s *) player; int ret = MM_ERROR_NONE; + PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); ret = mm_player_set_attribute(handle->mm_handle, NULL, "pcm_extraction",TRUE, "pcm_extraction_start_msec", 0, "pcm_extraction_end_msec", 0, NULL); if(ret != MM_ERROR_NONE) return __player_convert_error_code(ret,(char*)__FUNCTION__); + ret = mm_player_set_audio_stream_callback_ex(handle->mm_handle, sync, __audio_stream_callback_ex, (void*)handle); + if(ret != MM_ERROR_NONE) + return __player_convert_error_code(ret,(char*)__FUNCTION__); + + PLAYER_SET_CALLBACK(_PLAYER_EVENT_TYPE_AUDIO_FRAME, handle, callback, user_data); + return PLAYER_ERROR_NONE; +} + +int player_set_pcm_spec(player_h player, const char *format, int samplerate, int channel) +{ + PLAYER_INSTANCE_CHECK(player); + + player_s * handle = (player_s *) player; + int ret = MM_ERROR_NONE; + + LOGE("[%s] player_set_pcm_spec %s %d %d", __FUNCTION__, format, samplerate, channel); ret = mm_player_set_attribute(handle->mm_handle, NULL, "pcm_audioformat", format , strlen(format), NULL); if(ret != MM_ERROR_NONE) return __player_convert_error_code(ret,(char*)__FUNCTION__); - ret = mm_player_set_audio_stream_callback_ex(handle->mm_handle, sync, __audio_stream_callback_ex, (void*)handle); + ret = mm_player_set_pcm_spec(handle->mm_handle, samplerate, channel); if(ret != MM_ERROR_NONE) return __player_convert_error_code(ret,(char*)__FUNCTION__); - PLAYER_SET_CALLBACK(_PLAYER_EVENT_TYPE_AUDIO_FRAME, handle, callback, user_data); return PLAYER_ERROR_NONE; } - diff --git a/test/player_test.c b/test/player_test.c index 1239ba0..809564b 100644 --- a/test/player_test.c +++ b/test/player_test.c @@ -1067,7 +1067,7 @@ static void audio_frame_decoded_cb_ex() fp_out2 = fopen("/opt/usr/media/out2.pcm", "wb"); #endif - ret = player_set_pcm_extraction_mode(g_player[0], false, "F32LE", _audio_frame_decoded_cb_ex, &ret); + ret = player_set_pcm_extraction_mode(g_player[0], false, _audio_frame_decoded_cb_ex, &ret); g_print(" ==> [Player_Test] player_set_audio_frame_decoded_cb_ex return: %d\n", ret); } @@ -1075,7 +1075,7 @@ static void set_pcm_spec() { int ret; - ret = player_set_pcm_spec(g_player[0], 44100, 2); + ret = player_set_pcm_spec(g_player[0], "F32LE", 44100, 2); g_print("[Player_Test] set_pcm_spec return: %d\n", ret); } -- 2.7.4