From 81b95a26c227496176139c9371b043ca8b9dde77 Mon Sep 17 00:00:00 2001 From: Jihoon Jung Date: Thu, 11 Feb 2016 14:48:54 +0900 Subject: [PATCH] Change deprecated sound / wav api Signed-off-by: Jihoon Jung Change-Id: I1057df0e2bf849723fe2926050259c4a62c59b3d --- src/manager/net_nfc_manager_util.c | 41 +++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/src/manager/net_nfc_manager_util.c b/src/manager/net_nfc_manager_util.c index 1efed4d..3a5ab05 100755 --- a/src/manager/net_nfc_manager_util.c +++ b/src/manager/net_nfc_manager_util.c @@ -26,6 +26,21 @@ #include "net_nfc_util_internal.h" #include "net_nfc_manager_util_internal.h" +static void __focus_changed_cb(sound_stream_info_h stream_info, + sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data) +{ + +} + +static void __wav_start_completed_cb(int id, void *user_data) +{ + sound_stream_info_h stream_info = (sound_stream_info_h) user_data; + + sound_manager_release_focus(stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL); + sound_manager_destroy_stream_information(stream_info); +} + + void net_nfc_manager_util_play_sound(net_nfc_sound_type_e sound_type) { int bSoundOn = 0; @@ -85,11 +100,27 @@ void net_nfc_manager_util_play_sound(net_nfc_sound_type_e sound_type) if (sound_path != NULL) { - sound_manager_set_session_type(SOUND_SESSION_TYPE_NOTIFICATION); - if (MM_ERROR_NONE == wav_player_start(sound_path, SOUND_TYPE_NOTIFICATION, NULL, NULL, NULL)) -// if (MM_ERROR_NONE == mm_sound_play_keysound(sound_path, VOLUME_TYPE_NOTIFICATION)) - { - DEBUG_MSG("wav_player_start success"); + int id; + int ret; + sound_stream_info_h stream_info; + + ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_NOTIFICATION, __focus_changed_cb, NULL, &stream_info); + + if (ret == SOUND_MANAGER_ERROR_NONE) { + ret = sound_manager_acquire_focus(stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL); + if (ret == SOUND_MANAGER_ERROR_NONE) { + ret = wav_player_start_with_stream_info(sound_path, + stream_info, __wav_start_completed_cb, stream_info, &id); + if (ret == WAV_PLAYER_ERROR_NONE) { + DEBUG_SERVER_MSG("wav_player_start_with_stream_info success"); + } else { + DEBUG_SERVER_MSG("wav_player_start_with_stream_info failed"); + } + } else { + DEBUG_SERVER_MSG("sound_manager_acquire_focus failed"); + } + } else { + DEBUG_SERVER_MSG("sound_manager_create_stream_information failed"); } _net_nfc_util_free_mem(sound_path); -- 2.7.4