From: Sangchul Lee Date: Wed, 14 Jan 2015 05:17:34 +0000 (+0900) Subject: Change APIs based on Tizen 2.3 X-Git-Tag: submit/tizen/20150115.120604^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_3.0.2015.q1_common;p=platform%2Fcore%2Fapi%2Fsound-manager.git Change APIs based on Tizen 2.3 Change-Id: I46e717e95f740ffdbc05d11dcf008a08c8838595 --- diff --git a/AUTHORS b/AUTHORS old mode 100755 new mode 100644 index 5fe5722..b0dbe7a --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,2 @@ -Seungkeun Lee -Kangho Hur -Seungbae Shin +Seungbae Shin +Sangchul Lee diff --git a/CMakeLists.txt b/CMakeLists.txt index 8dea0f7..bc278ab 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,6 @@ SET(Services SET(project_prefix "capi") SET(prefix "/usr") SET(version "0.0.1") -SET(maintainer "Seungkeun Lee , Kangho Hur") SET(description "A Sound Manager library in Tizen Native API") SET(service "media") SET(submodule "sound-manager") @@ -48,7 +47,8 @@ FOREACH(flag ${${fw_name}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror") +#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -DTEMP_COMMENT_UNTIL_MM_SOUND_READY") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") IF("${ARCH}" STREQUAL "arm") @@ -91,7 +91,7 @@ CONFIGURE_FILE( ) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) -#ADD_SUBDIRECTORY(test) +ADD_SUBDIRECTORY(test) IF(UNIX) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bbe9d02 --- /dev/null +++ b/LICENSE @@ -0,0 +1,206 @@ +Copyright (c) 2000 - 2011 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/LICENSE.APLv2 b/LICENSE.APLv2 deleted file mode 100644 index f94008a..0000000 --- a/LICENSE.APLv2 +++ /dev/null @@ -1,206 +0,0 @@ -Copyright (c) 2000 - 2011 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/NOTICE b/NOTICE deleted file mode 100644 index ccdad52..0000000 --- a/NOTICE +++ /dev/null @@ -1,3 +0,0 @@ -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/doc/sound_manager_doc.h b/doc/sound_manager_doc.h new file mode 100644 index 0000000..c614aba --- /dev/null +++ b/doc/sound_manager_doc.h @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + + +#ifndef __TIZEN_MEDIA_SOUND_MANAGER_DOC_H__ +#define __TIZEN_MEDIA_SOUND_MANAGER_DOC_H__ + + +/** + * @file sound_manager_doc.h + * @brief This file contains high level documentation of the Sound Manager API. + */ + +/** + * @ingroup CAPI_MEDIA_FRAMEWORK + * @defgroup CAPI_MEDIA_SOUND_MANAGER_MODULE Sound Manager + * @brief The @ref CAPI_MEDIA_SOUND_MANAGER_MODULE API provides functions to get and set sound parameters like volume and session policy. + * + * @section CAPI_MEDIA_SOUND_MANAGER_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_MEDIA_SOUND_MANAGER_OVERVIEW Overview + * The Sound Manager service allows APIs to manage audio output. + * + * The Sound Manager API allows you to: + * - check/control output volumes + * - handle a volume changed notification + * - determine a sound session policy + * - handle the notification of a sound session interruption + * - query the basic information of connected sound devices + * - handle the notification for connection of a sound device, and for changed information of a sound device + * + * @subsection CAPI_MEDIA_SOUND_MANAGER_LIFE_CYCLE_ASYNCHRONOUS_OPERATIONS Asynchronous operations + * The Sound Manager API allows only asynchronous operations. \n + * Thus the result will be passed to the application via the callback mechanism. + * An appropriate callback can be called in response to changes initiated from outside the application. \n + * Possible callbacks are listed below: + *

+ *

    + *
  • sound_manager_volume_changed_cb() - invoked when volume level is changed.

  • + *
  • sound_session_interrupted_cb() - invoked when the session is interrupted.

  • + *
  • sound_device_connected_cb() - invoked when the connection of a sound device is changed.

  • + *
  • sound_device_information_changed_cb() - invoked when the information of a sound device is changed.

  • + *
+ * + * @subsection CAPI_MEDIA_SOUND_MANAGER_MODULE_LIFE_CYCLE_CALLBACK_OPERATIONS Callback(Event) Operations + * The callback mechanism is used to notify the application about significant sound manager events. + *
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
REGISTER UNREGISTER CALLBACK DESCRIPTION
sound_manager_set_volume_changed_cb() sound_manager_unset_volume_changed_cb() sound_manager_volume_changed_cb() This callback is called when volume value is changed.
sound_manager_set_session_interrupted_cb() sound_manager_unset_session_interrupted_cb() sound_session_interrupted_cb() This callback is called when audio session is interrupted.
sound_manager_set_device_connected_cb() sound_manager_unset_device_connected_cb() sound_device_connected_cb() This callback is called when the connection of a sound device is changed.
sound_manager_set_device_information_changed_cb() sound_manager_unset_device_information_changed_cb() sound_device_information_changed_cb() This callback is called when the information of a sound device is changed.
+ * +*/ + +/** + * @ingroup CAPI_MEDIA_SOUND_MANAGER_MODULE + * @defgroup CAPI_MEDIA_SOUND_MANAGER_VOLUME_MODULE Volume + * @brief The @ref CAPI_MEDIA_SOUND_MANAGER_VOLUME_MODULE API provides functions to check and control volumes. + * @section CAPI_MEDIA_SOUND_MANAGER_VOLUME_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_MEDIA_SOUND_MANAGER_VOLUME_MODULE_OVERVIEW Overview + * The Sound Manager Volume API allows you to: + * - check/control output volumes + * - handle a volume changed notification + * + * The Sound Manager has predefined types of sounds.(system, notification, alarm, ringtone, media, call, voip, voice). + * + * Current volume level of each type can be checked with sound_manager_get_volume(). + * To get the maximum supported volume level of each type, call sound_manager_get_max_volume(). + * The volume level of each type can be adjusted with sound_manager_set_volume(). + * + * The type of currently playing sound may be obtained by calling sound_manager_get_current_sound_type(). + * To set the type of the currently playing sound forcibly, call sound_manager_set_current_sound_type(). + * + * +*/ + +/** + * @ingroup CAPI_MEDIA_SOUND_MANAGER_MODULE + * @defgroup CAPI_MEDIA_SOUND_MANAGER_SESSION_MODULE Session + * @brief The @ref CAPI_MEDIA_SOUND_MANAGER_SESSION_MODULE API provides functions to control a session. + * @section CAPI_MEDIA_SOUND_MANAGER_SESSION_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_MEDIA_SOUND_MANAGER_SESSION_MODULE_OVERVIEW Overview + * The Sound Manager Session API allows you to: + * - determine a sound session policy + * - handle the notification of a sound session interruption + * + * The Sound Manager has predefined sound sessions (media, alarm, notification, emergency, voip) + * + * @section CAPI_MEDIA_SOUND_MANAGER_MODULE_FEATURE Related Features + * APIs for voip sound session are related with the following features:\n + * - http://tizen.org/feature/microphone\n + * - http://tizen.org/feature/sip.voip\n + * + * It is recommended to design feature related codes in your application for reliability.\n + * + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on featuring your application can be found from Feature Element. + * +*/ + +/** + * @ingroup CAPI_MEDIA_SOUND_MANAGER_MODULE + * @defgroup CAPI_MEDIA_SOUND_MANAGER_DEVICE_MODULE Device + * @brief The @ref CAPI_MEDIA_SOUND_MANAGER_DEVICE_MODULE API provides functions to query the information of sound devices. + * @section CAPI_MEDIA_SOUND_MANAGER_DEIVCE_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_MEDIA_SOUND_MANAGER_DEVICE_MODULE_OVERVIEW Overview + * The Sound Manager Device API allows you to: + * - query the basic information of connected sound devices. + * - handle the sound device's connection and information change notification. + * + * The list of currently connected sound device can be obtained by calling sound_manager_get_current_device_list(). + * To get the handle of each sound device, call sound_manager_get_next_device() and sound_manager_get_prev_device(). + * + * Device information, such as "type", "IO direction", "state", "ID", "name", can be obtained by calling corresponding APIs. + * + * +*/ + +#endif /* __TIZEN_MEDIA_SOUND_MANAGER_DOC_H__ */ diff --git a/include/sound_manager.h b/include/sound_manager.h index bd20c50..8b2cd46 100755 --- a/include/sound_manager.h +++ b/include/sound_manager.h @@ -14,12 +14,13 @@ * limitations under the License. */ - - - #ifndef __TIZEN_MEDIA_SOUND_MANAGER_H__ #define __TIZEN_MEDIA_SOUND_MANAGER_H__ +#ifndef DEPRECATED +#define DEPRECATED __attribute__((deprecated)) +#endif + #include #ifdef __cplusplus @@ -27,11 +28,9 @@ extern "C" { #endif -#define SOUND_MANAGER_ERROR_CLASS TIZEN_ERROR_MULTIMEDIA_CLASS | 0x30 - /** * @file sound_manager.h - * @brief This file contains the Sound Manager API + * @brief This file contains the Sound Manager API. */ /** @@ -40,16 +39,42 @@ extern "C" */ /** - * @brief Enumerations of sound type + * @brief Enumeration for sound manager's error codes. + * @since_tizen 2.3 + */ +typedef enum +{ + SOUND_MANAGER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + SOUND_MANAGER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + SOUND_MANAGER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + SOUND_MANAGER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */ + SOUND_MANAGER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + SOUND_MANAGER_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */ + SOUND_MANAGER_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data */ + SOUND_MANAGER_ERROR_INTERNAL = TIZEN_ERROR_SOUND_MANAGER | 01, /**< Internal error inside the sound system */ + SOUND_MANAGER_ERROR_POLICY = TIZEN_ERROR_SOUND_MANAGER | 02, /**< Noncompliance with the sound system policy */ + SOUND_MANAGER_ERROR_NO_PLAYING_SOUND = TIZEN_ERROR_SOUND_MANAGER | 03, /**< No playing sound */ +} sound_manager_error_e; + +/** + * @addtogroup CAPI_MEDIA_SOUND_MANAGER_VOLUME_MODULE + * @{ + */ + +/** + * @brief Enumeration for sound type. + * @since_tizen 2.3 */ typedef enum { SOUND_TYPE_SYSTEM, /**< Sound type for system */ SOUND_TYPE_NOTIFICATION, /**< Sound type for notifications */ SOUND_TYPE_ALARM, /**< Sound type for alarm */ - SOUND_TYPE_RINGTONE, /**< Sound type for ringtones */ + SOUND_TYPE_RINGTONE, /**< @internal Sound type for ringtones */ SOUND_TYPE_MEDIA, /**< Sound type for media */ - SOUND_TYPE_CALL, /**< Sound type for call */ + SOUND_TYPE_CALL, /**< @internal Sound type for call */ + SOUND_TYPE_VOIP, /**< @internal Sound type for voip */ + SOUND_TYPE_VOICE, /**< Sound type for voice */ } sound_type_e; /** @@ -64,36 +89,249 @@ typedef enum VOLUME_KEY_TYPE_RINGTONE, /**< Volume key type for ringtones sound */ VOLUME_KEY_TYPE_MEDIA, /**< Volume key type for media sound */ VOLUME_KEY_TYPE_CALL, /**< Volume key type for call sound */ -} volume_key_type_e; +} volume_key_type_e DEPRECATED; // will be deprecated /** - * @brief error codes for sound manager + * @} */ -typedef enum{ - SOUND_MANAGER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - SOUND_MANAGER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ - SOUND_MANAGER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - SOUND_MANAGER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */ - SOUND_MANAGER_ERROR_NO_PLAYING_SOUND = SOUND_MANAGER_ERROR_CLASS | 01, /**< No playing sound */ -} sound_manager_error_e; /** - * @brief Enumerations of session type + * @addtogroup CAPI_MEDIA_SOUND_MANAGER_SESSION_MODULE + * @{ */ -typedef enum{ - SOUND_SESSION_TYPE_SHARE = 0, /**< Share type : shares it's session with other share type application. */ - SOUND_SESSION_TYPE_EXCLUSIVE, /**< Exclusive type : make previous session stop.*/ - SOUND_SESSION_TYPE_ALARM, /**< Alarm type */ - SOUND_SESSION_TYPE_EMERGENCY, /**< Emergency type */ + +/** + * @brief Enumeration for session type. + * @since_tizen 2.3 + */ +typedef enum +{ + SOUND_SESSION_TYPE_MEDIA = 0, /**< Media type */ + SOUND_SESSION_TYPE_ALARM, /**< Alarm type */ + SOUND_SESSION_TYPE_NOTIFICATION, /**< Notification type */ + SOUND_SESSION_TYPE_EMERGENCY, /**< Emergency type */ + SOUND_SESSION_TYPE_VOIP, /**< VOIP type */ + SOUND_SESSION_TYPE_SHARE = SOUND_SESSION_TYPE_MEDIA, /**< will be deprecated */ + SOUND_SESSION_TYPE_EXCLUSIVE = SOUND_SESSION_TYPE_MEDIA, /**< will be deprecated */ } sound_session_type_e; +/** + * @brief Enumeration for session option for starting. + * @since_tizen 2.3 + */ +typedef enum +{ + SOUND_SESSION_OPTION_MIX_WITH_OTHERS_WHEN_START = 0, /**< This session will be mixed with others when starting (default) */ + SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START, /**< This session will interrupt other sessions when starting */ +} sound_session_option_for_starting_e; + +/** + * @brief Enumeration for session option during play. + * @since_tizen 2.3 + */ +typedef enum +{ + SOUND_SESSION_OPTION_INTERRUPTIBLE_DURING_PLAY = 0, /**< This session will be interrupted by other sessions during play (default) */ + SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY, /**< This session will not be interrupted by other media sessions */ +} sound_session_option_for_during_play_e; + +/** + * @brief Enumeration for session option for resumption. + * @since_tizen 2.3 + */ +typedef enum +{ + SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM = 0, /**< This session will be resumed according to system policy (default) */ + SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED, /**< This session will be resumed according to system policy and when the media session which interrupted this session is paused */ +} sound_session_option_for_resumption_e; + +/** + * @brief Enumeration for voip session mode. + * @since_tizen 2.3 + */ +typedef enum +{ + SOUND_SESSION_VOIP_MODE_RINGTONE = 0, /**< voip mode for ringtone */ + SOUND_SESSION_VOIP_MODE_VOICE_WITH_BUILTIN_RECEIVER, /**< voip mode for during call with built-in receiver */ + SOUND_SESSION_VOIP_MODE_VOICE_WITH_BUILTIN_SPEAKER, /**< voip mode for during call with built-in speaker */ + SOUND_SESSION_VOIP_MODE_VOICE_WITH_AUDIO_JACK, /**< voip mode for during call with audio jack */ + SOUND_SESSION_VOIP_MODE_VOICE_WITH_BLUETOOTH, /**< voip mode for during call with bluetooth */ +} sound_session_voip_mode_e; + +/** + * @brief Enumeration for sound session interrupted type. + * @since_tizen 2.3 + */ +typedef enum +{ + SOUND_SESSION_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed*/ + SOUND_SESSION_INTERRUPTED_BY_MEDIA, /**< Interrupted by media application*/ + SOUND_SESSION_INTERRUPTED_BY_CALL, /**< Interrupted by an incoming call*/ + SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphones*/ + SOUND_SESSION_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by a resource conflict*/ + SOUND_SESSION_INTERRUPTED_BY_ALARM, /**< Interrupted by an alarm*/ + SOUND_SESSION_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by an emergency*/ + SOUND_SESSION_INTERRUPTED_BY_NOTIFICATION, /**< Interrupted by a notification*/ +} sound_session_interrupted_code_e; + +/** + * @brief Called when the playing sound session is interrupted. + * @since_tizen 2.3 + * @param[in] code The interrupted code + * @param[in] user_data The user data passed from the callback registration function + * @pre You should register this callback using sound_manager_set_session_interrupted_cb(). + * @see sound_manager_set_session_interrupted_cb() + * @see sound_manager_unset_session_interrupted_cb() + */ +typedef void(* sound_session_interrupted_cb)(sound_session_interrupted_code_e code, void *user_data); + + + /** * @brief Enumerations of session notification */ typedef enum{ SOUND_SESSION_NOTIFY_STOP = 0, /**< Stop : session of application has interrupted by policy. */ SOUND_SESSION_NOTIFY_RESUME, /**< Resume : session interrupt of application has ended. */ -} sound_session_notify_e; +} sound_session_notify_e DEPRECATED; // will be deprecated + +/** + * @brief Enumerations of sound interrupted type + */ +typedef enum +{ + SOUND_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed*/ + SOUND_INTERRUPTED_BY_MEDIA, /**< Interrupted by non-resumable media application*/ + SOUND_INTERRUPTED_BY_CALL, /**< Interrupted by incoming call*/ + SOUND_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphone*/ + SOUND_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by resource conflict*/ + SOUND_INTERRUPTED_BY_ALARM, /**< Interrupted by alarm*/ + SOUND_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by emergency*/ + SOUND_INTERRUPTED_BY_RESUMABLE_MEDIA, /**< Interrupted by resumable media application*/ +} sound_interrupted_code_e DEPRECATED; // will be deprecated + +/** + * @brief Called when the sound session notification has occured. + * @param[in] notify The sound session notification + * @param[in] user_data The user data passed from the callback registration function + * @pre You should register this callback by sound_manager_set_session_notify_cb() + * @see sound_manager_set_session_notify_cb() + */ +typedef void (*sound_session_notify_cb) (sound_session_notify_e notify, void *user_data) DEPRECATED; // will be deprecated + +/** + * @brief Called when the playing sound was interrupted. + * @param[in] code The interrupted code + * @param[in] user_data The user data passed from the callback registration function + * @pre You should register this callback by sound_manager_set_interrupted_cb() + * @see sound_manager_set_interrupted_cb() + */ +typedef void(* sound_interrupted_cb)(sound_interrupted_code_e code, void *user_data) DEPRECATED; // will be deprecated + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_SOUND_MANAGER_DEVICE_MODULE + * @{ + */ + +/** + * @brief sound device handle + * @since_tizen 2.3 + */ +typedef void* sound_device_h; + +/** + * @brief sound device list handle + * @since_tizen 2.3 + */ +typedef void* sound_device_list_h; + +/** +* @brief Enumeration for sound device type. +* @since_tizen 2.3 +*/ +typedef enum{ + SOUND_DEVICE_BUILTIN_SPEAKER, /**< Built-in speaker */ + SOUND_DEVICE_BUILTIN_RECEIVER, /**< Built-in receiver */ + SOUND_DEVICE_BUILTIN_MIC, /**< Built-in mic */ + SOUND_DEVICE_AUDIO_JACK, /**< Audio jack that can be connected to wired accessory such as headphone, headset, and so on */ + SOUND_DEVICE_BLUETOOTH, /**< Bluetooth */ + SOUND_DEVICE_HDMI, /**< HDMI */ + SOUND_DEVICE_MIRRORING, /**< MIRRORING */ + SOUND_DEVICE_USB_AUDIO, /**< USB Audio */ +} sound_device_type_e; + +/** +* @brief Enumeration for sound device direction. +* @since_tizen 2.3 +*/ +typedef enum { + SOUND_DEVICE_IO_DIRECTION_IN, /**< Input device */ + SOUND_DEVICE_IO_DIRECTION_OUT, /**< Output device */ + SOUND_DEVICE_IO_DIRECTION_BOTH, /**< Input/output device (both directions are available) */ +} sound_device_io_direction_e; + +/** +* @brief Enumeration for sound device state. +* @since_tizen 2.3 +*/ +typedef enum { + SOUND_DEVICE_STATE_DEACTIVATED, /**< Deactivated state */ + SOUND_DEVICE_STATE_ACTIVATED, /**< Activated state */ +} sound_device_state_e; + +/** +* @brief Enumeration for sound device mask. +* @since_tizen 2.3 +*/ +typedef enum { + SOUND_DEVICE_IO_DIRECTION_IN_MASK = 0x0001, /**< Mask for input devices */ + SOUND_DEVICE_IO_DIRECTION_OUT_MASK = 0x0002, /**< Mask for output devices */ + SOUND_DEVICE_IO_DIRECTION_BOTH_MASK = 0x0004, /**< Mask for input/output devices (both directions are available) */ + SOUND_DEVICE_TYPE_INTERNAL_MASK = 0x0010, /**< Mask for built-in devices */ + SOUND_DEVICE_TYPE_EXTERNAL_MASK = 0x0020, /**< Mask for external devices */ + SOUND_DEVICE_STATE_DEACTIVATED_MASK = 0x1000, /**< Mask for deactivated devices */ + SOUND_DEVICE_STATE_ACTIVATED_MASK = 0x2000, /**< Mask for activated devices */ + SOUND_DEVICE_ALL_MASK = 0xFFFF, /**< Mask for all devices */ +} sound_device_mask_e; + +/** +* @brief Enumeration for changed information of sound device. +* @since_tizen 2.3 +*/ +typedef enum { + SOUND_DEVICE_CAHNGED_INFO_STATE, /**< State of the device was changed */ + SOUND_DEVICE_CHANGED_INFO_IO_DIRECTION, /**< IO direction of the device was changed */ +} sound_device_changed_info_e; + +/** + * @brief Called when the state of connection of a sound device was changed. + * @since_tizen 2.3 + * @param[in] sound_device_h The sound_device + * @param[in] is_connected The state of device connection + * @param[in] user_data The user data passed from the callback registration function + * @pre You should register this callback using sound_manager_set_device_connected_cb(). + * @see sound_manager_set_device_connected_cb() + * @see sound_manager_unset_device_connected_cb() + */ +typedef void(* sound_device_connected_cb)(sound_device_h device, bool is_connected, void *user_data); + +/** + * @brief Called when the information of a sound device was changed. + * @since_tizen 2.3 + * @param[in] sound_device_h The sound_device + * @param[in] changed_info The entry of sound device information + * @param[in] user_data The user data passed from the callback registration function + * @pre You should register this callback using sound_manager_set_device_information_changed_cb(). + * @see sound_manager_set_device_information_changed_cb() + * @see sound_manager_unset_device_information_changed_cb() + */ +typedef void(* sound_device_information_changed_cb)(sound_device_h device, sound_device_changed_info_e changed_info, void *user_data); + + /** * @brief Enumerations of audio input device type. @@ -102,7 +340,7 @@ typedef enum{ SOUND_DEVICE_IN_MIC = 0x01, /**< Device builtin mic. */ SOUND_DEVICE_IN_WIRED_ACCESSORY = 0x02, /**< Wired input devices */ SOUND_DEVICE_IN_BT_SCO = 0x04, /**< Bluetooth SCO device */ -} sound_device_in_e; +} sound_device_in_e DEPRECATED;// will be deprecated /** * @brief Enumerations of audio output device type. @@ -117,7 +355,7 @@ typedef enum{ SOUND_DEVICE_OUT_HDMI = 0x040<<8, /**< HDMI device */ SOUND_DEVICE_OUT_WFD = 0x080<<8, /**< WFD device */ SOUND_DEVICE_OUT_USB_AUDIO = 0x100<<8, /**< USB Audio device */ -} sound_device_out_e; +} sound_device_out_e DEPRECATED;// will be deprecated /** * @brief Enumerations of route type. @@ -137,176 +375,342 @@ typedef enum{ SOUND_ROUTE_IN_MIC_OUT_HEADPHONE = SOUND_DEVICE_IN_MIC | SOUND_DEVICE_OUT_WIRED_ACCESSORY,/**< Routing audio input to device builtin mic and routing audio output to headphone */ SOUND_ROUTE_INOUT_HEADSET = SOUND_DEVICE_IN_WIRED_ACCESSORY | SOUND_DEVICE_OUT_WIRED_ACCESSORY, /**< Routing audio input and output to headset*/ SOUND_ROUTE_INOUT_BLUETOOTH = SOUND_DEVICE_IN_BT_SCO |SOUND_DEVICE_OUT_BT_SCO /**< Routing audio input and output to bluetooth SCO */ -} sound_route_e; - -/** - * @brief Enumerations of call session type - */ -typedef enum{ - SOUND_CALL_SESSION_TYPE_CALL = 0, /**< call type */ - SOUND_CALL_SESSION_TYPE_VOIP = 1, /**< voip type */ - SOUND_SESSION_TYPE_CALL = 0, - SOUND_SESSION_TYPE_VOIP = 1, -} sound_call_session_type_e; - -/** - * @brief Enumerations of communication session type - */ -typedef enum{ - SOUND_CALL_SESSION_MODE_VOICE = 0, /**< normal talking mode */ - SOUND_CALL_SESSION_MODE_RINGTONE, /**< ringtone mode */ - SOUND_CALL_SESSION_MODE_MEDIA, /**< notification sound in call*/ -} sound_call_session_mode_e; - -/** - * @brief Enumerations of sound interrupted type - */ -typedef enum -{ - SOUND_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed*/ - SOUND_INTERRUPTED_BY_MEDIA, /**< Interrupted by non-resumable media application*/ - SOUND_INTERRUPTED_BY_CALL, /**< Interrupted by incoming call*/ - SOUND_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphone*/ - SOUND_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by resource conflict*/ - SOUND_INTERRUPTED_BY_ALARM, /**< Interrupted by alarm*/ - SOUND_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by emergency*/ - SOUND_INTERRUPTED_BY_RESUMABLE_MEDIA, /**< Interrupted by resumable media application*/ -} sound_interrupted_code_e; +} sound_route_e DEPRECATED;// will be deprecated /** - * @brief Sound call session handle type. + * @} */ -typedef struct sound_call_session_s *sound_call_session_h; -/** - * @brief Called when the sound session notification has occured. - * @param[in] notify The sound session notification - * @param[in] user_data The user data passed from the callback registration function - * @pre You should register this callback by sound_manager_set_session_notify_cb() - * @see sound_manager_set_session_notify_cb() - */ -typedef void (*sound_session_notify_cb) (sound_session_notify_e notify, void *user_data); /** - * @brief Called when the playing sound was interrupted. - * @param[in] code The interrupted code - * @param[in] user_data The user data passed from the callback registration function - * @pre You should register this callback by sound_manager_set_interrupted_cb() - * @see sound_manager_set_interrupted_cb() + * @addtogroup CAPI_MEDIA_SOUND_MANAGER_VOLUME_MODULE + * @{ */ -typedef void(* sound_interrupted_cb)(sound_interrupted_code_e code, void *user_data); - /** * @brief Called when the system volume has changed. - * @param[in] type The sound type of changed volume + * @since_tizen 2.3 + * @param[in] type The sound type of the changed volume * @param[in] volume The new volume value * @param[in] user_data The user data passed from the callback registration function - * @pre sound_manager_set_volume() will invoke this callback if you register it using sound_manager_set_volume_changed_cb() + * @pre sound_manager_set_volume() will invoke this callback if you register it using sound_manager_set_volume_changed_cb(). * @see sound_manager_set_volume_changed_cb() * @see sound_manager_unset_volume_changed_cb() */ typedef void (*sound_manager_volume_changed_cb)(sound_type_e type, unsigned int volume, void *user_data); /** - * @brief Gets the maximum volume level supported for a particular sound type + * @brief Gets the maximum volume level supported for a particular sound type. + * @since_tizen 2.3 * @param[in] type The sound type * @param[out] max The maximum volume level - * @return 0 on success, otherwise a negative error value. + * @return @c 0 on success, + * otherwise a negative error value * @retval #SOUND_MANAGER_ERROR_NONE Success * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter * @see sound_manager_set_volume() + * @see sound_manager_get_volume() */ int sound_manager_get_max_volume(sound_type_e type, int *max); /** - * @brief Sets the volume level specified for a particular sound type + * @brief Sets the volume level specified for a particular sound type. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/volume.set * @param[in] type The sound type - * @param[out] volume The volume level to be set - * @return 0 on success, otherwise a negative error value. + * @param[in] volume The volume level to be set + * @return @c 0 on success, + * otherwise a negative error value * @retval #SOUND_MANAGER_ERROR_NONE Success * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_PERMISSION_DENIED Permission denied + * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system * @see sound_manager_get_max_volume() * @see sound_manager_get_volume() */ int sound_manager_set_volume(sound_type_e type, int volume); /** - * @brief Gets the volume level specified for a particular sound type + * @brief Gets the volume level specified for a particular sound type. + * @since_tizen 2.3 * @param[in] type The sound type * @param[out] volume The current volume level - * @return 0 on success, otherwise a negative error value. + * @return @c 0 on success, + * otherwise a negative error value * @retval #SOUND_MANAGER_ERROR_NONE Success * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system * @see sound_manager_get_max_volume() * @see sound_manager_set_volume() */ int sound_manager_get_volume(sound_type_e type, int *volume); /** - * @brief Gets the current playing sound type - * @param[out] type The current sound type - * @return 0 on success, otherwise a negative error value. + * @brief Sets the type of the sound being currently played. + * @since_tizen 2.3 + * @param[in] type The sound type to set + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system + * @see sound_manager_get_current_sound_type() + * @see sound_manager_unset_current_sound_type() + */ +int sound_manager_set_current_sound_type(sound_type_e type); + +/** + * @brief Gets the type of the sound being currently played. + * @since_tizen 2.3 + * @param[out] type The current sound type + * @return @c 0 on success, + * otherwise a negative error value * @retval #SOUND_MANAGER_ERROR_NONE Success * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #SOUND_MANAGER_ERROR_NO_PLAYING_SOUND No playing sound - * @see player_set_sound_type() - * @see audio_out_create() - * @see wav_player_start() + * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system + * @see sound_manager_set_current_sound_type() + * @see sound_manager_unset_current_sound_type() */ int sound_manager_get_current_sound_type(sound_type_e *type); +/** + * @brief Unsets the type of the sound being currently played. + * @since_tizen 2.3 + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system + * @see sound_manager_set_current_sound_type() + * @see sound_manager_get_current_sound_type() + */ +int sound_manager_unset_current_sound_type(void); + /** * @brief Registers a callback function to be invoked when the volume level is changed. + * @since_tizen 2.3 * @param[in] callback Callback function to indicate change in volume * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. + * @return @c 0 on success, + * otherwise a negative error value * @retval #SOUND_MANAGER_ERROR_NONE Success * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @post sound_manager_volume_changed_cb() will be invoked + * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system + * @post sound_manager_volume_changed_cb() will be invoked. * @see sound_manager_unset_volume_changed_cb() * @see sound_manager_volume_changed_cb() */ int sound_manager_set_volume_changed_cb(sound_manager_volume_changed_cb callback, void *user_data); /** - * @brief Unregisters the volume change callback + * @brief Unregisters the volume change callback. + * @since_tizen 2.3 + * @return 0 on success, otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system * @see sound_manager_set_volume_changed_cb() */ -void sound_manager_unset_volume_changed_cb(void); +int sound_manager_unset_volume_changed_cb(void); + + + /** - * @brief Gets the A2DP activation information. - * @remarks If @a connected is @c true, @a bt_name must be released with free() by you. If @a connected is @c false, @a bt_name is set to NULL. - * @param[out] connected The Bluetooth A2DP connection status (@c true = connected, @c false = disconnected) - * @param[out] bt_name The Bluetooth A2DP connected device name + * @brief Sets the volume key type + * @param[in] type The volume key type to set * @return 0 on success, otherwise a negative error value. * @retval #SOUND_MANAGER_ERROR_NONE Success * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation */ -int sound_manager_get_a2dp_status(bool *connected, char **bt_name); +int sound_manager_set_volume_key_type(volume_key_type_e type) DEPRECATED;// will be deprecated +/** + * @} + */ /** - * @brief Sets the application's sound session type + * @addtogroup CAPI_MEDIA_SOUND_MANAGER_SESSION_MODULE + * @{ + */ + +/** + * @brief Sets the application's sound session type. + * @since_tizen 2.3 * @param[in] type The session type to set - * @return 0 on success, otherwise a negative error value. + * @return @c 0 on success, + * otherwise a negative error value * @retval #SOUND_MANAGER_ERROR_NONE Success * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported + * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system + * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy + * @see sound_manager_get_session_type() + * @see sound_manager_set_media_session_option() + * @see sound_manager_get_media_session_option() + * @see sound_manager_set_media_session_resumption_option() + * @see sound_manager_get_media_session_resumption_option() + * @see sound_manager_set_voip_session_mode() + * @see sound_manager_get_voip_session_mode() */ int sound_manager_set_session_type(sound_session_type_e type); - /** - * @brief Gets the application's sound session type + * @brief Gets the application's sound session type. + * @since_tizen 2.3 * @param[in] type The session type - * @return 0 on success, otherwise a negative error value. + * @return @c 0 on success, + * otherwise a negative error value * @retval #SOUND_MANAGER_ERROR_NONE Success * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @see sound_manager_set_session_type() + * @see sound_manager_set_media_session_option() + * @see sound_manager_get_media_session_option() + * @see sound_manager_set_media_session_resumption_option() + * @see sound_manager_get_media_session_resumption_option() + * @see sound_manager_set_voip_session_mode() + * @see sound_manager_get_voip_session_mode() */ int sound_manager_get_session_type(sound_session_type_e *type); +/** + * @brief Sets the media sound session option. + * @since_tizen 2.3 + * @param[in] s_option The session option for starting + * @param[in] d_option The session option for during play + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation + * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy + * @pre Call sound_manager_set_session_type(SOUND_SESSION_TYPE_MEDIA) before calling this function. + * @see sound_manager_set_session_type() + * @see sound_manager_get_session_type() + * @see sound_manager_get_media_session_option() + * @see sound_manager_set_media_session_resumption_option() + * @see sound_manager_get_media_session_resumption_option() + */ +int sound_manager_set_media_session_option(sound_session_option_for_starting_e s_option, sound_session_option_for_during_play_e d_option); + +/** + * @brief Gets the media sound session option. + * @since_tizen 2.3 + * @param[out] s_option The session option for starting + * @param[out] d_option The session option for during play + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation + * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy + * @see sound_manager_set_session_type() + * @see sound_manager_get_session_type() + * @see sound_manager_set_media_session_option() + * @see sound_manager_set_media_session_resumption_option() + * @see sound_manager_get_media_session_resumption_option() + */ +int sound_manager_get_media_session_option(sound_session_option_for_starting_e *s_option, sound_session_option_for_during_play_e *d_option); + +/** + * @brief Sets the media sound session resumption option. + * @since_tizen 2.3 + * @param[in] option The session resumption option + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation + * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy + * @pre Call sound_manager_set_session_type(SOUND_SESSION_TYPE_MEDIA) before calling this function. + * @see sound_manager_set_session_type() + * @see sound_manager_get_session_type() + * @see sound_manager_set_media_session_option() + * @see sound_manager_get_media_session_option() + * @see sound_manager_get_media_session_resumption_option() + */ +int sound_manager_set_media_session_resumption_option(sound_session_option_for_resumption_e option); + +/** + * @brief Gets the media sound session resumption option. + * @since_tizen 2.3 + * @param[out] option The session resumption option + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation + * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy + * @see sound_manager_set_session_type() + * @see sound_manager_get_session_type() + * @see sound_manager_set_media_session_option() + * @see sound_manager_get_media_session_option() + * @see sound_manager_set_media_session_resumption_option() + */ +int sound_manager_get_media_session_resumption_option(sound_session_option_for_resumption_e *option); + +/** + * @brief Sets the mode of the voip sound session. + * @since_tizen 2.3 + * @param[in] mode The voip session mode + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported + * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system + * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy + * @pre Call sound_manager_set_session_type(SOUND_SESSION_TYPE_VOIP) before calling this function. + * @see sound_manager_set_session_type() + * @see sound_manager_get_session_type() + * @see sound_manager_get_voip_session_mode() +*/ +int sound_manager_set_voip_session_mode(sound_session_voip_mode_e mode); + +/** + * @brief Gets the mode of the voip sound session. + * @since_tizen 2.3 + * @param[out] mode The voip session mode + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported + * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system + * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy + * @pre Call sound_manager_set_session_type(SOUND_SESSION_TYPE_VOIP) before calling this function. + * @see sound_manager_set_session_type() + * @see sound_manager_get_session_type() + * @see sound_manager_set_voip_session_mode() +*/ +int sound_manager_get_voip_session_mode(sound_session_voip_mode_e *mode); + +/** + * @brief Registers a callback function to be invoked when the sound session being played was interrupted. + * @since_tizen 2.3 + * @param[in] callback The interrupted callback function + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy + * @post sound_session_interrupted_cb() will be invoked. + * @see sound_manager_unset_session_interrupted_cb() + * @see sound_session_interrupted_cb() + */ +int sound_manager_set_session_interrupted_cb(sound_session_interrupted_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function which is called when the sound session being played is interrupted. + * @since_tizen 2.3 + * @return 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system + * @see sound_manager_set_session_interrupted_cb() + */ +int sound_manager_unset_session_interrupted_cb(void); /** * @brief Registers a callback function to be invoked when the sound session notification is occured. @@ -319,13 +723,13 @@ int sound_manager_get_session_type(sound_session_type_e *type); * @see sound_manager_unset_session_notify_cb() * @see sound_session_notify_cb() */ -int sound_manager_set_session_notify_cb(sound_session_notify_cb callback, void *user_data); +int sound_manager_set_session_notify_cb(sound_session_notify_cb callback, void *user_data) DEPRECATED;// will be deprecated /** * @brief Unregisters the callback function which is called when the session notification is occured * @see sound_manager_set_session_notify_cb() */ -void sound_manager_unset_session_notify_cb(void); +void sound_manager_unset_session_notify_cb(void) DEPRECATED;// will be deprecated; /** * @brief Registers a callback function to be invoked when the playing sound was interrupted. @@ -338,24 +742,243 @@ void sound_manager_unset_session_notify_cb(void); * @see sound_manager_unset_interrupted_cb() * @see sound_interrupted_cb() */ -int sound_manager_set_interrupted_cb(sound_interrupted_cb callback, void *user_data); +int sound_manager_set_interrupted_cb(sound_interrupted_cb callback, void *user_data) DEPRECATED;// will be deprecated; /** * @brief Unregisters the callback function which is called when the playing sound was interrupted * @see sound_manager_set_interrupted_cb() */ -void sound_manager_unset_interrupted_cb(void); +void sound_manager_unset_interrupted_cb(void) DEPRECATED;// will be deprecated; +/** + * @} + */ +/** + * @addtogroup CAPI_MEDIA_SOUND_MANAGER_DEVICE_MODULE + * @{ + */ /** - * @brief Sets the volume key type - * @param[in] type The volume key type to set - * @return 0 on success, otherwise a negative error value. + * @brief Gets the list consisting of connected devices. + * @since_tizen 2.3 + * @param[in] device_mask The mask value + * @param[out] device_list The list of connected devices + * + * @remarks @a Use sound_manager_get_next_device() to get the first node of the list. + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_NO_DATA No data + * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system + * @see sound_manager_get_next_device() + * @see sound_manager_get_prev_device() + * @see sound_manager_get_device_type() + * @see sound_manager_get_device_io_direction() + * @see sound_manager_get_device_id() + * @see sound_manager_get_device_name() + * @see sound_manager_get_device_state() + */ +int sound_manager_get_current_device_list(sound_device_mask_e device_mask, sound_device_list_h *device_list); + +/** + * @brief Gets the next item of the device list. + * @since_tizen 2.3 + * @param[in] device_list The list of connected devices + * @param[out] device The device item + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_NO_DATA No data + * @see sound_manager_get_current_device_list() + * @see sound_manager_get_prev_device() + * @see sound_manager_get_device_type() + * @see sound_manager_get_device_io_direction() + * @see sound_manager_get_device_id() + * @see sound_manager_get_device_name() + * @see sound_manager_get_device_state() + */ +int sound_manager_get_next_device (sound_device_list_h device_list, sound_device_h *device); + +/** + * @brief Gets the previous item of the device list. + * @since_tizen 2.3 + * @param[in] device_list The list of connected devices + * @param[out] device The device item + * @return @c 0 on success, + * otherwise a negative error value * @retval #SOUND_MANAGER_ERROR_NONE Success * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_NO_DATA No data + * @see sound_manager_get_current_device_list() + * @see sound_manager_get_next_device() + * @see sound_manager_get_device_type() + * @see sound_manager_get_device_io_direction() + * @see sound_manager_get_device_id() + * @see sound_manager_get_device_name() + * @see sound_manager_get_device_state() */ -int sound_manager_set_volume_key_type(volume_key_type_e type); +int sound_manager_get_prev_device (sound_device_list_h device_list, sound_device_h *device); + +/** + * @brief Gets the type of the device. + * @since_tizen 2.3 + * @param[in] device The device item + * @param[out] type The type of the device + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @see sound_manager_get_current_device_list() + * @see sound_manager_get_next_device() + * @see sound_manager_get_prev_device() + * @see sound_manager_get_device_io_direction() + * @see sound_manager_get_device_id() + * @see sound_manager_get_device_name() + * @see sound_manager_get_device_state() + */ +int sound_manager_get_device_type (sound_device_h device, sound_device_type_e *type); + +/** + * @brief Gets the io direction of the device. + * @since_tizen 2.3 + * @param[in] device The device item + * @param[out] io_direction The io direction of the device + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @see sound_manager_get_current_device_list() + * @see sound_manager_get_next_device() + * @see sound_manager_get_prev_device() + * @see sound_manager_get_device_type() + * @see sound_manager_get_device_id() + * @see sound_manager_get_device_name() + * @see sound_manager_get_device_state() + */ +int sound_manager_get_device_io_direction (sound_device_h device, sound_device_io_direction_e *io_direction); + +/** + * @brief Gets the id of the device. + * @since_tizen 2.3 + * @param[in] device The device item + * @param[out] id The id of the device + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @see sound_manager_get_current_device_list() + * @see sound_manager_get_next_device() + * @see sound_manager_get_prev_device() + * @see sound_manager_get_device_type() + * @see sound_manager_get_device_io_direction() + * @see sound_manager_get_device_name() + * @see sound_manager_get_device_state() + */ +int sound_manager_get_device_id (sound_device_h device, int *id); + +/** + * @brief Gets the name of the device. + * @since_tizen 2.3 + * @param[in] device The device item + * @param[out] name The name of the device + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system + * @see sound_manager_get_current_device_list() + * @see sound_manager_get_next_device() + * @see sound_manager_get_prev_device() + * @see sound_manager_get_device_type() + * @see sound_manager_get_device_io_direction() + * @see sound_manager_get_device_id() + * @see sound_manager_get_device_state() + */ +int sound_manager_get_device_name (sound_device_h device, char **name); + +/** + * @brief Gets the state of the device. + * @since_tizen 2.3 + * @param[in] device The device item + * @param[out] state The state of the device + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @see sound_manager_get_current_device_list() + * @see sound_manager_get_next_device() + * @see sound_manager_get_prev_device() + * @see sound_manager_get_device_type() + * @see sound_manager_get_device_io_direction() + * @see sound_manager_get_device_id() + * @see sound_manager_get_device_name() + */ +int sound_manager_get_device_state (sound_device_h device, sound_device_state_e *state); + +/** + * @brief Registers a callback function to be invoked when the state of connection of a sound device was changed. + * @since_tizen 2.3 + * @param[in] device_mask The mask value + * @param[in] callback The interrupted callback function + * @param[in] user_data The user data to be passed to the callback function + * + * @remarks @a The initial state of sound devices connected is deactivated. + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system + * @post sound_device_connected_cb() will be invoked. + * @see sound_manager_unset_device_connected_cb() + * @see sound_device_connected_cb() + */ +int sound_manager_set_device_connected_cb (sound_device_mask_e device_mask, sound_device_connected_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function which is called when the state of connection of a sound device was changed. + * @since_tizen 2.3 + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system + * @see sound_manager_set_device_connected_cb() + */ +int sound_manager_unset_device_connected_cb (void); + +/** + * @brief Registers a callback function to be invoked when the information of a sound device was changed. + * @since_tizen 2.3 + * @param[in] device_mask The mask value + * @param[in] callback The interrupted callback function + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system + * @post sound_device_information_changed_cb() will be invoked. + * @see sound_manager_unset_device_information_changed_cb() + * @see sound_device_information_changed_cb() + */ +int sound_manager_set_device_information_changed_cb (sound_device_mask_e device_mask, sound_device_information_changed_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function which is called when the information of a sound device was changed. + * @since_tizen 2.3 + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system + * @see sound_manager_set_device_information_changed_cb() + */ +int sound_manager_unset_device_information_changed_cb (void); + + /** * @brief Gets called iteratively to notify you of available route. @@ -365,7 +988,7 @@ int sound_manager_set_volume_key_type(volume_key_type_e type); * @pre sound_manager_foreach_available_route() will invoke this callback. * @see sound_manager_foreach_available_route() */ -typedef bool(* sound_available_route_cb)(sound_route_e route, void *user_data); +typedef bool(* sound_available_route_cb)(sound_route_e route, void *user_data) DEPRECATED;// will be deprecated /** * @brief Called when the available audio route is changed. @@ -375,7 +998,7 @@ typedef bool(* sound_available_route_cb)(sound_route_e route, void *user_data); * @pre sound_manager_foreach_available_route() will invoke this callback. * @see sound_manager_foreach_available_route() */ -typedef void(* sound_available_route_changed_cb)(sound_route_e route, bool available, void *user_data); +typedef void(* sound_available_route_changed_cb)(sound_route_e route, bool available, void *user_data) DEPRECATED;// will be deprecated /** * @brief Called when the audio route is changed. @@ -384,7 +1007,7 @@ typedef void(* sound_available_route_changed_cb)(sound_route_e route, bool avail * @pre You should register this callback by sound_manager_set_active_device_changed_cb() * @see sound_manager_set_active_device_changed_cb() */ -typedef void(* sound_active_device_changed_cb)(sound_device_in_e in, sound_device_out_e out, void *user_data); +typedef void(* sound_active_device_changed_cb)(sound_device_in_e in, sound_device_out_e out, void *user_data) DEPRECATED;// will be deprecated /** * @brief Retrieves all available audio routes by invoking a specific callback for each valid route. @@ -396,7 +1019,7 @@ typedef void(* sound_active_device_changed_cb)(sound_device_in_e in, sound_devic * @post sound_available_route_cb() will be invoked * @see sound_available_route_cb() */ -int sound_manager_foreach_available_route (sound_available_route_cb callback, void *user_data); +int sound_manager_foreach_available_route (sound_available_route_cb callback, void *user_data) DEPRECATED;// will be deprecated /** * @brief Changes the audio routes. @@ -406,7 +1029,7 @@ int sound_manager_foreach_available_route (sound_available_route_cb callback, vo * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter * @see sound_manager_get_active_device() */ -int sound_manager_set_active_route (sound_route_e route); +int sound_manager_set_active_route (sound_route_e route) DEPRECATED;// will be deprecated /** * @brief Changes the audio route. @@ -417,7 +1040,7 @@ int sound_manager_set_active_route (sound_route_e route); * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter * @see sound_manager_set_active_route() */ -int sound_manager_get_active_device (sound_device_in_e *in, sound_device_out_e *out); +int sound_manager_get_active_device (sound_device_in_e *in, sound_device_out_e *out) DEPRECATED;// will be deprecated /** * @brief Check if given audio route is available or not. @@ -426,7 +1049,7 @@ int sound_manager_get_active_device (sound_device_in_e *in, sound_device_out_e * * @return @c true if the specified route is supported, \n else @c false * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter */ -bool sound_manager_is_route_available (sound_route_e route); +bool sound_manager_is_route_available (sound_route_e route) DEPRECATED;// will be deprecated /** * @brief Registers a callback function to be invoked when the available status is changed. @@ -439,13 +1062,13 @@ bool sound_manager_is_route_available (sound_route_e route); * @see sound_manager_unset_available_route_changed_cb() * @see sound_available_route_changed_cb() */ -int sound_manager_set_available_route_changed_cb (sound_available_route_changed_cb callback, void *user_data); +int sound_manager_set_available_route_changed_cb (sound_available_route_changed_cb callback, void *user_data) DEPRECATED;// will be deprecated /** * @brief Unregisters the callback function. * @see sound_manager_set_available_route_changed_cb() */ -void sound_manager_unset_available_route_changed_cb (void); +void sound_manager_unset_available_route_changed_cb (void) DEPRECATED;// will be deprecated /** * @brief Registers a callback function to be invoked when the audio device is changed. @@ -464,53 +1087,24 @@ int sound_manager_set_active_device_changed_cb (sound_active_device_changed_cb c * @brief Unregisters the callback function which is called when the route notification is occured. * @see sound_manager_set_active_device_changed_cb() */ -void sound_manager_unset_active_device_changed_cb (void); +void sound_manager_unset_active_device_changed_cb (void) DEPRECATED;// will be deprecated -/** - * @brief Creates a call session handle. - * @remarks @a session must be released sound_manager_call_session_destroy() by you. - * @param[out] session A new handle to call session - * @retval #SOUND_MANAGER_ERROR_NONE Successful - * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #SOUND_MANAGER_OUT_OF_MEMORY Out of memory - * @see sound_manager_call_session_destroy() - */ -int sound_manager_call_session_create(sound_call_session_type_e type, sound_call_session_h *session); /** - * @brief Sets the call session mode. - * - * @param[in] session The handle to call session - * @param[in] mode The call session mode - * @return 0 on success, otherwise a negative error value. - * @retval #SOUND_MANAGER_ERROR_NONE Successful - * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @see sound_manager_call_session_get_mode() - */ -int sound_manager_call_session_set_mode(sound_call_session_h session, sound_call_session_mode_e mode); - -/** - * @brief Gets the call session mode. - * - * @param[in] session The handle to call session - * @param[out] mode The call session mode + * @brief Gets the A2DP activation information. + * @remarks If @a connected is @c true, @a bt_name must be released with free() by you. If @a connected is @c false, @a bt_name is set to NULL. + * @param[out] connected The Bluetooth A2DP connection status (@c true = connected, @c false = disconnected) + * @param[out] bt_name The Bluetooth A2DP connected device name * @return 0 on success, otherwise a negative error value. - * @retval #SOUND_MANAGER_ERROR_NONE Successful + * @retval #SOUND_MANAGER_ERROR_NONE Success * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @see sound_manager_call_session_set_mode() + * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation */ -int sound_manager_call_session_get_mode(sound_call_session_h session, sound_call_session_mode_e *mode); +int sound_manager_get_a2dp_status(bool *connected, char **bt_name) DEPRECATED;// will be deprecated /** - * @brief Destroys the call session handle. - * - * @param[in] session The handle to call session to be destroyed - * @return 0 on success, otherwise a negative error value. - * @retval #SOUND_MANAGER_ERROR_NONE Successful - * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @see sound_manager_call_session_create() + * @} */ -int sound_manager_call_session_destroy(sound_call_session_h session); /** * @} diff --git a/include/sound_manager_internal.h b/include/sound_manager_internal.h new file mode 100644 index 0000000..c79a1cf --- /dev/null +++ b/include/sound_manager_internal.h @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +#ifndef __TIZEN_MEDIA_SOUND_MANAGER_INTERNAL_H__ +#define __TIZEN_MEDIA_SOUND_MANAGER_INTERNAL_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define SOUND_TYPE_NUM SOUND_TYPE_VOICE + 1 + +/** + * @file sound_manager_internal.h + * @brief This file contains the Sound Manager API (internal header) + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_MEDIA_SOUND_MANAGER_INTERNAL_H__ */ diff --git a/include/sound_manager_private.h b/include/sound_manager_private.h new file mode 100644 index 0000000..f3a493b --- /dev/null +++ b/include/sound_manager_private.h @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +#ifndef __TIZEN_MEDIA_SOUND_MANAGER_PRIVATE_H__ +#define __TIZEN_MEDIA_SOUND_MANAGER_PRIVATE_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sound_manager_internal.h" + +#define SOUND_SESSION_TYPE_DEFAULT SOUND_SESSION_TYPE_MEDIA + +typedef struct { + int is_registered; + void *user_data; + sound_session_interrupted_cb user_cb; +}_session_interrupt_info_s; + +typedef struct { + void *user_data; + sound_manager_volume_changed_cb user_cb; +}_volume_changed_info_s; + +typedef struct { + void *user_data; + sound_device_connected_cb user_cb; +}_device_connected_info_s; + +typedef struct { + void *user_data; + sound_device_information_changed_cb user_cb; +}_device_changed_info_s; + +int __convert_sound_manager_error_code(const char *func, int code); + +void __session_interrupt_cb(session_msg_t msg, session_event_t event, void *user_data); + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_MEDIA_SOUND_MANAGER_PRIVATE_H__ */ diff --git a/packaging/capi-media-sound-manager.spec b/packaging/capi-media-sound-manager.spec index 8d8530b..e73d230 100755 --- a/packaging/capi-media-sound-manager.spec +++ b/packaging/capi-media-sound-manager.spec @@ -1,6 +1,6 @@ Name: capi-media-sound-manager Summary: Sound Manager library -Version: 0.1.1 +Version: 0.2.27 Release: 0 Group: Multimedia/API License: Apache-2.0 @@ -11,6 +11,11 @@ BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(mm-sound) BuildRequires: pkgconfig(mm-session) BuildRequires: pkgconfig(capi-base-common) +BuildRequires: pkgconfig(vconf) +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig +Requires(post): libprivilege-control + %description A Sound Manager library in Tizen C API @@ -34,19 +39,29 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %__make %{?jobs:-j%jobs} %install +rm -rf %{buildroot} +mkdir -p %{buildroot}/usr/share/license +mkdir -p %{buildroot}/opt/usr/devel +cp LICENSE %{buildroot}/usr/share/license/%{name} +cp test/sound_manager_test %{buildroot}/opt/usr/devel + %make_install -%post -p /sbin/ldconfig +%post +/sbin/ldconfig +/usr/bin/api_feature_loader --verbose --dir=/usr/share/privilege-control %postun -p /sbin/ldconfig %files %manifest %{name}.manifest -%license LICENSE.APLv2 %{_libdir}/libcapi-media-sound-manager.so.* +%{_datadir}/license/%{name} +/opt/usr/devel/* %files devel %manifest %{name}.manifest %{_includedir}/media/sound_manager.h +%{_includedir}/media/sound_manager_internal.h %{_libdir}/pkgconfig/*.pc %{_libdir}/libcapi-media-sound-manager.so diff --git a/src/sound_manager.c b/src/sound_manager.c index f76e828..4f28ca8 100755 --- a/src/sound_manager.c +++ b/src/sound_manager.c @@ -15,154 +15,32 @@ */ -#define LOG_TAG "TIZEN_N_SOUND_MANGER" +#define LOG_TAG "TIZEN_N_SOUND_MANAGER" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define MAX_VOLUME_TYPE 5 +#include typedef struct { void *user_data; sound_manager_volume_changed_cb user_cb; }_changed_volume_info_s; -typedef struct { - int is_registered; - void *user_data; - sound_session_notify_cb user_cb; - void *interrupted_user_data; - sound_interrupted_cb interrupted_cb; -}_session_notify_info_s; - -typedef struct { - void *user_data; - sound_available_route_changed_cb user_cb; -}_changed_available_route_info_s; +_session_interrupt_info_s g_session_interrupt_cb_table = {0, NULL, NULL}; +_volume_changed_info_s g_volume_changed_cb_table = {NULL, NULL}; +_device_connected_info_s g_device_connected_cb_table = {NULL, NULL}; +_device_changed_info_s g_device_info_changed_cb_table = {NULL, NULL}; -typedef struct { - void *user_data; - sound_active_device_changed_cb user_cb; -}_changed_active_device_info_s; - -static _changed_volume_info_s g_volume_changed_cb_table; -static _session_notify_info_s g_session_notify_cb_table = {0, NULL, NULL, NULL, NULL}; -static sound_session_type_e g_cached_session = -1; - -#define SOUND_SESSION_TYPE_DEFAULT SOUND_SESSION_TYPE_SHARE - -static void __volume_changed_cb(void *user_data) -{ - int ret = SOUND_MANAGER_ERROR_NONE; - sound_type_e type = (sound_type_e)user_data; - - int new_volume; - ret = sound_manager_get_volume(type, &new_volume); - if (ret == SOUND_MANAGER_ERROR_NONE) { - if(g_volume_changed_cb_table.user_cb) - (g_volume_changed_cb_table.user_cb)(type, new_volume, g_volume_changed_cb_table.user_data); - } else { - LOGE("sound_manager_get_volume() error code(0x%08x)", ret); - } -} - -static void __session_notify_cb(session_msg_t msg, session_event_t event, void *user_data){ - if(g_session_notify_cb_table.user_cb){ - g_session_notify_cb_table.user_cb(msg, g_session_notify_cb_table.user_data); - } - if( g_session_notify_cb_table.interrupted_cb ){ - sound_interrupted_code_e e = SOUND_INTERRUPTED_COMPLETED; - if( msg == MM_SESSION_MSG_RESUME ) - e = SOUND_INTERRUPTED_COMPLETED; - else{ - switch(event){ - case MM_SESSION_EVENT_MEDIA : - e = SOUND_INTERRUPTED_BY_MEDIA; - break; - case MM_SESSION_EVENT_RESUMABLE_MEDIA : - e = SOUND_INTERRUPTED_BY_RESUMABLE_MEDIA; - break; - case MM_SESSION_EVENT_CALL : - e = SOUND_INTERRUPTED_BY_CALL; - break; - case MM_SESSION_EVENT_ALARM : - e = SOUND_INTERRUPTED_BY_ALARM; - break; - case MM_SESSION_EVENT_EARJACK_UNPLUG: - e = SOUND_INTERRUPTED_BY_EARJACK_UNPLUG; - break; - case MM_SESSION_EVENT_RESOURCE_CONFLICT: - e = SOUND_INTERRUPTED_BY_RESOURCE_CONFLICT; - break; - case MM_SESSION_EVENT_EMERGENCY: - e = SOUND_INTERRUPTED_BY_EMERGENCY; - break; - default : - e = SOUND_INTERRUPTED_BY_MEDIA; - break; - } - } - g_session_notify_cb_table.interrupted_cb(e, g_session_notify_cb_table.interrupted_user_data); - } -} - -static int __convert_sound_manager_error_code(const char *func, int code){ - int ret = SOUND_MANAGER_ERROR_NONE; - char *errorstr = NULL; - - switch(code) - { - case SOUND_MANAGER_ERROR_INVALID_PARAMETER: - ret = SOUND_MANAGER_ERROR_INVALID_PARAMETER; - errorstr = "INVALID_PARAMETER"; - break; - case SOUND_MANAGER_ERROR_INVALID_OPERATION: - ret = SOUND_MANAGER_ERROR_INVALID_OPERATION; - errorstr = "INVALID_OPERATION"; - break; - case MM_ERROR_NONE: - ret = SOUND_MANAGER_ERROR_NONE; - errorstr = "ERROR_NONE"; - break; - case MM_ERROR_INVALID_ARGUMENT: - case MM_ERROR_SOUND_INVALID_POINTER: - ret = SOUND_MANAGER_ERROR_INVALID_PARAMETER; - errorstr = "INVALID_PARAMETER"; - break; - case MM_ERROR_SOUND_INTERNAL: - case MM_ERROR_POLICY_DUPLICATED: - case MM_ERROR_POLICY_BLOCKED: - case MM_ERROR_POLICY_INTERNAL: - ret = SOUND_MANAGER_ERROR_INVALID_OPERATION; - errorstr = "INVALID_OPERATION" ; - break; - case MM_ERROR_SOUND_VOLUME_NO_INSTANCE: - case MM_ERROR_SOUND_VOLUME_CAPTURE_ONLY: - ret = SOUND_MANAGER_ERROR_NO_PLAYING_SOUND; - errorstr = "NO_PLAYING_SOUND" ; - break; - } - LOGE("[%s] %s(0x%08x) : core frameworks error code(0x%08x)",func, errorstr, ret, code); - return ret; -} +sound_session_type_e g_cached_session = -1; +sound_session_voip_mode_e g_cached_voip_mode = -1; int sound_manager_get_max_volume(sound_type_e type, int *max) { int volume; if(max == NULL) - return __convert_sound_manager_error_code(__func__, SOUND_MANAGER_ERROR_INVALID_PARAMETER); + return __convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); - if(type > MAX_VOLUME_TYPE || type < 0) - return __convert_sound_manager_error_code(__func__, SOUND_MANAGER_ERROR_INVALID_PARAMETER); + if(type >= SOUND_TYPE_NUM || type < 0) + return __convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); int ret = mm_sound_volume_get_step(type, &volume); if(ret == 0) @@ -173,12 +51,13 @@ int sound_manager_get_max_volume(sound_type_e type, int *max) int sound_manager_set_volume(sound_type_e type, int volume) { - if(type > MAX_VOLUME_TYPE || type < 0) - return __convert_sound_manager_error_code(__func__, SOUND_MANAGER_ERROR_INVALID_PARAMETER); + if(type >= SOUND_TYPE_NUM || type < 0) + return __convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); if(volume < 0) - return __convert_sound_manager_error_code(__func__, SOUND_MANAGER_ERROR_INVALID_PARAMETER); + return __convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); int ret = mm_sound_volume_set_value(type, volume); + LOGI("returns : type=%d, volume=%d, ret=0x%x", type, volume, ret); return __convert_sound_manager_error_code(__func__, ret); } @@ -186,354 +65,881 @@ int sound_manager_set_volume(sound_type_e type, int volume) int sound_manager_get_volume(sound_type_e type, int *volume) { unsigned int uvolume; - if(type > MAX_VOLUME_TYPE || type < 0) - return __convert_sound_manager_error_code(__func__, SOUND_MANAGER_ERROR_INVALID_PARAMETER); + if(type >= SOUND_TYPE_NUM || type < 0) + return __convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); if(volume == NULL) - return __convert_sound_manager_error_code(__func__, SOUND_MANAGER_ERROR_INVALID_PARAMETER); + return __convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); int ret = mm_sound_volume_get_value(type, &uvolume); if(ret == 0) *volume = uvolume; + LOGI("returns : type=%d, volume=%d, ret=0x%x", type, *volume, ret); + + return __convert_sound_manager_error_code(__func__, ret); +} + +int sound_manager_set_current_sound_type(sound_type_e type) +{ + int ret = MM_ERROR_NONE; + if(type >= SOUND_TYPE_NUM || type < 0) + return __convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); + + ret = mm_sound_volume_primary_type_set(type); + return __convert_sound_manager_error_code(__func__, ret); } int sound_manager_get_current_sound_type(sound_type_e *type) { + int ret = MM_ERROR_NONE; if(type == NULL) - return __convert_sound_manager_error_code(__func__, SOUND_MANAGER_ERROR_INVALID_PARAMETER); - int ret; + return __convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); ret = mm_sound_volume_get_current_playing_type((volume_type_t *)type); + LOGI("returns : type=%d, ret=0x%x", *type, ret); + return __convert_sound_manager_error_code(__func__, ret); } -int sound_manager_set_volume_changed_cb(sound_manager_volume_changed_cb callback, void* user_data) +int sound_manager_unset_current_sound_type(void) { - if(callback == NULL) - return __convert_sound_manager_error_code(__func__, SOUND_MANAGER_ERROR_INVALID_PARAMETER); - long i; - g_volume_changed_cb_table.user_cb = callback; - g_volume_changed_cb_table.user_data = user_data; - for(i = 0 ; i <= MAX_VOLUME_TYPE ; i++) - { - mm_sound_volume_add_callback(i , __volume_changed_cb ,(void*) i); - } - return 0; + int ret = MM_ERROR_NONE; + ret = mm_sound_volume_primary_type_clear(); + + return __convert_sound_manager_error_code(__func__, ret); } -void sound_manager_unset_volume_changed_cb(void) +int sound_manager_set_volume_changed_cb(sound_manager_volume_changed_cb callback, void* user_data) { - int i; - for(i = 0 ; i <= MAX_VOLUME_TYPE ; i++) - { - mm_sound_volume_remove_callback(i); + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + ret = mm_sound_add_volume_changed_callback((mm_sound_volume_changed_cb)callback, user_data); + if (ret == MM_ERROR_NONE) { + g_volume_changed_cb_table.user_cb = (sound_manager_volume_changed_cb)callback; + g_volume_changed_cb_table.user_data = user_data; } - g_volume_changed_cb_table.user_cb = NULL; - g_volume_changed_cb_table.user_data = NULL; + +#endif + return __convert_sound_manager_error_code(__func__, ret); } -int sound_manager_get_a2dp_status(bool *connected , char** bt_name){ - int ret = mm_sound_route_get_a2dp_status(connected , bt_name); +int sound_manager_unset_volume_changed_cb(void) +{ + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + if (g_volume_changed_cb_table.user_cb) { + ret = mm_sound_remove_volume_changed_callback(); + if (ret == MM_ERROR_NONE) { + g_volume_changed_cb_table.user_cb = NULL; + g_volume_changed_cb_table.user_data = NULL; + } + } else { + ret = MM_ERROR_SOUND_INTERNAL; + } +#endif return __convert_sound_manager_error_code(__func__, ret); } -int sound_manager_set_session_type(sound_session_type_e type){ - int ret = 0; - int session = 0; - if(type < 0 || type > SOUND_SESSION_TYPE_EMERGENCY) - return __convert_sound_manager_error_code(__func__, SOUND_MANAGER_ERROR_INVALID_PARAMETER); +int sound_manager_set_session_type(sound_session_type_e type) +{ + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + int cur_session = -1; + int new_session = MM_SESSION_TYPE_MEDIA; + + LOGI(">> enter : type=%d", type); - /* if call session is activated, can't set session */ - ret = mm_session_get_current_type(&session); - if( ret == 0 && session >= MM_SESSION_TYPE_CALL ) { - return __convert_sound_manager_error_code(__func__, SOUND_MANAGER_ERROR_INVALID_OPERATION); + if(type < SOUND_SESSION_TYPE_MEDIA || type > SOUND_SESSION_TYPE_VOIP) + return __convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); + + switch(type) { + case SOUND_SESSION_TYPE_MEDIA: + new_session = MM_SESSION_TYPE_MEDIA; + break; + case SOUND_SESSION_TYPE_ALARM: + new_session = MM_SESSION_TYPE_ALARM; + break; + case SOUND_SESSION_TYPE_NOTIFICATION: + new_session = MM_SESSION_TYPE_NOTIFY; + break; + case SOUND_SESSION_TYPE_EMERGENCY: + new_session = MM_SESSION_TYPE_EMERGENCY; + break; + case SOUND_SESSION_TYPE_VOIP: + new_session = MM_SESSION_TYPE_VOIP; + break; } - if(g_session_notify_cb_table.is_registered){ - ret = mm_session_finish(); - if (ret != MM_ERROR_NONE) { - return __convert_sound_manager_error_code(__func__, ret); + /* valid session check */ + ret = mm_session_get_current_type(&cur_session); + if(ret == 0) { + if (cur_session == MM_SESSION_TYPE_MEDIA_RECORD) { + if (type > SOUND_SESSION_TYPE_MEDIA) { + LOGE("<< leave : Could not set this type(%d) during camera/recorder/audio-io(in)/radio", type); + return __convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL); + } + } + if (cur_session == MM_SESSION_TYPE_CALL || + cur_session == MM_SESSION_TYPE_VIDEOCALL || + cur_session >= MM_SESSION_TYPE_VOICE_RECOGNITION) { + return __convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL); } - g_session_notify_cb_table.is_registered = 0; } - ret = mm_session_init_ex(type , __session_notify_cb, NULL); + if(g_session_interrupt_cb_table.is_registered) { + if (new_session == cur_session || + ((new_session == SOUND_SESSION_TYPE_MEDIA) && (cur_session == MM_SESSION_TYPE_MEDIA_RECORD))) { + LOGI("<< leave : already set type=%d, ret=0x%x", type, ret); + return SOUND_MANAGER_ERROR_NONE; + } else { + ret = mm_session_finish(); + if (ret != MM_ERROR_NONE) { + return __convert_sound_manager_error_code(__func__, ret); + } + g_session_interrupt_cb_table.is_registered = 0; + g_cached_voip_mode = -1; + } + } + ret = mm_session_init_ex(new_session , __session_interrupt_cb, NULL); if(ret == 0){ - g_session_notify_cb_table.is_registered = 1; + g_session_interrupt_cb_table.is_registered = 1; + } + if (new_session == MM_SESSION_TYPE_VOIP) { + /* set default sub-session for voip */ + ret = mm_session_set_subsession (MM_SUBSESSION_TYPE_RINGTONE, MM_SUBSESSION_OPTION_NONE); + if (ret != MM_ERROR_NONE) { + return __convert_sound_manager_error_code(__func__, ret); + } + g_cached_voip_mode = SOUND_SESSION_VOIP_MODE_RINGTONE; } + LOGI("<< leave : type=%d, ret=0x%x", type, ret); + +#endif return __convert_sound_manager_error_code(__func__, ret); } -int sound_manager_get_session_type(sound_session_type_e *type){ +int sound_manager_get_session_type(sound_session_type_e *type) +{ + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + int cur_session; + if( type == NULL ) - return __convert_sound_manager_error_code(__func__, SOUND_MANAGER_ERROR_INVALID_PARAMETER); - int ret = 0; - int session; - ret = mm_session_get_current_type(&session); - if( ret !=0 ) - session = SOUND_SESSION_TYPE_DEFAULT; - if( session > SOUND_SESSION_TYPE_EMERGENCY ){ // call session or voip session + return __convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); + ret = mm_session_get_current_type(&cur_session); + if (ret != 0) + cur_session = SOUND_SESSION_TYPE_DEFAULT; + if ((cur_session > MM_SESSION_TYPE_EMERGENCY) && (cur_session != MM_SESSION_TYPE_VOIP)) { if( g_cached_session != -1 ) - session = g_cached_session; // saved session + cur_session = g_cached_session; else //will be never reach here. just prevent code - session = SOUND_SESSION_TYPE_DEFAULT; + cur_session = SOUND_SESSION_TYPE_DEFAULT; } - *type = session; + switch(cur_session) { + case MM_SESSION_TYPE_MEDIA: + case MM_SESSION_TYPE_MEDIA_RECORD: + *type = SOUND_SESSION_TYPE_MEDIA; + break; + case MM_SESSION_TYPE_ALARM: + *type = SOUND_SESSION_TYPE_ALARM; + break; + case MM_SESSION_TYPE_NOTIFY: + *type = SOUND_SESSION_TYPE_NOTIFICATION; + break; + case MM_SESSION_TYPE_EMERGENCY: + *type = SOUND_SESSION_TYPE_EMERGENCY; + break; + case MM_SESSION_TYPE_VOIP: + *type = SOUND_SESSION_TYPE_VOIP; + break; + default: + *type = cur_session; + break; + } + + LOGI("returns : type=%d, ret=0x%x", *type, ret); + +#endif return 0; } +int sound_manager_set_media_session_option(sound_session_option_for_starting_e s_option, sound_session_option_for_during_play_e d_option) +{ + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + int session = 0; + int session_option = 0; + int updated = 0; + + LOGI(">> enter : option for starting=%d, for during play=%d", s_option, d_option); + + if(s_option < 0 || s_option > SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START) + return __convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); + if(d_option < 0 || d_option > SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY) + return __convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); + + ret = mm_session_get_current_information(&session, &session_option); + if ( ret != 0 || !g_session_interrupt_cb_table.is_registered) { + LOGW("need to set session type first"); + return __convert_sound_manager_error_code(__func__, ret); + } else if ( ret == 0 && session > MM_SESSION_TYPE_MEDIA ) { + if (session == MM_SESSION_TYPE_MEDIA_RECORD) { + if (!g_session_interrupt_cb_table.is_registered) { + LOGE("Already set by camera/recorder/audio-io(in)/radio API, but need to set session to Media first"); + return __convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL); + } + } else { + return __convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL); + } + } -int sound_manager_set_session_notify_cb(sound_session_notify_cb callback , void *user_data){ - int ret =0 ; - if(callback == NULL) - return __convert_sound_manager_error_code(__func__, SOUND_MANAGER_ERROR_INVALID_PARAMETER); + switch (s_option) { + case SOUND_SESSION_OPTION_MIX_WITH_OTHERS_WHEN_START: + if (session_option & MM_SESSION_OPTION_PAUSE_OTHERS) { + ret = mm_session_update_option(MM_SESSION_UPDATE_TYPE_REMOVE, MM_SESSION_OPTION_PAUSE_OTHERS); + if(ret){ + return __convert_sound_manager_error_code(__func__, ret); + } + updated = 1; + } + break; + case SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START: + if (!(session_option & MM_SESSION_OPTION_PAUSE_OTHERS)) { + ret = mm_session_update_option(MM_SESSION_UPDATE_TYPE_ADD, MM_SESSION_OPTION_PAUSE_OTHERS); + if(ret){ + return __convert_sound_manager_error_code(__func__, ret); + } + updated = 1; + } + break; + } + switch (d_option) { + case SOUND_SESSION_OPTION_INTERRUPTIBLE_DURING_PLAY: + if (session_option & MM_SESSION_OPTION_UNINTERRUPTIBLE) { + ret = mm_session_update_option(MM_SESSION_UPDATE_TYPE_REMOVE, MM_SESSION_OPTION_UNINTERRUPTIBLE); + if(ret){ + return __convert_sound_manager_error_code(__func__, ret); + } + updated = 1; + } + break; + case SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY: + if (!(session_option & MM_SESSION_OPTION_UNINTERRUPTIBLE)) { + ret = mm_session_update_option(MM_SESSION_UPDATE_TYPE_ADD, MM_SESSION_OPTION_UNINTERRUPTIBLE); + if(ret){ + return __convert_sound_manager_error_code(__func__, ret); + } + updated = 1; + } + break; + } - if(g_session_notify_cb_table.is_registered ==0){ - ret = mm_session_init_ex(SOUND_SESSION_TYPE_DEFAULT /*default*/ , __session_notify_cb, NULL); - if(ret != 0) - return __convert_sound_manager_error_code(__func__, ret); - g_session_notify_cb_table.is_registered = 1; + if (updated) { + LOGI("<< leave : updated"); + } else { + LOGI("<< leave : already set same option(%x), skip it", session_option); } - g_session_notify_cb_table.user_cb = callback; - g_session_notify_cb_table.user_data = user_data; - return SOUND_MANAGER_ERROR_NONE; +#endif + return __convert_sound_manager_error_code(__func__, ret); } -void sound_manager_unset_session_notify_cb(void){ - g_session_notify_cb_table.user_cb = NULL; - g_session_notify_cb_table.user_data = NULL; -} +int sound_manager_get_media_session_option(sound_session_option_for_starting_e *s_option, sound_session_option_for_during_play_e *d_option) +{ + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + int session = 0; + int session_options = 0; -int sound_manager_set_interrupted_cb(sound_interrupted_cb callback, void *user_data){ - int ret =0 ; - if(callback == NULL) - return __convert_sound_manager_error_code(__func__, SOUND_MANAGER_ERROR_INVALID_PARAMETER); + LOGI(">> enter"); - if(g_session_notify_cb_table.is_registered ==0){ - ret = mm_session_init_ex(SOUND_SESSION_TYPE_DEFAULT /*default*/ , __session_notify_cb, NULL); - if(ret != 0) - return __convert_sound_manager_error_code(__func__, ret); - g_session_notify_cb_table.is_registered = 1; + if( s_option == NULL || d_option == NULL ) + return __convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); + + ret = mm_session_get_current_information(&session, &session_options); + if( ret != 0 ) { + return __convert_sound_manager_error_code(__func__, ret); + } else if (session > SOUND_SESSION_TYPE_MEDIA ) { + if (session == MM_SESSION_TYPE_MEDIA_RECORD) { + if (!g_session_interrupt_cb_table.is_registered) { + LOGE("Already set by camera/recorder/audio-io(in)/radio API, but need to set session to Media first"); + return __convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL); + } + } else { + return __convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL); + } + } + /* get option */ + if (session_options & MM_SESSION_OPTION_PAUSE_OTHERS) { + *s_option = SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START; + } else { + *s_option = SOUND_SESSION_OPTION_MIX_WITH_OTHERS_WHEN_START; + } + if (session_options & MM_SESSION_OPTION_UNINTERRUPTIBLE) { + *d_option = SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY; + } else { + *d_option = SOUND_SESSION_OPTION_INTERRUPTIBLE_DURING_PLAY; } - g_session_notify_cb_table.interrupted_cb= callback; - g_session_notify_cb_table.interrupted_user_data = user_data; + LOGI("<< leave : option for starting=%d, for during play=%d", *s_option, *d_option); + +#endif return SOUND_MANAGER_ERROR_NONE; } -void sound_manager_unset_interrupted_cb(void){ - g_session_notify_cb_table.interrupted_cb= NULL; - g_session_notify_cb_table.interrupted_user_data = NULL; +int sound_manager_set_media_session_resumption_option(sound_session_option_for_resumption_e option) +{ + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + int session = 0; + int session_option = 0; + int updated = 0; + + LOGI(">> enter : option for resumption=%d (0:by system, 1:by system or media paused)", option); + + if(option < SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM || option > SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED) + return __convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); + + ret = mm_session_get_current_information(&session, &session_option); + if ( ret != 0 || !g_session_interrupt_cb_table.is_registered) { + LOGW("need to set session type first"); + return __convert_sound_manager_error_code(__func__, ret); + } else if ( ret == 0 && session > MM_SESSION_TYPE_MEDIA ) { + if (session == MM_SESSION_TYPE_MEDIA_RECORD) { + if (!g_session_interrupt_cb_table.is_registered) { + LOGE("Already set by camera/recorder/audio-io(in)/radio API, but need to set session to Media first"); + return __convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL); + } + } else { + return __convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL); + } + } + + switch (option) { + case SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM: + if (session_option & MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED) { + ret = mm_session_update_option(MM_SESSION_UPDATE_TYPE_REMOVE, MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED); + if(ret){ + return __convert_sound_manager_error_code(__func__, ret); + } + updated = 1; + } + break; + case SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED: + if (!(session_option & MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED)) { + ret = mm_session_update_option(MM_SESSION_UPDATE_TYPE_ADD, MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED); + if(ret){ + return __convert_sound_manager_error_code(__func__, ret); + } + updated = 1; + } + break; + } + + if (updated) { + LOGI("<< leave : updated"); + } else { + LOGI("<< leave : already set same option(%x), skip it", session_option); + } + +#endif + return __convert_sound_manager_error_code(__func__, ret); } +int sound_manager_get_media_session_resumption_option(sound_session_option_for_resumption_e *option) +{ + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + int session = 0; + int session_options = 0; + + LOGI(">> enter"); + + if( option == NULL ) + return __convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); + ret = mm_session_get_current_information(&session, &session_options); + if( ret != 0 ) { + return __convert_sound_manager_error_code(__func__, ret); + } else if (session > SOUND_SESSION_TYPE_MEDIA ) { + if (session == MM_SESSION_TYPE_MEDIA_RECORD) { + if (!g_session_interrupt_cb_table.is_registered) { + LOGE("Already set by camera/recorder/audio-io(in)/radio API, but need to set session to Media first"); + return __convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL); + } + } else { + return __convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL); + } + } + /* get option */ + if (session_options & MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED) { + *option = SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED; + } else { + *option = SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM; + } -int sound_manager_set_volume_key_type(volume_key_type_e type){ - if(type < VOLUME_KEY_TYPE_NONE || type > VOLUME_KEY_TYPE_CALL) - return __convert_sound_manager_error_code(__func__, SOUND_MANAGER_ERROR_INVALID_PARAMETER); - int ret; - if(type == VOLUME_KEY_TYPE_NONE) - ret = mm_sound_volume_primary_type_clear(); - else - ret = mm_sound_volume_primary_type_set(type); + LOGI("<< leave : option for resumption=%d (0:by system, 1:by system or media paused)", *option); + +#endif + return SOUND_MANAGER_ERROR_NONE; +} +int sound_manager_set_voip_session_mode(sound_session_voip_mode_e mode) +{ + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + int session = 0; + int session_options = 0; + + LOGI(">> enter : mode=%d", mode); + + ret = mm_session_get_current_information(&session, &session_options); + if( ret != MM_ERROR_NONE ) { + return __convert_sound_manager_error_code(__func__, ret); + } else if (session != MM_SESSION_TYPE_VOIP ) { + return __convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL); + } + + if(mode < SOUND_SESSION_VOIP_MODE_RINGTONE || mode > SOUND_SESSION_VOIP_MODE_VOICE_WITH_BLUETOOTH) { + ret = MM_ERROR_INVALID_ARGUMENT; + return __convert_sound_manager_error_code(__func__, ret); + } + + if (mode == SOUND_SESSION_VOIP_MODE_RINGTONE) { + /* sub-session */ + if (g_cached_voip_mode != mode) { + ret = mm_session_set_subsession (MM_SUBSESSION_TYPE_RINGTONE, MM_SUBSESSION_OPTION_NONE); + if (ret != MM_ERROR_NONE) { + return __convert_sound_manager_error_code(__func__, ret); + } + } + g_cached_voip_mode = mode; + } else { + mm_sound_route route; + bool need_to_check_device = false; + bool do_subsession = true; + switch (mode) { + case SOUND_SESSION_VOIP_MODE_RINGTONE: + do_subsession = false; + break; + case SOUND_SESSION_VOIP_MODE_VOICE_WITH_BUILTIN_RECEIVER: + route = MM_SOUND_ROUTE_IN_MIC_OUT_RECEIVER; + break; + case SOUND_SESSION_VOIP_MODE_VOICE_WITH_BUILTIN_SPEAKER: + route = MM_SOUND_ROUTE_IN_MIC_OUT_SPEAKER; + break; + case SOUND_SESSION_VOIP_MODE_VOICE_WITH_AUDIO_JACK: + route = MM_SOUND_ROUTE_IN_MIC_OUT_HEADPHONE; + need_to_check_device = true; + break; + case SOUND_SESSION_VOIP_MODE_VOICE_WITH_BLUETOOTH: + route = MM_SOUND_ROUTE_INOUT_BLUETOOTH; + need_to_check_device = true; + break; + } + + if (need_to_check_device) { + int w_ret = MM_ERROR_NONE; + MMSoundDeviceList_t device_list; + MMSoundDevice_t device; + do_subsession = false; + + ret = mm_sound_get_current_device_list(MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG, &device_list); + if (ret != MM_ERROR_NONE) { + return __convert_sound_manager_error_code(__func__, ret); + } else { + while ((w_ret = mm_sound_get_next_device(device_list, &device)) == MM_ERROR_NONE) { + mm_sound_device_type_e type; + ret = mm_sound_get_device_type(device, &type); + if (ret != MM_ERROR_NONE) + return __convert_sound_manager_error_code(__func__, ret); + + switch (mode) { + case SOUND_SESSION_VOIP_MODE_VOICE_WITH_AUDIO_JACK: + if (type == MM_SOUND_DEVICE_TYPE_AUDIOJACK) + do_subsession = true; + break; + case SOUND_SESSION_VOIP_MODE_VOICE_WITH_BLUETOOTH: + if (type == MM_SOUND_DEVICE_TYPE_BLUETOOTH) { + mm_sound_device_io_direction_e io_direction; + ret = mm_sound_get_device_io_direction(device, &io_direction); + if (ret != MM_ERROR_NONE) + return __convert_sound_manager_error_code(__func__, ret); + if (io_direction == MM_SOUND_DEVICE_IO_DIRECTION_BOTH) + do_subsession = true; + } + break; + default: + break; + } + } + } + } + /* sub-session */ + if (do_subsession && (g_cached_voip_mode != mode)) { + ret = mm_session_set_subsession (MM_SUBSESSION_TYPE_VOICE, MM_SUBSESSION_OPTION_NONE); + if (ret != MM_ERROR_NONE) { + return __convert_sound_manager_error_code(__func__, ret); + } + /* route */ + ret = mm_sound_set_active_route(route); + if (ret != MM_ERROR_NONE) { + return __convert_sound_manager_error_code(__func__, ret); + } + g_cached_voip_mode = mode; + } else { + if (!do_subsession) + ret = MM_ERROR_SOUND_INTERNAL; + } + } + + LOGI("<< leave : session=%p, mode=%d, ret=0x%x", session, mode, ret); + +#endif return __convert_sound_manager_error_code(__func__, ret); } -int sound_manager_foreach_available_route (sound_available_route_cb callback, void *user_data) +int sound_manager_get_voip_session_mode(sound_session_voip_mode_e *mode) { - int ret; - ret = mm_sound_foreach_available_route_cb((mm_sound_available_route_cb)callback, user_data); + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + int session = 0; + int session_options = 0; + int subsession = 0; + + if(mode == NULL) { + return __convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); + } + ret = mm_session_get_current_information(&session, &session_options); + if( ret != MM_ERROR_NONE ) { + return __convert_sound_manager_error_code(__func__, ret); + } else if (session != MM_SESSION_TYPE_VOIP ) { + return __convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL); + } + + ret = mm_session_get_subsession ((mm_subsession_t *)&subsession); + if(ret != MM_ERROR_NONE) { + return __convert_sound_manager_error_code(__func__, ret); + } + switch (subsession) { + case MM_SUBSESSION_TYPE_VOICE: + { + int w_ret = MM_ERROR_NONE; + bool need_to_out = false; + MMSoundDeviceList_t device_list; + MMSoundDevice_t device; + ret = mm_sound_get_current_device_list(MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG, &device_list); + if (ret != MM_ERROR_NONE) { + return __convert_sound_manager_error_code(__func__, ret); + } else { + while ((w_ret = mm_sound_get_next_device(device_list, &device)) == MM_ERROR_NONE) { + mm_sound_device_type_e type; + ret = mm_sound_get_device_type(device, &type); + if (ret != MM_ERROR_NONE) + return __convert_sound_manager_error_code(__func__, ret); + switch (type) { + case MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER: + *mode = SOUND_SESSION_VOIP_MODE_VOICE_WITH_BUILTIN_SPEAKER; + need_to_out = true; + break; + case MM_SOUND_DEVICE_TYPE_BUILTIN_RECEIVER: + *mode = SOUND_SESSION_VOIP_MODE_VOICE_WITH_BUILTIN_RECEIVER; + need_to_out = true; + break; + case MM_SOUND_DEVICE_TYPE_AUDIOJACK: + *mode = SOUND_SESSION_VOIP_MODE_VOICE_WITH_AUDIO_JACK; + need_to_out = true; + break; + case MM_SOUND_DEVICE_TYPE_BLUETOOTH: + *mode = SOUND_SESSION_VOIP_MODE_VOICE_WITH_BLUETOOTH; + need_to_out = true; + break; + default: + break; + } + if (need_to_out) + break; + } + } + } + break; + case MM_SUBSESSION_TYPE_RINGTONE: + *mode = SOUND_SESSION_VOIP_MODE_RINGTONE; + break; + default: + break; + } + + LOGI("returns : session=%p, mode=%d, ret=0x%x", session, *mode, ret); + +#endif return __convert_sound_manager_error_code(__func__, ret); } -int sound_manager_set_active_route (sound_route_e route) +int sound_manager_set_session_interrupted_cb(sound_session_interrupted_cb callback, void *user_data) { - int ret; - ret = mm_sound_set_active_route(route); + int ret = MM_ERROR_NONE; + if(callback == NULL) + return __convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); + + if(g_session_interrupt_cb_table.is_registered ==0){ + ret = mm_session_init_ex(SOUND_SESSION_TYPE_DEFAULT /*default*/ , __session_interrupt_cb, NULL); + if(ret != 0) + return __convert_sound_manager_error_code(__func__, ret); + g_session_interrupt_cb_table.is_registered = 1; + } + + g_session_interrupt_cb_table.user_cb = (sound_session_interrupted_cb)callback; + g_session_interrupt_cb_table.user_data = user_data; + return SOUND_MANAGER_ERROR_NONE; +} +int sound_manager_unset_session_interrupted_cb(void) +{ + int ret = MM_ERROR_NONE; + if (g_session_interrupt_cb_table.user_cb) { + g_session_interrupt_cb_table.user_cb = NULL; + g_session_interrupt_cb_table.user_data = NULL; + } else { + ret = MM_ERROR_SOUND_INTERNAL; + } return __convert_sound_manager_error_code(__func__, ret); } -int sound_manager_get_active_device (sound_device_in_e *in, sound_device_out_e *out) +int sound_manager_get_current_device_list(sound_device_mask_e device_mask, sound_device_list_h *device_list) { - int ret; - ret = mm_sound_get_active_device((mm_sound_device_in *)in, (mm_sound_device_out *)out); + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + ret = mm_sound_get_current_device_list((mm_sound_device_flags_e)device_mask, device_list); +#endif return __convert_sound_manager_error_code(__func__, ret); } -bool sound_manager_is_route_available (sound_route_e route) +int sound_manager_get_next_device (sound_device_list_h device_list, sound_device_h *device) { - bool is_available; - mm_sound_is_route_available(route, &is_available); + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + ret = mm_sound_get_next_device(device_list, device); - return is_available; +#endif + return __convert_sound_manager_error_code(__func__, ret); } -int sound_manager_set_available_route_changed_cb (sound_available_route_changed_cb callback, void *user_data) +int sound_manager_get_prev_device (sound_device_list_h device_list, sound_device_h *device) { - int ret; - ret = mm_sound_add_available_route_changed_callback((mm_sound_available_route_changed_cb)callback, user_data); + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + ret = mm_sound_get_prev_device(device_list, device); +#endif return __convert_sound_manager_error_code(__func__, ret); } -void sound_manager_unset_available_route_changed_cb (void) +int sound_manager_get_device_type (sound_device_h device, sound_device_type_e *type) { - mm_sound_remove_available_route_changed_callback(); + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + ret = mm_sound_get_device_type(device, (mm_sound_device_type_e*)type); + +#endif + return __convert_sound_manager_error_code(__func__, ret); } -int sound_manager_set_active_device_changed_cb (sound_active_device_changed_cb callback, void *user_data) +int sound_manager_get_device_io_direction (sound_device_h device, sound_device_io_direction_e *io_direction) { - int ret; - ret = mm_sound_add_active_device_changed_callback((mm_sound_active_device_changed_cb)callback, user_data); + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + ret = mm_sound_get_device_io_direction(device, (mm_sound_device_io_direction_e*)io_direction); +#endif return __convert_sound_manager_error_code(__func__, ret); } -void sound_manager_unset_active_device_changed_cb (void) +int sound_manager_get_device_id (sound_device_h device, int *id) { - mm_sound_remove_active_device_changed_callback(); + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + ret = mm_sound_get_device_id(device, id); + +#endif + return __convert_sound_manager_error_code(__func__, ret); } -struct sound_call_session_s +int sound_manager_get_device_name (sound_device_h device, char **name) { - int previous_session; -}; + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + ret = mm_sound_get_device_name(device, name); -int sound_manager_call_session_create(sound_call_session_type_e type, sound_call_session_h *session) +#endif + return __convert_sound_manager_error_code(__func__, ret); +} + +int sound_manager_get_device_state (sound_device_h device, sound_device_state_e *state) { - int ret = SOUND_MANAGER_ERROR_NONE; - sound_call_session_h handle = NULL; + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + ret = mm_sound_get_device_state(device, (mm_sound_device_state_e*)state); - /* Check input parameters */ - if(type < SOUND_SESSION_TYPE_CALL || type > SOUND_SESSION_TYPE_VOIP || session == NULL) { - ret = SOUND_MANAGER_ERROR_INVALID_PARAMETER; - goto ERROR; - } +#endif + return __convert_sound_manager_error_code(__func__, ret); +} - /* Allocate handle */ - handle = malloc(sizeof(struct sound_call_session_s)); - if(!handle) { - ret = SOUND_MANAGER_ERROR_OUT_OF_MEMORY; - goto ERROR; +int sound_manager_set_device_connected_cb (sound_device_mask_e device_mask, sound_device_connected_cb callback, void *user_data) +{ + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + ret = mm_sound_add_device_connected_callback((mm_sound_device_flags_e)device_mask, (mm_sound_device_connected_cb)callback, user_data); + if (ret == MM_ERROR_NONE) { + g_device_connected_cb_table.user_cb = (sound_device_connected_cb)callback; + g_device_connected_cb_table.user_data = user_data; } - memset(handle, 0, sizeof(struct sound_call_session_s)); - /* Finish previous session if exists */ - if(g_session_notify_cb_table.is_registered){ - sound_manager_get_session_type((sound_session_type_e*)&handle->previous_session); - g_cached_session = handle->previous_session; +#endif + return __convert_sound_manager_error_code(__func__, ret); +} - ret = mm_session_finish(); - if (ret != MM_ERROR_NONE) { - goto ERROR; +int sound_manager_unset_device_connected_cb (void) +{ + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + if (g_device_connected_cb_table.user_cb) { + ret = mm_sound_remove_device_connected_callback(); + if (ret == MM_ERROR_NONE) { + g_device_connected_cb_table.user_cb = NULL; + g_device_connected_cb_table.user_data = NULL; } - g_session_notify_cb_table.is_registered = 0; - - }else{ - g_cached_session = SOUND_SESSION_TYPE_DEFAULT; - handle->previous_session = SOUND_SESSION_TYPE_DEFAULT; + } else { + ret = MM_ERROR_SOUND_INTERNAL; } - /* Initialize session */ - switch(type) { - case SOUND_SESSION_TYPE_CALL: - ret = mm_session_init_ex(MM_SESSION_TYPE_CALL, __session_notify_cb, NULL); - break; - case SOUND_SESSION_TYPE_VOIP: - ret = mm_session_init_ex(MM_SESSION_TYPE_VIDEOCALL,__session_notify_cb, NULL); - break; - } - if(ret != MM_ERROR_NONE) - goto ERROR; +#endif + return __convert_sound_manager_error_code(__func__, ret); +} - g_session_notify_cb_table.is_registered = 1; - *session = handle; +int sound_manager_set_device_information_changed_cb (sound_device_mask_e device_mask, sound_device_information_changed_cb callback, void *user_data) +{ + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + ret = mm_sound_add_device_information_changed_callback((mm_sound_device_flags_e)device_mask, (mm_sound_device_info_changed_cb)callback, user_data); + if (ret == MM_ERROR_NONE) { + g_device_info_changed_cb_table.user_cb = (sound_device_information_changed_cb)callback; + g_device_info_changed_cb_table.user_data = user_data; + } - return SOUND_MANAGER_ERROR_NONE; +#endif + return __convert_sound_manager_error_code(__func__, ret); +} -ERROR: - if(handle) - free(handle); +int sound_manager_unset_device_information_changed_cb (void) +{ + int ret = MM_ERROR_NONE; +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + if (g_device_info_changed_cb_table.user_cb) { + ret = mm_sound_remove_device_information_changed_callback(); + if (ret == MM_ERROR_NONE) { + g_device_info_changed_cb_table.user_cb = NULL; + g_device_info_changed_cb_table.user_data = NULL; + } + } else { + ret = MM_ERROR_SOUND_INTERNAL; + } +#endif return __convert_sound_manager_error_code(__func__, ret); } -int sound_manager_call_session_set_mode(sound_call_session_h session, sound_call_session_mode_e mode) +/* below APIs are already deprecated Tizen 2.3, leave it temporarily */ +int sound_manager_get_a2dp_status(bool *connected , char** bt_name) { - int ret = SOUND_MANAGER_ERROR_NONE; + return SOUND_MANAGER_ERROR_NOT_SUPPORTED; +} - if(mode < SOUND_CALL_SESSION_MODE_VOICE || mode > SOUND_CALL_SESSION_MODE_MEDIA || session == NULL) { - ret = SOUND_MANAGER_ERROR_INVALID_PARAMETER; - goto ERROR; - } +int sound_manager_set_session_notify_cb(sound_session_notify_cb callback , void *user_data) +{ + return SOUND_MANAGER_ERROR_NOT_SUPPORTED; +} - ret = mm_session_set_subsession ((mm_subsession_t)mode); +void sound_manager_unset_session_notify_cb(void) +{ + return; +} - if(ret != MM_ERROR_NONE) - goto ERROR; +int sound_manager_set_interrupted_cb(sound_interrupted_cb callback, void *user_data){ + return SOUND_MANAGER_ERROR_NOT_SUPPORTED; +} - return SOUND_MANAGER_ERROR_NONE; +void sound_manager_unset_interrupted_cb(void){ + return SOUND_MANAGER_ERROR_NOT_SUPPORTED; +} -ERROR: - return __convert_sound_manager_error_code(__func__, ret); +int sound_manager_set_volume_key_type(volume_key_type_e type){ + return SOUND_MANAGER_ERROR_NOT_SUPPORTED; } -int sound_manager_call_session_get_mode(sound_call_session_h session, sound_call_session_mode_e *mode) +int sound_manager_foreach_available_route (sound_available_route_cb callback, void *user_data) { - int ret = SOUND_MANAGER_ERROR_NONE; + return SOUND_MANAGER_ERROR_NOT_SUPPORTED; +} - if(mode == NULL || session == NULL) { - ret = SOUND_MANAGER_ERROR_INVALID_PARAMETER; - goto ERROR; - } +int sound_manager_set_active_route (sound_route_e route) +{ + return SOUND_MANAGER_ERROR_NOT_SUPPORTED; +} - ret = mm_session_get_subsession ((mm_subsession_t *)mode); +int sound_manager_get_active_device (sound_device_in_e *in, sound_device_out_e *out) +{ + return SOUND_MANAGER_ERROR_NOT_SUPPORTED; +} - if(ret != MM_ERROR_NONE) - goto ERROR; +bool sound_manager_is_route_available (sound_route_e route) +{ + return false; +} - return SOUND_MANAGER_ERROR_NONE; +int sound_manager_set_available_route_changed_cb (sound_available_route_changed_cb callback, void *user_data) +{ + return SOUND_MANAGER_ERROR_NOT_SUPPORTED; +} -ERROR: - return __convert_sound_manager_error_code(__func__, ret); +void sound_manager_unset_available_route_changed_cb (void) +{ + return; } -int sound_manager_call_session_destroy(sound_call_session_h session) +int sound_manager_set_active_device_changed_cb (sound_active_device_changed_cb callback, void *user_data) { - int ret = SOUND_MANAGER_ERROR_NONE; + return SOUND_MANAGER_ERROR_NOT_SUPPORTED; +} - if(session == NULL) { - ret = SOUND_MANAGER_ERROR_INVALID_PARAMETER; - goto ERROR; - } +void sound_manager_unset_active_device_changed_cb (void) +{ + return; +} - if(g_session_notify_cb_table.is_registered){ - ret = mm_session_finish(); - if(ret != MM_ERROR_NONE) - goto ERROR; - g_session_notify_cb_table.is_registered = 0; - } +__attribute__ ((destructor)) +void __sound_manager_finalize(void) +{ + int ret = MM_ERROR_NONE; - /* Restore previous session */ - ret = mm_session_init_ex(session->previous_session , __session_notify_cb, NULL); - if(ret == 0){ - g_session_notify_cb_table.is_registered = 1; + if(g_session_interrupt_cb_table.is_registered){ + LOGI(""); + ret = mm_session_finish(); + if (ret != MM_ERROR_NONE) { + LOGE("[%s] failed to mm_session_finish(), ret(0x%x)", __func__, ret); + } + g_session_interrupt_cb_table.is_registered = 0; + LOGI(""); } +} - if(session) - free(session); - - return SOUND_MANAGER_ERROR_NONE; +__attribute__ ((constructor)) +void __sound_manager_initialize(void) +{ -ERROR: - return __convert_sound_manager_error_code(__func__, ret); } - diff --git a/src/sound_manager_private.c b/src/sound_manager_private.c new file mode 100644 index 0000000..fc5f2ce --- /dev/null +++ b/src/sound_manager_private.c @@ -0,0 +1,110 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +#include +#include + +#include +#include + +extern _session_interrupt_info_s g_session_interrupt_cb_table; + +int __convert_sound_manager_error_code(const char *func, int code) { + int ret = SOUND_MANAGER_ERROR_NONE; + char *errorstr = NULL; + + switch(code) + { + case MM_ERROR_FILE_WRITE: + case MM_ERROR_INVALID_HANDLE: + ret = SOUND_MANAGER_ERROR_INVALID_OPERATION; + errorstr = "INVALID_OPERATION"; + break; + case MM_ERROR_NONE: + ret = SOUND_MANAGER_ERROR_NONE; + errorstr = "ERROR_NONE"; + break; + case MM_ERROR_INVALID_ARGUMENT: + case MM_ERROR_SOUND_INVALID_POINTER: + ret = SOUND_MANAGER_ERROR_INVALID_PARAMETER; + errorstr = "INVALID_PARAMETER"; + break; + case MM_ERROR_SOUND_PERMISSION_DENIED: + ret = SOUND_MANAGER_ERROR_PERMISSION_DENIED; + errorstr = "PERMISSION_DENIED"; + break; + case MM_ERROR_SOUND_NO_DATA: + ret = SOUND_MANAGER_ERROR_NO_DATA; + errorstr = "NO_DATA"; + break; + case MM_ERROR_SOUND_INTERNAL: + case MM_ERROR_SOUND_VOLUME_CAPTURE_ONLY: + ret = SOUND_MANAGER_ERROR_INTERNAL; + errorstr = "INTERNAL"; + break; + case MM_ERROR_POLICY_DUPLICATED: + case MM_ERROR_POLICY_INTERNAL: + case MM_ERROR_POLICY_BLOCKED: + ret = SOUND_MANAGER_ERROR_POLICY; + errorstr = "POLICY"; + break; + case MM_ERROR_SOUND_VOLUME_NO_INSTANCE: + ret = SOUND_MANAGER_ERROR_NO_PLAYING_SOUND; + errorstr = "NO_PLAYING_SOUND"; + break; + } + LOGE("[%s] %s(0x%08x) : core frameworks error code(0x%08x)",func, errorstr, ret, code); + return ret; +} + +void __session_interrupt_cb(session_msg_t msg, session_event_t event, void *user_data){ + if( g_session_interrupt_cb_table.user_cb ){ + sound_session_interrupted_code_e e = SOUND_SESSION_INTERRUPTED_COMPLETED; + if( msg == MM_SESSION_MSG_RESUME ) + e = SOUND_SESSION_INTERRUPTED_COMPLETED; + else{ +#ifndef TEMP_COMMENT_UNTIL_MM_SOUND_READY + switch(event){ + case MM_SESSION_EVENT_MEDIA : + e = SOUND_SESSION_INTERRUPTED_BY_MEDIA; + break; + case MM_SESSION_EVENT_CALL : + e = SOUND_SESSION_INTERRUPTED_BY_CALL; + break; + case MM_SESSION_EVENT_ALARM : + e = SOUND_SESSION_INTERRUPTED_BY_ALARM; + break; + case MM_SESSION_EVENT_EARJACK_UNPLUG: + e = SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG; + break; + case MM_SESSION_EVENT_RESOURCE_CONFLICT: + e = SOUND_SESSION_INTERRUPTED_BY_RESOURCE_CONFLICT; + break; + case MM_SESSION_EVENT_EMERGENCY: + e = SOUND_SESSION_INTERRUPTED_BY_EMERGENCY; + break; + case MM_SESSION_EVENT_NOTIFICATION : + e = SOUND_SESSION_INTERRUPTED_BY_NOTIFICATION; + break; + default : + e = SOUND_SESSION_INTERRUPTED_BY_MEDIA; + break; + } +#endif + } + g_session_interrupt_cb_table.user_cb(e, g_session_interrupt_cb_table.user_data); + } +} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c0fae15..eea274d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,7 +1,7 @@ SET(fw_test "${fw_name}-test") INCLUDE(FindPkgConfig) -pkg_check_modules(${fw_test} REQUIRED mm-sound glib-2.0 gthread-2.0 capi-media-player) +pkg_check_modules(${fw_test} REQUIRED mm-sound glib-2.0 gthread-2.0) FOREACH(flag ${${fw_test}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") MESSAGE(${flag}) @@ -9,9 +9,6 @@ ENDFOREACH() SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall") -#ADD_EXECUTABLE("system-sensor" system-sensor.c) -#TARGET_LINK_LIBRARIES("system-sensor" ${fw_name} ${${fw_test}_LDFLAGS}) - aux_source_directory(. sources) FOREACH(src ${sources}) GET_FILENAME_COMPONENT(src_name ${src} NAME_WE) diff --git a/test/multimedia_sound_manager_test.c b/test/multimedia_sound_manager_test.c deleted file mode 100644 index 50ba3b6..0000000 --- a/test/multimedia_sound_manager_test.c +++ /dev/null @@ -1,244 +0,0 @@ -/* -* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -* -* 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. -*/ - - - -#include -#include -#include -#include -#include -#include -#include -#include - -static GMainLoop *g_mainloop = NULL; -static GThread *event_thread; -#define MAX_VOLUME_TYPE 5 - -gpointer GmainThread(gpointer data){ - g_mainloop = g_main_loop_new (NULL, 0); - g_main_loop_run (g_mainloop); - - return NULL; -} - -void _sound_manager_volume_changed_cb(sound_type_e type, unsigned int volume, void* user_data) -{ - printf("changed!! type=%d, volume = %d\n", type, volume); -} - -int set_volume_test() -{ - printf("set volume test\n"); - int i; - sound_manager_set_volume_changed_cb(_sound_manager_volume_changed_cb ,NULL); - for( i = SOUND_TYPE_SYSTEM ; i <=MAX_VOLUME_TYPE; i++){ - int max_value; - int j; - sound_manager_get_max_volume(i, &max_value); - printf(" sound type = %d , max volume = %d\n", i, max_value); - for( j = 0; j <= max_value+1 ; j++){ - int ret; - int getvalue; - ret = sound_manager_set_volume(i, j); - if( j <= max_value && ret == 0 ){ - sound_manager_get_volume(i, &getvalue); - if( j == getvalue ) - printf("PASS\n"); - else - printf("FAIL!set=%d, get=%d\n", j, getvalue); - } else if( j > max_value && ret == 0 ) - printf("FAIL! max_value over!!\n"); - - } - } - //sound_manager_unset_volume_changed_cb(); - printf("end set volume test!!!\n"); - sleep(10); - return 0; -} - -void _sound_manager_route_policy_changed_cb(sound_route_policy_e route , void* user_data) -{ - printf("new route policy %d\n", route); -} - -int set_policy_test() -{ - printf("-----------set policy test--------------\n"); - int ret; - //int i; - //sound_route_policy_e value; - sound_manager_set_route_policy_changed_cb(_sound_manager_route_policy_changed_cb,NULL); - /* - for( i = SOUND_ROUTE_DEFAULT ; i <= SOUND_ROUTE_HANDSET_ONLY ; i++){ - ret = sound_manager_set_route_policy(i); - ret = sound_manager_get_route_policy(&value); - if( i == value ) - printf("PASS\n"); - else - printf("FAIL\n"); - } - */ - ret = sound_manager_set_route_policy(SOUND_ROUTE_DEFAULT); - ret = sound_manager_set_route_policy(SOUND_ROUTE_DEFAULT); - ret = sound_manager_set_route_policy(SOUND_ROUTE_DEFAULT); - ret = sound_manager_set_route_policy(SOUND_ROUTE_DEFAULT); - - - return 0; -} - - -static void mm_volume_changed_cb(void *user_data) -{ - int v = (int)user_data; - unsigned int value = 0; - int ret = mm_sound_volume_get_value(v, &value); - printf("mm_volume_changed_cb type = %d ,volume = %d , ret = %x\n", v, value, ret ); -} - - -int mm_bug_test() -{ - int ret = 0; - mm_sound_volume_add_callback(0 , mm_volume_changed_cb , (void*)0); - mm_sound_volume_add_callback(1 , mm_volume_changed_cb ,(void*) 1); - mm_sound_volume_add_callback(2 , mm_volume_changed_cb , (void*)2); - mm_sound_volume_add_callback(5 , mm_volume_changed_cb , (void*)5); - - int i; - - for( i = 0 ; i < 10 ; i++) - { - ret = mm_sound_volume_set_value(0, i); - printf("type = 0 , volume = %d set , ret = %x\n", i, ret); - ret = mm_sound_volume_set_value(1, i); - printf("type = 1 , volume = %d set , ret = %x\n", i, ret); - ret = mm_sound_volume_set_value(2, i); - printf("type = 2 , volume = %d set , ret = %x\n", i, ret); - ret = mm_sound_volume_set_value(5, i); - printf("type = 5 , volume = %d set , ret = %x\n", i, ret); - sleep(1); - } - - //mm_sound_volume_remove_callback(0); - //mm_sound_volume_remove_callback(1); - //mm_sound_volume_remove_callback(2); - //mm_sound_volume_remove_callback(5); - - - ret = mm_sound_volume_set_value(5, 4); - - mm_sound_route_set_system_policy(SOUND_ROUTE_DEFAULT); - mm_sound_route_set_system_policy(SOUND_ROUTE_DEFAULT); - mm_sound_route_set_system_policy(SOUND_ROUTE_DEFAULT); - return 0; -} - -void mm_test(){ - - char path[255]; - int id; - int i; - getcwd(path, 255); - strcat(path, "/test2.wav"); - for( i =0 ; i < 10 ; i++){ - mm_sound_play_sound(path, SOUND_TYPE_MEDIA, NULL ,NULL, &id); - mm_sound_stop_sound(id); - } -} - -void session_notify_cb(sound_session_notify_e notify, void *user_data) -{ - printf("notify %d\n", notify); - - -} - - -void session_test(){ - printf("session_test\n"); - int ret = 0; - player_h player; - - ret = sound_manager_set_session_type(SOUND_SESSION_TYPE_EXCLUSIVE); - sound_manager_set_session_notify_cb(session_notify_cb,NULL); - - - - ret = player_create(&player); - printf("player_create ret =%x\n", ret); - ret = player_set_uri(player, "title_theme.mp3"); - printf("player_set_uri ret =%x\n", ret); - ret =player_prepare(player); - printf("player_prepare ret =%x\n", ret); - ret = player_start(player); - printf("player_start ret =%x\n", ret); - - while(1){ - player_state_e state; - player_get_state(player, &state); - printf("state %d\n", state); - //if( state == 4) - //player_start(player); - sleep(1); - //wav_player_start("test.wav", SOUND_TYPE_MEDIA,NULL, NULL,NULL); - } - - -} - - -void a2dp_test(){ - bool isconnected; - char * name; - sound_manager_get_a2dp_status(&isconnected, &name); - if( isconnected ){ - printf("name = %s\n", name); - free(name); - }else{ - printf("disconnected\n"); - } - sound_device_e device; - sound_manager_get_current_sound_device(&device); - printf("device =%d\n", device); - -} - -int main() -{ - if( !g_thread_supported() ) - { - g_thread_init(NULL); - } - - GError *gerr = NULL; - event_thread = g_thread_create(GmainThread, NULL, 1, &gerr); - - - - //set_volume_test(); - //set_policy_test(); - //mm_bug_test(); - //wav_play_test(); - //tone_play_test(); - //wav_play_test(); - session_test(); - //a2dp_test(); - return 0; -} diff --git a/test/sound_manager_test.c b/test/sound_manager_test.c new file mode 100644 index 0000000..6d63c97 --- /dev/null +++ b/test/sound_manager_test.c @@ -0,0 +1,997 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +#include +#include +#include + +#include +#include +#include +//#include + +#define MAX_STRING_LEN 2048 + + +enum +{ + CURRENT_STATUS_MAINMENU, + CURRENT_STATUS_GET_MAX_VOLUME, + CURRENT_STATUS_SET_VOLUME, + CURRENT_STATUS_GET_VOLUME, + CURRENT_STATUS_SET_CURRENT_SOUND_TYPE, + CURRENT_STATUS_GET_CURRENT_SOUND_TYPE, + CURRENT_STATUS_UNSET_CURRENT_SOUND_TYPE, + CURRENT_STATUS_SET_VOLUME_CHANGED_CB, + CURRENT_STATUS_UNSET_VOLUME_CHANGED_CB, + CURRENT_STATUS_SET_SESSION_TYPE, + CURRENT_STATUS_GET_SESSION_TYPE, + CURRENT_STATUS_SET_MEDIA_SESSION_OPTION, + CURRENT_STATUS_GET_MEDIA_SESSION_OPTION, + CURRENT_STATUS_SET_MEDIA_SESSION_RESUMPTION_OPTION, + CURRENT_STATUS_GET_MEDIA_SESSION_RESUMPTION_OPTION, + CURRENT_STATUS_SET_VOIP_SESSION_MODE, + CURRENT_STATUS_GET_VOIP_SESSION_MODE, + CURRENT_STATUS_SET_SESSION_INTERRUPTED_CB, + CURRENT_STATUS_UNSET_SESSION_INTERRUPTED_CB, + CURRENT_STATUS_SET_DEVICE_MASK, + CURRENT_STATUS_GET_DEVICE_MASK, + CURRENT_STATUS_GET_DEVICE_LIST, + CURRENT_STATUS_GET_DEVICE_NEXT, + CURRENT_STATUS_GET_DEVICE_PREV, + CURRENT_STATUS_SET_DEVICE_CONNECTED_CB, + CURRENT_STATUS_UNSET_DEVICE_CONNECTED_CB, + CURRENT_STATUS_SET_DEVICE_INFO_CHANGED_CB, + CURRENT_STATUS_UNSET_DEVICE_INFO_CHANGED_CB, +}; + + +static int g_menu_state = CURRENT_STATUS_MAINMENU; + +GMainLoop* g_loop; +sound_device_list_h g_device_list = NULL; +sound_device_mask_e g_device_mask = SOUND_DEVICE_ALL_MASK; + +void quit_program() +{ + g_main_loop_quit(g_loop); +} + +void _interpret_main_menu(char *cmd) +{ + if (strncmp(cmd, "gx", 2) == 0) + { + g_menu_state = CURRENT_STATUS_GET_MAX_VOLUME; + } + else if (strncmp(cmd, "sv", 2) == 0) + { + g_menu_state = CURRENT_STATUS_SET_VOLUME; + } + else if (strncmp(cmd, "gv", 2) == 0) + { + g_menu_state = CURRENT_STATUS_GET_VOLUME; + } + else if (strncmp(cmd, "st", 2) == 0) + { + g_menu_state = CURRENT_STATUS_SET_CURRENT_SOUND_TYPE; + } + else if (strncmp(cmd, "gt", 2) == 0) + { + g_menu_state = CURRENT_STATUS_GET_CURRENT_SOUND_TYPE; + } + else if (strncmp(cmd, "ut", 2) == 0) + { + g_menu_state = CURRENT_STATUS_UNSET_CURRENT_SOUND_TYPE; + } + else if (strncmp(cmd, "vc", 2) == 0) + { + g_menu_state = CURRENT_STATUS_SET_VOLUME_CHANGED_CB; + } + else if (strncmp(cmd, "uv", 2) == 0) + { + g_menu_state = CURRENT_STATUS_UNSET_VOLUME_CHANGED_CB; + } + else if (strncmp(cmd, "ss", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_SET_SESSION_TYPE; + } + else if (strncmp(cmd, "gs", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_GET_SESSION_TYPE; + } + else if (strncmp(cmd, "sm", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_SET_MEDIA_SESSION_OPTION; + } + else if (strncmp(cmd, "gm", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_GET_MEDIA_SESSION_OPTION; + } + else if (strncmp(cmd, "sr", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_SET_MEDIA_SESSION_RESUMPTION_OPTION; + } + else if (strncmp(cmd, "gr", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_GET_MEDIA_SESSION_RESUMPTION_OPTION; + } + else if (strncmp(cmd, "so", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_SET_VOIP_SESSION_MODE; + } + else if (strncmp(cmd, "go", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_GET_VOIP_SESSION_MODE; + } + else if (strncmp(cmd, "sc", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_SET_SESSION_INTERRUPTED_CB; + } + else if (strncmp(cmd, "us", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_UNSET_SESSION_INTERRUPTED_CB; + } + else if (strncmp(cmd, "sk", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_SET_DEVICE_MASK; + } + else if (strncmp(cmd, "gk", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_GET_DEVICE_MASK; + } + else if (strncmp(cmd, "gl", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_GET_DEVICE_LIST; + } + else if (strncmp(cmd, "gn", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_GET_DEVICE_NEXT; + } + else if (strncmp(cmd, "gp", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_GET_DEVICE_PREV; + } + else if (strncmp(cmd, "sd", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_SET_DEVICE_CONNECTED_CB; + } + else if (strncmp(cmd, "ud", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_UNSET_DEVICE_CONNECTED_CB; + } + else if (strncmp(cmd, "si", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_SET_DEVICE_INFO_CHANGED_CB; + } + else if (strncmp(cmd, "ui", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_UNSET_DEVICE_INFO_CHANGED_CB; + } + else if (strncmp(cmd, "q", 1) == 0 ) + { + g_print("closing the test suite\n"); + quit_program(); + } + else + { + g_print("unknown menu \n"); + } + +} + +void display_sub_basic() +{ + g_print("\n"); + g_print("=========================================================================================\n"); + g_print(" Sound Manager Test (press q to quit) \n"); + g_print("-----------------------------------------------------------------------------------------\n"); + g_print(" VOLUME MODULE \n"); + g_print("-----------------------------------------------------------------------------------------\n"); + g_print("gx. Get Max Volume \n"); + g_print("sv. Set Volume \t"); + g_print("gv. Get Volume \n"); + g_print("st. Set Current Sound Type \t"); + g_print("gt. Get Current Sound Type \t"); + g_print("ut. Unset Current Sound Type \n"); + g_print("vc. Set Volume Changed CB \t"); + g_print("uv. Unset Volume Changed CB \n"); + g_print("-----------------------------------------------------------------------------------------\n"); + g_print(" SESSION MODULE \n"); + g_print("-----------------------------------------------------------------------------------------\n"); + g_print("ss. Set Session Type\t\t"); + g_print("gs. Get Session Type\n"); + g_print("sm. Set Media Session Option \t"); + g_print("gm. Get Media Session Option \n"); + g_print("sr. Set Media Session Resumption Option \t"); + g_print("gr. Get Media Session Resumption Option \n"); + g_print("so. Set Voip Session Mode \t"); + g_print("go. Get Voip Session Mode \n"); + g_print("sc. Set Session Interruped CB \t"); + g_print("us. Unset Session Interrupted CB \n"); + g_print("-----------------------------------------------------------------------------------------\n"); + g_print(" DEVICE MODULE \n"); + g_print("-----------------------------------------------------------------------------------------\n"); + g_print("sk. Set Devices Mask(default ALL)\t"); + g_print("gk. Get Devices Mask\n"); + g_print("gl. Get Devices List\n"); + g_print("gn. Get Next Device\t\t"); + g_print("gp. Get Prev Device\n"); + g_print("sd. Set Device Connenected CB\t\t"); + g_print("ud. Unset Device Connenected CB\n"); + g_print("si. Set Device Information Changed CB\t"); + g_print("ui. Unset Device Information Changed CB\n"); + g_print("\n"); + g_print("=========================================================================================\n"); +} + +static void displaymenu() +{ + static int flag = 0; + if (g_menu_state == CURRENT_STATUS_MAINMENU) + { + display_sub_basic(); + flag = 0; + } + else if (g_menu_state == CURRENT_STATUS_GET_MAX_VOLUME) + { + g_print("*** input sound type(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE)\n"); + } + else if (g_menu_state == CURRENT_STATUS_SET_VOLUME) + { + if(flag == 0) + g_print("*** input sound type and desired volume level(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE, (0~max volum).\n"); + flag =1; + } + else if (g_menu_state == CURRENT_STATUS_GET_VOLUME) + { + g_print("*** input sound type(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE)\n"); + } + else if (g_menu_state == CURRENT_STATUS_SET_CURRENT_SOUND_TYPE) + { + g_print("*** input sound type.(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE)\n"); + } + else if (g_menu_state == CURRENT_STATUS_GET_CURRENT_SOUND_TYPE) + { + g_print("*** press enter to get current sound type\n"); + } + else if (g_menu_state == CURRENT_STATUS_UNSET_CURRENT_SOUND_TYPE) + { + g_print("*** press enter to unset current sound type\n"); + } + else if (g_menu_state == CURRENT_STATUS_SET_VOLUME_CHANGED_CB) + { + g_print("*** press enter to set volume changed cb\n"); + } + else if (g_menu_state == CURRENT_STATUS_UNSET_VOLUME_CHANGED_CB) + { + g_print("*** press enter to unset volume changed cb\n"); + } + else if (g_menu_state == CURRENT_STATUS_SET_SESSION_TYPE) + { + g_print("*** input session type(0:MEDIA, 1:ALARM, 2:NOTIFICATION, 3:EMERGENCY, 4:VOIP)\n"); + } + else if (g_menu_state == CURRENT_STATUS_GET_SESSION_TYPE) + { + g_print("*** press enter to get session type\n"); + } + else if (g_menu_state == CURRENT_STATUS_SET_MEDIA_SESSION_OPTION) + { + if(flag == 0) + g_print("*** input starting option, and ongoing(for starting(0:MIX WITH OTHERS, 1:PAUSE OTHERS), for ongoing(0:INTERRUPTABLE, 1:UNINTERRUPABLE)\n"); + flag = 1; + } + else if (g_menu_state == CURRENT_STATUS_GET_MEDIA_SESSION_OPTION) + { + g_print("*** press enter to get media session option\n"); + } + else if (g_menu_state == CURRENT_STATUS_SET_MEDIA_SESSION_RESUMPTION_OPTION) + { + g_print("*** input media session resumption option(0:BY SYSTEM, 1:OR MEDIA PAUSE)\n"); + } + else if (g_menu_state == CURRENT_STATUS_GET_MEDIA_SESSION_RESUMPTION_OPTION) + { + g_print("*** press enter to get media session resumption option\n"); + } + else if (g_menu_state == CURRENT_STATUS_SET_VOIP_SESSION_MODE) + { + g_print("*** input voip session mode (0:RINGTONE, 1:VOICE with RCV, 2:VOICE with SPK, 3:VOICE with AudioJack, 4:VOICE with BT)\n"); + } + else if (g_menu_state == CURRENT_STATUS_GET_VOIP_SESSION_MODE) + { + g_print("*** press enter to get voip session mode\n"); + } + else if (g_menu_state == CURRENT_STATUS_SET_SESSION_INTERRUPTED_CB) + { + g_print("*** press enter to set session interrupted cb\n"); + } + else if (g_menu_state == CURRENT_STATUS_UNSET_SESSION_INTERRUPTED_CB) + { + g_print("*** press enter to unset session interrupted cb\n"); + } + else if (g_menu_state == CURRENT_STATUS_SET_DEVICE_MASK) + { + g_print("*** input device mask (0:ALL, 1:INTERNAL, 2:EXTERNAL, 3:INPUT, 4:OUTPUT, 5:BOTH, 6:ACTIVATED, 7:DEACTIVATED, b:back to the menu\n"); + } + else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_MASK) + { + g_print("*** press enter to get device mask\n"); + } + else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_LIST) + { + g_print("*** press enter to get device list\n"); + } + else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_NEXT) + { + g_print("*** press enter to get next device from the list\n"); + } + else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_PREV) + { + g_print("*** press enter to get previous device from the list\n"); + } + else if (g_menu_state == CURRENT_STATUS_SET_DEVICE_CONNECTED_CB) + { + g_print("*** press enter to set device connected cb\n"); + } + else if (g_menu_state == CURRENT_STATUS_UNSET_DEVICE_CONNECTED_CB) + { + g_print("*** press enter to unset device connected cb\n"); + } + else if (g_menu_state == CURRENT_STATUS_SET_DEVICE_INFO_CHANGED_CB) + { + g_print("*** press enter to set device information changed cb\n"); + } + else if (g_menu_state == CURRENT_STATUS_UNSET_DEVICE_INFO_CHANGED_CB) + { + g_print("*** press enter to unset device information changed cb\n"); + } + else + { + g_print("*** unknown status.\n"); + quit_program(); + } + g_print(" >>> "); +} + +gboolean timeout_menu_display(void* data) +{ + displaymenu(); + return FALSE; +} + +gboolean timeout_quit_program(void* data) +{ + //elm_exit(); + quit_program(); + return FALSE; +} + +int convert_sound_type(sound_type_e *type, char *cmd) +{ + int sound_type_n = atoi(cmd); + if (SOUND_TYPE_SYSTEM > sound_type_n || sound_type_n > SOUND_TYPE_VOICE) + { + g_print("not supported sound type(%d)\n", sound_type_n); + return 0; + } + else + { + switch (sound_type_n) + { + case 0: + *type = SOUND_TYPE_SYSTEM; + break; + case 1: + *type = SOUND_TYPE_NOTIFICATION; + break; + case 2: + *type = SOUND_TYPE_ALARM; + break; + case 3: + *type = SOUND_TYPE_RINGTONE; + break; + case 4: + *type = SOUND_TYPE_MEDIA; + break; + case 5: + *type = SOUND_TYPE_CALL; + break; + case 6: + *type = SOUND_TYPE_VOIP; + break; + case 7: + *type = SOUND_TYPE_VOICE; + break; + default: + break; + } + } + return 1; +} + +int convert_session_type(sound_session_type_e *type, char *cmd) +{ + int session_type_n = atoi(cmd); + if (SOUND_SESSION_TYPE_MEDIA > session_type_n || session_type_n > SOUND_SESSION_TYPE_VOIP) + { + g_print("not supported session type(%d)\n", session_type_n); + return 0; + } + else + { + switch (session_type_n) + { + case 0: + *type = SOUND_SESSION_TYPE_MEDIA; + break; + case 1: + *type = SOUND_SESSION_TYPE_ALARM; + break; + case 2: + *type = SOUND_SESSION_TYPE_NOTIFICATION; + break; + case 3: + *type = SOUND_SESSION_TYPE_EMERGENCY; + break; + case 4: + *type = SOUND_SESSION_TYPE_VOIP; + break; + default: + break; + } + } + return 1; +} + +void _set_volume_changed_cb(sound_type_e type, unsigned int volume, void *user_data) +{ + g_print("***the volume has changed. the volume of this sound type(%d) is : %d \n", type, volume); +} + +void _set_session_interrupted_cb(sound_session_interrupted_code_e code, void *user_data) +{ + g_print("***your session has been interrupted by (%d)\n", code); +} + +void _set_device_connected_cb(sound_device_h device, bool is_connected, void *user_data) +{ + sound_device_type_e type; + sound_device_io_direction_e io_direction; + sound_device_state_e state; + int id; + char *name; + int ret = SOUND_MANAGER_ERROR_NONE; + + g_print("***device connected callback is called, is_connected[%d]\n", is_connected); + + if ((ret = sound_manager_get_device_type (device, &type))) + g_print("failed to get device type, ret[0x%x]\n", ret); + if ((ret = sound_manager_get_device_io_direction (device, &io_direction))) + g_print("failed to get device io direction, ret[0x%x]\n", ret); + if ((ret = sound_manager_get_device_id (device, &id))) + g_print("failed to get device id, ret[0x%x]\n", ret); + if ((ret = sound_manager_get_device_name (device, &name))) + g_print("failed to get device name, ret[0x%x]\n", ret); + if ((ret = sound_manager_get_device_state (device, &state))) + g_print("failed to get device state, ret[0x%x]\n", ret); + if (!ret) + g_print(" -- device type[%d], io_direction[%d], id[%d], name[%s], state[%d]\n", type, io_direction, id, name, state); +} + +void _set_device_info_changed_cb(sound_device_h device, sound_device_changed_info_e changed_info, void *user_data) +{ + sound_device_type_e type; + sound_device_io_direction_e io_direction; + sound_device_state_e state; + int id; + char *name; + int ret = SOUND_MANAGER_ERROR_NONE; + + g_print("***device information changed callback is called, changed_info[%d](0:STATE 1:IO_DIRECTION)\n", changed_info); + + if ((ret = sound_manager_get_device_type (device, &type))) + g_print("failed to get device type, ret[0x%x]\n", ret); + if ((ret = sound_manager_get_device_io_direction (device, &io_direction))) + g_print("failed to get device io direction, ret[0x%x]\n", ret); + if ((ret = sound_manager_get_device_id (device, &id))) + g_print("failed to get device id, ret[0x%x]\n", ret); + if ((ret = sound_manager_get_device_name (device, &name))) + g_print("failed to get device name, ret[0x%x]\n", ret); + if ((ret = sound_manager_get_device_state (device, &state))) + g_print("failed to get device state, ret[0x%x]\n", ret); + if (!ret) + g_print(" -- device type[%d], io_direction[%d], id[%d], name[%s], state[%d]\n", type, io_direction, id, name, state); +} + +void reset_menu_state(void) +{ + g_menu_state = CURRENT_STATUS_MAINMENU; +} + +static void interpret (char *cmd) +{ + switch (g_menu_state) + { + case CURRENT_STATUS_MAINMENU: + { + _interpret_main_menu(cmd); + } + break; + case CURRENT_STATUS_GET_MAX_VOLUME: + { + static sound_type_e type; + static int max; + if(convert_sound_type(&type,cmd) == 1) + { + if(sound_manager_get_max_volume(type, &max) != 0) + g_print("failt to get max volume\n"); + else + g_print("the max volume of this type(%d) is %d\n", type, max); + } + reset_menu_state(); + } + break; + case CURRENT_STATUS_SET_VOLUME: + { + static int cnt =0; + static sound_type_e type; + static int volume; + switch(cnt) + { + case 0: + if(convert_sound_type(&type,cmd) == 1) + cnt ++; + else + reset_menu_state(); + break; + case 1: + volume = atoi(cmd); + if(sound_manager_set_volume(type, volume) != 0) + g_print("fail to set volume(%d) check sound type(%d)'s available volume level\n", volume, type); + else + g_print("set volume success : sound type(%d), volume(%d)\n",type, volume); + cnt = 0; + reset_menu_state(); + break; + default: + break; + } + } + break; + case CURRENT_STATUS_GET_VOLUME: + { + static sound_type_e type; + static int volume; + if(convert_sound_type(&type,cmd) == 1) + { + if(sound_manager_get_volume(type, &volume) != 0) + g_print("fail to get volume\n"); + else + g_print("current volume of this type(%d) is : %d\n", type, volume); + } + reset_menu_state(); + } + break; + case CURRENT_STATUS_SET_CURRENT_SOUND_TYPE: + { + static sound_type_e type; + if(convert_sound_type(&type,cmd) == 1) + { + if(sound_manager_set_current_sound_type(type) != 0) + g_print("fail to set sound type(%d)\n", type); + else + g_print("success to set sound type(%d)\n", type); + } + reset_menu_state(); + } + break; + case CURRENT_STATUS_GET_CURRENT_SOUND_TYPE: + { + static sound_type_e type; + if(sound_manager_get_current_sound_type(&type) !=0) + g_print("fail to get current sound type\n"); + else + g_print("current sound type is (%d)\n", type); + reset_menu_state(); + } + break; + case CURRENT_STATUS_UNSET_CURRENT_SOUND_TYPE: + { + if(sound_manager_unset_current_sound_type() !=0) + g_print("fail to unset current sound type\n"); + else + g_print("success to unset current sound type\n"); + reset_menu_state(); + } + break; + case CURRENT_STATUS_SET_VOLUME_CHANGED_CB: + { + if(sound_manager_set_volume_changed_cb(_set_volume_changed_cb, NULL) !=0) + g_print("fail to set volume changed cb\n"); + else + g_print("success to set volume changed cb\n"); + reset_menu_state(); + } + break; + case CURRENT_STATUS_UNSET_VOLUME_CHANGED_CB: + { + if(sound_manager_unset_volume_changed_cb() !=0) + g_print("fail to unset volume changed cb\n"); + else + g_print("success to unset volume changed cb\n"); + reset_menu_state(); + } + break; + case CURRENT_STATUS_SET_SESSION_TYPE: + { + static sound_session_type_e type; + if(convert_session_type(&type, cmd) == 1) + { + if(sound_manager_set_session_type(type) !=0) + g_print("fail to set session type\n"); + else + g_print("success to set session type(%d)\n",type); + } + reset_menu_state(); + } + break; + case CURRENT_STATUS_GET_SESSION_TYPE: + { + static sound_session_type_e type; + if(sound_manager_get_session_type(&type) !=0) + g_print("fail to get session type\n"); + else + g_print("current session type is : %d (0:MEDIA, 1:ALARM, 2:NOTIFICATION, 3:EMERGENCY, 4:VOIP)\n", type); + + reset_menu_state(); + } + break; + case CURRENT_STATUS_SET_MEDIA_SESSION_OPTION: + { + static sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA; + static sound_session_option_for_starting_e option_s; + static sound_session_option_for_during_play_e option_d; + static int cnt = 0; + if(sound_manager_set_session_type(type) !=0) + { + g_print("fail to set media session type\n"); + reset_menu_state(); + } + else + { + switch(cnt) + { + case 0: + option_s = (sound_session_option_for_starting_e)atoi(cmd); + if(SOUND_SESSION_OPTION_MIX_WITH_OTHERS_WHEN_START > option_s || SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START < option_s) + g_print("not supported option type\n"); + else + cnt ++; + break; + case 1: + option_d = (sound_session_option_for_during_play_e)atoi(cmd); + if(SOUND_SESSION_OPTION_INTERRUPTIBLE_DURING_PLAY > option_d || SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY < option_d) + g_print("not supported option type\n"); + else + { + if(sound_manager_set_media_session_option(option_s, option_d) != 0) + g_print("fail to set media session option\n"); + else + g_print("success to set media session option\n"); + cnt = 0; + } + reset_menu_state(); + break; + default: + break; + } + } + } + break; + case CURRENT_STATUS_GET_MEDIA_SESSION_OPTION: + { + static sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA; + static sound_session_option_for_starting_e option_s; + static sound_session_option_for_during_play_e option_d; + if(sound_manager_set_session_type(type) != 0) + g_print("fail to set media session type\n"); + else + { + if(sound_manager_get_media_session_option(&option_s,&option_d) !=0) + g_print("fail to get media session option\n"); + else + g_print("current media session options are (%d) for starting, (%d) for ongoing\n", option_s, option_d); + } + reset_menu_state(); + } + break; + case CURRENT_STATUS_SET_MEDIA_SESSION_RESUMPTION_OPTION: + { + static sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA; + static sound_session_option_for_resumption_e option_r; + if(sound_manager_set_session_type(type) != 0) + g_print("fail to set media session type\n"); + else + { + option_r = (sound_session_option_for_resumption_e)atoi(cmd); + if(SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM > option_r || SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED < option_r) + g_print("not supported option type\n"); + else + { + if(sound_manager_set_media_session_resumption_option(option_r) !=0) + g_print("fail to set media session resumption option\n"); + else + g_print("succese to set media session resumption option\n"); + } + } + reset_menu_state(); + } + break; + case CURRENT_STATUS_GET_MEDIA_SESSION_RESUMPTION_OPTION: + { + static sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA; + static sound_session_option_for_resumption_e option_r; + if(sound_manager_set_session_type(type) != 0) + g_print("fail to set media session type\n"); + else + { + if(sound_manager_get_media_session_resumption_option(&option_r) != 0) + g_print("fail to get media session resumption option\n"); + else + g_print("current media session resumption option is : %d\n", option_r); + } + reset_menu_state(); + } + break; + case CURRENT_STATUS_SET_VOIP_SESSION_MODE: + { + int ret = SOUND_MANAGER_ERROR_NONE; + sound_session_voip_mode_e mode; + mode = (sound_session_voip_mode_e)atoi(cmd); + ret = sound_manager_set_voip_session_mode(mode); + if (ret) { + g_print("failed to set voip session mode(%d), ret[0x%x]\n", mode, ret); + } else { + g_print("success to set voip session mode\n"); + } + reset_menu_state(); + } + break; + case CURRENT_STATUS_GET_VOIP_SESSION_MODE: + { + int ret = SOUND_MANAGER_ERROR_NONE; + sound_session_voip_mode_e mode; + ret = sound_manager_get_voip_session_mode(&mode); + if(ret) + g_print("fail to get voip session mode, ret[0x%x]\n", ret); + else + g_print("success to get voip session mode, mode[%d]\n", mode); + reset_menu_state(); + } + break; + case CURRENT_STATUS_SET_SESSION_INTERRUPTED_CB: + { + if(sound_manager_set_session_interrupted_cb(_set_session_interrupted_cb, NULL) != 0) + g_print("fail to set interrupted changed cb\n"); + else + g_print("success to set interrupted changed cb\n"); + reset_menu_state(); + } + break; + case CURRENT_STATUS_UNSET_SESSION_INTERRUPTED_CB: + { + if(sound_manager_unset_session_interrupted_cb() != 0) + g_print("fail to unset interrupted changed cb\n"); + else + g_print("success to unset interrupted changed cb\n"); + reset_menu_state(); + } + break; + case CURRENT_STATUS_SET_DEVICE_MASK: + { + if (strncmp(cmd, "0", 1) == 0) { + g_device_mask = SOUND_DEVICE_ALL_MASK; + reset_menu_state(); + } else if (strncmp(cmd, "1", 1) == 0) { + if (g_device_mask == SOUND_DEVICE_ALL_MASK) + g_device_mask = SOUND_DEVICE_TYPE_INTERNAL_MASK; + else + g_device_mask |= SOUND_DEVICE_TYPE_INTERNAL_MASK; + g_print("add TYPE_INTERNAL MASK\n"); + } else if (strncmp(cmd, "2", 1) == 0) { + if (g_device_mask == SOUND_DEVICE_ALL_MASK) + g_device_mask = SOUND_DEVICE_TYPE_EXTERNAL_MASK; + else + g_device_mask |= SOUND_DEVICE_TYPE_EXTERNAL_MASK; + g_print("add TYPE_EXTERNAL MASK\n"); + } else if (strncmp(cmd, "3", 1) == 0) { + if (g_device_mask == SOUND_DEVICE_ALL_MASK) + g_device_mask = SOUND_DEVICE_IO_DIRECTION_IN_MASK; + else + g_device_mask |= SOUND_DEVICE_IO_DIRECTION_IN_MASK; + g_print("add IO_DIRECTION_IN MASK\n"); + } else if (strncmp(cmd, "4", 1) == 0) { + if (g_device_mask == SOUND_DEVICE_ALL_MASK) + g_device_mask = SOUND_DEVICE_IO_DIRECTION_OUT_MASK; + else + g_device_mask |= SOUND_DEVICE_IO_DIRECTION_OUT_MASK; + g_print("add IO_DIRECTION_OUT MASK\n"); + } else if (strncmp(cmd, "5", 1) == 0) { + if (g_device_mask == SOUND_DEVICE_ALL_MASK) + g_device_mask = SOUND_DEVICE_IO_DIRECTION_BOTH_MASK; + else + g_device_mask |= SOUND_DEVICE_IO_DIRECTION_BOTH_MASK; + g_print("add IO_DIRECTION_BOTH MASK\n"); + } else if (strncmp(cmd, "6", 1) == 0) { + if (g_device_mask == SOUND_DEVICE_ALL_MASK) + g_device_mask = SOUND_DEVICE_STATE_ACTIVATED_MASK; + else + g_device_mask |= SOUND_DEVICE_STATE_ACTIVATED_MASK; + g_print("add STATE_ACTIVATED MASK\n"); + } else if (strncmp(cmd, "7", 1) == 0) { + if (g_device_mask == SOUND_DEVICE_ALL_MASK) + g_device_mask = SOUND_DEVICE_STATE_DEACTIVATED_MASK; + else + g_device_mask |= SOUND_DEVICE_STATE_DEACTIVATED_MASK; + g_print("add STATE_DEACTIVATED MASK\n"); + } else if (strncmp(cmd, "b", 1) == 0) { + g_print("device mask[0x%x]\n", g_device_mask); + reset_menu_state(); + } else { + g_print("invalid selection, please select again..\n"); + } + } + break; + case CURRENT_STATUS_GET_DEVICE_MASK: + { + g_print("current device mask[0x%x]\n", g_device_mask); + reset_menu_state(); + } + break; + case CURRENT_STATUS_GET_DEVICE_LIST: + { + int ret = SOUND_MANAGER_ERROR_NONE; + if (!(ret = sound_manager_get_current_device_list(g_device_mask, &g_device_list))) + g_print("success to get current device list\n"); + else + g_print("fail to get current device list, ret[0x%x]\n", ret); + reset_menu_state(); + } + break; + case CURRENT_STATUS_GET_DEVICE_NEXT: + { + sound_device_h device; + sound_device_type_e type; + sound_device_io_direction_e io_direction; + sound_device_state_e state; + int id; + char *name; + int ret = SOUND_MANAGER_ERROR_NONE; + if (!(ret = sound_manager_get_next_device(g_device_list, &device))) { + g_print("success to get next device\n"); + if ((ret = sound_manager_get_device_type (device, &type))) + g_print("failed to get device type, ret[0x%x]\n", ret); + if ((ret = sound_manager_get_device_io_direction (device, &io_direction))) + g_print("failed to get device io direction, ret[0x%x]\n", ret); + if ((ret = sound_manager_get_device_id (device, &id))) + g_print("failed to get device id, ret[0x%x]\n", ret); + if ((ret = sound_manager_get_device_name (device, &name))) + g_print("failed to get device name, ret[0x%x]\n", ret); + if ((ret = sound_manager_get_device_state (device, &state))) + g_print("failed to get device state, ret[0x%x]\n", ret); + if (!ret) + g_print("-- NEXT device type[%d], io_direction[%d], id[%d], name[%s], state[%d]\n", type, io_direction, id, name, state); + } else { + g_print("failed to get next device, ret[0x%x]\n", ret); + } + reset_menu_state(); + } + break; + case CURRENT_STATUS_GET_DEVICE_PREV: + { + sound_device_h device; + sound_device_type_e type; + sound_device_io_direction_e io_direction; + sound_device_state_e state; + int id; + char *name; + int ret = SOUND_MANAGER_ERROR_NONE; + if (!(ret = sound_manager_get_prev_device(g_device_list, &device))) { + g_print("success to get previous device\n"); + if ((ret = sound_manager_get_device_type (device, &type))) + g_print("failed to get device type, ret[0x%x]\n", ret); + if ((ret = sound_manager_get_device_io_direction (device, &io_direction))) + g_print("failed to get device io direction, ret[0x%x]\n", ret); + if ((ret = sound_manager_get_device_id (device, &id))) + g_print("failed to get device id, ret[0x%x]\n", ret); + if ((ret = sound_manager_get_device_name (device, &name))) + g_print("failed to get device name, ret[0x%x]\n", ret); + if ((ret = sound_manager_get_device_state (device, &state))) + g_print("failed to get device state, ret[0x%x]\n", ret); + if (!ret) + g_print("-- PREV device type[%d], io_direction[%d], id[%d], name[%s], state[%d]\n", type, io_direction, id, name, state); + } else { + g_print("failed to get previous device, ret[0x%x]\n", ret); + } + reset_menu_state(); + } + break; + case CURRENT_STATUS_SET_DEVICE_CONNECTED_CB: + { + if (sound_manager_set_device_connected_cb(g_device_mask, _set_device_connected_cb, NULL)) + g_print("fail to set device connected cb\n"); + else + g_print("success to set device connected cb\n"); + reset_menu_state(); + } + break; + case CURRENT_STATUS_UNSET_DEVICE_CONNECTED_CB: + { + if (sound_manager_unset_device_connected_cb()) + g_print("fail to unset device connected cb\n"); + else + g_print("success to unset device connected cb\n"); + reset_menu_state(); + } + break; + case CURRENT_STATUS_SET_DEVICE_INFO_CHANGED_CB: + { + if (sound_manager_set_device_information_changed_cb(g_device_mask, _set_device_info_changed_cb, NULL)) + g_print("fail to set device information changed cb\n"); + else + g_print("success to set device information changed cb\n"); + reset_menu_state(); + } + break; + case CURRENT_STATUS_UNSET_DEVICE_INFO_CHANGED_CB: + { + if (sound_manager_unset_device_information_changed_cb()) + g_print("fail to unset device information changed cb\n"); + else + g_print("success to unset device information changed cb\n"); + reset_menu_state(); + } + break; + } + g_timeout_add(100, timeout_menu_display, 0); +} + +gboolean input (GIOChannel *channel) +{ + gchar buf[MAX_STRING_LEN]; + gsize read; + GError *error = NULL; + + g_io_channel_read_chars(channel, buf, MAX_STRING_LEN, &read, &error); + buf[read] = '\0'; + g_strstrip(buf); + interpret (buf); + + return TRUE; +} + +int main(int argc, char *argv[]) +{ + GIOChannel *stdin_channel; + stdin_channel = g_io_channel_unix_new(0); + g_io_channel_set_flags (stdin_channel, G_IO_FLAG_NONBLOCK, NULL); + g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)input, NULL); + g_loop = g_main_loop_new (NULL, 1); + + displaymenu(); + g_main_loop_run (g_loop); + + return 0; +}