summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS2
-rw-r--r--LICENSE.APLv2204
-rw-r--r--Makefile.am28
-rw-r--r--NOTICE3
-rwxr-xr-xaudio-session-manager.manifest5
-rw-r--r--audio-session-mgr.pc.in2
-rw-r--r--configure.ac12
-rw-r--r--[-rwxr-xr-x]include/asm-error.h4
-rw-r--r--[-rwxr-xr-x]include/audio-session-manager-types.h76
-rw-r--r--[-rwxr-xr-x]include/audio-session-manager.h10
-rw-r--r--packaging/audio-session-manager.spec33
-rw-r--r--src/audio-session-mgr.c774
-rw-r--r--test/Makefile.am17
-rw-r--r--test/asm_testsuite.c296
14 files changed, 1148 insertions, 318 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..79a79b1
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+Seungbae Shin <seungbae.shin at samsung.com>
+Sangchul Lee <sc11.lee at samsung.com>
diff --git a/LICENSE.APLv2 b/LICENSE.APLv2
new file mode 100644
index 0000000..3b739e3
--- /dev/null
+++ b/LICENSE.APLv2
@@ -0,0 +1,204 @@
+Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ 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.
+
diff --git a/Makefile.am b/Makefile.am
index a2ea79e..8537556 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,37 +1,25 @@
-SUBDIRS = init
+SUBDIRS = . \
+ test
-bin_PROGRAMS = audio-session-mgr-server
-
-audio_session_mgr_server_SOURCES = \
- $(srcdir)/src/audio-session-mgr-server.c
-
-#audio_session_mgr_server_LDADD = libaudio-session-mgr.la
-
-audio_session_mgr_server_CPPFLAGS = -I$(srcdir)/include/ -D__DEBUG_MODE__ -DUSE_VCONF $(MMLOG_CFLAGS) -D__USE_LOGMANAGER__ $(SYSMAN_CFLAGS) $(AVSYSAUDIO_CFLAGS)
-#audio_session_mgr_server_LDFLAGS += $(AUDIOSESSIONMGR_LIBS) $(MMLOG_LIBS) $(SYSMAN_LIBS)
-audio_session_mgr_server_LDADD = $(AUDIOSESSIONMGR_LIBS) $(MMLOG_LIBS) $(SYSMAN_LIBS) $(AVSYSAUDIO_LIBS)
-
-if USE_SECURITY
-audio_session_mgr_server_CPPFLAGS += $(SECURITY_CFLAGS) -DUSE_SECURITY
-audio_session_mgr_server_LDADD += $(SECURITY_LIBS)
-endif
-
-AM_CFLAGS = $(AUDIOSESSIONMGR_CFLAGS)
+AM_CFLAGS = $(AUDIOSESSIONMGR_CFLAGS)
lib_LTLIBRARIES = libaudio-session-mgr.la
libaudio_session_mgr_la_SOURCES = $(srcdir)/src/audio-session-mgr.c
-libaudio_session_mgr_la_LIBADD = $(AUDIOSESSIONMGR_LIBS) $(MMLOG_LIBS)
+libaudio_session_mgr_la_LIBADD = $(AUDIOSESSIONMGR_LIBS) $(VCONF_LIBS) $(MMCOMMON_LIBS)
libaudio_session_mgr_la_LDFLAGS = -Wl,-init, __ASM_init_module
libaudio_session_mgr_la_LDFLAGS += -Wl,-fini, __ASM_fini_module
-libaudio_session_mgr_la_CPPFLAGS = -I$(srcdir)/include -D__DEBUG_MODE__ -DUSE_VCONF $(MMLOG_CFLAGS) -D__USE_LOGMANAGER__
+libaudio_session_mgr_la_CPPFLAGS = -I$(srcdir)/include -DUSE_VCONF $(VCONF_CFLAGS) $(MMCOMMON_CFLAGS)
if USE_SECURITY
libaudio_session_mgr_la_CPPFLAGS += $(SECURITY_CFLAGS) -DUSE_SECURITY
libaudio_session_mgr_la_LIBADD += $(SECURITY_LIBS)
endif
+libaudio_session_mgr_la_CPPFLAGS += $(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x00800000 -DMMF_DEBUG_PREFIX=\"MMF-SESSIONMGR\"
+libaudio_session_mgr_la_LIBADD += $(MMLOG_LIBS)
+
audiosessionmgrincludedir = $(includedir)/mmf
audiosessionmgrinclude_HEADERS = \
$(srcdir)/include/audio-session-manager-types.h \
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..ccdad52
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE file for Apache License terms and conditions.
diff --git a/audio-session-manager.manifest b/audio-session-manager.manifest
new file mode 100755
index 0000000..a76fdba
--- /dev/null
+++ b/audio-session-manager.manifest
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
diff --git a/audio-session-mgr.pc.in b/audio-session-mgr.pc.in
index 0644782..0fb8fc2 100644
--- a/audio-session-mgr.pc.in
+++ b/audio-session-mgr.pc.in
@@ -6,6 +6,6 @@ includedir=@includedir@
Name: audio-session-mgr
Description: audio-session-mgr
Version: @VERSION@
-Requires: vconf sysman mm-log
+Requires: vconf sysman mm-common
Libs: -L${libdir} -laudio-session-mgr
Cflags: -I${includedir}/mmf
diff --git a/configure.ac b/configure.ac
index 4d5ae2f..f4a0663 100644
--- a/configure.ac
+++ b/configure.ac
@@ -14,14 +14,22 @@ AC_PROG_MAKE_SET
AC_PROG_LIBTOOL
# Checks for libraries.
-PKG_CHECK_MODULES(AUDIOSESSIONMGR, glib-2.0 vconf )
+PKG_CHECK_MODULES(AUDIOSESSIONMGR, glib-2.0 gthread-2.0)
AC_SUBST(AUDIOSESSIONMGR_CFLAGS)
AC_SUBST(AUDIOSESSIONMGR_LIBS)
+PKG_CHECK_MODULES(MMLOG, mm-common)
+AC_SUBST(MMCOMMON_CFLAGS)
+AC_SUBST(MMCOMMON_LIBS)
+
PKG_CHECK_MODULES(MMLOG, mm-log)
AC_SUBST(MMLOG_CFLAGS)
AC_SUBST(MMLOG_LIBS)
+PKG_CHECK_MODULES(VCONF, vconf)
+AC_SUBST(VCONF_CFLAGS)
+AC_SUBST(VCONF_LIBS)
+
PKG_CHECK_MODULES(SYSMAN, sysman)
AC_SUBST(SYSMAN_CFLAGS)
AC_SUBST(SYSMAN_LIBS)
@@ -64,7 +72,7 @@ AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset])
AC_CONFIG_FILES([Makefile
+ test/Makefile
audio-session-mgr.pc
- init/Makefile
])
AC_OUTPUT
diff --git a/include/asm-error.h b/include/asm-error.h
index 9084444..f6d814d 100755..100644
--- a/include/asm-error.h
+++ b/include/asm-error.h
@@ -1,9 +1,9 @@
/*
* audio-session-manager
*
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
+ * Contact: Seungbae Shin <seungbae.shin at samsung.com>, Sangchul Lee <sc11.lee at samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/include/audio-session-manager-types.h b/include/audio-session-manager-types.h
index f2ab404..fa7b3fb 100755..100644
--- a/include/audio-session-manager-types.h
+++ b/include/audio-session-manager-types.h
@@ -1,9 +1,9 @@
/*
* audio-session-manager
*
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
+ * Contact: Seungbae Shin <seungbae.shin at samsung.com>, Sangchul Lee <sc11.lee at samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,23 +35,25 @@
#define ERR_ASM_MSG_QUEUE_MSGID_GET_FAILED 0x03
#define ERR_ASM_MSG_QUEUE_SND_ERROR 0x04
#define ERR_ASM_MSG_QUEUE_RCV_ERROR 0x05
-#define ERR_ASM_ALREADY_REGISTERED 0x06
+#define ERR_ASM_ALREADY_REGISTERED 0x06
#define ERR_ASM_ALREADY_UNREGISTERED 0x07
-#define ERR_ASM_EVENT_IS_INVALID 0x08
-#define ERR_ASM_EVENT_IS_FULL 0x09
-#define ERR_ASM_POLICY_CANNOT_PLAY 0x10
-#define ERR_ASM_POLICY_INVALID_HANDLE 0x11
-#define ERR_ASM_INVALID_PARAMETER 0x12
-#define ERR_ASM_VCONF_ERROR 0x13
-#define ERR_ASM_UNKNOWN_ERROR 0x0F
-#define ERR_ASM_HANDLE_IS_FULL 0x20
+#define ERR_ASM_EVENT_IS_INVALID 0x08
+#define ERR_ASM_EVENT_IS_FULL 0x09
+#define ERR_ASM_POLICY_CANNOT_PLAY 0x10
+#define ERR_ASM_POLICY_CANNOT_PLAY_BY_CALL 0x11 /* CALL / VIDEOCALL / RICH_CALL */
+#define ERR_ASM_POLICY_CANNOT_PLAY_BY_ALARM 0x12
+#define ERR_ASM_POLICY_INVALID_HANDLE 0x1f
+#define ERR_ASM_INVALID_PARAMETER 0x20
+#define ERR_ASM_VCONF_ERROR 0x21
+#define ERR_ASM_UNKNOWN_ERROR 0x2F
+#define ERR_ASM_HANDLE_IS_FULL 0x30
#ifdef USE_SECURITY
-#define ERR_ASM_CHECK_PRIVILEGE_FAILED 0x30
-#define COOKIE_SIZE 20
+#define ERR_ASM_CHECK_PRIVILEGE_FAILED 0x40
+#define COOKIE_SIZE 20
#endif
-#define ASM_PRIORITY_MATRIX_MIN (ASM_EVENT_MAX-1)//13
+#define ASM_PRIORITY_MATRIX_MIN (ASM_EVENT_MAX-1)
#define ASM_SERVER_HANDLE_MAX 256
@@ -62,15 +64,16 @@
typedef enum
{
ASM_REQUEST_REGISTER = 0,
- ASM_REQUEST_UNREGISTER = 1,
- ASM_REQUEST_GETSTATE = 2,
- ASM_REQUEST_GETMYSTATE = 3,
- ASM_REQUEST_SETSTATE = 4,
- ASM_REQUEST_EMERGENT_EXIT = 5,
- ASM_REQUEST_DUMP = 6,
+ ASM_REQUEST_UNREGISTER,
+ ASM_REQUEST_GETSTATE,
+ ASM_REQUEST_GETMYSTATE,
+ ASM_REQUEST_SETSTATE,
+ ASM_REQUEST_EMERGENT_EXIT,
+ ASM_REQUEST_DUMP,
+ ASM_REQUEST_SET_SUBSESSION,
+ ASM_REQUEST_GET_SUBSESSION,
} ASM_requests_t;
-
/**
* This enumeration defines sound event for Sound Scenario in Multimedia Resources Conflict Manager.
*/
@@ -96,6 +99,9 @@ typedef enum
ASM_EVENT_ALARM,
ASM_EVENT_VIDEOCALL,
ASM_EVENT_MONITOR,
+ ASM_EVENT_RICH_CALL,
+ ASM_EVENT_EMERGENCY,
+ ASM_EVENT_EXCLUSIVE_RESOURCE,
ASM_EVENT_MAX
} ASM_sound_events_t;
@@ -104,14 +110,16 @@ typedef enum
*/
typedef enum
{
- ASM_EVENT_SOURCE_OTHER_APP = 0,
+ ASM_EVENT_SOURCE_MEDIA = 0,
ASM_EVENT_SOURCE_CALL_START,
- ASM_EVENT_SOURCE_CALL_END,
ASM_EVENT_SOURCE_EARJACK_UNPLUG,
ASM_EVENT_SOURCE_RESOURCE_CONFLICT,
ASM_EVENT_SOURCE_ALARM_START,
ASM_EVENT_SOURCE_ALARM_END,
+ ASM_EVENT_SOURCE_EMERGENCY_START,
+ ASM_EVENT_SOURCE_EMERGENCY_END,
ASM_EVENT_SOURCE_OTHER_PLAYER_APP,
+ ASM_EVENT_SOURCE_RESUMABLE_MEDIA,
} ASM_event_sources_t;
/**
@@ -124,7 +132,8 @@ typedef enum
ASM_CASE_1PLAY_2STOP = 1,
ASM_CASE_1STOP_2PLAY = 5,
ASM_CASE_1PAUSE_2PLAY = 6,
- ASM_CASE_1PLAY_2PLAY_MIX = 8
+ ASM_CASE_1PLAY_2PLAY_MIX = 8,
+ ASM_CASE_RESOURCE_CHECK = 9
} ASM_sound_cases_t;
@@ -154,6 +163,9 @@ typedef enum
ASM_STATUS_ALARM = 0x00100000,
ASM_STATUS_VIDEOCALL = 0x20000000, //Watch out
ASM_STATUS_MONITOR = 0x80000000, //watch out
+ ASM_STATUS_RICH_CALL = 0x40000000, //Watch out
+ ASM_STATUS_EMERGENCY = 0x00004000,
+ ASM_STATUS_EXCLUSIVE_RESOURCE = 0x00008000,
} ASM_sound_status_t;
@@ -162,13 +174,13 @@ typedef enum
*/
typedef enum
{
- ASM_STATE_IGNORE = -1,
ASM_STATE_NONE = 0,
ASM_STATE_PLAYING = 1,
ASM_STATE_WAITING = 2,
ASM_STATE_STOP = 3,
ASM_STATE_PAUSE = 4,
ASM_STATE_PAUSE_BY_APP = 5,
+ ASM_STATE_IGNORE = 6,
} ASM_sound_states_t;
@@ -226,7 +238,7 @@ typedef enum
*/
typedef struct
{
- int handle;
+ int handle;
ASM_requests_t request_id;
ASM_sound_events_t sound_event;
ASM_sound_states_t sound_state;
@@ -241,12 +253,13 @@ typedef struct
*/
typedef struct
{
- int alloc_handle;
- int cmd_handle;
- ASM_sound_commands_t result_sound_command;
+ int alloc_handle;
+ int cmd_handle;
+ ASM_sound_commands_t result_sound_command;
ASM_sound_states_t result_sound_state;
+ ASM_sound_events_t former_sound_event;
#ifdef USE_SECURITY
- int check_privilege;
+ int check_privilege;
#endif
} __ASM_msg_data_asm_to_lib_t;
@@ -314,6 +327,9 @@ static const ASM_sound_event_type_t ASM_sound_type[] = {
{ ASM_EVENT_ALARM, ASM_STATUS_ALARM },
{ ASM_EVENT_VIDEOCALL, ASM_STATUS_VIDEOCALL },
{ ASM_EVENT_MONITOR, ASM_STATUS_MONITOR },
+ { ASM_EVENT_RICH_CALL, ASM_STATUS_RICH_CALL },
+ { ASM_EVENT_EMERGENCY, ASM_STATUS_EMERGENCY },
+ { ASM_EVENT_EXCLUSIVE_RESOURCE, ASM_STATUS_EXCLUSIVE_RESOURCE },
};
diff --git a/include/audio-session-manager.h b/include/audio-session-manager.h
index 9a74181..a10fa6f 100755..100644
--- a/include/audio-session-manager.h
+++ b/include/audio-session-manager.h
@@ -1,9 +1,9 @@
/*
* audio-session-manager
*
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
+ * Contact: Seungbae Shin <seungbae.shin at samsung.com>, Sangchul Lee <sc11.lee at samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,6 +53,9 @@ bool
ASM_register_sound(const int application_pid, int *asm_handle, ASM_sound_events_t sound_event,
ASM_sound_states_t sound_state, ASM_sound_cb_t callback, void* cb_data, ASM_resource_t mm_resource, int *error_code);
+bool
+ASM_register_sound_ex (const int application_pid, int *asm_handle, ASM_sound_events_t sound_event,
+ ASM_sound_states_t sound_state, ASM_sound_cb_t callback, void* cb_data, ASM_resource_t mm_resource, int *error_code, int (*func)(void*,void*));
/**
* This function unregister sound event to ASM server. If unregistered, sound event is not playing.
@@ -65,6 +68,7 @@ ASM_register_sound(const int application_pid, int *asm_handle, ASM_sound_events_
bool
ASM_unregister_sound(const int asm_handle, ASM_sound_events_t sound_event, int *error_code);
+bool ASM_unregister_sound_ex(const int asm_handle, ASM_sound_events_t sound_event, int *error_code, int (*func)(void*,void*));
/**
@@ -118,7 +122,7 @@ ASM_get_process_session_state(const int asm_handle, ASM_sound_states_t *sound_st
bool
ASM_set_sound_state(const int asm_handle, ASM_sound_events_t sound_event, ASM_sound_states_t sound_state, ASM_resource_t mm_resource, int *error_code);
-
+bool ASM_set_sound_state_ex (const int asm_handle, ASM_sound_events_t sound_event, ASM_sound_states_t sound_state, ASM_resource_t mm_resource, int *error_code, int (*func)(void*,void*));
/**
* This function ask sound policy to ASM server.
diff --git a/packaging/audio-session-manager.spec b/packaging/audio-session-manager.spec
index be2d0dc..3853ed8 100644
--- a/packaging/audio-session-manager.spec
+++ b/packaging/audio-session-manager.spec
@@ -1,16 +1,16 @@
Name: audio-session-manager
-Summary: Audioxi Session Manager
-Version: 0.1.14
-Release: 1
-Group: TO_BE/FILLED_IN
-License: TO BE FILLED IN
+Summary: Audio Session Manager
+Version: 0.2.7
+Release: 0
+Group: System/Libraries
+License: Apache License, Version 2.0
+URL: http://source.tizen.org
Source0: %{name}-%{version}.tar.gz
Requires(post): /sbin/ldconfig
Requires(post): /usr/bin/vconftool
Requires(postun): /sbin/ldconfig
-BuildRequires: vconf-keys-devel
BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(mm-log)
+BuildRequires: pkgconfig(mm-common)
BuildRequires: pkgconfig(sysman)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(avsysaudio)
@@ -34,7 +34,7 @@ Audio-session-manager development package (devel)
%package sdk-devel
Summary: auido-session-manager development package for sdk release
Group: Development/Libraries
-Requires: %{name} = %{version}-%{release}
+Requires: %{name}-devel = %{version}-%{release}
%description sdk-devel
auido-session-manager development package for sdk release for audio-session
@@ -48,9 +48,9 @@ auido-session-manager development package for sdk release for audio-session
%autogen --disable-static --noconfigure
LDFLAGS="$LDFLAGS -Wl,--rpath=%{prefix}/lib -Wl,--hash-style=both -Wl,--as-needed "; export LDFLAGS
-CFLAGS="%{optflags} -fvisibility=hidden -DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\"" ; export CFLAGS
+CFLAGS="%{optflags} -fvisibility=hidden -DMM_DEBUG_FLAG -DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\"" ; export CFLAGS
%configure --disable-static --enable-security
-make
+make %{?jobs:-j%jobs}
%install
rm -rf %{buildroot}
@@ -61,19 +61,16 @@ rm -rf %{buildroot}
%post
/sbin/ldconfig
-vconftool set -t int memory/Sound/SoundStatus "0" -i
-
-%postun -p /sbin/ldconfig
-
-
-
+vconftool set -t int memory/Sound/SoundStatus "0" -g 29 -f -i
+%postun
+/sbin/ldconfig
%files
+%manifest audio-session-manager.manifest
%defattr(-,root,root,-)
-%{_sysconfdir}/rc.d/init.d/audiosessionmanager
-%{_bindir}/audio-session-mgr-server
%{_libdir}/libaudio-session-mgr.so.*
+%{_bindir}/asm_testsuite
%files devel
%defattr(-,root,root,-)
diff --git a/src/audio-session-mgr.c b/src/audio-session-mgr.c
index 2178161..91c5feb 100644
--- a/src/audio-session-mgr.c
+++ b/src/audio-session-mgr.c
@@ -1,9 +1,9 @@
/*
* audio-session-manager
*
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
+ * Contact: Seungbae Shin <seungbae.shin at samsung.com>, Sangchul Lee <sc11.lee at samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,6 +40,7 @@
#include <signal.h>
#include <poll.h>
#include <string.h>
+#include <mm_debug.h>
#ifdef USE_SECURITY
#include <security-server.h>
@@ -55,7 +56,6 @@
#endif
#include "../include/audio-session-manager.h"
-#include "../include/asm-log.h"
#define asmgettid() (long int)getpid()
#define ASM_HANDLE_MAX 256
@@ -82,14 +82,16 @@ typedef gboolean (*gLoopPollHandler_t)(gpointer d);
typedef struct
{
ASM_sound_events_t sound_event;
- int asm_fd;
+ GSourceFuncs* g_src_funcs;
+ GPollFD* g_poll_fd;
+ int asm_fd;
ASM_sound_cb_t asm_callback;
- void *cb_data;
- int asm_tid;
- int handle;
- bool is_used;
- GSource* asm_src;
- guint ASM_g_id;
+ void *cb_data;
+ int asm_tid;
+ int handle;
+ bool is_used;
+ GSource* asm_src;
+ guint ASM_g_id;
} ASM_sound_ino_t;
ASM_sound_ino_t ASM_sound_handle[ASM_HANDLE_MAX];
@@ -113,7 +115,10 @@ static const char* ASM_sound_events_str[] =
"EARJACK_UNPLUG",
"ALARM",
"VIDEOCALL",
- "MONITOR"
+ "MONITOR",
+ "RICH_CALL",
+ "EMERGENCY",
+ "EXCLUSIVE_RESOURCE"
};
static const char* ASM_sound_cases_str[] =
@@ -126,7 +131,8 @@ static const char* ASM_sound_cases_str[] =
"CASE_1STOP_2PLAY",
"CASE_1PAUSE_2PLAY",
"CASE_1VIRTUAL_2PLAY",
- "CASE_1PLAY_2PLAY_MIX"
+ "CASE_1PLAY_2PLAY_MIX",
+ "CASE_RESOURCE_CHECK"
};
static const char* ASM_sound_state_str[] =
@@ -156,10 +162,11 @@ bool __ASM_get_sound_state(unsigned int *all_sound_status, int *error_code)
int value = 0;
if(vconf_get_int(SOUND_STATUS_KEY, &value)) {
- asm_error_r("[Error = %d] __ASM_get_sound_state => phonestatus_get \n", ERR_ASM_VCONF_ERROR);
+ debug_error("failed to vconf_get_int(SOUND_STATUS_KEY)");
+ *error_code = ERR_ASM_VCONF_ERROR;
return false;
}
- asm_info(" __ASM_get_sound_state : All status(%#X) \n", value);
+ debug_msg("All status(%#X)", value);
*all_sound_status = value;
ASM_all_sound_status = value;
@@ -169,8 +176,7 @@ bool __ASM_get_sound_state(unsigned int *all_sound_status, int *error_code)
bool __ASM_set_sound_state(ASM_sound_events_t sound_event, ASM_sound_states_t sound_state, int *error_code)
{
/* this function will deprecated */
- asm_info(" __ASM_set_sound_state : Event(%s), State(%s)\n",
- ASM_sound_events_str[sound_event], ASM_sound_state_str[sound_state]);
+ debug_msg("Event(%s), State(%s)", ASM_sound_events_str[sound_event], ASM_sound_state_str[sound_state]);
return true;
}
@@ -178,6 +184,10 @@ bool __ASM_set_sound_state(ASM_sound_events_t sound_event, ASM_sound_states_t so
gboolean __asm_fd_check(GSource * source)
{
GSList *fd_list;
+ if (!source) {
+ debug_error("GSource is null");
+ return FALSE;
+ }
fd_list = source->poll_fds;
GPollFD *temp;
@@ -210,8 +220,12 @@ gboolean asm_callback_handler( gpointer d)
int count;
int tid = 0;
int asm_index = 0;
- asm_info("asm_callback_handler");
+ debug_fenter();
+ if (!data) {
+ debug_error("GPollFd is null");
+ return FALSE;
+ }
if (data->revents & (POLLIN | POLLPRI)) {
int handle;
int error_code = 0;
@@ -229,16 +243,16 @@ gboolean asm_callback_handler( gpointer d)
asm_index = __ASM_find_index(handle);
if (asm_index == -1) {
- asm_critical_r("asm_callback_handler : Can not find index\n");
- return false;
+ debug_error("Can not find index");
+ return FALSE;
}
tid = ASM_sound_handle[asm_index].asm_tid;
if (rcv_command) {
- asm_critical("[RETCB] got and start CB : TID(%d), handle(%d) cmd(%d) event_src(%d)\n", tid, handle, rcv_command, event_src );
+ debug_msg("got and start CB : TID(%d), handle(%d) cmd(%d) event_src(%d)", tid, handle, rcv_command, event_src );
if (!__ASM_get_sound_state(&sound_status_value, &error_code)) {
- asm_info("[ASM_CB][Error = %d] asm_callback_handler : ASM_set_sound_state => __ASM_get_sound_state \n", error_code);
+ debug_error("failed to __ASM_get_sound_state(), error(%d)", error_code);
}
switch (rcv_command) {
case ASM_COMMAND_PLAY:
@@ -246,132 +260,177 @@ gboolean asm_callback_handler( gpointer d)
case ASM_COMMAND_PAUSE:
case ASM_COMMAND_STOP:
if (ASM_sound_handle[asm_index].asm_callback == NULL) {
- asm_info("callback is null!!!!\n");
+ debug_msg("callback is null..");
return FALSE;
}
- asm_info("ASM callback function pointer - start(%p)\n",ASM_sound_handle[asm_index].asm_callback);
- if (ASM_sound_handle[asm_index].asm_callback != NULL) {
- cb_res = (ASM_sound_handle[asm_index].asm_callback)(handle, event_src, rcv_command, sound_status_value, ASM_sound_handle[asm_index].cb_data);
- } else {
- asm_info("[ASM_CB][RETCB]callback in null(possibly unregistered simultaneously)\n");
- }
- asm_info("[ASM_CB][RETCB]callback - end\n");
+ debug_msg("[CALLBACK(%p) START]",ASM_sound_handle[asm_index].asm_callback);
+ cb_res = (ASM_sound_handle[asm_index].asm_callback)(handle, event_src, rcv_command, sound_status_value, ASM_sound_handle[asm_index].cb_data);
+ debug_msg("[CALLBACK END]");
break;
default:
break;
}
#ifdef CONFIG_ENABLE_RETCB
- int rett = 0;
- int buf = cb_res;
- int tmpfd = -1;
- char *filename2 = g_strdup_printf("/tmp/ASM.%d.%dr", ASM_sound_handle[asm_index].asm_tid, handle);
- tmpfd = open(filename2, O_WRONLY | O_NONBLOCK);
- if (tmpfd < 0) {
- char str_error[256];
- strerror_r(errno, str_error, sizeof(str_error));
- asm_error("[ASM_CB][RETCB][Failed(May Server Close First)]tid(%d) fd(%d) %s errno=%d(%s)\n", tid, tmpfd, filename2, errno, str_error);
+
+ /* If command is other than RESUME, send return */
+ if (rcv_command != ASM_COMMAND_RESUME) {
+ int rett = 0;
+ int buf = cb_res;
+ int tmpfd = -1;
+ char *filename2 = g_strdup_printf("/tmp/ASM.%d.%dr", ASM_sound_handle[asm_index].asm_tid, handle);
+ tmpfd = open(filename2, O_WRONLY | O_NONBLOCK);
+ if (tmpfd < 0) {
+ char str_error[256];
+ strerror_r(errno, str_error, sizeof(str_error));
+ debug_error("[RETCB][Failed(May Server Close First)]tid(%d) fd(%d) %s errno=%d(%s)\n", tid, tmpfd, filename2, errno, str_error);
+ g_free(filename2);
+ return FALSE;
+ }
+ rett = write(tmpfd, &buf, sizeof(buf));
+ close(tmpfd);
g_free(filename2);
- return FALSE;
+ debug_msg("[RETCB] tid(%d) finishing CB (write=%d)\n", tid, rett);
+ } else {
+ debug_msg("[RETCB] No need to send return for RESUME command\n");
}
- rett = write(tmpfd, &buf, sizeof(buf));
- close(tmpfd);
- g_free(filename2);
- asm_info("[RETCB]tid(%d) finishing CB (write=%d)\n", tid, rett);
#endif
}
}
+ debug_fleave();
return TRUE;
}
bool __ASM_add_sound_callback(int index, int fd, gushort events, gLoopPollHandler_t p_gloop_poll_handler )
{
- GSource* cmd_fd_gsrc = NULL;
- GSourceFuncs *src_funcs = NULL; /* handler function */
+ GSource* g_src = NULL;
+ GSourceFuncs *g_src_funcs = NULL; /* handler function */
guint gsource_handle;
- GPollFD *g_fd_cmd = NULL; /* file descriptor */
+ GPollFD *g_poll_fd = NULL; /* file descriptor */
/* 1. make GSource Object */
- src_funcs = (GSourceFuncs *)g_malloc(sizeof(GSourceFuncs));
- if (!src_funcs) {
- asm_info(" __ASM_add_sound_callback : g_malloc failed on g_src_funcs");
+ g_src_funcs = (GSourceFuncs *)g_malloc(sizeof(GSourceFuncs));
+ if (!g_src_funcs) {
+ debug_error("g_malloc failed on g_src_funcs");
return false;
}
- src_funcs->prepare = __asm_fd_prepare;
- src_funcs->check = __asm_fd_check;
- src_funcs->dispatch = __asm_fd_dispatch;
- src_funcs->finalize = NULL;
- cmd_fd_gsrc = g_source_new(src_funcs, sizeof(GSource));
- if (!cmd_fd_gsrc) {
- asm_critical(" __ASM_add_sound_callback : g_malloc failed on m_readfd");
- return false;
+ g_src_funcs->prepare = __asm_fd_prepare;
+ g_src_funcs->check = __asm_fd_check;
+ g_src_funcs->dispatch = __asm_fd_dispatch;
+ g_src_funcs->finalize = NULL;
+ g_src = g_source_new(g_src_funcs, sizeof(GSource));
+ if (!g_src) {
+ debug_error("g_malloc failed on m_readfd");
+ return false;
}
- ASM_sound_handle[index].asm_src = cmd_fd_gsrc;
+ ASM_sound_handle[index].asm_src = g_src;
+ ASM_sound_handle[index].g_src_funcs = g_src_funcs;
+ debug_msg(" g_malloc : g_src_funcs(%#X)", g_src_funcs);
/* 2. add file description which used in g_loop() */
- g_fd_cmd = (GPollFD *)g_malloc(sizeof(GPollFD));
- g_fd_cmd->fd = fd;
- g_fd_cmd->events = events;
+ g_poll_fd = (GPollFD *)g_malloc(sizeof(GPollFD));
+ if (!g_poll_fd) {
+ debug_error("g_malloc failed on g_poll_fd");
+ return false;
+ }
+ g_poll_fd->fd = fd;
+ g_poll_fd->events = events;
+ ASM_sound_handle[index].g_poll_fd = g_poll_fd;
+ debug_msg(" g_malloc : g_poll_fd(%#X)", g_poll_fd);
/* 3. combine g_source object and file descriptor */
- g_source_add_poll(cmd_fd_gsrc, g_fd_cmd);
- gsource_handle = g_source_attach(cmd_fd_gsrc, NULL);
+ g_source_add_poll(g_src, g_poll_fd);
+ gsource_handle = g_source_attach(g_src, NULL);
if (!gsource_handle) {
- asm_critical(" __ASM_add_sound_callback : Error: Failed to attach the source to context");
- return false;
+ debug_error(" Failed to attach the source to context");
+ return false;
}
- asm_info(" g_source_add_poll : g_src_id(%d)\n", gsource_handle);
+ debug_msg(" g_source_add_poll : g_src_id(%d)", gsource_handle);
ASM_sound_handle[index].ASM_g_id = gsource_handle;
/* 4. set callback */
- g_source_set_callback(cmd_fd_gsrc, p_gloop_poll_handler,(gpointer)g_fd_cmd, NULL);
+ g_source_set_callback(g_src, p_gloop_poll_handler,(gpointer)g_poll_fd, NULL);
- asm_info(" g_source_set_callback : %d\n", errno);
- return true;
+ debug_msg(" g_source_set_callback : %d", errno);
+ return true;
}
bool __ASM_remove_sound_callback(int index, gushort events)
{
- bool ret;
- GPollFD *g_fd_cmd = NULL; /* store file descriptor */
+ bool ret = true;
+ gboolean gret = TRUE;
- g_fd_cmd = (GPollFD *)g_malloc(sizeof(GPollFD));
- g_fd_cmd->fd = ASM_sound_handle[index].asm_fd;
- g_fd_cmd->events = events;
+ GSourceFunc *g_src_funcs = ASM_sound_handle[index].g_src_funcs;
+ GPollFD *g_poll_fd = ASM_sound_handle[index].g_poll_fd; /* store file descriptor */
+ if (!g_poll_fd) {
+ debug_error("g_poll_fd is null..");
+ ret = false;
+ goto init_handle;
+ }
+ g_poll_fd->fd = ASM_sound_handle[index].asm_fd;
+ g_poll_fd->events = events;
+
+ debug_msg(" g_source_remove_poll : fd(%d), event(%x)", g_poll_fd->fd, g_poll_fd->events);
+ g_source_remove_poll(ASM_sound_handle[index].asm_src, g_poll_fd);
+ debug_msg(" g_source_remove_poll : %d", errno);
+
+ gret = g_source_remove(ASM_sound_handle[index].ASM_g_id);
+ debug_msg(" g_source_remove : gret(%d)", gret);
+ if (!gret) {
+ debug_error("failed to g_source_remove(). ASM_g_id(%d)", ASM_sound_handle[index].ASM_g_id);
+ ret = false;
+ goto init_handle;
+ }
- asm_info(" g_source_remove_poll : fd(%d), event(%#x)\n", g_fd_cmd->fd, g_fd_cmd->events);
- g_source_remove_poll(ASM_sound_handle[index].asm_src, g_fd_cmd);
- asm_info(" g_source_remove_poll : %d\n", errno);
- ret = g_source_remove(ASM_sound_handle[index].ASM_g_id);
- asm_info(" g_source_remove : ret(%#X)\n", ret);
+init_handle:
+
+ if (g_src_funcs) {
+ debug_msg(" g_free : g_src_funcs(%#X)", g_src_funcs);
+ g_free(g_src_funcs);
+
+ }
+ if (g_poll_fd) {
+ debug_msg(" g_free : g_poll_fd(%#X)", g_poll_fd);
+ g_free(g_poll_fd);
+ }
+ ASM_sound_handle[index].g_src_funcs = NULL;
+ ASM_sound_handle[index].g_poll_fd = NULL;
ASM_sound_handle[index].ASM_g_id = 0;
ASM_sound_handle[index].asm_src = NULL;
ASM_sound_handle[index].asm_callback = NULL;
- return true;
+ return ret;
}
int __ASM_find_index(int handle)
{
int i = 0;
for(i = 0; i< ASM_HANDLE_MAX; i++) {
- if (handle == ASM_sound_handle[i].handle)
+ if (handle == ASM_sound_handle[i].handle) {
+ debug_msg("found index(%d) for handle(%d)", i, handle);
return i;
+ }
}
return -1;
}
void __ASM_add_callback(int index)
{
- __ASM_add_sound_callback(index, ASM_sound_handle[index].asm_fd, (gushort)POLLIN | POLLPRI, asm_callback_handler);
+ if (!__ASM_add_sound_callback(index, ASM_sound_handle[index].asm_fd, (gushort)POLLIN | POLLPRI, asm_callback_handler)) {
+ debug_error("failed to __ASM_add_sound_callback()");
+ //return false;
+ }
}
void __ASM_remove_callback(int index)
{
- __ASM_remove_sound_callback(index, (gushort)POLLIN | POLLPRI);
+ if (!__ASM_remove_sound_callback(index, (gushort)POLLIN | POLLPRI)) {
+ debug_error("failed to __ASM_remove_sound_callback()");
+ //return false;
+ }
}
@@ -379,22 +438,27 @@ void __ASM_open_callback(int index)
{
mode_t pre_mask;
- asm_info(" __ASM_open_callback : index (%d)\n", index);
+ debug_msg("index (%d)", index);
char *filename = g_strdup_printf("/tmp/ASM.%d.%d", ASM_sound_handle[index].asm_tid, ASM_sound_handle[index].handle);
pre_mask = umask(0);
- mknod(filename, S_IFIFO|0666, 0);
+ if (mknod(filename, S_IFIFO|0666, 0)) {
+ debug_error("mknod() failure, errno(%d)", errno);
+ }
umask(pre_mask);
ASM_sound_handle[index].asm_fd = open( filename, O_RDWR|O_NONBLOCK);
- if (ASM_sound_handle[index].asm_fd == -1)
- asm_info(" __ASM_open_callback %s : file open error(%d)\n", str_fail, errno);
- else
- asm_info(" __ASM_open_callback : %s : filename(%s), fd(%d)\n", str_pass, filename, ASM_sound_handle[index].asm_fd);
+ if (ASM_sound_handle[index].asm_fd == -1) {
+ debug_error("%s : file open error(%d)", str_fail, errno);
+ } else {
+ debug_msg("%s : filename(%s), fd(%d)", str_pass, filename, ASM_sound_handle[index].asm_fd);
+ }
g_free(filename);
#ifdef CONFIG_ENABLE_RETCB
char *filename2 = g_strdup_printf("/tmp/ASM.%d.%dr", ASM_sound_handle[index].asm_tid, ASM_sound_handle[index].handle);
pre_mask = umask(0);
- mknod(filename2, S_IFIFO | 0666, 0);
+ if (mknod(filename2, S_IFIFO | 0666, 0)) {
+ debug_error("mknod() failure, errno(%d)", errno);
+ }
umask(pre_mask);
g_free(filename2);
#endif
@@ -404,14 +468,16 @@ void __ASM_open_callback(int index)
void __ASM_close_callback(int index)
{
- asm_info(" __ASM_close_callback : index (%d)\n", index);
+ debug_msg("index (%d)", index);
if (ASM_sound_handle[index].asm_fd < 0) {
- asm_info(" __ASM_close_callback : %s : fd error.\n", str_fail);
+ debug_error("%s : fd error.", str_fail);
} else {
char *filename = g_strdup_printf("/tmp/ASM.%d.%d", ASM_sound_handle[index].asm_tid, ASM_sound_handle[index].handle);
close(ASM_sound_handle[index].asm_fd);
- remove(filename);
- asm_info(" __ASM_close_callback : %s : filename(%s), fd(%d)\n", str_pass, filename, ASM_sound_handle[index].asm_fd);
+ if (remove(filename)) {
+ debug_error("remove() failure, filename(%s), errno(%d)", filename, errno);
+ }
+ debug_msg("%s : filename(%s), fd(%d)", str_pass, filename, ASM_sound_handle[index].asm_fd);
g_free(filename);
}
@@ -426,15 +492,17 @@ void __ASM_close_callback(int index)
if (tmpfd < 0) {
char str_error[256];
strerror_r(errno, str_error, sizeof(str_error));
- asm_error("[__ASM_close_callback][Failed(May Server Close First)]tid(%d) fd(%d) %s errno=%d(%s)\n",
- ASM_sound_handle[index].asm_tid, tmpfd, filename2, errno, str_error);
+ debug_error("failed to open file(%s) (may server close first), tid(%d) fd(%d) %s errno=%d(%s)",
+ filename2, ASM_sound_handle[index].asm_tid, tmpfd, filename2, errno, str_error);
} else {
- asm_info("write ASM_CB_RES_STOP(tid:%d) for waiting server\n", ASM_sound_handle[index].asm_tid);
+ debug_msg("write ASM_CB_RES_STOP(tid:%d) for waiting server", ASM_sound_handle[index].asm_tid);
write(tmpfd, &buf, sizeof(buf));
close(tmpfd);
}
- remove(filename2);
+ if (remove(filename2)) {
+ debug_error("remove() failure, filename(%s), errno(%d)", filename2, errno);
+ }
g_free(filename2);
#endif
@@ -451,10 +519,10 @@ bool __asm_construct_snd_msg(int asm_pid, int handle, ASM_sound_events_t sound_e
asm_snd_msg.data.sound_state = sound_state;
asm_snd_msg.data.system_resource = resource;
- asm_info(" ASM_Lib send message (tid=%ld,handle=%d,req=%d,evt=%d,state=%d,resource=%d)\n", asm_snd_msg.instance_id, asm_snd_msg.data.handle,
+ debug_msg("tid=%ld,handle=%d,req=%d,evt=%d,state=%d,resource=%d", asm_snd_msg.instance_id, asm_snd_msg.data.handle,
asm_snd_msg.data.request_id, asm_snd_msg.data.sound_event, asm_snd_msg.data.sound_state, asm_snd_msg.data.system_resource);
- asm_info(" instance_id : %ld\n", asm_snd_msg.instance_id);
- asm_info(" handle : %d\n", asm_snd_msg.data.handle);
+ debug_msg(" instance_id : %ld\n", asm_snd_msg.instance_id);
+ debug_msg(" handle : %d\n", asm_snd_msg.data.handle);
return true;
}
@@ -466,14 +534,11 @@ bool __ASM_init_msg(int *error_code)
asm_rcv_msgid = msgget((key_t)4102, 0666);
asm_cb_msgid = msgget((key_t)4103, 0666);
-
- asm_info(" __asm_init !! : snd_msqid(%#X), rcv_msqid(%#X), cb_msqid(%#X)\n", asm_snd_msgid,
- asm_rcv_msgid, asm_cb_msgid);
-
+ debug_msg("snd_msqid(%#X), rcv_msqid(%#X), cb_msqid(%#X)\n", asm_snd_msgid, asm_rcv_msgid, asm_cb_msgid);
if (asm_snd_msgid == -1 || asm_rcv_msgid == -1 || asm_cb_msgid == -1 ) {
*error_code = ERR_ASM_MSG_QUEUE_MSGID_GET_FAILED;
- asm_info(" __ASM_init : Msgget failed with error.\n");
+ debug_error("failed to msgget with error(%d)",error_code);
return false;
}
@@ -482,16 +547,19 @@ bool __ASM_init_msg(int *error_code)
void __ASM_init_callback(int index)
{
+ debug_fenter();
__ASM_open_callback(index);
__ASM_add_callback(index);
+ debug_fleave();
}
void __ASM_destroy_callback(int index)
{
- asm_info(" __ASM_destroy_callback !!\n");
+ debug_fenter();
__ASM_remove_callback(index);
__ASM_close_callback(index);
+ debug_fleave();
}
#ifdef USE_SECURITY
@@ -499,27 +567,27 @@ bool __ASM_set_cookie (unsigned char* cookie)
{
int retval = -1;
int cookie_size = 0;
- asm_info ("<<<< [%s]\n", __func__);
cookie_size = security_server_get_cookie_size();
if (cookie_size != COOKIE_SIZE) {
- asm_error ("[Security] security_server_get_cookie_size(%d) != COOKIE_SIZE(%d)\n", cookie_size, COOKIE_SIZE);
+ debug_error ("[Security] security_server_get_cookie_size(%d) != COOKIE_SIZE(%d)\n", cookie_size, COOKIE_SIZE);
return false;
}
retval = security_server_request_cookie (cookie, COOKIE_SIZE);
if (retval == SECURITY_SERVER_API_SUCCESS) {
- asm_info ("[Security] security_server_request_cookie() returns [%d]\n", retval);
+ debug_msg ("[Security] security_server_request_cookie() returns [%d]\n", retval);
return true;
} else {
- asm_error ("[Security] security_server_request_cookie() returns [%d]\n", retval);
+ debug_error ("[Security] security_server_request_cookie() returns [%d]\n", retval);
return false;
}
}
#endif
EXPORT_API
-bool ASM_register_sound(const int application_pid, int *asm_handle, ASM_sound_events_t sound_event, ASM_sound_states_t sound_state, ASM_sound_cb_t callback, void *cb_data, ASM_resource_t mm_resource, int *error_code)
+bool ASM_register_sound_ex (const int application_pid, int *asm_handle, ASM_sound_events_t sound_event, ASM_sound_states_t sound_state,
+ ASM_sound_cb_t callback, void *cb_data, ASM_resource_t mm_resource, int *error_code, int (*func)(void*,void*))
{
int error = 0;
unsigned int sound_status_value;
@@ -529,26 +597,28 @@ bool ASM_register_sound(const int application_pid, int *asm_handle, ASM_sound_ev
int ret = 0;
unsigned int rcv_sound_status_value;
+ debug_fenter();
+
if (error_code==NULL) {
- asm_error_r("[Error] ASM_register_sound : invalid parameter. \n");
+ debug_error ("invalid parameter. error code is null");
return false;
}
if (sound_event< ASM_EVENT_SHARE_MMPLAYER || sound_event >= ASM_EVENT_MAX) {
*error_code = ERR_ASM_EVENT_IS_INVALID;
- asm_error_r("[Error] ASM_register_sound : invalid sound event \n");
+ debug_error ("invalid sound event(%d)",sound_event);
return false;
}
for (index = 0; index < ASM_HANDLE_MAX; index++) {
- if (ASM_sound_handle[index].is_used == FALSE) {
+ if (ASM_sound_handle[index].is_used == false) {
break;
}
}
if (index == ASM_HANDLE_MAX) {
*error_code = ERR_ASM_EVENT_IS_FULL;
- asm_error_r("[Error] >>>> ASM_register_sound : local sound event is full(MAX) \n");
+ debug_error ("local sound event is full(MAX)");
return false;
}
@@ -558,32 +628,32 @@ bool ASM_register_sound(const int application_pid, int *asm_handle, ASM_sound_ev
asm_pid = application_pid;
} else {
*error_code = ERR_ASM_INVALID_PARAMETER;
- asm_error_r("[Error] >>>> ASM_register_sound : invalid pid %d\n", application_pid);
+ debug_error ("invalid pid %d", application_pid);
return false;
}
ASM_sound_handle[index].sound_event = sound_event;
ASM_sound_handle[index].asm_tid = asm_pid;
- asm_info(" <<<< ASM_register_sound : Event(%s), Tid(%d), Index(%d) \n", ASM_sound_events_str[sound_event], ASM_sound_handle[index].asm_tid, index);
+ debug_msg(" <<<< Event(%s), Tid(%d), Index(%d)", ASM_sound_events_str[sound_event], ASM_sound_handle[index].asm_tid, index);
if (!__ASM_init_msg(&error)) {
- asm_error("[Error = %d] >>>> ASM_register_sound =>__asm_init \n", error);
+ debug_error("failed to __ASM_init_msg(), error(%d)", error);
}
if (!__ASM_get_sound_state(&sound_status_value, error_code)) {
- asm_error("[Error = %d] >>>> ASM_register_sound => __ASM_get_sound_state \n", *error_code);
+ debug_error("failed to __ASM_get_sound_state(), error(%d)", *error_code);
}
/* If state is PLAYING, do set state immediately */
if (sound_state == ASM_STATE_PLAYING) {
- asm_info(" <<<< ASM_register_sound : Event(%s), Tid(%d), State(PLAYING) \n", ASM_sound_events_str[sound_event], ASM_sound_handle[index].asm_tid);
+ debug_msg(" <<<< Event(%s), Tid(%d), State(PLAYING)", ASM_sound_events_str[sound_event], ASM_sound_handle[index].asm_tid);
if (!__ASM_set_sound_state(sound_event, ASM_STATE_PLAYING, error_code)) {
- asm_error_r("[Error = %d] >>>> ASM_register_sound => __ASM_set_sound_state(PLAYING) \n", *error_code);
+ debug_error("failed to __ASM_set_sound_state(PLAYING), error(%d)", *error_code);
return false;
}
} else {
- asm_info(" <<<< ASM_register_sound : Event(%s), Tid(%ld), State(WAITING) \n", ASM_sound_events_str[sound_event], asmgettid());
+ debug_msg(" <<<< Event(%s), Tid(%ld), State(WAITING)", ASM_sound_events_str[sound_event], asmgettid());
}
@@ -591,43 +661,50 @@ bool ASM_register_sound(const int application_pid, int *asm_handle, ASM_sound_ev
#ifdef USE_SECURITY
/* get cookie from security server */
- if (__ASM_set_cookie (asm_snd_msg.data.cookie) == false)
+ if (__ASM_set_cookie (asm_snd_msg.data.cookie) == false) {
+ debug_error("failed to ASM_set_cookie()");
return false;
+ }
#endif
/* Construct msg to send -> send msg -> recv msg */
if (!__asm_construct_snd_msg(asm_pid, handle, sound_event, ASM_REQUEST_REGISTER, sound_state, mm_resource, error_code)) {
- asm_error_r("[Error] >>>> ASM_register_sound : Send msg construct failed.\n");
+ debug_error("failed to __asm_construct_snd_msg(), error(%d)", *error_code);
return false;
}
- NO_EINTR(ret = msgsnd(asm_snd_msgid, (void *)&asm_snd_msg, sizeof(asm_snd_msg.data), 0));
- if (ret == -1) {
- *error_code = ERR_ASM_MSG_QUEUE_SND_ERROR;
- asm_error_r("[Error] >>>> ASM_register_sound : Msgsnd failed (%d,%s) \n", errno, strerror(errno));
- return false;
- }
- NO_EINTR(ret = msgrcv(asm_rcv_msgid, (void *)&asm_rcv_msg, sizeof(asm_rcv_msg.data), asm_pid, 0));
- if (ret == -1) {
- *error_code = ERR_ASM_MSG_QUEUE_RCV_ERROR;
- asm_error_r("[Error] >>>> ASM_register_sound : Msgrcv failed (%d,%s) \n", errno, strerror(errno));
- return false;
+
+ if (func) {
+ func ((void*)&asm_snd_msg, (void*)&asm_rcv_msg);
+ } else {
+ NO_EINTR(ret = msgsnd(asm_snd_msgid, (void *)&asm_snd_msg, sizeof(asm_snd_msg.data), 0));
+ if (ret == -1) {
+ *error_code = ERR_ASM_MSG_QUEUE_SND_ERROR;
+ debug_error("failed to msgsnd(%d,%s)", errno, strerror(errno));
+ return false;
+ }
+ NO_EINTR(ret = msgrcv(asm_rcv_msgid, (void *)&asm_rcv_msg, sizeof(asm_rcv_msg.data), asm_pid, 0));
+ if (ret == -1) {
+ *error_code = ERR_ASM_MSG_QUEUE_RCV_ERROR;
+ debug_error("failed to msgrcv(%d,%s)", errno, strerror(errno));
+ return false;
+ }
}
/* Construct msg to send -> send msg -> recv msg : end */
#ifdef USE_SECURITY
/* Check privilege first */
if (asm_rcv_msg.data.check_privilege == 0) {
- asm_error_r("[Security] Check privilege from server Failed!!!\n");
+ debug_error("[Security] Check privilege from server Failed!!!");
*error_code = ERR_ASM_CHECK_PRIVILEGE_FAILED;
return false;
} else {
- asm_info ("[Security] Check privilege from server Success");
+ debug_msg ("[Security] Check privilege from server Success");
}
#endif
handle = asm_rcv_msg.data.alloc_handle; /* get handle from server */
if (handle == -1) {
- asm_error_r("[Error] >>> ASM_register_sound : Create handle from server failed\n");
+ debug_error("failed to create handle from server");
*error_code = ERR_ASM_HANDLE_IS_FULL;
return false;
}
@@ -636,20 +713,18 @@ bool ASM_register_sound(const int application_pid, int *asm_handle, ASM_sound_ev
__ASM_init_callback(index);
- asm_info( "ASM_register_sound \n");
/********************************************************************************************************/
switch (asm_rcv_msg.data.result_sound_command) {
case ASM_COMMAND_PAUSE:
case ASM_COMMAND_STOP:
if (handle == asm_rcv_msg.data.cmd_handle) {
-
__ASM_destroy_callback(index);
ASM_sound_handle[index].asm_fd = 0;
ASM_sound_handle[index].asm_tid = 0;
ASM_sound_handle[index].sound_event = ASM_EVENT_NONE;
- ASM_sound_handle[index].is_used = FALSE;
+ ASM_sound_handle[index].is_used = false;
*error_code = ERR_ASM_POLICY_CANNOT_PLAY;
return false;
@@ -657,18 +732,18 @@ bool ASM_register_sound(const int application_pid, int *asm_handle, ASM_sound_ev
int action_index = 0;
if (!__ASM_get_sound_state(&rcv_sound_status_value, error_code)) {
- asm_error("[ASM_CB][Error = %d] asm_callback_handler : ASM_set_sound_state => __ASM_get_sound_state \n", *error_code);
+ debug_error("failed to __ASM_get_sound_state(), error(%d)", *error_code);
}
- asm_info("[ASM_CB] asm_callback_handler : Callback : TID(%ld), handle(%d)\n", asm_rcv_msg.instance_id, asm_rcv_msg.data.cmd_handle);
+ debug_msg("Callback : TID(%ld), handle(%d), command(%d)", asm_rcv_msg.instance_id, asm_rcv_msg.data.cmd_handle, asm_rcv_msg.data.result_sound_command);
action_index = __ASM_find_index(asm_rcv_msg.data.cmd_handle);
if (action_index == -1) {
- asm_error("[ASM_CB] Can not find index of instance %ld, handle %d\n", asm_rcv_msg.instance_id, asm_rcv_msg.data.cmd_handle);
+ debug_error("Can not find index of instance %ld, handle %d", asm_rcv_msg.instance_id, asm_rcv_msg.data.cmd_handle);
} else {
if (ASM_sound_handle[action_index].asm_callback!=NULL) {
ASM_sound_handle[action_index].asm_callback(asm_rcv_msg.data.cmd_handle, ASM_sound_handle[action_index].sound_event, asm_rcv_msg.data.result_sound_command, rcv_sound_status_value, ASM_sound_handle[action_index].cb_data);
} else {
- asm_info("[ASM_CB] null callback");
+ debug_msg("null callback");
}
}
}
@@ -685,29 +760,39 @@ bool ASM_register_sound(const int application_pid, int *asm_handle, ASM_sound_ev
ASM_sound_handle[index].asm_callback = callback;
ASM_sound_handle[index].cb_data = cb_data;
- ASM_sound_handle[index].is_used = TRUE;
+ ASM_sound_handle[index].is_used = true;
- asm_info(" >>>> ASM_register_sound : Event(%s), Handle(%d), CBFuncPtr(%p) \n", ASM_sound_events_str[sound_event], handle, callback);
+ debug_msg(" >>>> Event(%s), Handle(%d), CBFuncPtr(%p)", ASM_sound_events_str[sound_event], handle, callback);
/* Add [out] param, asm_handle */
*asm_handle = handle;
+ debug_fleave();
+
return true;
}
EXPORT_API
+bool ASM_register_sound (const int application_pid, int *asm_handle, ASM_sound_events_t sound_event, ASM_sound_states_t sound_state,
+ ASM_sound_cb_t callback, void *cb_data, ASM_resource_t mm_resource, int *error_code)
+{
+ return ASM_register_sound_ex (application_pid, asm_handle, sound_event, sound_state, callback, cb_data, mm_resource, error_code, NULL);
+}
+
+
+EXPORT_API
bool ASM_change_callback(const int asm_handle, ASM_sound_events_t sound_event, ASM_sound_cb_t callback, void *cb_data, int *error_code)
{
int handle=0;
if (error_code==NULL) {
- asm_error_r("[Error] ASM_unregister_sound : invalid parameter. \n");
+ debug_error ("invalid parameter. error code is null");
return false;
}
if (sound_event < ASM_EVENT_SHARE_MMPLAYER || sound_event >= ASM_EVENT_MAX) {
*error_code = ERR_ASM_EVENT_IS_INVALID;
- asm_error_r("[Error] ASM_unregister_sound : invalid sound event \n");
+ debug_error ("invalid sound event(%d)",sound_event);
return false;
}
@@ -715,7 +800,7 @@ bool ASM_change_callback(const int asm_handle, ASM_sound_events_t sound_event, A
if (asm_handle < 0 || asm_handle >= ASM_SERVER_HANDLE_MAX) {
*error_code = ERR_ASM_POLICY_INVALID_HANDLE;
- asm_error_r("[Error] >>>> invalid handle %d. callback is not registered\n", asm_handle);
+ debug_error("invalid handle(%d). callback is not registered", asm_handle);
return false;
}
@@ -724,39 +809,40 @@ bool ASM_change_callback(const int asm_handle, ASM_sound_events_t sound_event, A
asm_index = __ASM_find_index(handle);
if (asm_index == -1) {
*error_code = ERR_ASM_POLICY_INVALID_HANDLE;
- asm_error_r("[Error] >>>> Can not find index for handle %d [%d]\n", handle, __LINE__);
+ debug_error("Can not find index for handle %d", handle);
return false;
}
- asm_info("callback function has changed to %p\n", callback);
+ debug_msg("callback function has changed to %p", callback);
ASM_sound_handle[asm_index].asm_callback = callback;
ASM_sound_handle[asm_index].cb_data = cb_data;
return true;
}
-
EXPORT_API
-bool ASM_unregister_sound(const int asm_handle, ASM_sound_events_t sound_event, int *error_code)
+bool ASM_unregister_sound_ex(const int asm_handle, ASM_sound_events_t sound_event, int *error_code, int (*func)(void*,void*))
{
int handle=0;
int asm_index = -1;
int ret = 0;
+ debug_fenter();
+
if (error_code==NULL) {
- asm_error_r("[Error] ASM_unregister_sound : invalid parameter. \n");
+ debug_error ("invalid parameter. error code is null");
return false;
}
if (sound_event<ASM_EVENT_SHARE_MMPLAYER || sound_event >= ASM_EVENT_MAX) {
*error_code = ERR_ASM_EVENT_IS_INVALID;
- asm_error_r("[Error] ASM_unregister_sound : invalid sound event %d\n", sound_event);
+ debug_error ("invalid sound event(%d)",sound_event);
return false;
}
if (asm_handle < 0 || asm_handle >= ASM_SERVER_HANDLE_MAX) {
*error_code = ERR_ASM_POLICY_INVALID_HANDLE;
- asm_error_r("[Error] >>>> invalid handle %d. callback is not registered\n", asm_handle);
+ debug_error("invalid handle(%d). callback is not registered", asm_handle);
return false;
}
@@ -764,22 +850,26 @@ bool ASM_unregister_sound(const int asm_handle, ASM_sound_events_t sound_event,
asm_index = __ASM_find_index(handle);
if (asm_index == -1) {
*error_code = ERR_ASM_POLICY_INVALID_HANDLE;
- asm_error_r("[Error] >>>> Can not find index for handle %d [%d]\n", handle, __LINE__);
+ debug_error("Can not find index for handle(%d)", handle);
return false;
}
- asm_info("<<<< ASM_unregister_sound : Event(%s), Tid(%d), Handle(%d) Index(%d)\n",
+ debug_msg("<<<< Event(%s), Tid(%d), Handle(%d) Index(%d)",
ASM_sound_events_str[sound_event], ASM_sound_handle[asm_index].asm_tid, ASM_sound_handle[asm_index].handle, asm_index);
if (!__asm_construct_snd_msg(ASM_sound_handle[asm_index].asm_tid, handle, sound_event, ASM_REQUEST_UNREGISTER, ASM_STATE_NONE, ASM_RESOURCE_NONE, error_code)) {
- asm_error_r(">>>> Send msg construct failed.\n");
+ debug_error("failed to __asm_construct_snd_msg(), error(%d)", *error_code);
return false;
}
- NO_EINTR(ret = msgsnd(asm_snd_msgid, (void *)&asm_snd_msg, sizeof(asm_snd_msg.data), 0));
- if (ret == -1) {
- *error_code = ERR_ASM_MSG_QUEUE_SND_ERROR;
- asm_error_r("[Error] >>>> ASM_unregister_sound : Msgsnd failed (%d,%s) \n", errno, strerror(errno));
- return false;
+ if (func) {
+ func(&asm_snd_msg, &asm_rcv_msg);
+ } else {
+ NO_EINTR(ret = msgsnd(asm_snd_msgid, (void *)&asm_snd_msg, sizeof(asm_snd_msg.data), 0));
+ if (ret == -1) {
+ *error_code = ERR_ASM_MSG_QUEUE_SND_ERROR;
+ debug_error("failed to msgsnd(%d,%s)", errno, strerror(errno));
+ return false;
+ }
}
__ASM_destroy_callback(asm_index);
@@ -787,32 +877,38 @@ bool ASM_unregister_sound(const int asm_handle, ASM_sound_events_t sound_event,
ASM_sound_handle[asm_index].asm_fd = 0;
ASM_sound_handle[asm_index].asm_tid = 0;
ASM_sound_handle[asm_index].sound_event = ASM_EVENT_NONE;
- ASM_sound_handle[asm_index].is_used = FALSE;
+ ASM_sound_handle[asm_index].is_used = false;
- asm_info(">>>> ASM_unregister_sound : Event(%s) \n", ASM_sound_events_str[sound_event]);
+ debug_msg(">>>> Event(%s)", ASM_sound_events_str[sound_event]);
+
+ debug_fleave();
return true;
}
EXPORT_API
+bool ASM_unregister_sound(const int asm_handle, ASM_sound_events_t sound_event, int *error_code)
+{
+ return ASM_unregister_sound_ex (asm_handle, sound_event, error_code, NULL);
+}
+
+EXPORT_API
bool ASM_get_sound_status(unsigned int *all_sound_status, int *error_code)
{
if (all_sound_status == NULL || error_code == NULL) {
if (error_code)
*error_code = ERR_ASM_UNKNOWN_ERROR;
- asm_error_r("[Error] ASM_get_sound_status : invalid parameter \n");
+ debug_error("invalid parameter");
return false;
}
- asm_info("<<<< ASM_get_sound_status : Tid(%ld) \n", asmgettid());
+ debug_msg("Tid(%ld)", asmgettid());
if (!__ASM_get_sound_state(all_sound_status, error_code)) {
- asm_error_r("[Error = %d] >>>> ASM_get_sound_status => __ASM_get_sound_state \n", *error_code);
+ debug_error("failed to __ASM_get_sound_state(), error(%d)", *error_code);
return false;
}
- asm_info(">>>> ASM_get_sound_status : All status(%#X) \n", *all_sound_status);
-
return true;
}
@@ -826,22 +922,22 @@ bool ASM_get_process_session_state(const int asm_handle, ASM_sound_states_t *sou
if (sound_state == NULL || error_code == NULL) {
if (error_code)
*error_code = ERR_ASM_UNKNOWN_ERROR;
- asm_error_r("[Error] ASM_get_process_session_state : invalid parameter \n");
+ debug_error("invalid parameter");
return false;
}
handle = asm_handle;
asm_index = __ASM_find_index(handle);
if (asm_index == -1) {
- asm_error_r("Can not find index of %d [%d]\n", handle, __LINE__);
+ debug_error("Can not find index of %d", handle);
return false;
}
- asm_info("<<<< ASM_get_process_session_state : Pid(%d)\n", ASM_sound_handle[asm_index].asm_tid);
+ debug_msg("Pid(%d)", ASM_sound_handle[asm_index].asm_tid);
if (!__asm_construct_snd_msg(ASM_sound_handle[asm_index].asm_tid, handle, ASM_EVENT_MONITOR, ASM_REQUEST_GETMYSTATE, ASM_STATE_NONE, ASM_RESOURCE_NONE, error_code)) {
- asm_error_r("[Error] >>>> ASM_get_sound_state : Send msg construct failed.\n");
+ debug_error("failed to __asm_construct_snd_msg(), error(%d)", *error_code);
return false;
}
@@ -849,20 +945,20 @@ bool ASM_get_process_session_state(const int asm_handle, ASM_sound_states_t *sou
NO_EINTR(ret = msgsnd(asm_snd_msgid, (void *)&asm_snd_msg, sizeof(asm_snd_msg.data), 0));
if (ret == -1) {
*error_code = ERR_ASM_MSG_QUEUE_SND_ERROR;
- asm_error_r("[Error] >>>> ASM_get_process_session_state : Msgsnd failed (%d,%s) \n", errno, strerror(errno));
+ debug_error("failed to msgsnd(%d,%s)", errno, strerror(errno));
return false;
}
NO_EINTR(ret = msgrcv(asm_rcv_msgid, (void *)&asm_rcv_msg, sizeof(asm_rcv_msg.data), asm_snd_msg.instance_id, 0));
if (ret == -1) {
*error_code = ERR_ASM_MSG_QUEUE_RCV_ERROR;
- asm_error_r("[Error] >>>> ASM_get_process_session_state : Msgrcv failed (%d,%s) \n", errno, strerror(errno));
+ debug_error("failed to msgrcv(%d,%s)", errno, strerror(errno));
return false;
}
*sound_state = asm_rcv_msg.data.result_sound_state;
- asm_info(">>>> ASM_get_process_session_state : Pid(%d), State(%s) \n", ASM_sound_handle[asm_index].asm_tid, ASM_sound_state_str[*sound_state]);
+ debug_msg(">>>> Pid(%d), State(%s)", ASM_sound_handle[asm_index].asm_tid, ASM_sound_state_str[*sound_state]);
return true;
@@ -878,26 +974,26 @@ bool ASM_get_sound_state(const int asm_handle, ASM_sound_events_t sound_event, A
if (sound_state == NULL || error_code == NULL) {
if (error_code)
*error_code = ERR_ASM_UNKNOWN_ERROR;
- asm_error_r("[Error] ASM_get_sound_state : invalid parameter \n");
+ debug_error("invalid parameter");
return false;
}
if (sound_event < ASM_EVENT_SHARE_MMPLAYER || sound_event >= ASM_EVENT_MAX) {
*error_code = ERR_ASM_EVENT_IS_INVALID;
- asm_error_r("[Error] ASM_get_sound_state : invalid sound event (%x)\n",sound_event);
+ debug_error("invalid sound event(%d)",sound_event);
return false;
}
handle = asm_handle;
asm_index = __ASM_find_index(handle);
if (asm_index == -1) {
- asm_error_r("Can not find index of %d [%d]\n", handle, __LINE__);
+ debug_error("Can not find index of %d", handle);
return false;
}
- asm_info("<<<< ASM_get_sound_state : Event(%s), Tid(%d), handle(%d)\n",
+ debug_msg("<<<< Event(%s), Tid(%d), handle(%d)",
ASM_sound_events_str[sound_event], ASM_sound_handle[asm_index].asm_tid, ASM_sound_handle[asm_index].handle);
if (!__asm_construct_snd_msg(ASM_sound_handle[asm_index].asm_tid, handle, sound_event, ASM_REQUEST_GETSTATE, ASM_STATE_NONE, ASM_RESOURCE_NONE, error_code)) {
- asm_error_r("[Error] >>>> ASM_get_sound_state : Send msg construct failed.\n");
+ debug_error("failed to __asm_construct_snd_msg(), error(%d)", *error_code);
return false;
}
@@ -905,50 +1001,49 @@ bool ASM_get_sound_state(const int asm_handle, ASM_sound_events_t sound_event, A
NO_EINTR(ret = msgsnd(asm_snd_msgid, (void *)&asm_snd_msg, sizeof(asm_snd_msg.data), 0));
if (ret == -1) {
*error_code = ERR_ASM_MSG_QUEUE_SND_ERROR;
- asm_error_r("[Error] >>>> ASM_get_sound_state : Msgsnd failed (%d,%s) \n", errno, strerror(errno));
+ debug_error("failed to msgsnd(%d,%s)", errno, strerror(errno));
return false;
}
NO_EINTR(ret = msgrcv(asm_rcv_msgid, (void *)&asm_rcv_msg, sizeof(asm_rcv_msg.data), asm_snd_msg.instance_id, 0));
if (ret == -1) {
*error_code = ERR_ASM_MSG_QUEUE_RCV_ERROR;
- asm_error_r("[Error] >>>> ASM_get_sound_state : Msgrcv failed (%d,%s) \n", errno, strerror(errno));
+ debug_error("failed to msgrcv(%d,%s)", errno, strerror(errno));
return false;
}
*sound_state = asm_rcv_msg.data.result_sound_state;
- asm_info(">>>> ASM_get_sound_state : Event(%s), State(%s) \n",
- ASM_sound_events_str[sound_event], ASM_sound_state_str[*sound_state]);
+ debug_msg(">>>> Event(%s), State(%s)", ASM_sound_events_str[sound_event], ASM_sound_state_str[*sound_state]);
return true;
}
-
EXPORT_API
-bool ASM_set_sound_state(const int asm_handle, ASM_sound_events_t sound_event, ASM_sound_states_t sound_state, ASM_resource_t mm_resource, int *error_code)
+bool ASM_set_sound_state_ex (const int asm_handle, ASM_sound_events_t sound_event, ASM_sound_states_t sound_state, ASM_resource_t mm_resource, int *error_code, int (*func)(void*,void*))
{
int handle = 0;
int asm_index = 0;
int ret = 0;
unsigned int rcv_sound_status_value;
- asm_info("<<<< ASM_set_sound_state \n");
+ debug_fenter();
+
if (error_code == NULL) {
- asm_error_r("error_code is null \n");
+ debug_error("error_code is null");
return false;
}
if (sound_event < 0 || sound_event > ASM_PRIORITY_MATRIX_MIN) {
- asm_error_r(" ASM_set_sound_state(%x,%x) arg is out of bound!!\n", sound_event, sound_state);
+ debug_error("invalid sound event(%d)",sound_event);
*error_code = ERR_ASM_EVENT_IS_INVALID;
return false;
}
if (asm_handle < 0 || asm_handle >= ASM_SERVER_HANDLE_MAX) {
*error_code = ERR_ASM_POLICY_INVALID_HANDLE;
- asm_error_r("[Error] ASM_set_sound_state : Invalid handle %d \n", asm_handle);
+ debug_error("Invalid handle %d", asm_handle);
return false;
}
@@ -956,70 +1051,99 @@ bool ASM_set_sound_state(const int asm_handle, ASM_sound_events_t sound_event, A
asm_index = __ASM_find_index(handle);
if (asm_index == -1) {
- asm_error_r("Can not find index of %d [%d]\n", handle, __LINE__);
+ debug_error("Can not find index of %d", handle);
return false;
}
- asm_info("<<<< ASM_set_sound_state : Event(%s), State(%s), Tid(%d), handle(%d) \n",
+ debug_msg("<<<< Event(%s), State(%s), Tid(%d), handle(%d)",
ASM_sound_events_str[sound_event], ASM_sound_state_str[sound_state], ASM_sound_handle[asm_index].asm_tid, ASM_sound_handle[asm_index].handle);
-
if (!__asm_construct_snd_msg(ASM_sound_handle[asm_index].asm_tid, ASM_sound_handle[asm_index].handle, sound_event, ASM_REQUEST_SETSTATE, sound_state, mm_resource, error_code)) {
- asm_error_r("[Error] >>>> ASM_set_sound_state : Send msg construct failed.\n");
+ debug_error("failed to __asm_construct_snd_msg(), error(%d)", *error_code);
return false;
}
- NO_EINTR(ret = msgsnd(asm_snd_msgid, (void *)&asm_snd_msg, sizeof(asm_snd_msg.data), 0));
- if (ret == -1) {
- *error_code = ERR_ASM_MSG_QUEUE_SND_ERROR;
- asm_error_r("[Error] >>>> ASM_set_sound_state : Msgsnd failed (%d,%s) \n", errno, strerror(errno));
- return false;
+ if (func) {
+ debug_msg( "[func(%p) START]", func);
+ func (&asm_snd_msg, &asm_rcv_msg);
+ debug_msg( "[func END]");
+ } else {
+ NO_EINTR(ret = msgsnd(asm_snd_msgid, (void *)&asm_snd_msg, sizeof(asm_snd_msg.data), 0));
+ if (ret == -1) {
+ *error_code = ERR_ASM_MSG_QUEUE_SND_ERROR;
+ debug_error("failed to msgsnd(%d,%s)", errno, strerror(errno));
+ return false;
+ }
}
if (sound_state == ASM_STATE_PLAYING ) {
- NO_EINTR(ret = msgrcv(asm_rcv_msgid, (void *)&asm_rcv_msg, sizeof(asm_rcv_msg.data), ASM_sound_handle[handle].asm_tid, 0));
- if (ret == -1) {
- *error_code = ERR_ASM_MSG_QUEUE_RCV_ERROR;
- asm_error_r("[Error] >>>> ASM_set_sound_state : Msgrcv failed (%d,%s) \n", errno, strerror(errno));
- return false;
+ debug_msg( "sound_state is PLAYING");
+ if (func == NULL) {
+ NO_EINTR(ret = msgrcv(asm_rcv_msgid, (void *)&asm_rcv_msg, sizeof(asm_rcv_msg.data), ASM_sound_handle[handle].asm_tid, 0));
+ if (ret == -1) {
+ *error_code = ERR_ASM_MSG_QUEUE_RCV_ERROR;
+ debug_error("failed to msgrcv(%d,%s)", errno, strerror(errno));
+ return false;
+ } else {
+
+ }
}
- asm_info( " <<<<<<<<<<<<<<<< [BEFORE] Callback : Main Context >>>>>>>>>>>>>>>>>>>> \n");
+ debug_msg( " <<<<<<<<<<<<<<<< [BEFORE] Callback : Main Context >>>>>>>>>>>>>>>>>>>> \n");
/********************************************************************************************************/
switch (asm_rcv_msg.data.result_sound_command) {
case ASM_COMMAND_PAUSE:
case ASM_COMMAND_STOP:
if (handle == asm_rcv_msg.data.cmd_handle) {
+ debug_msg("handle(%d) is same as asm_rcv_msg.data.cmd_handle", handle);
+
asm_index = __ASM_find_index(asm_rcv_msg.data.cmd_handle);
if (asm_index == -1) {
*error_code = ERR_ASM_POLICY_INVALID_HANDLE;
- asm_error_r( "[Error] >>>> Can not find index from instance_id %ld, handle %d [%d]\n",
- asm_rcv_msg.instance_id, asm_rcv_msg.data.cmd_handle, __LINE__);
+ debug_error( "Can not find index from instance_id %ld, handle %d", asm_rcv_msg.instance_id, asm_rcv_msg.data.cmd_handle);
return false;
}
- *error_code = ERR_ASM_POLICY_CANNOT_PLAY;
+ /* check former sound event */
+ switch (asm_rcv_msg.data.former_sound_event) {
+ case ASM_EVENT_ALARM:
+ debug_msg("blocked by ALARM");
+ *error_code = ERR_ASM_POLICY_CANNOT_PLAY_BY_ALARM;
+ break;
+ case ASM_EVENT_CALL:
+ case ASM_EVENT_VIDEOCALL:
+ case ASM_EVENT_RICH_CALL:
+ debug_msg("blocked by CALL/VIDEOCALL/RICH_CALL");
+ *error_code = ERR_ASM_POLICY_CANNOT_PLAY_BY_CALL;
+ break;
+ default:
+ debug_msg("blocked by Other(sound_event num:%d)", asm_rcv_msg.data.former_sound_event);
+ *error_code = ERR_ASM_POLICY_CANNOT_PLAY;
+ break;
+ }
return false;
} else {
+
if (!__ASM_get_sound_state(&rcv_sound_status_value, error_code)) {
- asm_error("[ASM_CB][Error = %d] asm_callback_handler : ASM_set_sound_state => __ASM_get_sound_state \n", *error_code);
+ debug_error("failed to __ASM_get_sound_state(), error(%d)", *error_code);
}
- asm_info("[ASM_CB] asm_callback_handler : Callback : TID(%ld), handle(%d)\n", asm_rcv_msg.instance_id, asm_rcv_msg.data.cmd_handle);
+ debug_msg("[ASM_CB] Callback : TID(%ld), handle(%d)", asm_rcv_msg.instance_id, asm_rcv_msg.data.cmd_handle);
asm_index = __ASM_find_index(asm_rcv_msg.data.cmd_handle);
if (asm_index == -1) {
*error_code = ERR_ASM_POLICY_INVALID_HANDLE;
- asm_error_r("[Error] >>>> Can not find index from instance_id %ld, handle %d [%d]\n",
- asm_rcv_msg.instance_id, asm_rcv_msg.data.cmd_handle, __LINE__);
+ debug_error("Can not find index from instance_id %ld, handle %d", asm_rcv_msg.instance_id, asm_rcv_msg.data.cmd_handle);
return false;
}
if (ASM_sound_handle[asm_index].asm_callback!=NULL) {
+ debug_msg( "[ASM_CB(%p) START]", ASM_sound_handle[asm_index].asm_callback);
ASM_sound_handle[asm_index].asm_callback(asm_rcv_msg.data.cmd_handle, ASM_sound_handle[asm_index].sound_event, asm_rcv_msg.data.result_sound_command, rcv_sound_status_value, ASM_sound_handle[asm_index].cb_data);
+ debug_msg( "[ASM_CB END]");
} else {
- asm_info("[ASM_CB]callback in null\n");
+ debug_msg("asm callback is null");
}
}
break;
@@ -1031,12 +1155,168 @@ bool ASM_set_sound_state(const int asm_handle, ASM_sound_events_t sound_event, A
break;
}
/********************************************************************************************************/
- asm_info(" <<<<<<<<<<<<<<<< [AFTER] Callback : Main Context >>>>>>>>>>>>>>>>>>>> \n");
+ debug_msg(" <<<<<<<<<<<<<<<< [AFTER] Callback : Main Context >>>>>>>>>>>>>>>>>>>> \n");
}
- asm_info(">>>> ASM_set_sound_state : Event(%s), State(%s) \n", ASM_sound_events_str[sound_event],ASM_sound_state_str[sound_state]);
+ debug_msg(">>>> Event(%s), State(%s)", ASM_sound_events_str[sound_event],ASM_sound_state_str[sound_state]);
+
+ debug_fleave();
+
+ return true;
+}
+
+EXPORT_API
+bool ASM_set_sound_state (const int asm_handle, ASM_sound_events_t sound_event, ASM_sound_states_t sound_state, ASM_resource_t mm_resource, int *error_code)
+{
+ return ASM_set_sound_state_ex (asm_handle, sound_event, sound_state, mm_resource, error_code, NULL);
+}
+
+EXPORT_API
+bool ASM_set_subsession (const int asm_handle, int subsession, int *error_code, int (*func)(void*,void*))
+{
+ int handle = 0;
+ int asm_index = 0;
+ int ret = 0;
+ unsigned int rcv_sound_status_value;
+
+ debug_fenter();
+
+ if (error_code == NULL) {
+ debug_error("error_code is null");
+ return false;
+ }
+
+ if (asm_handle < 0 || asm_handle >= ASM_SERVER_HANDLE_MAX) {
+ *error_code = ERR_ASM_POLICY_INVALID_HANDLE;
+ debug_error("Invalid handle(%d)", asm_handle);
+ return false;
+ }
+
+ handle = asm_handle;
+
+ asm_index = __ASM_find_index(handle);
+ if (asm_index == -1) {
+ debug_error("Can not find index of %d", handle);
+ return false;
+ }
+
+ if (!__asm_construct_snd_msg(ASM_sound_handle[asm_index].asm_tid, ASM_sound_handle[asm_index].handle, subsession, ASM_REQUEST_SET_SUBSESSION, 0, 0, error_code)) {
+ debug_error("failed to __asm_construct_snd_msg(), error(%d)", *error_code);
+ return false;
+ }
+
+
+ if (func) {
+ func (&asm_snd_msg, &asm_rcv_msg);
+ } else {
+ NO_EINTR(ret = msgsnd(asm_snd_msgid, (void *)&asm_snd_msg, sizeof(asm_snd_msg.data), 0));
+ if (ret == -1) {
+ *error_code = ERR_ASM_MSG_QUEUE_SND_ERROR;
+ debug_error("failed to msgsnd(%d,%s)", errno, strerror(errno));
+ return false;
+ }
+
+ NO_EINTR(ret = msgrcv(asm_rcv_msgid, (void *)&asm_rcv_msg, sizeof(asm_rcv_msg.data), ASM_sound_handle[handle].asm_tid, 0));
+ if (ret == -1) {
+ *error_code = ERR_ASM_MSG_QUEUE_RCV_ERROR;
+ debug_error("failed to msgrcv(%d,%s)", errno, strerror(errno));
+ return false;
+ }
+ }
+
+ /* TODO: Should check msg returned.....*/
+#if 0
+ {
+ debug_msg( " <<<<<<<<<<<<<<<< [BEFORE] Callback : Main Context >>>>>>>>>>>>>>>>>>>> \n");
+ /********************************************************************************************************/
+ switch (asm_rcv_msg.data.result_sound_command) {
+ case ASM_COMMAND_PAUSE:
+ case ASM_COMMAND_STOP:
+ case ASM_COMMAND_PLAY:
+ case ASM_COMMAND_NONE:
+ case ASM_COMMAND_RESUME:
+ default:
+ break;
+ }
+ /********************************************************************************************************/
+ debug_msg(" <<<<<<<<<<<<<<<< [AFTER] Callback : Main Context >>>>>>>>>>>>>>>>>>>> \n");
+
+ }
+#endif
+
+ debug_fleave();
+
+ return true;
+}
+
+EXPORT_API
+bool ASM_get_subsession (const int asm_handle, int *subsession_value, int *error_code, int (*func)(void*,void*))
+{
+ int handle = 0;
+ int asm_index = 0;
+ int ret = 0;
+ unsigned int rcv_sound_status_value;
+
+ debug_fenter();
+
+ if (error_code == NULL) {
+ debug_error("error_code is null");
+ return false;
+ }
+
+ /* TODO : Error Handling */
+#if 0
+ if (sound_event < 0 || sound_event > ASM_PRIORITY_MATRIX_MIN) {
+ debug_error("invalid sound event(%d)",sound_event);
+ *error_code = ERR_ASM_EVENT_IS_INVALID;
+ return false;
+ }
+#endif
+
+ if (asm_handle < 0 || asm_handle >= ASM_SERVER_HANDLE_MAX) {
+ *error_code = ERR_ASM_POLICY_INVALID_HANDLE;
+ debug_error("Invalid handle %d \n", asm_handle);
+ return false;
+ }
+
+ handle = asm_handle;
+
+ asm_index = __ASM_find_index(handle);
+ if (asm_index == -1) {
+ debug_error("Can not find index of %d", handle);
+ return false;
+ }
+
+ if (!__asm_construct_snd_msg(ASM_sound_handle[asm_index].asm_tid, ASM_sound_handle[asm_index].handle, 0, ASM_REQUEST_GET_SUBSESSION, 0, 0, error_code)) {
+ debug_error("failed to __asm_construct_snd_msg(), error(%d)", *error_code);
+ return false;
+ }
+
+
+ if (func) {
+ func (&asm_snd_msg, &asm_rcv_msg);
+ } else {
+ NO_EINTR(ret = msgsnd(asm_snd_msgid, (void *)&asm_snd_msg, sizeof(asm_snd_msg.data), 0));
+ if (ret == -1) {
+ *error_code = ERR_ASM_MSG_QUEUE_SND_ERROR;
+ debug_error("failed to msgsnd(%d,%s)", errno, strerror(errno));
+ return false;
+ }
+
+ NO_EINTR(ret = msgrcv(asm_rcv_msgid, (void *)&asm_rcv_msg, sizeof(asm_rcv_msg.data), ASM_sound_handle[handle].asm_tid, 0));
+ if (ret == -1) {
+ *error_code = ERR_ASM_MSG_QUEUE_RCV_ERROR;
+ debug_error("failed to msgrcv(%d,%s)", errno, strerror(errno));
+ return false;
+ }
+ }
+
+ *subsession_value = asm_rcv_msg.data.result_sound_command;
+
+ debug_msg(">>>> ASM_get_subsession with subsession value [%d]\n", *subsession_value);
+ debug_fleave();
return true;
}
@@ -1048,15 +1328,15 @@ void ASM_dump_sound_state()
int ret = 0;
if (!__ASM_init_msg(&error) ) {
- asm_error("[Error = %d] >>>> %s =>__asm_init \n", error, __func__);
+ debug_error("failed to __ASM_init_msg(), error(%d)", error);
}
- if (!__asm_construct_snd_msg(getpid(), 0, 0, ASM_REQUEST_DUMP, ASM_STATE_NONE, ASM_RESOURCE_NONE, NULL)) {
- asm_error_r("[Error] >>>> %s : Send msg construct failed.\n", __func__);
+ if (!__asm_construct_snd_msg(getpid(), 0, 0, ASM_REQUEST_DUMP, ASM_STATE_NONE, ASM_RESOURCE_NONE, &error)) {
+ debug_error("failed to __asm_construct_snd_msg(), error(%d)", error);
return;
}
NO_EINTR(ret = msgsnd(asm_snd_msgid, (void *)&asm_snd_msg, sizeof(asm_snd_msg.data), 0));
if (ret == -1) {
- asm_error_r("[Error] >>>> ASM_dump_sound_state : Msgsnd failed (%d,%s) \n", errno, strerror(errno));
+ debug_error("failed to msgsnd(%d,%s)", errno, strerror(errno));
return;
}
}
@@ -1082,32 +1362,36 @@ void __ASM_unregister_sound(int index)
int ret = 0;
unsigned int sound_status_value;
- asm_info(" <<<< __ASM_unregister_sound : Event(%s), Index(%d) \n", ASM_sound_events_str[ASM_sound_handle[index].sound_event], index);
+ debug_fenter();
+
+ debug_msg(" <<<< Event(%s), Index(%d)", ASM_sound_events_str[ASM_sound_handle[index].sound_event], index);
+
if (!__ASM_get_sound_state(&sound_status_value, &error_code)) {
- asm_error("[Error = %d] >>>> ASM_unregister_sound => __ASM_get_sound_state \n", error_code);
+ debug_error("failed to __ASM_get_sound_state()", error_code);
}
if (!__ASM_set_sound_state(ASM_sound_handle[index].sound_event, ASM_STATE_NONE, &error_code)) {
- asm_error("[Error = %d] >>>> __ASM_unregister_sound => __ASM_set_sound_state(NONE) \n", error_code);
+ debug_error("failed to __ASM_set_sound_state(NONE)", error_code);
}
if (!__asm_construct_snd_msg(ASM_sound_handle[index].asm_tid, ASM_sound_handle[index].handle, ASM_sound_handle[index].sound_event, ASM_REQUEST_UNREGISTER, ASM_STATE_NONE, ASM_RESOURCE_NONE, &error_code)) {
- asm_error(" >>>> Send msg construct failed.\n");
+ debug_error("failed to __asm_construct_snd_msg(), error(%d)", error_code);
}
NO_EINTR(ret = msgsnd(asm_snd_msgid, (void *)&asm_snd_msg, sizeof(asm_snd_msg.data), 0));
if (ret == -1) {
- asm_error_r("[Error] >>>> __ASM_unregister_sound : Msgsnd failed (%d,%s) \n", errno, strerror(errno));
+ debug_error("failed to msgsnd(%d,%s)", errno, strerror(errno));
}
__ASM_destroy_callback(index);
- asm_info(" >>>> __ASM_unregister_sound : Event(%s) \n", ASM_sound_events_str[ASM_sound_handle[index].sound_event]);
+ debug_msg(" >>>> Event(%s)", ASM_sound_events_str[ASM_sound_handle[index].sound_event]);
ASM_sound_handle[index].asm_fd = 0;
ASM_sound_handle[index].asm_tid = 0;
ASM_sound_handle[index].sound_event = ASM_EVENT_NONE;
- ASM_sound_handle[index].is_used = FALSE;
+ ASM_sound_handle[index].is_used = false;
+ debug_fleave();
}
@@ -1118,7 +1402,7 @@ void __ASM_signal_handler(int signo)
int run_emergency_exit = 0;
for (asm_index=0 ;asm_index < ASM_HANDLE_MAX; asm_index++) {
- if (ASM_sound_handle[asm_index].is_used == TRUE) {
+ if (ASM_sound_handle[asm_index].is_used == true) {
exit_pid = ASM_sound_handle[asm_index].asm_tid;
if (exit_pid == asmgettid()) {
run_emergency_exit = 1;
@@ -1139,13 +1423,13 @@ void __ASM_signal_handler(int signo)
sigprocmask(SIG_BLOCK, &all_mask, &old_mask);
if (msgsnd(asm_snd_msgid, (void *)&asm_snd_msg, sizeof(asm_snd_msg.data), 0) < 0) {
- asm_info("[signal handler][msgsnd failed]tid=%ld, reqid=%d, handle=0x%x, state=0x%x event=%d size=%d\n",asm_snd_msg.instance_id,
+ debug_error("msgsnd() failed, tid=%ld, reqid=%d, handle=0x%x, state=0x%x event=%d size=%d",asm_snd_msg.instance_id,
asm_snd_msg.data.request_id, asm_snd_msg.data.handle, asm_snd_msg.data.sound_state, asm_snd_msg.data.sound_event, sizeof(asm_snd_msg.data) );
int tmpid = msgget((key_t)2014, 0666);
if (msgsnd(tmpid, (void *)&asm_snd_msg, sizeof(asm_snd_msg.data), 0) > 0) {
- asm_info("[signal handler]msgsnd succeed\n");
+ debug_msg("msgsnd() succeed");
} else {
- asm_critical("[signal handler]msgsnd retry also failed.\n");
+ debug_error("msgsnd() retry also failed");
}
}
@@ -1190,9 +1474,10 @@ void __attribute__((constructor)) __ASM_init_module(void)
struct sigaction ASM_action;
ASM_action.sa_handler = __ASM_signal_handler;
ASM_action.sa_flags = SA_NOCLDSTOP;
- sigemptyset(&ASM_action.sa_mask);
- asm_info(" __ASM_init_module : start \n");
+ debug_fenter();
+
+ sigemptyset(&ASM_action.sa_mask);
sigaction(SIGINT, &ASM_action, &ASM_int_old_action);
sigaction(SIGABRT, &ASM_action, &ASM_abrt_old_action);
@@ -1200,21 +1485,24 @@ void __attribute__((constructor)) __ASM_init_module(void)
sigaction(SIGTERM, &ASM_action, &ASM_term_old_action);
sigaction(SIGSYS, &ASM_action, &ASM_sys_old_action);
sigaction(SIGXCPU, &ASM_action, &ASM_xcpu_old_action);
+
+ debug_fleave();
#endif
}
void __attribute__((destructor)) __ASM_fini_module(void)
{
+ debug_fenter();
+
#if defined(CONFIG_ENABLE_SIGNAL_HANDLER)
- asm_info(" __ASM_fini_module : start \n");
int exit_pid = 0;
int asm_index = 0;
int run_emergency_exit = 0;
for (asm_index = 0; asm_index < ASM_HANDLE_MAX; asm_index++) {
- if (ASM_sound_handle[asm_index].is_used == TRUE) {
+ if (ASM_sound_handle[asm_index].is_used == true) {
exit_pid = ASM_sound_handle[asm_index].asm_tid;
if (exit_pid == asmgettid()) {
run_emergency_exit = 1;
@@ -1231,13 +1519,13 @@ void __attribute__((destructor)) __ASM_fini_module(void)
asm_snd_msg.data.sound_state = 0;
if (msgsnd(asm_snd_msgid, (void *)&asm_snd_msg, sizeof(asm_snd_msg.data), 0) < 0 ) {
- asm_info( "[signal handler][msgsnd failed]tid=%ld, reqid=%d, handle=0x%x, state=0x%x event=%d size=%d\n",asm_snd_msg.instance_id,
+ debug_msg( "msgsnd() failed, tid=%ld, reqid=%d, handle=0x%x, state=0x%x event=%d size=%d",asm_snd_msg.instance_id,
asm_snd_msg.data.request_id, asm_snd_msg.data.handle, asm_snd_msg.data.sound_state, asm_snd_msg.data.sound_event, sizeof(asm_snd_msg.data) );
int tmpid = msgget((key_t)2014, 0666);
if (msgsnd(tmpid, (void *)&asm_snd_msg, sizeof(asm_snd_msg.data), 0) > 0) {
- asm_info("[signal handler]msgsnd succeed\n");
+ debug_msg("msgsnd() succeed");
} else {
- asm_critical("[signal handler]msgsnd retry also failed.\n");
+ debug_error("msgsnd() retry also failed");
}
}
}
@@ -1248,5 +1536,7 @@ void __attribute__((destructor)) __ASM_fini_module(void)
sigaction(SIGTERM, &ASM_term_old_action, NULL);
sigaction(SIGSYS, &ASM_sys_old_action, NULL);
sigaction(SIGXCPU, &ASM_xcpu_old_action, NULL);
+
+ debug_fleave();
}
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 0000000..df09a2e
--- /dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,17 @@
+bin_PROGRAMS = asm_testsuite
+
+asm_testsuite_SOURCES = asm_testsuite.c
+
+asm_testsuite_CFLAGS = -I$(srcdir)/../include \
+ $(AUDIOSESSIONMGR_CFLAGS) \
+ $(DLOG_CFLAGS) \
+ $(VCONF_CFLAGS)
+
+asm_testsuite_DEPENDENCIES = $(srcdir)/../.libs/libaudio-session-mgr.la
+
+asm_testsuite_LDADD = $(AUDIOSESSIONMGR_LIBS) \
+ $(srcdir)/../.libs/libaudio-session-mgr.la \
+ $(DLOG_LIBS) \
+ $(VCONF_LIBS)
+
+
diff --git a/test/asm_testsuite.c b/test/asm_testsuite.c
new file mode 100644
index 0000000..238a2b0
--- /dev/null
+++ b/test/asm_testsuite.c
@@ -0,0 +1,296 @@
+#include <stdio.h>
+#include <glib.h>
+#include <stdlib.h>
+
+#include <audio-session-manager.h>
+
+
+GMainLoop *g_loop;
+GThreadPool* g_pool;
+gint asm_handle = -1;
+gint event_type = ASM_EVENT_NONE;
+gint asm_state = ASM_STATE_NONE;
+ASM_resource_t g_resource = ASM_RESOURCE_NONE;
+gboolean thread_run;
+
+ASM_cb_result_t
+asm_callback (int handle, ASM_event_sources_t event_src, ASM_sound_commands_t command, unsigned int sound_status, void* cb_data)
+{
+ g_print ("\n[%s][%d] handle = %d, event src = %d, command = %d, sound_state = %d\n\n", __func__, __LINE__, handle ,event_src, command, sound_status);
+ return ASM_CB_RES_IGNORE;
+}
+
+void print_menu_main(void)
+{
+ printf("========ASM Testsuite======\n");
+ printf(" r. Register ASM\n");
+ printf(" s. Set state\n");
+ printf(" u. Unregister ASM\n");
+ printf(" q. Quit\n");
+ printf("============================\n");
+ printf(">> ");
+}
+
+void menu_unregister(void)
+{
+ gint errorcode = 0;
+ if(asm_handle == -1) {
+ g_print("Register sound first..\n\n");
+ return;
+ }
+ if( !ASM_unregister_sound(asm_handle, event_type, &errorcode) ) {
+ g_print("Unregister sound failed 0x%X\n\n", errorcode);
+ } else {
+ g_print("Unregister success..\n\n");
+ asm_handle = -1;
+ }
+}
+
+void menu_register(void)
+{
+ char key = 0;
+ int input = 0;
+ gint errorcode = 0;
+ gint pid = -1;
+ g_resource = ASM_RESOURCE_NONE;
+
+ while(1) {
+ printf("==========select ASM event=============\n");
+ printf(" 0. ASM_EVENT_SHARE_MMPLAYER \n");
+ printf(" 1. ASM_EVENT_SHARE_MMCAMCORDER\n");
+ printf(" 2. ASM_EVENT_SHARE_MMSOUND\n");
+ printf(" 3. ASM_EVENT_SHARE_OPENAL\n");
+ printf(" 4. ASM_EVENT_SHARE_AVSYSTEM\n");
+ printf(" 5. ASM_EVENT_SHARE_FMRADIO\n");
+ printf(" 6. ASM_EVENT_EXCLUSIVE_MMPLAYER\n");
+ printf(" 7. ASM_EVENT_EXCLUSIVE_MMCAMCORDER\n");
+ printf(" 8. ASM_EVENT_EXCLUSIVE_MMSOUND\n");
+ printf(" 9. ASM_EVENT_EXCLUSIVE_OPENAL\n");
+ printf(" a. ASM_EVENT_EXCLUSIVE_AVSYSTEM\n");
+ printf(" b. ASM_EVENT_EXCLUSIVE_FMRADIO\n");
+ printf(" c. ASM_EVENT_NOTIFY\n");
+ printf(" d. ASM_EVENT_CALL\n");
+ printf(" e. ASM_EVENT_EARJACK_UNPLUG\n");
+ printf(" f. ASM_EVENT_ALARM\n");
+ printf(" g. ASM_EVENT_VIDEOCALL\n");
+ printf(" h. ASM_EVENT_MONITOR\n");
+ printf(" i. ASM_EVENT_RICHCALL\n");
+ printf(" j. ASM_EVENT_EMERGENCY\n");
+ printf(" k. ASM_EVENT_EXCLUSIVE_RESOURCE\n");
+ printf(" q. Back to main menu\n");
+ printf("=======================================\n");
+ printf(">> ");
+
+
+ while( (input = getchar())!= '\n' && input != EOF) {
+ key = (char)input;
+ }
+ switch (key) {
+ case '0':
+ event_type = ASM_EVENT_SHARE_MMPLAYER;
+ break;
+ case '1':
+ event_type = ASM_EVENT_SHARE_MMCAMCORDER;
+ g_resource = ASM_RESOURCE_CAMERA;
+ break;
+ case '2':
+ event_type = ASM_EVENT_SHARE_MMSOUND;
+ break;
+ case '3':
+ event_type = ASM_EVENT_SHARE_OPENAL;
+ break;
+ case '4':
+ event_type = ASM_EVENT_SHARE_AVSYSTEM;
+ break;
+ case '5':
+ event_type = ASM_EVENT_SHARE_FMRADIO;
+ break;
+ case '6':
+ event_type = ASM_EVENT_EXCLUSIVE_MMPLAYER;
+ break;
+ case '7':
+ event_type = ASM_EVENT_EXCLUSIVE_MMCAMCORDER;
+ g_resource = ASM_RESOURCE_CAMERA;
+ break;
+ case '8':
+ event_type = ASM_EVENT_EXCLUSIVE_MMSOUND;
+ break;
+ case '9':
+ event_type = ASM_EVENT_EXCLUSIVE_OPENAL;
+ break;
+ case 'a':
+ event_type = ASM_EVENT_EXCLUSIVE_AVSYSTEM;
+ break;
+ case 'b':
+ event_type = ASM_EVENT_EXCLUSIVE_FMRADIO;
+ break;
+ case 'c':
+ event_type = ASM_EVENT_NOTIFY;
+ break;
+ case 'd':
+ event_type = ASM_EVENT_CALL;
+ break;
+ case 'e':
+ event_type = ASM_EVENT_EARJACK_UNPLUG;
+ break;
+ case 'f':
+ event_type = ASM_EVENT_ALARM;
+ break;
+ case 'g':
+ event_type = ASM_EVENT_VIDEOCALL;
+ g_resource = ASM_RESOURCE_CAMERA;
+ break;
+ case 'h':
+ event_type = ASM_EVENT_MONITOR;
+ break;
+ case 'i':
+ event_type = ASM_EVENT_RICH_CALL;
+ g_resource = ASM_RESOURCE_CAMERA;
+ break;
+ case 'j':
+ event_type = ASM_EVENT_EMERGENCY;
+ break;
+ case 'k':
+ event_type = ASM_EVENT_EXCLUSIVE_RESOURCE;
+ /* temporarily set it ASM_RESOURCE_CAMERA */
+ g_resource = ASM_RESOURCE_CAMERA;
+ break;
+ case 'q':
+ return;
+ default :
+ g_print("select event again...\n");
+ event_type = -1;
+ break;
+ }
+ if (event_type == -1) {
+ continue;
+ }
+ if( ! ASM_register_sound(pid, &asm_handle, event_type, ASM_STATE_NONE, asm_callback, NULL, g_resource, &errorcode)) {
+ g_print("ASM_register_sound() failed, error = %x\n\n", errorcode);
+ break;
+ } else {
+ g_print("ASM_register_sound() success, ASM handle=%d, ASM_EVENT=%d, ASM_RESOURCE=%d, ASM_STATE_NONE.\n\n", asm_handle, event_type, g_resource);
+ break;
+ }
+ }
+}
+
+void menu_set_state(void)
+{
+ int ret = 0;
+ char key = 0;
+ int input = 0;
+ while(1) {
+ printf("==========ASM state==========\n");
+ printf(" 0. ASM_STATE_IGNORE\n");
+ printf(" 1. ASM_STATE_NONE\n");
+ printf(" 2. ASM_STATE_PLAYING\n");
+ printf(" 3. ASM_STATE_WAITING\n");
+ printf(" 4. ASM_STATE_STOP\n");
+ printf(" 5. ASM_STATE_PAUSE\n");
+ printf(" 6. ASM_STATE_PAUSE_BY_APP\n");
+ printf(" q. Back to main menu\n");
+ printf("=============================\n");
+ printf(">> ");
+ while( (input = getchar())!= '\n' && input != EOF) {
+ key = (char)input;
+ }
+
+ switch (key) {
+ case '0':
+ asm_state = ASM_STATE_IGNORE;
+ break;
+ case '1':
+ asm_state = ASM_STATE_NONE;
+ break;
+ case '2':
+ asm_state = ASM_STATE_PLAYING;
+ break;
+ case '3':
+ asm_state = ASM_STATE_WAITING;
+ break;
+ case '4':
+ asm_state = ASM_STATE_STOP;
+ break;
+ case '5':
+ asm_state = ASM_STATE_PAUSE;
+ break;
+ case '6':
+ asm_state = ASM_STATE_PAUSE_BY_APP;
+ break;
+ case 'q':
+ return;
+ default :
+ g_print("select ASM state again...\n");
+ asm_state = 9;
+ }
+ if (asm_state == 9) {
+ continue;
+ }
+ /* set ASM sound state */
+ if( ! ASM_set_sound_state( asm_handle, event_type, asm_state, g_resource, &ret) ) {
+ g_print("ASM_set_sound_state() failed, Set state to [%d] failed 0x%X\n\n", asm_state, ret);
+ break;
+ } else {
+ g_print("ASM_set_sound_state() success, ASM handle=%d, ASM_EVENT=%d, ASM_RESOURCE=%d, ASM_STATE=%d\n\n", asm_handle, event_type, g_resource, asm_state);
+ break;
+ }
+ }
+}
+
+gpointer keythread(gpointer data)
+{
+ int input = 0;
+ char key = 0;
+
+ while (thread_run) {
+ print_menu_main();
+ while( (input = getchar())!= '\n' && input != EOF) {
+ key = (char)input;
+ }
+
+ switch (key) {
+ case 'r':
+ menu_register();
+ break;
+ case 's':
+ menu_set_state();
+ break;
+ case 'u':
+ menu_unregister();
+ break;
+ case 'q':
+ if(asm_handle != -1) {
+ menu_unregister();
+ }
+ g_main_loop_quit(g_loop);
+ break;
+ default :
+ g_print("wrong input, select again...\n\n");
+ } /* switch (key) */
+ } /* while () */
+ return NULL;
+}
+
+int main ()
+{
+ g_thread_init (NULL);
+ thread_run = TRUE;
+
+ g_loop = g_main_loop_new (NULL, 0);
+ GThread * command_thread = g_thread_create (keythread, NULL, FALSE, NULL);
+ if (!command_thread) {
+ g_print ("key thread creation failure\n");
+ return 0;
+ }
+
+ g_main_loop_run (g_loop);
+ g_print ("loop finished !!\n");
+ thread_run = FALSE;
+ if (command_thread) {
+ g_thread_join (command_thread);
+ command_thread = NULL;
+ }
+
+ return 0;
+}