From 92ce1a7124e7073f8e19a9de7ca3c6d8bd143efd Mon Sep 17 00:00:00 2001 From: "jk7744.park" Date: Tue, 8 Sep 2015 22:31:06 +0900 Subject: tizen 2.3.1 release --- .gitignore | 14 + LICENSE | 204 - LICENSE.APLv2 | 206 + Makefile.am | 39 +- NOTICE | 3 + common/Makefile.am | 3 +- common/mm_sound_utils.c | 282 +- common/mm_source.c | 333 +- configure | 15649 ------------------- configure.ac | 77 +- depcomp | 589 - dump_audio.sh | 23 + include/mm_ipc.h | 20 +- include/mm_sound.h | 615 +- include/mm_sound_client.h | 25 +- include/mm_sound_common.h | 202 +- include/mm_sound_device.h | 112 + include/mm_sound_msg.h | 23 + include/mm_sound_pa_client.h | 91 + include/mm_sound_pcm_async.h | 50 + include/mm_sound_private.h | 64 +- include/mm_sound_utils.h | 20 + init/Makefile.am | 2 - init/mmfwaudio | 10 - init/soundserver | 12 - libmm-sound-tool.manifest | 8 + libmm-sound.manifest | 12 + missing | 367 - mm_sound.c | 1314 +- mm_sound_bootsound.c | 85 + mm_sound_client.c | 1435 +- mm_sound_device.c | 275 + mm_sound_keysound.c | 41 +- mm_sound_pa_client.c | 1048 ++ mm_sound_pcm.c | 1249 ++ mm_sound_pcm_async.c | 1431 ++ packaging/libmm-sound.spec | 153 +- packaging/sound-server.path | 5 + packaging/sound-server.service | 12 + pkgconfig/Makefile.am | 4 +- pkgconfig/mm-bootsound.pc.in | 11 + pkgconfig/mm-sound.pc.in | 2 +- server/Makefile.am | 33 +- server/include/asm-log.h | 81 - server/include/mm_sound_mgr_asm.h | 2 +- server/include/mm_sound_mgr_codec.h | 6 +- server/include/mm_sound_mgr_device.h | 35 + server/include/mm_sound_mgr_device_dock.h | 41 + server/include/mm_sound_mgr_device_hdmi.h | 30 + server/include/mm_sound_mgr_device_headset.h | 31 + server/include/mm_sound_mgr_device_wfd.h | 30 + server/include/mm_sound_mgr_dock.h | 32 - server/include/mm_sound_mgr_headset.h | 33 - server/include/mm_sound_mgr_ipc.h | 5 + server/include/mm_sound_mgr_pulse.h | 27 +- server/include/mm_sound_mgr_session.h | 55 +- server/include/mm_sound_plugin_codec.h | 5 +- server/include/mm_sound_recovery.h | 29 - server/mm_sound_mgr_asm.c | 3355 +++- server/mm_sound_mgr_codec.c | 247 +- server/mm_sound_mgr_device.c | 1385 +- server/mm_sound_mgr_device_dock.c | 215 + server/mm_sound_mgr_device_hdmi.c | 213 + server/mm_sound_mgr_device_headset.c | 107 + server/mm_sound_mgr_device_wfd.c | 94 + server/mm_sound_mgr_dock.c | 97 - server/mm_sound_mgr_headset.c | 245 - server/mm_sound_mgr_ipc.c | 657 +- server/mm_sound_mgr_pulse.c | 2582 ++- server/mm_sound_mgr_session.c | 2545 ++- server/mm_sound_plugin.c | 19 +- server/mm_sound_recovery.c | 69 - server/mm_sound_server.c | 221 +- server/mm_sound_thread_pool.c | 17 +- server/plugin/Makefile.am | 5 + server/plugin/keytone/Makefile.am | 18 +- .../plugin/keytone/mm_sound_plugin_run_key_tone.c | 715 +- server/plugin/ogg/Makefile.am | 21 + server/plugin/ogg/mm_sound_plugin_codec_ogg.c | 519 + server/plugin/tone/Makefile.am | 5 +- server/plugin/tone/mm_sound_plugin_codec_tone.c | 218 +- server/plugin/wav/Makefile.am | 5 +- server/plugin/wav/mm_sound_plugin_codec_wave.c | 279 +- server/sounds/Tizen_HW_Touch.ogg | Bin 0 -> 6646 bytes server/sounds/dock.ogg | Bin 0 -> 13792 bytes server/sounds/undock.ogg | Bin 0 -> 8066 bytes testsuite/Makefile.am | 4 +- testsuite/mm_sound_testsuite_simple.c | 822 +- 88 files changed, 19885 insertions(+), 21389 deletions(-) create mode 100644 .gitignore delete mode 100644 LICENSE create mode 100644 LICENSE.APLv2 create mode 100644 NOTICE mode change 100644 => 100755 common/mm_sound_utils.c delete mode 100755 configure delete mode 100755 depcomp create mode 100755 dump_audio.sh mode change 100644 => 100755 include/mm_sound.h mode change 100644 => 100755 include/mm_sound_common.h create mode 100644 include/mm_sound_device.h create mode 100644 include/mm_sound_pa_client.h create mode 100644 include/mm_sound_pcm_async.h mode change 100644 => 100755 include/mm_sound_utils.h delete mode 100644 init/Makefile.am delete mode 100755 init/mmfwaudio delete mode 100755 init/soundserver create mode 100644 libmm-sound-tool.manifest create mode 100644 libmm-sound.manifest delete mode 100755 missing mode change 100644 => 100755 mm_sound.c create mode 100644 mm_sound_bootsound.c create mode 100644 mm_sound_device.c create mode 100644 mm_sound_pa_client.c create mode 100644 mm_sound_pcm.c create mode 100644 mm_sound_pcm_async.c create mode 100644 packaging/sound-server.path create mode 100644 packaging/sound-server.service create mode 100644 pkgconfig/mm-bootsound.pc.in delete mode 100644 server/include/asm-log.h create mode 100644 server/include/mm_sound_mgr_device_dock.h create mode 100644 server/include/mm_sound_mgr_device_hdmi.h create mode 100644 server/include/mm_sound_mgr_device_headset.h create mode 100644 server/include/mm_sound_mgr_device_wfd.h delete mode 100644 server/include/mm_sound_mgr_dock.h delete mode 100644 server/include/mm_sound_mgr_headset.h mode change 100644 => 100755 server/include/mm_sound_mgr_pulse.h mode change 100644 => 100755 server/include/mm_sound_mgr_session.h delete mode 100644 server/include/mm_sound_recovery.h mode change 100644 => 100755 server/mm_sound_mgr_device.c create mode 100644 server/mm_sound_mgr_device_dock.c create mode 100755 server/mm_sound_mgr_device_hdmi.c create mode 100644 server/mm_sound_mgr_device_headset.c create mode 100644 server/mm_sound_mgr_device_wfd.c delete mode 100644 server/mm_sound_mgr_dock.c delete mode 100644 server/mm_sound_mgr_headset.c mode change 100644 => 100755 server/mm_sound_mgr_pulse.c mode change 100644 => 100755 server/mm_sound_mgr_session.c delete mode 100644 server/mm_sound_recovery.c create mode 100644 server/plugin/ogg/Makefile.am create mode 100644 server/plugin/ogg/mm_sound_plugin_codec_ogg.c create mode 100644 server/sounds/Tizen_HW_Touch.ogg create mode 100644 server/sounds/dock.ogg create mode 100644 server/sounds/undock.ogg diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..93c5f57 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +build_log +*.log +*.pyc +usr +opt +*.o +*.lo +*.la +*.os +*.exe +packages +binaries +*.ipk +*~ diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 9c13a9b..0000000 --- a/LICENSE +++ /dev/null @@ -1,204 +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/LICENSE.APLv2 b/LICENSE.APLv2 new file mode 100644 index 0000000..bbe9d02 --- /dev/null +++ b/LICENSE.APLv2 @@ -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/Makefile.am b/Makefile.am index efa0c75..0955574 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,16 +4,20 @@ SUBDIRS = common \ server \ testsuite -SUBDIRS += init - lib_LTLIBRARIES = libmmfsound.la includelibmmfsounddir = $(includedir)/mmf includelibmmfsound_HEADERS = include/mm_sound.h \ - include/mm_sound_private.h + include/mm_sound_private.h \ + include/mm_sound_pa_client.h \ + include/mm_sound_pcm_async.h libmmfsound_la_SOURCES = mm_sound.c \ - mm_sound_client.c + mm_sound_client.c \ + mm_sound_device.c \ + mm_sound_pcm.c \ + mm_sound_pa_client.c \ + mm_sound_pcm_async.c libmmfsound_la_DEPENDENCIES = common/libmmfsoundcommon.la @@ -22,26 +26,28 @@ libmmfsound_la_CFLAGS = -I$(srcdir)/include \ $(MMCOMMON_CFLAGS) \ $(VCONF_CFLAGS) \ -I$(srcdir)/servertype/include \ - $(AVSYSTEM_CFLAGS) \ $(GLIB2_CFLAGS) \ $(MMSESSION_CFLAGS) \ $(AUDIOSESSIONMGR_CFLAGS) \ -D_USE_INTERNAL_SOUND_PATH_ \ + $(PASIMPLE_CFLAGS) \ + $(PA_CFLAGS) \ $(VCONF_CFLAGS) if USE_PULSE libmmfsound_la_CFLAGS += -DPULSE_CLIENT endif - libmmfsound_la_LIBADD = $(MMCOMMON_LIBS) \ - $(AVSYSTEM_LIBS) \ $(MMSESSION_LIBS) \ $(AUDIOSESSIONMGR_LIBS) \ $(GLIB2_LIBS) \ $(srcdir)/common/libmmfsoundcommon.la \ + $(PASIMPLE_LIBS) \ + $(PA_LIBS) \ $(VCONF_LIBS) - + + libmmfsound_la_LDFLAGS = -version-info 1:0:1 #For logmanager @@ -62,8 +68,23 @@ libmmfkeysound_la_SOURCES = mm_sound_keysound.c libmmfkeysound_la_CFLAGS = -I$(srcdir)/include \ $(MMCOMMON_CFLAGS) \ + $(VCONF_CFLAGS) \ -D_USE_INTERNAL_SOUND_PATH_ -libmmfkeysound_la_LIBADD = $(MMCOMMON_LIBS) +libmmfkeysound_la_LIBADD = $(MMCOMMON_LIBS) $(VCONF_LIBS) libmmfkeysound_la_CFLAGS += $(MMLOGSVR_CFLAGS) -DMMF_LOG_OWNER=0x020 -DMMF_DEBUG_PREFIX=\"MMF-SOUND\" libmmfkeysound_la_LIBADD += $(MMLOGSVR_LIBS) + +lib_LTLIBRARIES += libmmfbootsound.la + +includelibmmfbootsounddir = $(includedir)/mmf + +libmmfbootsound_la_SOURCES = mm_sound_bootsound.c +libmmfbootsound_la_CFLAGS = -I$(srcdir)/include \ + $(MMCOMMON_CFLAGS) \ + $(VCONF_CFLAGS) \ + -D_USE_INTERNAL_SOUND_PATH_ + +libmmfbootsound_la_LIBADD = $(MMCOMMON_LIBS) $(VCONF_LIBS) +libmmfbootsound_la_CFLAGS += $(MMLOGSVR_CFLAGS) -DMMF_LOG_OWNER=0x020 -DMMF_DEBUG_PREFIX=\"MMF-SOUND\" +libmmfbootsound_la_LIBADD += $(MMLOGSVR_LIBS) diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..0e0f016 --- /dev/null +++ b/NOTICE @@ -0,0 +1,3 @@ +Copyright (c) Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Apache License, Version 2. +Please, see the LICENSE.APLv2 file for Apache License terms and conditions. diff --git a/common/Makefile.am b/common/Makefile.am index 9481f5d..5e97c1b 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -10,10 +10,9 @@ libmmfsoundcommon_la_SOURCES = mm_ipc.c \ libmmfsoundcommon_la_CFLAGS = -I$(srcdir)/../include \ $(MMCOMMON_CFLAGS) \ $(VCONF_CFLAGS) - libmmfsoundcommon_la_LIBADD = $(MMCOMMON_LIBS) \ - $(VCONF_LIBS) + $(VCONF_LIBS) #libmmfsound_la_LDFLAGS = -version-info 1:0:1 diff --git a/common/mm_sound_utils.c b/common/mm_sound_utils.c old mode 100644 new mode 100755 index 25de33c..0cae6f6 --- a/common/mm_sound_utils.c +++ b/common/mm_sound_utils.c @@ -24,19 +24,59 @@ #include #include #include +#include #include +#include +#include #include #include #include #include "../include/mm_sound_private.h" #include "../include/mm_sound.h" +#include "../include/mm_sound_common.h" #include "../include/mm_sound_utils.h" -static mm_sound_route g_valid_route[] = { MM_SOUND_ROUTE_OUT_SPEAKER, MM_SOUND_ROUTE_OUT_WIRED_ACCESSORY, MM_SOUND_ROUTE_OUT_BLUETOOTH, - MM_SOUND_ROUTE_IN_MIC, MM_SOUND_ROUTE_IN_WIRED_ACCESSORY, MM_SOUND_ROUTE_IN_MIC_OUT_RECEIVER, - MM_SOUND_ROUTE_IN_MIC_OUT_SPEAKER, MM_SOUND_ROUTE_IN_MIC_OUT_HEADPHONE, - MM_SOUND_ROUTE_INOUT_HEADSET, MM_SOUND_ROUTE_INOUT_BLUETOOTH }; +static mm_sound_route g_valid_route[] = { + MM_SOUND_ROUTE_OUT_SPEAKER, MM_SOUND_ROUTE_OUT_RECEIVER, MM_SOUND_ROUTE_OUT_WIRED_ACCESSORY, MM_SOUND_ROUTE_OUT_BLUETOOTH_SCO, MM_SOUND_ROUTE_OUT_BLUETOOTH_A2DP, + MM_SOUND_ROUTE_OUT_DOCK, MM_SOUND_ROUTE_OUT_HDMI, MM_SOUND_ROUTE_OUT_MIRRORING, MM_SOUND_ROUTE_OUT_USB_AUDIO, MM_SOUND_ROUTE_OUT_MULTIMEDIA_DOCK, + MM_SOUND_ROUTE_IN_MIC, MM_SOUND_ROUTE_IN_WIRED_ACCESSORY, MM_SOUND_ROUTE_IN_MIC_OUT_RECEIVER, + MM_SOUND_ROUTE_IN_MIC_OUT_SPEAKER, MM_SOUND_ROUTE_IN_MIC_OUT_HEADPHONE, + MM_SOUND_ROUTE_INOUT_HEADSET, MM_SOUND_ROUTE_INOUT_BLUETOOTH +}; + +#define MM_SOUND_DEFAULT_VOLUME_SYSTEM 9 +#define MM_SOUND_DEFAULT_VOLUME_NOTIFICATION 11 +#define MM_SOUND_DEFAULT_VOLUME_ALARAM 7 +#define MM_SOUND_DEFAULT_VOLUME_RINGTONE 11 +#define MM_SOUND_DEFAULT_VOLUME_MEDIA 7 +#define MM_SOUND_DEFAULT_VOLUME_CALL 4 +#define MM_SOUND_DEFAULT_VOLUME_VOIP 4 +#define MM_SOUND_DEFAULT_VOLUME_VOICE 7 +#define MM_SOUND_DEFAULT_VOLUME_ANDROID 0 + +static char *g_volume_vconf[VOLUME_TYPE_MAX] = { + VCONF_KEY_VOLUME_TYPE_SYSTEM, /* VOLUME_TYPE_SYSTEM */ + VCONF_KEY_VOLUME_TYPE_NOTIFICATION, /* VOLUME_TYPE_NOTIFICATION */ + VCONF_KEY_VOLUME_TYPE_ALARM, /* VOLUME_TYPE_ALARM */ + VCONF_KEY_VOLUME_TYPE_RINGTONE, /* VOLUME_TYPE_RINGTONE */ + VCONF_KEY_VOLUME_TYPE_MEDIA, /* VOLUME_TYPE_MEDIA */ + VCONF_KEY_VOLUME_TYPE_CALL, /* VOLUME_TYPE_CALL */ + VCONF_KEY_VOLUME_TYPE_VOIP, /* VOLUME_TYPE_VOIP */ + VCONF_KEY_VOLUME_TYPE_VOICE, /* VOLUME_TYPE_VOICE */ + VCONF_KEY_VOLUME_TYPE_ANDROID /* VOLUME_TYPE_FIXED */ +}; +static char *g_volume_str[VOLUME_TYPE_MAX] = { + "SYSTEM", + "NOTIFICATION", + "ALARM", + "RINGTONE", + "MEDIA", + "CALL", + "VOIP", + "VOICE", + "FIXED", +}; EXPORT_API int _mm_sound_get_valid_route_list(mm_sound_route **route_list) @@ -67,7 +107,7 @@ void _mm_sound_get_devices_from_route(mm_sound_route route, mm_sound_device_in * { if (device_in && device_out) { *device_in = route & 0x00FF; - *device_out = route & 0xFF00; + *device_out = route & 0xFFF00; } } @@ -92,5 +132,237 @@ bool _mm_sound_check_hibernation (const char *path) return true; } +EXPORT_API +int _mm_sound_volume_add_callback(volume_type_t type, void *func, void* user_data) +{ + if (vconf_notify_key_changed(g_volume_vconf[type], func, user_data)) { + debug_error ("vconf_notify_key_changed failed..\n"); + return MM_ERROR_SOUND_INTERNAL; + } + + return MM_ERROR_NONE; +} + +EXPORT_API +int _mm_sound_volume_remove_callback(volume_type_t type, void *func) +{ + if (vconf_ignore_key_changed(g_volume_vconf[type], func)) { + debug_error ("vconf_ignore_key_changed failed..\n"); + return MM_ERROR_SOUND_INTERNAL; + } + + return MM_ERROR_NONE; +} + +EXPORT_API +int _mm_sound_muteall_add_callback(void *func) +{ + if (vconf_notify_key_changed(VCONF_KEY_MUTE_ALL, func, NULL)) { + debug_error ("vconf_notify_key_changed failed..\n"); + return MM_ERROR_SOUND_INTERNAL; + } + + return MM_ERROR_NONE; +} + +EXPORT_API +int _mm_sound_muteall_remove_callback(void *func) +{ + if (vconf_ignore_key_changed(VCONF_KEY_MUTE_ALL, func)) { + debug_error ("vconf_ignore_key_changed failed..\n"); + return MM_ERROR_SOUND_INTERNAL; + } + + return MM_ERROR_NONE; +} + +EXPORT_API +int _mm_sound_volume_get_value_by_type(volume_type_t type, unsigned int *value) +{ + int ret = MM_ERROR_NONE; + int vconf_value = 0; + + /* Get volume value from VCONF */ + if (vconf_get_int(g_volume_vconf[type], &vconf_value)) { + debug_error ("vconf_get_int(%s) failed..\n", g_volume_vconf[type]); + return MM_ERROR_SOUND_INTERNAL; + } + + *value = vconf_value; + if (ret == MM_ERROR_NONE) + debug_log("volume_get_value %s %d", g_volume_str[type], *value); + + return ret; +} + +EXPORT_API +int _mm_sound_volume_set_value_by_type(volume_type_t type, unsigned int value) +{ + int ret = MM_ERROR_NONE; + int vconf_value = 0; + + vconf_value = value; + debug_log("volume_set_value %s %d", g_volume_str[type], value); + + /* Set volume value to VCONF */ + if ((ret = vconf_set_int(g_volume_vconf[type], vconf_value)) != 0) { + debug_error ("vconf_set_int(%s) failed..ret[%d]\n", g_volume_vconf[type], ret); + if (ret == -EPERM || ret == -EACCES) + return MM_ERROR_SOUND_PERMISSION_DENIED; + else + return MM_ERROR_SOUND_INTERNAL; + } + return ret; +} + +EXPORT_API +int _mm_sound_volume_set_balance(float balance) +{ + /* Set balance value to VCONF */ + if (vconf_set_dbl(VCONF_KEY_VOLUME_BALANCE, balance)) { + debug_error ("vconf_set_dbl(%s) failed..\n", VCONF_KEY_VOLUME_BALANCE); + return MM_ERROR_SOUND_INTERNAL; + } + + return MM_ERROR_NONE; +} + +EXPORT_API +int _mm_sound_volume_get_balance(float *balance) +{ + double balance_value = 0; + + /* Get balance value from VCONF */ + if (vconf_get_dbl(VCONF_KEY_VOLUME_BALANCE, &balance_value)) { + debug_error ("vconf_get_int(%s) failed..\n", VCONF_KEY_VOLUME_BALANCE); + return MM_ERROR_SOUND_INTERNAL; + } + + *balance = balance_value; + debug_log("balance get value [%s]=[%f]", VCONF_KEY_VOLUME_BALANCE, *balance); + + return MM_ERROR_NONE; +} + +EXPORT_API +int _mm_sound_set_muteall(int muteall) +{ + /* Set muteall value to VCONF */ + if (vconf_set_int(VCONF_KEY_MUTE_ALL, muteall)) { + debug_error ("vconf_set_int(%s) failed..\n", VCONF_KEY_MUTE_ALL); + return MM_ERROR_SOUND_INTERNAL; + } + + return MM_ERROR_NONE; +} + +EXPORT_API +int _mm_sound_get_muteall(int *muteall) +{ + int muteall_value = 0; + + /* Get muteall value from VCONF */ + if (vconf_get_int(VCONF_KEY_MUTE_ALL, &muteall_value)) { + debug_error ("vconf_get_int(%s) failed..\n", VCONF_KEY_MUTE_ALL); + return MM_ERROR_SOUND_INTERNAL; + } + + *muteall = muteall_value; + debug_log("muteall get value [%s]=[%d]", VCONF_KEY_MUTE_ALL, *muteall); + + return MM_ERROR_NONE; +} + +EXPORT_API +int __mm_sound_set_stereo_to_mono(int ismono) +{ + /* Set ismono value to VCONF */ + if (vconf_set_int(VCONF_KEY_MONO_AUDIO, ismono)) { + debug_error ("vconf_set_int(%s) failed..\n", VCONF_KEY_MONO_AUDIO); + return MM_ERROR_SOUND_INTERNAL; + } + + return MM_ERROR_NONE; +} + +EXPORT_API +int __mm_sound_get_stereo_to_mono(int *ismono) +{ + int ismono_value = 0; + + /* Get ismono value from VCONF */ + if (vconf_get_int(VCONF_KEY_MONO_AUDIO, &ismono_value)) { + debug_error ("vconf_get_int(%s) failed..\n", VCONF_KEY_MONO_AUDIO); + return MM_ERROR_SOUND_INTERNAL; + } + *ismono = ismono_value; + debug_log("ismono get value [%s]=[%d]", VCONF_KEY_MONO_AUDIO, *ismono); + return MM_ERROR_NONE; +} + +EXPORT_API +int _mm_sound_get_earjack_type (int *type) +{ + int earjack_status = 0; + + if (type == NULL) { + debug_error ("invalid parameter!!!"); + return MM_ERROR_INVALID_ARGUMENT; + } + + /* Get actual vconf value */ + vconf_get_int(VCONFKEY_SYSMAN_EARJACK, &earjack_status); + debug_msg ("[%s] get status=[%d]\n", VCONFKEY_SYSMAN_EARJACK, earjack_status); + + *type = (earjack_status >= 0)? earjack_status : VCONFKEY_SYSMAN_EARJACK_REMOVED; + + return MM_ERROR_NONE; +} + +EXPORT_API +int _mm_sound_get_dock_type (int *type) +{ + int dock_status = 0; + + if (type == NULL) { + debug_error ("invalid parameter!!!"); + return MM_ERROR_INVALID_ARGUMENT; + } + + /* Get actual vconf value */ + vconf_get_int(VCONFKEY_SYSMAN_CRADLE_STATUS, &dock_status); + debug_msg ("[%s] get dock status=[%d]\n", VCONFKEY_SYSMAN_CRADLE_STATUS, dock_status); + + *type = dock_status; + + return MM_ERROR_NONE; +} + +EXPORT_API +bool _mm_sound_is_recording (void) +{ + int capture_status = 0; + bool result = false; + + /* Check whether audio is recording */ + vconf_get_int(VCONFKEY_RECORDER_STATE, &capture_status); + if(capture_status == VCONFKEY_RECORDER_STATE_RECORDING) { + result = true; + debug_msg ("capture status=%d, result=%d", capture_status, result); + } + return result; +} + +EXPORT_API +bool _mm_sound_is_mute_policy (void) +{ + int setting_sound_status = true; + + /* If sound is mute mode, force ringtone/notification path to headset */ + vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &setting_sound_status); + debug_log ("[%s] setting_sound_status=%d\n", VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, setting_sound_status); + + return !setting_sound_status; +} diff --git a/common/mm_source.c b/common/mm_source.c index c4766e9..059e7f4 100644 --- a/common/mm_source.c +++ b/common/mm_source.c @@ -33,22 +33,20 @@ #include "mm_debug.h" #include "mm_error.h" #include "mm_source.h" +#include "mm_sound_common.h" - -bool _is_drm_file( - const char *filePath -) +static bool _is_drm_file(const char *filePath) { - if(!filePath || filePath[0] == '\0') - { + char *p = NULL; + + if(!filePath || filePath[0] == '\0') { debug_error("invalid argument\n"); return false; } - char *p = NULL; - p = (char*) strrchr(filePath, '.'); - if( p && ((strncasecmp(p, ".odf", 4) == 0) || (strncasecmp(p, ".dcf", 4) == 0) || (strncasecmp(p, ".o4a", 4) == 0) || (strncasecmp(p, ".o4v", 4) == 0))) - { + p = (char*) strrchr(filePath, '.'); + if( p && ((strncasecmp(p, ".odf", 4) == 0) || (strncasecmp(p, ".dcf", 4) == 0) || + (strncasecmp(p, ".o4a", 4) == 0) || (strncasecmp(p, ".o4v", 4) == 0))) { return true; } return false; @@ -60,139 +58,117 @@ int mm_source_open_file(const char *filename, MMSourceType *source, int drmsuppo struct stat finfo = {0, }; int fd = -1; void *mmap_buf = NULL; + unsigned int mediaSize,readSize,offSet=0; + char genStr[20]; + int i; - if(filename == NULL) - { + if(filename == NULL) { debug_error("filename is null\n"); return MM_ERROR_SOUND_INVALID_FILE; } - if(drmsupport) - { - if(_is_drm_file(filename)) - { + if(drmsupport) { + if(_is_drm_file(filename)) { debug_error("%s is DRM contents\n", filename); return MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE; } } fd = open(filename, O_RDONLY); - debug_fenter(); - debug_msg("Open file name is %s\n", filename); - unsigned int mediaSize,readSize,offSet=0; - char genStr[20],i; - - if (fd == -1) - { - debug_error("file open fail\n\n"); + if (fd == -1) { + debug_error("file [%s] open fail\n", filename); return MM_ERROR_SOUND_INTERNAL; } - if (fstat(fd, &finfo) == -1) - { - debug_error("file get info fail\n"); + if (fstat(fd, &finfo) == -1) { + debug_error("file [%s] get info fail\n", filename); close(fd); return MM_ERROR_SOUND_INTERNAL; } mediaSize = (unsigned int)finfo.st_size; - - { - /* get the extension (3 characters from last including NULL)*/ - strncpy((void *)genStr,(void *)(filename+(strlen(filename)-2)),3); - - debug_msg("ExtName of the Sound file %s\n",genStr); - - - if(strcasecmp (genStr, "dm") == 0) - { - debug_msg("It is DM file going ahead with special decoding\n"); - - /* Vlidation of the DM file */ - readSize = read(fd,(void*)genStr,0x8); - if(readSize != 0x8) - { - debug_error("Error in Reading the file Header %x/0x8\n",readSize); - return MM_ERROR_SOUND_INTERNAL; - } - genStr[readSize] ='\0'; - - debug_msg("Header details of DM file %s\n",genStr); - - if(strcasecmp (genStr, "--random") != 0) - { - debug_error("It is not a valied DM file"); - return MM_ERROR_SOUND_INTERNAL; - } + /* get the extension (3 characters from last including NULL)*/ + strncpy((void *)genStr,(void *)(filename+(strlen(filename)-2)),3); - /*checking the Media Type */ - readSize = lseek(fd, 0x32, SEEK_SET); - if(readSize != 0x32) - { - debug_error("Error in Seeking the file to offset %x/0x32\n",readSize); - return MM_ERROR_SOUND_INTERNAL; - } - - readSize = read(fd,(void*)genStr,0xf); - - for(i=0;i<0xf;i++) - { - if(genStr[i] == (char)0xD) - { - genStr[i] ='\0'; - break; - } - } - - debug_msg("Header details of DM file %s\n",genStr); - - /*Finding the Media Offset */ - - if(strcasecmp (genStr, "audio/mpeg") == 0) - { - offSet = 0x63; - } - else if(strcasecmp (genStr, "audio/wav") == 0) - { - offSet = 0x62; - } - else - { - debug_error("It is not MP3/Wav DM file \n"); - return MM_ERROR_SOUND_INTERNAL; - } +#if defined(_DEBUG_VERBOS_) + debug_log("Open file [%s] ext[%s]\n", filename, genStr); +#endif + + if(strcasecmp (genStr, "dm") == 0) { + debug_msg("It is DM file going ahead with special decoding\n"); + + /* Vlidation of the DM file */ + readSize = read(fd,(void*)genStr,0x8); + if(readSize != 0x8) { + debug_error("Error in Reading the file Header %x/0x8\n",readSize); + close(fd); + return MM_ERROR_SOUND_INTERNAL; + } + + genStr[readSize] ='\0'; + + debug_msg("Header details of DM file %s\n",genStr); + + if(strcasecmp (genStr, "--random") != 0) { + debug_error("It is not a valied DM file"); + close(fd); + return MM_ERROR_SOUND_INTERNAL; + } + + /*checking the Media Type */ + readSize = lseek(fd, 0x32, SEEK_SET); + if(readSize != 0x32) { + debug_error("Error in Seeking the file to offset %x/0x32\n",readSize); + close(fd); + return MM_ERROR_SOUND_INTERNAL; + } + + readSize = read(fd,(void*)genStr,0xf); - /*Finding the Media Size */ - - mediaSize -= (offSet + 0x28); - - /*Seeking the file to start */ - readSize = lseek(fd, 0x0, SEEK_SET); - - if( readSize != 0x0) - { - debug_error("Error in Seeking the file to offset %x/0x32\n",readSize); - return MM_ERROR_SOUND_INTERNAL; + for(i=0;i<0xf;i++) { + if(genStr[i] == (char)0xD) { + genStr[i] ='\0'; + break; } + } + + debug_msg("Header details of DM file %s\n",genStr); + /*Finding the Media Offset */ + + if(strcasecmp (genStr, "audio/mpeg") == 0) { + offSet = 0x63; + } else if(strcasecmp (genStr, "audio/wav") == 0) { + offSet = 0x62; + } else { + debug_error("It is not MP3/Wav DM file \n"); + close(fd); + return MM_ERROR_SOUND_INTERNAL; } - else - { - debug_msg("It is NON DM file going ahead with normal decoding\n"); + + /*Finding the Media Size */ + mediaSize -= (offSet + 0x28); + + /*Seeking the file to start */ + readSize = lseek(fd, 0x0, SEEK_SET); + + if( readSize != 0x0) { + debug_error("Error in Seeking the file to offset %x/0x32\n",readSize); + close(fd); + return MM_ERROR_SOUND_INTERNAL; } } mmap_buf = mmap(0, finfo.st_size, PROT_READ, MAP_SHARED, fd,0); - - if (mmap_buf == NULL) - { + if (mmap_buf == NULL) { debug_error("MMAP fail\n"); close(fd); return MM_ERROR_SOUND_INTERNAL; } source->ptr = mmap_buf+offSet; source->medOffset = offSet; - debug_msg("source ptr = %p\n", source->ptr); - debug_msg("Med Offset Size : %d",source->medOffset); +#if defined(_DEBUG_VERBOS_) + debug_log("source ptr[%p] med offset size[%d]\n", source->ptr, source->medOffset); +#endif source->tot_size = finfo.st_size; source->cur_size = mediaSize; source->type = MM_SOURCE_FILE; @@ -205,95 +181,92 @@ EXPORT_API int mm_source_open_full_memory(const void *ptr, int totsize, int alloc, MMSourceType *source) { int err = MM_ERROR_NONE; - if (ptr == NULL) - { + if (ptr == NULL) { debug_error("PTR is NULL\n"); return MM_ERROR_INVALID_ARGUMENT; } - if (alloc) - { + + if (alloc) { err = mm_source_open_memory(ptr, totsize, totsize, source); + } else { + source->ptr = (void *)ptr; + source->tot_size = totsize; + source->cur_size = totsize; + source->type = MM_SOURCE_MEMORY_NOTALLOC; + source->fd = -1; } - else - { - source->ptr = ptr; - source->tot_size = totsize; - source->cur_size = totsize; - source->type = MM_SOURCE_MEMORY_NOTALLOC; - source->fd = -1; - } - return err; + return err; } EXPORT_API int mm_source_open_memory(const void *ptr, int totsize, int size, MMSourceType *source) { - source->ptr = (unsigned char*) malloc(totsize); - if (source->ptr == NULL) - { - debug_error("memory alloc fail\n"); - return MM_ERROR_SOUND_NO_FREE_SPACE; - } - source->tot_size = totsize; - source->cur_size = 0; - source->type = MM_SOURCE_MEMORY; - source->fd = -1; - - return mm_source_append_memory(ptr, size, source); + source->ptr = (unsigned char*) malloc(totsize); + if (source->ptr == NULL) { + debug_error("memory alloc fail\n"); + return MM_ERROR_SOUND_NO_FREE_SPACE; + } + source->tot_size = totsize; + source->cur_size = 0; + source->type = MM_SOURCE_MEMORY; + source->fd = -1; + + return mm_source_append_memory(ptr, size, source); } EXPORT_API int mm_source_append_memory(const void *ptr, int size, MMSourceType *source) { - if (source->cur_size + size > source->tot_size) - { - debug_error("memory too large\n"); - return MM_ERROR_SOUND_NO_FREE_SPACE; - } - - memcpy(source->ptr + source->cur_size, ptr, size); - source->cur_size += size; - return MM_ERROR_NONE; + if (source->cur_size + size > source->tot_size) { + debug_error("memory too large\n"); + return MM_ERROR_SOUND_NO_FREE_SPACE; + } + + memcpy(source->ptr + source->cur_size, ptr, size); + source->cur_size += size; + return MM_ERROR_NONE; } EXPORT_API int mm_source_close(MMSourceType *source) { - debug_fenter(); - - ////PREVENT - if(source == NULL) - { - debug_critical("source is null %s\n", __func__); - return MM_ERROR_CLASS; - } - ///// - debug_msg("Source type = %d\n", source->type); - switch(source->type) - { - case MM_SOURCE_FILE: - if(source->ptr != NULL) - { - source->ptr -= source->medOffset; - debug_msg("Med Offset Size : %d/%d",source->medOffset,source->tot_size); - if (munmap(source->ptr, source->tot_size) == -1) { - debug_error("MEM UNMAP fail\n\n"); - } - } - close(source->fd); - break; - case MM_SOURCE_MEMORY: - if(source->ptr != NULL) - free(source->ptr); - break; - case MM_SOURCE_MEMORY_NOTALLOC: - break; - default: - debug_critical("Unknown Source\n"); - break; - } - memset(source, 0, sizeof(MMSourceType)); - return MM_ERROR_NONE; -} + if(source == NULL) { + debug_critical("source is null\n"); + return MM_ERROR_CLASS; + } + +#if defined(_DEBUG_VERBOS_) + debug_log("Source type = %d\n", source->type); +#endif + switch(source->type) + { + case MM_SOURCE_FILE: + if(source->ptr != NULL) { + source->ptr -= source->medOffset; +#if defined(_DEBUG_VERBOS_) + debug_log("Med Offset Size : %d/%d",source->medOffset,source->tot_size); +#endif + if (munmap(source->ptr, source->tot_size) == -1) { + debug_error("MEM UNMAP fail\n\n"); + } + } + close(source->fd); + break; + + case MM_SOURCE_MEMORY: + if(source->ptr != NULL) + free(source->ptr); + break; + case MM_SOURCE_MEMORY_NOTALLOC: + break; + + default: + debug_critical("Unknown Source\n"); + break; + } + memset(source, 0, sizeof(MMSourceType)); + + return MM_ERROR_NONE; +} diff --git a/configure b/configure deleted file mode 100755 index 1fdc3f7..0000000 --- a/configure +++ /dev/null @@ -1,15649 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.67 for avsystem 1.0. -# -# -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software -# Foundation, Inc. -# -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else - case \`(set -o) 2>/dev/null\` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi -" - as_required="as_fn_return () { (exit \$1); } -as_fn_success () { as_fn_return 0; } -as_fn_failure () { as_fn_return 1; } -as_fn_ret_success () { return 0; } -as_fn_ret_failure () { return 1; } - -exitcode=0 -as_fn_success || { exitcode=1; echo as_fn_success failed.; } -as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } -as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } -as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } -if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : - -else - exitcode=1; echo positional parameters were not saved. -fi -test x\$exitcode = x0 || exit 1" - as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO - as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO - eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && - test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 -test \$(( 1 + 1 )) = 2 || exit 1" - if (eval "$as_required") 2>/dev/null; then : - as_have_required=yes -else - as_have_required=no -fi - if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : - -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_found=false -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - as_found=: - case $as_dir in #( - /*) - for as_base in sh bash ksh sh5; do - # Try only shells that exist, to save several forks. - as_shell=$as_dir/$as_base - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : - CONFIG_SHELL=$as_shell as_have_required=yes - if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : - break 2 -fi -fi - done;; - esac - as_found=false -done -$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : - CONFIG_SHELL=$SHELL as_have_required=yes -fi; } -IFS=$as_save_IFS - - - if test "x$CONFIG_SHELL" != x; then : - # We cannot yet assume a decent shell, so we have to provide a - # neutralization value for shells without unset; and this also - # works around shells that cannot unset nonexistent variables. - BASH_ENV=/dev/null - ENV=/dev/null - (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} -fi - - if test x$as_have_required = xno; then : - $as_echo "$0: This script requires a shell more modern than all" - $as_echo "$0: the shells that I found on your system." - if test x${ZSH_VERSION+set} = xset ; then - $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" - $as_echo "$0: be upgraded to zsh 4.3.4 or later." - else - $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, -$0: including any error possibly output before this -$0: message. Then install a modern shell, or manually run -$0: the script under such a shell if you do have one." - fi - exit 1 -fi -fi -fi -SHELL=${CONFIG_SHELL-/bin/sh} -export SHELL -# Unset more variables known to interfere with behavior of common tools. -CLICOLOR_FORCE= GREP_OPTIONS= -unset CLICOLOR_FORCE GREP_OPTIONS - -## --------------------- ## -## M4sh Shell Functions. ## -## --------------------- ## -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - - - as_lineno_1=$LINENO as_lineno_1a=$LINENO - as_lineno_2=$LINENO as_lineno_2a=$LINENO - eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && - test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { - # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -p' - fi -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - - -# Check that we are running under the correct shell. -SHELL=${CONFIG_SHELL-/bin/sh} - -case X$lt_ECHO in -X*--fallback-echo) - # Remove one level of quotation (which was required for Make). - ECHO=`echo "$lt_ECHO" | sed 's,\\\\\$\\$0,'$0','` - ;; -esac - -ECHO=${lt_ECHO-echo} -if test "X$1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X$1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then - # Yippee, $ECHO works! - : -else - # Restart under the correct shell. - exec $SHELL "$0" --no-reexec ${1+"$@"} -fi - -if test "X$1" = X--fallback-echo; then - # used as fallback echo - shift - cat <<_LT_EOF -$* -_LT_EOF - exit 0 -fi - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -if test -z "$lt_ECHO"; then - if test "X${echo_test_string+set}" != Xset; then - # find a string as large as possible, as long as the shell can cope with it - for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do - # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... - if { echo_test_string=`eval $cmd`; } 2>/dev/null && - { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null - then - break - fi - done - fi - - if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - : - else - # The Solaris, AIX, and Digital Unix default echo programs unquote - # backslashes. This makes it impossible to quote backslashes using - # echo "$something" | sed 's/\\/\\\\/g' - # - # So, first we look for a working echo in the user's PATH. - - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for dir in $PATH /usr/ucb; do - IFS="$lt_save_ifs" - if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && - test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - ECHO="$dir/echo" - break - fi - done - IFS="$lt_save_ifs" - - if test "X$ECHO" = Xecho; then - # We didn't find a better echo, so look for alternatives. - if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # This shell has a builtin print -r that does the trick. - ECHO='print -r' - elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && - test "X$CONFIG_SHELL" != X/bin/ksh; then - # If we have ksh, try running configure again with it. - ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} - export ORIGINAL_CONFIG_SHELL - CONFIG_SHELL=/bin/ksh - export CONFIG_SHELL - exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} - else - # Try using printf. - ECHO='printf %s\n' - if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # Cool, printf works - : - elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL - export CONFIG_SHELL - SHELL="$CONFIG_SHELL" - export SHELL - ECHO="$CONFIG_SHELL $0 --fallback-echo" - elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - ECHO="$CONFIG_SHELL $0 --fallback-echo" - else - # maybe with a smaller string... - prev=: - - for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do - if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null - then - break - fi - prev="$cmd" - done - - if test "$prev" != 'sed 50q "$0"'; then - echo_test_string=`eval $prev` - export echo_test_string - exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} - else - # Oops. We lost completely, so just stick with echo. - ECHO=echo - fi - fi - fi - fi - fi -fi - -# Copy echo and quote the copy suitably for passing to libtool from -# the Makefile, instead of quoting the original, which is used later. -lt_ECHO=$ECHO -if test "X$lt_ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then - lt_ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" -fi - - - - -test -n "$DJDIR" || exec 7<&0 &1 - -# Name of the host. -# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_clean_files= -ac_config_libobj_dir=. -LIBOBJS= -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= - -# Identity of this package. -PACKAGE_NAME='avsystem' -PACKAGE_TARNAME='avsystem' -PACKAGE_VERSION='1.0' -PACKAGE_STRING='avsystem 1.0' -PACKAGE_BUGREPORT='' -PACKAGE_URL='' - -ac_header_list= -# Factoring default headers for most tests. -ac_includes_default="\ -#include -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef STDC_HEADERS -# include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# if !defined STDC_HEADERS && defined HAVE_MEMORY_H -# include -# endif -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_INTTYPES_H -# include -#endif -#ifdef HAVE_STDINT_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif" - -ac_subst_vars='am__EXEEXT_FALSE -am__EXEEXT_TRUE -LTLIBOBJS -ALLOCA -USE_PULSE_FALSE -USE_PULSE_TRUE -PULSE_LIBS -PULSE_CFLAGS -HEYNOTI_LIBS -HEYNOTI_CFLAGS -VCONF_LIBS -VCONF_CFLAGS -GLIB2_LIBS -GLIB2_CFLAGS -AUDIOSESSIONMGR_LIBS -AUDIOSESSIONMGR_CFLAGS -MMSESSION_LIBS -MMSESSION_CFLAGS -MMLOG_LIBS -MMLOG_CFLAGS -MMCOMMON_LIBS -MMCOMMON_CFLAGS -AVSYSTEM_LIBS -AVSYSTEM_CFLAGS -PKG_CONFIG_LIBDIR -PKG_CONFIG_PATH -PKG_CONFIG -IS_SDK_FALSE -IS_SDK_TRUE -OTOOL64 -OTOOL -LIPO -NMEDIT -DSYMUTIL -lt_ECHO -RANLIB -AR -OBJDUMP -LN_S -NM -ac_ct_DUMPBIN -DUMPBIN -LD -FGREP -SED -host_os -host_vendor -host_cpu -host -build_os -build_vendor -build_cpu -build -LIBTOOL -LIBOBJS -EGREP -GREP -CPP -am__fastdepCC_FALSE -am__fastdepCC_TRUE -CCDEPMODE -AMDEPBACKSLASH -AMDEP_FALSE -AMDEP_TRUE -am__quote -am__include -DEPDIR -OBJEXT -EXEEXT -ac_ct_CC -CPPFLAGS -LDFLAGS -CFLAGS -CC -am__untar -am__tar -AMTAR -am__leading_dot -SET_MAKE -AWK -mkdir_p -MKDIR_P -INSTALL_STRIP_PROGRAM -STRIP -install_sh -MAKEINFO -AUTOHEADER -AUTOMAKE -AUTOCONF -ACLOCAL -VERSION -PACKAGE -CYGPATH_W -am__isrc -INSTALL_DATA -INSTALL_SCRIPT -INSTALL_PROGRAM -target_alias -host_alias -build_alias -LIBS -ECHO_T -ECHO_N -ECHO_C -DEFS -mandir -localedir -libdir -psdir -pdfdir -dvidir -htmldir -infodir -docdir -oldincludedir -includedir -localstatedir -sharedstatedir -sysconfdir -datadir -datarootdir -libexecdir -sbindir -bindir -program_transform_name -prefix -exec_prefix -PACKAGE_URL -PACKAGE_BUGREPORT -PACKAGE_STRING -PACKAGE_VERSION -PACKAGE_TARNAME -PACKAGE_NAME -PATH_SEPARATOR -SHELL' -ac_subst_files='' -ac_user_opts=' -enable_option_checking -enable_dependency_tracking -enable_shared -enable_static -with_pic -enable_fast_install -with_gnu_ld -enable_libtool_lock -enable_sdk -enable_pulse -' - ac_precious_vars='build_alias -host_alias -target_alias -CC -CFLAGS -LDFLAGS -LIBS -CPPFLAGS -CPP -PKG_CONFIG -PKG_CONFIG_PATH -PKG_CONFIG_LIBDIR -AVSYSTEM_CFLAGS -AVSYSTEM_LIBS -MMCOMMON_CFLAGS -MMCOMMON_LIBS -MMLOG_CFLAGS -MMLOG_LIBS -MMSESSION_CFLAGS -MMSESSION_LIBS -AUDIOSESSIONMGR_CFLAGS -AUDIOSESSIONMGR_LIBS -GLIB2_CFLAGS -GLIB2_LIBS -VCONF_CFLAGS -VCONF_LIBS -HEYNOTI_CFLAGS -HEYNOTI_LIBS -PULSE_CFLAGS -PULSE_LIBS' - - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -ac_unrecognized_opts= -ac_unrecognized_sep= -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -# (The list follows the same order as the GNU Coding Standards.) -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datarootdir='${prefix}/share' -datadir='${datarootdir}' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -includedir='${prefix}/include' -oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' -infodir='${datarootdir}/info' -htmldir='${docdir}' -dvidir='${docdir}' -pdfdir='${docdir}' -psdir='${docdir}' -libdir='${exec_prefix}/lib' -localedir='${datarootdir}/locale' -mandir='${datarootdir}/man' - -ac_prev= -ac_dashdash= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval $ac_prev=\$ac_option - ac_prev= - continue - fi - - case $ac_option in - *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *=) ac_optarg= ;; - *) ac_optarg=yes ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_dashdash$ac_option in - --) - ac_dashdash=yes ;; - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=*) - datadir=$ac_optarg ;; - - -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ - | --dataroo | --dataro | --datar) - ac_prev=datarootdir ;; - -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ - | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) - datarootdir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=no ;; - - -docdir | --docdir | --docdi | --doc | --do) - ac_prev=docdir ;; - -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) - docdir=$ac_optarg ;; - - -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) - ac_prev=dvidir ;; - -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) - dvidir=$ac_optarg ;; - - -enable-* | --enable-*) - ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=\$ac_optarg ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) - ac_prev=htmldir ;; - -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ - | --ht=*) - htmldir=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localedir | --localedir | --localedi | --localed | --locale) - ac_prev=localedir ;; - -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) - localedir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst | --locals) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) - ac_prev=pdfdir ;; - -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) - pdfdir=$ac_optarg ;; - - -psdir | --psdir | --psdi | --psd | --ps) - ac_prev=psdir ;; - -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) - psdir=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=\$ac_optarg ;; - - -without-* | --without-*) - ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=no ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) as_fn_error $? "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information" - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - case $ac_envvar in #( - '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; - esac - eval $ac_envvar=\$ac_optarg - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error $? "missing argument to $ac_option" -fi - -if test -n "$ac_unrecognized_opts"; then - case $enable_option_checking in - no) ;; - fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; - *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; - esac -fi - -# Check all directory arguments for consistency. -for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir -do - eval ac_val=\$$ac_var - # Remove trailing slashes. - case $ac_val in - */ ) - ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` - eval $ac_var=\$ac_val;; - esac - # Be sure to have absolute directory names. - case $ac_val in - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; - esac - as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used" >&2 - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -ac_pwd=`pwd` && test -n "$ac_pwd" && -ac_ls_di=`ls -di .` && -ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error $? "working directory cannot be determined" -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error $? "pwd does not report name of working directory" - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$as_myself" || -$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_myself" : 'X\(//\)[^/]' \| \ - X"$as_myself" : 'X\(//\)$' \| \ - X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_myself" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r "$srcdir/$ac_unique_file"; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" -fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" - pwd)` -# When building in place, set srcdir=. -if test "$ac_abs_confdir" = "$ac_pwd"; then - srcdir=. -fi -# Remove unnecessary trailing slashes from srcdir. -# Double slashes in file names in object file debugging info -# mess up M-x gdb in Emacs. -case $srcdir in -*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; -esac -for ac_var in $ac_precious_vars; do - eval ac_env_${ac_var}_set=\${${ac_var}+set} - eval ac_env_${ac_var}_value=\$${ac_var} - eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} - eval ac_cv_env_${ac_var}_value=\$${ac_var} -done - -# -# Report the --help message. -# -if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF -\`configure' configures avsystem 1.0 to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking ...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/avsystem] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] -_ACEOF - - cat <<\_ACEOF - -Program names: - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM run sed PROGRAM on installed program names - -System types: - --build=BUILD configure for building on BUILD [guessed] - --host=HOST cross-compile to build programs to run on HOST [BUILD] -_ACEOF -fi - -if test -n "$ac_init_help"; then - case $ac_init_help in - short | recursive ) echo "Configuration of avsystem 1.0:";; - esac - cat <<\_ACEOF - -Optional Features: - --disable-option-checking ignore unrecognized --enable/--with options - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --disable-dependency-tracking speeds up one-time build - --enable-dependency-tracking do not reject slow dependency extractors - --enable-shared[=PKGS] build shared libraries [default=yes] - --enable-static[=PKGS] build static libraries [default=yes] - --enable-fast-install[=PKGS] - optimize for fast installation [default=yes] - --disable-libtool-lock avoid locking (might break parallel builds) - --enable-sdk sdk build - --enable-pulse enable pulseaudio client - -Optional Packages: - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-pic try to use only PIC/non-PIC objects [default=use - both] - --with-gnu-ld assume the C compiler uses GNU ld [default=no] - -Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if - you have headers in a nonstandard directory - CPP C preprocessor - PKG_CONFIG path to pkg-config utility - PKG_CONFIG_PATH - directories to add to pkg-config's search path - PKG_CONFIG_LIBDIR - path overriding pkg-config's built-in search path - AVSYSTEM_CFLAGS - C compiler flags for AVSYSTEM, overriding pkg-config - AVSYSTEM_LIBS - linker flags for AVSYSTEM, overriding pkg-config - MMCOMMON_CFLAGS - C compiler flags for MMCOMMON, overriding pkg-config - MMCOMMON_LIBS - linker flags for MMCOMMON, overriding pkg-config - MMLOG_CFLAGS - C compiler flags for MMLOG, overriding pkg-config - MMLOG_LIBS linker flags for MMLOG, overriding pkg-config - MMSESSION_CFLAGS - C compiler flags for MMSESSION, overriding pkg-config - MMSESSION_LIBS - linker flags for MMSESSION, overriding pkg-config - AUDIOSESSIONMGR_CFLAGS - C compiler flags for AUDIOSESSIONMGR, overriding pkg-config - AUDIOSESSIONMGR_LIBS - linker flags for AUDIOSESSIONMGR, overriding pkg-config - GLIB2_CFLAGS - C compiler flags for GLIB2, overriding pkg-config - GLIB2_LIBS linker flags for GLIB2, overriding pkg-config - VCONF_CFLAGS - C compiler flags for VCONF, overriding pkg-config - VCONF_LIBS linker flags for VCONF, overriding pkg-config - HEYNOTI_CFLAGS - C compiler flags for HEYNOTI, overriding pkg-config - HEYNOTI_LIBS - linker flags for HEYNOTI, overriding pkg-config - PULSE_CFLAGS - C compiler flags for PULSE, overriding pkg-config - PULSE_LIBS linker flags for PULSE, overriding pkg-config - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -Report bugs to the package provider. -_ACEOF -ac_status=$? -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || - { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || - continue - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - cd "$ac_dir" || { ac_status=$?; continue; } - # Check for guested configure. - if test -f "$ac_srcdir/configure.gnu"; then - echo && - $SHELL "$ac_srcdir/configure.gnu" --help=recursive - elif test -f "$ac_srcdir/configure"; then - echo && - $SHELL "$ac_srcdir/configure" --help=recursive - else - $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi || ac_status=$? - cd "$ac_pwd" || { ac_status=$?; break; } - done -fi - -test -n "$ac_init_help" && exit $ac_status -if $ac_init_version; then - cat <<\_ACEOF -avsystem configure 1.0 -generated by GNU Autoconf 2.67 - -Copyright (C) 2010 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit -fi - -## ------------------------ ## -## Autoconf initialization. ## -## ------------------------ ## - -# ac_fn_c_try_compile LINENO -# -------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - as_fn_set_status $ac_retval - -} # ac_fn_c_try_compile - -# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists and can be compiled using the include files in -# INCLUDES, setting the cache variable VAR accordingly. -ac_fn_c_check_header_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_header_compile - -# ac_fn_c_try_cpp LINENO -# ---------------------- -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp - -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - -# ac_fn_c_try_link LINENO -# ----------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - as_fn_set_status $ac_retval - -} # ac_fn_c_try_link - -# ac_fn_c_check_func LINENO FUNC VAR -# ---------------------------------- -# Tests whether FUNC exists, setting the cache variable VAR accordingly -ac_fn_c_check_func () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Define $2 to an innocuous variant, in case declares $2. - For example, HP-UX 11i declares gettimeofday. */ -#define $2 innocuous_$2 - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $2 - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $2 (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$2 || defined __stub___$2 -choke me -#endif - -int -main () -{ -return $2 (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_func - -# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists, giving a warning if it cannot be compiled using -# the include files in INCLUDES and setting the cache variable VAR -# accordingly. -ac_fn_c_check_header_mongrel () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if eval "test \"\${$3+set}\"" = set; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : - $as_echo_n "(cached) " >&6 -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 -$as_echo_n "checking $2 usability... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_header_compiler=yes -else - ac_header_compiler=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 -$as_echo_n "checking $2 presence... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <$2> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - ac_header_preproc=yes -else - ac_header_preproc=no -fi -rm -f conftest.err conftest.i conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( - yes:no: ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; - no:yes:* ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=\$ac_header_compiler" -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_header_mongrel - -# ac_fn_c_check_type LINENO TYPE VAR INCLUDES -# ------------------------------------------- -# Tests whether TYPE exists after having included INCLUDES, setting cache -# variable VAR accordingly. -ac_fn_c_check_type () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=no" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof ($2)) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof (($2))) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - eval "$3=yes" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_type -cat >config.log <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by avsystem $as_me 1.0, which was -generated by GNU Autoconf 2.67. Invocation command line was - - $ $0 $@ - -_ACEOF -exec 5>>config.log -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" - done -IFS=$as_save_IFS - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *\'*) - ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; - 2) - as_fn_append ac_configure_args1 " '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - as_fn_append ac_configure_args " '$ac_arg'" - ;; - esac - done -done -{ ac_configure_args0=; unset ac_configure_args0;} -{ ac_configure_args1=; unset ac_configure_args1;} - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - $as_echo "## ---------------- ## -## Cache variables. ## -## ---------------- ##" - echo - # The following way of writing the cache mishandles newlines in values, -( - for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - (set) 2>&1 | - case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - sed -n \ - "s/'\''/'\''\\\\'\'''\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" - ;; #( - *) - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) - echo - - $as_echo "## ----------------- ## -## Output variables. ## -## ----------------- ##" - echo - for ac_var in $ac_subst_vars - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - - if test -n "$ac_subst_files"; then - $as_echo "## ------------------- ## -## File substitutions. ## -## ------------------- ##" - echo - for ac_var in $ac_subst_files - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - fi - - if test -s confdefs.h; then - $as_echo "## ----------- ## -## confdefs.h. ## -## ----------- ##" - echo - cat confdefs.h - echo - fi - test "$ac_signal" != 0 && - $as_echo "$as_me: caught signal $ac_signal" - $as_echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core core.conftest.* && - rm -f -r conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status -' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -f -r conftest* confdefs.h - -$as_echo "/* confdefs.h */" > confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_URL "$PACKAGE_URL" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer an explicitly selected file to automatically selected ones. -ac_site_file1=NONE -ac_site_file2=NONE -if test -n "$CONFIG_SITE"; then - # We do not want a PATH search for config.site. - case $CONFIG_SITE in #(( - -*) ac_site_file1=./$CONFIG_SITE;; - */*) ac_site_file1=$CONFIG_SITE;; - *) ac_site_file1=./$CONFIG_SITE;; - esac -elif test "x$prefix" != xNONE; then - ac_site_file1=$prefix/share/config.site - ac_site_file2=$prefix/etc/config.site -else - ac_site_file1=$ac_default_prefix/share/config.site - ac_site_file2=$ac_default_prefix/etc/config.site -fi -for ac_site_file in "$ac_site_file1" "$ac_site_file2" -do - test "x$ac_site_file" = xNONE && continue - if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 -$as_echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" \ - || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5 ; } - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special files - # actually), so we avoid doing that. DJGPP emulates it as a regular file. - if test /dev/null != "$cache_file" && test -f "$cache_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 -$as_echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . "$cache_file";; - *) . "./$cache_file";; - esac - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 -$as_echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -as_fn_append ac_header_list " stdlib.h" -as_fn_append ac_header_list " unistd.h" -as_fn_append ac_header_list " sys/param.h" -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value - case $ac_old_set,$ac_new_set in - set,) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - # differences in whitespace do not lead to failure. - ac_old_val_w=`echo x $ac_old_val` - ac_new_val_w=`echo x $ac_new_val` - if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 -$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - ac_cache_corrupted=: - else - { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 -$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} - eval $ac_var=\$ac_old_val - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 -$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 -$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) as_fn_append ac_configure_args " '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 -$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 -fi -## -------------------- ## -## Main body of script. ## -## -------------------- ## - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -am__api_version='1.11' - -ac_aux_dir= -for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do - if test -f "$ac_dir/install-sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f "$ac_dir/install.sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f "$ac_dir/shtool"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi -done -if test -z "$ac_aux_dir"; then - as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 -fi - -# These three variables are undocumented and unsupported, -# and are intended to be withdrawn in a future Autoconf release. -# They can cause serious problems if a builder's source tree is in a directory -# whose full name contains unusual characters. -ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. -ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. -ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AmigaOS /C/install, which installs bootblocks on floppy discs -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# OS/2's system install, which has a completely different semantic -# ./install, which can be erroneously created by make from ./install.sh. -# Reject install programs that cannot install multiple files. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 -$as_echo_n "checking for a BSD-compatible install... " >&6; } -if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in #(( - ./ | .// | /[cC]/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - rm -rf conftest.one conftest.two conftest.dir - echo one > conftest.one - echo two > conftest.two - mkdir conftest.dir - if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && - test -s conftest.one && test -s conftest.two && - test -s conftest.dir/conftest.one && - test -s conftest.dir/conftest.two - then - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi - fi - done - done - ;; -esac - - done -IFS=$as_save_IFS - -rm -rf conftest.one conftest.two conftest.dir - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. Don't cache a - # value for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - INSTALL=$ac_install_sh - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 -$as_echo "$INSTALL" >&6; } - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 -$as_echo_n "checking whether build environment is sane... " >&6; } -# Just in case -sleep 1 -echo timestamp > conftest.file -# Reject unsafe characters in $srcdir or the absolute working directory -# name. Accept space and tab only in the latter. -am_lf=' -' -case `pwd` in - *[\\\"\#\$\&\'\`$am_lf]*) - as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5 ;; -esac -case $srcdir in - *[\\\"\#\$\&\'\`$am_lf\ \ ]*) - as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5 ;; -esac - -# Do `set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$*" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - rm -f conftest.file - if test "$*" != "X $srcdir/configure conftest.file" \ - && test "$*" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - as_fn_error $? "ls -t appears to fail. Make sure there is not a broken -alias in your environment" "$LINENO" 5 - fi - - test "$2" = conftest.file - ) -then - # Ok. - : -else - as_fn_error $? "newly created file is older than distributed files! -Check your system clock" "$LINENO" 5 -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -test "$program_prefix" != NONE && - program_transform_name="s&^&$program_prefix&;$program_transform_name" -# Use a double $ so make ignores it. -test "$program_suffix" != NONE && - program_transform_name="s&\$&$program_suffix&;$program_transform_name" -# Double any \ or $. -# By default was `s,x,x', remove it if useless. -ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' -program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` - -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` - -if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac -fi -# Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " -else - am_missing_run= - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 -$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} -fi - -if test x"${install_sh}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; - *) - install_sh="\${SHELL} $am_aux_dir/install-sh" - esac -fi - -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. -if test "$cross_compiling" != no; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. -set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_STRIP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -STRIP=$ac_cv_prog_STRIP -if test -n "$STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 -$as_echo "$STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_STRIP"; then - ac_ct_STRIP=$STRIP - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_STRIP"; then - ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_STRIP="strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP -if test -n "$ac_ct_STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 -$as_echo "$ac_ct_STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_STRIP" = x; then - STRIP=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - STRIP=$ac_ct_STRIP - fi -else - STRIP="$ac_cv_prog_STRIP" -fi - -fi -INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 -$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } -if test -z "$MKDIR_P"; then - if test "${ac_cv_path_mkdir+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in mkdir gmkdir; do - for ac_exec_ext in '' $ac_executable_extensions; do - { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue - case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( - 'mkdir (GNU coreutils) '* | \ - 'mkdir (coreutils) '* | \ - 'mkdir (fileutils) '4.1*) - ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext - break 3;; - esac - done - done - done -IFS=$as_save_IFS - -fi - - test -d ./--version && rmdir ./--version - if test "${ac_cv_path_mkdir+set}" = set; then - MKDIR_P="$ac_cv_path_mkdir -p" - else - # As a last resort, use the slow shell script. Don't cache a - # value for MKDIR_P within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - MKDIR_P="$ac_install_sh -d" - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 -$as_echo "$MKDIR_P" >&6; } - -mkdir_p="$MKDIR_P" -case $mkdir_p in - [\\/$]* | ?:[\\/]*) ;; - */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; -esac - -for ac_prog in gawk mawk nawk awk -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AWK+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AWK"; then - ac_cv_prog_AWK="$AWK" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_AWK="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AWK=$ac_cv_prog_AWK -if test -n "$AWK"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 -$as_echo "$AWK" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$AWK" && break -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } -set x ${MAKE-make} -ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then : - $as_echo_n "(cached) " >&6 -else - cat >conftest.make <<\_ACEOF -SHELL = /bin/sh -all: - @echo '@@@%%%=$(MAKE)=@@@%%%' -_ACEOF -# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. -case `${MAKE-make} -f conftest.make 2>/dev/null` in - *@@@%%%=?*=@@@%%%*) - eval ac_cv_prog_make_${ac_make}_set=yes;; - *) - eval ac_cv_prog_make_${ac_make}_set=no;; -esac -rm -f conftest.make -fi -if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - SET_MAKE= -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - SET_MAKE="MAKE=${MAKE-make}" -fi - -rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null - -if test "`cd $srcdir && pwd`" != "`pwd`"; then - # Use -I$(srcdir) only when $(srcdir) != ., so that make's output - # is not polluted with repeated "-I." - am__isrc=' -I$(srcdir)' - # test to see if srcdir already configured - if test -f $srcdir/config.status; then - as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 - fi -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi - - -# Define the identity of the package. - PACKAGE='avsystem' - VERSION='1.0' - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE "$PACKAGE" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define VERSION "$VERSION" -_ACEOF - -# Some tools Automake needs. - -ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} - - -AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} - - -AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} - - -AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} - - -MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} - -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. -# Always define AMTAR for backward compatibility. - -AMTAR=${AMTAR-"${am_missing_run}tar"} - -am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' - - - - - -ac_config_headers="$ac_config_headers config.h:config.hin" - - - - -# Checks for programs. -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5 ; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` - -# The possible output files: -ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" - -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { { ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. - break;; - * ) - break;; - esac -done -test "$ac_cv_exeext" = no && ac_cv_exeext= - -else - ac_file='' -fi -if test -z "$ac_file"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5 ; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -ac_exeext=$ac_cv_exeext - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 -$as_echo_n "checking for suffix of executables... " >&6; } -if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - break;; - * ) break;; - esac -done -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5 ; } -fi -rm -f conftest conftest$ac_cv_exeext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -ac_clean_files="$ac_clean_files conftest.out" -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -if test "$cross_compiling" != yes; then - { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if { ac_try='./conftest$ac_cv_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5 ; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5 ; } -fi -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -DEPDIR="${am__leading_dot}deps" - -ac_config_commands="$ac_config_commands depfiles" - - -am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo this is the am__doit target -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 -$as_echo_n "checking for style of include used by $am_make... " >&6; } -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from `make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD - ;; - esac -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 -$as_echo "$_am_result" >&6; } -rm -f confinc confmf - -# Check whether --enable-dependency-tracking was given. -if test "${enable_dependency_tracking+set}" = set; then : - enableval=$enable_dependency_tracking; -fi - -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' -fi - if test "x$enable_dependency_tracking" != xno; then - AMDEP_TRUE= - AMDEP_FALSE='#' -else - AMDEP_TRUE='#' - AMDEP_FALSE= -fi - - - -depcc="$CC" am_compiler_list= - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 -$as_echo_n "checking dependency style of $depcc... " >&6; } -if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_CC_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - am__universal=false - case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with `-c' and `-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvisualcpp | msvcmsys) - # This compiler won't grok `-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_CC_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_CC_dependencies_compiler_type=none -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 -$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } -CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type - - if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then - am__fastdepCC_TRUE= - am__fastdepCC_FALSE='#' -else - am__fastdepCC_TRUE='#' - am__fastdepCC_FALSE= -fi - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 -$as_echo_n "checking for an ANSI C-conforming const... " >&6; } -if test "${ac_cv_c_const+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -/* FIXME: Include the comments suggested by Paul. */ -#ifndef __cplusplus - /* Ultrix mips cc rejects this. */ - typedef int charset[2]; - const charset cs; - /* SunOS 4.1.1 cc rejects this. */ - char const *const *pcpcc; - char **ppc; - /* NEC SVR4.0.2 mips cc rejects this. */ - struct point {int x, y;}; - static struct point const zero = {0,0}; - /* AIX XL C 1.02.0.0 rejects this. - It does not let you subtract one const X* pointer from another in - an arm of an if-expression whose if-part is not a constant - expression */ - const char *g = "string"; - pcpcc = &g + (g ? g-g : 0); - /* HPUX 7.0 cc rejects these. */ - ++pcpcc; - ppc = (char**) pcpcc; - pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this. */ - char *t; - char const *s = 0 ? (char *) 0 : (char const *) 0; - - *t++ = 0; - if (s) return 0; - } - { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ - int x[] = {25, 17}; - const int *foo = &x[0]; - ++foo; - } - { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ - typedef const int *iptr; - iptr p = 0; - ++p; - } - { /* AIX XL C 1.02.0.0 rejects this saying - "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; }; - struct s *b; b->j = 5; - } - { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ - const int foo = 10; - if (!foo) return 0; - } - return !cs[0] && !zero.x; -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_const=yes -else - ac_cv_c_const=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 -$as_echo "$ac_cv_c_const" >&6; } -if test $ac_cv_c_const = no; then - -$as_echo "#define const /**/" >>confdefs.h - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5 ; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - - - - - for ac_header in $ac_header_list -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - - - - - - - -for ac_func in getpagesize -do : - ac_fn_c_check_func "$LINENO" "getpagesize" "ac_cv_func_getpagesize" -if test "x$ac_cv_func_getpagesize" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_GETPAGESIZE 1 -_ACEOF - -fi -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mmap" >&5 -$as_echo_n "checking for working mmap... " >&6; } -if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_mmap_fixed_mapped=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -/* malloc might have been renamed as rpl_malloc. */ -#undef malloc - -/* Thanks to Mike Haertel and Jim Avera for this test. - Here is a matrix of mmap possibilities: - mmap private not fixed - mmap private fixed at somewhere currently unmapped - mmap private fixed at somewhere already mapped - mmap shared not fixed - mmap shared fixed at somewhere currently unmapped - mmap shared fixed at somewhere already mapped - For private mappings, we should verify that changes cannot be read() - back from the file, nor mmap's back from the file at a different - address. (There have been systems where private was not correctly - implemented like the infamous i386 svr4.0, and systems where the - VM page cache was not coherent with the file system buffer cache - like early versions of FreeBSD and possibly contemporary NetBSD.) - For shared mappings, we should conversely verify that changes get - propagated back to all the places they're supposed to be. - - Grep wants private fixed already mapped. - The main things grep needs to know about mmap are: - * does it exist and is it safe to write into the mmap'd area - * how to use it (BSD variants) */ - -#include -#include - -#if !defined STDC_HEADERS && !defined HAVE_STDLIB_H -char *malloc (); -#endif - -/* This mess was copied from the GNU getpagesize.h. */ -#ifndef HAVE_GETPAGESIZE -# ifdef _SC_PAGESIZE -# define getpagesize() sysconf(_SC_PAGESIZE) -# else /* no _SC_PAGESIZE */ -# ifdef HAVE_SYS_PARAM_H -# include -# ifdef EXEC_PAGESIZE -# define getpagesize() EXEC_PAGESIZE -# else /* no EXEC_PAGESIZE */ -# ifdef NBPG -# define getpagesize() NBPG * CLSIZE -# ifndef CLSIZE -# define CLSIZE 1 -# endif /* no CLSIZE */ -# else /* no NBPG */ -# ifdef NBPC -# define getpagesize() NBPC -# else /* no NBPC */ -# ifdef PAGESIZE -# define getpagesize() PAGESIZE -# endif /* PAGESIZE */ -# endif /* no NBPC */ -# endif /* no NBPG */ -# endif /* no EXEC_PAGESIZE */ -# else /* no HAVE_SYS_PARAM_H */ -# define getpagesize() 8192 /* punt totally */ -# endif /* no HAVE_SYS_PARAM_H */ -# endif /* no _SC_PAGESIZE */ - -#endif /* no HAVE_GETPAGESIZE */ - -int -main () -{ - char *data, *data2, *data3; - const char *cdata2; - int i, pagesize; - int fd, fd2; - - pagesize = getpagesize (); - - /* First, make a file with some known garbage in it. */ - data = (char *) malloc (pagesize); - if (!data) - return 1; - for (i = 0; i < pagesize; ++i) - *(data + i) = rand (); - umask (0); - fd = creat ("conftest.mmap", 0600); - if (fd < 0) - return 2; - if (write (fd, data, pagesize) != pagesize) - return 3; - close (fd); - - /* Next, check that the tail of a page is zero-filled. File must have - non-zero length, otherwise we risk SIGBUS for entire page. */ - fd2 = open ("conftest.txt", O_RDWR | O_CREAT | O_TRUNC, 0600); - if (fd2 < 0) - return 4; - cdata2 = ""; - if (write (fd2, cdata2, 1) != 1) - return 5; - data2 = (char *) mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L); - if (data2 == MAP_FAILED) - return 6; - for (i = 0; i < pagesize; ++i) - if (*(data2 + i)) - return 7; - close (fd2); - if (munmap (data2, pagesize)) - return 8; - - /* Next, try to mmap the file at a fixed address which already has - something else allocated at it. If we can, also make sure that - we see the same garbage. */ - fd = open ("conftest.mmap", O_RDWR); - if (fd < 0) - return 9; - if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_FIXED, fd, 0L)) - return 10; - for (i = 0; i < pagesize; ++i) - if (*(data + i) != *(data2 + i)) - return 11; - - /* Finally, make sure that changes to the mapped area do not - percolate back to the file as seen by read(). (This is a bug on - some variants of i386 svr4.0.) */ - for (i = 0; i < pagesize; ++i) - *(data2 + i) = *(data2 + i) + 1; - data3 = (char *) malloc (pagesize); - if (!data3) - return 12; - if (read (fd, data3, pagesize) != pagesize) - return 13; - for (i = 0; i < pagesize; ++i) - if (*(data + i) != *(data3 + i)) - return 14; - close (fd); - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_mmap_fixed_mapped=yes -else - ac_cv_func_mmap_fixed_mapped=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mmap_fixed_mapped" >&5 -$as_echo "$ac_cv_func_mmap_fixed_mapped" >&6; } -if test $ac_cv_func_mmap_fixed_mapped = yes; then - -$as_echo "#define HAVE_MMAP 1" >>confdefs.h - -fi -rm -f conftest.mmap conftest.txt - -for ac_header in stdlib.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" -if test "x$ac_cv_header_stdlib_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STDLIB_H 1 -_ACEOF - -fi - -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible realloc" >&5 -$as_echo_n "checking for GNU libc compatible realloc... " >&6; } -if test "${ac_cv_func_realloc_0_nonnull+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_realloc_0_nonnull=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#if defined STDC_HEADERS || defined HAVE_STDLIB_H -# include -#else -char *realloc (); -#endif - -int -main () -{ -return ! realloc (0, 0); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_realloc_0_nonnull=yes -else - ac_cv_func_realloc_0_nonnull=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_realloc_0_nonnull" >&5 -$as_echo "$ac_cv_func_realloc_0_nonnull" >&6; } -if test $ac_cv_func_realloc_0_nonnull = yes; then : - -$as_echo "#define HAVE_REALLOC 1" >>confdefs.h - -else - $as_echo "#define HAVE_REALLOC 0" >>confdefs.h - - case " $LIBOBJS " in - *" realloc.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS realloc.$ac_objext" - ;; -esac - - -$as_echo "#define realloc rpl_realloc" >>confdefs.h - -fi - - -for ac_header in sys/select.h sys/socket.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking types of arguments for select" >&5 -$as_echo_n "checking types of arguments for select... " >&6; } -if test "${ac_cv_func_select_args+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - for ac_arg234 in 'fd_set *' 'int *' 'void *'; do - for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do - for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -#ifdef HAVE_SYS_SELECT_H -# include -#endif -#ifdef HAVE_SYS_SOCKET_H -# include -#endif - -int -main () -{ -extern int select ($ac_arg1, - $ac_arg234, $ac_arg234, $ac_arg234, - $ac_arg5); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3 -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done - done -done -# Provide a safe default value. -: ${ac_cv_func_select_args='int,int *,struct timeval *'} - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_select_args" >&5 -$as_echo "$ac_cv_func_select_args" >&6; } -ac_save_IFS=$IFS; IFS=',' -set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'` -IFS=$ac_save_IFS -shift - -cat >>confdefs.h <<_ACEOF -#define SELECT_TYPE_ARG1 $1 -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define SELECT_TYPE_ARG234 ($2) -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define SELECT_TYPE_ARG5 ($3) -_ACEOF - -rm -f conftest* - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether lstat correctly handles trailing slash" >&5 -$as_echo_n "checking whether lstat correctly handles trailing slash... " >&6; } -if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - rm -f conftest.sym conftest.file -echo >conftest.file -if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then - if test "$cross_compiling" = yes; then : - ac_cv_func_lstat_dereferences_slashed_symlink=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -struct stat sbuf; - /* Linux will dereference the symlink and fail, as required by POSIX. - That is better in the sense that it means we will not - have to compile and use the lstat wrapper. */ - return lstat ("conftest.sym/", &sbuf) == 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_lstat_dereferences_slashed_symlink=yes -else - ac_cv_func_lstat_dereferences_slashed_symlink=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -else - # If the `ln -s' command failed, then we probably don't even - # have an lstat function. - ac_cv_func_lstat_dereferences_slashed_symlink=no -fi -rm -f conftest.sym conftest.file - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_lstat_dereferences_slashed_symlink" >&5 -$as_echo "$ac_cv_func_lstat_dereferences_slashed_symlink" >&6; } - -test $ac_cv_func_lstat_dereferences_slashed_symlink = yes && - -cat >>confdefs.h <<_ACEOF -#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 -_ACEOF - - -if test "x$ac_cv_func_lstat_dereferences_slashed_symlink" = xno; then - case " $LIBOBJS " in - *" lstat.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS lstat.$ac_objext" - ;; -esac - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat accepts an empty string" >&5 -$as_echo_n "checking whether stat accepts an empty string... " >&6; } -if test "${ac_cv_func_stat_empty_string_bug+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_stat_empty_string_bug=yes -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -struct stat sbuf; - return stat ("", &sbuf) == 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_stat_empty_string_bug=no -else - ac_cv_func_stat_empty_string_bug=yes -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_stat_empty_string_bug" >&5 -$as_echo "$ac_cv_func_stat_empty_string_bug" >&6; } -if test $ac_cv_func_stat_empty_string_bug = yes; then - case " $LIBOBJS " in - *" stat.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS stat.$ac_objext" - ;; -esac - - -cat >>confdefs.h <<_ACEOF -#define HAVE_STAT_EMPTY_STRING_BUG 1 -_ACEOF - -fi - -for ac_func in vprintf -do : - ac_fn_c_check_func "$LINENO" "vprintf" "ac_cv_func_vprintf" -if test "x$ac_cv_func_vprintf" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_VPRINTF 1 -_ACEOF - -ac_fn_c_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt" -if test "x$ac_cv_func__doprnt" = x""yes; then : - -$as_echo "#define HAVE_DOPRNT 1" >>confdefs.h - -fi - -fi -done - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 -$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } -if test "${ac_cv_header_stdbool_h+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifndef bool - "error: bool is not defined" -#endif -#ifndef false - "error: false is not defined" -#endif -#if false - "error: false is not 0" -#endif -#ifndef true - "error: true is not defined" -#endif -#if true != 1 - "error: true is not 1" -#endif -#ifndef __bool_true_false_are_defined - "error: __bool_true_false_are_defined is not defined" -#endif - - struct s { _Bool s: 1; _Bool t; } s; - - char a[true == 1 ? 1 : -1]; - char b[false == 0 ? 1 : -1]; - char c[__bool_true_false_are_defined == 1 ? 1 : -1]; - char d[(bool) 0.5 == true ? 1 : -1]; - bool e = &s; - char f[(_Bool) 0.0 == false ? 1 : -1]; - char g[true]; - char h[sizeof (_Bool)]; - char i[sizeof s.t]; - enum { j = false, k = true, l = false * true, m = true * 256 }; - /* The following fails for - HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ - _Bool n[m]; - char o[sizeof n == m * sizeof n[0] ? 1 : -1]; - char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; -# if defined __xlc__ || defined __GNUC__ - /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 - reported by James Lemley on 2005-10-05; see - http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html - This test is not quite right, since xlc is allowed to - reject this program, as the initializer for xlcbug is - not one of the forms that C requires support for. - However, doing the test right would require a runtime - test, and that would make cross-compilation harder. - Let us hope that IBM fixes the xlc bug, and also adds - support for this kind of constant expression. In the - meantime, this test will reject xlc, which is OK, since - our stdbool.h substitute should suffice. We also test - this with GCC, where it should work, to detect more - quickly whether someone messes up the test in the - future. */ - char digs[] = "0123456789"; - int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); -# endif - /* Catch a bug in an HP-UX C compiler. See - http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html - */ - _Bool q = true; - _Bool *pq = &q; - -int -main () -{ - - *pq |= q; - *pq |= ! q; - /* Refer to every declared value, to avoid compiler optimizations. */ - return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l - + !m + !n + !o + !p + !q + !pq); - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdbool_h=yes -else - ac_cv_header_stdbool_h=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 -$as_echo "$ac_cv_header_stdbool_h" >&6; } -ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" -if test "x$ac_cv_type__Bool" = x""yes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE__BOOL 1 -_ACEOF - - -fi - -if test $ac_cv_header_stdbool_h = yes; then - -$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 -$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } -if test "${ac_cv_header_time+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include - -int -main () -{ -if ((struct tm *) 0) -return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_time=yes -else - ac_cv_header_time=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 -$as_echo "$ac_cv_header_time" >&6; } -if test $ac_cv_header_time = yes; then - -$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h - -fi - -if test $ac_cv_c_compiler_gnu = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5 -$as_echo_n "checking whether $CC needs -traditional... " >&6; } -if test "${ac_cv_prog_gcc_traditional+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_pattern="Autoconf.*'x'" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -Autoconf TIOCGETP -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "$ac_pattern" >/dev/null 2>&1; then : - ac_cv_prog_gcc_traditional=yes -else - ac_cv_prog_gcc_traditional=no -fi -rm -f conftest* - - - if test $ac_cv_prog_gcc_traditional = no; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -Autoconf TCGETA -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "$ac_pattern" >/dev/null 2>&1; then : - ac_cv_prog_gcc_traditional=yes -fi -rm -f conftest* - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gcc_traditional" >&5 -$as_echo "$ac_cv_prog_gcc_traditional" >&6; } - if test $ac_cv_prog_gcc_traditional = yes; then - CC="$CC -traditional" - fi -fi - -case `pwd` in - *\ * | *\ *) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 -$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; -esac - - - -macro_version='2.2.6b' -macro_revision='1.3017' - - - - - - - - - - - - - -ltmain="$ac_aux_dir/ltmain.sh" - -# Make sure we can run config.sub. -$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 -$as_echo_n "checking build system type... " >&6; } -if test "${ac_cv_build+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_build_alias=$build_alias -test "x$ac_build_alias" = x && - ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` -test "x$ac_build_alias" = x && - as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 -ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 -$as_echo "$ac_cv_build" >&6; } -case $ac_cv_build in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;; -esac -build=$ac_cv_build -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_build -shift -build_cpu=$1 -build_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -build_os=$* -IFS=$ac_save_IFS -case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 -$as_echo_n "checking host system type... " >&6; } -if test "${ac_cv_host+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "x$host_alias" = x; then - ac_cv_host=$ac_cv_build -else - ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 -$as_echo "$ac_cv_host" >&6; } -case $ac_cv_host in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;; -esac -host=$ac_cv_host -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_host -shift -host_cpu=$1 -host_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -host_os=$* -IFS=$ac_save_IFS -case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 -$as_echo_n "checking for a sed that does not truncate output... " >&6; } -if test "${ac_cv_path_SED+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ - for ac_i in 1 2 3 4 5 6 7; do - ac_script="$ac_script$as_nl$ac_script" - done - echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed - { ac_script=; unset ac_script;} - if test -z "$SED"; then - ac_path_SED_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue -# Check for GNU ac_path_SED and select it if it is found. - # Check for GNU $ac_path_SED -case `"$ac_path_SED" --version 2>&1` in -*GNU*) - ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo '' >> "conftest.nl" - "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_SED_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_SED="$ac_path_SED" - ac_path_SED_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_SED_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_SED"; then - as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 - fi -else - ac_cv_path_SED=$SED -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 -$as_echo "$ac_cv_path_SED" >&6; } - SED="$ac_cv_path_SED" - rm -f conftest.sed - -test -z "$SED" && SED=sed -Xsed="$SED -e 1s/^X//" - - - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 -$as_echo_n "checking for fgrep... " >&6; } -if test "${ac_cv_path_FGREP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 - then ac_cv_path_FGREP="$GREP -F" - else - if test -z "$FGREP"; then - ac_path_FGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in fgrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue -# Check for GNU ac_path_FGREP and select it if it is found. - # Check for GNU $ac_path_FGREP -case `"$ac_path_FGREP" --version 2>&1` in -*GNU*) - ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'FGREP' >> "conftest.nl" - "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_FGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_FGREP="$ac_path_FGREP" - ac_path_FGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_FGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_FGREP"; then - as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_FGREP=$FGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 -$as_echo "$ac_cv_path_FGREP" >&6; } - FGREP="$ac_cv_path_FGREP" - - -test -z "$GREP" && GREP=grep - - - - - - - - - - - - - - - - - - - -# Check whether --with-gnu-ld was given. -if test "${with_gnu_ld+set}" = set; then : - withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes -else - with_gnu_ld=no -fi - -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 -$as_echo_n "checking for ld used by $CC... " >&6; } - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [\\/]* | ?:[\\/]*) - re_direlt='/[^/][^/]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` - while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do - ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 -$as_echo_n "checking for GNU ld... " >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 -$as_echo_n "checking for non-GNU ld... " >&6; } -fi -if test "${lt_cv_path_LD+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$lt_cv_path_LD" -v 2>&1 &5 -$as_echo "$LD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi -test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 -$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } -if test "${lt_cv_prog_gnu_ld+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - # I'd rather use --version here, but apparently some GNU lds only accept -v. -case `$LD -v 2>&1 &5 -$as_echo "$lt_cv_prog_gnu_ld" >&6; } -with_gnu_ld=$lt_cv_prog_gnu_ld - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 -$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } -if test "${lt_cv_path_NM+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$NM"; then - # Let the user override the test. - lt_cv_path_NM="$NM" -else - lt_nm_to_check="${ac_tool_prefix}nm" - if test -n "$ac_tool_prefix" && test "$build" = "$host"; then - lt_nm_to_check="$lt_nm_to_check nm" - fi - for lt_tmp_nm in $lt_nm_to_check; do - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - tmp_nm="$ac_dir/$lt_tmp_nm" - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - # Tru64's nm complains that /dev/null is an invalid object file - case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in - */dev/null* | *'Invalid file or object type'*) - lt_cv_path_NM="$tmp_nm -B" - break - ;; - *) - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in - */dev/null*) - lt_cv_path_NM="$tmp_nm -p" - break - ;; - *) - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but - continue # so that we can try to find one that supports BSD flags - ;; - esac - ;; - esac - fi - done - IFS="$lt_save_ifs" - done - : ${lt_cv_path_NM=no} -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 -$as_echo "$lt_cv_path_NM" >&6; } -if test "$lt_cv_path_NM" != "no"; then - NM="$lt_cv_path_NM" -else - # Didn't find any BSD compatible name lister, look for dumpbin. - if test -n "$ac_tool_prefix"; then - for ac_prog in "dumpbin -symbols" "link -dump -symbols" - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_DUMPBIN+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$DUMPBIN"; then - ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -DUMPBIN=$ac_cv_prog_DUMPBIN -if test -n "$DUMPBIN"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 -$as_echo "$DUMPBIN" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$DUMPBIN" && break - done -fi -if test -z "$DUMPBIN"; then - ac_ct_DUMPBIN=$DUMPBIN - for ac_prog in "dumpbin -symbols" "link -dump -symbols" -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_DUMPBIN"; then - ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN -if test -n "$ac_ct_DUMPBIN"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 -$as_echo "$ac_ct_DUMPBIN" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_DUMPBIN" && break -done - - if test "x$ac_ct_DUMPBIN" = x; then - DUMPBIN=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - DUMPBIN=$ac_ct_DUMPBIN - fi -fi - - - if test "$DUMPBIN" != ":"; then - NM="$DUMPBIN" - fi -fi -test -z "$NM" && NM=nm - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 -$as_echo_n "checking the name lister ($NM) interface... " >&6; } -if test "${lt_cv_nm_interface+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_nm_interface="BSD nm" - echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:5730: $ac_compile\"" >&5) - (eval "$ac_compile" 2>conftest.err) - cat conftest.err >&5 - (eval echo "\"\$as_me:5733: $NM \\\"conftest.$ac_objext\\\"\"" >&5) - (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) - cat conftest.err >&5 - (eval echo "\"\$as_me:5736: output\"" >&5) - cat conftest.out >&5 - if $GREP 'External.*some_variable' conftest.out > /dev/null; then - lt_cv_nm_interface="MS dumpbin" - fi - rm -f conftest* -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 -$as_echo "$lt_cv_nm_interface" >&6; } - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 -$as_echo_n "checking whether ln -s works... " >&6; } -LN_S=$as_ln_s -if test "$LN_S" = "ln -s"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 -$as_echo "no, using $LN_S" >&6; } -fi - -# find the maximum length of command line arguments -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 -$as_echo_n "checking the maximum length of command line arguments... " >&6; } -if test "${lt_cv_sys_max_cmd_len+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - i=0 - teststring="ABCD" - - case $build_os in - msdosdjgpp*) - # On DJGPP, this test can blow up pretty badly due to problems in libc - # (any single argument exceeding 2000 bytes causes a buffer overrun - # during glob expansion). Even if it were fixed, the result of this - # check would be larger than it should be. - lt_cv_sys_max_cmd_len=12288; # 12K is about right - ;; - - gnu*) - # Under GNU Hurd, this test is not required because there is - # no limit to the length of command line arguments. - # Libtool will interpret -1 as no limit whatsoever - lt_cv_sys_max_cmd_len=-1; - ;; - - cygwin* | mingw* | cegcc*) - # On Win9x/ME, this test blows up -- it succeeds, but takes - # about 5 minutes as the teststring grows exponentially. - # Worse, since 9x/ME are not pre-emptively multitasking, - # you end up with a "frozen" computer, even though with patience - # the test eventually succeeds (with a max line length of 256k). - # Instead, let's just punt: use the minimum linelength reported by - # all of the supported platforms: 8192 (on NT/2K/XP). - lt_cv_sys_max_cmd_len=8192; - ;; - - amigaos*) - # On AmigaOS with pdksh, this test takes hours, literally. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) - # This has been around since 386BSD, at least. Likely further. - if test -x /sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` - elif test -x /usr/sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` - else - lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs - fi - # And add a safety zone - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - ;; - - interix*) - # We know the value 262144 and hardcode it with a safety zone (like BSD) - lt_cv_sys_max_cmd_len=196608 - ;; - - osf*) - # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure - # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not - # nice to cause kernel panics so lets avoid the loop below. - # First set a reasonable default. - lt_cv_sys_max_cmd_len=16384 - # - if test -x /sbin/sysconfig; then - case `/sbin/sysconfig -q proc exec_disable_arg_limit` in - *1*) lt_cv_sys_max_cmd_len=-1 ;; - esac - fi - ;; - sco3.2v5*) - lt_cv_sys_max_cmd_len=102400 - ;; - sysv5* | sco5v6* | sysv4.2uw2*) - kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` - if test -n "$kargmax"; then - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` - else - lt_cv_sys_max_cmd_len=32768 - fi - ;; - *) - lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len"; then - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - else - # Make teststring a little bigger before we do anything with it. - # a 1K string should be a reasonable start. - for i in 1 2 3 4 5 6 7 8 ; do - teststring=$teststring$teststring - done - SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} - # If test is not a shell built-in, we'll probably end up computing a - # maximum length that is only half of the actual maximum length, but - # we can't tell. - while { test "X"`$SHELL $0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ - = "XX$teststring$teststring"; } >/dev/null 2>&1 && - test $i != 17 # 1/2 MB should be enough - do - i=`expr $i + 1` - teststring=$teststring$teststring - done - # Only check the string length outside the loop. - lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` - teststring= - # Add a significant safety factor because C++ compilers can tack on - # massive amounts of additional arguments before passing them to the - # linker. It appears as though 1/2 is a usable value. - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` - fi - ;; - esac - -fi - -if test -n $lt_cv_sys_max_cmd_len ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 -$as_echo "$lt_cv_sys_max_cmd_len" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 -$as_echo "none" >&6; } -fi -max_cmd_len=$lt_cv_sys_max_cmd_len - - - - - - -: ${CP="cp -f"} -: ${MV="mv -f"} -: ${RM="rm -f"} - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 -$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } -# Try some XSI features -xsi_shell=no -( _lt_dummy="a/b/c" - test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ - = c,a/b,, \ - && eval 'test $(( 1 + 1 )) -eq 2 \ - && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ - && xsi_shell=yes -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 -$as_echo "$xsi_shell" >&6; } - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 -$as_echo_n "checking whether the shell understands \"+=\"... " >&6; } -lt_shell_append=no -( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ - >/dev/null 2>&1 \ - && lt_shell_append=yes -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 -$as_echo "$lt_shell_append" >&6; } - - -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - lt_unset=unset -else - lt_unset=false -fi - - - - - -# test EBCDIC or ASCII -case `echo X|tr X '\101'` in - A) # ASCII based system - # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr - lt_SP2NL='tr \040 \012' - lt_NL2SP='tr \015\012 \040\040' - ;; - *) # EBCDIC based system - lt_SP2NL='tr \100 \n' - lt_NL2SP='tr \r\n \100\100' - ;; -esac - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 -$as_echo_n "checking for $LD option to reload object files... " >&6; } -if test "${lt_cv_ld_reload_flag+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_ld_reload_flag='-r' -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 -$as_echo "$lt_cv_ld_reload_flag" >&6; } -reload_flag=$lt_cv_ld_reload_flag -case $reload_flag in -"" | " "*) ;; -*) reload_flag=" $reload_flag" ;; -esac -reload_cmds='$LD$reload_flag -o $output$reload_objs' -case $host_os in - darwin*) - if test "$GCC" = yes; then - reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' - else - reload_cmds='$LD$reload_flag -o $output$reload_objs' - fi - ;; -esac - - - - - - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. -set dummy ${ac_tool_prefix}objdump; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OBJDUMP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OBJDUMP"; then - ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OBJDUMP=$ac_cv_prog_OBJDUMP -if test -n "$OBJDUMP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 -$as_echo "$OBJDUMP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OBJDUMP"; then - ac_ct_OBJDUMP=$OBJDUMP - # Extract the first word of "objdump", so it can be a program name with args. -set dummy objdump; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OBJDUMP"; then - ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OBJDUMP="objdump" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP -if test -n "$ac_ct_OBJDUMP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 -$as_echo "$ac_ct_OBJDUMP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OBJDUMP" = x; then - OBJDUMP="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OBJDUMP=$ac_ct_OBJDUMP - fi -else - OBJDUMP="$ac_cv_prog_OBJDUMP" -fi - -test -z "$OBJDUMP" && OBJDUMP=objdump - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 -$as_echo_n "checking how to recognize dependent libraries... " >&6; } -if test "${lt_cv_deplibs_check_method+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_file_magic_cmd='$MAGIC_CMD' -lt_cv_file_magic_test_file= -lt_cv_deplibs_check_method='unknown' -# Need to set the preceding variable on all platforms that support -# interlibrary dependencies. -# 'none' -- dependencies not supported. -# `unknown' -- same as none, but documents that we really don't know. -# 'pass_all' -- all dependencies passed with no checks. -# 'test_compile' -- check by making test program. -# 'file_magic [[regex]]' -- check by looking for files in library path -# which responds to the $file_magic_cmd with a given extended regex. -# If you have `file' or equivalent on your system and you're not sure -# whether `pass_all' will *always* work, you probably want this one. - -case $host_os in -aix[4-9]*) - lt_cv_deplibs_check_method=pass_all - ;; - -beos*) - lt_cv_deplibs_check_method=pass_all - ;; - -bsdi[45]*) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' - lt_cv_file_magic_cmd='/usr/bin/file -L' - lt_cv_file_magic_test_file=/shlib/libc.so - ;; - -cygwin*) - # func_win32_libid is a shell function defined in ltmain.sh - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' - lt_cv_file_magic_cmd='func_win32_libid' - ;; - -mingw* | pw32*) - # Base MSYS/MinGW do not provide the 'file' command needed by - # func_win32_libid shell function, so use a weaker test based on 'objdump', - # unless we find 'file', for example because we are cross-compiling. - if ( file / ) >/dev/null 2>&1; then - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' - lt_cv_file_magic_cmd='func_win32_libid' - else - lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - fi - ;; - -cegcc) - # use the weaker test based on 'objdump'. See mingw*. - lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - ;; - -darwin* | rhapsody*) - lt_cv_deplibs_check_method=pass_all - ;; - -freebsd* | dragonfly*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - case $host_cpu in - i*86 ) - # Not sure whether the presence of OpenBSD here was a mistake. - # Let's accept both of them until this is cleared up. - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - ;; - esac - else - lt_cv_deplibs_check_method=pass_all - fi - ;; - -gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - -hpux10.20* | hpux11*) - lt_cv_file_magic_cmd=/usr/bin/file - case $host_cpu in - ia64*) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' - lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so - ;; - hppa*64*) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]' - lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl - ;; - *) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' - lt_cv_file_magic_test_file=/usr/lib/libc.sl - ;; - esac - ;; - -interix[3-9]*) - # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' - ;; - -irix5* | irix6* | nonstopux*) - case $LD in - *-32|*"-32 ") libmagic=32-bit;; - *-n32|*"-n32 ") libmagic=N32;; - *-64|*"-64 ") libmagic=64-bit;; - *) libmagic=never-match;; - esac - lt_cv_deplibs_check_method=pass_all - ;; - -# This must be Linux ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) - lt_cv_deplibs_check_method=pass_all - ;; - -netbsd* | netbsdelf*-gnu) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' - fi - ;; - -newos6*) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libnls.so - ;; - -*nto* | *qnx*) - lt_cv_deplibs_check_method=pass_all - ;; - -openbsd*) - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' - fi - ;; - -osf3* | osf4* | osf5*) - lt_cv_deplibs_check_method=pass_all - ;; - -rdos*) - lt_cv_deplibs_check_method=pass_all - ;; - -solaris*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv4 | sysv4.3*) - case $host_vendor in - motorola) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` - ;; - ncr) - lt_cv_deplibs_check_method=pass_all - ;; - sequent) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' - ;; - sni) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" - lt_cv_file_magic_test_file=/lib/libc.so - ;; - siemens) - lt_cv_deplibs_check_method=pass_all - ;; - pc) - lt_cv_deplibs_check_method=pass_all - ;; - esac - ;; - -tpf*) - lt_cv_deplibs_check_method=pass_all - ;; -esac - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 -$as_echo "$lt_cv_deplibs_check_method" >&6; } -file_magic_cmd=$lt_cv_file_magic_cmd -deplibs_check_method=$lt_cv_deplibs_check_method -test -z "$deplibs_check_method" && deplibs_check_method=unknown - - - - - - - - - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. -set dummy ${ac_tool_prefix}ar; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AR+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AR"; then - ac_cv_prog_AR="$AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_AR="${ac_tool_prefix}ar" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AR=$ac_cv_prog_AR -if test -n "$AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 -$as_echo "$AR" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_AR"; then - ac_ct_AR=$AR - # Extract the first word of "ar", so it can be a program name with args. -set dummy ar; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_AR+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_AR"; then - ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_AR="ar" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_AR=$ac_cv_prog_ac_ct_AR -if test -n "$ac_ct_AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 -$as_echo "$ac_ct_AR" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_AR" = x; then - AR="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - AR=$ac_ct_AR - fi -else - AR="$ac_cv_prog_AR" -fi - -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru - - - - - - - - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. -set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_STRIP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -STRIP=$ac_cv_prog_STRIP -if test -n "$STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 -$as_echo "$STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_STRIP"; then - ac_ct_STRIP=$STRIP - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_STRIP"; then - ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_STRIP="strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP -if test -n "$ac_ct_STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 -$as_echo "$ac_ct_STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_STRIP" = x; then - STRIP=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - STRIP=$ac_ct_STRIP - fi -else - STRIP="$ac_cv_prog_STRIP" -fi - -test -z "$STRIP" && STRIP=: - - - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. -set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_RANLIB+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -RANLIB=$ac_cv_prog_RANLIB -if test -n "$RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 -$as_echo "$RANLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_RANLIB"; then - ac_ct_RANLIB=$RANLIB - # Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_RANLIB"; then - ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_RANLIB="ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB -if test -n "$ac_ct_RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 -$as_echo "$ac_ct_RANLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_RANLIB" = x; then - RANLIB=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - RANLIB=$ac_ct_RANLIB - fi -else - RANLIB="$ac_cv_prog_RANLIB" -fi - -test -z "$RANLIB" && RANLIB=: - - - - - - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC - - -# Check for command to grab the raw symbol name followed by C symbol from nm. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 -$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } -if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - -# These are sane defaults that work on at least a few old systems. -# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -# Character class describing NM global symbol codes. -symcode='[BCDEGRST]' - -# Regexp to match symbols that can be accessed directly from C. -sympat='\([_A-Za-z][_A-Za-z0-9]*\)' - -# Define system-specific variables. -case $host_os in -aix*) - symcode='[BCDT]' - ;; -cygwin* | mingw* | pw32* | cegcc*) - symcode='[ABCDGISTW]' - ;; -hpux*) - if test "$host_cpu" = ia64; then - symcode='[ABCDEGRST]' - fi - ;; -irix* | nonstopux*) - symcode='[BCDEGRST]' - ;; -osf*) - symcode='[BCDEGQRST]' - ;; -solaris*) - symcode='[BDRT]' - ;; -sco3.2v5*) - symcode='[DT]' - ;; -sysv4.2uw2*) - symcode='[DT]' - ;; -sysv5* | sco5v6* | unixware* | OpenUNIX*) - symcode='[ABDT]' - ;; -sysv4) - symcode='[DFNSTU]' - ;; -esac - -# If we're using GNU nm, then use its standard symbol codes. -case `$NM -V 2>&1` in -*GNU* | *'with BFD'*) - symcode='[ABCDGIRSTW]' ;; -esac - -# Transform an extracted symbol line into a proper C declaration. -# Some systems (esp. on ia64) link data and code symbols differently, -# so use this general approach. -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" - -# Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" - -# Handle CRLF in mingw tool chain -opt_cr= -case $build_os in -mingw*) - opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp - ;; -esac - -# Try without a prefix underscore, then with it. -for ac_symprfx in "" "_"; do - - # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. - symxfrm="\\1 $ac_symprfx\\2 \\2" - - # Write the raw and C identifiers. - if test "$lt_cv_nm_interface" = "MS dumpbin"; then - # Fake it for dumpbin and say T for any non-static function - # and D for any global variable. - # Also find C++ and __fastcall symbols from MSVC++, - # which start with @ or ?. - lt_cv_sys_global_symbol_pipe="$AWK '"\ -" {last_section=section; section=\$ 3};"\ -" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ -" \$ 0!~/External *\|/{next};"\ -" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ -" {if(hide[section]) next};"\ -" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ -" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ -" s[1]~/^[@?]/{print s[1], s[1]; next};"\ -" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ -" ' prfx=^$ac_symprfx" - else - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" - fi - - # Check to see that the pipe works correctly. - pipe_works=no - - rm -f conftest* - cat > conftest.$ac_ext <<_LT_EOF -#ifdef __cplusplus -extern "C" { -#endif -char nm_test_var; -void nm_test_func(void); -void nm_test_func(void){} -#ifdef __cplusplus -} -#endif -int main(){nm_test_var='a';nm_test_func();return(0);} -_LT_EOF - - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - # Now try to grab the symbols. - nlist=conftest.nm - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\""; } >&5 - (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s "$nlist"; then - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - else - rm -f "$nlist"T - fi - - # Make sure that we snagged all the symbols we need. - if $GREP ' nm_test_var$' "$nlist" >/dev/null; then - if $GREP ' nm_test_func$' "$nlist" >/dev/null; then - cat <<_LT_EOF > conftest.$ac_ext -#ifdef __cplusplus -extern "C" { -#endif - -_LT_EOF - # Now generate the symbol file. - eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' - - cat <<_LT_EOF >> conftest.$ac_ext - -/* The mapping between symbol names and symbols. */ -const struct { - const char *name; - void *address; -} -lt__PROGRAM__LTX_preloaded_symbols[] = -{ - { "@PROGRAM@", (void *) 0 }, -_LT_EOF - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext - cat <<\_LT_EOF >> conftest.$ac_ext - {0, (void *) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt__PROGRAM__LTX_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif -_LT_EOF - # Now try linking the two files. - mv conftest.$ac_objext conftstm.$ac_objext - lt_save_LIBS="$LIBS" - lt_save_CFLAGS="$CFLAGS" - LIBS="conftstm.$ac_objext" - CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 - (eval $ac_link) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s conftest${ac_exeext}; then - pipe_works=yes - fi - LIBS="$lt_save_LIBS" - CFLAGS="$lt_save_CFLAGS" - else - echo "cannot find nm_test_func in $nlist" >&5 - fi - else - echo "cannot find nm_test_var in $nlist" >&5 - fi - else - echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 - fi - else - echo "$progname: failed program was:" >&5 - cat conftest.$ac_ext >&5 - fi - rm -rf conftest* conftst* - - # Do not use the global_symbol_pipe unless it works. - if test "$pipe_works" = yes; then - break - else - lt_cv_sys_global_symbol_pipe= - fi -done - -fi - -if test -z "$lt_cv_sys_global_symbol_pipe"; then - lt_cv_sys_global_symbol_to_cdecl= -fi -if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 -$as_echo "failed" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; } -fi - - - - - - - - - - - - - - - - - - - - - - -# Check whether --enable-libtool-lock was given. -if test "${enable_libtool_lock+set}" = set; then : - enableval=$enable_libtool_lock; -fi - -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -ia64-*-hpux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - case `/usr/bin/file conftest.$ac_objext` in - *ELF-32*) - HPUX_IA64_MODE="32" - ;; - *ELF-64*) - HPUX_IA64_MODE="64" - ;; - esac - fi - rm -rf conftest* - ;; -*-*-irix6*) - # Find out which ABI we are using. - echo '#line 6941 "configure"' > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - if test "$lt_cv_prog_gnu_ld" = yes; then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -melf32bsmip" - ;; - *N32*) - LD="${LD-ld} -melf32bmipn32" - ;; - *64-bit*) - LD="${LD-ld} -melf64bmip" - ;; - esac - else - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - fi - rm -rf conftest* - ;; - -x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ -s390*-*linux*|s390*-*tpf*|sparc*-*linux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - case `/usr/bin/file conftest.o` in - *32-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_i386_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_i386" - ;; - ppc64-*linux*|powerpc64-*linux*) - LD="${LD-ld} -m elf32ppclinux" - ;; - s390x-*linux*) - LD="${LD-ld} -m elf_s390" - ;; - sparc64-*linux*) - LD="${LD-ld} -m elf32_sparc" - ;; - esac - ;; - *64-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_x86_64_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_x86_64" - ;; - ppc*-*linux*|powerpc*-*linux*) - LD="${LD-ld} -m elf64ppc" - ;; - s390*-*linux*|s390*-*tpf*) - LD="${LD-ld} -m elf64_s390" - ;; - sparc*-*linux*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 -$as_echo_n "checking whether the C compiler needs -belf... " >&6; } -if test "${lt_cv_cc_needs_belf+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - lt_cv_cc_needs_belf=yes -else - lt_cv_cc_needs_belf=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 -$as_echo "$lt_cv_cc_needs_belf" >&6; } - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; -sparc*-*solaris*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - case `/usr/bin/file conftest.o` in - *64-bit*) - case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; - *) - if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then - LD="${LD-ld} -64" - fi - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; -esac - -need_locks="$enable_libtool_lock" - - - case $host_os in - rhapsody* | darwin*) - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. -set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_DSYMUTIL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$DSYMUTIL"; then - ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -DSYMUTIL=$ac_cv_prog_DSYMUTIL -if test -n "$DSYMUTIL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 -$as_echo "$DSYMUTIL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_DSYMUTIL"; then - ac_ct_DSYMUTIL=$DSYMUTIL - # Extract the first word of "dsymutil", so it can be a program name with args. -set dummy dsymutil; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_DSYMUTIL"; then - ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL -if test -n "$ac_ct_DSYMUTIL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 -$as_echo "$ac_ct_DSYMUTIL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_DSYMUTIL" = x; then - DSYMUTIL=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - DSYMUTIL=$ac_ct_DSYMUTIL - fi -else - DSYMUTIL="$ac_cv_prog_DSYMUTIL" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. -set dummy ${ac_tool_prefix}nmedit; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_NMEDIT+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$NMEDIT"; then - ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -NMEDIT=$ac_cv_prog_NMEDIT -if test -n "$NMEDIT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 -$as_echo "$NMEDIT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_NMEDIT"; then - ac_ct_NMEDIT=$NMEDIT - # Extract the first word of "nmedit", so it can be a program name with args. -set dummy nmedit; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_NMEDIT"; then - ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_NMEDIT="nmedit" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT -if test -n "$ac_ct_NMEDIT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 -$as_echo "$ac_ct_NMEDIT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_NMEDIT" = x; then - NMEDIT=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - NMEDIT=$ac_ct_NMEDIT - fi -else - NMEDIT="$ac_cv_prog_NMEDIT" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. -set dummy ${ac_tool_prefix}lipo; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_LIPO+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$LIPO"; then - ac_cv_prog_LIPO="$LIPO" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_LIPO="${ac_tool_prefix}lipo" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -LIPO=$ac_cv_prog_LIPO -if test -n "$LIPO"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 -$as_echo "$LIPO" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_LIPO"; then - ac_ct_LIPO=$LIPO - # Extract the first word of "lipo", so it can be a program name with args. -set dummy lipo; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_LIPO+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_LIPO"; then - ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_LIPO="lipo" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO -if test -n "$ac_ct_LIPO"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 -$as_echo "$ac_ct_LIPO" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_LIPO" = x; then - LIPO=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - LIPO=$ac_ct_LIPO - fi -else - LIPO="$ac_cv_prog_LIPO" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. -set dummy ${ac_tool_prefix}otool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OTOOL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OTOOL"; then - ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OTOOL="${ac_tool_prefix}otool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OTOOL=$ac_cv_prog_OTOOL -if test -n "$OTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 -$as_echo "$OTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OTOOL"; then - ac_ct_OTOOL=$OTOOL - # Extract the first word of "otool", so it can be a program name with args. -set dummy otool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OTOOL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OTOOL"; then - ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OTOOL="otool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL -if test -n "$ac_ct_OTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 -$as_echo "$ac_ct_OTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OTOOL" = x; then - OTOOL=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OTOOL=$ac_ct_OTOOL - fi -else - OTOOL="$ac_cv_prog_OTOOL" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. -set dummy ${ac_tool_prefix}otool64; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OTOOL64+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OTOOL64"; then - ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OTOOL64=$ac_cv_prog_OTOOL64 -if test -n "$OTOOL64"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 -$as_echo "$OTOOL64" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OTOOL64"; then - ac_ct_OTOOL64=$OTOOL64 - # Extract the first word of "otool64", so it can be a program name with args. -set dummy otool64; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OTOOL64+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OTOOL64"; then - ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OTOOL64="otool64" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 -if test -n "$ac_ct_OTOOL64"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 -$as_echo "$ac_ct_OTOOL64" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OTOOL64" = x; then - OTOOL64=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OTOOL64=$ac_ct_OTOOL64 - fi -else - OTOOL64="$ac_cv_prog_OTOOL64" -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 -$as_echo_n "checking for -single_module linker flag... " >&6; } -if test "${lt_cv_apple_cc_single_mod+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_apple_cc_single_mod=no - if test -z "${LT_MULTI_MODULE}"; then - # By default we will add the -single_module flag. You can override - # by either setting the environment variable LT_MULTI_MODULE - # non-empty at configure time, or by adding -multi_module to the - # link flags. - rm -rf libconftest.dylib* - echo "int foo(void){return 1;}" > conftest.c - echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ --dynamiclib -Wl,-single_module conftest.c" >&5 - $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ - -dynamiclib -Wl,-single_module conftest.c 2>conftest.err - _lt_result=$? - if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then - lt_cv_apple_cc_single_mod=yes - else - cat conftest.err >&5 - fi - rm -rf libconftest.dylib* - rm -f conftest.* - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 -$as_echo "$lt_cv_apple_cc_single_mod" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 -$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } -if test "${lt_cv_ld_exported_symbols_list+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_ld_exported_symbols_list=no - save_LDFLAGS=$LDFLAGS - echo "_main" > conftest.sym - LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - lt_cv_ld_exported_symbols_list=yes -else - lt_cv_ld_exported_symbols_list=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS="$save_LDFLAGS" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 -$as_echo "$lt_cv_ld_exported_symbols_list" >&6; } - case $host_os in - rhapsody* | darwin1.[012]) - _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; - darwin1.*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - darwin*) # darwin 5.x on - # if running on 10.5 or later, the deployment target defaults - # to the OS version, if on x86, and 10.4, the deployment - # target defaults to 10.4. Don't you love it? - case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[91]*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - 10.[012]*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - 10.*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - esac - ;; - esac - if test "$lt_cv_apple_cc_single_mod" = "yes"; then - _lt_dar_single_mod='$single_module' - fi - if test "$lt_cv_ld_exported_symbols_list" = "yes"; then - _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' - else - _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - if test "$DSYMUTIL" != ":"; then - _lt_dsymutil='~$DSYMUTIL $lib || :' - else - _lt_dsymutil= - fi - ;; - esac - -for ac_header in dlfcn.h -do : - ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default -" -if test "x$ac_cv_header_dlfcn_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_DLFCN_H 1 -_ACEOF - -fi - -done - - - -# Set options - - - - enable_dlopen=no - - - enable_win32_dll=no - - - # Check whether --enable-shared was given. -if test "${enable_shared+set}" = set; then : - enableval=$enable_shared; p=${PACKAGE-default} - case $enableval in - yes) enable_shared=yes ;; - no) enable_shared=no ;; - *) - enable_shared=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_shared=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - enable_shared=yes -fi - - - - - - - - - - # Check whether --enable-static was given. -if test "${enable_static+set}" = set; then : - enableval=$enable_static; p=${PACKAGE-default} - case $enableval in - yes) enable_static=yes ;; - no) enable_static=no ;; - *) - enable_static=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - enable_static=yes -fi - - - - - - - - - - -# Check whether --with-pic was given. -if test "${with_pic+set}" = set; then : - withval=$with_pic; pic_mode="$withval" -else - pic_mode=default -fi - - -test -z "$pic_mode" && pic_mode=default - - - - - - - - # Check whether --enable-fast-install was given. -if test "${enable_fast_install+set}" = set; then : - enableval=$enable_fast_install; p=${PACKAGE-default} - case $enableval in - yes) enable_fast_install=yes ;; - no) enable_fast_install=no ;; - *) - enable_fast_install=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_fast_install=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - enable_fast_install=yes -fi - - - - - - - - - - - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ltmain" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' - - - - - - - - - - - - - - - - - - - - - - - - - -test -z "$LN_S" && LN_S="ln -s" - - - - - - - - - - - - - - -if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 -$as_echo_n "checking for objdir... " >&6; } -if test "${lt_cv_objdir+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - lt_cv_objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - lt_cv_objdir=_libs -fi -rmdir .libs 2>/dev/null -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 -$as_echo "$lt_cv_objdir" >&6; } -objdir=$lt_cv_objdir - - - - - -cat >>confdefs.h <<_ACEOF -#define LT_OBJDIR "$lt_cv_objdir/" -_ACEOF - - - - - - - - - - - - - - - - - -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -sed_quote_subst='s/\(["`$\\]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\(["`\\]\)/\\\1/g' - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to delay expansion of an escaped single quote. -delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' - -# Global variables: -ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except MSVC, -# which needs '.lib'). -libext=a - -with_gnu_ld="$lt_cv_prog_gnu_ld" - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$CC" && CC=cc -test -z "$LTCC" && LTCC=$CC -test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS -test -z "$LD" && LD=ld -test -z "$ac_objext" && ac_objext=o - -for cc_temp in $compiler""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` - - -# Only perform the check for file, if the check method requires it -test -z "$MAGIC_CMD" && MAGIC_CMD=file -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 -$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } -if test "${lt_cv_path_MAGIC_CMD+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - case $MAGIC_CMD in -[\\/*] | ?:[\\/]*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" - for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/${ac_tool_prefix}file; then - lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <<_LT_EOF 1>&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -_LT_EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac -fi - -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 -$as_echo "$MAGIC_CMD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - - - -if test -z "$lt_cv_path_MAGIC_CMD"; then - if test -n "$ac_tool_prefix"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 -$as_echo_n "checking for file... " >&6; } -if test "${lt_cv_path_MAGIC_CMD+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - case $MAGIC_CMD in -[\\/*] | ?:[\\/]*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" - for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/file; then - lt_cv_path_MAGIC_CMD="$ac_dir/file" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <<_LT_EOF 1>&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -_LT_EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac -fi - -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 -$as_echo "$MAGIC_CMD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - else - MAGIC_CMD=: - fi -fi - - fi - ;; -esac - -# Use C for the default configuration in the libtool script - -lt_save_CC="$CC" -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -# Source file extension for C test sources. -ac_ext=c - -# Object file extension for compiled C test sources. -objext=o -objext=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(){return(0);}' - - - - - - - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC - -# Save the default compiler, since it gets overwritten when the other -# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. -compiler_DEFAULT=$CC - -# save warnings/boilerplate of simple test code -ac_outfile=conftest.$ac_objext -echo "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$RM conftest* - -ac_outfile=conftest.$ac_objext -echo "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$RM -r conftest* - - -if test -n "$compiler"; then - -lt_prog_compiler_no_builtin_flag= - -if test "$GCC" = yes; then - lt_prog_compiler_no_builtin_flag=' -fno-builtin' - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 -$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } -if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_rtti_exceptions=no - ac_outfile=conftest.$ac_objext - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="-fno-rtti -fno-exceptions" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8199: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:8203: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler_rtti_exceptions=yes - fi - fi - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 -$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } - -if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then - lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" -else - : -fi - -fi - - - - - - - lt_prog_compiler_wl= -lt_prog_compiler_pic= -lt_prog_compiler_static= - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 -$as_echo_n "checking for $compiler option to produce PIC... " >&6; } - - if test "$GCC" = yes; then - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_static='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static='-Bstatic' - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - lt_prog_compiler_pic='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - lt_prog_compiler_pic='-DDLL_EXPORT' - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - lt_prog_compiler_pic='-fno-common' - ;; - - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - # +Z the default - ;; - *) - lt_prog_compiler_pic='-fPIC' - ;; - esac - ;; - - interix[3-9]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - lt_prog_compiler_can_build_shared=no - enable_shared=no - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - lt_prog_compiler_pic='-fPIC -shared' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - lt_prog_compiler_pic=-Kconform_pic - fi - ;; - - *) - lt_prog_compiler_pic='-fPIC' - ;; - esac - else - # PORTME Check for flag to pass linker flags through the system compiler. - case $host_os in - aix*) - lt_prog_compiler_wl='-Wl,' - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static='-Bstatic' - else - lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' - fi - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_prog_compiler_pic='-DDLL_EXPORT' - ;; - - hpux9* | hpux10* | hpux11*) - lt_prog_compiler_wl='-Wl,' - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - lt_prog_compiler_pic='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - lt_prog_compiler_static='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - lt_prog_compiler_wl='-Wl,' - # PIC (with -KPIC) is the default. - lt_prog_compiler_static='-non_shared' - ;; - - linux* | k*bsd*-gnu | kopensolaris*-gnu) - case $cc_basename in - # old Intel for x86_64 which still supported -KPIC. - ecc*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-static' - ;; - # icc used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - icc* | ifort*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-fPIC' - lt_prog_compiler_static='-static' - ;; - # Lahey Fortran 8.1. - lf95*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='--shared' - lt_prog_compiler_static='--static' - ;; - pgcc* | pgf77* | pgf90* | pgf95*) - # Portland Group compilers (*not* the Pentium gcc compiler, - # which looks to be a dead project) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-fpic' - lt_prog_compiler_static='-Bstatic' - ;; - ccc*) - lt_prog_compiler_wl='-Wl,' - # All Alpha code is PIC. - lt_prog_compiler_static='-non_shared' - ;; - xl*) - # IBM XL C 8.0/Fortran 10.1 on PPC - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-qpic' - lt_prog_compiler_static='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C 5.9 - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - lt_prog_compiler_wl='-Wl,' - ;; - *Sun\ F*) - # Sun Fortran 8.3 passes all unrecognized flags to the linker - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - lt_prog_compiler_wl='' - ;; - esac - ;; - esac - ;; - - newsos6) - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - lt_prog_compiler_pic='-fPIC -shared' - ;; - - osf3* | osf4* | osf5*) - lt_prog_compiler_wl='-Wl,' - # All OSF/1 code is PIC. - lt_prog_compiler_static='-non_shared' - ;; - - rdos*) - lt_prog_compiler_static='-non_shared' - ;; - - solaris*) - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - case $cc_basename in - f77* | f90* | f95*) - lt_prog_compiler_wl='-Qoption ld ';; - *) - lt_prog_compiler_wl='-Wl,';; - esac - ;; - - sunos4*) - lt_prog_compiler_wl='-Qoption ld ' - lt_prog_compiler_pic='-PIC' - lt_prog_compiler_static='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - lt_prog_compiler_pic='-Kconform_pic' - lt_prog_compiler_static='-Bstatic' - fi - ;; - - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - ;; - - unicos*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_can_build_shared=no - ;; - - uts4*) - lt_prog_compiler_pic='-pic' - lt_prog_compiler_static='-Bstatic' - ;; - - *) - lt_prog_compiler_can_build_shared=no - ;; - esac - fi - -case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - lt_prog_compiler_pic= - ;; - *) - lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" - ;; -esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic" >&5 -$as_echo "$lt_prog_compiler_pic" >&6; } - - - - - - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$lt_prog_compiler_pic"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 -$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } -if test "${lt_cv_prog_compiler_pic_works+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_pic_works=no - ac_outfile=conftest.$ac_objext - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$lt_prog_compiler_pic -DPIC" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8538: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:8542: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler_pic_works=yes - fi - fi - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 -$as_echo "$lt_cv_prog_compiler_pic_works" >&6; } - -if test x"$lt_cv_prog_compiler_pic_works" = xyes; then - case $lt_prog_compiler_pic in - "" | " "*) ;; - *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; - esac -else - lt_prog_compiler_pic= - lt_prog_compiler_can_build_shared=no -fi - -fi - - - - - - -# -# Check to make sure the static flag actually works. -# -wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 -$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } -if test "${lt_cv_prog_compiler_static_works+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_static_works=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $lt_tmp_static_flag" - echo "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&5 - $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler_static_works=yes - fi - else - lt_cv_prog_compiler_static_works=yes - fi - fi - $RM -r conftest* - LDFLAGS="$save_LDFLAGS" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 -$as_echo "$lt_cv_prog_compiler_static_works" >&6; } - -if test x"$lt_cv_prog_compiler_static_works" = xyes; then - : -else - lt_prog_compiler_static= -fi - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if test "${lt_cv_prog_compiler_c_o+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_c_o=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8643: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:8647: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - lt_cv_prog_compiler_c_o=yes - fi - fi - chmod u+w . 2>&5 - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 -$as_echo "$lt_cv_prog_compiler_c_o" >&6; } - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if test "${lt_cv_prog_compiler_c_o+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_c_o=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8698: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:8702: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - lt_cv_prog_compiler_c_o=yes - fi - fi - chmod u+w . 2>&5 - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 -$as_echo "$lt_cv_prog_compiler_c_o" >&6; } - - - - -hard_links="nottested" -if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 -$as_echo_n "checking if we can lock with hard links... " >&6; } - hard_links=yes - $RM conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 -$as_echo "$hard_links" >&6; } - if test "$hard_links" = no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} - need_locks=warn - fi -else - need_locks=no -fi - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } - - runpath_var= - allow_undefined_flag= - always_export_symbols=no - archive_cmds= - archive_expsym_cmds= - compiler_needs_object=no - enable_shared_with_static_runtimes=no - export_dynamic_flag_spec= - export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - hardcode_automatic=no - hardcode_direct=no - hardcode_direct_absolute=no - hardcode_libdir_flag_spec= - hardcode_libdir_flag_spec_ld= - hardcode_libdir_separator= - hardcode_minus_L=no - hardcode_shlibpath_var=unsupported - inherit_rpath=no - link_all_deplibs=unknown - module_cmds= - module_expsym_cmds= - old_archive_from_new_cmds= - old_archive_from_expsyms_cmds= - thread_safe_flag_spec= - whole_archive_flag_spec= - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - include_expsyms= - # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ` (' and `)$', so one must not match beginning or - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', - # as well as any symbol that contains `d'. - exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' - # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out - # platforms (ab)use it in PIC code, but their linkers get confused if - # the symbol is explicitly referenced. Since portable code cannot - # rely on this symbol name, it's probably fine to never include it in - # preloaded symbol tables. - # Exclude shared library initialization/finalization symbols. - extract_expsyms_cmds= - - case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd*) - with_gnu_ld=no - ;; - linux* | k*bsd*-gnu) - link_all_deplibs=no - ;; - esac - - ld_shlibs=yes - if test "$with_gnu_ld" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - runpath_var=LD_RUN_PATH - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - export_dynamic_flag_spec='${wl}--export-dynamic' - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then - whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - whole_archive_flag_spec= - fi - supports_anon_versioning=no - case `$LD -v 2>&1` in - *GNU\ gold*) supports_anon_versioning=yes ;; - *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 - *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... - *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... - *\ 2.11.*) ;; # other 2.11 versions - *) supports_anon_versioning=yes ;; - esac - - # See if GNU ld supports shared libraries. - case $host_os in - aix[3-9]*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - ld_shlibs=no - cat <<_LT_EOF 1>&2 - -*** Warning: the GNU linker, at least up to release 2.9.1, is reported -*** to be unable to reliably create shared libraries on AIX. -*** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to modify your PATH -*** so that a non-GNU linker is found, and then restart. - -_LT_EOF - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='' - ;; - m68k) - archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - esac - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - allow_undefined_flag=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - ld_shlibs=no - fi - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, - # as there is no search path for DLLs. - hardcode_libdir_flag_spec='-L$libdir' - allow_undefined_flag=unsupported - always_export_symbols=no - enable_shared_with_static_runtimes=yes - export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - ld_shlibs=no - fi - ;; - - interix[3-9]*) - hardcode_direct=no - hardcode_shlibpath_var=no - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - export_dynamic_flag_spec='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - - gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) - tmp_diet=no - if test "$host_os" = linux-dietlibc; then - case $cc_basename in - diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) - esac - fi - if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ - && test "$tmp_diet" = no - then - tmp_addflag= - tmp_sharedflag='-shared' - case $cc_basename,$host_cpu in - pgcc*) # Portland Group C compiler - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag' - ;; - pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag -Mnomain' ;; - ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 - tmp_addflag=' -i_dynamic' ;; - efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 - tmp_addflag=' -i_dynamic -nofor_main' ;; - ifc* | ifort*) # Intel Fortran compiler - tmp_addflag=' -nofor_main' ;; - lf95*) # Lahey Fortran 8.1 - whole_archive_flag_spec= - tmp_sharedflag='--shared' ;; - xl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) - tmp_sharedflag='-qmkshrobj' - tmp_addflag= ;; - esac - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) # Sun C 5.9 - whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - compiler_needs_object=yes - tmp_sharedflag='-G' ;; - *Sun\ F*) # Sun Fortran 8.3 - tmp_sharedflag='-G' ;; - esac - archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - - if test "x$supports_anon_versioning" = xyes; then - archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - - case $cc_basename in - xlf*) - # IBM XL Fortran 10.1 on PPC cannot create shared libs itself - whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' - hardcode_libdir_flag_spec= - hardcode_libdir_flag_spec_ld='-rpath $libdir' - archive_cmds='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then - archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' - fi - ;; - esac - else - ld_shlibs=no - fi - ;; - - netbsd* | netbsdelf*-gnu) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris*) - if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then - ld_shlibs=no - cat <<_LT_EOF 1>&2 - -*** Warning: The releases 2.8.* of the GNU linker cannot reliably -*** create shared libraries on Solaris systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.9.1 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) - ld_shlibs=no - cat <<_LT_EOF 1>&2 - -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not -*** reliably create shared libraries on SCO systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.16.91.0.3 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - ;; - *) - # For security reasons, it is highly recommended that you always - # use absolute paths for naming shared libraries, and exclude the - # DT_RUNPATH tag from executables and libraries. But doing so - # requires that you compile everything twice, which is a pain. - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - esac - ;; - - sunos4*) - archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - *) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - esac - - if test "$ld_shlibs" = no; then - runpath_var= - hardcode_libdir_flag_spec= - export_dynamic_flag_spec= - whole_archive_flag_spec= - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - allow_undefined_flag=unsupported - always_export_symbols=yes - archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - hardcode_minus_L=yes - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct=unsupported - fi - ;; - - aix[4-9]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - else - export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - fi - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - archive_cmds='' - hardcode_direct=yes - hardcode_direct_absolute=yes - hardcode_libdir_separator=':' - link_all_deplibs=yes - file_list_spec='${wl}-f,' - - if test "$GCC" = yes; then - case $host_os in aix4.[012]|aix4.[012].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - hardcode_direct=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - hardcode_minus_L=yes - hardcode_libdir_flag_spec='-L$libdir' - hardcode_libdir_separator= - fi - ;; - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - link_all_deplibs=no - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - export_dynamic_flag_spec='${wl}-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - always_export_symbols=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - allow_undefined_flag='-berok' - # Determine the default libpath from the value encoded in an - # empty executable. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - -lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\(.*\)$/\1/ - p - } - }' -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then - aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -fi -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi - - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' - allow_undefined_flag="-z nodefs" - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - -lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\(.*\)$/\1/ - p - } - }' -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then - aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -fi -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi - - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - no_undefined_flag=' ${wl}-bernotok' - allow_undefined_flag=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - whole_archive_flag_spec='$convenience' - archive_cmds_need_lc=yes - # This is similar to how AIX traditionally builds its shared libraries. - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='' - ;; - m68k) - archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - esac - ;; - - bsdi[45]*) - export_dynamic_flag_spec=-rdynamic - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec=' ' - allow_undefined_flag=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - archive_cmds='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - old_archive_from_new_cmds='true' - # FIXME: Should let the user specify the lib program. - old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' - fix_srcfile_path='`cygpath -w "$srcfile"`' - enable_shared_with_static_runtimes=yes - ;; - - darwin* | rhapsody*) - - - archive_cmds_need_lc=no - hardcode_direct=no - hardcode_automatic=yes - hardcode_shlibpath_var=unsupported - whole_archive_flag_spec='' - link_all_deplibs=yes - allow_undefined_flag="$_lt_dar_allow_undefined" - case $cc_basename in - ifort*) _lt_dar_can_shared=yes ;; - *) _lt_dar_can_shared=$GCC ;; - esac - if test "$_lt_dar_can_shared" = "yes"; then - output_verbose_link_cmd=echo - archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" - module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" - archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" - module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" - - else - ld_shlibs=no - fi - - ;; - - dgux*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_shlibpath_var=no - ;; - - freebsd1*) - ld_shlibs=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) - archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - hpux9*) - if test "$GCC" = yes; then - archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - fi - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - export_dynamic_flag_spec='${wl}-E' - ;; - - hpux10*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - fi - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_flag_spec_ld='+b $libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - hardcode_direct_absolute=yes - export_dynamic_flag_spec='${wl}-E' - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - fi - ;; - - hpux11*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - case $host_cpu in - hppa*64*) - archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - else - case $host_cpu in - hppa*64*) - archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - fi - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - - case $host_cpu in - hppa*64*|ia64*) - hardcode_direct=no - hardcode_shlibpath_var=no - ;; - *) - hardcode_direct=yes - hardcode_direct_absolute=yes - export_dynamic_flag_spec='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - # Try to use the -exported_symbol ld option, if it does not - # work, assume that -exports_file does not work either and - # implicitly export all symbols. - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int foo(void) {} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' - -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS="$save_LDFLAGS" - else - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' - fi - archive_cmds_need_lc='no' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - inherit_rpath=yes - link_all_deplibs=yes - ;; - - netbsd* | netbsdelf*-gnu) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - newsos6) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_shlibpath_var=no - ;; - - *nto* | *qnx*) - ;; - - openbsd*) - if test -f /usr/libexec/ld.so; then - hardcode_direct=yes - hardcode_shlibpath_var=no - hardcode_direct_absolute=yes - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - export_dynamic_flag_spec='${wl}-E' - else - case $host_os in - openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-R$libdir' - ;; - *) - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - ;; - esac - fi - else - ld_shlibs=no - fi - ;; - - os2*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - allow_undefined_flag=unsupported - archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - fi - archive_cmds_need_lc='no' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - else - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ - $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' - - # Both c and cxx compiler support -rpath directly - hardcode_libdir_flag_spec='-rpath $libdir' - fi - archive_cmds_need_lc='no' - hardcode_libdir_separator=: - ;; - - solaris*) - no_undefined_flag=' -z defs' - if test "$GCC" = yes; then - wlarc='${wl}' - archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - else - case `$CC -V 2>&1` in - *"Compilers 5.0"*) - wlarc='' - archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' - ;; - *) - wlarc='${wl}' - archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - ;; - esac - fi - hardcode_libdir_flag_spec='-R$libdir' - hardcode_shlibpath_var=no - case $host_os in - solaris2.[0-5] | solaris2.[0-5].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. GCC discards it without `$wl', - # but is careful enough not to reorder. - # Supported since Solaris 2.6 (maybe 2.5.1?) - if test "$GCC" = yes; then - whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - else - whole_archive_flag_spec='-z allextract$convenience -z defaultextract' - fi - ;; - esac - link_all_deplibs=yes - ;; - - sunos4*) - if test "x$host_vendor" = xsequent; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - sysv4) - case $host_vendor in - sni) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' - reload_cmds='$CC -r -o $output$reload_objs' - hardcode_direct=no - ;; - motorola) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var=no - ;; - - sysv4.3*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - export_dynamic_flag_spec='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - ld_shlibs=yes - fi - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) - no_undefined_flag='${wl}-z,text' - archive_cmds_need_lc=no - hardcode_shlibpath_var=no - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - no_undefined_flag='${wl}-z,text' - allow_undefined_flag='${wl}-z,nodefs' - archive_cmds_need_lc=no - hardcode_shlibpath_var=no - hardcode_libdir_flag_spec='${wl}-R,$libdir' - hardcode_libdir_separator=':' - link_all_deplibs=yes - export_dynamic_flag_spec='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - uts4*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_shlibpath_var=no - ;; - - *) - ld_shlibs=no - ;; - esac - - if test x$host_vendor = xsni; then - case $host in - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - export_dynamic_flag_spec='${wl}-Blargedynsym' - ;; - esac - fi - fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 -$as_echo "$ld_shlibs" >&6; } -test "$ld_shlibs" = no && can_build_shared=no - -with_gnu_ld=$with_gnu_ld - - - - - - - - - - - - - - - -# -# Do we need to explicitly link libc? -# -case "x$archive_cmds_need_lc" in -x|xyes) - # Assume -lc should be added - archive_cmds_need_lc=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $archive_cmds in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 -$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } - $RM conftest* - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_prog_compiler_wl - pic_flag=$lt_prog_compiler_pic - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$allow_undefined_flag - allow_undefined_flag= - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 - (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - then - archive_cmds_need_lc=no - else - archive_cmds_need_lc=yes - fi - allow_undefined_flag=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $RM conftest* - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc" >&5 -$as_echo "$archive_cmds_need_lc" >&6; } - ;; - esac - fi - ;; -esac - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 -$as_echo_n "checking dynamic linker characteristics... " >&6; } - -if test "$GCC" = yes; then - case $host_os in - darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; - *) lt_awk_arg="/^libraries:/" ;; - esac - lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then - # if the path contains ";" then we assume it to be the separator - # otherwise default to the standard path separator (i.e. ":") - it is - # assumed that no part of a normal pathname contains ";" but that should - # okay in the real world where ";" in dirpaths is itself problematic. - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` - else - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - # Ok, now we have the path, separated by spaces, we can step through it - # and add multilib dir if necessary. - lt_tmp_lt_search_path_spec= - lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` - for lt_sys_path in $lt_search_path_spec; do - if test -d "$lt_sys_path/$lt_multi_os_dir"; then - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" - else - test -d "$lt_sys_path" && \ - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" - fi - done - lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' -BEGIN {RS=" "; FS="/|\n";} { - lt_foo=""; - lt_count=0; - for (lt_i = NF; lt_i > 0; lt_i--) { - if ($lt_i != "" && $lt_i != ".") { - if ($lt_i == "..") { - lt_count++; - } else { - if (lt_count == 0) { - lt_foo="/" $lt_i lt_foo; - } else { - lt_count--; - } - } - } - } - if (lt_foo != "") { lt_freq[lt_foo]++; } - if (lt_freq[lt_foo] == 1) { print lt_foo; } -}'` - sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix[4-9]*) - version_type=linux - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[01] | aix4.[01].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - case $host_cpu in - powerpc) - # Since July 2007 AmigaOS4 officially supports .so libraries. - # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - ;; - m68k) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - esac - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[45]*) - version_type=linux - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32* | cegcc*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname~ - if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then - eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; - fi' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" - ;; - mingw* | cegcc*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then - # It is most probably a Windows format PATH printed by - # mingw gcc, but we are running on Cygwin. Gcc prints its search - # path with ; separators, and with drive letters. We can handle the - # drive letters (cygwin fileutils understands them), so leave them, - # especially as we might pass files found there to a mingw objdump, - # which wouldn't understand a cygwinified path. Ahh. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - ;; - esac - ;; - - *) - library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' - ;; - esac - dynamic_linker='Win32 ld.exe' - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' - - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd1*) - dynamic_linker=no - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[123]*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[01]* | freebsdelf3.[01]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ - freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - *) # from 4.6 on, and DragonFly - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555. - postinstall_cmds='chmod 555 $lib' - ;; - -interix[3-9]*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be Linux ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - # Some binutils ld are patched to set DT_RUNPATH - save_LDFLAGS=$LDFLAGS - save_libdir=$libdir - eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ - LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : - shlibpath_overrides_runpath=yes -fi -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS=$save_LDFLAGS - libdir=$save_libdir - - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsdelf*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='NetBSD ld.elf_so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -*nto* | *qnx*) - version_type=qnx - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='ldqnx.so' - ;; - -openbsd*) - version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" - need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[89] | openbsd2.[89].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -rdos*) - dynamic_linker=no - ;; - -solaris*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -tpf*) - # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -uts4*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 -$as_echo "$dynamic_linker" >&6; } -test "$dynamic_linker" = no && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then - sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" -fi -if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then - sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 -$as_echo_n "checking how to hardcode library paths into programs... " >&6; } -hardcode_action= -if test -n "$hardcode_libdir_flag_spec" || - test -n "$runpath_var" || - test "X$hardcode_automatic" = "Xyes" ; then - - # We can hardcode non-existent directories. - if test "$hardcode_direct" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && - test "$hardcode_minus_L" != no; then - # Linking always hardcodes the temporary library directory. - hardcode_action=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - hardcode_action=unsupported -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 -$as_echo "$hardcode_action" >&6; } - -if test "$hardcode_action" = relink || - test "$inherit_rpath" = yes; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi - - - - - - - if test "x$enable_dlopen" != xyes; then - enable_dlopen=unknown - enable_dlopen_self=unknown - enable_dlopen_self_static=unknown -else - lt_cv_dlopen=no - lt_cv_dlopen_libs= - - case $host_os in - beos*) - lt_cv_dlopen="load_add_on" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ;; - - mingw* | pw32* | cegcc*) - lt_cv_dlopen="LoadLibrary" - lt_cv_dlopen_libs= - ;; - - cygwin*) - lt_cv_dlopen="dlopen" - lt_cv_dlopen_libs= - ;; - - darwin*) - # if libdl is installed we need to link against it - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 -$as_echo_n "checking for dlopen in -ldl... " >&6; } -if test "${ac_cv_lib_dl_dlopen+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dlopen (); -int -main () -{ -return dlopen (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dl_dlopen=yes -else - ac_cv_lib_dl_dlopen=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 -$as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -else - - lt_cv_dlopen="dyld" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - -fi - - ;; - - *) - ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" -if test "x$ac_cv_func_shl_load" = x""yes; then : - lt_cv_dlopen="shl_load" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 -$as_echo_n "checking for shl_load in -ldld... " >&6; } -if test "${ac_cv_lib_dld_shl_load+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldld $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char shl_load (); -int -main () -{ -return shl_load (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dld_shl_load=yes -else - ac_cv_lib_dld_shl_load=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 -$as_echo "$ac_cv_lib_dld_shl_load" >&6; } -if test "x$ac_cv_lib_dld_shl_load" = x""yes; then : - lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" -else - ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" -if test "x$ac_cv_func_dlopen" = x""yes; then : - lt_cv_dlopen="dlopen" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 -$as_echo_n "checking for dlopen in -ldl... " >&6; } -if test "${ac_cv_lib_dl_dlopen+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dlopen (); -int -main () -{ -return dlopen (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dl_dlopen=yes -else - ac_cv_lib_dl_dlopen=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 -$as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 -$as_echo_n "checking for dlopen in -lsvld... " >&6; } -if test "${ac_cv_lib_svld_dlopen+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lsvld $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dlopen (); -int -main () -{ -return dlopen (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_svld_dlopen=yes -else - ac_cv_lib_svld_dlopen=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 -$as_echo "$ac_cv_lib_svld_dlopen" >&6; } -if test "x$ac_cv_lib_svld_dlopen" = x""yes; then : - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 -$as_echo_n "checking for dld_link in -ldld... " >&6; } -if test "${ac_cv_lib_dld_dld_link+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldld $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dld_link (); -int -main () -{ -return dld_link (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dld_dld_link=yes -else - ac_cv_lib_dld_dld_link=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 -$as_echo "$ac_cv_lib_dld_dld_link" >&6; } -if test "x$ac_cv_lib_dld_dld_link" = x""yes; then : - lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" -fi - - -fi - - -fi - - -fi - - -fi - - -fi - - ;; - esac - - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else - enable_dlopen=no - fi - - case $lt_cv_dlopen in - dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - - save_LDFLAGS="$LDFLAGS" - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 -$as_echo_n "checking whether a program can dlopen itself... " >&6; } -if test "${lt_cv_dlopen_self+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - lt_cv_dlopen_self=cross -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF -#line 11082 "configure" -#include "confdefs.h" - -#if HAVE_DLFCN_H -#include -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -void fnord() { int i=42;} -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - /* dlclose (self); */ - } - else - puts (dlerror ()); - - return status; -} -_LT_EOF - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 - (eval $ac_link) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&5 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; - x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; - x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; - esac - else : - # compilation failed - lt_cv_dlopen_self=no - fi -fi -rm -fr conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 -$as_echo "$lt_cv_dlopen_self" >&6; } - - if test "x$lt_cv_dlopen_self" = xyes; then - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 -$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } -if test "${lt_cv_dlopen_self_static+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - lt_cv_dlopen_self_static=cross -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF -#line 11178 "configure" -#include "confdefs.h" - -#if HAVE_DLFCN_H -#include -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -void fnord() { int i=42;} -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - /* dlclose (self); */ - } - else - puts (dlerror ()); - - return status; -} -_LT_EOF - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 - (eval $ac_link) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&5 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; - esac - else : - # compilation failed - lt_cv_dlopen_self_static=no - fi -fi -rm -fr conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 -$as_echo "$lt_cv_dlopen_self_static" >&6; } - fi - - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" - ;; - esac - - case $lt_cv_dlopen_self in - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; - *) enable_dlopen_self=unknown ;; - esac - - case $lt_cv_dlopen_self_static in - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; - *) enable_dlopen_self_static=unknown ;; - esac -fi - - - - - - - - - - - - - - - - - -striplib= -old_striplib= -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 -$as_echo_n "checking whether stripping libraries is possible... " >&6; } -if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP" ; then - striplib="$STRIP -x" - old_striplib="$STRIP -S" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - fi - ;; - *) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - ;; - esac -fi - - - - - - - - - - - - - # Report which library types will actually be built - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 -$as_echo_n "checking if libtool supports shared libraries... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 -$as_echo "$can_build_shared" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 -$as_echo_n "checking whether to build shared libraries... " >&6; } - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - - aix[4-9]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 -$as_echo "$enable_shared" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 -$as_echo_n "checking whether to build static libraries... " >&6; } - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 -$as_echo "$enable_static" >&6; } - - - - -fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -CC="$lt_save_CC" - - - - - - - - - - - - - - ac_config_commands="$ac_config_commands libtool" - - - - -# Only expand once: - - - -# Check whether --enable-sdk was given. -if test "${enable_sdk+set}" = set; then : - enableval=$enable_sdk; - case "${enableval}" in - yes) IS_SDK=yes ;; - no) IS_SDK=no ;; - *) as_fn_error $? "bad value ${enableval} for --enable-sdk" "$LINENO" 5 ;; - esac - -else - IS_SDK=no -fi - - if test "x$IS_SDK" = "xyes"; then - IS_SDK_TRUE= - IS_SDK_FALSE='#' -else - IS_SDK_TRUE='#' - IS_SDK_FALSE= -fi - - -# Checks for libraries. - - - - - - -if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. -set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - case $PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -PKG_CONFIG=$ac_cv_path_PKG_CONFIG -if test -n "$PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 -$as_echo "$PKG_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_path_PKG_CONFIG"; then - ac_pt_PKG_CONFIG=$PKG_CONFIG - # Extract the first word of "pkg-config", so it can be a program name with args. -set dummy pkg-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - case $ac_pt_PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG -if test -n "$ac_pt_PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 -$as_echo "$ac_pt_PKG_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_pt_PKG_CONFIG" = x; then - PKG_CONFIG="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - PKG_CONFIG=$ac_pt_PKG_CONFIG - fi -else - PKG_CONFIG="$ac_cv_path_PKG_CONFIG" -fi - -fi -if test -n "$PKG_CONFIG"; then - _pkg_min_version=0.9.0 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 -$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } - if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - PKG_CONFIG="" - fi -fi - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for AVSYSTEM" >&5 -$as_echo_n "checking for AVSYSTEM... " >&6; } - -if test -n "$AVSYSTEM_CFLAGS"; then - pkg_cv_AVSYSTEM_CFLAGS="$AVSYSTEM_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"avsysaudio\""; } >&5 - ($PKG_CONFIG --exists --print-errors "avsysaudio") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_AVSYSTEM_CFLAGS=`$PKG_CONFIG --cflags "avsysaudio" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$AVSYSTEM_LIBS"; then - pkg_cv_AVSYSTEM_LIBS="$AVSYSTEM_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"avsysaudio\""; } >&5 - ($PKG_CONFIG --exists --print-errors "avsysaudio") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_AVSYSTEM_LIBS=`$PKG_CONFIG --libs "avsysaudio" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - AVSYSTEM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "avsysaudio" 2>&1` - else - AVSYSTEM_PKG_ERRORS=`$PKG_CONFIG --print-errors "avsysaudio" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$AVSYSTEM_PKG_ERRORS" >&5 - - as_fn_error $? "Package requirements (avsysaudio) were not met: - -$AVSYSTEM_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -Alternatively, you may set the environment variables AVSYSTEM_CFLAGS -and AVSYSTEM_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details." "$LINENO" 5 -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -Alternatively, you may set the environment variables AVSYSTEM_CFLAGS -and AVSYSTEM_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. - -To get pkg-config, see . -See \`config.log' for more details" "$LINENO" 5 ; } -else - AVSYSTEM_CFLAGS=$pkg_cv_AVSYSTEM_CFLAGS - AVSYSTEM_LIBS=$pkg_cv_AVSYSTEM_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -fi - - - - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MMCOMMON" >&5 -$as_echo_n "checking for MMCOMMON... " >&6; } - -if test -n "$MMCOMMON_CFLAGS"; then - pkg_cv_MMCOMMON_CFLAGS="$MMCOMMON_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"mm-common\""; } >&5 - ($PKG_CONFIG --exists --print-errors "mm-common") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_MMCOMMON_CFLAGS=`$PKG_CONFIG --cflags "mm-common" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$MMCOMMON_LIBS"; then - pkg_cv_MMCOMMON_LIBS="$MMCOMMON_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"mm-common\""; } >&5 - ($PKG_CONFIG --exists --print-errors "mm-common") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_MMCOMMON_LIBS=`$PKG_CONFIG --libs "mm-common" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - MMCOMMON_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "mm-common" 2>&1` - else - MMCOMMON_PKG_ERRORS=`$PKG_CONFIG --print-errors "mm-common" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$MMCOMMON_PKG_ERRORS" >&5 - - as_fn_error $? "Package requirements (mm-common) were not met: - -$MMCOMMON_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -Alternatively, you may set the environment variables MMCOMMON_CFLAGS -and MMCOMMON_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details." "$LINENO" 5 -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -Alternatively, you may set the environment variables MMCOMMON_CFLAGS -and MMCOMMON_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. - -To get pkg-config, see . -See \`config.log' for more details" "$LINENO" 5 ; } -else - MMCOMMON_CFLAGS=$pkg_cv_MMCOMMON_CFLAGS - MMCOMMON_LIBS=$pkg_cv_MMCOMMON_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -fi - - - -if test "x$IS_SDK" = "xyes"; -then -echo "SDK build does not use mm-log" -else - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MMLOG" >&5 -$as_echo_n "checking for MMLOG... " >&6; } - -if test -n "$MMLOG_CFLAGS"; then - pkg_cv_MMLOG_CFLAGS="$MMLOG_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"mm-log\""; } >&5 - ($PKG_CONFIG --exists --print-errors "mm-log") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_MMLOG_CFLAGS=`$PKG_CONFIG --cflags "mm-log" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$MMLOG_LIBS"; then - pkg_cv_MMLOG_LIBS="$MMLOG_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"mm-log\""; } >&5 - ($PKG_CONFIG --exists --print-errors "mm-log") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_MMLOG_LIBS=`$PKG_CONFIG --libs "mm-log" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - MMLOG_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "mm-log" 2>&1` - else - MMLOG_PKG_ERRORS=`$PKG_CONFIG --print-errors "mm-log" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$MMLOG_PKG_ERRORS" >&5 - - as_fn_error $? "Package requirements (mm-log) were not met: - -$MMLOG_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -Alternatively, you may set the environment variables MMLOG_CFLAGS -and MMLOG_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details." "$LINENO" 5 -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -Alternatively, you may set the environment variables MMLOG_CFLAGS -and MMLOG_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. - -To get pkg-config, see . -See \`config.log' for more details" "$LINENO" 5 ; } -else - MMLOG_CFLAGS=$pkg_cv_MMLOG_CFLAGS - MMLOG_LIBS=$pkg_cv_MMLOG_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -fi - - -fi - - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MMSESSION" >&5 -$as_echo_n "checking for MMSESSION... " >&6; } - -if test -n "$MMSESSION_CFLAGS"; then - pkg_cv_MMSESSION_CFLAGS="$MMSESSION_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"mm-session\""; } >&5 - ($PKG_CONFIG --exists --print-errors "mm-session") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_MMSESSION_CFLAGS=`$PKG_CONFIG --cflags "mm-session" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$MMSESSION_LIBS"; then - pkg_cv_MMSESSION_LIBS="$MMSESSION_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"mm-session\""; } >&5 - ($PKG_CONFIG --exists --print-errors "mm-session") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_MMSESSION_LIBS=`$PKG_CONFIG --libs "mm-session" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - MMSESSION_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "mm-session" 2>&1` - else - MMSESSION_PKG_ERRORS=`$PKG_CONFIG --print-errors "mm-session" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$MMSESSION_PKG_ERRORS" >&5 - - as_fn_error $? "Package requirements (mm-session) were not met: - -$MMSESSION_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -Alternatively, you may set the environment variables MMSESSION_CFLAGS -and MMSESSION_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details." "$LINENO" 5 -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -Alternatively, you may set the environment variables MMSESSION_CFLAGS -and MMSESSION_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. - -To get pkg-config, see . -See \`config.log' for more details" "$LINENO" 5 ; } -else - MMSESSION_CFLAGS=$pkg_cv_MMSESSION_CFLAGS - MMSESSION_LIBS=$pkg_cv_MMSESSION_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -fi - - - - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for AUDIOSESSIONMGR" >&5 -$as_echo_n "checking for AUDIOSESSIONMGR... " >&6; } - -if test -n "$AUDIOSESSIONMGR_CFLAGS"; then - pkg_cv_AUDIOSESSIONMGR_CFLAGS="$AUDIOSESSIONMGR_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"audio-session-mgr\""; } >&5 - ($PKG_CONFIG --exists --print-errors "audio-session-mgr") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_AUDIOSESSIONMGR_CFLAGS=`$PKG_CONFIG --cflags "audio-session-mgr" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$AUDIOSESSIONMGR_LIBS"; then - pkg_cv_AUDIOSESSIONMGR_LIBS="$AUDIOSESSIONMGR_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"audio-session-mgr\""; } >&5 - ($PKG_CONFIG --exists --print-errors "audio-session-mgr") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_AUDIOSESSIONMGR_LIBS=`$PKG_CONFIG --libs "audio-session-mgr" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - AUDIOSESSIONMGR_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "audio-session-mgr" 2>&1` - else - AUDIOSESSIONMGR_PKG_ERRORS=`$PKG_CONFIG --print-errors "audio-session-mgr" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$AUDIOSESSIONMGR_PKG_ERRORS" >&5 - - as_fn_error $? "Package requirements (audio-session-mgr) were not met: - -$AUDIOSESSIONMGR_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -Alternatively, you may set the environment variables AUDIOSESSIONMGR_CFLAGS -and AUDIOSESSIONMGR_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details." "$LINENO" 5 -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -Alternatively, you may set the environment variables AUDIOSESSIONMGR_CFLAGS -and AUDIOSESSIONMGR_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. - -To get pkg-config, see . -See \`config.log' for more details" "$LINENO" 5 ; } -else - AUDIOSESSIONMGR_CFLAGS=$pkg_cv_AUDIOSESSIONMGR_CFLAGS - AUDIOSESSIONMGR_LIBS=$pkg_cv_AUDIOSESSIONMGR_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -fi - - - - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLIB2" >&5 -$as_echo_n "checking for GLIB2... " >&6; } - -if test -n "$GLIB2_CFLAGS"; then - pkg_cv_GLIB2_CFLAGS="$GLIB2_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"glib-2.0 gthread-2.0\""; } >&5 - ($PKG_CONFIG --exists --print-errors "glib-2.0 gthread-2.0") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_GLIB2_CFLAGS=`$PKG_CONFIG --cflags "glib-2.0 gthread-2.0" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$GLIB2_LIBS"; then - pkg_cv_GLIB2_LIBS="$GLIB2_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"glib-2.0 gthread-2.0\""; } >&5 - ($PKG_CONFIG --exists --print-errors "glib-2.0 gthread-2.0") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_GLIB2_LIBS=`$PKG_CONFIG --libs "glib-2.0 gthread-2.0" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - GLIB2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "glib-2.0 gthread-2.0" 2>&1` - else - GLIB2_PKG_ERRORS=`$PKG_CONFIG --print-errors "glib-2.0 gthread-2.0" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$GLIB2_PKG_ERRORS" >&5 - - as_fn_error $? "Package requirements (glib-2.0 gthread-2.0) were not met: - -$GLIB2_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -Alternatively, you may set the environment variables GLIB2_CFLAGS -and GLIB2_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details." "$LINENO" 5 -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -Alternatively, you may set the environment variables GLIB2_CFLAGS -and GLIB2_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. - -To get pkg-config, see . -See \`config.log' for more details" "$LINENO" 5 ; } -else - GLIB2_CFLAGS=$pkg_cv_GLIB2_CFLAGS - GLIB2_LIBS=$pkg_cv_GLIB2_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -fi - - - - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for VCONF" >&5 -$as_echo_n "checking for VCONF... " >&6; } - -if test -n "$VCONF_CFLAGS"; then - pkg_cv_VCONF_CFLAGS="$VCONF_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"vconf\""; } >&5 - ($PKG_CONFIG --exists --print-errors "vconf") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_VCONF_CFLAGS=`$PKG_CONFIG --cflags "vconf" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$VCONF_LIBS"; then - pkg_cv_VCONF_LIBS="$VCONF_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"vconf\""; } >&5 - ($PKG_CONFIG --exists --print-errors "vconf") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_VCONF_LIBS=`$PKG_CONFIG --libs "vconf" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - VCONF_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "vconf" 2>&1` - else - VCONF_PKG_ERRORS=`$PKG_CONFIG --print-errors "vconf" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$VCONF_PKG_ERRORS" >&5 - - as_fn_error $? "Package requirements (vconf) were not met: - -$VCONF_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -Alternatively, you may set the environment variables VCONF_CFLAGS -and VCONF_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details." "$LINENO" 5 -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -Alternatively, you may set the environment variables VCONF_CFLAGS -and VCONF_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. - -To get pkg-config, see . -See \`config.log' for more details" "$LINENO" 5 ; } -else - VCONF_CFLAGS=$pkg_cv_VCONF_CFLAGS - VCONF_LIBS=$pkg_cv_VCONF_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -fi - - - - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for HEYNOTI" >&5 -$as_echo_n "checking for HEYNOTI... " >&6; } - -if test -n "$HEYNOTI_CFLAGS"; then - pkg_cv_HEYNOTI_CFLAGS="$HEYNOTI_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"heynoti\""; } >&5 - ($PKG_CONFIG --exists --print-errors "heynoti") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_HEYNOTI_CFLAGS=`$PKG_CONFIG --cflags "heynoti" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$HEYNOTI_LIBS"; then - pkg_cv_HEYNOTI_LIBS="$HEYNOTI_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"heynoti\""; } >&5 - ($PKG_CONFIG --exists --print-errors "heynoti") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_HEYNOTI_LIBS=`$PKG_CONFIG --libs "heynoti" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - HEYNOTI_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "heynoti" 2>&1` - else - HEYNOTI_PKG_ERRORS=`$PKG_CONFIG --print-errors "heynoti" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$HEYNOTI_PKG_ERRORS" >&5 - - as_fn_error $? "Package requirements (heynoti) were not met: - -$HEYNOTI_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -Alternatively, you may set the environment variables HEYNOTI_CFLAGS -and HEYNOTI_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details." "$LINENO" 5 -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -Alternatively, you may set the environment variables HEYNOTI_CFLAGS -and HEYNOTI_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. - -To get pkg-config, see . -See \`config.log' for more details" "$LINENO" 5 ; } -else - HEYNOTI_CFLAGS=$pkg_cv_HEYNOTI_CFLAGS - HEYNOTI_LIBS=$pkg_cv_HEYNOTI_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -fi - - - - -# Check whether --enable-pulse was given. -if test "${enable_pulse+set}" = set; then : - enableval=$enable_pulse; - case "${enableval}" in - yes) USE_PULSE=yes ;; - no) USE_PULSE=no ;; - *) as_fn_error $? "bad value ${enableval} for --enable-pulse" "$LINENO" 5 ;; - esac - -else - USE_PULSE=no -fi - -if test "x$USE_PULSE" = "xyes"; then - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PULSE" >&5 -$as_echo_n "checking for PULSE... " >&6; } - -if test -n "$PULSE_CFLAGS"; then - pkg_cv_PULSE_CFLAGS="$PULSE_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpulse\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libpulse") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_PULSE_CFLAGS=`$PKG_CONFIG --cflags "libpulse" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$PULSE_LIBS"; then - pkg_cv_PULSE_LIBS="$PULSE_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpulse\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libpulse") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_PULSE_LIBS=`$PKG_CONFIG --libs "libpulse" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - PULSE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libpulse" 2>&1` - else - PULSE_PKG_ERRORS=`$PKG_CONFIG --print-errors "libpulse" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$PULSE_PKG_ERRORS" >&5 - - as_fn_error $? "Package requirements (libpulse) were not met: - -$PULSE_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -Alternatively, you may set the environment variables PULSE_CFLAGS -and PULSE_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details." "$LINENO" 5 -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -Alternatively, you may set the environment variables PULSE_CFLAGS -and PULSE_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. - -To get pkg-config, see . -See \`config.log' for more details" "$LINENO" 5 ; } -else - PULSE_CFLAGS=$pkg_cv_PULSE_CFLAGS - PULSE_LIBS=$pkg_cv_PULSE_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -fi - - -fi - if test "x$USE_PULSE" = "xyes"; then - USE_PULSE_TRUE= - USE_PULSE_FALSE='#' -else - USE_PULSE_TRUE='#' - USE_PULSE_FALSE= -fi - - - -# Checks for header files. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -for ac_header in fcntl.h memory.h stdlib.h string.h sys/time.h unistd.h errno.h sys/types.h sys/stat.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -# Checks for typedefs, structures, and compiler characteristics. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 -$as_echo_n "checking for an ANSI C-conforming const... " >&6; } -if test "${ac_cv_c_const+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -/* FIXME: Include the comments suggested by Paul. */ -#ifndef __cplusplus - /* Ultrix mips cc rejects this. */ - typedef int charset[2]; - const charset cs; - /* SunOS 4.1.1 cc rejects this. */ - char const *const *pcpcc; - char **ppc; - /* NEC SVR4.0.2 mips cc rejects this. */ - struct point {int x, y;}; - static struct point const zero = {0,0}; - /* AIX XL C 1.02.0.0 rejects this. - It does not let you subtract one const X* pointer from another in - an arm of an if-expression whose if-part is not a constant - expression */ - const char *g = "string"; - pcpcc = &g + (g ? g-g : 0); - /* HPUX 7.0 cc rejects these. */ - ++pcpcc; - ppc = (char**) pcpcc; - pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this. */ - char *t; - char const *s = 0 ? (char *) 0 : (char const *) 0; - - *t++ = 0; - if (s) return 0; - } - { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ - int x[] = {25, 17}; - const int *foo = &x[0]; - ++foo; - } - { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ - typedef const int *iptr; - iptr p = 0; - ++p; - } - { /* AIX XL C 1.02.0.0 rejects this saying - "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; }; - struct s *b; b->j = 5; - } - { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ - const int foo = 10; - if (!foo) return 0; - } - return !cs[0] && !zero.x; -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_const=yes -else - ac_cv_c_const=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 -$as_echo "$ac_cv_c_const" >&6; } -if test $ac_cv_c_const = no; then - -$as_echo "#define const /**/" >>confdefs.h - -fi - -ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" -if test "x$ac_cv_type_pid_t" = x""yes; then : - -else - -cat >>confdefs.h <<_ACEOF -#define pid_t int -_ACEOF - -fi - -ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" -if test "x$ac_cv_type_size_t" = x""yes; then : - -else - -cat >>confdefs.h <<_ACEOF -#define size_t unsigned int -_ACEOF - -fi - - -# Checks for library functions. -# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works -# for constant arguments. Useless! -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 -$as_echo_n "checking for working alloca.h... " >&6; } -if test "${ac_cv_working_alloca_h+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -char *p = (char *) alloca (2 * sizeof (int)); - if (p) return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_working_alloca_h=yes -else - ac_cv_working_alloca_h=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 -$as_echo "$ac_cv_working_alloca_h" >&6; } -if test $ac_cv_working_alloca_h = yes; then - -$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 -$as_echo_n "checking for alloca... " >&6; } -if test "${ac_cv_func_alloca_works+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __GNUC__ -# define alloca __builtin_alloca -#else -# ifdef _MSC_VER -# include -# define alloca _alloca -# else -# ifdef HAVE_ALLOCA_H -# include -# else -# ifdef _AIX - #pragma alloca -# else -# ifndef alloca /* predefined by HP cc +Olibcalls */ -char *alloca (); -# endif -# endif -# endif -# endif -#endif - -int -main () -{ -char *p = (char *) alloca (1); - if (p) return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_func_alloca_works=yes -else - ac_cv_func_alloca_works=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 -$as_echo "$ac_cv_func_alloca_works" >&6; } - -if test $ac_cv_func_alloca_works = yes; then - -$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h - -else - # The SVR3 libPW and SVR4 libucb both contain incompatible functions -# that cause trouble. Some versions do not even contain alloca or -# contain a buggy version. If you still want to use their alloca, -# use ar to extract alloca.o from them instead of compiling alloca.c. - -ALLOCA=\${LIBOBJDIR}alloca.$ac_objext - -$as_echo "#define C_ALLOCA 1" >>confdefs.h - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 -$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } -if test "${ac_cv_os_cray+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#if defined CRAY && ! defined CRAY2 -webecray -#else -wenotbecray -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "webecray" >/dev/null 2>&1; then : - ac_cv_os_cray=yes -else - ac_cv_os_cray=no -fi -rm -f conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 -$as_echo "$ac_cv_os_cray" >&6; } -if test $ac_cv_os_cray = yes; then - for ac_func in _getb67 GETB67 getb67; do - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - -cat >>confdefs.h <<_ACEOF -#define CRAY_STACKSEG_END $ac_func -_ACEOF - - break -fi - - done -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 -$as_echo_n "checking stack direction for C alloca... " >&6; } -if test "${ac_cv_c_stack_direction+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_c_stack_direction=0 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -find_stack_direction () -{ - static char *addr = 0; - auto char dummy; - if (addr == 0) - { - addr = &dummy; - return find_stack_direction (); - } - else - return (&dummy > addr) ? 1 : -1; -} - -int -main () -{ - return find_stack_direction () < 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_c_stack_direction=1 -else - ac_cv_c_stack_direction=-1 -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 -$as_echo "$ac_cv_c_stack_direction" >&6; } -cat >>confdefs.h <<_ACEOF -#define STACK_DIRECTION $ac_cv_c_stack_direction -_ACEOF - - -fi - -for ac_header in vfork.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "vfork.h" "ac_cv_header_vfork_h" "$ac_includes_default" -if test "x$ac_cv_header_vfork_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_VFORK_H 1 -_ACEOF - -fi - -done - -for ac_func in fork vfork -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - -if test "x$ac_cv_func_fork" = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working fork" >&5 -$as_echo_n "checking for working fork... " >&6; } -if test "${ac_cv_func_fork_works+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_fork_works=cross -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ - - /* By Ruediger Kuhlmann. */ - return fork () < 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_fork_works=yes -else - ac_cv_func_fork_works=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_fork_works" >&5 -$as_echo "$ac_cv_func_fork_works" >&6; } - -else - ac_cv_func_fork_works=$ac_cv_func_fork -fi -if test "x$ac_cv_func_fork_works" = xcross; then - case $host in - *-*-amigaos* | *-*-msdosdjgpp*) - # Override, as these systems have only a dummy fork() stub - ac_cv_func_fork_works=no - ;; - *) - ac_cv_func_fork_works=yes - ;; - esac - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&5 -$as_echo "$as_me: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&2;} -fi -ac_cv_func_vfork_works=$ac_cv_func_vfork -if test "x$ac_cv_func_vfork" = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working vfork" >&5 -$as_echo_n "checking for working vfork... " >&6; } -if test "${ac_cv_func_vfork_works+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_vfork_works=cross -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Thanks to Paul Eggert for this test. */ -$ac_includes_default -#include -#ifdef HAVE_VFORK_H -# include -#endif -/* On some sparc systems, changes by the child to local and incoming - argument registers are propagated back to the parent. The compiler - is told about this with #include , but some compilers - (e.g. gcc -O) don't grok . Test for this by using a - static variable whose address is put into a register that is - clobbered by the vfork. */ -static void -#ifdef __cplusplus -sparc_address_test (int arg) -# else -sparc_address_test (arg) int arg; -#endif -{ - static pid_t child; - if (!child) { - child = vfork (); - if (child < 0) { - perror ("vfork"); - _exit(2); - } - if (!child) { - arg = getpid(); - write(-1, "", 0); - _exit (arg); - } - } -} - -int -main () -{ - pid_t parent = getpid (); - pid_t child; - - sparc_address_test (0); - - child = vfork (); - - if (child == 0) { - /* Here is another test for sparc vfork register problems. This - test uses lots of local variables, at least as many local - variables as main has allocated so far including compiler - temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris - 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should - reuse the register of parent for one of the local variables, - since it will think that parent can't possibly be used any more - in this routine. Assigning to the local variable will thus - munge parent in the parent process. */ - pid_t - p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(), - p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid(); - /* Convince the compiler that p..p7 are live; otherwise, it might - use the same hardware register for all 8 local variables. */ - if (p != p1 || p != p2 || p != p3 || p != p4 - || p != p5 || p != p6 || p != p7) - _exit(1); - - /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent - from child file descriptors. If the child closes a descriptor - before it execs or exits, this munges the parent's descriptor - as well. Test for this by closing stdout in the child. */ - _exit(close(fileno(stdout)) != 0); - } else { - int status; - struct stat st; - - while (wait(&status) != child) - ; - return ( - /* Was there some problem with vforking? */ - child < 0 - - /* Did the child fail? (This shouldn't happen.) */ - || status - - /* Did the vfork/compiler bug occur? */ - || parent != getpid() - - /* Did the file descriptor bug occur? */ - || fstat(fileno(stdout), &st) != 0 - ); - } -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_vfork_works=yes -else - ac_cv_func_vfork_works=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_vfork_works" >&5 -$as_echo "$ac_cv_func_vfork_works" >&6; } - -fi; -if test "x$ac_cv_func_fork_works" = xcross; then - ac_cv_func_vfork_works=$ac_cv_func_vfork - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&5 -$as_echo "$as_me: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&2;} -fi - -if test "x$ac_cv_func_vfork_works" = xyes; then - -$as_echo "#define HAVE_WORKING_VFORK 1" >>confdefs.h - -else - -$as_echo "#define vfork fork" >>confdefs.h - -fi -if test "x$ac_cv_func_fork_works" = xyes; then - -$as_echo "#define HAVE_WORKING_FORK 1" >>confdefs.h - -fi - -for ac_header in stdlib.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" -if test "x$ac_cv_header_stdlib_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STDLIB_H 1 -_ACEOF - -fi - -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 -$as_echo_n "checking for GNU libc compatible malloc... " >&6; } -if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_malloc_0_nonnull=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#if defined STDC_HEADERS || defined HAVE_STDLIB_H -# include -#else -char *malloc (); -#endif - -int -main () -{ -return ! malloc (0); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_malloc_0_nonnull=yes -else - ac_cv_func_malloc_0_nonnull=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5 -$as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } -if test $ac_cv_func_malloc_0_nonnull = yes; then : - -$as_echo "#define HAVE_MALLOC 1" >>confdefs.h - -else - $as_echo "#define HAVE_MALLOC 0" >>confdefs.h - - case " $LIBOBJS " in - *" malloc.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS malloc.$ac_objext" - ;; -esac - - -$as_echo "#define malloc rpl_malloc" >>confdefs.h - -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working memcmp" >&5 -$as_echo_n "checking for working memcmp... " >&6; } -if test "${ac_cv_func_memcmp_working+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_memcmp_working=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ - - /* Some versions of memcmp are not 8-bit clean. */ - char c0 = '\100', c1 = '\200', c2 = '\201'; - if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0) - return 1; - - /* The Next x86 OpenStep bug shows up only when comparing 16 bytes - or more and with at least one buffer not starting on a 4-byte boundary. - William Lewis provided this test program. */ - { - char foo[21]; - char bar[21]; - int i; - for (i = 0; i < 4; i++) - { - char *a = foo + i; - char *b = bar + i; - strcpy (a, "--------01111111"); - strcpy (b, "--------10000000"); - if (memcmp (a, b, 16) >= 0) - return 1; - } - return 0; - } - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_memcmp_working=yes -else - ac_cv_func_memcmp_working=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_memcmp_working" >&5 -$as_echo "$ac_cv_func_memcmp_working" >&6; } -test $ac_cv_func_memcmp_working = no && case " $LIBOBJS " in - *" memcmp.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS memcmp.$ac_objext" - ;; -esac - - -for ac_header in sys/select.h sys/socket.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking types of arguments for select" >&5 -$as_echo_n "checking types of arguments for select... " >&6; } -if test "${ac_cv_func_select_args+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - for ac_arg234 in 'fd_set *' 'int *' 'void *'; do - for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do - for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -#ifdef HAVE_SYS_SELECT_H -# include -#endif -#ifdef HAVE_SYS_SOCKET_H -# include -#endif - -int -main () -{ -extern int select ($ac_arg1, - $ac_arg234, $ac_arg234, $ac_arg234, - $ac_arg5); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3 -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done - done -done -# Provide a safe default value. -: ${ac_cv_func_select_args='int,int *,struct timeval *'} - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_select_args" >&5 -$as_echo "$ac_cv_func_select_args" >&6; } -ac_save_IFS=$IFS; IFS=',' -set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'` -IFS=$ac_save_IFS -shift - -cat >>confdefs.h <<_ACEOF -#define SELECT_TYPE_ARG1 $1 -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define SELECT_TYPE_ARG234 ($2) -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define SELECT_TYPE_ARG5 ($3) -_ACEOF - -rm -f conftest* - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 -$as_echo_n "checking return type of signal handlers... " >&6; } -if test "${ac_cv_type_signal+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include - -int -main () -{ -return *(signal (0, 0)) (0) == 1; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_type_signal=int -else - ac_cv_type_signal=void -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 -$as_echo "$ac_cv_type_signal" >&6; } - -cat >>confdefs.h <<_ACEOF -#define RETSIGTYPE $ac_cv_type_signal -_ACEOF - - -for ac_func in memset select -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - -ac_config_files="$ac_config_files common/Makefile Makefile server/Makefile server/plugin/Makefile server/plugin/wav/Makefile server/plugin/keytone/Makefile server/plugin/headset/Makefile server/plugin/tone/Makefile pkgconfig/Makefile pkgconfig/mm-sound.pc pkgconfig/mm-keysound.pc pkgconfig-sdk/Makefile pkgconfig-sdk/mm-sound.pc pkgconfig-sdk/mm-keysound.pc testsuite/Makefile init/Makefile" - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - - (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes: double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \. - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) | - sed ' - /^ac_cv_env_/b end - t clear - :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && - { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 -$as_echo "$as_me: updating cache $cache_file" >&6;} - cat confcache >$cache_file - else - { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 -$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -DEFS=-DHAVE_CONFIG_H - -ac_libobjs= -ac_ltlibobjs= -U= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`$as_echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" - as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - - if test -n "$EXEEXT"; then - am__EXEEXT_TRUE= - am__EXEEXT_FALSE='#' -else - am__EXEEXT_TRUE='#' - am__EXEEXT_FALSE= -fi - -if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then - as_fn_error $? "conditional \"AMDEP\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then - as_fn_error $? "conditional \"am__fastdepCC\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${IS_SDK_TRUE}" && test -z "${IS_SDK_FALSE}"; then - as_fn_error $? "conditional \"IS_SDK\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${USE_PULSE_TRUE}" && test -z "${USE_PULSE_FALSE}"; then - as_fn_error $? "conditional \"USE_PULSE\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi - -: ${CONFIG_STATUS=./config.status} -ac_write_fail=0 -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -as_write_fail=0 -cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false - -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -p' - fi -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 -## ----------------------------------- ## -## Main body of $CONFIG_STATUS script. ## -## ----------------------------------- ## -_ASEOF -test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# Save the log message, to keep $0 and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by avsystem $as_me 1.0, which was -generated by GNU Autoconf 2.67. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -_ACEOF - -case $ac_config_files in *" -"*) set x $ac_config_files; shift; ac_config_files=$*;; -esac - -case $ac_config_headers in *" -"*) set x $ac_config_headers; shift; ac_config_headers=$*;; -esac - - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# Files that config.status was made for. -config_files="$ac_config_files" -config_headers="$ac_config_headers" -config_commands="$ac_config_commands" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -ac_cs_usage="\ -\`$as_me' instantiates files and other configuration actions -from templates according to the current configuration. Unless the files -and actions are specified as TAGs, all are instantiated by default. - -Usage: $0 [OPTION]... [TAG]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - --config print configuration, then exit - -q, --quiet, --silent - do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - --header=FILE[:TEMPLATE] - instantiate the configuration header FILE - -Configuration files: -$config_files - -Configuration headers: -$config_headers - -Configuration commands: -$config_commands - -Report bugs to the package provider." - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" -ac_cs_version="\\ -avsystem config.status 1.0 -configured by $0, generated by GNU Autoconf 2.67, - with options \\"\$ac_cs_config\\" - -Copyright (C) 2010 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -INSTALL='$INSTALL' -MKDIR_P='$MKDIR_P' -AWK='$AWK' -test -n "\$AWK" || AWK=awk -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# The default lists apply if the user does not specify any file. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=?*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - --*=) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg= - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - $as_echo "$ac_cs_version"; exit ;; - --config | --confi | --conf | --con | --co | --c ) - $as_echo "$ac_cs_config"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - '') as_fn_error $? "missing file argument" ;; - esac - as_fn_append CONFIG_FILES " '$ac_optarg'" - ac_need_defaults=false;; - --header | --heade | --head | --hea ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - as_fn_append CONFIG_HEADERS " '$ac_optarg'" - ac_need_defaults=false;; - --he | --h) - # Conflict between --help and --header - as_fn_error $? "ambiguous option: \`$1' -Try \`$0 --help' for more information.";; - --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) as_fn_error $? "unrecognized option: \`$1' -Try \`$0 --help' for more information." ;; - - *) as_fn_append ac_config_targets " $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion - shift - \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 - CONFIG_SHELL='$SHELL' - export CONFIG_SHELL - exec "\$@" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - $as_echo "$ac_log" -} >&5 - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# -# INIT-COMMANDS -# -AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" - - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -sed_quote_subst='$sed_quote_subst' -double_quote_subst='$double_quote_subst' -delay_variable_subst='$delay_variable_subst' -macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`' -macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`' -enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`' -enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`' -pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`' -enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`' -host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`' -host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`' -host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`' -build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`' -build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`' -build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`' -SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`' -Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`' -GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`' -EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`' -FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`' -LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`' -NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`' -LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`' -max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`' -ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`' -exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`' -lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`' -lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`' -lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`' -reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`' -reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`' -OBJDUMP='`$ECHO "X$OBJDUMP" | $Xsed -e "$delay_single_quote_subst"`' -deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`' -file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`' -AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`' -AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`' -STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`' -RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`' -old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' -old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' -old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' -CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`' -CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`' -compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`' -GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' -objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`' -SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`' -ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`' -MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`' -lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`' -lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`' -lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`' -lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`' -need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`' -DSYMUTIL='`$ECHO "X$DSYMUTIL" | $Xsed -e "$delay_single_quote_subst"`' -NMEDIT='`$ECHO "X$NMEDIT" | $Xsed -e "$delay_single_quote_subst"`' -LIPO='`$ECHO "X$LIPO" | $Xsed -e "$delay_single_quote_subst"`' -OTOOL='`$ECHO "X$OTOOL" | $Xsed -e "$delay_single_quote_subst"`' -OTOOL64='`$ECHO "X$OTOOL64" | $Xsed -e "$delay_single_quote_subst"`' -libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`' -shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`' -extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' -archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`' -enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`' -export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' -whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' -compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`' -old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`' -old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' -archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' -archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' -module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`' -module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' -with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`' -allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' -no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`' -inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`' -link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`' -fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`' -always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`' -export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`' -exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`' -include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`' -prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`' -file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`' -variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`' -need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' -need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`' -version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`' -runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`' -shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' -shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`' -libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`' -library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`' -soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`' -postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' -postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' -finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`' -finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`' -sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`' -sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`' -enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`' -enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`' -enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`' -old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`' -striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`' - -LTCC='$LTCC' -LTCFLAGS='$LTCFLAGS' -compiler='$compiler_DEFAULT' - -# Quote evaled strings. -for var in SED \ -GREP \ -EGREP \ -FGREP \ -LD \ -NM \ -LN_S \ -lt_SP2NL \ -lt_NL2SP \ -reload_flag \ -OBJDUMP \ -deplibs_check_method \ -file_magic_cmd \ -AR \ -AR_FLAGS \ -STRIP \ -RANLIB \ -CC \ -CFLAGS \ -compiler \ -lt_cv_sys_global_symbol_pipe \ -lt_cv_sys_global_symbol_to_cdecl \ -lt_cv_sys_global_symbol_to_c_name_address \ -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ -SHELL \ -ECHO \ -lt_prog_compiler_no_builtin_flag \ -lt_prog_compiler_wl \ -lt_prog_compiler_pic \ -lt_prog_compiler_static \ -lt_cv_prog_compiler_c_o \ -need_locks \ -DSYMUTIL \ -NMEDIT \ -LIPO \ -OTOOL \ -OTOOL64 \ -shrext_cmds \ -export_dynamic_flag_spec \ -whole_archive_flag_spec \ -compiler_needs_object \ -with_gnu_ld \ -allow_undefined_flag \ -no_undefined_flag \ -hardcode_libdir_flag_spec \ -hardcode_libdir_flag_spec_ld \ -hardcode_libdir_separator \ -fix_srcfile_path \ -exclude_expsyms \ -include_expsyms \ -file_list_spec \ -variables_saved_for_relink \ -libname_spec \ -library_names_spec \ -soname_spec \ -finish_eval \ -old_striplib \ -striplib; do - case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in - *[\\\\\\\`\\"\\\$]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Double-quote double-evaled strings. -for var in reload_cmds \ -old_postinstall_cmds \ -old_postuninstall_cmds \ -old_archive_cmds \ -extract_expsyms_cmds \ -old_archive_from_new_cmds \ -old_archive_from_expsyms_cmds \ -archive_cmds \ -archive_expsym_cmds \ -module_cmds \ -module_expsym_cmds \ -export_symbols_cmds \ -prelink_cmds \ -postinstall_cmds \ -postuninstall_cmds \ -finish_cmds \ -sys_lib_search_path_spec \ -sys_lib_dlsearch_path_spec; do - case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in - *[\\\\\\\`\\"\\\$]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Fix-up fallback echo if it was mangled by the above quoting rules. -case \$lt_ECHO in -*'\\\$0 --fallback-echo"') lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\` - ;; -esac - -ac_aux_dir='$ac_aux_dir' -xsi_shell='$xsi_shell' -lt_shell_append='$lt_shell_append' - -# See if we are running on zsh, and set the options which allow our -# commands through without removal of \ escapes INIT. -if test -n "\${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi - - - PACKAGE='$PACKAGE' - VERSION='$VERSION' - TIMESTAMP='$TIMESTAMP' - RM='$RM' - ofile='$ofile' - - - - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.hin" ;; - "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; - "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; - "common/Makefile") CONFIG_FILES="$CONFIG_FILES common/Makefile" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "server/Makefile") CONFIG_FILES="$CONFIG_FILES server/Makefile" ;; - "server/plugin/Makefile") CONFIG_FILES="$CONFIG_FILES server/plugin/Makefile" ;; - "server/plugin/wav/Makefile") CONFIG_FILES="$CONFIG_FILES server/plugin/wav/Makefile" ;; - "server/plugin/keytone/Makefile") CONFIG_FILES="$CONFIG_FILES server/plugin/keytone/Makefile" ;; - "server/plugin/headset/Makefile") CONFIG_FILES="$CONFIG_FILES server/plugin/headset/Makefile" ;; - "server/plugin/tone/Makefile") CONFIG_FILES="$CONFIG_FILES server/plugin/tone/Makefile" ;; - "pkgconfig/Makefile") CONFIG_FILES="$CONFIG_FILES pkgconfig/Makefile" ;; - "pkgconfig/mm-sound.pc") CONFIG_FILES="$CONFIG_FILES pkgconfig/mm-sound.pc" ;; - "pkgconfig/mm-keysound.pc") CONFIG_FILES="$CONFIG_FILES pkgconfig/mm-keysound.pc" ;; - "pkgconfig-sdk/Makefile") CONFIG_FILES="$CONFIG_FILES pkgconfig-sdk/Makefile" ;; - "pkgconfig-sdk/mm-sound.pc") CONFIG_FILES="$CONFIG_FILES pkgconfig-sdk/mm-sound.pc" ;; - "pkgconfig-sdk/mm-keysound.pc") CONFIG_FILES="$CONFIG_FILES pkgconfig-sdk/mm-keysound.pc" ;; - "testsuite/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/Makefile" ;; - "init/Makefile") CONFIG_FILES="$CONFIG_FILES init/Makefile" ;; - - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers - test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= - trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status -' 0 - trap 'as_fn_exit 1' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 - -# Set up the scripts for CONFIG_FILES section. -# No need to generate them if there are no CONFIG_FILES. -# This happens for instance with `./config.status config.h'. -if test -n "$CONFIG_FILES"; then - - -ac_cr=`echo X | tr X '\015'` -# On cygwin, bash can eat \r inside `` if the user requested igncr. -# But we know of no other shell where ac_cr would be empty at this -# point, so we can use a bashism as a fallback. -if test "x$ac_cr" = x; then - eval ac_cr=\$\'\\r\' -fi -ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` -if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\\r' -else - ac_cs_awk_cr=$ac_cr -fi - -echo 'BEGIN {' >"$tmp/subs1.awk" && -_ACEOF - - -{ - echo "cat >conf$$subs.awk <<_ACEOF" && - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" -} >conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - . ./conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - - ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` - if test $ac_delim_n = $ac_delim_num; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done -rm -f conf$$subs.sh - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$tmp/subs1.awk" <<\\_ACAWK && -_ACEOF -sed -n ' -h -s/^/S["/; s/!.*/"]=/ -p -g -s/^[^!]*!// -:repl -t repl -s/'"$ac_delim"'$// -t delim -:nl -h -s/\(.\{148\}\)..*/\1/ -t more1 -s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ -p -n -b repl -:more1 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t nl -:delim -h -s/\(.\{148\}\)..*/\1/ -t more2 -s/["\\]/\\&/g; s/^/"/; s/$/"/ -p -b -:more2 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t delim -' >$CONFIG_STATUS || ac_write_fail=1 -rm -f conf$$subs.awk -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACAWK -cat >>"\$tmp/subs1.awk" <<_ACAWK && - for (key in S) S_is_set[key] = 1 - FS = "" - -} -{ - line = $ 0 - nfields = split(line, field, "@") - substed = 0 - len = length(field[1]) - for (i = 2; i < nfields; i++) { - key = field[i] - keylen = length(key) - if (S_is_set[key]) { - value = S[key] - line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) - len += length(value) + length(field[++i]) - substed = 1 - } else - len += 1 + keylen - } - - print line -} - -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then - sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" -else - cat -fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 -_ACEOF - -# VPATH may cause trouble with some makes, so we remove sole $(srcdir), -# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ -h -s/// -s/^/:/ -s/[ ]*$/:/ -s/:\$(srcdir):/:/g -s/:\${srcdir}:/:/g -s/:@srcdir@:/:/g -s/^:*// -s/:*$// -x -s/\(=[ ]*\).*/\1/ -G -s/\n// -s/^[^=]*=[ ]*$// -}' -fi - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -fi # test -n "$CONFIG_FILES" - -# Set up the scripts for CONFIG_HEADERS section. -# No need to generate them if there are no CONFIG_HEADERS. -# This happens for instance with `./config.status Makefile'. -if test -n "$CONFIG_HEADERS"; then -cat >"$tmp/defines.awk" <<\_ACAWK || -BEGIN { -_ACEOF - -# Transform confdefs.h into an awk script `defines.awk', embedded as -# here-document in config.status, that substitutes the proper values into -# config.h.in to produce config.h. - -# Create a delimiter string that does not exist in confdefs.h, to ease -# handling of long lines. -ac_delim='%!_!# ' -for ac_last_try in false false :; do - ac_t=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_t"; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done - -# For the awk script, D is an array of macro values keyed by name, -# likewise P contains macro parameters if any. Preserve backslash -# newline sequences. - -ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* -sed -n ' -s/.\{148\}/&'"$ac_delim"'/g -t rset -:rset -s/^[ ]*#[ ]*define[ ][ ]*/ / -t def -d -:def -s/\\$// -t bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3"/p -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p -d -:bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3\\\\\\n"\\/p -t cont -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p -t cont -d -:cont -n -s/.\{148\}/&'"$ac_delim"'/g -t clear -:clear -s/\\$// -t bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/"/p -d -:bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p -b cont -' >$CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - for (key in D) D_is_set[key] = 1 - FS = "" -} -/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { - line = \$ 0 - split(line, arg, " ") - if (arg[1] == "#") { - defundef = arg[2] - mac1 = arg[3] - } else { - defundef = substr(arg[1], 2) - mac1 = arg[2] - } - split(mac1, mac2, "(") #) - macro = mac2[1] - prefix = substr(line, 1, index(line, defundef) - 1) - if (D_is_set[macro]) { - # Preserve the white space surrounding the "#". - print prefix "define", macro P[macro] D[macro] - next - } else { - # Replace #undef with comments. This is necessary, for example, - # in the case of _POSIX_SOURCE, which is predefined and required - # on some systems where configure will not decide to define it. - if (defundef == "undef") { - print "/*", prefix defundef, macro, "*/" - next - } - } -} -{ print } -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 -fi # test -n "$CONFIG_HEADERS" - - -eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" -shift -for ac_tag -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; - esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - as_fn_append ac_file_inputs " '$ac_f'" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input='Generated from '` - $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' - `' by configure.' - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 -$as_echo "$as_me: creating $ac_file" >&6;} - fi - # Neutralize special characters interpreted by sed in replacement strings. - case $configure_input in #( - *\&* | *\|* | *\\* ) - ac_sed_conf_input=`$as_echo "$configure_input" | - sed 's/[\\\\&|]/\\\\&/g'`;; #( - *) ac_sed_conf_input=$configure_input;; - esac - - case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir="$ac_dir"; as_fn_mkdir_p - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - - case $INSTALL in - [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; - esac - ac_MKDIR_P=$MKDIR_P - case $MKDIR_P in - [\\/$]* | ?:[\\/]* ) ;; - */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; - esac -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= -ac_sed_dataroot=' -/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p' -case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac -_ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_sed_extra="$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s|@configure_input@|$ac_sed_conf_input|;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@top_build_prefix@&$ac_top_build_prefix&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -s&@INSTALL@&$ac_INSTALL&;t t -s&@MKDIR_P@&$ac_MKDIR_P&;t t -$ac_datarootdir_hack -" -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&5 -$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&2;} - - rm -f "$tmp/stdin" - case $ac_file in - -) cat "$tmp/out" && rm -f "$tmp/out";; - *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; - esac \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - ;; - :H) - # - # CONFIG_HEADER - # - if test x"$ac_file" != x-; then - { - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" - } >"$tmp/config.h" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 -$as_echo "$as_me: $ac_file is unchanged" >&6;} - else - rm -f "$ac_file" - mv "$tmp/config.h" "$ac_file" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - fi - else - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ - || as_fn_error $? "could not create -" "$LINENO" 5 - fi -# Compute "$ac_file"'s index in $config_headers. -_am_arg="$ac_file" -_am_stamp_count=1 -for _am_header in $config_headers :; do - case $_am_header in - $_am_arg | $_am_arg:* ) - break ;; - * ) - _am_stamp_count=`expr $_am_stamp_count + 1` ;; - esac -done -echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || -$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$_am_arg" : 'X\(//\)[^/]' \| \ - X"$_am_arg" : 'X\(//\)$' \| \ - X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$_am_arg" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'`/stamp-h$_am_stamp_count - ;; - - :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 -$as_echo "$as_me: executing $ac_file commands" >&6;} - ;; - esac - - - case $ac_file$ac_mode in - "depfiles":C) test x"$AMDEP_TRUE" != x"" || { - # Autoconf 2.62 quotes --file arguments for eval, but not when files - # are listed without --file. Let's play safe and only enable the eval - # if we detect the quoting. - case $CONFIG_FILES in - *\'*) eval set x "$CONFIG_FILES" ;; - *) set x $CONFIG_FILES ;; - esac - shift - for mf - do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named `Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line - # limit of 2048, but all sed's we know have understand at least 4000. - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then - dirpart=`$as_dirname -- "$mf" || -$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$mf" : 'X\(//\)[^/]' \| \ - X"$mf" : 'X\(//\)$' \| \ - X"$mf" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$mf" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running `make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n 's/^U = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`$as_dirname -- "$file" || -$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$file" : 'X\(//\)[^/]' \| \ - X"$file" : 'X\(//\)$' \| \ - X"$file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir=$dirpart/$fdir; as_fn_mkdir_p - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done - done -} - ;; - "libtool":C) - - # See if we are running on zsh, and set the options which allow our - # commands through without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST - fi - - cfgfile="${ofile}T" - trap "$RM \"$cfgfile\"; exit 1" 1 2 15 - $RM "$cfgfile" - - cat <<_LT_EOF >> "$cfgfile" -#! $SHELL - -# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008 Free Software Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is part of GNU Libtool. -# -# GNU Libtool is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, or -# obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - -# The names of the tagged configurations supported by this script. -available_tags="" - -# ### BEGIN LIBTOOL CONFIG - -# Which release of libtool.m4 was used? -macro_version=$macro_version -macro_revision=$macro_revision - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# What type of objects to build. -pic_mode=$pic_mode - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# The host system. -host_alias=$host_alias -host=$host -host_os=$host_os - -# The build system. -build_alias=$build_alias -build=$build -build_os=$build_os - -# A sed program that does not truncate output. -SED=$lt_SED - -# Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="\$SED -e 1s/^X//" - -# A grep program that handles long lines. -GREP=$lt_GREP - -# An ERE matcher. -EGREP=$lt_EGREP - -# A literal string matcher. -FGREP=$lt_FGREP - -# A BSD- or MS-compatible name lister. -NM=$lt_NM - -# Whether we need soft or hard links. -LN_S=$lt_LN_S - -# What is the maximum length of a command? -max_cmd_len=$max_cmd_len - -# Object file suffix (normally "o"). -objext=$ac_objext - -# Executable file suffix (normally ""). -exeext=$exeext - -# whether the shell understands "unset". -lt_unset=$lt_unset - -# turn spaces into newlines. -SP2NL=$lt_lt_SP2NL - -# turn newlines into spaces. -NL2SP=$lt_lt_NL2SP - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# An object symbol dumper. -OBJDUMP=$lt_OBJDUMP - -# Method to check whether dependent libraries are shared objects. -deplibs_check_method=$lt_deplibs_check_method - -# Command to use when deplibs_check_method == "file_magic". -file_magic_cmd=$lt_file_magic_cmd - -# The archiver. -AR=$lt_AR -AR_FLAGS=$lt_AR_FLAGS - -# A symbol stripping program. -STRIP=$lt_STRIP - -# Commands used to install an old-style archive. -RANLIB=$lt_RANLIB -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# A C compiler. -LTCC=$lt_CC - -# LTCC compiler flags. -LTCFLAGS=$lt_CFLAGS - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe - -# Transform the output of nm in a proper C declaration. -global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl - -# Transform the output of nm in a C name address pair. -global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - -# Transform the output of nm in a C name address pair when lib prefix is needed. -global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# An echo program that does not interpret backslashes. -ECHO=$lt_ECHO - -# Used to examine libraries when file_magic_cmd begins with "file". -MAGIC_CMD=$MAGIC_CMD - -# Must we lock files when doing compilation? -need_locks=$lt_need_locks - -# Tool to manipulate archived DWARF debug symbol files on Mac OS X. -DSYMUTIL=$lt_DSYMUTIL - -# Tool to change global to local symbols on Mac OS X. -NMEDIT=$lt_NMEDIT - -# Tool to manipulate fat objects and archives on Mac OS X. -LIPO=$lt_LIPO - -# ldd/readelf like tool for Mach-O binaries on Mac OS X. -OTOOL=$lt_OTOOL - -# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. -OTOOL64=$lt_OTOOL64 - -# Old archive suffix (normally "a"). -libext=$libext - -# Shared library suffix (normally ".so"). -shrext_cmds=$lt_shrext_cmds - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at link time. -variables_saved_for_relink=$lt_variables_saved_for_relink - -# Do we need the "lib" prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Library versioning type. -version_type=$version_type - -# Shared library runtime path variable. -runpath_var=$runpath_var - -# Shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# List of archive names. First name is the real one, the rest are links. -# The last name is the one that the linker finds with -lNAME -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Command to use after installation of a shared archive. -postinstall_cmds=$lt_postinstall_cmds - -# Command to use after uninstallation of a shared archive. -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# As "finish_cmds", except a single script fragment to be evaled but -# not shown. -finish_eval=$lt_finish_eval - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Compile-time system search path for libraries. -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec - -# Run-time system search path for libraries. -sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - - -# The linker used to build libraries. -LD=$lt_LD - -# Commands used to build an old-style archive. -old_archive_cmds=$lt_old_archive_cmds - -# A language specific compiler. -CC=$lt_compiler - -# Is the compiler the GNU compiler? -with_gcc=$GCC - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag - -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl - -# Additional compiler flags for building library objects. -pic_flag=$lt_lt_prog_compiler_pic - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_lt_prog_compiler_static - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_lt_cv_prog_compiler_c_o - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$archive_cmds_need_lc - -# Whether or not to disallow shared libs when runtime libs are static. -allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec - -# Whether the compiler copes with passing no objects directly. -compiler_needs_object=$lt_compiler_needs_object - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds - -# Commands used to build a shared archive. -archive_cmds=$lt_archive_cmds -archive_expsym_cmds=$lt_archive_expsym_cmds - -# Commands used to build a loadable module if different from building -# a shared archive. -module_cmds=$lt_module_cmds -module_expsym_cmds=$lt_module_expsym_cmds - -# Whether we are building with GNU ld or not. -with_gnu_ld=$lt_with_gnu_ld - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag - -# Flag that enforces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist -hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec - -# If ld is used when linking, flag to hardcode \$libdir into a binary -# during linking. This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld - -# Whether we need a single "-rpath" flag with a separated argument. -hardcode_libdir_separator=$lt_hardcode_libdir_separator - -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes -# DIR into the resulting binary. -hardcode_direct=$hardcode_direct - -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes -# DIR into the resulting binary and the resulting library dependency is -# "absolute",i.e impossible to change by setting \${shlibpath_var} if the -# library is relocated. -hardcode_direct_absolute=$hardcode_direct_absolute - -# Set to "yes" if using the -LDIR flag during linking hardcodes DIR -# into the resulting binary. -hardcode_minus_L=$hardcode_minus_L - -# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR -# into the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var - -# Set to "yes" if building a shared library automatically hardcodes DIR -# into the library and all subsequent libraries and executables linked -# against it. -hardcode_automatic=$hardcode_automatic - -# Set to yes if linker adds runtime paths of dependent libraries -# to runtime path list. -inherit_rpath=$inherit_rpath - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs - -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path=$lt_fix_srcfile_path - -# Set to "yes" if exported symbols are required. -always_export_symbols=$always_export_symbols - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms - -# Commands necessary for linking programs (against libraries) with templates. -prelink_cmds=$lt_prelink_cmds - -# Specify filename containing input files. -file_list_spec=$lt_file_list_spec - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action - -# ### END LIBTOOL CONFIG - -_LT_EOF - - case $host_os in - aix3*) - cat <<\_LT_EOF >> "$cfgfile" -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES -fi -_LT_EOF - ;; - esac - - -ltmain="$ac_aux_dir/ltmain.sh" - - - # We use sed instead of cat because bash on DJGPP gets confused if - # if finds mixed CR/LF and LF-only lines. Since sed operates in - # text mode, it properly converts lines to CR/LF. This bash problem - # is reportedly fixed, but why not run on old versions too? - sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - case $xsi_shell in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac -} - -# func_basename file -func_basename () -{ - func_basename_result="${1##*/}" -} - -# func_dirname_and_basename file append nondir_replacement -# perform func_basename and func_dirname in a single function -# call: -# dirname: Compute the dirname of FILE. If nonempty, -# add APPEND to the result, otherwise set result -# to NONDIR_REPLACEMENT. -# value returned in "$func_dirname_result" -# basename: Compute filename of FILE. -# value retuned in "$func_basename_result" -# Implementation must be kept synchronized with func_dirname -# and func_basename. For efficiency, we do not delegate to -# those functions but instead duplicate the functionality here. -func_dirname_and_basename () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac - func_basename_result="${1##*/}" -} - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -func_stripname () -{ - # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are - # positional parameters, so assign one to ordinary parameter first. - func_stripname_result=${3} - func_stripname_result=${func_stripname_result#"${1}"} - func_stripname_result=${func_stripname_result%"${2}"} -} - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=${1%%=*} - func_opt_split_arg=${1#*=} -} - -# func_lo2o object -func_lo2o () -{ - case ${1} in - *.lo) func_lo2o_result=${1%.lo}.${objext} ;; - *) func_lo2o_result=${1} ;; - esac -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=${1%.*}.lo -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=$(( $* )) -} - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=${#1} -} - -_LT_EOF - ;; - *) # Bourne compatible functions. - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - # Extract subdirectory from the argument. - func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi -} - -# func_basename file -func_basename () -{ - func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` -} - - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# func_strip_suffix prefix name -func_stripname () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "X${3}" \ - | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "X${3}" \ - | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; - esac -} - -# sed scripts: -my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q' -my_sed_long_arg='1s/^-[^=]*=//' - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` - func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` -} - -# func_lo2o object -func_lo2o () -{ - func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[^.]*$/.lo/'` -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=`expr "$@"` -} - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` -} - -_LT_EOF -esac - -case $lt_shell_append in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$1+=\$2" -} -_LT_EOF - ;; - *) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$1=\$$1\$2" -} - -_LT_EOF - ;; - esac - - - sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - mv -f "$cfgfile" "$ofile" || - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") - chmod +x "$ofile" - - ;; - - esac -done # for ac_tag - - -as_fn_exit 0 -_ACEOF -ac_clean_files=$ac_clean_files_save - -test $ac_write_fail = 0 || - as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit 1 -fi -if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} -fi - diff --git a/configure.ac b/configure.ac index da77f1a..fa9f9d1 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ(2.52) -AC_INIT([avsystem], [1.0]) +AC_INIT([libmm-sound], [1.0]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AC_CONFIG_HEADERS([config.h:config.hin]) @@ -22,10 +22,6 @@ AC_PROG_GCC_TRADITIONAL AC_PROG_LIBTOOL # Checks for libraries. -PKG_CHECK_MODULES(AVSYSTEM, avsysaudio) -AC_SUBST(AVSYSTEM_CFLAGS) -AC_SUBST(AVSYSTEM_LIBS) - PKG_CHECK_MODULES(MMCOMMON, mm-common) AC_SUBST(MMCOMMON_CFLAGS) AC_SUBST(MMCOMMON_LIBS) @@ -51,13 +47,42 @@ PKG_CHECK_MODULES(GLIB2, glib-2.0 gthread-2.0) AC_SUBST(GLIB2_CFLAGS) AC_SUBST(GLIB2_LIBS) +PKG_CHECK_MODULES(GIO, gio-2.0) +AC_SUBST(GIO_CFLAGS) +AC_SUBST(GIO_LIBS) + PKG_CHECK_MODULES(VCONF, vconf) AC_SUBST(VCONF_CFLAGS) AC_SUBST(VCONF_LIBS) -PKG_CHECK_MODULES(HEYNOTI, heynoti) -AC_SUBST(HEYNOTI_CFLAGS) -AC_SUBST(HEYNOTI_LIBS) +AC_ARG_ENABLE(bluetooth, AC_HELP_STRING([--enable-bluetooth], [enable bluetooth client]), +[ + case "${enableval}" in + yes) SUPPORT_BT_SCO=yes ;; + no) SUPPORT_BT_SCO=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-bluetooth) ;; + esac + ],[SUPPORT_BT_SCO=no]) +if test "x$SUPPORT_BT_SCO" = "xyes"; then +PKG_CHECK_MODULES(BLUETOOTH, capi-network-bluetooth) +AC_SUBST(BLUETOOTH_CFLAGS) +AC_SUBST(BLUETOOTH_LIBS) +fi +AM_CONDITIONAL([SUPPORT_BT_SCO], [test "x$SUPPORT_BT_SCO" = "xyes"]) + +AC_ARG_ENABLE(hfp, AC_HELP_STRING([--enable-hfp], [enable hfp api]), +[ + case "${enableval}" in + yes) USE_HFP=yes ;; + no) USE_HFP=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-hfp) ;; + esac + ],[USE_HFP=no]) +if test "x$USE_HFP" = "xyes"; then +PKG_CHECK_MODULES(BLUETOOTH_API, bluetooth-api) +AC_SUBST(BLUETOOTH_API_CFLAGS) +AC_SUBST(BLUETOOTH_API_LIBS) +fi AC_ARG_ENABLE(pulse, AC_HELP_STRING([--enable-pulse], [enable pulseaudio client]), [ @@ -68,30 +93,29 @@ AC_ARG_ENABLE(pulse, AC_HELP_STRING([--enable-pulse], [enable pulseaudio client] esac ],[USE_PULSE=no]) if test "x$USE_PULSE" = "xyes"; then -PKG_CHECK_MODULES(PULSE, libpulse) -AC_SUBST(PULSE_CFLAGS) -AC_SUBST(PULSE_LIBS) +PKG_CHECK_MODULES(PASIMPLE, libpulse-simple) +AC_SUBST(PASIMPLE_CFLAGS) +AC_SUBST(PASIMPLE_LIBS) +PKG_CHECK_MODULES(PA, libpulse) +AC_SUBST(PA_CFLAGS) +AC_SUBST(PA_LIBS) fi AM_CONDITIONAL([USE_PULSE], [test "x$USE_PULSE" = "xyes"]) -dnl use security -------------------------------------------------------------------------- -AC_ARG_ENABLE(security, AC_HELP_STRING([--enable-security], [using security]), +AC_ARG_ENABLE(ogg, AC_HELP_STRING([--enable-ogg], [enable ogg client]), [ case "${enableval}" in - yes) USE_SECURITY=yes ;; - no) USE_SECURITY=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-security) ;; + yes) OGG_SUPPORT=yes ;; + no) OGG_SUPPORT=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-ogg) ;; esac - ],[USE_SECURITY=no]) - -if test "x$USE_SECURITY" = "xyes"; then -PKG_CHECK_MODULES(SECURITY, security-server) -AC_SUBST(SECURITY_CFLAGS) -AC_SUBST(SECURITY_LIBS) + ],[OGG_SUPPORT=no]) +if test "x$OGG_SUPPORT" = "xyes"; then +PKG_CHECK_MODULES(TREMOLO, libtremolo) +AC_SUBST(TREMOLO_CFLAGS) +AC_SUBST(TREMOLO_LIBS) fi -AM_CONDITIONAL(USE_SECURITY, test "x$USE_SECURITY" = "xyes") -dnl end -------------------------------------------------------------------- - +AM_CONDITIONAL([OGG_SUPPORT], [test "x$OGG_SUPPORT" = "xyes"]) # Checks for header files. AC_HEADER_STDC @@ -116,12 +140,13 @@ Makefile server/Makefile server/plugin/Makefile server/plugin/wav/Makefile +server/plugin/ogg/Makefile server/plugin/keytone/Makefile server/plugin/tone/Makefile pkgconfig/Makefile pkgconfig/mm-sound.pc pkgconfig/mm-keysound.pc +pkgconfig/mm-bootsound.pc testsuite/Makefile -init/Makefile ]) AC_OUTPUT diff --git a/depcomp b/depcomp deleted file mode 100755 index e5f9736..0000000 --- a/depcomp +++ /dev/null @@ -1,589 +0,0 @@ -#! /bin/sh -# depcomp - compile a program generating dependencies as side-effects - -scriptversion=2007-03-29.01 - -# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software -# Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Alexandre Oliva . - -case $1 in - '') - echo "$0: No command. Try \`$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: depcomp [--help] [--version] PROGRAM [ARGS] - -Run PROGRAMS ARGS to compile a file, generating dependencies -as side-effects. - -Environment variables: - depmode Dependency tracking mode. - source Source file read by `PROGRAMS ARGS'. - object Object file output by `PROGRAMS ARGS'. - DEPDIR directory where to store dependencies. - depfile Dependency file to output. - tmpdepfile Temporary file to use when outputing dependencies. - libtool Whether libtool is used (yes/no). - -Report bugs to . -EOF - exit $? - ;; - -v | --v*) - echo "depcomp $scriptversion" - exit $? - ;; -esac - -if test -z "$depmode" || test -z "$source" || test -z "$object"; then - echo "depcomp: Variables source, object and depmode must be set" 1>&2 - exit 1 -fi - -# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. -depfile=${depfile-`echo "$object" | - sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} -tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} - -rm -f "$tmpdepfile" - -# Some modes work just like other modes, but use different flags. We -# parameterize here, but still list the modes in the big case below, -# to make depend.m4 easier to write. Note that we *cannot* use a case -# here, because this file can only contain one case statement. -if test "$depmode" = hp; then - # HP compiler uses -M and no extra arg. - gccflag=-M - depmode=gcc -fi - -if test "$depmode" = dashXmstdout; then - # This is just like dashmstdout with a different argument. - dashmflag=-xM - depmode=dashmstdout -fi - -case "$depmode" in -gcc3) -## gcc 3 implements dependency tracking that does exactly what -## we want. Yay! Note: for some reason libtool 1.4 doesn't like -## it if -MD -MP comes after the -MF stuff. Hmm. -## Unfortunately, FreeBSD c89 acceptance of flags depends upon -## the command line argument order; so add the flags where they -## appear in depend2.am. Note that the slowdown incurred here -## affects only configure: in makefiles, %FASTDEP% shortcuts this. - for arg - do - case $arg in - -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; - *) set fnord "$@" "$arg" ;; - esac - shift # fnord - shift # $arg - done - "$@" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - mv "$tmpdepfile" "$depfile" - ;; - -gcc) -## There are various ways to get dependency output from gcc. Here's -## why we pick this rather obscure method: -## - Don't want to use -MD because we'd like the dependencies to end -## up in a subdir. Having to rename by hand is ugly. -## (We might end up doing this anyway to support other compilers.) -## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like -## -MM, not -M (despite what the docs say). -## - Using -M directly means running the compiler twice (even worse -## than renaming). - if test -z "$gccflag"; then - gccflag=-MD, - fi - "$@" -Wp,"$gccflag$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -## The second -e expression handles DOS-style file names with drive letters. - sed -e 's/^[^:]*: / /' \ - -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -## This next piece of magic avoids the `deleted header file' problem. -## The problem is that when a header file which appears in a .P file -## is deleted, the dependency causes make to die (because there is -## typically no way to rebuild the header). We avoid this by adding -## dummy dependencies for each header file. Too bad gcc doesn't do -## this for us directly. - tr ' ' ' -' < "$tmpdepfile" | -## Some versions of gcc put a space before the `:'. On the theory -## that the space means something, we add a space to the output as -## well. -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -sgi) - if test "$libtool" = yes; then - "$@" "-Wp,-MDupdate,$tmpdepfile" - else - "$@" -MDupdate "$tmpdepfile" - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - - if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files - echo "$object : \\" > "$depfile" - - # Clip off the initial element (the dependent). Don't try to be - # clever and replace this with sed code, as IRIX sed won't handle - # lines with more than a fixed number of characters (4096 in - # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; - # the IRIX cc adds comments like `#:fec' to the end of the - # dependency line. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ - tr ' -' ' ' >> $depfile - echo >> $depfile - - # The second pass generates a dummy entry for each header file. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> $depfile - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -aix) - # The C for AIX Compiler uses -M and outputs the dependencies - # in a .u file. In older versions, this file always lives in the - # current directory. Also, the AIX compiler puts `$object:' at the - # start of each line; $object doesn't have directory information. - # Version 6 uses the directory in both cases. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - if test "$libtool" = yes; then - tmpdepfile1=$dir$base.u - tmpdepfile2=$base.u - tmpdepfile3=$dir.libs/$base.u - "$@" -Wc,-M - else - tmpdepfile1=$dir$base.u - tmpdepfile2=$dir$base.u - tmpdepfile3=$dir$base.u - "$@" -M - fi - stat=$? - - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - # Each line is of the form `foo.o: dependent.h'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - # That's a tab and a space in the []. - sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -icc) - # Intel's C compiler understands `-MD -MF file'. However on - # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c - # ICC 7.0 will fill foo.d with something like - # foo.o: sub/foo.c - # foo.o: sub/foo.h - # which is wrong. We want: - # sub/foo.o: sub/foo.c - # sub/foo.o: sub/foo.h - # sub/foo.c: - # sub/foo.h: - # ICC 7.1 will output - # foo.o: sub/foo.c sub/foo.h - # and will wrap long lines using \ : - # foo.o: sub/foo.c ... \ - # sub/foo.h ... \ - # ... - - "$@" -MD -MF "$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - # Each line is of the form `foo.o: dependent.h', - # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" - # Some versions of the HPUX 10.20 sed can't process this invocation - # correctly. Breaking it into two sed invocations is a workaround. - sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | - sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp2) - # The "hp" stanza above does not work with aCC (C++) and HP's ia64 - # compilers, which have integrated preprocessors. The correct option - # to use with these is +Maked; it writes dependencies to a file named - # 'foo.d', which lands next to the object file, wherever that - # happens to be. - # Much of this is similar to the tru64 case; see comments there. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - if test "$libtool" = yes; then - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir.libs/$base.d - "$@" -Wc,+Maked - else - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir$base.d - "$@" +Maked - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" - # Add `dependent.h:' lines. - sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" "$tmpdepfile2" - ;; - -tru64) - # The Tru64 compiler uses -MD to generate dependencies as a side - # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put - # dependencies in `foo.d' instead, so we check for that too. - # Subdirectories are respected. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - - if test "$libtool" = yes; then - # With Tru64 cc, shared objects can also be used to make a - # static library. This mechanism is used in libtool 1.4 series to - # handle both shared and static libraries in a single compilation. - # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. - # - # With libtool 1.5 this exception was removed, and libtool now - # generates 2 separate objects for the 2 libraries. These two - # compilations output dependencies in $dir.libs/$base.o.d and - # in $dir$base.o.d. We have to check for both files, because - # one of the two compilations can be disabled. We should prefer - # $dir$base.o.d over $dir.libs/$base.o.d because the latter is - # automatically cleaned when .libs/ is deleted, while ignoring - # the former would cause a distcleancheck panic. - tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 - tmpdepfile2=$dir$base.o.d # libtool 1.5 - tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 - tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 - "$@" -Wc,-MD - else - tmpdepfile1=$dir$base.o.d - tmpdepfile2=$dir$base.d - tmpdepfile3=$dir$base.d - tmpdepfile4=$dir$base.d - "$@" -MD - fi - - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - # That's a tab and a space in the []. - sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -#nosideeffect) - # This comment above is used by automake to tell side-effect - # dependency tracking mechanisms from slower ones. - -dashmstdout) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout, regardless of -o. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - test -z "$dashmflag" && dashmflag=-M - # Require at least two characters before searching for `:' - # in the target name. This is to cope with DOS-style filenames: - # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. - "$@" $dashmflag | - sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - tr ' ' ' -' < "$tmpdepfile" | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -dashXmstdout) - # This case only exists to satisfy depend.m4. It is never actually - # run, as this mode is specially recognized in the preamble. - exit 1 - ;; - -makedepend) - "$@" || exit $? - # Remove any Libtool call - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - # X makedepend - shift - cleared=no - for arg in "$@"; do - case $cleared in - no) - set ""; shift - cleared=yes ;; - esac - case "$arg" in - -D*|-I*) - set fnord "$@" "$arg"; shift ;; - # Strip any option that makedepend may not understand. Remove - # the object too, otherwise makedepend will parse it as a source file. - -*|$object) - ;; - *) - set fnord "$@" "$arg"; shift ;; - esac - done - obj_suffix="`echo $object | sed 's/^.*\././'`" - touch "$tmpdepfile" - ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - sed '1,2d' "$tmpdepfile" | tr ' ' ' -' | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" "$tmpdepfile".bak - ;; - -cpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - "$@" -E | - sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ - -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | - sed '$ s: \\$::' > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - cat < "$tmpdepfile" >> "$depfile" - sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvisualcpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout, regardless of -o, - # because we must use -o when running libtool. - "$@" || exit $? - IFS=" " - for arg - do - case "$arg" in - "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") - set fnord "$@" - shift - shift - ;; - *) - set fnord "$@" "$arg" - shift - shift - ;; - esac - done - "$@" -E | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" - echo " " >> "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -none) - exec "$@" - ;; - -*) - echo "Unknown depmode $depmode" 1>&2 - exit 1 - ;; -esac - -exit 0 - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/dump_audio.sh b/dump_audio.sh new file mode 100755 index 0000000..052d73b --- /dev/null +++ b/dump_audio.sh @@ -0,0 +1,23 @@ +#!/bin/sh +#-------------------------------------- +# audio +#-------------------------------------- + +AUDIO_DEBUG=$1/audio +mkdir -p ${AUDIO_DEBUG} +ps -ef | egrep "sound_server|pulseaudio" >> ${AUDIO_DEBUG}/pactl_dump +pactl stat >> ${AUDIO_DEBUG}/pactl_dump +pactl list >> ${AUDIO_DEBUG}/pactl_dump +vconftool get file/private/sound/volume/ >> ${AUDIO_DEBUG}/vconf_dump +vconftool get memory/private/sound/ >> ${AUDIO_DEBUG}/vconf_dump +vconftool get memory/private/Sound/ >> ${AUDIO_DEBUG}/vconf_dump +cat /proc/asound/cards >> ${AUDIO_DEBUG}/device_dump +ls /dev/snd/ -alZ >> ${AUDIO_DEBUG}/device_dump +ls /usr/share/alsa/ucm/* -alZ >> ${AUDIO_DEBUG}/device_dump +amixer contents >> ${AUDIO_DEBUG}/device_dump +hcitool con >> ${AUDIO_DEBUG}/device_dump +ls /tmp/ -alZ | grep ASM >> ${AUDIO_DEBUG}/tmp_dump +ls /tmp/ -alZ | grep session >> ${AUDIO_DEBUG}/tmp_dump +ipcs >> ${AUDIO_DEBUG}/ipcs_dump +rpm -qa | egrep "mm-sound|avsystem|audio|session|sound|ext0|wav-player|tone-player|alsa|sysconf|openal" >> ${AUDIO_DEBUG}/rpm_dump +openal-info >> ${AUDIO_DEBUG}/openal_dump diff --git a/include/mm_ipc.h b/include/mm_ipc.h index 744b73b..2aaf5e8 100644 --- a/include/mm_ipc.h +++ b/include/mm_ipc.h @@ -26,6 +26,8 @@ #include #include "mm_sound.h" +#include "mm_sound_device.h" + #define FILE_PATH 512 @@ -54,22 +56,38 @@ typedef struct char filename[FILE_PATH]; /* Device */ + mm_sound_device_t device_handle; + int total_device_num; + int device_flags; + bool is_connected; + int changed_device_info_type; + int route; int device_in; int device_out; int is_available; int route_list[MM_SOUND_ROUTE_NUM]; + /* Volume */ + int type; + int val; + /* Common data */ int handle; void *callback; void *cbdata; int samplerate; int channels; - int volume_table; + int volume_config; int session_type; + int session_options; int priority; int handle_route; + + bool enable_session; + bool need_broadcast; + + char name[MM_SOUND_NAME_NUM]; } mmsound_ipc_t; typedef struct diff --git a/include/mm_sound.h b/include/mm_sound.h old mode 100644 new mode 100755 index 8a9c594..2cdec83 --- a/include/mm_sound.h +++ b/include/mm_sound.h @@ -282,20 +282,50 @@ * Enumerations of Volume type. */ -typedef enum -{ +typedef enum { VOLUME_TYPE_SYSTEM, /**< System volume type */ VOLUME_TYPE_NOTIFICATION, /**< Notification volume type */ VOLUME_TYPE_ALARM, /**< Alarm volume type */ VOLUME_TYPE_RINGTONE, /**< Ringtone volume type */ VOLUME_TYPE_MEDIA, /**< Media volume type */ VOLUME_TYPE_CALL, /**< Call volume type */ + VOLUME_TYPE_VOIP, /**< VOIP volume type */ + VOLUME_TYPE_VOICE, /**< VOICE volume type */ VOLUME_TYPE_FIXED, /**< Volume type for fixed acoustic level */ - VOLUME_TYPE_EXT_JAVA, /**< External system volume for Java */ VOLUME_TYPE_MAX, /**< Volume type count */ VOLUME_TYPE_EXT_ANDROID = VOLUME_TYPE_FIXED, /**< External system volume for Android */ } volume_type_t; +typedef enum { + VOLUME_GAIN_DEFAULT = 0, + VOLUME_GAIN_DIALER = 1<<8, + VOLUME_GAIN_TOUCH = 2<<8, + VOLUME_GAIN_AF = 3<<8, + VOLUME_GAIN_SHUTTER1 = 4<<8, + VOLUME_GAIN_SHUTTER2 = 5<<8, + VOLUME_GAIN_CAMCORDING = 6<<8, + VOLUME_GAIN_MIDI = 7<<8, + VOLUME_GAIN_BOOTING = 8<<8, + VOLUME_GAIN_VIDEO = 9<<8, + VOLUME_GAIN_TTS = 10<<8, +} volume_gain_t; + +/** + * @brief Enumerations of supporting source_type + */ +typedef enum { + SUPPORT_SOURCE_TYPE_DEFAULT, + SUPPORT_SOURCE_TYPE_MIRRORING, + SUPPORT_SOURCE_TYPE_VOICECONTROL, + SUPPORT_SOURCE_TYPE_SVR, + SUPPORT_SOURCE_TYPE_VIDEOCALL, + SUPPORT_SOURCE_TYPE_VOICERECORDING, + SUPPORT_SOURCE_TYPE_VOIP, /* Supporting VoIP source*/ + SUPPORT_SOURCE_TYPE_CALL_FORWARDING, + SUPPORT_SOURCE_TYPE_FMRADIO, + SUPPORT_SOURCE_TYPE_LOOPBACK, +} mm_sound_source_type_e; + /** * Volume change callback function type. * @@ -307,6 +337,31 @@ typedef enum */ typedef void (*volume_callback_fn)(void* user_data); +/** + * Active volume change callback function type. + * + * @param type [in] The sound type of changed volume + * @param volume [in] The new volume value + * @param user_data [in] Argument passed when callback has called + * + * @return No return value + * @remark None. + * @see mm_sound_add_volume_changed_callback mm_sound_remove_volume_changed_callback + */ +typedef void (*mm_sound_volume_changed_cb) (volume_type_t type, unsigned int volume, void *user_data); + + +/** + * Muteall state change callback function type. + * + * @param user_data [in] Argument passed when callback has called + * + * @return No return value + * @remark None. + * @see mm_sound_muteall_add_callback mm_sound_muteall_remove_callback + */ +typedef void (*muteall_callback_fn)(void* user_data); + /** * This function is to retrieve number of volume level. * @@ -397,6 +452,7 @@ int volume_control() * @endcode */ int mm_sound_volume_add_callback(volume_type_t type, volume_callback_fn func, void* user_data); +int mm_sound_add_volume_changed_callback(mm_sound_volume_changed_cb func, void* user_data); /** @@ -441,6 +497,93 @@ int volume_callback() */ int mm_sound_volume_remove_callback(volume_type_t type); +/** + * This function is to remove volume change callback. + * + * @return This function returns MM_ERROR_NONE on success, or negative value + * with error code. + **/ +int mm_sound_remove_volume_changed_callback(void); + +/** + * This function is to add muteall changed callback. + * + * @param func [in] callback function pointer + * @param user_data [in] user data passing to callback function + * + * @return This function returns MM_ERROR_NONE on success, or negative value + * with error code. + * @see muteall_callback_fn + * @code +void _muteall_callback(void *data) +{ + int muteall; + + mm_sound_get_muteall(&muteall); + g_print("Muteall Callback Runs :::: muteall value = %d\n", muteall); +} + +int muteall_callback() +{ + int ret = 0; + + ret = mm_sound_muteall_add_callback( _muteall_callback); + + if ( MM_ERROR_NONE != ret) + { + printf("Can not add callback\n"); + } + else + { + printf("Add callback success\n"); + } + + return 0; +} + + * @endcode + */ +int mm_sound_muteall_add_callback(muteall_callback_fn func); + + +/** + * This function is to remove muteall changed callback. + * + * @param func [in] callback function pointer + * + * @return This function returns MM_ERROR_NONE on success, or negative value + * with error code. + * @remark None. + * @post Callback function will not be called anymore. + * @see muteall_callback_fn + * @code +void _muteall_callback(void *data) +{ + printf("Callback function\n"); +} + +int muteall_callback() +{ + int ret = 0; + + mm_sound_muteall_add_callback( _muteall_callback); + + ret = mm_sound_muteall_remove_callback(_muteall_callback); + if ( MM_ERROR_NONE == ret) + { + printf("Remove callback success\n"); + } + else + { + printf("Remove callback failed\n"); + } + + return ret; +} + + * @endcode + */ +int mm_sound_muteall_remove_callback(muteall_callback_fn func); /** * This function is to set volume level of certain volume type. @@ -481,6 +624,24 @@ int mm_sound_volume_set_value(volume_type_t type, const unsigned int value); + + + +/** + * This function is to set all volume type to mute or unmute. + * + * @param muteall [in] the switch to control mute or unmute. + * + * @return This function returns MM_ERROR_NONE on success, or negative value + * with error code. + * @remark None. + * @pre None. + * @post None. + */ +int mm_sound_mute_all(int muteall); + + + /** * This function is to get volume level of certain volume type. * @@ -622,7 +783,7 @@ int main() } * @endcode */ -int mm_sound_volume_primary_type_clear(); +int mm_sound_volume_primary_type_clear(void); @@ -665,6 +826,47 @@ default: */ int mm_sound_volume_get_current_playing_type(volume_type_t *type); +int mm_sound_volume_set_balance (float balance); + +int mm_sound_volume_get_balance (float *balance); + +int mm_sound_set_muteall (int muteall); + +int mm_sound_get_muteall (int *muteall); + +int mm_sound_set_stereo_to_mono (int ismono); + +int mm_sound_get_stereo_to_mono (int *ismono); + +int mm_sound_set_call_mute(volume_type_t type, int mute); + +int mm_sound_get_call_mute(volume_type_t type, int *mute); + +int mm_sound_set_factory_loopback_test(int loopback); + +int mm_sound_get_factory_loopback_test(int *loopback); + +typedef enum { + MM_SOUND_FACTORY_MIC_TEST_STATUS_OFF = 0, + MM_SOUND_FACTORY_MIC_TEST_STATUS_MAIN_MIC, + MM_SOUND_FACTORY_MIC_TEST_STATUS_SUB_MIC, + MM_SOUND_FACTORY_MIC_TEST_STATUS_NUM, +} mm_sound_factory_mic_test_status_t;/* device in for factory mic test */ + +int mm_sound_set_factory_mic_test(mm_sound_factory_mic_test_status_t mic_test); + +int mm_sound_get_factory_mic_test(mm_sound_factory_mic_test_status_t *mic_test); + +typedef enum { + MMSOUND_DHA_OFF, + MMSOUND_DHA_SOFT_SOUND, + MMSOUND_DHA_CLEAR_SOUND, + MMSOUND_DHA_PERSNOL_LEFT, + MMSOUND_DHA_PERSNOL_RIGHT, + MMSOUND_DHA_INVALID, +} MMSoundDHAMode_t; + + /* * MMSound PCM APIs @@ -674,8 +876,7 @@ typedef void* MMSoundPcmHandle_t; /**< MMsound PCM handle type */ /** * Enumerations of Format used in MMSoundPcm operation. */ -typedef enum -{ +typedef enum { MMSOUND_PCM_U8 = 0x70, /**< unsigned 8bit audio */ MMSOUND_PCM_S16_LE, /**< signed 16bit audio */ } MMSoundPcmFormat_t; @@ -688,15 +889,42 @@ typedef enum { MMSOUND_PCM_STEREO, /**< Stereo channel */ }MMSoundPcmChannel_t; +/** + * Get audio stream latency value. + * + * @param handle [in] handle to get latency + * @param latency [out] Stream latency value(millisecond). + * + * @return This function returns MM_ERROR_NONE on success, or negative value + * with error code. + * @remark + * @see + */ +int mm_sound_pcm_get_latency(MMSoundPcmHandle_t handle, int *latency); + +/** + * Get started status of pcm stream. + * + * @param handle [in] handle to check pcm start + * @param is_started [out] retrieve started status of pcm stream. + * + * @return This function returns MM_ERROR_NONE on success, or negative value + * with error code. + * @remark + * @see + */ +int mm_sound_pcm_is_started(MMSoundPcmHandle_t handle, bool *is_started); + +int mm_sound_pcm_play_open_no_session(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, int volume_config); /** * This function is to create handle for PCM playback. * - * @param handle [out] handle to play pcm data - * @param rate [in] sample rate (8000Hz ~ 44100Hz) - * @param channel [in] number of channels (mono or stereo) - * @param format [in] S8 or S16LE - * @param volume [in] volume type + * @param handle [out] handle to play pcm data + * @param rate [in] sample rate (8000Hz ~ 44100Hz) + * @param channel [in] number of channels (mono or stereo) + * @param format [in] S8 or S16LE + * @param volume config [in] Volume type & volume gain * * @return This function returns suggested buffer size (in bytes) on success, or negative value * with error code. @@ -759,7 +987,7 @@ int main(int argc, char* argv[]) } * @endcode */ -int mm_sound_pcm_play_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, const volume_type_t volume); +int mm_sound_pcm_play_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, int volume_config); /** * This function start pcm playback @@ -929,7 +1157,19 @@ int main(int argc, char* argv[]) */ int mm_sound_pcm_play_close(MMSoundPcmHandle_t handle); - +/** + * This function is to ignore session for playback + * + * @param handle [in] handle to play pcm data + * + * @return This function returns MM_ERROR_NONE on success, or negative value + * with error code. + * @remark This function only works for not started pcm handle and can't be reversed. + * @see + * @pre PCM play handle should be created and not started. + * @post PCM play session will be set to mix. + */ +int mm_sound_pcm_play_ignore_session(MMSoundPcmHandle_t *handle); /** * This function is to create handle for PCM capture. @@ -1006,6 +1246,82 @@ int main(int argc, char* argv[]) */ int mm_sound_pcm_capture_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format); +/** + * This function is to create handle for PCM capture of source_type. + * + * @param handle [out] handle to capture pcm data + * @param rate [in] sample rate (8000Hz ~ 44100Hz) + * @param channel [in] number of channels (mono or stereo) + * @param format [in] S8 or S16LE + * @param source_type [in] The source_type,mm_sound_source_type_e + * + * @return This function returns suggested buffer size (in bytes) on success, or negative value + * with error code. + * @remark only mono channel is valid for now. + * @see mm_sound_pcm_capture_read, mm_sound_pcm_capture_close, MMSoundPcmFormat_t, MMSoundPcmChannel_t + * @pre None. + * @post PCM capture handle will be allocated. + * @par Example + * @code +#include +#include +#include + +int main(int argc, char* argv[]) +{ + FILE *fp = NULL; + char *buffer = NULL; + int ret = 0; + int size = 0; + int count = 0; + MMSoundPcmHandle_t handle; + char *filename = NULL; + + if(argc !=2 ) + { + printf("Usage) %s filename\n", argv[0]); + return -1; + } + filename = argv[1]; + + fp = fopen(filename,"w"); + if(fp ==NULL) + { + printf("Can not open file %s\n", filename); + return -1; + } + + size = mm_sound_pcm_capture_open_ex(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE,1); + if(size < 0) + { + printf("Can not open capture handle\n"); + return -2; + } + + buffer = alloca(size); + while(1) + { + ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size); + if(ret < 0) + { + printf("read fail\n"); + break; + } + fwrite(buffer, ret, sizeof(char), fp); + if(count++ > 20) { + break; + } + } + + fclose(fp); + mm_sound_pcm_capture_close(handle); + return 0; +} + + * @endcode + */ +int mm_sound_pcm_capture_open_ex(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, mm_sound_source_type_e source_type); + /** * This function start pcm capture * @@ -1180,6 +1496,20 @@ int main(int argc, char* argv[]) */ int mm_sound_pcm_capture_close(MMSoundPcmHandle_t handle); +/** + * This function is to ignore session for capture + * + * @param handle [in] handle to capture pcm data + * + * @return This function returns MM_ERROR_NONE on success, or negative value + * with error code. + * @remark This function only works for not started pcm handle and can't be reversed. + * @see + * @pre PCM capture handle should be created and not started. + * @post PCM capture session will be set to mix. + */ +int mm_sound_pcm_capture_ignore_session(MMSoundPcmHandle_t *handle); + /** * This function sets callback function for receiving messages from pcm API. * @@ -1218,14 +1548,15 @@ int mm_sound_pcm_set_message_callback (MMSoundPcmHandle_t handle, MMMessageCallb /** * Terminate callback function type. * - * @param param [in] Argument passed when callback was set + * @param data [in] Argument passed when callback was set + * @param id [in] handle which has completed playing * * @return No return value * @remark It is not allowed to call MMSound API recursively or do time-consuming * task in this callback because this callback is called synchronously. * @see mm_sound_play_sound */ -typedef void (*mm_sound_stop_callback_func) (void *data); +typedef void (*mm_sound_stop_callback_func) (void *data, int id); /* * MMSound Play APIs @@ -1234,18 +1565,18 @@ typedef void (*mm_sound_stop_callback_func) (void *data); /** * This function is to play system sound. * - * @param filename [in] Sound filename to play - * @param volume [in] Volume type - * @param callback [in] Callback function pointer when playing is terminated. - * @param data [in] Pointer to user data when callback is called. - * @param handle [out] Handle of sound play. + * @param filename [in] Sound filename to play + * @param volume config [in] Volume type & volume gain + * @param callback [in] Callback function pointer when playing is terminated. + * @param data [in] Pointer to user data when callback is called. + * @param handle [out] Handle of sound play. * * @return This function returns MM_ERROR_NONE on success, or negative value * with error code. * @remark When the stop callback is set, it will be called when system sound is * terminated. If mm_sound_stop_sound() is called apparently before * system sound is terminated, stop_callback will not be called. - * @see mm_sound_stop_sound mm_sound_stop_callback_func volume_type_t + * @see mm_sound_stop_sound mm_sound_stop_callback_func volume_type_t volume_gain_t * @pre None. * @post Sound will be generated with given filename. * @par Example @@ -1282,22 +1613,26 @@ int play_file() } * @endcode */ -int mm_sound_play_sound(const char *filename, const volume_type_t volume, mm_sound_stop_callback_func callback, void *data, int *handle); +int mm_sound_play_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle); + +int mm_sound_play_sound_without_session(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle); + +int mm_sound_play_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle); /** * This function is to play system sound. And other audio stream will be mute during playing time * - * @param filename [in] Sound filename to play - * @param volume [in] Volume type - * @param callback [in] Callback function pointer when playing is terminated. - * @param data [in] Pointer to user data when callback is called. - * @param handle [out] Handle of sound play. + * @param filename [in] Sound filename to play + * @param volume config [in] Volume type & volume gain + * @param callback [in] Callback function pointer when playing is terminated. + * @param data [in] Pointer to user data when callback is called. + * @param handle [out] Handle of sound play. * * @return This function returns MM_ERROR_NONE on success, or negative value * with error code. * @remark This function is almost same with mm_sound_play_sound, * but this make other audio playback stream to mute during playing time. - * @see mm_sound_stop_sound mm_sound_stop_callback_func volume_type_t + * @see mm_sound_stop_sound mm_sound_stop_callback_func volume_type_t volume_gain_t * @pre None. * @post Sound will be generated with given filename. * @par Example @@ -1334,7 +1669,9 @@ int play_file() } * @endcode */ -int mm_sound_play_loud_solo_sound(const char *filename, const volume_type_t volume_type, mm_sound_stop_callback_func callback, void *data, int *handle); +int mm_sound_play_loud_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle); + +int mm_sound_play_loud_solo_sound_no_restore(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle); /** * This function is to stop playing system sound. @@ -1507,6 +1844,9 @@ typedef enum { MM_SOUND_TONE_CDMA_NETWORK_BUSY_ONE_SHOT, /**CDMA_NETWORK_BUSY_ONE_SHOT tone: 425Hz 500ms ON, 500ms OFF. */ MM_SOUND_TONE_CDMA_ABBR_ALERT, /**CDMA_ABBR_ALERT tone: 1150Hz+770Hz 400ms ON */ MM_SOUND_TONE_CDMA_SIGNAL_OFF, /**CDMA_SIGNAL_OFF - silent tone */ + MM_SOUND_TONE_LOW_FRE, /**100Hz continuous */ + MM_SOUND_TONE_MED_FRE, /**200Hz continuous */ + MM_SOUND_TONE_HIGH_FRE, /**300Hz continuous */ MM_SOUND_TONE_NUM, }MMSoundTone_t; @@ -1515,17 +1855,51 @@ typedef unsigned long sound_time_msec_t; /**< millisecond unit */ /** * This function is to play tone sound. * - * @param num [in] predefined tone type (MMSoundTone_t) - * volume type [in] volume type - * volume [in] volume ratio (0.0 ~1.0) + * @param num [in] predefined tone type (MMSoundTone_t) + * volume config [in] volume type & volume gain + * volume [in] volume ratio (0.0 ~1.0) * duration [in] millisecond (-1 for infinite) - * handle [in] Handle of mm_sound_play_tone + * handle [in] Handle of mm_sound_play_tone + * enable_session [in] set enable/unable session * * @return This function returns MM_ERROR_NONE on success, or negative value * with error code. * * @remark It doesn't provide stop - * @see volume_type_t MMSoundTone_t + * @see volume_type_t volume_gain_t MMSoundTone_t + * @pre None. + * @post TONE sound will be played. + * @par Example + * @code +int ret = 0; + +ret = mm_sound_play_tone_ex(MM_SOUND_TONE_DTMF_9, VOLUME_TYPE_SYSTEM, 1.0, 1000, &handle, TRUE); //play 1 second with volume ratio 1.0 +if(ret < 0) +{ + printf("play tone failed\n"); +} +else +{ + printf("play tone success\n"); +} + * @endcode + */ +int mm_sound_play_tone_ex (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle, bool enable_session); + +/** + * This function is to play tone sound. + * + * @param num [in] predefined tone type (MMSoundTone_t) + * volume config [in] volume type & volume gain + * volume [in] volume ratio (0.0 ~1.0) + * duration [in] millisecond (-1 for infinite) + * handle [in] Handle of mm_sound_play_tone + * + * @return This function returns MM_ERROR_NONE on success, or negative value + * with error code. + * + * @remark It doesn't provide stop + * @see volume_type_t volume_gain_t MMSoundTone_t * @pre None. * @post TONE sound will be played. * @par Example @@ -1543,7 +1917,7 @@ else } * @endcode */ -int mm_sound_play_tone (MMSoundTone_t num, const volume_type_t vol_type, const double volume, const int duration, int *handle); +int mm_sound_play_tone (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle); /* * Enumerations of System audio route policy @@ -1736,7 +2110,7 @@ if (ret == MM_ERROR_NONE) { * @endcode */ -int mm_sound_route_get_a2dp_status (int* connected, char** bt_name); +int mm_sound_route_get_a2dp_status (bool* connected, char** bt_name); /** @@ -1783,7 +2157,6 @@ else */ int mm_sound_route_get_playing_device(system_audio_route_device_t *dev); - /** * Audio route policy change callback function type. * @@ -1893,30 +2266,60 @@ int mm_sound_route_remove_change_callback(void); * Enumerations of device & route */ +typedef enum{ + MM_SOUND_DIRECTION_NONE, + MM_SOUND_DIRECTION_IN, /**< Capture */ + MM_SOUND_DIRECTION_OUT, /**< Playback */ +} mm_sound_direction; + typedef enum{ MM_SOUND_DEVICE_IN_NONE = 0x00, MM_SOUND_DEVICE_IN_MIC = 0x01, /**< Device builtin mic. */ MM_SOUND_DEVICE_IN_WIRED_ACCESSORY = 0x02, /**< Wired input devices */ - MM_SOUND_DEVICE_IN_BT_SCO = 0x04, /**< Bluetooth SCO device */ + MM_SOUND_DEVICE_IN_BT_SCO = 0x08, /**< Bluetooth SCO device */ } mm_sound_device_in; typedef enum{ - MM_SOUND_DEVICE_OUT_NONE = 0x00, - MM_SOUND_DEVICE_OUT_SPEAKER = 0x01<<8, /**< Device builtin speaker */ - MM_SOUND_DEVICE_OUT_RECEIVER = 0x02<<8, /**< Device builtin receiver */ - MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY = 0x04<<8, /**< Wired output devices such as headphone, headset, and so on. */ - MM_SOUND_DEVICE_OUT_BT_SCO = 0x08<<8, /**< Bluetooth SCO device */ - MM_SOUND_DEVICE_OUT_BT_A2DP = 0x10<<8, /**< Bluetooth A2DP device */ - MM_SOUND_DEVICE_OUT_DOCK = 0x20<<8, /**< DOCK device */ + MM_SOUND_DEVICE_OUT_NONE = 0x000, + MM_SOUND_DEVICE_OUT_SPEAKER = 0x001<<8, /**< Device builtin speaker */ + MM_SOUND_DEVICE_OUT_RECEIVER = 0x002<<8, /**< Device builtin receiver */ + MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY = 0x004<<8, /**< Wired output devices such as headphone, headset, and so on. */ + MM_SOUND_DEVICE_OUT_BT_SCO = 0x008<<8, /**< Bluetooth SCO device */ + MM_SOUND_DEVICE_OUT_BT_A2DP = 0x010<<8, /**< Bluetooth A2DP device */ + MM_SOUND_DEVICE_OUT_DOCK = 0x020<<8, /**< DOCK device */ + MM_SOUND_DEVICE_OUT_HDMI = 0x040<<8, /**< HDMI device */ + MM_SOUND_DEVICE_OUT_MIRRORING = 0x080<<8, /**< MIRRORING device */ + MM_SOUND_DEVICE_OUT_USB_AUDIO = 0x100<<8, /**< USB Audio device */ + MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK = 0x200<<8, /**< Multimedia DOCK device */ } mm_sound_device_out; -#define MM_SOUND_ROUTE_NUM 10 +typedef enum { + MM_SOUND_VOLUME_DEVICE_OUT_SPEAKER, /**< Device builtin speaker */ + MM_SOUND_VOLUME_DEVICE_OUT_RECEIVER, /**< Device builtin receiver */ + MM_SOUND_VOLUME_DEVICE_OUT_WIRED_ACCESSORY, /**< Wired output devices such as headphone, headset, and so on. */ + MM_SOUND_VOLUME_DEVICE_OUT_BT_SCO, /**< Bluetooth SCO device */ + MM_SOUND_VOLUME_DEVICE_OUT_BT_A2DP, /**< Bluetooth A2DP device */ + MM_SOUND_VOLUME_DEVICE_OUT_DOCK, /**< DOCK device */ + MM_SOUND_VOLUME_DEVICE_OUT_HDMI, /**< HDMI device */ + MM_SOUND_VOLUME_DEVICE_OUT_MIRRORING, /**< MIRRORING device */ + MM_SOUND_VOLUME_DEVICE_OUT_USB_AUDIO, /**< USB Audio device */ + MM_SOUND_VOLUME_DEVICE_OUT_MULTIMEDIA_DOCK, /**< Multimedia DOCK device */ +} mm_sound_volume_device_out_t; + +#define MM_SOUND_ROUTE_NUM 16 +#define MM_SOUND_NAME_NUM 32 typedef enum{ MM_SOUND_ROUTE_OUT_SPEAKER = MM_SOUND_DEVICE_OUT_SPEAKER, /**< Routing audio output to builtin device such as internal speaker. */ + MM_SOUND_ROUTE_OUT_RECEIVER = MM_SOUND_DEVICE_OUT_RECEIVER, /**< Routing audio output to builtin device such as internal receiver. */ MM_SOUND_ROUTE_OUT_WIRED_ACCESSORY = MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY,/**< Routing audio output to wired accessory such as headphone, headset, and so on. */ - MM_SOUND_ROUTE_OUT_BLUETOOTH = MM_SOUND_DEVICE_OUT_BT_A2DP, /**< Routing audio output to bluetooth A2DP. */ + MM_SOUND_ROUTE_OUT_BLUETOOTH_SCO = MM_SOUND_DEVICE_OUT_BT_SCO, /**< Routing audio output to bluetooth SCO. */ + MM_SOUND_ROUTE_OUT_BLUETOOTH_A2DP = MM_SOUND_DEVICE_OUT_BT_A2DP, /**< Routing audio output to bluetooth A2DP. */ MM_SOUND_ROUTE_OUT_DOCK = MM_SOUND_DEVICE_OUT_DOCK, /**< Routing audio output to DOCK */ + MM_SOUND_ROUTE_OUT_HDMI = MM_SOUND_DEVICE_OUT_HDMI, /**< Routing audio output to HDMI */ + MM_SOUND_ROUTE_OUT_MIRRORING = MM_SOUND_DEVICE_OUT_MIRRORING, /**< Routing audio output to MIRRORING */ + MM_SOUND_ROUTE_OUT_USB_AUDIO = MM_SOUND_DEVICE_OUT_USB_AUDIO, /**< Routing audio output to USB Audio */ + MM_SOUND_ROUTE_OUT_MULTIMEDIA_DOCK = MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK, /**< Routing audio output to Multimedia DOCK */ MM_SOUND_ROUTE_IN_MIC = MM_SOUND_DEVICE_IN_MIC, /**< Routing audio input to device builtin mic. */ MM_SOUND_ROUTE_IN_WIRED_ACCESSORY = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY, /**< Routing audio input to wired accessory. */ MM_SOUND_ROUTE_IN_MIC_OUT_RECEIVER = MM_SOUND_DEVICE_IN_MIC | MM_SOUND_DEVICE_OUT_RECEIVER, /**< Routing audio input to device builtin mic and routing audio output to builtin receiver*/ @@ -1926,13 +2329,83 @@ typedef enum{ MM_SOUND_ROUTE_INOUT_BLUETOOTH = MM_SOUND_DEVICE_IN_BT_SCO | MM_SOUND_DEVICE_OUT_BT_SCO /**< Routing audio input and output to bluetooth SCO */ } mm_sound_route; -typedef int (*mm_sound_available_route_cb)(mm_sound_route route, void *user_data); +/* + * MMSound Device APIs + */ -int mm_sound_is_route_available(mm_sound_route route, bool *is_available); +typedef enum { + MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG = 0x0001, /**< Flag for input devices */ + MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG = 0x0002, /**< Flag for output devices */ + MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG = 0x0004, /**< Flag for input/output devices (both directions are available) */ + MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG = 0x0010, /**< Flag for built-in devices */ + MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG = 0x0020, /**< Flag for external devices */ + MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG = 0x1000, /**< Flag for deactivated devices */ + MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG = 0x2000, /**< Flag for activated devices */ + MM_SOUND_DEVICE_ALL_FLAG = 0xFFFF, /**< Flag for all devices */ +} mm_sound_device_flags_e; -int mm_sound_foreach_available_route_cb(mm_sound_available_route_cb, void *user_data); +typedef enum { + MM_SOUND_DEVICE_IO_DIRECTION_IN, + MM_SOUND_DEVICE_IO_DIRECTION_OUT, + MM_SOUND_DEVICE_IO_DIRECTION_BOTH, +} mm_sound_device_io_direction_e; +typedef enum { + MM_SOUND_DEVICE_STATE_DEACTIVATED, + MM_SOUND_DEVICE_STATE_ACTIVATED, +} mm_sound_device_state_e; + +typedef enum +{ + MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER, /**< Built-in speaker. */ + MM_SOUND_DEVICE_TYPE_BUILTIN_RECEIVER, /**< Built-in receiver. */ + MM_SOUND_DEVICE_TYPE_BUILTIN_MIC, /**< Built-in mic. */ + MM_SOUND_DEVICE_TYPE_AUDIOJACK, /**< Audio jack such as headphone, headset, and so on. */ + MM_SOUND_DEVICE_TYPE_BLUETOOTH, /**< Bluetooth */ + MM_SOUND_DEVICE_TYPE_HDMI, /**< HDMI. */ + MM_SOUND_DEVICE_TYPE_MIRRORING, /**< MIRRORING. */ + MM_SOUND_DEVICE_TYPE_USB_AUDIO, /**< USB Audio. */ +} mm_sound_device_type_e; + +typedef void *MMSoundDevice_t; /**< MMsound Device handle */ +typedef void *MMSoundDeviceList_t; /**< MMsound Device list handle */ +typedef void (*mm_sound_device_connected_cb) (MMSoundDevice_t device_h, bool is_connected, void *user_data); +typedef void (*mm_sound_device_info_changed_cb) (MMSoundDevice_t device_h, int changed_info_type, void *user_data); + +int mm_sound_add_device_connected_callback(mm_sound_device_flags_e flags, mm_sound_device_connected_cb func, void *user_data); +int mm_sound_remove_device_connected_callback(void); +int mm_sound_add_device_information_changed_callback(mm_sound_device_flags_e flags, mm_sound_device_info_changed_cb func, void *user_data); +int mm_sound_remove_device_information_changed_callback(void); + +int mm_sound_get_current_device_list(mm_sound_device_flags_e device_mask, MMSoundDeviceList_t *device_list); +int mm_sound_get_next_device (MMSoundDeviceList_t device_list, MMSoundDevice_t *device); +int mm_sound_get_prev_device (MMSoundDeviceList_t device_list, MMSoundDevice_t *device); +int mm_sound_get_device_type(MMSoundDevice_t device_h, mm_sound_device_type_e *type); +int mm_sound_get_device_io_direction(MMSoundDevice_t device_h, mm_sound_device_io_direction_e *io_direction); +int mm_sound_get_device_id(MMSoundDevice_t device_h, int *id); +int mm_sound_get_device_state(MMSoundDevice_t device_h, mm_sound_device_state_e *state); +int mm_sound_get_device_name(MMSoundDevice_t device_h, char **name); + +/* below APIs are for product */ +typedef int (*mm_sound_available_route_cb)(mm_sound_route route, void *user_data); +int mm_sound_is_route_available(mm_sound_route route, bool *is_available); +int mm_sound_foreach_available_route_cb(mm_sound_available_route_cb, void *user_data); int mm_sound_set_active_route(mm_sound_route route); +int mm_sound_set_active_route_auto(void); + + +/** + * This function is to set active route without callback to client. + * + * @param route [IN] route + * @return This function returns MM_ERROR_NONE on success, or negative value + * with error code. + * @remark None. + * @pre None. + * @post None. + * @see mm_sound_set_active_route_without_broadcast mm_sound_route + */ +int mm_sound_set_active_route_without_broadcast(mm_sound_route route); /** * This function is to get active playback device and capture device. @@ -1963,6 +2436,7 @@ typedef void (*mm_sound_active_device_changed_cb) (mm_sound_device_in device_in, /** * This function is to add active device callback. * + * @param name [in] plugin name (name max size : MM_SOUND_NAME_NUM 32) * @param func [in] callback function pointer * @param user_data [in] user data passing to callback function * @@ -1999,11 +2473,11 @@ int active_device_control() * @endcode */ -int mm_sound_add_active_device_changed_callback(mm_sound_active_device_changed_cb func, void *user_data); - +int mm_sound_add_active_device_changed_callback(const char *name,mm_sound_active_device_changed_cb func, void *user_data); /** * This function is to remove active device callback. * + * @param name [in] plugin name (name max size : MM_SOUND_NAME_NUM 32) * @return This function returns MM_ERROR_NONE on success, or negative value * with error code. * @remark None. @@ -2038,8 +2512,7 @@ int active_device_control() * @endcode */ -int mm_sound_remove_active_device_changed_callback(void); - +int mm_sound_remove_active_device_changed_callback(const char *name); /** * Available route changed callback function type. * @@ -2130,6 +2603,40 @@ int available_device_control() * @endcode */ int mm_sound_remove_available_route_changed_callback(void); + + /** + * This function is to set path for active device. + * + * @param device_out [in] active playback device + * @param device_in [in] active capture device + * + * @return This function returns MM_ERROR_NONE on success, or negative value + * with error code. + * @remark None. + * @see None + * @pre None. + * @post None. + * @par Example + * @*/ +int mm_sound_set_sound_path_for_active_device(mm_sound_device_out device_out, mm_sound_device_in device_in); + +/** +* This function is to get current audio path. +* +* @param device_out [in] active playback device +* @param device_in [in] active capture device +* +* @return This function returns MM_ERROR_NONE on success, or negative value +* with error code. +* @remark None. +* @see None +* @pre None. +* @post None. +* @par Example +* @*/ + +int mm_sound_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out); + /** @} */ diff --git a/include/mm_sound_client.h b/include/mm_sound_client.h index 2628e6a..a6a112b 100644 --- a/include/mm_sound_client.h +++ b/include/mm_sound_client.h @@ -23,21 +23,36 @@ #define __MM_SOUND_CLIENT_H__ #include "mm_sound_private.h" +#include "mm_sound_device.h" //#define MEMTYPE_TRANS_PER_MAX (1024 * 1024) /* 1MB */ int MMSoundClientInit(void); int MMSoundClientCallbackFini(void); -int MMSoundClientPlayTone(int number, int vol_type, double volume, int time, int *handle); -int MMSoundClientPlaySound(MMSoundParamType *param, int tone, int keytone, int *handle); +int MMSoundClientPlayTone(int number, int volume_config, double volume, int time, int *handle, bool enable_session); +int MMSoundClientPlaySound(MMSoundPlayParam *param, int tone, int keytone, int *handle); int MMSoundClientStopSound(int handle); int _mm_sound_client_is_route_available(mm_sound_route route, bool *is_available); int _mm_sound_client_foreach_available_route_cb(mm_sound_available_route_cb, void *user_data); -int _mm_sound_client_set_active_route(mm_sound_route route); +int _mm_sound_client_set_active_route(mm_sound_route route, bool need_broadcast); int _mm_sound_client_get_active_device(mm_sound_device_in *device_in, mm_sound_device_out *device_out); -int _mm_sound_client_add_active_device_changed_callback(mm_sound_active_device_changed_cb func, void* user_data); -int _mm_sound_client_remove_active_device_changed_callback(void); +int _mm_sound_client_add_active_device_changed_callback(const char *name, mm_sound_active_device_changed_cb func, void* user_data); +int _mm_sound_client_remove_active_device_changed_callback(const char *name); int _mm_sound_client_add_available_route_changed_callback(mm_sound_available_route_changed_cb func, void* user_data); int _mm_sound_client_remove_available_route_changed_callback(void); +int _mm_sound_client_add_volume_changed_callback(mm_sound_volume_changed_cb func, void* user_data); +int _mm_sound_client_remove_volume_changed_callback(void); +int _mm_sound_client_set_sound_path_for_active_device(mm_sound_device_out device_out, mm_sound_device_in device_in); +int _mm_sound_client_get_current_connected_device_list(int device_flgas, mm_sound_device_list_t **device_list); +int _mm_sound_client_add_device_connected_callback(int device_flags, mm_sound_device_connected_cb func, void* user_data); +int _mm_sound_client_remove_device_connected_callback(void); +int _mm_sound_client_add_device_info_changed_callback(int device_flags, mm_sound_device_info_changed_cb func, void* user_data); +int _mm_sound_client_remove_device_info_changed_callback(void); + +#ifdef PULSE_CLIENT +int MMSoundClientIsBtA2dpOn (bool *connected, char** bt_name); +#endif +int _mm_sound_client_set_active_route_auto(void); +int _mm_sound_client_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out); #endif /* __MM_SOUND_CLIENT_H__ */ diff --git a/include/mm_sound_common.h b/include/mm_sound_common.h old mode 100644 new mode 100755 index daa94d3..9b18afb --- a/include/mm_sound_common.h +++ b/include/mm_sound_common.h @@ -1,82 +1,120 @@ -/* - * libmm-sound - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Seungbae Shin - * - * 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 __MM_SOUND_COMMON_H__ -#define __MM_SOUND_COMMON_H__ - -/////////////////////////////////// -//// MMSOUND VOLUME APIs -/////////////////////////////////// -#define VCONF_KEY_VOLUME_PREFIX "db/private/sound/volume" -#define VCONF_KEY_VOLUME_TYPE_SYSTEM VCONF_KEY_VOLUME_PREFIX"/system" -#define VCONF_KEY_VOLUME_TYPE_NOTIFICATION VCONF_KEY_VOLUME_PREFIX"/notification" -#define VCONF_KEY_VOLUME_TYPE_ALARM VCONF_KEY_VOLUME_PREFIX"/alarm" -#define VCONF_KEY_VOLUME_TYPE_RINGTONE VCONF_KEY_VOLUME_PREFIX"/ringtone" -#define VCONF_KEY_VOLUME_TYPE_MEDIA VCONF_KEY_VOLUME_PREFIX"/media" -#define VCONF_KEY_VOLUME_TYPE_CALL VCONF_KEY_VOLUME_PREFIX"/call" -#define VCONF_KEY_VOLUME_TYPE_ANDROID VCONF_KEY_VOLUME_PREFIX"/fixed" -#define VCONF_KEY_VOLUME_TYPE_JAVA VCONF_KEY_VOLUME_PREFIX"/java" - -#define ASM_READY_KEY "memory/Sound/ASMReady" - -#define MMSOUND_ENTER_CRITICAL_SECTION(x_mutex) \ -switch ( pthread_mutex_lock( x_mutex ) ) \ -{ \ -case EINVAL: \ - debug_warning("try mutex init..\n"); \ - if( 0 > pthread_mutex_init( x_mutex, NULL) ) { \ - return; \ - } else { \ - break; \ - } \ - return; \ -case 0: \ - break; \ -default: \ - debug_error("mutex lock failed\n"); \ - return; \ -} - -#define MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(x_mutex,x_return) \ -switch ( pthread_mutex_lock( x_mutex ) ) \ -{ \ -case EINVAL: \ - debug_warning("try mutex init..\n"); \ - if( 0 > pthread_mutex_init( x_mutex, NULL) ) { \ - return x_return; \ - } else { \ - break; \ - } \ - return x_return; \ -case 0: \ - break; \ -default: \ - debug_error("mutex lock failed\n"); \ - return x_return; \ -} - -#define MMSOUND_LEAVE_CRITICAL_SECTION(x_mutex) \ -if( pthread_mutex_unlock( x_mutex ) ) { \ - debug_error("mutex unlock failed\n"); \ -} - -#endif /* __MM_SOUND_COMMON_H__ */ - +/* + * libmm-sound + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * 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 __MM_SOUND_COMMON_H__ +#define __MM_SOUND_COMMON_H__ + +/////////////////////////////////// +//// MMSOUND VOLUME APIs +/////////////////////////////////// +#define VCONF_KEY_VOLUME_PREFIX "file/private/sound/volume" +#define VCONF_KEY_VOLUME_TYPE_SYSTEM VCONF_KEY_VOLUME_PREFIX"/system" +#define VCONF_KEY_VOLUME_TYPE_NOTIFICATION VCONF_KEY_VOLUME_PREFIX"/notification" +#define VCONF_KEY_VOLUME_TYPE_ALARM VCONF_KEY_VOLUME_PREFIX"/alarm" +#define VCONF_KEY_VOLUME_TYPE_RINGTONE VCONF_KEY_VOLUME_PREFIX"/ringtone" +#define VCONF_KEY_VOLUME_TYPE_MEDIA VCONF_KEY_VOLUME_PREFIX"/media" +#define VCONF_KEY_VOLUME_TYPE_CALL VCONF_KEY_VOLUME_PREFIX"/call" +#define VCONF_KEY_VOLUME_TYPE_VOIP VCONF_KEY_VOLUME_PREFIX"/voip" +#define VCONF_KEY_VOLUME_TYPE_VOICE VCONF_KEY_VOLUME_PREFIX"/voice" +#define VCONF_KEY_VOLUME_TYPE_ANDROID VCONF_KEY_VOLUME_PREFIX"/fixed" + +#define VCONF_KEY_VOLUME_BALANCE VCONF_KEY_VOLUME_PREFIX"/balance" +#define VCONF_KEY_MUTE_ALL VCONF_KEY_VOLUME_PREFIX"/muteall" +#define VCONF_KEY_MONO_AUDIO VCONFKEY_SETAPPL_ACCESSIBILITY_MONO_AUDIO + +#define VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE "memory/private/sound/PrimaryVolumetype" +#define VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE_FORCE "memory/private/sound/PrimaryVolumetypeForce" + + +#ifndef _TIZEN_PUBLIC_ +#define VCONF_KEY_NOISE_REDUCTION VCONFKEY_CALL_NOISE_REDUCTION_STATE_BOOL +#define VCONF_KEY_EXTRA_VOLUME VCONFKEY_CALL_EXTRA_VOLUME_STATE_BOOL +#define VCONF_KEY_WBAMR VCONFKEY_CALL_WBAMR_STATE_BOOL +#define VCONF_KEY_VR_ENABLED VCONFKEY_VOICE_CONTROL_ENABLED +#define VCONF_KEY_VR_RINGTONE_ENABLED VCONFKEY_VOICE_CONTROL_INCOMING_CALL_ENABLED +#ifdef TIZEN_MICRO +#define VCONF_KEY_VR_LEFTHAND_ENABLED VCONFKEY_SETAPPL_PERFERED_ARM_LEFT_BOOL +#endif +#endif +#define ASM_READY_KEY "memory/private/Sound/ASMReady" +#define VCONF_KEY_FMRADIO_RECORDING "memory/private/Sound/FMRadioRecording" + +#define PA_READY "/tmp/.pa_ready" + +#define MMSOUND_ENTER_CRITICAL_SECTION(x_mutex) \ +switch ( pthread_mutex_lock( x_mutex ) ) \ +{ \ +case EINVAL: \ + debug_warning("try mutex init..\n"); \ + if( 0 > pthread_mutex_init( x_mutex, NULL) ) { \ + return; \ + } else { \ + break; \ + } \ + return; \ +case 0: \ + break; \ +default: \ + debug_error("mutex lock failed\n"); \ + return; \ +} + +#define MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(x_mutex,x_return) \ +switch ( pthread_mutex_lock( x_mutex ) ) \ +{ \ +case EINVAL: \ + debug_warning("try mutex init..\n"); \ + if( 0 > pthread_mutex_init( x_mutex, NULL) ) { \ + return x_return; \ + } else { \ + break; \ + } \ + return x_return; \ +case 0: \ + break; \ +default: \ + debug_error("mutex lock failed\n"); \ + return x_return; \ +} + +#define MMSOUND_LEAVE_CRITICAL_SECTION(x_mutex) \ +if( pthread_mutex_unlock( x_mutex ) ) { \ + debug_error("mutex unlock failed\n"); \ +} + +#define MMSOUND_STRNCPY(dst,src,size)\ +do { \ + if(src != NULL && dst != NULL && size > 0) {\ + strncpy(dst,src,size); \ + dst[size-1] = '\0';\ + } else if(dst == NULL) { \ + debug_error("STRNCPY ERROR: Destination String is NULL\n"); \ + } \ + else if(size <= 0) { \ + debug_error("STRNCPY ERROR: Destination String is NULL\n"); \ + } \ + else { \ + debug_error("STRNCPY ERROR: Destination String is NULL\n"); \ + } \ +} while(0) + +#endif /* __MM_SOUND_COMMON_H__ */ + diff --git a/include/mm_sound_device.h b/include/mm_sound_device.h new file mode 100644 index 0000000..6950cd7 --- /dev/null +++ b/include/mm_sound_device.h @@ -0,0 +1,112 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Sangchul Lee + * + * 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. + * + */ + +/** + * @file mm_sound_device.h + * @brief Application interface library for sound module. + * @date + * + * Application interface library for sound module. + */ + +#ifndef __MM_SOUND_DEVICE_H__ +#define __MM_SOUND_DEVICE_H__ + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +#define MAX_DEVICE_NAME_NUM 256 +typedef struct { + int type; + int io_direction; + int id; + char name[MAX_DEVICE_NAME_NUM]; + int state; +} mm_sound_device_t; + +typedef struct { + GList *list; +} mm_sound_device_list_t; + +typedef enum { + DEVICE_IO_DIRECTION_IN, + DEVICE_IO_DIRECTION_OUT, + DEVICE_IO_DIRECTION_BOTH, +} device_io_direction_e; + +typedef enum { + DEVICE_STATE_DEACTIVATED, + DEVICE_STATE_ACTIVATED, +} device_state_e; + +typedef enum { + DEVICE_CHANGED_INFO_STATE, + DEVICE_CHANGED_INFO_IO_DIRECTION, +} device_changed_info_e; + +typedef enum +{ + DEVICE_UPDATE_STATUS_DISCONNECTED = 0, + DEVICE_UPDATE_STATUS_CONNECTED, + DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, + DEVICE_UPDATE_STATUS_CHANGED_INFO_IO_DIRECTION, +} device_update_status_e; + +typedef enum +{ + DEVICE_TYPE_BUILTIN_SPEAKER, /**< Built-in speaker. */ + DEVICE_TYPE_BUILTIN_RECEIVER, /**< Built-in receiver. */ + DEVICE_TYPE_BUILTIN_MIC, /**< Built-in mic. */ + DEVICE_TYPE_AUDIOJACK, /**< Audio jack such as headphone, headset, and so on. */ + DEVICE_TYPE_BLUETOOTH, /**< Bluetooth */ + DEVICE_TYPE_HDMI, /**< HDMI. */ + DEVICE_TYPE_MIRRORING, /**< MIRRORING. */ + DEVICE_TYPE_USB_AUDIO, /**< USB Audio. */ +} device_type_e; + +typedef enum { + DEVICE_IO_DIRECTION_IN_FLAG = 0x0001, /**< Flag for input devices */ + DEVICE_IO_DIRECTION_OUT_FLAG = 0x0002, /**< Flag for output devices */ + DEVICE_IO_DIRECTION_BOTH_FLAG = 0x0004, /**< Flag for input/output devices (both directions are available) */ + DEVICE_TYPE_INTERNAL_FLAG = 0x0010, /**< Flag for built-in devices */ + DEVICE_TYPE_EXTERNAL_FLAG = 0x0020, /**< Flag for external devices */ + DEVICE_STATE_DEACTIVATED_FLAG = 0x1000, /**< Flag for deactivated devices */ + DEVICE_STATE_ACTIVATED_FLAG = 0x2000, /**< Flag for activated devices */ + DEVICE_ALL_FLAG = 0xFFFF, /**< Flag for all devices */ +} device_flag_e; + +typedef enum { + DEVICE_IO_DIRECTION_FLAGS = 0x000F, /**< Flag for io direction */ + DEVICE_TYPE_FLAGS = 0x00F0, /**< Flag for device type */ + DEVICE_STATE_FLAGS = 0xF000, /**< Flag for device state */ +} device_flags_type_e; + +#define IS_INTERNAL_DEVICE(x_device_type) (((DEVICE_TYPE_BUILTIN_SPEAKER <= x_device_type) && (x_device_type <= DEVICE_TYPE_BUILTIN_MIC)) ? true : false) + +#ifdef __cplusplus +} +#endif + +#endif /* __MM_SOUND_DEVICE_H__ */ + diff --git a/include/mm_sound_msg.h b/include/mm_sound_msg.h index e98bf28..4b1789b 100644 --- a/include/mm_sound_msg.h +++ b/include/mm_sound_msg.h @@ -60,6 +60,8 @@ enum { MM_SOUND_MSG_INF_FOREACH_AVAILABLE_ROUTE_CB, MM_SOUND_MSG_REQ_SET_ACTIVE_ROUTE, MM_SOUND_MSG_RES_SET_ACTIVE_ROUTE, + MM_SOUND_MSG_REQ_SET_ACTIVE_ROUTE_AUTO, + MM_SOUND_MSG_RES_SET_ACTIVE_ROUTE_AUTO, MM_SOUND_MSG_REQ_GET_ACTIVE_DEVICE, MM_SOUND_MSG_RES_GET_ACTIVE_DEVICE, MM_SOUND_MSG_REQ_ADD_ACTIVE_DEVICE_CB, @@ -72,6 +74,27 @@ enum { MM_SOUND_MSG_REQ_REMOVE_AVAILABLE_ROUTE_CB, MM_SOUND_MSG_RES_REMOVE_AVAILABLE_ROUTE_CB, MM_SOUND_MSG_INF_AVAILABLE_ROUTE_CB, + MM_SOUND_MSG_REQ_ADD_VOLUME_CB, + MM_SOUND_MSG_RES_ADD_VOLUME_CB, + MM_SOUND_MSG_REQ_REMOVE_VOLUME_CB, + MM_SOUND_MSG_RES_REMOVE_VOLUME_CB, + MM_SOUND_MSG_INF_VOLUME_CB, + MM_SOUND_MSG_REQ_SET_PATH_FOR_ACTIVE_DEVICE, + MM_SOUND_MSG_RES_SET_PATH_FOR_ACTIVE_DEVICE, + MM_SOUND_MSG_REQ_GET_AUDIO_PATH, + MM_SOUND_MSG_RES_GET_AUDIO_PATH, + MM_SOUND_MSG_REQ_ADD_DEVICE_CONNECTED_CB, + MM_SOUND_MSG_RES_ADD_DEVICE_CONNECTED_CB, + MM_SOUND_MSG_REQ_REMOVE_DEVICE_CONNECTED_CB, + MM_SOUND_MSG_RES_REMOVE_DEVICE_CONNECTED_CB, + MM_SOUND_MSG_INF_DEVICE_CONNECTED_CB, + MM_SOUND_MSG_REQ_ADD_DEVICE_INFO_CHANGED_CB, + MM_SOUND_MSG_RES_ADD_DEVICE_INFO_CHANGED_CB, + MM_SOUND_MSG_REQ_REMOVE_DEVICE_INFO_CHANGED_CB, + MM_SOUND_MSG_RES_REMOVE_DEVICE_INFO_CHANGED_CB, + MM_SOUND_MSG_INF_DEVICE_INFO_CHANGED_CB, + MM_SOUND_MSG_REQ_GET_CONNECTED_DEVICE_LIST, + MM_SOUND_MSG_RES_GET_CONNECTED_DEVICE_LIST, }; #define DSIZE sizeof(mm_ipc_msg_t)-sizeof(long) /* data size for rcv & snd */ diff --git a/include/mm_sound_pa_client.h b/include/mm_sound_pa_client.h new file mode 100644 index 0000000..9728c7f --- /dev/null +++ b/include/mm_sound_pa_client.h @@ -0,0 +1,91 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * 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 __MM_SOUND_PA_CLIENT__ + #define __MM_SOUND_PA_CLIENT__ + +#include +#include +#include +#include +#include +#include +#include "include/mm_sound.h" + +typedef enum { + HANDLE_ROUTE_POLICY_DEFAULT, + HANDLE_ROUTE_POLICY_OUT_AUTO, + HANDLE_ROUTE_POLICY_OUT_HANDSET, + HANDLE_ROUTE_POLICY_OUT_ALL, + HANDLE_ROUTE_POLICY_IN_MIRRORING, + HANDLE_ROUTE_POLICY_IN_VOIP, +}MMSoundHandleRoutePolicy; /* custom route policy per handle */ + +typedef enum { + HANDLE_PRIORITY_NORMAL, + HANDLE_PRIORITY_SOLO, + HANDLE_PRIORITY_MAX, +}MMSoundHandlePriority; + +typedef enum { + HANDLE_MODE_OUTPUT, /**< Output mode of handle */ + HANDLE_MODE_OUTPUT_CLOCK, /**< Output mode of gst audio only mode */ + HANDLE_MODE_OUTPUT_VIDEO, /**< Output mode of gst video mode */ + HANDLE_MODE_OUTPUT_LOW_LATENCY, /**< Output mode for low latency play mode. typically for game */ + HANDLE_MODE_INPUT, /**< Input mode of handle */ + HANDLE_MODE_INPUT_HIGH_LATENCY, /**< Input mode for high latency capture mode. */ + HANDLE_MODE_INPUT_LOW_LATENCY, /**< Input mode for low latency capture mode. typically for VoIP */ + HANDLE_MODE_CALL_OUT, /**< for voice call establish */ + HANDLE_MODE_CALL_IN, /**< for voice call establish */ + HANDLE_MODE_OUTPUT_AP_CALL, /**< for VT call on thin modem */ + HANDLE_MODE_INPUT_AP_CALL, /**< for VT call on thin modem */ + HANDLE_MODE_NUM, /**< Number of mode */ +}MMSoundHandleMode; + +enum mm_sound_handle_direction_t { + HANDLE_DIRECTION_NONE, + HANDLE_DIRECTION_IN, + HANDLE_DIRECTION_OUT, +}; + +typedef struct mm_sound_handle_route_info{ + MMSoundHandleRoutePolicy policy; + mm_sound_device_in device_in; + mm_sound_device_out device_out; + bool do_not_restore; +}mm_sound_handle_route_info; + +int mm_sound_pa_open(MMSoundHandleMode mode, mm_sound_handle_route_info *route_info, MMSoundHandlePriority priority, int volume_config, pa_sample_spec* ss, pa_channel_map* channel_map, int* size); +int mm_sound_pa_read(const int handle, void* buf, const int size); +int mm_sound_pa_write(const int handle, void* buf, const int size); +int mm_sound_pa_close(const int handle); +int mm_sound_pa_cork(const int handle, const int cork); +int mm_sound_pa_drain(const int handle); +int mm_sound_pa_set_volume_by_type(const int type, const int value); +int mm_sound_pa_get_latency(const int handle, int* latency); +int mm_sound_pa_set_call_mute(const int type, const int mute, int direction); +int mm_sound_pa_get_volume_max(const int type, int* step); +int mm_sound_pa_get_volume_level(const int handle, const int type, int* level); +int mm_sound_pa_set_volume_level(const int handle, const int type, int level); +int mm_sound_pa_set_mute(const int handle, const int type, int direction, int mute); +int mm_sound_pa_get_mute(const int handle, const int type, int direction, int* mute); +int mm_sound_pa_corkall(int cork); + +#endif diff --git a/include/mm_sound_pcm_async.h b/include/mm_sound_pcm_async.h new file mode 100644 index 0000000..4f3eff6 --- /dev/null +++ b/include/mm_sound_pcm_async.h @@ -0,0 +1,50 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * 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 __MM_SOUND_PCM_ASYNC__ +#define __MM_SOUND_PCM_ASYNC__ + +/* Common */ +typedef void (*mm_sound_pcm_stream_cb_t)(void *p, size_t nbytes, void *userdata); + +int mm_sound_pcm_set_message_callback_async (MMSoundPcmHandle_t handle, MMMessageCallback callback, void *user_param); +int mm_sound_pcm_get_latency_async(MMSoundPcmHandle_t handle, int *latency); +int mm_sound_pcm_is_started_async(MMSoundPcmHandle_t handle, bool *is_started); + +/* PCM capture async */ +int mm_sound_pcm_capture_open_async(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, + MMSoundPcmFormat_t format, mm_sound_source_type_e source_type, + mm_sound_pcm_stream_cb_t callback, void* userdata); +int mm_sound_pcm_capture_start_async(MMSoundPcmHandle_t handle); +int mm_sound_pcm_capture_stop_async(MMSoundPcmHandle_t handle); +int mm_sound_pcm_capture_peek(MMSoundPcmHandle_t handle, const void **buffer, const unsigned int *length); +int mm_sound_pcm_capture_drop(MMSoundPcmHandle_t handle); +int mm_sound_pcm_capture_close_async(MMSoundPcmHandle_t handle); + +/* PCM playback async */ +int mm_sound_pcm_play_open_async (MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, + MMSoundPcmFormat_t format, int volume_config, + mm_sound_pcm_stream_cb_t callback, void* userdata); +int mm_sound_pcm_play_start_async(MMSoundPcmHandle_t handle); +int mm_sound_pcm_play_stop_async(MMSoundPcmHandle_t handle); +int mm_sound_pcm_play_write_async(MMSoundPcmHandle_t handle, void* ptr, unsigned int length_byte); +int mm_sound_pcm_play_close_async(MMSoundPcmHandle_t handle); + +#endif /* __MM_SOUND_PCM_ASYNC__ */ diff --git a/include/mm_sound_private.h b/include/mm_sound_private.h index 82cda96..c8c1a12 100644 --- a/include/mm_sound_private.h +++ b/include/mm_sound_private.h @@ -46,6 +46,9 @@ */ +#define MM_SOUND_VOLUME_CONFIG_TYPE(vol) (vol & 0x00FF) +#define MM_SOUND_VOLUME_CONFIG_GAIN(vol) (vol & 0xFF00) + enum MMSoundGainType { MM_SOUND_GAIN_KEYTONE = 0, /**< hw gain configuration for keytone play */ MM_SOUND_GAIN_RINGTONE, /**< hw gain configuration for ringtone play */ @@ -101,11 +104,13 @@ enum MMSoundPathOptionType { enum mm_sound_handle_route_t { MM_SOUND_HANDLE_ROUTE_USING_CURRENT, - MM_SOUND_HANDLE_ROUTE_SPEAKER + MM_SOUND_HANDLE_ROUTE_SPEAKER, + MM_SOUND_HANDLE_ROUTE_SPEAKER_NO_RESTORE }; typedef struct { const char *filename; /**< filename to play */ + bool skip_session; /**< skip session control */ int volume; /**< relative volume level */ int loop; /**< loop count */ mm_sound_stop_callback_func callback; /**< callback function when playing is terminated */ @@ -113,15 +118,15 @@ typedef struct { void *mem_ptr; /**< memory buffer to play */ int mem_size; /**< size of memory buffer */ int handle_route; /**< 1 for speaker, 0 for current */ - int volume_table; /**< Volume Type (SW Volume table type) */ + int volume_config; /**< volume type & volume gain */ int priority; /**< 0 or 1 */ -} MMSoundParamType; +} MMSoundPlayParam; /** * This function is to play system sound with specified parameters. * - * @param param [in] Reference pointer to MMSoundParamType structure + * @param param [in] Reference pointer to MMSoundPlayParam structure * @param handle [out] Handle of sound play. * * @return This function returns MM_ERROR_NONE on success, or negative value @@ -134,64 +139,29 @@ typedef struct { * @since R1, 1.0 * @limo */ -int mm_sound_play_sound_ex(MMSoundParamType *param, int *handle); +int mm_sound_play_sound_ex(MMSoundPlayParam *param, int *handle); /** * This function is to play key sound. * - * @param filename [in] keytone filename to play - * @param vol_type [in] Volume type + * @param filename [in] keytone filename to play + * @param volume_config [in] Volume type & volume gain * * @return This function returns MM_ERROR_NONE on success, or negative value * with error code. * * @remark This function provide low latency sound play (such as dialer keytone) * using fixed spec of wave file (44100Hz, mono channel) - * @see volume_type_t mm_sound_volume_set_value + * @see volume_type_t volume_gain_t mm_sound_volume_set_value */ -int mm_sound_play_keysound(const char *filename, const volume_type_t vol_type); - +int mm_sound_play_keysound(const char *filename, int volume_config); -/** - * This function is to set sound device path. - * - * @param gain [in] sound path gain - * @param output [in] sound path out device - * @param input [in] sound path in device - * @param option [in] Sound path option - * MM_SOUND_PATH_OPTION_NONE - * MM_SOUND_PATH_OPTION_AUTO_HEADSET_CONTROL - * MM_SOUND_PATH_OPTION_SPEAKER_WITH_HEADSET - * - * @return This function returns MM_ERROR_NONE on success, or negative value - * with error code. - * @remark - * @see mm_sound_get_path - * @since 1.0 - */ -int mm_sound_set_path(int gain, int output, int input, int option); +int mm_sound_pcm_play_open_ex (MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, int volume_config, int asm_event); +int mm_sound_boot_ready(int timeout_sec); -/** - * This function retreives current sound device path. - * - * @param gain [out] Sound device path - * @param output [out] Sound output device on/off - * @param input [out] Sound input device on/off - * @param option [out] Sound path option - * MM_SOUND_PATH_OPTION_NONE - * MM_SOUND_PATH_OPTION_AUTO_HEADSET_CONTROL - * MM_SOUND_PATH_OPTION_SPEAKER_WITH_HEADSET - * - * @return This function returns MM_ERROR_NONE on success, or negative value - * with error code. - * @remark - * @see mm_sound_set_path - */ -int mm_sound_get_path(int *gain, int *output, int *input, int *option); - -int mm_sound_pcm_play_open_ex (MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, const volume_type_t vol_type, int asm_event); +int mm_sound_boot_play_sound(char* path); /** @} diff --git a/include/mm_sound_utils.h b/include/mm_sound_utils.h old mode 100644 new mode 100755 index aadf9e5..9ee2593 --- a/include/mm_sound_utils.h +++ b/include/mm_sound_utils.h @@ -43,6 +43,26 @@ int _mm_sound_get_valid_route_list(mm_sound_route **route_list); bool _mm_sound_is_route_valid(mm_sound_route route); void _mm_sound_get_devices_from_route(mm_sound_route route, mm_sound_device_in *device_in, mm_sound_device_out *device_out); +bool _mm_sound_check_hibernation (const char *path); +int _mm_sound_volume_add_callback(volume_type_t type, void *func, void* user_data); +int _mm_sound_volume_remove_callback(volume_type_t type, void *func); +int _mm_sound_volume_get_value_by_type(volume_type_t type, unsigned int *value); +int _mm_sound_volume_set_value_by_type(volume_type_t type, unsigned int value); +int _mm_sound_muteall_add_callback(void *func); +int _mm_sound_muteall_remove_callback(void *func); +int _mm_sound_volume_set_balance(float balance); +int _mm_sound_volume_get_balance(float *balance); +int _mm_sound_set_muteall(int muteall); +int _mm_sound_get_muteall(int *muteall); +int _mm_sound_set_stereo_to_mono(int ismono); +int _mm_sound_get_stereo_to_mono(int *ismono); +int _mm_sound_get_earjack_type (int *type); +int _mm_sound_get_dock_type (int *type); +mm_sound_device_in _mm_sound_get_device_in_from_path (int path); +mm_sound_device_out _mm_sound_get_device_out_from_path (int path); + +bool _mm_sound_is_recording (void); +bool _mm_sound_is_mute_policy (void); #ifdef __cplusplus } diff --git a/init/Makefile.am b/init/Makefile.am deleted file mode 100644 index 504f7b4..0000000 --- a/init/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -installinitscriptdir = /etc/rc.d/init.d -installinitscript_SCRIPTS = $(srcdir)/soundserver diff --git a/init/mmfwaudio b/init/mmfwaudio deleted file mode 100755 index 9ddc192..0000000 --- a/init/mmfwaudio +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# -### BEGIN INIT INFO -# Provides: mmfwaudio -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: start sound_server daemon -### END INIT INFO - -dlogutil -v threadtime -f /var/log/mmfw_audio.log -r 1000 -n 10 MMFW_AVAUDIO:W MMFW_SOUND MMFW_SESSIONMGR & diff --git a/init/soundserver b/init/soundserver deleted file mode 100755 index d7b7884..0000000 --- a/init/soundserver +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# -### BEGIN INIT INFO -# Provides: soundserver -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: start sound_server daemon -### END INIT INFO - -if [ -x /usr/bin/sound_server ]; then - /usr/bin/sound_server -S& -fi diff --git a/libmm-sound-tool.manifest b/libmm-sound-tool.manifest new file mode 100644 index 0000000..8b135ea --- /dev/null +++ b/libmm-sound-tool.manifest @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/libmm-sound.manifest b/libmm-sound.manifest new file mode 100644 index 0000000..75a676e --- /dev/null +++ b/libmm-sound.manifest @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/missing b/missing deleted file mode 100755 index 1c8ff70..0000000 --- a/missing +++ /dev/null @@ -1,367 +0,0 @@ -#! /bin/sh -# Common stub for a few missing GNU programs while installing. - -scriptversion=2006-05-10.23 - -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006 -# Free Software Foundation, Inc. -# Originally by Fran,cois Pinard , 1996. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 -fi - -run=: -sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' -sed_minuso='s/.* -o \([^ ]*\).*/\1/p' - -# In the cases where this matters, `missing' is being run in the -# srcdir already. -if test -f configure.ac; then - configure_ac=configure.ac -else - configure_ac=configure.in -fi - -msg="missing on your system" - -case $1 in ---run) - # Try to run requested program, and just exit if it succeeds. - run= - shift - "$@" && exit 0 - # Exit code 63 means version mismatch. This often happens - # when the user try to use an ancient version of a tool on - # a file that requires a minimum version. In this case we - # we should proceed has if the program had been absent, or - # if --run hadn't been passed. - if test $? = 63; then - run=: - msg="probably too old" - fi - ;; - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - --run try to run the given command, and emulate it if it fails - -Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - autom4te touch the output file, or create a stub one - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - help2man touch the output file - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - tar try tar, gnutar, gtar, then tar without non-portable flags - yacc create \`y.tab.[ch]', if possible, from existing .[ch] - -Send bug reports to ." - exit $? - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing $scriptversion (GNU Automake)" - exit $? - ;; - - -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 - ;; - -esac - -# Now exit if we have it, but it failed. Also exit now if we -# don't have it and --version was passed (most likely to detect -# the program). -case $1 in - lex|yacc) - # Not GNU programs, they don't have --version. - ;; - - tar) - if test -n "$run"; then - echo 1>&2 "ERROR: \`tar' requires --run" - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - exit 1 - fi - ;; - - *) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - # Could not run --version or --help. This is probably someone - # running `$TOOL --version' or `$TOOL --help' to check whether - # $TOOL exists and not knowing $TOOL uses missing. - exit 1 - fi - ;; -esac - -# If it does not exist, or fails to run (possibly an outdated version), -# try to emulate it. -case $1 in - aclocal*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acinclude.m4' or \`${configure_ac}'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`${configure_ac}'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acconfig.h' or \`${configure_ac}'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case $f in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - autom4te) - echo 1>&2 "\ -WARNING: \`$1' is needed, but is $msg. - You might have modified some files without having the - proper tools for further handling them. - You can get \`$1' as part of \`Autoconf' from any GNU - archive site." - - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo "#! /bin/sh" - echo "# Created by GNU Automake missing as a replacement of" - echo "# $ $@" - echo "exit 0" - chmod +x $file - exit 1 - fi - ;; - - bison|yacc) - echo 1>&2 "\ -WARNING: \`$1' $msg. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if test $# -ne 1; then - eval LASTARG="\${$#}" - case $LASTARG in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if test ! -f y.tab.h; then - echo >y.tab.h - fi - if test ! -f y.tab.c; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex|flex) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if test $# -ne 1; then - eval LASTARG="\${$#}" - case $LASTARG in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if test ! -f lex.yy.c; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - help2man) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a dependency of a manual page. You may need the - \`Help2man' package in order for those modifications to take - effect. You can get \`Help2man' from any GNU archive site." - - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo ".ab help2man is required to generate this page" - exit 1 - fi - ;; - - makeinfo) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - # The file to touch is that specified with -o ... - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -z "$file"; then - # ... or it is the one specified with @setfilename ... - infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n ' - /^@setfilename/{ - s/.* \([^ ]*\) *$/\1/ - p - q - }' $infile` - # ... or it is derived from the source name (dir/f.texi becomes f.info) - test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info - fi - # If the file does not exist, the user really needs makeinfo; - # let's fail without touching anything. - test -f $file || exit 1 - touch $file - ;; - - tar) - shift - - # We have already tried tar in the generic part. - # Look for gnutar/gtar before invocation to avoid ugly error - # messages. - if (gnutar --version > /dev/null 2>&1); then - gnutar "$@" && exit 0 - fi - if (gtar --version > /dev/null 2>&1); then - gtar "$@" && exit 0 - fi - firstarg="$1" - if shift; then - case $firstarg in - *o*) - firstarg=`echo "$firstarg" | sed s/o//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - case $firstarg in - *h*) - firstarg=`echo "$firstarg" | sed s/h//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - fi - - echo 1>&2 "\ -WARNING: I can't seem to be able to run \`tar' with the given arguments. - You may want to install GNU tar or Free paxutils, or check the - command line arguments." - exit 1 - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and is $msg. - You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequisites for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/mm_sound.c b/mm_sound.c old mode 100644 new mode 100755 index c297f78..1bba912 --- a/mm_sound.c +++ b/mm_sound.c @@ -29,7 +29,6 @@ #include #include -#include #include #include @@ -40,19 +39,19 @@ #include "include/mm_sound.h" #include "include/mm_sound_utils.h" #include "include/mm_sound_client.h" +#include "include/mm_sound_pa_client.h" #include "include/mm_ipc.h" #include "include/mm_sound_common.h" -#include -#include -#include +#define VOLUME_MAX_MULTIMEDIA 16 +#define VOLUME_MAX_BASIC 8 +#define VOLUME_MAX_SINGLE 1 + + +#define MASTER_VOLUME_MAX 100 +#define MASTER_VOLUME_MIN 0 -#define MAX_FILE_LENGTH 256 -#define MAX_MEMORY_SIZE 1048576 /* Max memory size 1024*1024 (1MB) */ -#define _MIN_SYSTEM_SAMPLERATE 8000 -#define _MAX_SYSTEM_SAMPLERATE 48000 -#define MIN_TONE_PLAY_TIME 300 typedef struct { volume_callback_fn func; @@ -64,27 +63,14 @@ volume_cb_param g_volume_param[VOLUME_TYPE_MAX]; static pthread_mutex_t _volume_mutex = PTHREAD_MUTEX_INITIALIZER; -typedef struct { - avsys_handle_t audio_handle; - int asm_handle; - ASM_sound_events_t asm_event; - - bool is_started; - bool is_playback; - - MMMessageCallback msg_cb; - void *msg_cb_param; +static char *volume_type_str[VOLUME_TYPE_MAX] = { "SYSTEM", "NOTIFICATION", "ALARM", "RINGTONE", "MEDIA", "CALL", "VOIP", "VOICE", "FIXED"}; +static char* __get_volume_str (volume_type_t type) +{ + return (type >= VOLUME_TYPE_SYSTEM && type < VOLUME_TYPE_MAX)? volume_type_str[type] : "Unknown"; +} -} mm_sound_pcm_t; - -static int _pcm_sound_start (MMSoundPcmHandle_t handle); -static int _pcm_sound_stop_internal (MMSoundPcmHandle_t handle); -static int _pcm_sound_stop(MMSoundPcmHandle_t handle); - -static void __sound_pcm_send_message (mm_sound_pcm_t *pcmHandle, int message, int code); - -int _validate_volume(volume_type_t type, int value) +static int __validate_volume(volume_type_t type, int value) { if (value < 0) return -1; @@ -92,22 +78,23 @@ int _validate_volume(volume_type_t type, int value) switch (type) { case VOLUME_TYPE_CALL: - if (value >= AVSYS_AUDIO_VOLUME_MAX_BASIC) { + case VOLUME_TYPE_VOIP: + if (value >= VOLUME_MAX_BASIC) { return -1; } break; case VOLUME_TYPE_SYSTEM: case VOLUME_TYPE_MEDIA: case VOLUME_TYPE_ALARM: - case VOLUME_TYPE_EXT_JAVA: case VOLUME_TYPE_NOTIFICATION: case VOLUME_TYPE_RINGTONE: - if (value >= AVSYS_AUDIO_VOLUME_MAX_MULTIMEDIA) { + case VOLUME_TYPE_VOICE: + if (value >= VOLUME_MAX_MULTIMEDIA) { return -1; } break; case VOLUME_TYPE_EXT_ANDROID: - if (value >= AVSYS_AUDIO_VOLUME_MAX_SINGLE) { + if (value >= VOLUME_MAX_SINGLE) { return -1; } break; @@ -118,7 +105,7 @@ int _validate_volume(volume_type_t type, int value) return 0; } -void volume_changed_cb(keynode_t* node, void* data) +static void volume_changed_cb(keynode_t* node, void* data) { volume_cb_param* param = (volume_cb_param*) data; @@ -127,7 +114,7 @@ void volume_changed_cb(keynode_t* node, void* data) MMSOUND_ENTER_CRITICAL_SECTION( &_volume_mutex ) if(param && (param->func != NULL)) { - debug_msg("funcion 0x%x\n", param->func); + debug_log("function 0x%x\n", param->func); ((volume_callback_fn)param->func)(param->data); } @@ -137,1026 +124,488 @@ void volume_changed_cb(keynode_t* node, void* data) EXPORT_API int mm_sound_volume_add_callback(volume_type_t type, volume_callback_fn func, void* user_data) { - char *keystr[] = {VCONF_KEY_VOLUME_TYPE_SYSTEM, VCONF_KEY_VOLUME_TYPE_NOTIFICATION, VCONF_KEY_VOLUME_TYPE_ALARM, - VCONF_KEY_VOLUME_TYPE_RINGTONE, VCONF_KEY_VOLUME_TYPE_MEDIA, VCONF_KEY_VOLUME_TYPE_CALL, - VCONF_KEY_VOLUME_TYPE_ANDROID,VCONF_KEY_VOLUME_TYPE_JAVA}; - - debug_fenter(); + debug_msg("type = (%d)%15s, func = %p, user_data = %p", type, __get_volume_str(type), func, user_data); /* Check input param */ - if(type < VOLUME_TYPE_SYSTEM || type >=VOLUME_TYPE_MAX) { + if (type < 0 || type >= VOLUME_TYPE_MAX) { + debug_error("invalid argument\n"); return MM_ERROR_INVALID_ARGUMENT; } - if(!func) { + if (!func) { debug_warning("callback function is null\n"); return MM_ERROR_INVALID_ARGUMENT; } - MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN( &_volume_mutex, MM_ERROR_SOUND_INTERNAL ) + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN( &_volume_mutex, MM_ERROR_SOUND_INTERNAL ); g_volume_param[type].func = func; g_volume_param[type].data = user_data; g_volume_param[type].type = type; - MMSOUND_LEAVE_CRITICAL_SECTION( &_volume_mutex ) + MMSOUND_LEAVE_CRITICAL_SECTION( &_volume_mutex ); - return vconf_notify_key_changed(keystr[type], volume_changed_cb, (void*)&g_volume_param[type]); + return _mm_sound_volume_add_callback(type, volume_changed_cb, (void*)&g_volume_param[type]); } EXPORT_API int mm_sound_volume_remove_callback(volume_type_t type) { - char *keystr[] = {VCONF_KEY_VOLUME_TYPE_SYSTEM, VCONF_KEY_VOLUME_TYPE_NOTIFICATION, VCONF_KEY_VOLUME_TYPE_ALARM, - VCONF_KEY_VOLUME_TYPE_RINGTONE, VCONF_KEY_VOLUME_TYPE_MEDIA, VCONF_KEY_VOLUME_TYPE_CALL, - VCONF_KEY_VOLUME_TYPE_ANDROID,VCONF_KEY_VOLUME_TYPE_JAVA}; - debug_fenter(); + debug_msg("type = (%d)%s", type, __get_volume_str(type)); - if(type < VOLUME_TYPE_SYSTEM || type >=VOLUME_TYPE_MAX) { + if(type < 0 || type >=VOLUME_TYPE_MAX) { + debug_error("invalid argument\n"); return MM_ERROR_INVALID_ARGUMENT; } - MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN( &_volume_mutex, MM_ERROR_SOUND_INTERNAL ) + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN( &_volume_mutex, MM_ERROR_SOUND_INTERNAL ); g_volume_param[type].func = NULL; g_volume_param[type].data = NULL; g_volume_param[type].type = type; - MMSOUND_LEAVE_CRITICAL_SECTION( &_volume_mutex ) + MMSOUND_LEAVE_CRITICAL_SECTION( &_volume_mutex ); - return vconf_ignore_key_changed(keystr[type], volume_changed_cb); + return _mm_sound_volume_remove_callback(type, volume_changed_cb); } EXPORT_API -int mm_sound_get_volume_step(volume_type_t type, int *step) +int mm_sound_add_volume_changed_callback(mm_sound_volume_changed_cb func, void* user_data) { - printf("\n**********\n\nTHIS FUNCTION HAS DEFPRECATED [%s]\n\n \ - use mm_sound_volume_get_step() instead\n\n**********\n", __func__); - return mm_sound_volume_get_step(type, step); -} - -EXPORT_API -int mm_sound_volume_get_step(volume_type_t type, int *step) -{ - int err; - - debug_fenter(); + int ret = MM_ERROR_NONE; - /* Check input param */ - if(step == NULL) { - debug_error("second parameter is null\n"); - return MM_ERROR_INVALID_ARGUMENT; - } - if(type < VOLUME_TYPE_SYSTEM || type >= VOLUME_TYPE_MAX) { - debug_error("Invalid type value %d\n", (int)type); + if (func == NULL) { + debug_error("argument is not valid\n"); return MM_ERROR_INVALID_ARGUMENT; } - err = avsys_audio_get_volume_max_ex((int)type, step); - if (AVSYS_FAIL(err)) { - err = MM_ERROR_INVALID_ARGUMENT; + ret = _mm_sound_client_add_volume_changed_callback(func, user_data); + if (ret < 0) { + debug_error("Can not add volume changed callback, ret = %x\n", ret); } - debug_fleave(); - return MM_ERROR_NONE; + return ret; } EXPORT_API -int mm_sound_volume_set_value(volume_type_t type, const unsigned int value) +int mm_sound_remove_volume_changed_callback(void) { int ret = MM_ERROR_NONE; - char *keystr[] = {VCONF_KEY_VOLUME_TYPE_SYSTEM, VCONF_KEY_VOLUME_TYPE_NOTIFICATION, VCONF_KEY_VOLUME_TYPE_ALARM, - VCONF_KEY_VOLUME_TYPE_RINGTONE, VCONF_KEY_VOLUME_TYPE_MEDIA, VCONF_KEY_VOLUME_TYPE_CALL, - VCONF_KEY_VOLUME_TYPE_ANDROID,VCONF_KEY_VOLUME_TYPE_JAVA}; - int vconf_value = 0; -#ifdef SEPARATE_EARPHONE_VOLUME - system_audio_route_device_t dev = 0; -#endif - - debug_fenter(); - - /* Check input param */ - if (0 > _validate_volume(type, (int)value)) { - debug_error("invalid volume type %d, value %u\n", type, value); - return MM_ERROR_INVALID_ARGUMENT; - } -#ifdef SEPARATE_EARPHONE_VOLUME - /* Get volume value from VCONF */ - if (vconf_get_int(keystr[type], &vconf_value)){ - debug_error("Can not get %s as %d\n", keystr[type], vconf_value); - return MM_ERROR_SOUND_INTERNAL; - } - - /* Calculate volume value of current device */ - mm_sound_route_get_playing_device(&dev); - if (dev == SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_EARPHONE) { - vconf_value = 0x10000 | (vconf_value & 0x00FF) | (value << 8); - debug_log("volume_set_value [earphone] %d(0x%04x)", value, vconf_value); - } else { - vconf_value = (vconf_value & 0xFF00) | value; - debug_log("volume_set_value [speaker] %d(0x%04x)", value, vconf_value); - } -#else - vconf_value = value; -#endif - - /* Set volume value to VCONF */ - if (vconf_set_int(keystr[type], vconf_value)) { - debug_error("Can not set %s as %d\n", keystr[type], vconf_value); - ret = MM_ERROR_SOUND_INTERNAL; - } else { - /* update shared memory value */ - ret = avsys_audio_set_volume_by_type(type, value); - if (AVSYS_FAIL(ret)) { - debug_error("Can not set volume to shared memory 0x%x\n", ret); - } + ret = _mm_sound_client_remove_volume_changed_callback(); + if (ret < 0) { + debug_error("Can not remove volume changed callback, ret = %x\n", ret); } - debug_fleave(); return ret; } EXPORT_API -int mm_sound_volume_get_value(volume_type_t type, unsigned int *value) +int mm_sound_muteall_add_callback(muteall_callback_fn func) { - int ret = MM_ERROR_NONE; - char *keystr[] = {VCONF_KEY_VOLUME_TYPE_SYSTEM, VCONF_KEY_VOLUME_TYPE_NOTIFICATION, VCONF_KEY_VOLUME_TYPE_ALARM, - VCONF_KEY_VOLUME_TYPE_RINGTONE, VCONF_KEY_VOLUME_TYPE_MEDIA, VCONF_KEY_VOLUME_TYPE_CALL, - VCONF_KEY_VOLUME_TYPE_ANDROID,VCONF_KEY_VOLUME_TYPE_JAVA}; - int vconf_value = 0; -#ifdef SEPARATE_EARPHONE_VOLUME - system_audio_route_device_t dev = 0; -#endif + debug_msg("func = %p", func); - debug_fenter(); - - /* Check input param */ - if (value == NULL) - return MM_ERROR_INVALID_ARGUMENT; - if (type < 0 || type >= VOLUME_TYPE_MAX) { - debug_error("invalid volume type value %d\n", type); + if (!func) { + debug_warning("callback function is null\n"); return MM_ERROR_INVALID_ARGUMENT; } - /* Get volume value from VCONF */ - if (vconf_get_int(keystr[type], &vconf_value)) { - debug_error("Can not get value of %s\n", keystr[type]); - ret = MM_ERROR_SOUND_INTERNAL; - } - -#ifdef SEPARATE_EARPHONE_VOLUME - /* Get volume value of current device */ - mm_sound_route_get_playing_device(&dev); - if (dev == SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_EARPHONE) { - *value = (vconf_value >> 8) & 0x00FF; - debug_log("volume_get_value [earphone] %d(0x%04x)", *value, vconf_value); - } else { - *value = vconf_value & 0x00FF; - debug_log("volume_get_value [speaker] %d(0x%04x)", *value, vconf_value); - } -#else - *value = vconf_value; -#endif - - debug_fleave(); - return ret; + return _mm_sound_muteall_add_callback(func); } EXPORT_API -int mm_sound_volume_primary_type_set(volume_type_t type) +int mm_sound_muteall_remove_callback(muteall_callback_fn func) { - pid_t mypid; - int ret = MM_ERROR_NONE; + debug_msg("func = %p", func); - /* Check input param */ - if(type < VOLUME_TYPE_SYSTEM || type >= VOLUME_TYPE_MAX) + if (!func) { + debug_warning("callback function is null\n"); return MM_ERROR_INVALID_ARGUMENT; - - debug_fenter(); - - mypid = getpid(); - if(AVSYS_FAIL(avsys_audio_set_primary_volume((int)mypid, type))) { - debug_error("Can not set primary volume [%d, %d]\n", mypid, type); - ret = MM_ERROR_SOUND_INTERNAL; } - debug_fleave(); - return ret; + return _mm_sound_muteall_remove_callback(func); } EXPORT_API -int mm_sound_volume_primary_type_clear() +int mm_sound_get_volume_step(volume_type_t type, int *step) { - pid_t mypid; - int ret = MM_ERROR_NONE; - - debug_fenter(); - - mypid = getpid(); - if(AVSYS_FAIL(avsys_audio_clear_primary_volume((int)mypid))) { - debug_error("Can not clear primary volume [%d]\n", mypid); - ret = MM_ERROR_SOUND_INTERNAL; - } - - debug_fleave(); - return ret; + debug_error("\n**********\n\nTHIS FUNCTION HAS DEFPRECATED\n\n \ + use mm_sound_volume_get_step() instead\n\n**********\n"); + return mm_sound_volume_get_step(type, step); } EXPORT_API -int mm_sound_volume_get_current_playing_type(volume_type_t *type) +int mm_sound_volume_get_step(volume_type_t type, int *step) { - int result = AVSYS_STATE_SUCCESS; - int voltype = AVSYS_AUDIO_VOLUME_TYPE_SYSTEM; - - debug_fenter(); + int err; /* Check input param */ - if(type == NULL) { + if (step == NULL) { + debug_error("second parameter is null\n"); return MM_ERROR_INVALID_ARGUMENT; } - - result = avsys_audio_get_current_playing_volume_type(&voltype); - if(result == AVSYS_STATE_SUCCESS) { - *type = voltype; - return MM_ERROR_NONE; - } else if(result ==AVSYS_STATE_ERR_ALLOCATION ) { - return MM_ERROR_SOUND_VOLUME_NO_INSTANCE; - } else if(result == AVSYS_STATE_ERR_INVALID_MODE) { - return MM_ERROR_SOUND_VOLUME_CAPTURE_ONLY; - } else { - return MM_ERROR_SOUND_INTERNAL; + if (type < 0 || type >= VOLUME_TYPE_MAX) { + debug_error("Invalid type value %d\n", (int)type); + return MM_ERROR_INVALID_ARGUMENT; } -} - -/////////////////////////////////// -//// MMSOUND PCM APIs -/////////////////////////////////// - -int _get_asm_event_type(ASM_sound_events_t *type) -{ - int sessionType = MM_SESSION_TYPE_SHARE; - ASM_sound_events_t asm_event; - - if(type == NULL) - return MM_ERROR_SOUND_INVALID_POINTER; - - /* read session type */ - if(_mm_session_util_read_type(-1, &sessionType) < 0) { - debug_log("Read Session Type failed. Set default \"Share\" type\n"); - sessionType = MM_SESSION_TYPE_SHARE; - if(mm_session_init(sessionType) < 0) { - debug_error("mm_session_init() failed\n"); - return MM_ERROR_SOUND_INTERNAL; - } + if(MM_ERROR_NONE != mm_sound_pa_get_volume_max(type, step)) { + err = MM_ERROR_INVALID_ARGUMENT; } - /* convert MM_SESSION_TYPE to ASM_EVENT_TYPE */ - switch (sessionType) - { - case MM_SESSION_TYPE_SHARE: - asm_event = ASM_EVENT_SHARE_MMSOUND; - break; - case MM_SESSION_TYPE_EXCLUSIVE: - asm_event = ASM_EVENT_EXCLUSIVE_MMSOUND; - break; - case MM_SESSION_TYPE_NOTIFY: - asm_event = ASM_EVENT_NOTIFY; - break; - case MM_SESSION_TYPE_ALARM: - asm_event = ASM_EVENT_ALARM; - break; - case MM_SESSION_TYPE_CALL: - asm_event = ASM_EVENT_CALL; - break; - case MM_SESSION_TYPE_VIDEOCALL: - asm_event = ASM_EVENT_VIDEOCALL; - break; - default: - debug_error("Unexpected %d\n", sessionType); - return MM_ERROR_SOUND_INTERNAL; - } + debug_msg("type = (%d)%15s, step = %d", type, __get_volume_str(type), *step); - *type = asm_event; return MM_ERROR_NONE; } -static void __sound_pcm_send_message (mm_sound_pcm_t *pcmHandle, int message, int code) -{ - int ret = 0; - if (pcmHandle->msg_cb) { - MMMessageParamType msg; - msg.union_type = MM_MSG_UNION_CODE; - msg.code = code; - - debug_log ("calling msg callback(%p) with message(%d), code(%d), msg callback param(%p)\n", - pcmHandle->msg_cb, message, msg.code, pcmHandle->msg_cb_param); - ret = pcmHandle->msg_cb(message, &msg, pcmHandle->msg_cb_param); - debug_log ("msg callback returned (%d)\n", ret); - } else { - debug_log ("No pcm msg callback\n"); - } -} - -ASM_cb_result_t sound_pcm_asm_callback(int handle, ASM_event_sources_t event_src, ASM_sound_commands_t command, unsigned int sound_status, void *cb_data) -{ - mm_sound_pcm_t *pcmHandle = NULL; - ASM_cb_result_t cb_res = ASM_CB_RES_IGNORE; - - /* Check input param */ - pcmHandle = (mm_sound_pcm_t *)cb_data; - if(pcmHandle == NULL) { - debug_error("sound_pcm_asm_callback cb_data is null\n"); - return cb_res; - } - - debug_log ("command = %d, handle = %p, is_started = %d\n",command, pcmHandle, pcmHandle->is_started); - switch(command) - { - case ASM_COMMAND_STOP: - /* Do stop */ - _pcm_sound_stop_internal (pcmHandle); - cb_res = ASM_CB_RES_PAUSE; - break; - - case ASM_COMMAND_RESUME: - cb_res = ASM_CB_RES_IGNORE; - break; - - case ASM_COMMAND_PAUSE: - case ASM_COMMAND_PLAY: - case ASM_COMMAND_NONE: - debug_error ("Not an expected case!!!!\n"); - break; - } - - /* execute user callback if callback available */ - __sound_pcm_send_message (pcmHandle, MM_MESSAGE_SOUND_PCM_INTERRUPTED, event_src); - - return cb_res; -} - EXPORT_API -int mm_sound_pcm_capture_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format) +int mm_sound_volume_set_value(volume_type_t type, const unsigned int value) { - avsys_audio_param_t param; - mm_sound_pcm_t *pcmHandle = NULL; - int size = 0; - int result = AVSYS_STATE_SUCCESS; - int errorcode = 0; - - debug_fenter(); - memset(¶m, 0, sizeof(avsys_audio_param_t)); - - - if (rate < _MIN_SYSTEM_SAMPLERATE || rate > _MAX_SYSTEM_SAMPLERATE) { - debug_error("unsupported sample rate %u", rate); - return MM_ERROR_SOUND_DEVICE_INVALID_SAMPLERATE; - } else { - param.samplerate = rate; - } + int ret = MM_ERROR_NONE; - switch(channel) - { - case MMSOUND_PCM_MONO: - param.channels = 1; - break; - case MMSOUND_PCM_STEREO: - param.channels = 2; - break; + debug_msg("type = (%d)%s, value = %d", type, __get_volume_str(type), value); - default: - debug_error("Unsupported channel type\n"); - return MM_ERROR_SOUND_DEVICE_INVALID_CHANNEL; + /* Check input param */ + if (0 > __validate_volume(type, (int)value)) { + debug_error("invalid volume type %d, value %u\n", type, value); + return MM_ERROR_INVALID_ARGUMENT; } - switch(format) - { - case MMSOUND_PCM_U8: - param.format = AVSYS_AUDIO_FORMAT_8BIT; - break; - case MMSOUND_PCM_S16_LE: - param.format = AVSYS_AUDIO_FORMAT_16BIT; - break; - default: - debug_error("Unsupported format type\n"); - return MM_ERROR_SOUND_DEVICE_INVALID_FORMAT; - } - - pcmHandle = calloc(sizeof(mm_sound_pcm_t), 1); - if(pcmHandle == NULL) - return MM_ERROR_OUT_OF_MEMORY; - - /* Register ASM */ - /* get session type */ - if(MM_ERROR_NONE != _get_asm_event_type(&pcmHandle->asm_event)) { - free(pcmHandle); - return MM_ERROR_POLICY_INTERNAL; - } - /* register asm */ - if(pcmHandle->asm_event != ASM_EVENT_CALL && pcmHandle->asm_event != ASM_EVENT_VIDEOCALL) { - if(!ASM_register_sound(-1, &pcmHandle->asm_handle, pcmHandle->asm_event, - /* ASM_STATE_PLAYING */ ASM_STATE_NONE, sound_pcm_asm_callback, (void*)pcmHandle, ASM_RESOURCE_NONE, &errorcode)) - { - debug_error("ASM_register_sound() failed 0x%x\n", errorcode); - free(pcmHandle); - return MM_ERROR_POLICY_BLOCKED; + ret = _mm_sound_volume_set_value_by_type(type, value); + if (ret == MM_ERROR_NONE) { + /* update shared memory value */ + int muteall; + _mm_sound_get_muteall(&muteall); + if(!muteall) { + if(MM_ERROR_NONE != mm_sound_pa_set_volume_by_type(type, (int)value)) { + debug_error("Can not set volume to shared memory 0x%x\n", ret); + } } } - /* Open */ - param.mode = AVSYS_AUDIO_MODE_INPUT; - param.vol_type = AVSYS_AUDIO_VOLUME_TYPE_SYSTEM; //dose not effect at capture mode - param.priority = AVSYS_AUDIO_PRIORITY_0; //This does not affect anymore. - result = avsys_audio_open(¶m, &pcmHandle->audio_handle, &size); - if(AVSYS_FAIL(result)) { - debug_error("Device Open Error 0x%x\n", result); - free(pcmHandle); - return MM_ERROR_SOUND_DEVICE_NOT_OPENED; - } - - pcmHandle->is_playback = false; - - /* Set handle to return */ - *handle = (MMSoundPcmHandle_t)pcmHandle; - - debug_fleave(); - return size; + return ret; } -static int _pcm_sound_start (MMSoundPcmHandle_t handle) +EXPORT_API +int mm_sound_mute_all(int muteall) { - mm_sound_pcm_t *pcmHandle = NULL; - int errorcode = 0; - - debug_fenter(); - - /* Check input param */ - pcmHandle = (mm_sound_pcm_t*)handle; - if(pcmHandle == NULL) { - debug_error ("Handle is null, return Invalid Argument\n"); - return MM_ERROR_INVALID_ARGUMENT; - } - - /* ASM set state to PLAYING */ - if (!ASM_set_sound_state(pcmHandle->asm_handle, pcmHandle->asm_event, ASM_STATE_PLAYING, ASM_RESOURCE_NONE, &errorcode)) { - debug_error("ASM_set_sound_state(PLAYING) failed 0x%x\n", errorcode); - return MM_ERROR_POLICY_BLOCKED; - } - - /* Update State */ - pcmHandle->is_started = true; + int ret = MM_ERROR_NONE; - debug_fleave(); + debug_msg("** deprecated API ** muteall = %d", muteall); - /* Un-Cork */ - return avsys_audio_cork(pcmHandle->audio_handle, 0); + return ret; } EXPORT_API -int mm_sound_pcm_capture_start(MMSoundPcmHandle_t handle) +int mm_sound_set_call_mute(volume_type_t type, int mute) { int ret = MM_ERROR_NONE; - ret = _pcm_sound_start (handle); - if (ret != MM_ERROR_NONE) { - debug_error ("_pcm_sound_start() failed (%x)\n", ret); - return ret; - } + debug_error("Unsupported API\n"); return ret; } -static int _pcm_sound_stop_internal (MMSoundPcmHandle_t handle) -{ - mm_sound_pcm_t *pcmHandle = NULL; - - /* Check input param */ - pcmHandle = (mm_sound_pcm_t*)handle; - if(pcmHandle == NULL) - return MM_ERROR_INVALID_ARGUMENT; - /* Check State */ - if (pcmHandle->is_started == false) { - debug_warning ("Can't stop because not started\n"); - return MM_ERROR_SOUND_INVALID_STATE; - } - - /* Drain if playback mode */ - if (pcmHandle->is_playback) { - if(AVSYS_FAIL(avsys_audio_drain(pcmHandle->audio_handle))) { - debug_error("drain failed\n"); - } - } - - /* Update State */ - pcmHandle->is_started = false; - - /* Cork */ - return avsys_audio_cork(pcmHandle->audio_handle, 1); -} - -static int _pcm_sound_stop(MMSoundPcmHandle_t handle) +EXPORT_API +int mm_sound_get_call_mute(volume_type_t type, int *mute) { - mm_sound_pcm_t *pcmHandle = NULL; - int errorcode = 0; int ret = MM_ERROR_NONE; - debug_fenter(); - - /* Check input param */ - pcmHandle = (mm_sound_pcm_t*)handle; - if(pcmHandle == NULL) { - debug_error ("Handle is null, return Invalid Argument\n"); + if(!mute) return MM_ERROR_INVALID_ARGUMENT; - } - /* Do stop procedure */ - ret = _pcm_sound_stop_internal(handle); - if (ret == MM_ERROR_NONE) { - /* Set ASM State to STOP */ - if (!ASM_set_sound_state(pcmHandle->asm_handle, pcmHandle->asm_event, ASM_STATE_STOP, ASM_RESOURCE_NONE, &errorcode)) { - debug_error("ASM_set_sound_state(STOP) failed 0x%x\n", errorcode); - ret = MM_ERROR_POLICY_BLOCKED; - } - } - - debug_log ("pcm sound [%p] stopped success!!!\n", handle); - - debug_fleave(); + debug_error("Unsupported API\n"); return ret; } - -EXPORT_API -int mm_sound_pcm_capture_stop(MMSoundPcmHandle_t handle) -{ - return _pcm_sound_stop (handle); -} - - EXPORT_API -int mm_sound_pcm_capture_read(MMSoundPcmHandle_t handle, void *buffer, const unsigned int length ) +int mm_sound_volume_get_value(volume_type_t type, unsigned int *value) { - mm_sound_pcm_t *pcmHandle = NULL; + int ret = MM_ERROR_NONE; /* Check input param */ - pcmHandle = (mm_sound_pcm_t*)handle; - if(pcmHandle == NULL) { - debug_error ("Handle is null, return Invalid Argument\n"); + if (value == NULL) { + debug_error("invalid argument\n"); return MM_ERROR_INVALID_ARGUMENT; } - if(buffer == NULL) { - debug_error("Invalid buffer pointer\n"); - return MM_ERROR_SOUND_INVALID_POINTER; - } - if(length == 0 ) { - debug_error ("length is 0, return 0\n"); - return 0; + if (type < 0 || type >= VOLUME_TYPE_MAX) { + debug_error("invalid volume type value %d\n", type); + return MM_ERROR_INVALID_ARGUMENT; } - /* Check State : return fail if not started */ - if (!pcmHandle->is_started) { - /* not started, return fail */ - debug_error ("Not started yet, return Invalid State \n"); - return MM_ERROR_SOUND_INVALID_STATE; - } + ret = _mm_sound_volume_get_value_by_type(type, value); - /* Read */ - return avsys_audio_read(pcmHandle->audio_handle, buffer, length); + debug_msg("returned %s = %d", __get_volume_str(type), *value); + return ret; } EXPORT_API -int mm_sound_pcm_capture_close(MMSoundPcmHandle_t handle) +int mm_sound_volume_primary_type_set(volume_type_t type) { - int result = MM_ERROR_NONE; - mm_sound_pcm_t *pcmHandle = NULL; - int errorcode = 0; - - debug_fenter(); + pid_t mypid; + int ret = MM_ERROR_NONE; /* Check input param */ - pcmHandle = (mm_sound_pcm_t*)handle; - if(pcmHandle == NULL) { - debug_error ("Handle is null, return Invalid Argument\n"); + if(type < 0 || type >= VOLUME_TYPE_MAX) { + debug_error("invalid argument\n"); return MM_ERROR_INVALID_ARGUMENT; } - /* Close */ - result = avsys_audio_close(pcmHandle->audio_handle); - if(AVSYS_FAIL(result)) { - debug_error("handle close failed 0x%X", result); - result = MM_ERROR_SOUND_INTERNAL; + if (vconf_set_int(VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE_FORCE, type)) { + debug_error("could not set vconf for RIMARY_VOLUME_TYPE_FORCE\n"); + ret = MM_ERROR_SOUND_INTERNAL; + } else { + debug_msg("set primary volume type forcibly %d(%s)", type, __get_volume_str(type)); } - /* Unregister ASM */ - if(pcmHandle->asm_event != ASM_EVENT_CALL && pcmHandle->asm_event != ASM_EVENT_VIDEOCALL) { - if(!ASM_unregister_sound(pcmHandle->asm_handle, pcmHandle->asm_event, &errorcode)) { - debug_error("ASM_unregister failed in %s with 0x%x\n", __func__, errorcode); - } - } - - /* Free handle */ - free(pcmHandle); pcmHandle= NULL; - - debug_fleave(); - return result; + return ret; } EXPORT_API -int mm_sound_pcm_set_message_callback (MMSoundPcmHandle_t handle, MMMessageCallback callback, void *user_param) +int mm_sound_volume_primary_type_clear(void) { - mm_sound_pcm_t *pcmHandle = (mm_sound_pcm_t*)handle; - - if(pcmHandle == NULL || callback == NULL) - return MM_ERROR_INVALID_ARGUMENT; - - pcmHandle->msg_cb = callback; - pcmHandle->msg_cb_param = user_param; + pid_t mypid; + int ret = MM_ERROR_NONE; - debug_log ("set pcm message callback (%p,%p)\n", callback, user_param); + if (vconf_set_int(VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE_FORCE, -1)) { + debug_error("could not reset vconf for RIMARY_VOLUME_TYPE_FORCE\n"); + ret = MM_ERROR_SOUND_INTERNAL; + } else { + debug_msg("clear primary volume type forcibly %d(%s)", -1, "none"); + } - return MM_ERROR_NONE; + return ret; } - EXPORT_API -int mm_sound_pcm_play_open_ex (MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, const volume_type_t vol_type, ASM_sound_events_t asm_event) +int mm_sound_volume_get_current_playing_type(volume_type_t *type) { - avsys_audio_param_t param; - mm_sound_pcm_t *pcmHandle = NULL; - int size = 0; - int result = AVSYS_STATE_SUCCESS; - int lvol_type = vol_type; - int errorcode = 0; - - debug_fenter(); - memset(¶m, 0, sizeof(avsys_audio_param_t)); + int ret = MM_ERROR_NONE; + int voltype = VOLUME_TYPE_RINGTONE; + int fvoltype = -1; /* Check input param */ - if(vol_type < 0) { - debug_error("Volume type should not be negative value\n"); - return MM_ERROR_INVALID_ARGUMENT; - } - if(vol_type >= VOLUME_TYPE_MAX) { - debug_error("Volume type should be under VOLUME_TYPE_MAX\n"); + if(type == NULL) { + debug_error("invalid argument\n"); return MM_ERROR_INVALID_ARGUMENT; } - if(rate < _MIN_SYSTEM_SAMPLERATE || rate > _MAX_SYSTEM_SAMPLERATE) { - debug_error("unsupported sample rate %u", rate); - return MM_ERROR_SOUND_DEVICE_INVALID_SAMPLERATE; - } else { - param.samplerate = rate; - } - switch(channel) - { - case MMSOUND_PCM_MONO: - param.channels = 1; - break; - case MMSOUND_PCM_STEREO: - param.channels = 2; - break; - default: - debug_error("Unsupported channel type\n"); - return MM_ERROR_SOUND_DEVICE_INVALID_CHANNEL; - } - - switch(format) - { - case MMSOUND_PCM_U8: - param.format = AVSYS_AUDIO_FORMAT_8BIT; - break; - case MMSOUND_PCM_S16_LE: - param.format = AVSYS_AUDIO_FORMAT_16BIT; - break; - default: - debug_error("Unsupported format type\n"); - return MM_ERROR_SOUND_DEVICE_INVALID_FORMAT; - } - - pcmHandle = calloc(sizeof(mm_sound_pcm_t),1); - if(pcmHandle == NULL) - return MM_ERROR_OUT_OF_MEMORY; - - /* Register ASM */ - debug_log ("session start : input asm_event = %d-------------\n", asm_event); - if (asm_event == ASM_EVENT_NONE) { - if(pcmHandle->asm_event != ASM_EVENT_CALL && pcmHandle->asm_event != ASM_EVENT_VIDEOCALL) { - /* get session type */ - if(MM_ERROR_NONE != _get_asm_event_type(&pcmHandle->asm_event)) { - debug_error ("_get_asm_event_type failed....\n"); - free(pcmHandle); - return MM_ERROR_POLICY_INTERNAL; - } - - /* register asm */ - if(!ASM_register_sound(-1, &pcmHandle->asm_handle, pcmHandle->asm_event, - ASM_STATE_NONE, sound_pcm_asm_callback, (void*)pcmHandle, ASM_RESOURCE_NONE, &errorcode)) { - debug_error("ASM_register_sound() failed 0x%x\n", errorcode); - free(pcmHandle); - return MM_ERROR_POLICY_BLOCKED; - } - } + /* check force set */ + if (vconf_get_int(VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE_FORCE, &fvoltype)) { + debug_error("could not get vconf for RIMARY_VOLUME_TYPE_FORCE\n"); + ret = MM_ERROR_SOUND_INTERNAL; } else { - /* register asm using asm_event input */ - if(!ASM_register_sound(-1, &pcmHandle->asm_handle, asm_event, - ASM_STATE_NONE, NULL, (void*)pcmHandle, ASM_RESOURCE_NONE, &errorcode)) { - debug_error("ASM_register_sound() failed 0x%x\n", errorcode); - free(pcmHandle); - return MM_ERROR_POLICY_BLOCKED; + if(fvoltype >= 0) { + *type = fvoltype; + return MM_ERROR_NONE; } } - param.mode = AVSYS_AUDIO_MODE_OUTPUT; - param.vol_type = lvol_type; - param.priority = AVSYS_AUDIO_PRIORITY_0; - -// avsys_audio_ampon(); - - /* Open */ - debug_log ("avsys open -------------\n"); - result = avsys_audio_open(¶m, &pcmHandle->audio_handle, &size); - if(AVSYS_FAIL(result)) { - debug_error("Device Open Error 0x%x\n", result); - free(pcmHandle); - return MM_ERROR_SOUND_DEVICE_NOT_OPENED; + /* If primary volume is not set by user, get current playing volume */ + if(vconf_get_int(VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE, &voltype)) { + debug_error("get vconf(VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE) failed voltype(%d)\n", voltype); + } else { + debug_error("get vconf(VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE) voltype(%d)\n", voltype); } - pcmHandle->is_playback = true; - - /* Set handle to return */ - *handle = (MMSoundPcmHandle_t)pcmHandle; + if(voltype >= 0) { + *type = voltype; + ret = MM_ERROR_NONE; + } + else if(voltype == -1) + ret = MM_ERROR_SOUND_VOLUME_NO_INSTANCE; + else if(voltype == -2) + ret = MM_ERROR_SOUND_VOLUME_CAPTURE_ONLY; + else + ret = MM_ERROR_SOUND_INTERNAL; - debug_fleave(); - return size; -} + debug_msg("returned type = (%d)%15s, ret = 0x%x", *type, __get_volume_str(*type), ret); -EXPORT_API -int mm_sound_pcm_play_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, const volume_type_t vol_type) -{ - return mm_sound_pcm_play_open_ex (handle, rate, channel, format, vol_type, ASM_EVENT_NONE); + return ret; } EXPORT_API -int mm_sound_pcm_play_start(MMSoundPcmHandle_t handle) +int mm_sound_volume_set_balance (float balance) { - return _pcm_sound_start (handle); -} + debug_msg("balance = %f", balance); + /* Check input param */ + if (balance < -1.0 || balance > 1.0) { + debug_error("invalid balance value [%f]\n", balance); + return MM_ERROR_INVALID_ARGUMENT; + } -EXPORT_API -int mm_sound_pcm_play_stop(MMSoundPcmHandle_t handle) -{ - return _pcm_sound_stop(handle); + return _mm_sound_volume_set_balance(balance); } - EXPORT_API -int mm_sound_pcm_play_write(MMSoundPcmHandle_t handle, void* ptr, unsigned int length_byte) +int mm_sound_volume_get_balance (float *balance) { - mm_sound_pcm_t *pcmHandle = NULL; + int ret = MM_ERROR_NONE; /* Check input param */ - pcmHandle = (mm_sound_pcm_t*)handle; - if(pcmHandle == NULL) { - debug_error ("Handle is null, return Invalid Argument\n"); + if (balance == NULL) { + debug_error("invalid argument\n"); return MM_ERROR_INVALID_ARGUMENT; } - if(ptr == NULL) { - debug_error("Invalid buffer pointer\n"); - return MM_ERROR_SOUND_INVALID_POINTER; - } - if(length_byte == 0 ) { - debug_error ("length is 0, return 0\n"); - return 0; - } - /* Check State : return fail if not started */ - if (!pcmHandle->is_started) { - /* not started, return fail */ - debug_error ("Not started yet, return Invalid State \n"); - return MM_ERROR_SOUND_INVALID_STATE; - } + ret = _mm_sound_volume_get_balance(balance); + debug_msg("returned balance = %f", *balance); - /* Write */ - return avsys_audio_write(pcmHandle->audio_handle, ptr, length_byte); + return ret; } EXPORT_API -int mm_sound_pcm_play_close(MMSoundPcmHandle_t handle) +int mm_sound_set_muteall (int muteall) { - int result = AVSYS_STATE_SUCCESS; - mm_sound_pcm_t *pcmHandle = NULL; - int errorcode = 0; - - debug_fenter(); + debug_msg("muteall = %d", muteall); /* Check input param */ - pcmHandle = (mm_sound_pcm_t*)handle; - if(pcmHandle == NULL) { - debug_error ("Handle is null, return Invalid Argument\n"); + if (muteall < 0 || muteall > 1) { + debug_error("invalid muteall value [%f]\n", muteall); return MM_ERROR_INVALID_ARGUMENT; } - /* Drain if needed */ - if (pcmHandle->is_started) { - /* stop() is not called before close(), drain is needed */ - if(AVSYS_FAIL(avsys_audio_drain(pcmHandle->audio_handle))) { - debug_error("drain failed\n"); - } - } + return _mm_sound_set_muteall(muteall); +} - /* Close */ - result = avsys_audio_close(pcmHandle->audio_handle); - if(AVSYS_FAIL(result)) { - debug_error("handle close failed 0x%X", result); - result = MM_ERROR_SOUND_INTERNAL; - } +EXPORT_API +int mm_sound_get_muteall (int *muteall) +{ + int ret = MM_ERROR_NONE; - /* Unregister ASM */ - if(pcmHandle->asm_event != ASM_EVENT_CALL && pcmHandle->asm_event != ASM_EVENT_VIDEOCALL) { - if(!ASM_unregister_sound(pcmHandle->asm_handle, pcmHandle->asm_event, &errorcode)) { - debug_error("ASM_unregister failed in %s with 0x%x\n",__func__, errorcode); - } + /* Check input param */ + if (muteall == NULL) { + debug_error("invalid argument\n"); + return MM_ERROR_INVALID_ARGUMENT; } - debug_log ("pcm sound [%p] closed success!!!\n", handle); - - /* Free handle */ - free(pcmHandle); pcmHandle= NULL; - - debug_fleave(); + ret = _mm_sound_get_muteall(muteall); + debug_msg("returned muteall = %d", *muteall); - return result; + return ret; } -/////////////////////////////////// -//// MMSOUND PLAY APIs -/////////////////////////////////// EXPORT_API -int mm_sound_play_loud_solo_sound(const char *filename, const volume_type_t volume_type, mm_sound_stop_callback_func callback, void *data, int *handle) +int mm_sound_set_stereo_to_mono (int ismono) { - MMSoundParamType param = { 0, }; - int err; - int lhandle = -1; - int lvol_type = volume_type; - - debug_fenter(); + debug_msg("ismono = %d", ismono); /* Check input param */ - if(filename == NULL) { - debug_error("filename is NULL\n"); - return MM_ERROR_SOUND_FILE_NOT_FOUND; - } - if(volume_type < 0 || volume_type >= VOLUME_TYPE_MAX) { - debug_error("Volume type should not be negative value\n"); + if (ismono < 0 || ismono > 1) { + debug_error("invalid ismono value [%f]\n", ismono); return MM_ERROR_INVALID_ARGUMENT; } - /* Play sound */ - param.filename = filename; - param.volume = 0; //volume value dose not effect anymore - param.callback = callback; - param.data = data; - param.loop = 1; - param.volume_table = lvol_type; - param.priority = AVSYS_AUDIO_PRIORITY_SOLO; - param.handle_route = MM_SOUND_HANDLE_ROUTE_SPEAKER; - - err = MMSoundClientPlaySound(¶m, 0, 0, &lhandle); - if (err < 0) { - debug_error("Failed to play sound\n"); - return err; - } - - /* Set handle to return */ - if (handle) { - *handle = lhandle; - } else { - debug_critical("The sound handle cannot be get [%d]\n", lhandle); - } - - debug_fleave(); - return MM_ERROR_NONE; + return __mm_sound_set_stereo_to_mono(ismono); } EXPORT_API -int mm_sound_play_solo_sound(const char *filename, const volume_type_t volume_type, mm_sound_stop_callback_func callback, void *data, int *handle) +int mm_sound_get_stereo_to_mono (int *ismono) { - MMSoundParamType param = { 0, }; - int err; - int lhandle = -1; - int lvol_type = volume_type; - - debug_fenter(); + int ret = MM_ERROR_NONE; /* Check input param */ - if(filename == NULL) { - debug_error("filename is NULL\n"); - return MM_ERROR_SOUND_FILE_NOT_FOUND; - } - if(volume_type < 0 || volume_type >= VOLUME_TYPE_MAX) { - debug_error("Volume type should not be negative value\n"); + if (ismono == NULL) { + debug_error("invalid argument\n"); return MM_ERROR_INVALID_ARGUMENT; } - /* Play sound */ - param.filename = filename; - param.volume = 0; /* volume value dose not effect anymore */ - param.callback = callback; - param.data = data; - param.loop = 1; - param.volume_table = lvol_type; - param.priority = AVSYS_AUDIO_PRIORITY_SOLO; - param.handle_route = MM_SOUND_HANDLE_ROUTE_USING_CURRENT; - - err = MMSoundClientPlaySound(¶m, 0, 0, &lhandle); - if (err < 0) { - debug_error("Failed to play sound\n"); - return err; - } + ret = __mm_sound_get_stereo_to_mono(ismono); + debug_msg("returned ismono = %d", *ismono); - /* Set handle to return */ - if (handle) { - *handle = lhandle; - } else { - debug_critical("The sound handle cannot be get [%d]\n", lhandle); - } + return ret; +} - debug_fleave(); - return MM_ERROR_NONE; + +/////////////////////////////////// +//// MMSOUND PLAY APIs +/////////////////////////////////// +static inline void _mm_sound_fill_play_param(MMSoundPlayParam *param, const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int priority, int handle_route) +{ + param->filename = filename; + param->volume = 0; //volume value dose not effect anymore + param->callback = callback; + param->data = data; + param->loop = 1; + param->volume_config = volume_config; + param->priority = priority; + param->handle_route = handle_route; } +EXPORT_API +int mm_sound_play_loud_solo_sound_no_restore(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle) +{ + MMSoundPlayParam param = { 0, }; + + _mm_sound_fill_play_param(¶m, filename, volume_config, callback, data, HANDLE_PRIORITY_SOLO, MM_SOUND_HANDLE_ROUTE_SPEAKER_NO_RESTORE); + return mm_sound_play_sound_ex(¶m, handle); +} EXPORT_API -int mm_sound_play_sound(const char *filename, const volume_type_t volume_type, mm_sound_stop_callback_func callback, void *data, int *handle) +int mm_sound_play_loud_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle) { - MMSoundParamType param = { 0, }; - int err; - int lhandle = -1; - int lvol_type = volume_type; + MMSoundPlayParam param = { 0, }; - debug_fenter(); + _mm_sound_fill_play_param(¶m, filename, volume_config, callback, data, HANDLE_PRIORITY_SOLO, MM_SOUND_HANDLE_ROUTE_SPEAKER); + return mm_sound_play_sound_ex(¶m, handle); +} - /* Check input param */ - if(filename == NULL) { - debug_error("filename is NULL\n"); - return MM_ERROR_SOUND_FILE_NOT_FOUND; - } - if(volume_type < 0) { - debug_error("Volume type should not be negative value\n"); - return MM_ERROR_INVALID_ARGUMENT; - } - if(volume_type >= VOLUME_TYPE_MAX) { - debug_error("Volume type should be under VOLUME_TYPE_MAX\n"); - return MM_ERROR_INVALID_ARGUMENT; - } +EXPORT_API +int mm_sound_play_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle) +{ + MMSoundPlayParam param = { 0, }; - /* Play sound */ - param.filename = filename; - param.volume = 0; /* volume value dose not effect anymore */ - param.callback = callback; - param.data = data; - param.loop = 1; - param.volume_table = lvol_type; - param.priority = AVSYS_AUDIO_PRIORITY_NORMAL; - param.handle_route = MM_SOUND_HANDLE_ROUTE_USING_CURRENT; - - err = MMSoundClientPlaySound(¶m, 0, 0, &lhandle); - if (err < 0) { - debug_error("Failed to play sound\n"); - return err; - } + _mm_sound_fill_play_param(¶m, filename, volume_config, callback, data, HANDLE_PRIORITY_SOLO, MM_SOUND_HANDLE_ROUTE_USING_CURRENT); + return mm_sound_play_sound_ex(¶m, handle); +} - /* Set handle to return */ - if (handle) { - *handle = lhandle; - } else { - debug_critical("The sound handle cannot be get [%d]\n", lhandle); - } +EXPORT_API +int mm_sound_play_sound_without_session(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle) +{ + MMSoundPlayParam param = { 0, }; - debug_fleave(); - return MM_ERROR_NONE; + _mm_sound_fill_play_param(¶m, filename, volume_config, callback, data, HANDLE_PRIORITY_SOLO, MM_SOUND_HANDLE_ROUTE_USING_CURRENT); + param.skip_session = true; + return mm_sound_play_sound_ex(¶m, handle); } +EXPORT_API +int mm_sound_play_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle) +{ + MMSoundPlayParam param = { 0, }; + + _mm_sound_fill_play_param(¶m, filename, volume_config, callback, data, HANDLE_PRIORITY_NORMAL, MM_SOUND_HANDLE_ROUTE_USING_CURRENT); + return mm_sound_play_sound_ex(¶m, handle); +} EXPORT_API -int mm_sound_play_sound_ex(MMSoundParamType *param, int *handle) +int mm_sound_play_sound_ex(MMSoundPlayParam *param, int *handle) { int err; int lhandle = -1; - - debug_fenter(); - + int volume_type = 0; /* Check input param */ if (param == NULL) { debug_error("param is null\n"); return MM_ERROR_INVALID_ARGUMENT; } + volume_type = MM_SOUND_VOLUME_CONFIG_TYPE(param->volume_config); + + if (param->filename == NULL) { + debug_error("filename is NULL\n"); + return MM_ERROR_SOUND_FILE_NOT_FOUND; + } + if (volume_type < 0 || volume_type >= VOLUME_TYPE_MAX) { + debug_error("Volume type is invalid %d\n", volume_type); + return MM_ERROR_INVALID_ARGUMENT; + } + + debug_warning ("play sound : priority=[%d], handle_route=[%d]\n", param->priority, param->handle_route); + /* Play sound */ err = MMSoundClientPlaySound(param, 0, 0, &lhandle); if (err < 0) { @@ -1171,7 +620,8 @@ int mm_sound_play_sound_ex(MMSoundParamType *param, int *handle) debug_critical("The sound hadle cannot be get [%d]\n", lhandle); } - debug_fleave(); + debug_warning ("success : handle=[%p]\n", handle); + return MM_ERROR_NONE; } @@ -1181,16 +631,15 @@ int mm_sound_stop_sound(int handle) { int err; - debug_fenter(); - + debug_warning ("enter : handle=[%p]\n", handle); /* Stop sound */ err = MMSoundClientStopSound(handle); if (err < 0) { debug_error("Fail to stop sound\n"); return err; } + debug_warning ("success : handle=[%p]\n", handle); - debug_fleave(); return MM_ERROR_NONE; } @@ -1198,34 +647,35 @@ int mm_sound_stop_sound(int handle) //// MMSOUND TONE APIs /////////////////////////////////// EXPORT_API -int mm_sound_play_tone (MMSoundTone_t num, const volume_type_t vol_type, const double volume, const int duration, int *handle) +int mm_sound_play_tone_ex (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle, bool enable_session) { int lhandle = -1; int err = MM_ERROR_NONE; + int volume_type = MM_SOUND_VOLUME_CONFIG_TYPE(volume_config); debug_fenter(); /* Check input param */ - if(duration < -1) { + if (duration < -1) { debug_error("number is invalid %d\n", duration); return MM_ERROR_INVALID_ARGUMENT; } - if(num < MM_SOUND_TONE_DTMF_0 || num >= MM_SOUND_TONE_NUM) { + if (num < MM_SOUND_TONE_DTMF_0 || num >= MM_SOUND_TONE_NUM) { debug_error("TONE Value is invalid %d\n", num); return MM_ERROR_INVALID_ARGUMENT; } - if(vol_type < VOLUME_TYPE_SYSTEM || vol_type >= VOLUME_TYPE_MAX) { - debug_error("Volume Type is invalid %d\n", vol_type); + if (volume_type < 0 || volume_type >= VOLUME_TYPE_MAX) { + debug_error("Volume type is invalid %d\n", volume_type); return MM_ERROR_INVALID_ARGUMENT; } - if(volume < 0.0 || volume > 1.0) { - debug_error("Volume Value is invalid %d\n", vol_type); + if (volume < 0.0 || volume > 1.0) { + debug_error("Volume Value is invalid %d\n", volume); return MM_ERROR_INVALID_ARGUMENT; } /* Play tone */ debug_msg("Call MMSoundClientPlayTone\n"); - err = MMSoundClientPlayTone (num, vol_type, volume, duration, &lhandle); + err = MMSoundClientPlayTone(num, volume_config, volume, duration, &lhandle, enable_session); if (err < 0) { debug_error("Failed to play sound\n"); return err; @@ -1241,47 +691,15 @@ int mm_sound_play_tone (MMSoundTone_t num, const volume_type_t vol_type, const d return MM_ERROR_NONE; } -/////////////////////////////////// -//// MMSOUND ROUTING APIs -/////////////////////////////////// -EXPORT_API -int mm_sound_set_path(int gain, int output, int input, int option) -{ - int err; - - debug_fenter(); - - debug_msg("gain: 0x%02X, output: %d, input: %d, option: 0x%x\n", gain, output, input, option); - - err = avsys_audio_set_path_ex( gain, output, input, option); - if (err < 0) { - debug_error("avsys_audio_set_path() failed\n"); - return MM_ERROR_SOUND_INTERNAL; - } - - debug_fleave(); - return MM_ERROR_NONE; -} - EXPORT_API -int mm_sound_get_path(int *gain, int *output, int *input, int *option) +int mm_sound_play_tone (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle) { - int err; - - debug_fenter(); - - err = avsys_audio_get_path_ex( gain, output, input, option); - if (err < 0) { - debug_error("SoundCtlPathGet() failed\n"); - return MM_ERROR_SOUND_INTERNAL; - } - - debug_msg("gain: 0x%02X, output: %d, input: %d, option: 0x%x\n", *gain, *output, *input, *option); - - debug_fleave(); - return MM_ERROR_NONE; + return mm_sound_play_tone_ex (num, volume_config, volume, duration, handle, true); } +/////////////////////////////////// +//// MMSOUND ROUTING APIs +/////////////////////////////////// #ifdef PULSE_CLIENT enum { USE_PA_SINK_ALSA = 0, @@ -1302,16 +720,14 @@ int mm_sound_route_get_system_policy (system_audio_route_t *route) EXPORT_API -int mm_sound_route_get_a2dp_status (int *connected, char **bt_name) +int mm_sound_route_get_a2dp_status (bool *connected, char **bt_name) { int ret = MM_ERROR_NONE; - debug_fenter(); - if (connected == NULL || bt_name == NULL) { debug_error ("argument is not valid\n"); - return MM_ERROR_INVALID_ARGUMENT; - } + return MM_ERROR_INVALID_ARGUMENT; + } ret = MMSoundClientIsBtA2dpOn (connected, bt_name); debug_msg ("connected=[%d] bt_name[%s]\n", *connected, *bt_name); @@ -1320,8 +736,6 @@ int mm_sound_route_get_a2dp_status (int *connected, char **bt_name) return ret; } - debug_fleave(); - return ret; } @@ -1366,7 +780,7 @@ int mm_sound_route_add_change_callback(audio_route_policy_changed_callback_fn fu } EXPORT_API -int mm_sound_route_remove_change_callback() +int mm_sound_route_remove_change_callback(void) { /* Deprecated */ return MM_ERROR_NONE; @@ -1377,18 +791,17 @@ int mm_sound_route_remove_change_callback() EXPORT_API int mm_sound_system_get_capture_status(system_audio_capture_status_t *status) { - int err = AVSYS_STATE_SUCCESS; + int err = MM_ERROR_NONE; int on_capture = 0; - if(!status) + if(!status) { + debug_error("invalid argument\n"); return MM_ERROR_INVALID_ARGUMENT; - - err = avsys_audio_get_capture_status(&on_capture); - if(err < 0) { - debug_error("Can not get capture status with 0x%x\n", err); - return MM_ERROR_SOUND_INTERNAL; } + /* Check whether sound is capturing */ + vconf_get_int(VCONFKEY_SOUND_CAPTURE_STATUS, &on_capture); // need to check where it is set + if(on_capture) *status = SYSTEM_AUDIO_CAPTURE_ACTIVE; else @@ -1402,24 +815,24 @@ int mm_sound_is_route_available(mm_sound_route route, bool *is_available) { int ret = MM_ERROR_NONE; - debug_fenter(); + debug_warning ("enter : route=[%x], is_available=[%p]\n", route, is_available); if (!_mm_sound_is_route_valid(route)) { debug_error("route is invalid %d\n", route); return MM_ERROR_INVALID_ARGUMENT; } - if (!is_available) - { + if (!is_available) { debug_error("is_available is invalid\n"); return MM_ERROR_INVALID_ARGUMENT; } ret = _mm_sound_client_is_route_available(route, is_available); if (ret < 0) { - debug_error("Can not check given route is available\n"); + debug_error("Can not check given route is available, ret = %x\n", ret); + } else { + debug_warning ("success : route=[%x], available=[%d]\n", route, *is_available); } - debug_fleave(); return ret; } @@ -1428,20 +841,16 @@ int mm_sound_foreach_available_route_cb(mm_sound_available_route_cb available_ro { int ret = MM_ERROR_NONE; - debug_fenter(); - - if (!available_route_cb) - { + if (!available_route_cb) { debug_error("available_route_cb is invalid\n"); return MM_ERROR_INVALID_ARGUMENT; } ret = _mm_sound_client_foreach_available_route_cb(available_route_cb, user_data); if (ret < 0) { - debug_error("Can not set foreach available route callback\n"); + debug_error("Can not set foreach available route callback, ret = %x\n", ret); } - debug_fleave(); return ret; } @@ -1450,30 +859,63 @@ int mm_sound_set_active_route(mm_sound_route route) { int ret = MM_ERROR_NONE; - debug_fenter(); - + debug_warning ("enter : route=[%x]\n", route); if (!_mm_sound_is_route_valid(route)) { debug_error("route is invalid %d\n", route); return MM_ERROR_INVALID_ARGUMENT; } - ret = _mm_sound_client_set_active_route(route); + ret = _mm_sound_client_set_active_route(route, true); if (ret < 0) { - debug_error("Can not set active route\n"); + debug_error("Can not set active route, ret = %x\n", ret); + } else { + debug_warning ("success : route=[%x]\n", route); + } + + return ret; +} + +EXPORT_API +int mm_sound_set_active_route_auto(void) +{ + int ret = MM_ERROR_NONE; + + ret = _mm_sound_client_set_active_route_auto(); + if (ret < 0) { + debug_error("fail to set active route auto, ret = %x\n", ret); + } else { + debug_msg ("success !!\n"); } - debug_fleave(); return ret; } +EXPORT_API +int mm_sound_set_active_route_without_broadcast(mm_sound_route route) +{ + int ret = MM_ERROR_NONE; + + debug_warning ("enter : route=[%x]\n", route); + if (!_mm_sound_is_route_valid(route)) { + debug_error("route is invalid %d\n", route); + return MM_ERROR_INVALID_ARGUMENT; + } + + ret = _mm_sound_client_set_active_route(route, false); + if (ret < 0) { + debug_error("Can not set active route, ret = %x\n", ret); + } else { + debug_warning ("success : route=[%x]\n", route); + } + + return ret; +} EXPORT_API int mm_sound_get_active_device(mm_sound_device_in *device_in, mm_sound_device_out *device_out) { int ret = MM_ERROR_NONE; - debug_fenter(); - if (device_in == NULL || device_out == NULL) { debug_error("argument is not valid\n"); return MM_ERROR_INVALID_ARGUMENT; @@ -1481,47 +923,64 @@ int mm_sound_get_active_device(mm_sound_device_in *device_in, mm_sound_device_ou ret = _mm_sound_client_get_active_device(device_in, device_out); if (ret < 0) { - debug_error("Can not add active device callback\n"); + debug_error("Can not add active device callback, ret = %x\n", ret); + } else { + debug_msg ("success : in=[%x], out=[%x]\n", *device_in, *device_out); } - debug_fleave(); return ret; } EXPORT_API -int mm_sound_add_active_device_changed_callback(mm_sound_active_device_changed_cb func, void *user_data) +int mm_sound_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out) { int ret = MM_ERROR_NONE; - debug_fenter(); + if (device_in == NULL || device_out == NULL) { + debug_error("argument is not valid\n"); + return MM_ERROR_INVALID_ARGUMENT; + } + + ret = _mm_sound_client_get_audio_path(device_in, device_out); + if (ret < 0) { + debug_error("Can not add active device callback, ret = %x\n", ret); + } else { + debug_msg ("success : in=[%x], out=[%x]\n", *device_in, *device_out); + } + + return ret; +} + +EXPORT_API +int mm_sound_add_active_device_changed_callback(const char *name, mm_sound_active_device_changed_cb func, void *user_data) +{ + int ret = MM_ERROR_NONE; + debug_warning ("enter %s\n", name); if (func == NULL) { debug_error("argument is not valid\n"); return MM_ERROR_INVALID_ARGUMENT; } - ret = _mm_sound_client_add_active_device_changed_callback(func, user_data); + ret = _mm_sound_client_add_active_device_changed_callback(name, func, user_data); if (ret < 0) { - debug_error("Can not add active device changed callback\n"); + debug_error("Can not add active device changed callback, ret = %x\n", ret); } - debug_fleave(); return ret; } EXPORT_API -int mm_sound_remove_active_device_changed_callback(void) +int mm_sound_remove_active_device_changed_callback(const char *name) { int ret = MM_ERROR_NONE; - debug_fenter(); - - ret = _mm_sound_client_remove_active_device_changed_callback(); + debug_warning ("enter name %s \n", name); + ret = _mm_sound_client_remove_active_device_changed_callback(name); if (ret < 0) { - debug_error("Can not remove active device changed callback\n"); + debug_error("Can not remove active device changed callback, ret = %x\n", ret); } - debug_fleave(); return ret; } @@ -1530,8 +989,6 @@ int mm_sound_add_available_route_changed_callback(mm_sound_available_route_chang { int ret = MM_ERROR_NONE; - debug_fenter(); - if (func == NULL) { debug_error("argument is not valid\n"); return MM_ERROR_INVALID_ARGUMENT; @@ -1539,10 +996,9 @@ int mm_sound_add_available_route_changed_callback(mm_sound_available_route_chang ret = _mm_sound_client_add_available_route_changed_callback(func, user_data); if (ret < 0) { - debug_error("Can not add available route changed callback\n"); + debug_error("Can not add available route changed callback, ret = %x\n", ret); } - debug_fleave(); return ret; } @@ -1551,25 +1007,31 @@ int mm_sound_remove_available_route_changed_callback(void) { int ret = MM_ERROR_NONE; - debug_fenter(); - ret = _mm_sound_client_remove_available_route_changed_callback(); if (ret < 0) { - debug_error("Can not remove available route changed callback\n"); + debug_error("Can not remove available route changed callback, ret = %x\n", ret); + } + + return ret; +} + +EXPORT_API +int mm_sound_set_sound_path_for_active_device(mm_sound_device_out device_out, mm_sound_device_in device_in) +{ + int ret = MM_ERROR_NONE; + + ret = _mm_sound_client_set_sound_path_for_active_device(device_out, device_in); + if (ret < 0) { + debug_error("Can not mm sound set sound path for active device, ret = %x\n", ret); } - debug_fleave(); return ret; } __attribute__ ((destructor)) void __mmfsnd_finalize(void) { - debug_fenter(); - MMSoundClientCallbackFini(); - - debug_fleave(); } __attribute__ ((constructor)) diff --git a/mm_sound_bootsound.c b/mm_sound_bootsound.c new file mode 100644 index 0000000..74c7bb6 --- /dev/null +++ b/mm_sound_bootsound.c @@ -0,0 +1,85 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * 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 + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#define VCONF_BOOTING "memory/private/sound/booting" +#define MAX_RETRY 40 +#define RETRY_INTERVAL_USEC 50000 + +EXPORT_API +int mm_sound_boot_ready(int timeout_sec) +{ + struct timespec ts; + sem_t* sem = NULL; + + debug_msg("[BOOT] check for sync...."); + if ((sem = sem_open ("booting-sound", O_CREAT, 0660, 0))== SEM_FAILED) { + debug_error ("error creating sem : %d", errno); + return -1; + } + + debug_msg("[BOOT] start to wait ready....timeout is set to %d sec", timeout_sec); + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += timeout_sec; + + if (sem_timedwait(sem, &ts) == -1) { + if (errno == ETIMEDOUT) + debug_warning("[BOOT] timeout!\n"); + } else { + debug_msg("[BOOT] ready wait success!!!!"); + sem_post(sem); + } + + return 0; +} + +EXPORT_API +int mm_sound_boot_play_sound(char* path) +{ + debug_msg("[BOOT] set vconf to play boot sound [%s]!!!!", path); + if (path == NULL) + return -1; + + return vconf_set_str(VCONF_BOOTING, path); +} + + diff --git a/mm_sound_client.c b/mm_sound_client.c index 0cfaed1..969e08c 100644 --- a/mm_sound_client.c +++ b/mm_sound_client.c @@ -38,6 +38,8 @@ #include "include/mm_sound.h" #include "include/mm_sound_msg.h" #include "include/mm_sound_client.h" +#include "include/mm_sound_common.h" +#include "include/mm_sound_device.h" #include #include @@ -53,11 +55,15 @@ #define MEMTYPE_SUPPORT_MAX (1024 * 1024) /* 1MB */ #define MEMTYPE_TRANS_PER_MAX (128 * 1024) /* 128K */ - int g_msg_scsnd; /* global msg queue id sound client snd */ int g_msg_scrcv; /* global msg queue id sound client rcv */ int g_msg_sccb; /* global msg queue id sound client callback */ +/* global variables for device list */ +static GList *g_device_list = NULL; +static mm_sound_device_list_t g_device_list_t; +static pthread_mutex_t g_device_list_mutex = PTHREAD_MUTEX_INITIALIZER; + /* callback */ struct __callback_param { @@ -93,10 +99,10 @@ int MMSoundClientCallbackFini(void) { mm_ipc_msg_t msgsnd={0,}; int ret = MM_ERROR_NONE; - + debug_fenter(); - /* When the the callback thread is not created, do not wait destory thread */ + /* When the the callback thread is not created, do not wait destroy thread */ /* g_thread_id is initialized : -1 */ /* g_thread_id is set to 0, when the callback thread is created */ if (g_thread_id != -1) @@ -108,10 +114,7 @@ int MMSoundClientCallbackFini(void) { debug_critical("[Client] Fail to send message\n"); } - /* wait for leave callback thread */ - while (g_exit_thread == 0) - usleep(30000); - g_exit_thread = 0; + pthread_join(g_thread, 0); } if (g_mutex_initted != -1) @@ -152,15 +155,34 @@ gboolean sndcb_fd_dispatch(GSource *source, GSourceFunc callback, gpointer user_ return TRUE; } #endif -gboolean RunCallback(gpointer *data) +gboolean RunCallback(gpointer data) { mm_ipc_msg_t* msg = NULL; debug_msg("[Client] execute mm_sound stop callback function\n"); msg = (mm_ipc_msg_t*)data; - ((mm_sound_stop_callback_func)msg->sound_msg.callback)(msg->sound_msg.cbdata); + ((mm_sound_stop_callback_func)msg->sound_msg.callback)(msg->sound_msg.cbdata, msg->sound_msg.handle); + + return FALSE; +} + +gboolean _volume_change_cb(gpointer data) +{ + mm_ipc_msg_t* msg = NULL; + + if (!data) { + debug_error("[Client] NULL param\n"); + return FALSE; + } + msg = (mm_ipc_msg_t*)data; + ((mm_sound_volume_changed_cb)msg->sound_msg.callback)(msg->sound_msg.type, msg->sound_msg.val, msg->sound_msg.cbdata); + + if(msg != NULL) { + free(msg); + msg = NULL; + } return FALSE; } @@ -194,7 +216,7 @@ static void* callbackfunc(void *param) GPollFD *g_fd_cmd = NULL; // file descriptor #endif - debug_warning("[Client] Waiting message\n"); + debug_msg("[Client] Waiting message\n"); ret = __MMIpcCBRecvMsg(instance, msgrcv); if (ret != MM_ERROR_NONE) { @@ -207,13 +229,12 @@ static void* callbackfunc(void *param) switch (msgrcv->sound_msg.msgtype) { case MM_SOUND_MSG_INF_STOP_CB: - debug_msg("[Client] callback : %p\n", msgrcv->sound_msg.callback); - debug_msg("[Client] data : %p\n", msgrcv->sound_msg.cbdata); + debug_msg("[Client] callback : %p, data : %p\n", msgrcv->sound_msg.callback, msgrcv->sound_msg.cbdata); if (msgrcv->sound_msg.callback) { #if defined(__DIRECT_CALLBACK__) - ((mm_sound_stop_callback_func)msgrcv->sound_msg.callback)(msgrcv->sound_msg.cbdata); + ((mm_sound_stop_callback_func)msgrcv->sound_msg.callback)(msgrcv->sound_msg.cbdata, msgrcv->sound_msg.handle); #elif defined(__GIDLE_CALLBACK__) guint eventid = 0; eventid = g_idle_add((GSourceFunc)RunCallback, (gpointer)msgrcv); @@ -286,11 +307,25 @@ static void* callbackfunc(void *param) run = 0; break; + case MM_SOUND_MSG_INF_DEVICE_CONNECTED_CB: + debug_msg("[Client] device handle : %x, is_connected : %d, callback : %p, data : %p\n", + &msgrcv->sound_msg.device_handle, msgrcv->sound_msg.is_connected, msgrcv->sound_msg.callback, msgrcv->sound_msg.cbdata); + if (msgrcv->sound_msg.callback) { + ((mm_sound_device_connected_cb)msgrcv->sound_msg.callback)(&msgrcv->sound_msg.device_handle, msgrcv->sound_msg.is_connected, msgrcv->sound_msg.cbdata); + } + break; + + case MM_SOUND_MSG_INF_DEVICE_INFO_CHANGED_CB: + debug_msg("[Client] device handle : %x, changed_info_type : %d, callback : %p, data : %p\n", + &msgrcv->sound_msg.device_handle, msgrcv->sound_msg.changed_device_info_type, msgrcv->sound_msg.callback, msgrcv->sound_msg.cbdata); + if (msgrcv->sound_msg.callback) { + ((mm_sound_device_info_changed_cb)msgrcv->sound_msg.callback)(&msgrcv->sound_msg.device_handle, msgrcv->sound_msg.changed_device_info_type, msgrcv->sound_msg.cbdata); + } + break; + case MM_SOUND_MSG_INF_ACTIVE_DEVICE_CB: - debug_msg("[Client] device_in : %p\n", msgrcv->sound_msg.device_in); - debug_msg("[Client] device_out : %p\n", msgrcv->sound_msg.device_out); - debug_msg("[Client] callback : %p\n", msgrcv->sound_msg.callback); - debug_msg("[Client] data : %p\n", msgrcv->sound_msg.cbdata); + debug_msg("[Client] device_in : %d, device_out : %d\n", msgrcv->sound_msg.device_in, msgrcv->sound_msg.device_out); + debug_log("[Client] callback : %p, data : %p\n", msgrcv->sound_msg.callback, msgrcv->sound_msg.cbdata); if (msgrcv->sound_msg.callback) { @@ -298,35 +333,58 @@ static void* callbackfunc(void *param) } break; case MM_SOUND_MSG_INF_AVAILABLE_ROUTE_CB: - debug_msg("[Client] callback : %p\n", msgrcv->sound_msg.callback); - debug_msg("[Client] data : %p\n", msgrcv->sound_msg.cbdata); + debug_log("[Client] callback : %p, data : %p\n", msgrcv->sound_msg.callback, msgrcv->sound_msg.cbdata); if (msgrcv->sound_msg.callback) { int route_index; mm_sound_route route; - for (route_index = 0; route_index < sizeof(msgrcv->sound_msg.route_list) / sizeof(int); route_index++) { + int list_count = sizeof(msgrcv->sound_msg.route_list) / sizeof(int); + + for (route_index = list_count-1; route_index >= 0; route_index--) { route = msgrcv->sound_msg.route_list[route_index]; if (route == 0) - break; + continue; if (msgrcv->sound_msg.is_available) { - debug_msg("[Client] available route : %d\n", route); + debug_msg("[Client] available route : 0x%x\n", route); } else { - debug_msg("[Client] unavailable route : %d\n", route); + debug_msg("[Client] unavailable route : 0x%x\n", route); } ((mm_sound_available_route_changed_cb)msgrcv->sound_msg.callback)(route, msgrcv->sound_msg.is_available, msgrcv->sound_msg.cbdata); + + if (route == MM_SOUND_ROUTE_INOUT_HEADSET || route == MM_SOUND_ROUTE_IN_MIC_OUT_HEADPHONE) { + debug_msg("[Client] no need to proceed further more....\n"); + break; + } + } + } + break; + case MM_SOUND_MSG_INF_VOLUME_CB: + debug_msg("[Client] type: %d, volume value : %d, callback : %p, data : %p\n", msgrcv->sound_msg.type, msgrcv->sound_msg.val, msgrcv->sound_msg.callback, msgrcv->sound_msg.cbdata); + + if (msgrcv->sound_msg.callback) + { + mm_ipc_msg_t* tmp = NULL; + tmp = (mm_ipc_msg_t*)malloc(sizeof(mm_ipc_msg_t)); + if(tmp == NULL) { + debug_critical("Fail malloc"); + break; } + memcpy(tmp, msgrcv, sizeof(mm_ipc_msg_t)); + g_idle_add((GSourceFunc)_volume_change_cb, (gpointer)tmp); } break; + default: /* Unexpected msg */ debug_msg("Receive wrong msg in callback func\n"); break; } } - if(msgrcv) + if(msgrcv) { free(msgrcv); + } g_exit_thread = 1; debug_msg("[Client] callback [%d] is leaved\n", instance); @@ -340,22 +398,27 @@ static int __mm_sound_client_get_msg_queue(void) if (g_mutex_initted == -1) { - pthread_mutex_init(&g_thread_mutex, NULL); - debug_msg("[Client] mutex initialized. \n"); + if(pthread_mutex_init(&g_thread_mutex, NULL)) { + debug_error("pthread_mutex_init failed\n"); + return MM_ERROR_SOUND_INTERNAL; + } + debug_log("[Client] mutex initialized. \n"); g_mutex_initted = 1; /* Get msg queue id */ ret = __MMSoundGetMsg(); if(ret != MM_ERROR_NONE) { - debug_critical("[Client] Fail to get message queue id\n"); + debug_error("[Client] Fail to get message queue id. sound_server is not initialized.\n"); + pthread_mutex_destroy(&g_thread_mutex); + g_mutex_initted = -1; } } return ret; } -int MMSoundClientPlayTone(int number, int vol_type, double volume, int time, int *handle) +int MMSoundClientPlayTone(int number, int volume_config, double volume, int time, int *handle, bool enable_session) { mm_ipc_msg_t msgrcv = {0,}; mm_ipc_msg_t msgsnd = {0,}; @@ -365,25 +428,30 @@ int MMSoundClientPlayTone(int number, int vol_type, double volume, int time, int debug_fenter(); - if (__mm_sound_client_get_msg_queue() != MM_ERROR_NONE) + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { return ret; - - /* read mm-session type */ - int sessionType = MM_SESSION_TYPE_SHARE; - if(MM_ERROR_NONE != _mm_session_util_read_type(-1, &sessionType)) + } + /* read session information */ + int session_type = MM_SESSION_TYPE_MEDIA; + int session_options = 0; + if (enable_session) { - debug_warning("[Client] Read MMSession Type failed. use default \"share\" type\n"); - sessionType = MM_SESSION_TYPE_SHARE; - - if(MM_ERROR_NONE != mm_session_init(sessionType)) + if (MM_ERROR_NONE != _mm_session_util_read_information(-1, &session_type, &session_options)) { - debug_critical("[Client] MMSessionInit() failed\n"); - return MM_ERROR_POLICY_INTERNAL; + debug_warning("[Client] Read Session Information failed. use default \"media\" type\n"); + session_type = MM_SESSION_TYPE_MEDIA; + + if(MM_ERROR_NONE != mm_session_init(session_type)) + { + debug_critical("[Client] MMSessionInit() failed\n"); + return MM_ERROR_POLICY_INTERNAL; + } } } instance = getpid(); - debug_msg("[Client] pid for client ::: [%d]\n", instance); + debug_log("[Client] pid for client ::: [%d]\n", instance); pthread_mutex_lock(&g_thread_mutex); @@ -392,12 +460,14 @@ int MMSoundClientPlayTone(int number, int vol_type, double volume, int time, int /* Send req memory */ msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_DTMF; msgsnd.sound_msg.msgid = instance; - msgsnd.sound_msg.session_type = sessionType;//asm_session_type; - msgsnd.sound_msg.volume = volume;//This does not effect anymore - msgsnd.sound_msg.volume_table = vol_type; + msgsnd.sound_msg.session_type = session_type; //session type + msgsnd.sound_msg.session_options = session_options; //session options + msgsnd.sound_msg.volume = volume; //This does not effect anymore + msgsnd.sound_msg.volume_config = volume_config; msgsnd.sound_msg.tone = number; msgsnd.sound_msg.handle = -1; msgsnd.sound_msg.repeat = time; + msgsnd.sound_msg.enable_session = enable_session; ret = __MMIpcSndMsg(&msgsnd); if (ret != MM_ERROR_NONE) @@ -418,16 +488,19 @@ int MMSoundClientPlayTone(int number, int vol_type, double volume, int time, int { case MM_SOUND_MSG_RES_DTMF: *handle = msgrcv.sound_msg.handle; - if(*handle == -1) + if(*handle == -1) { debug_error("[Client] The handle is not get\n"); - - debug_msg("[Client] Success to play sound sound handle : [%d]\n", *handle); + } else { + debug_msg("[Client] Success to play sound sound handle : [%d]\n", *handle); + } break; + case MM_SOUND_MSG_RES_ERROR: debug_error("[Client] Error occurred \n"); ret = msgrcv.sound_msg.code; goto cleanup; break; + default: debug_critical("[Client] Unexpected state with communication \n"); ret = msgrcv.sound_msg.code; @@ -442,7 +515,7 @@ cleanup: } -int MMSoundClientPlaySound(MMSoundParamType *param, int tone, int keytone, int *handle) +int MMSoundClientPlaySound(MMSoundPlayParam *param, int tone, int keytone, int *handle) { mm_ipc_msg_t msgrcv = {0,}; mm_ipc_msg_t msgsnd = {0,}; @@ -460,24 +533,27 @@ int MMSoundClientPlaySound(MMSoundParamType *param, int tone, int keytone, int * memset(shm_name, 0, sizeof(shm_name)); ret = __mm_sound_client_get_msg_queue(); - if (ret != MM_ERROR_NONE) + if (ret != MM_ERROR_NONE) { return ret; + } + /* read session information */ + int session_type = MM_SESSION_TYPE_MEDIA; + int session_options = 0; - /* read mm-session type */ - int sessionType = MM_SESSION_TYPE_SHARE; - if(MM_ERROR_NONE != _mm_session_util_read_type(-1, &sessionType)) - { - debug_warning("[Client] Read MMSession Type failed. use default \"share\" type\n"); - sessionType = MM_SESSION_TYPE_SHARE; - - if(MM_ERROR_NONE != mm_session_init(sessionType)) + if (param->skip_session == false) { + if(MM_ERROR_NONE != _mm_session_util_read_information(-1, &session_type, &session_options)) { - debug_critical("[Client] MMSessionInit() failed\n"); - return MM_ERROR_POLICY_INTERNAL; + debug_warning("[Client] Read MMSession Type failed. use default \"media\" type\n"); + session_type = MM_SESSION_TYPE_MEDIA; + + if(MM_ERROR_NONE != mm_session_init(session_type)) + { + debug_critical("[Client] MMSessionInit() failed\n"); + return MM_ERROR_POLICY_INTERNAL; + } } } - instance = getpid(); debug_msg("[Client] pid for client ::: [%d]\n", instance); @@ -503,7 +579,7 @@ int MMSoundClientPlaySound(MMSoundParamType *param, int tone, int keytone, int * { debug_msg("The memptr : [%p]\n", param->mem_ptr); debug_msg("The memptr : [%d]\n", param->mem_size); - /* Limitted memory size */ + /* Limited memory size */ if (param->mem_ptr && param->mem_size > MEMTYPE_SUPPORT_MAX) { debug_msg("[Client] Memory size is too big. We support size of media to 1MB\n"); @@ -532,17 +608,12 @@ int MMSoundClientPlaySound(MMSoundParamType *param, int tone, int keytone, int * mmap_buf = mmap (0, MEMTYPE_SUPPORT_MAX, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0); if (mmap_buf == MAP_FAILED) { - debug_error("[Client] MMAP failed \n"); + debug_error("[Client] MMAP failed (%s)\n", strerror(errno)); goto cleanup; } - + sharedmem = mmap_buf; - if(ret != MM_ERROR_NONE) - { - debug_error("[Client] Not allocated shared memory"); - goto cleanup; - } debug_msg("[Client] Sheared mem ptr : %p\n", sharedmem); debug_msg("[Client] Sheared key : [%d]\n", 1); /* Send req memory */ @@ -550,28 +621,29 @@ int MMSoundClientPlaySound(MMSoundParamType *param, int tone, int keytone, int * msgsnd.sound_msg.msgid = instance; msgsnd.sound_msg.callback = (void*)(param->callback); msgsnd.sound_msg.cbdata = (void*)(param->data); - msgsnd.sound_msg.memptr = sharedmem; + msgsnd.sound_msg.memptr = (int)sharedmem; msgsnd.sound_msg.sharedkey = 1; /* In case of shared memory file name */ - msgsnd.sound_msg.session_type = sessionType;//asm_session_type; + msgsnd.sound_msg.session_type = session_type; //session type + msgsnd.sound_msg.session_options = session_options; //session options msgsnd.sound_msg.priority = param->priority; - - strncpy(msgsnd.sound_msg.filename, shm_name, 512); + MMSOUND_STRNCPY(msgsnd.sound_msg.filename, shm_name, FILE_PATH); debug_msg("[Client] shm_name : %s\n", msgsnd.sound_msg.filename); - + msgsnd.sound_msg.memsize = param->mem_size; msgsnd.sound_msg.volume = param->volume; msgsnd.sound_msg.tone = tone; msgsnd.sound_msg.handle = -1; msgsnd.sound_msg.repeat = param->loop; - msgsnd.sound_msg.volume_table = param->volume_table; + msgsnd.sound_msg.volume_config = param->volume_config; msgsnd.sound_msg.keytone = keytone; msgsnd.sound_msg.handle_route = param->handle_route; + msgsnd.sound_msg.enable_session = !param->skip_session; /* Send req memory */ debug_msg("[Client] Shared mem ptr %p, %p, size %d\n", sharedmem, param->mem_ptr, param->mem_size); memcpy(sharedmem, param->mem_ptr, param->mem_size); - + if (close(shm_fd) == -1) { @@ -579,7 +651,7 @@ int MMSoundClientPlaySound(MMSoundParamType *param, int tone, int keytone, int * ret = MM_ERROR_SOUND_INTERNAL; goto cleanup; } - + ret = __MMIpcSndMsg(&msgsnd); if (ret != MM_ERROR_NONE) { @@ -598,21 +670,23 @@ int MMSoundClientPlaySound(MMSoundParamType *param, int tone, int keytone, int * msgsnd.sound_msg.tone = tone; msgsnd.sound_msg.handle = -1; msgsnd.sound_msg.repeat = param->loop; - msgsnd.sound_msg.volume_table = param->volume_table; - msgsnd.sound_msg.session_type = sessionType;//asm_session_type; + msgsnd.sound_msg.volume_config = param->volume_config; + msgsnd.sound_msg.session_type = session_type; //session type + msgsnd.sound_msg.session_options = session_options; //session options msgsnd.sound_msg.priority = param->priority; msgsnd.sound_msg.handle_route = param->handle_route; + msgsnd.sound_msg.enable_session = !param->skip_session; if((strlen(param->filename)) < FILE_PATH) { - strncpy(msgsnd.sound_msg.filename, param->filename, sizeof(msgsnd.sound_msg.filename)-1); + MMSOUND_STRNCPY(msgsnd.sound_msg.filename, param->filename, FILE_PATH); } else { debug_error("File name is over count\n"); ret = MM_ERROR_SOUND_INVALID_PATH; } - + msgsnd.sound_msg.keytone = keytone; debug_msg("[Client] callback : %p\n", msgsnd.sound_msg.callback); @@ -626,7 +700,7 @@ int MMSoundClientPlaySound(MMSoundParamType *param, int tone, int keytone, int * } } - + /* Receive */ ret = __MMIpcRecvMsg(instance, &msgrcv); if (ret != MM_ERROR_NONE) @@ -643,11 +717,11 @@ int MMSoundClientPlaySound(MMSoundParamType *param, int tone, int keytone, int * break; case MM_SOUND_MSG_RES_MEMORY: *handle = msgrcv.sound_msg.handle; - if(*handle == -1) + if(*handle == -1) { debug_error("[Client] The handle is not get\n"); - - shm_unlink(shm_name); - if (ret != MM_ERROR_NONE) + } + int r = shm_unlink(shm_name); + if (r == -1) { debug_critical("[Client] Fail to remove shared memory, must be checked\n"); goto cleanup; @@ -689,17 +763,19 @@ int MMSoundClientStopSound(int handle) ret = MM_ERROR_INVALID_ARGUMENT; return ret; } - - if (__mm_sound_client_get_msg_queue() != MM_ERROR_NONE) + + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { return ret; + } pthread_mutex_lock(&g_thread_mutex); - + /* Send req STOP */ msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_STOP; msgsnd.sound_msg.msgid = instance; msgsnd.sound_msg.handle = handle; /* handle means audio handle slot id */ - + ret = __MMIpcSndMsg(&msgsnd); if (ret != MM_ERROR_NONE) { @@ -707,7 +783,7 @@ int MMSoundClientStopSound(int handle) goto cleanup; } - /* Recieve */ + /* Receive */ ret = __MMIpcRecvMsg(instance, &msgrcv); if (ret != MM_ERROR_NONE) { @@ -739,134 +815,217 @@ cleanup: return ret; } -int _mm_sound_client_is_route_available(mm_sound_route route, bool *is_available) +static int __mm_sound_device_check_flags_to_append (int device_flags, mm_sound_device_t *device_h, bool *is_good_to_append) { - mm_ipc_msg_t msgrcv = {0,}; - mm_ipc_msg_t msgsnd = {0,}; - int ret = MM_ERROR_NONE; - int instance; - - debug_fenter(); - - *is_available = FALSE; + bool need_to_append = false; + int need_to_check_for_io_direction = device_flags & DEVICE_IO_DIRECTION_FLAGS; + int need_to_check_for_state = device_flags & DEVICE_STATE_FLAGS; + int need_to_check_for_type = device_flags & DEVICE_TYPE_FLAGS; - if (__mm_sound_client_get_msg_queue() != MM_ERROR_NONE) - return ret; + debug_warning("device_h[0x%x], device_flags[0x%x], need_to_check(io_direction[0x%x],state[0x%x],type[0x%x])\n", + device_h, device_flags, need_to_check_for_io_direction, need_to_check_for_state, need_to_check_for_type); - pthread_mutex_lock(&g_thread_mutex); + if(!device_h) { + return MM_ERROR_INVALID_ARGUMENT; + } + if (device_flags == DEVICE_ALL_FLAG) { + *is_good_to_append = true; + return MM_ERROR_NONE; + } - instance = getpid(); - /* Send REQ_IS_ROUTE_AVAILABLE */ - msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_IS_ROUTE_AVAILABLE; - msgsnd.sound_msg.msgid = instance; - msgsnd.sound_msg.route = route; + if (need_to_check_for_io_direction) { + if ((device_h->io_direction == DEVICE_IO_DIRECTION_IN) && (device_flags & DEVICE_IO_DIRECTION_IN_FLAG)) { + need_to_append = true; + } else if ((device_h->io_direction == DEVICE_IO_DIRECTION_OUT) && (device_flags & DEVICE_IO_DIRECTION_OUT_FLAG)) { + need_to_append = true; + } else if ((device_h->io_direction == DEVICE_IO_DIRECTION_BOTH) && (device_flags & DEVICE_IO_DIRECTION_BOTH_FLAG)) { + need_to_append = true; + } + if (need_to_append) { + if (!need_to_check_for_state && !need_to_check_for_type) { + *is_good_to_append = true; + return MM_ERROR_NONE; + } + } else { + *is_good_to_append = false; + return MM_ERROR_NONE; + } + } + if (need_to_check_for_state) { + need_to_append = false; + if ((device_h->state == DEVICE_STATE_DEACTIVATED) && (device_flags & DEVICE_STATE_DEACTIVATED_FLAG)) { + need_to_append = true; + } else if ((device_h->state == DEVICE_STATE_ACTIVATED) && (device_flags & DEVICE_STATE_ACTIVATED_FLAG)) { + need_to_append = true; + } + if (need_to_append) { + if (!need_to_check_for_type) { + *is_good_to_append = true; + return MM_ERROR_NONE; + } + } else { + *is_good_to_append = false; + return MM_ERROR_NONE; + } + } + if (need_to_check_for_type) { + need_to_append = false; + bool is_internal_device = IS_INTERNAL_DEVICE(device_h->type); + if (is_internal_device && (device_flags & DEVICE_TYPE_INTERNAL_FLAG)) { + need_to_append = true; + } else if (!is_internal_device && (device_flags & DEVICE_TYPE_EXTERNAL_FLAG)) { + need_to_append = true; + } + if (need_to_append) { + *is_good_to_append = true; + return MM_ERROR_NONE; + } else { + *is_good_to_append = false; + return MM_ERROR_NONE; + } + } + return MM_ERROR_NONE; +} - if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) - goto cleanup; +int __mm_sound_client_device_list_clear () +{ + int ret = MM_ERROR_NONE; - /* Recieve */ - if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) - goto cleanup; + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_list_mutex, MM_ERROR_SOUND_INTERNAL); - switch (msgrcv.sound_msg.msgtype) - { - case MM_SOUND_MSG_RES_IS_ROUTE_AVAILABLE: - *is_available = msgrcv.sound_msg.is_available; - debug_msg("[Client] Success to check given route is available %d\n", *is_available); - break; - case MM_SOUND_MSG_RES_ERROR: - debug_error("[Client] Error occurred \n"); - ret = msgrcv.sound_msg.code; - goto cleanup; - break; - default: - debug_critical("[Client] Unexpected state with communication \n"); - ret = msgrcv.sound_msg.code; - goto cleanup; - break; + if (g_device_list) { + g_list_free_full(g_device_list, g_free); + g_device_list = NULL; } -cleanup: - pthread_mutex_unlock(&g_thread_mutex); + MMSOUND_LEAVE_CRITICAL_SECTION(&g_device_list_mutex); - debug_fleave(); return ret; } -static int _handle_foreach_callback(mm_ipc_msg_t *msg) +int __mm_sound_client_device_list_append_item (mm_sound_device_t *device_h) { - int instance; - int route_index; - mm_sound_route route; + int ret = MM_ERROR_NONE; + mm_sound_device_t *device_node = g_malloc0(sizeof(mm_sound_device_t)); + if (!device_node) + return MM_ERROR_SOUND_INTERNAL; + memcpy(device_node, device_h, sizeof(mm_sound_device_t)); - debug_fenter(); + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_list_mutex, MM_ERROR_SOUND_INTERNAL); - if (msg->sound_msg.callback == NULL) { - debug_error ("[Client] Foreach callback is [%p], cbdata = %p => exit", - msg->sound_msg.callback, msg->sound_msg.cbdata); - return MM_ERROR_SOUND_INTERNAL; - } + g_device_list = g_list_append(g_device_list, device_node); + debug_log("[Client] g_device_list[0x%x], new device_node[0x%x] is appended, type[%d], id[%d]\n", g_device_list, device_node, device_node->type, device_node->id); - for (route_index = 0; route_index < sizeof(msg->sound_msg.route_list); route_index++) { - route = msg->sound_msg.route_list[route_index]; - if (route == 0) - break; - debug_msg("[Client] available route : %d\n", route); - if (((mm_sound_available_route_cb)msg->sound_msg.callback)(route, msg->sound_msg.cbdata) == false) { - debug_msg ("[Client] user doesn't want anymore. quit loop!!\n"); - break; + MMSOUND_LEAVE_CRITICAL_SECTION(&g_device_list_mutex); + + return ret; +} + +int _mm_sound_client_device_list_dump (GList *device_list) +{ + int ret = MM_ERROR_NONE; + GList *list = NULL; + mm_sound_device_t *device_node = NULL; + int count = 0; + + debug_log("======================== device list : start ==========================\n"); + for (list = device_list; list != NULL; list = list->next) { + device_node = (mm_sound_device_t *)list->data; + if (device_node) { + debug_log(" list idx[%d]: type[%02d], id[%02d], io_direction[%d], state[%d], name[%s]\n", + count++, device_node->type, device_node->id, device_node->io_direction, device_node->state, device_node->name); } } + debug_log("======================== device list : end ============================\n"); - debug_fleave(); - - return MM_ERROR_NONE; + return ret; } -int _mm_sound_client_foreach_available_route_cb(mm_sound_available_route_cb available_route_cb, void *user_data) +int _mm_sound_client_get_current_connected_device_list(int device_flags, mm_sound_device_list_t **device_list) { mm_ipc_msg_t msgrcv = {0,}; mm_ipc_msg_t msgsnd = {0,}; int ret = MM_ERROR_NONE; int instance; - pthread_t thread_forech; debug_fenter(); - if (__mm_sound_client_get_msg_queue() != MM_ERROR_NONE) + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { return ret; - + } pthread_mutex_lock(&g_thread_mutex); instance = getpid(); - /* Send REQ_FOREACH_AVAILABLE_ROUTE_CB */ - msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_FOREACH_AVAILABLE_ROUTE_CB; + + /* Send REQ_ADD_ACTIVE_DEVICE_CB */ + msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_GET_CONNECTED_DEVICE_LIST; msgsnd.sound_msg.msgid = instance; - msgsnd.sound_msg.callback = (void *)available_route_cb; - msgsnd.sound_msg.cbdata = (void *)user_data; + msgsnd.sound_msg.device_flags = device_flags; - if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) + if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) { goto cleanup; + } - /* Recieve */ - if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) { goto cleanup; + } switch (msgrcv.sound_msg.msgtype) { - case MM_SOUND_MSG_RES_FOREACH_AVAILABLE_ROUTE_CB: - debug_msg("[Client] Success to set foreach available route callback\n"); - msgrcv.sound_msg.callback = (void *)available_route_cb; - msgrcv.sound_msg.cbdata = (void *)user_data; - ret = _handle_foreach_callback (&msgrcv); + case MM_SOUND_MSG_RES_GET_CONNECTED_DEVICE_LIST: + { + int i = 0; + int ret = MM_ERROR_NONE; + int total_device_num = msgrcv.sound_msg.total_device_num; + bool is_good_to_append = false; + mm_sound_device_t* device_h = &msgrcv.sound_msg.device_handle; + + ret = __mm_sound_client_device_list_clear(); + if (ret) { + debug_error("[Client] failed to __mm_sound_client_device_list_clear(), ret[0x%x]\n", ret); + goto cleanup; + } + + debug_msg("[Client] supposed to receive %d messages\n", total_device_num); + for (i = 0; i < total_device_num; i++) { + /* check if this device_handle is suitable according to flags */ + ret = __mm_sound_device_check_flags_to_append (device_flags, device_h, &is_good_to_append); + if (is_good_to_append) { + ret = __mm_sound_client_device_list_append_item(device_h); + if (ret) { + debug_error("[Client] failed to __mm_sound_client_device_list_append_item(), ret[0x%x]\n", ret); + } + } + if (total_device_num-i > 1) { + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) { + debug_error("[Client] failed to [%d]th of __MMIpcRecvMsg()\n", i); + goto cleanup; + } + switch (msgrcv.sound_msg.msgtype) + { + case MM_SOUND_MSG_RES_GET_CONNECTED_DEVICE_LIST: + break; + default: + debug_error("[Client] failed to [%d]th of __MMIpcRecvMsg(), msgtype[%d] is not expected\n", msgrcv.sound_msg.msgtype); + goto cleanup; + break; + } + } + } + g_device_list_t.list = g_device_list; + *device_list = &g_device_list_t; + debug_msg("[Client] Success to get connected device list, g_device_list_t[0x%x]->list[0x%x], device_list[0x%x]\n", &g_device_list_t, g_device_list_t.list, *device_list); + _mm_sound_client_device_list_dump((*device_list)->list); + } break; case MM_SOUND_MSG_RES_ERROR: debug_error("[Client] Error occurred \n"); - ret = msgrcv.sound_msg.code; + ret = msgrcv.sound_msg.code; // no data is possible goto cleanup; break; default: - debug_critical("[Client] Unexpected state with communication \n"); + debug_error("[Client] Unexpected state with communication \n"); ret = msgrcv.sound_msg.code; goto cleanup; break; @@ -879,7 +1038,7 @@ cleanup: return ret; } -int _mm_sound_client_set_active_route(mm_sound_route route) +int _mm_sound_client_add_device_connected_callback(int device_flags, mm_sound_device_connected_cb func, void* user_data) { mm_ipc_msg_t msgrcv = {0,}; mm_ipc_msg_t msgsnd = {0,}; @@ -888,28 +1047,44 @@ int _mm_sound_client_set_active_route(mm_sound_route route) debug_fenter(); - if (__mm_sound_client_get_msg_queue() != MM_ERROR_NONE) + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { return ret; + } pthread_mutex_lock(&g_thread_mutex); instance = getpid(); - /* Send REQ_SET_ACTIVE_ROUTE */ - msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_SET_ACTIVE_ROUTE; + /* Send REQ_ADD_ACTIVE_DEVICE_CB */ + msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_ADD_DEVICE_CONNECTED_CB; msgsnd.sound_msg.msgid = instance; - msgsnd.sound_msg.route = route; + msgsnd.sound_msg.device_flags = device_flags; + msgsnd.sound_msg.callback = func; + msgsnd.sound_msg.cbdata = user_data; - if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) + if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) { goto cleanup; + } /* Recieve */ - if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) { goto cleanup; + } switch (msgrcv.sound_msg.msgtype) { - case MM_SOUND_MSG_RES_SET_ACTIVE_ROUTE: - debug_msg("[Client] Success to add active device callback\n"); + case MM_SOUND_MSG_RES_ADD_DEVICE_CONNECTED_CB: + debug_msg("[Client] Success to add device connected callback\n"); + if (g_thread_id == -1) + { + g_thread_id = pthread_create(&g_thread, NULL, callbackfunc, NULL); + if (g_thread_id == -1) + { + debug_critical("[Client] Fail to create thread %s\n", strerror(errno)); + ret = MM_ERROR_SOUND_INTERNAL; + goto cleanup; + } + } break; case MM_SOUND_MSG_RES_ERROR: debug_error("[Client] Error occurred \n"); @@ -930,7 +1105,7 @@ cleanup: return ret; } -int _mm_sound_client_get_active_device(mm_sound_device_in *device_in, mm_sound_device_out *device_out) +int _mm_sound_client_remove_device_connected_callback(void) { mm_ipc_msg_t msgrcv = {0,}; mm_ipc_msg_t msgsnd = {0,}; @@ -939,29 +1114,29 @@ int _mm_sound_client_get_active_device(mm_sound_device_in *device_in, mm_sound_d debug_fenter(); - if (__mm_sound_client_get_msg_queue() != MM_ERROR_NONE) + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { return ret; + } pthread_mutex_lock(&g_thread_mutex); instance = getpid(); - /* Send REQ_GET_ACTIVE_DEVICE */ - msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_GET_ACTIVE_DEVICE; + /* Send REQ_REMOVE_ACTIVE_DEVICE_CB */ + msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_REMOVE_DEVICE_CONNECTED_CB; msgsnd.sound_msg.msgid = instance; - if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) + if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) { goto cleanup; - + } /* Recieve */ - if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) { goto cleanup; - + } switch (msgrcv.sound_msg.msgtype) { - case MM_SOUND_MSG_RES_GET_ACTIVE_DEVICE: - *device_in = msgrcv.sound_msg.device_in; - *device_out = msgrcv.sound_msg.device_out; - debug_msg("[Client] Success to get active device %d %d\n", *device_in, *device_out); + case MM_SOUND_MSG_RES_REMOVE_DEVICE_CONNECTED_CB: + debug_msg("[Client] Success to remove device connected callback\n"); break; case MM_SOUND_MSG_RES_ERROR: debug_error("[Client] Error occurred \n"); @@ -982,7 +1157,7 @@ cleanup: return ret; } -int _mm_sound_client_add_active_device_changed_callback(mm_sound_active_device_changed_cb func, void* user_data) +int _mm_sound_client_add_device_info_changed_callback(int device_flags, mm_sound_device_info_changed_cb func, void* user_data) { mm_ipc_msg_t msgrcv = {0,}; mm_ipc_msg_t msgsnd = {0,}; @@ -991,29 +1166,34 @@ int _mm_sound_client_add_active_device_changed_callback(mm_sound_active_device_c debug_fenter(); - if (__mm_sound_client_get_msg_queue() != MM_ERROR_NONE) + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { return ret; + } pthread_mutex_lock(&g_thread_mutex); instance = getpid(); /* Send REQ_ADD_ACTIVE_DEVICE_CB */ - msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_ADD_ACTIVE_DEVICE_CB; + msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_ADD_DEVICE_INFO_CHANGED_CB; msgsnd.sound_msg.msgid = instance; + msgsnd.sound_msg.device_flags = device_flags; msgsnd.sound_msg.callback = func; msgsnd.sound_msg.cbdata = user_data; - if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) + if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) { goto cleanup; + } /* Recieve */ - if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) { goto cleanup; + } switch (msgrcv.sound_msg.msgtype) { - case MM_SOUND_MSG_RES_ADD_ACTIVE_DEVICE_CB: - debug_msg("[Client] Success to add active device callback\n"); + case MM_SOUND_MSG_RES_ADD_DEVICE_INFO_CHANGED_CB: + debug_msg("[Client] Success to add device connected callback\n"); if (g_thread_id == -1) { g_thread_id = pthread_create(&g_thread, NULL, callbackfunc, NULL); @@ -1044,7 +1224,7 @@ cleanup: return ret; } -int _mm_sound_client_remove_active_device_changed_callback(void) +int _mm_sound_client_remove_device_info_changed_callback(void) { mm_ipc_msg_t msgrcv = {0,}; mm_ipc_msg_t msgsnd = {0,}; @@ -1053,27 +1233,31 @@ int _mm_sound_client_remove_active_device_changed_callback(void) debug_fenter(); - if (__mm_sound_client_get_msg_queue() != MM_ERROR_NONE) + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { return ret; + } pthread_mutex_lock(&g_thread_mutex); instance = getpid(); /* Send REQ_REMOVE_ACTIVE_DEVICE_CB */ - msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_REMOVE_ACTIVE_DEVICE_CB; + msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_REMOVE_DEVICE_INFO_CHANGED_CB; msgsnd.sound_msg.msgid = instance; - if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) + if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) { goto cleanup; + } /* Recieve */ - if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) { goto cleanup; + } switch (msgrcv.sound_msg.msgtype) { - case MM_SOUND_MSG_RES_REMOVE_ACTIVE_DEVICE_CB: - debug_msg("[Client] Success to remove active device callback\n"); + case MM_SOUND_MSG_RES_REMOVE_DEVICE_INFO_CHANGED_CB: + debug_msg("[Client] Success to remove device info changed callback\n"); break; case MM_SOUND_MSG_RES_ERROR: debug_error("[Client] Error occurred \n"); @@ -1094,7 +1278,7 @@ cleanup: return ret; } -int _mm_sound_client_add_available_route_changed_callback(mm_sound_available_route_changed_cb func, void* user_data) +int _mm_sound_client_is_route_available(mm_sound_route route, bool *is_available) { mm_ipc_msg_t msgrcv = {0,}; mm_ipc_msg_t msgsnd = {0,}; @@ -1103,8 +1287,620 @@ int _mm_sound_client_add_available_route_changed_callback(mm_sound_available_rou debug_fenter(); - if (__mm_sound_client_get_msg_queue() != MM_ERROR_NONE) + *is_available = FALSE; + + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { + return ret; + } + + pthread_mutex_lock(&g_thread_mutex); + + instance = getpid(); + /* Send REQ_IS_ROUTE_AVAILABLE */ + msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_IS_ROUTE_AVAILABLE; + msgsnd.sound_msg.msgid = instance; + msgsnd.sound_msg.route = route; + + if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) { + goto cleanup; + } + + /* Receive */ + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) { + goto cleanup; + } + + switch (msgrcv.sound_msg.msgtype) + { + case MM_SOUND_MSG_RES_IS_ROUTE_AVAILABLE: + *is_available = msgrcv.sound_msg.is_available; + debug_msg("[Client] Success to check given route is available %d\n", *is_available); + break; + case MM_SOUND_MSG_RES_ERROR: + debug_error("[Client] Error occurred \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + default: + debug_critical("[Client] Unexpected state with communication \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + } + +cleanup: + pthread_mutex_unlock(&g_thread_mutex); + + debug_fleave(); + return ret; +} + +static int _handle_foreach_callback(mm_ipc_msg_t *msg) +{ + int route_index; + mm_sound_route route; + + debug_fenter(); + + if (msg->sound_msg.callback == NULL) { + debug_error ("[Client] Foreach callback is [%p], cbdata = %p => exit", + msg->sound_msg.callback, msg->sound_msg.cbdata); + return MM_ERROR_SOUND_INTERNAL; + } + + for (route_index = 0; route_index < MM_SOUND_ROUTE_NUM; route_index++) { + route = msg->sound_msg.route_list[route_index]; + if (route == 0) { + break; + } + debug_msg("[Client] available route : %d\n", route); + if (((mm_sound_available_route_cb)msg->sound_msg.callback)(route, msg->sound_msg.cbdata) == false) { + debug_msg ("[Client] user doesn't want anymore. quit loop!!\n"); + break; + } + } + + debug_fleave(); + + return MM_ERROR_NONE; +} + +int _mm_sound_client_foreach_available_route_cb(mm_sound_available_route_cb available_route_cb, void *user_data) +{ + mm_ipc_msg_t msgrcv = {0,}; + mm_ipc_msg_t msgsnd = {0,}; + int ret = MM_ERROR_NONE; + int instance; + + debug_fenter(); + + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { + return ret; + } + + pthread_mutex_lock(&g_thread_mutex); + + instance = getpid(); + /* Send REQ_FOREACH_AVAILABLE_ROUTE_CB */ + msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_FOREACH_AVAILABLE_ROUTE_CB; + msgsnd.sound_msg.msgid = instance; + msgsnd.sound_msg.callback = (void *)available_route_cb; + msgsnd.sound_msg.cbdata = (void *)user_data; + + if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) { + goto cleanup; + } + + /* Recieve */ + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) { + goto cleanup; + } + + switch (msgrcv.sound_msg.msgtype) + { + case MM_SOUND_MSG_RES_FOREACH_AVAILABLE_ROUTE_CB: + debug_msg("[Client] Success to set foreach available route callback\n"); + msgrcv.sound_msg.callback = (void *)available_route_cb; + msgrcv.sound_msg.cbdata = (void *)user_data; + ret = _handle_foreach_callback (&msgrcv); + break; + case MM_SOUND_MSG_RES_ERROR: + debug_error("[Client] Error occurred \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + default: + debug_critical("[Client] Unexpected state with communication \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + } + +cleanup: + pthread_mutex_unlock(&g_thread_mutex); + + debug_fleave(); + return ret; +} + +int _mm_sound_client_set_active_route(mm_sound_route route, bool need_broadcast) +{ + mm_ipc_msg_t msgrcv = {0,}; + mm_ipc_msg_t msgsnd = {0,}; + int ret = MM_ERROR_NONE; + int instance; + + debug_fenter(); + + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { + return ret; + } + + pthread_mutex_lock(&g_thread_mutex); + + instance = getpid(); + /* Send REQ_SET_ACTIVE_ROUTE */ + msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_SET_ACTIVE_ROUTE; + msgsnd.sound_msg.msgid = instance; + msgsnd.sound_msg.route = route; + msgsnd.sound_msg.need_broadcast = need_broadcast; + + if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) + goto cleanup; + + /* Recieve */ + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) { + goto cleanup; + } + + switch (msgrcv.sound_msg.msgtype) + { + case MM_SOUND_MSG_RES_SET_ACTIVE_ROUTE: + debug_msg("[Client] Success to add active device callback\n"); + break; + case MM_SOUND_MSG_RES_ERROR: + debug_error("[Client] Error occurred \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + default: + debug_critical("[Client] Unexpected state with communication \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + } + +cleanup: + pthread_mutex_unlock(&g_thread_mutex); + + debug_fleave(); + return ret; +} + +int _mm_sound_client_set_active_route_auto(void) +{ + mm_ipc_msg_t msgrcv = {0,}; + mm_ipc_msg_t msgsnd = {0,}; + int ret = MM_ERROR_NONE; + int instance; + + debug_fenter(); + + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { + return ret; + } + + pthread_mutex_lock(&g_thread_mutex); + + instance = getpid(); + /* Send REQ_SET_ACTIVE_ROUTE */ + msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_SET_ACTIVE_ROUTE_AUTO; + msgsnd.sound_msg.msgid = instance; + + if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) { + goto cleanup; + } + + /* Recieve */ + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) { + goto cleanup; + } + + switch (msgrcv.sound_msg.msgtype) + { + case MM_SOUND_MSG_RES_SET_ACTIVE_ROUTE_AUTO: + debug_msg("[Client] Success to set active device auto\n"); + break; + case MM_SOUND_MSG_RES_ERROR: + debug_error("[Client] Error occurred \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + default: + debug_critical("[Client] Unexpected state with communication \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + } + +cleanup: + pthread_mutex_unlock(&g_thread_mutex); + + debug_fleave(); + return ret; +} + +int _mm_sound_client_get_active_device(mm_sound_device_in *device_in, mm_sound_device_out *device_out) +{ + mm_ipc_msg_t msgrcv = {0,}; + mm_ipc_msg_t msgsnd = {0,}; + int ret = MM_ERROR_NONE; + int instance; + + debug_fenter(); + + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { + return ret; + } + + pthread_mutex_lock(&g_thread_mutex); + + instance = getpid(); + /* Send REQ_GET_ACTIVE_DEVICE */ + msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_GET_ACTIVE_DEVICE; + msgsnd.sound_msg.msgid = instance; + + if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) { + goto cleanup; + } + + /* Recieve */ + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) { + goto cleanup; + } + + switch (msgrcv.sound_msg.msgtype) + { + case MM_SOUND_MSG_RES_GET_ACTIVE_DEVICE: + *device_in = msgrcv.sound_msg.device_in; + *device_out = msgrcv.sound_msg.device_out; + debug_log("[Client] Success to get active device in=[%x], out=[%x]\n", *device_in, *device_out); + break; + case MM_SOUND_MSG_RES_ERROR: + debug_error("[Client] Error occurred \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + default: + debug_critical("[Client] Unexpected state with communication \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + } + +cleanup: + pthread_mutex_unlock(&g_thread_mutex); + + debug_fleave(); + return ret; +} + +int _mm_sound_client_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out) +{ + mm_ipc_msg_t msgrcv = {0,}; + mm_ipc_msg_t msgsnd = {0,}; + int ret = MM_ERROR_NONE; + int instance; + + debug_fenter(); + + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { + return ret; + } + + pthread_mutex_lock(&g_thread_mutex); + + instance = getpid(); + /* Send REQ_GET_AUDIO_PATH */ + msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_GET_AUDIO_PATH; + msgsnd.sound_msg.msgid = instance; + + if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) { + goto cleanup; + } + + /* Recieve */ + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) { + goto cleanup; + } + + switch (msgrcv.sound_msg.msgtype) + { + case MM_SOUND_MSG_RES_GET_AUDIO_PATH: + *device_in = msgrcv.sound_msg.device_in; + *device_out = msgrcv.sound_msg.device_out; + debug_log("[Client] Success to get active device in=[%x], out=[%x]\n", *device_in, *device_out); + break; + case MM_SOUND_MSG_RES_ERROR: + debug_error("[Client] Error occurred \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + default: + debug_critical("[Client] Unexpected state with communication \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + } + +cleanup: + pthread_mutex_unlock(&g_thread_mutex); + + debug_fleave(); + return ret; +} + +int _mm_sound_client_add_active_device_changed_callback(const char *name, mm_sound_active_device_changed_cb func, void* user_data) +{ + mm_ipc_msg_t msgrcv = {0,}; + mm_ipc_msg_t msgsnd = {0,}; + int ret = MM_ERROR_NONE; + int instance; + + debug_fenter(); + + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { + return ret; + } + + pthread_mutex_lock(&g_thread_mutex); + + instance = getpid(); + /* Send REQ_ADD_ACTIVE_DEVICE_CB */ + msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_ADD_ACTIVE_DEVICE_CB; + msgsnd.sound_msg.msgid = instance; + msgsnd.sound_msg.callback = func; + msgsnd.sound_msg.cbdata = user_data; + MMSOUND_STRNCPY(msgsnd.sound_msg.name, name, MM_SOUND_NAME_NUM); + + if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) { + goto cleanup; + } + + /* Recieve */ + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) { + goto cleanup; + } + + switch (msgrcv.sound_msg.msgtype) + { + case MM_SOUND_MSG_RES_ADD_ACTIVE_DEVICE_CB: + debug_msg("[Client] Success to add active device callback\n"); + if (g_thread_id == -1) + { + g_thread_id = pthread_create(&g_thread, NULL, callbackfunc, NULL); + if (g_thread_id == -1) + { + debug_critical("[Client] Fail to create thread %s\n", strerror(errno)); + ret = MM_ERROR_SOUND_INTERNAL; + goto cleanup; + } + } + break; + case MM_SOUND_MSG_RES_ERROR: + debug_error("[Client] Error occurred \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + default: + debug_critical("[Client] Unexpected state with communication \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + } + +cleanup: + pthread_mutex_unlock(&g_thread_mutex); + + debug_fleave(); + return ret; +} + +int _mm_sound_client_remove_active_device_changed_callback(const char *name) +{ + mm_ipc_msg_t msgrcv = {0,}; + mm_ipc_msg_t msgsnd = {0,}; + int ret = MM_ERROR_NONE; + int instance; + + debug_fenter(); + + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { + return ret; + } + + pthread_mutex_lock(&g_thread_mutex); + + instance = getpid(); + /* Send REQ_REMOVE_ACTIVE_DEVICE_CB */ + msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_REMOVE_ACTIVE_DEVICE_CB; + msgsnd.sound_msg.msgid = instance; + MMSOUND_STRNCPY(msgsnd.sound_msg.name, name, MM_SOUND_NAME_NUM); + + if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) { + goto cleanup; + } + + /* Recieve */ + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) { + goto cleanup; + } + + switch (msgrcv.sound_msg.msgtype) + { + case MM_SOUND_MSG_RES_REMOVE_ACTIVE_DEVICE_CB: + debug_msg("[Client] Success to remove active device callback\n"); + break; + case MM_SOUND_MSG_RES_ERROR: + debug_error("[Client] Error occurred \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + default: + debug_critical("[Client] Unexpected state with communication \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + } + +cleanup: + pthread_mutex_unlock(&g_thread_mutex); + + debug_fleave(); + return ret; +} + +int _mm_sound_client_add_volume_changed_callback(mm_sound_volume_changed_cb func, void* user_data) +{ + mm_ipc_msg_t msgrcv = {0,}; + mm_ipc_msg_t msgsnd = {0,}; + int ret = MM_ERROR_NONE; + int instance; + + debug_fenter(); + + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { + return ret; + } + + pthread_mutex_lock(&g_thread_mutex); + + instance = getpid(); + /* Send REQ_ADD_VOLUME_CB */ + msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_ADD_VOLUME_CB; + msgsnd.sound_msg.msgid = instance; + msgsnd.sound_msg.callback = func; + msgsnd.sound_msg.cbdata = user_data; + + if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) { + goto cleanup; + } + + /* Recieve */ + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) { + goto cleanup; + } + + switch (msgrcv.sound_msg.msgtype) + { + case MM_SOUND_MSG_RES_ADD_VOLUME_CB: + debug_msg("[Client] Success to add volume callback\n"); + if (g_thread_id == -1) + { + g_thread_id = pthread_create(&g_thread, NULL, callbackfunc, NULL); + if (g_thread_id == -1) + { + debug_critical("[Client] Fail to create thread %s\n", strerror(errno)); + ret = MM_ERROR_SOUND_INTERNAL; + goto cleanup; + } + } + break; + case MM_SOUND_MSG_RES_ERROR: + debug_error("[Client] Error occurred \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + default: + debug_critical("[Client] Unexpected state with communication \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + } + +cleanup: + pthread_mutex_unlock(&g_thread_mutex); + + debug_fleave(); + return ret; +} + +int _mm_sound_client_remove_volume_changed_callback(void) +{ + mm_ipc_msg_t msgrcv = {0,}; + mm_ipc_msg_t msgsnd = {0,}; + int ret = MM_ERROR_NONE; + int instance; + + debug_fenter(); + + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { + return ret; + } + + pthread_mutex_lock(&g_thread_mutex); + + instance = getpid(); + /* Send REQ_REMOVE_VOLUME_CB */ + msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_REMOVE_VOLUME_CB; + msgsnd.sound_msg.msgid = instance; + + if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) { + goto cleanup; + } + + /* Recieve */ + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) { + goto cleanup; + } + + switch (msgrcv.sound_msg.msgtype) + { + case MM_SOUND_MSG_RES_REMOVE_VOLUME_CB: + debug_msg("[Client] Success to remove volume callback\n"); + break; + case MM_SOUND_MSG_RES_ERROR: + debug_error("[Client] Error occurred \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + default: + debug_critical("[Client] Unexpected state with communication \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + } + +cleanup: + pthread_mutex_unlock(&g_thread_mutex); + + debug_fleave(); + return ret; +} + +int _mm_sound_client_add_available_route_changed_callback(mm_sound_available_route_changed_cb func, void* user_data) +{ + mm_ipc_msg_t msgrcv = {0,}; + mm_ipc_msg_t msgsnd = {0,}; + int ret = MM_ERROR_NONE; + int instance; + + debug_fenter(); + + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { return ret; + } pthread_mutex_lock(&g_thread_mutex); @@ -1115,12 +1911,14 @@ int _mm_sound_client_add_available_route_changed_callback(mm_sound_available_rou msgsnd.sound_msg.callback = func; msgsnd.sound_msg.cbdata = user_data; - if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) + if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) { goto cleanup; + } /* Recieve */ - if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) { goto cleanup; + } switch (msgrcv.sound_msg.msgtype) { @@ -1165,8 +1963,10 @@ int _mm_sound_client_remove_available_route_changed_callback(void) debug_fenter(); - if (__mm_sound_client_get_msg_queue() != MM_ERROR_NONE) + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) { return ret; + } pthread_mutex_lock(&g_thread_mutex); @@ -1175,12 +1975,14 @@ int _mm_sound_client_remove_available_route_changed_callback(void) msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_REMOVE_AVAILABLE_ROUTE_CB; msgsnd.sound_msg.msgid = instance; - if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) + if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) { goto cleanup; + } /* Recieve */ - if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) { goto cleanup; + } switch (msgrcv.sound_msg.msgtype) { @@ -1212,27 +2014,7 @@ static int __MMIpcCBSndMsg(mm_ipc_msg_t *msg) msg->msg_type = msg->sound_msg.msgid; if (msgsnd(g_msg_sccb, msg,DSIZE, 0)== -1) { - if(errno == EACCES) - { - debug_warning("[Client] Not acces.\n"); - } - else if(errno == EAGAIN) - { - debug_warning("[Client] Blocked process [msgflag & IPC_NOWAIT != 0]\n"); - } - else if(errno == EIDRM) - { - debug_warning("[Client] Removed msgid from system\n"); - } - else if(errno == EINTR) - { - debug_warning("[Client] Iterrrupted by singnal\n"); - } - else if(errno == EINVAL) - { - debug_warning("[Client] Invalid msgid or msgtype < 1 or out of data size \n"); - } - debug_critical("[Client] Fail to callback send message msgid : [%d] \n", g_msg_sccb); + debug_error("[Client] Fail to callback send message msgid : [%d], [%d][%s]", g_msg_sccb, errno, strerror(errno)); return MM_ERROR_COMMON_UNKNOWN; } return MM_ERROR_NONE; @@ -1243,37 +2025,14 @@ static int __MMIpcCBRecvMsg(int msgtype, mm_ipc_msg_t *msg) /* rcv message */ if(msgrcv(g_msg_sccb, msg, DSIZE, msgtype, 0) == -1) { - if(errno == E2BIG) - { - debug_warning("[Client] Not acces.\n"); - } - else if(errno == EACCES) - { - debug_warning("[Client] Access denied\n"); - } - else if(errno == ENOMSG) - { - debug_warning("[Client] Blocked process [msgflag & IPC_NOWAIT != 0]\n"); - } - else if(errno == EIDRM) - { - debug_warning("[Client] Removed msgid from system\n"); - } - else if(errno == EINTR) - { - debug_warning("[Client] Iterrrupted by singnal\n"); - } - else if(errno == EINVAL) - { - debug_warning("[Client] Invalid msgid \n"); - } - - debug_error("[Client] Fail to callback receive msgid : [%d] \n", g_msg_sccb); + debug_error("[Client] Fail to callback receive message msgid : [%d], [%d][%s]", g_msg_sccb, errno, strerror(errno)); return MM_ERROR_COMMON_UNKNOWN; } return MM_ERROR_NONE; } +#define MAX_RCV_RETRY 20000 + static int __MMIpcRecvMsg(int msgtype, mm_ipc_msg_t *msg) { int retry_count = 0; @@ -1281,29 +2040,21 @@ static int __MMIpcRecvMsg(int msgtype, mm_ipc_msg_t *msg) /* rcv message */ while (msgrcv(g_msg_scrcv, msg, DSIZE, msgtype, IPC_NOWAIT) == -1) { if (errno == ENOMSG) { - if (retry_count < 20000) { /* usec is 10^-6 sec so, 5ms * 20000 = 10sec. */ + if (retry_count < MAX_RCV_RETRY) { /* usec is 10^-6 sec so, 5ms * 20000 = 10sec. */ usleep(5000); retry_count++; continue; } else { + debug_error("[Client] retry(%d) is over : [%d] \n", MAX_RCV_RETRY, g_msg_scrcv); return MM_ERROR_SOUND_INTERNAL; } - } else if (errno == E2BIG) { - debug_warning("[Client] Not acces.\n"); - } else if (errno == EACCES) { - debug_warning("[Client] Access denied\n"); - } else if (errno == ENOMSG) { - debug_warning("[Client] Blocked process [msgflag & IPC_NOWAIT != 0]\n"); - } else if (errno == EIDRM) { - debug_warning("[Client] Removed msgid from system\n"); } else if (errno == EINTR) { - debug_warning("[Client] Iterrrupted by singnal\n"); + debug_warning("[Client] Interrupted by signal, continue loop"); continue; - } else if (errno == EINVAL) { - debug_warning("[Client] Invalid msgid \n"); } - debug_error("[Client] Fail to recive msgid : [%d] \n", g_msg_scrcv); + debug_error("[Client] Fail to receive msgid : [%d], [%d][%s]", g_msg_scrcv, errno, strerror(errno)); + return MM_ERROR_COMMON_UNKNOWN; } debug_log("[Client] Retry %d times when receive msg\n", retry_count); @@ -1313,26 +2064,40 @@ static int __MMIpcRecvMsg(int msgtype, mm_ipc_msg_t *msg) static int __MMIpcSndMsg(mm_ipc_msg_t *msg) { /* rcv message */ + int try_again = 0; + msg->msg_type = msg->sound_msg.msgid; - if (msgsnd(g_msg_scsnd, msg,DSIZE, 0) == -1) + while (msgsnd(g_msg_scsnd, msg,DSIZE, IPC_NOWAIT) == -1) { - if (errno == EACCES) { - debug_warning("[Client] Not access.\n"); - } else if (errno == EAGAIN) { - debug_warning("[Client] Blocked process msgflag & IPC_NOWAIT != 0]\n"); - } else if (errno == EIDRM) { - debug_warning("[Client] Removed msgid from system\n"); - } else if (errno == EINTR) { - debug_warning("[Client] Iterrrupted by singnal\n"); - } else if (errno == EINVAL) { + if(errno == EACCES) { + debug_warning("Not acces.\n"); + } else if(errno == EAGAIN || errno == ENOMEM) { + mm_ipc_msg_t msgdata = {0,}; + debug_warning("Blocked process [msgflag & IPC_NOWAIT != 0]\n"); + debug_warning("The system does not have enough memory to make a copy of the message pointed to by msgp\n"); + /* wait 10 msec ,then it will try again */ + usleep(10000); + /* it will try 5 times, after 5 times ,if it still fail ,then it will clear the message queue */ + if (try_again <= 5) { + try_again ++; + continue; + } + /* message queue is full ,it need to clear the queue */ + while( msgrcv(g_msg_scsnd, &msgdata, DSIZE, 0, IPC_NOWAIT) != -1 ) { + debug_warning("msg queue is full ,remove msgtype:[%d] from the queue",msgdata.sound_msg.msgtype); + } + try_again++; + continue; + } else if(errno == EIDRM) { + debug_warning("Removed msgid from system\n"); + } else if(errno == EINTR) { + debug_warning("Iterrrupted by singnal\n"); + } else if(errno == EINVAL) { debug_warning("Invalid msgid or msgtype < 1 or out of data size \n"); - } else if (errno == EFAULT) { - debug_warning("[Client] The address pointed to by msgp isn't accessible \n"); - } else if (errno == ENOMEM) { - debug_warning("[Client] The system does not have enough memory to make a copy of the message pointed to by msgp\n"); + } else if(errno == EFAULT) { + debug_warning("The address pointed to by msgp isn't accessible \n"); } - - debug_critical("[Client] Fail to send message msgid : [%d] \n", g_msg_scsnd); + debug_error("[Client] Fail to send message msgid : [%d], [%d][%s]", g_msg_scsnd, errno, strerror(errno)); return MM_ERROR_SOUND_INTERNAL; } return MM_ERROR_NONE; @@ -1342,9 +2107,10 @@ static int __MMSoundGetMsg(void) { /* Init message queue, generate msgid for communication to server */ /* The key value to get msgid is defined "mm_sound_msg.h". Shared with server */ - + int i = 0; + debug_fenter(); - + /* get msg queue rcv, snd, cb */ g_msg_scsnd = msgget(ftok(KEY_BASE_PATH, RCV_MSG), 0666); g_msg_scrcv = msgget(ftok(KEY_BASE_PATH, SND_MSG), 0666); @@ -1358,21 +2124,33 @@ static int __MMSoundGetMsg(void) } else if(errno == ENOSPC) { debug_warning("Resource is empty.\n"); } - debug_error("Fail to GET msgid\n"); - return MM_ERROR_SOUND_INTERNAL; + /* Some app would start before Sound Server IPC ready. */ + /* Let's try it again in 50ms later by 10 times */ + for (i=0;i<10;i++) { + usleep(50000); + g_msg_scsnd = msgget(ftok(KEY_BASE_PATH, RCV_MSG), 0666); + g_msg_scrcv = msgget(ftok(KEY_BASE_PATH, SND_MSG), 0666); + g_msg_sccb = msgget(ftok(KEY_BASE_PATH, CB_MSG), 0666); + if ((g_msg_scsnd == -1 || g_msg_scrcv == -1 || g_msg_sccb == -1) != MM_ERROR_NONE) { + debug_error("Fail to GET msgid by retrying %d times\n", i+1); + } else + break; + } + if ((g_msg_scsnd == -1 || g_msg_scrcv == -1 || g_msg_sccb == -1) != MM_ERROR_NONE) { + debug_error("Fail to GET msgid finally, just return internal error.\n"); + return MM_ERROR_SOUND_INTERNAL; + } } - - debug_msg("Get msg queue id from server : [%d]\n", g_msg_scsnd); - debug_msg("Get msg queue id from server : [%d]\n", g_msg_scrcv); - debug_msg("Get msg queue id from server : [%d]\n", g_msg_sccb); - + + debug_log("Get msg queue id from server : snd[%d], rcv[%d], cb[%d]\n", g_msg_scsnd, g_msg_scrcv, g_msg_sccb); + debug_fleave(); return MM_ERROR_NONE; } #ifdef PULSE_CLIENT -int MMSoundClientIsBtA2dpOn (int *connected, char** bt_name) +int MMSoundClientIsBtA2dpOn (bool *connected, char** bt_name) { mm_ipc_msg_t msgrcv = {0,}; mm_ipc_msg_t msgsnd = {0,}; @@ -1381,9 +2159,10 @@ int MMSoundClientIsBtA2dpOn (int *connected, char** bt_name) debug_fenter(); - instance = getpid(); + instance = getpid(); - if (__mm_sound_client_get_msg_queue() != MM_ERROR_NONE) + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) return ret; pthread_mutex_lock(&g_thread_mutex); @@ -1399,7 +2178,7 @@ int MMSoundClientIsBtA2dpOn (int *connected, char** bt_name) goto cleanup; } - /* Recieve */ + /* Receive */ ret = __MMIpcRecvMsg(instance, &msgrcv); if (ret != MM_ERROR_NONE) { @@ -1410,7 +2189,7 @@ int MMSoundClientIsBtA2dpOn (int *connected, char** bt_name) { case MM_SOUND_MSG_RES_IS_BT_A2DP_ON: debug_msg("Success to get IS_BT_A2DP_ON [%d][%s]\n", msgrcv.sound_msg.code, msgrcv.sound_msg.filename); - *connected = msgrcv.sound_msg.code; + *connected = (bool)msgrcv.sound_msg.code; if (*connected) *bt_name = strdup (msgrcv.sound_msg.filename); else @@ -1435,4 +2214,58 @@ cleanup: return ret; } +int _mm_sound_client_set_sound_path_for_active_device(mm_sound_device_out device_out, mm_sound_device_in device_in) +{ + mm_ipc_msg_t msgrcv = {0,}; + mm_ipc_msg_t msgsnd = {0,}; + int ret = MM_ERROR_NONE; + int instance; + + debug_fenter(); + + ret = __mm_sound_client_get_msg_queue(); + if (ret != MM_ERROR_NONE) + return ret; + + pthread_mutex_lock(&g_thread_mutex); + + instance = getpid(); + /* Send MM_SOUND_MSG_REQ_SET_PATH_FOR_ACTIVE_DEVICE */ + msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_SET_PATH_FOR_ACTIVE_DEVICE; + msgsnd.sound_msg.msgid = instance; + msgsnd.sound_msg.device_in = device_in; + msgsnd.sound_msg.device_out = device_out; + + if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) + goto cleanup; + + /* Recieve */ + if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) + goto cleanup; + + switch (msgrcv.sound_msg.msgtype) + { + case MM_SOUND_MSG_RES_SET_PATH_FOR_ACTIVE_DEVICE: + debug_msg("[Client] Success to setsound path for active device\n"); + break; + case MM_SOUND_MSG_RES_ERROR: + debug_error("[Client] Error occurred \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + default: + debug_critical("[Client] Unexpected state with communication \n"); + ret = msgrcv.sound_msg.code; + goto cleanup; + break; + } + +cleanup: + pthread_mutex_unlock(&g_thread_mutex); + + debug_fleave(); + return ret; +} + + #endif // PULSE_CLIENT diff --git a/mm_sound_device.c b/mm_sound_device.c new file mode 100644 index 0000000..9c8c936 --- /dev/null +++ b/mm_sound_device.c @@ -0,0 +1,275 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Sangchul Lee + * + * 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/mm_sound.h" +#include "include/mm_sound_device.h" + +bool is_new_device_list = true; + +static int check_for_valid_mask (mm_sound_device_flags_e flags) +{ + int ret = MM_ERROR_NONE; + bool at_least_cond = false; + + if (flags > 0 && flags <= MM_SOUND_DEVICE_ALL_FLAG) { + if (flags & MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG) + at_least_cond = true; + if (!at_least_cond && (flags & MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG)) + at_least_cond = true; + if (!at_least_cond && (flags & MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG)) + at_least_cond = true; + if (!at_least_cond && (flags & MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG)) + at_least_cond = true; + if (!at_least_cond && (flags & MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG)) + at_least_cond = true; + if (!at_least_cond && (flags & MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG)) + at_least_cond = true; + if (!at_least_cond && (flags & MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG)) + at_least_cond = true; + } else { + ret = MM_ERROR_INVALID_ARGUMENT; + } + if (!at_least_cond) { + ret = MM_ERROR_INVALID_ARGUMENT; + } + if (ret) { + debug_error("flags[0x%x] is not valid\n", flags); + } + return ret; +} + +EXPORT_API +int mm_sound_add_device_connected_callback(mm_sound_device_flags_e flags, mm_sound_device_connected_cb func, void *user_data) +{ + int ret = MM_ERROR_NONE; + + if (func == NULL) { + debug_error("argument is not valid\n"); + return MM_ERROR_INVALID_ARGUMENT; + } + ret = check_for_valid_mask(flags); + if (ret == MM_ERROR_NONE) { + ret = _mm_sound_client_add_device_connected_callback(flags, func, user_data); + if (ret < 0) { + debug_error("Could not add device connected callback, ret = %x\n", ret); + } + } + + return ret; +} + +EXPORT_API +int mm_sound_remove_device_connected_callback(void) +{ + int ret = MM_ERROR_NONE; + + ret = _mm_sound_client_remove_device_connected_callback(); + if (ret < 0) { + debug_error("Could not remove device connected callback, ret = %x\n", ret); + } + + return ret; +} + +EXPORT_API +int mm_sound_add_device_information_changed_callback(mm_sound_device_flags_e flags, mm_sound_device_info_changed_cb func, void *user_data) +{ + int ret = MM_ERROR_NONE; + + if (func == NULL) { + debug_error("argument is not valid\n"); + return MM_ERROR_INVALID_ARGUMENT; + } + ret = check_for_valid_mask(flags); + if (ret == MM_ERROR_NONE) { + ret = _mm_sound_client_add_device_info_changed_callback(flags, func, user_data); + if (ret < 0) { + debug_error("Could not add device information changed callback, ret = %x\n", ret); + } + } + + return ret; +} + +EXPORT_API +int mm_sound_remove_device_information_changed_callback() +{ + int ret = MM_ERROR_NONE; + + ret = _mm_sound_client_remove_device_info_changed_callback(); + if (ret < 0) { + debug_error("Could not remove device information changed callback, ret = %x\n", ret); + } + + return ret; +} + +EXPORT_API +int mm_sound_get_current_device_list(mm_sound_device_flags_e flags, MMSoundDeviceList_t *device_list) +{ + int ret = MM_ERROR_NONE; + + if (!device_list) { + return MM_ERROR_INVALID_ARGUMENT; + } + ret = check_for_valid_mask(flags); + if (ret == MM_ERROR_NONE) { + ret = _mm_sound_client_get_current_connected_device_list(flags, (mm_sound_device_list_t**)device_list); + if (ret < 0) { + debug_error("Could not get current connected device list, ret = %x\n", ret); + } else { + is_new_device_list = true; + } + } + + return ret; +} + +EXPORT_API +int mm_sound_get_next_device (MMSoundDeviceList_t device_list, MMSoundDevice_t *device) +{ + int ret = MM_ERROR_NONE; + mm_sound_device_list_t *device_list_t = NULL; + mm_sound_device_t *device_h = NULL; + GList *node = NULL; + if (!device_list || !device) { + return MM_ERROR_INVALID_ARGUMENT; + } + device_list_t = (mm_sound_device_list_t*) device_list; + if (is_new_device_list) { + node = g_list_first(device_list_t->list); + } else { + node = g_list_next(device_list_t->list); + } + if (!node) { + ret = MM_ERROR_SOUND_NO_DATA; + } else { + if (is_new_device_list) { + is_new_device_list = false; + } else { + device_list_t->list = node; + } + *device = (mm_sound_device_t*)node->data; + debug_log("next device[0x%x]\n", *device); + } + return ret; +} + +EXPORT_API +int mm_sound_get_prev_device (MMSoundDeviceList_t device_list, MMSoundDevice_t *device) +{ + int ret = MM_ERROR_NONE; + mm_sound_device_list_t *device_list_t = NULL; + mm_sound_device_t *device_h = NULL; + GList *node = NULL; + if (!device_list || !device) { + return MM_ERROR_INVALID_ARGUMENT; + } + device_list_t = (mm_sound_device_list_t*) device_list; + node = g_list_previous(device_list_t->list); + if (!node) { + ret = MM_ERROR_SOUND_NO_DATA; + debug_error("Could not get previous device, ret = %x\n", ret); + } else { + device_list_t->list = node; + *device = (mm_sound_device_t*)node->data; + debug_log("previous device[0x%x]\n", *device); + } + return ret; +} + +EXPORT_API +int mm_sound_get_device_type(MMSoundDevice_t device_h, mm_sound_device_type_e *type) +{ + mm_sound_device_t *device = (mm_sound_device_t*)device_h; + if(!device) { + debug_error("invalid handle\n"); + return MM_ERROR_INVALID_ARGUMENT; + } + *type = device->type; + debug_log("device_handle:0x%x, type:%d\n", device, *type); + + return MM_ERROR_NONE; +} + +EXPORT_API +int mm_sound_get_device_io_direction(MMSoundDevice_t device_h, mm_sound_device_io_direction_e *io_direction) +{ + mm_sound_device_t *device = (mm_sound_device_t*)device_h; + if(!device) { + debug_error("invalid handle\n"); + return MM_ERROR_INVALID_ARGUMENT; + } + *io_direction = device->io_direction; + debug_log("device_handle:0x%x, io_direction:%d (0:IN,1:OUT,2:INOUT)\n", device, *io_direction); + + return MM_ERROR_NONE; +} + +EXPORT_API +int mm_sound_get_device_id(MMSoundDevice_t device_h, int *id) +{ + mm_sound_device_t *device = (mm_sound_device_t*)device_h; + if(!device) { + debug_error("invalid handle\n"); + return MM_ERROR_INVALID_ARGUMENT; + } + *id = device->id; + debug_log("device_handle:0x%x, id:%d\n", device, *id); + + return MM_ERROR_NONE; +} + +EXPORT_API +int mm_sound_get_device_state(MMSoundDevice_t device_h, mm_sound_device_state_e *state) +{ + mm_sound_device_t *device = (mm_sound_device_t*)device_h; + if(!device) { + debug_error("invalid handle\n"); + return MM_ERROR_INVALID_ARGUMENT; + } + *state = device->state; + debug_log("device_handle:0x%x, state:%d (0:INACTIVATED,1:ACTIVATED)\n", device, *state); + + return MM_ERROR_NONE; +} + +EXPORT_API +int mm_sound_get_device_name(MMSoundDevice_t device_h, char **name) +{ + mm_sound_device_t *device = (mm_sound_device_t*)device_h; + if(!device) { + debug_error("invalid handle\n"); + return MM_ERROR_INVALID_ARGUMENT; + } + *name = device->name; + debug_log("device_handle:0x%x, name:%s\n", device, *name); + + return MM_ERROR_NONE; +} + diff --git a/mm_sound_keysound.c b/mm_sound_keysound.c index 55e97c1..007e07d 100644 --- a/mm_sound_keysound.c +++ b/mm_sound_keysound.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -37,32 +38,40 @@ #include #include +#include "include/mm_sound_common.h" + #define KEYTONE_PATH "/tmp/keytone" /* Keytone pipe path */ #define FILE_FULL_PATH 1024 /* File path lenth */ + typedef struct { - char filename[1024]; - int vol_type; -}ipc_t; + char filename[FILE_FULL_PATH]; + int volume_config; +} ipc_t; EXPORT_API -int mm_sound_play_keysound(const char *filename, const volume_type_t vol_type) +int mm_sound_play_keysound(const char *filename, int volume_config) { int err = MM_ERROR_NONE; int fd = -1; int size = 0; ipc_t data = {{0,},}; + int capture_status = 0; - debug_fenter(); - - if(!filename) + if (!filename) return MM_ERROR_SOUND_INVALID_FILE; + /* Check whether audio is recording */ + vconf_get_int(VCONFKEY_RECORDER_STATE, &capture_status); + if(capture_status == VCONFKEY_RECORDER_STATE_RECORDING) { + debug_warning ("MUTE keysound during sound capture!!!, capture status=%d", capture_status); + return MM_ERROR_NONE; + } + /* Check whether file exists */ fd = open(filename, O_RDONLY); - if(fd == -1) { + if (fd == -1) { debug_error("file open failed with [%s][%d]\n", strerror(errno), errno); - switch(errno) - { + switch (errno) { case ENOENT: return MM_ERROR_SOUND_FILE_NOT_FOUND; default: @@ -78,22 +87,22 @@ int mm_sound_play_keysound(const char *filename, const volume_type_t vol_type) debug_error("Fail to open pipe\n"); return MM_ERROR_SOUND_FILE_NOT_FOUND; } - data.vol_type = vol_type; - strncpy(data.filename, filename, FILE_FULL_PATH); - debug_msg("The file name [%s]\n", data.filename); + data.volume_config = volume_config; + MMSOUND_STRNCPY(data.filename, filename, FILE_FULL_PATH); + + debug_msg("filepath=[%s], volume_config=[0x%x]\n", data.filename, volume_config); size = sizeof(ipc_t); /* Write to PIPE */ err = write(fd, &data, size); - if(err < 0) { - debug_error("Fail to write data: %s\n", strerror(err)); + if (err < 0) { + debug_error("Fail to write data: [%s][%d]\n", strerror(errno), errno); close(fd); return MM_ERROR_SOUND_INTERNAL; } /* Close PIPE */ close(fd); - debug_fleave(); return MM_ERROR_NONE; } diff --git a/mm_sound_pa_client.c b/mm_sound_pa_client.c new file mode 100644 index 0000000..6ca05ef --- /dev/null +++ b/mm_sound_pa_client.c @@ -0,0 +1,1048 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * 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 +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "include/mm_sound.h" +#include "include/mm_sound_private.h" +#include "include/mm_sound_utils.h" +#include "include/mm_sound_common.h" + +#define MM_SOUND_CHANNEL_MIN 1 +#define MM_SOUND_CHANNEL_MAX 6 + +#define MEDIA_POLICY_AUTO "auto" +#define MEDIA_POLICY_PHONE "phone" +#define MEDIA_POLICY_ALL "all" +#define MEDIA_POLICY_VOIP "voip" +#define MEDIA_POLICY_MIRRORING "mirroring" +#define MEDIA_POLICY_HIGH_LATENCY "high-latency" + +typedef struct _mm_sound_handle_t { + uint32_t handle; + + int mode; + int policy; + int volume_type; + int gain_type; + int rate; + int channels; + pa_simple* s; + + int period; /* open api retrun value.*/ + + int stream_idx; + int source_type; +} mm_sound_handle_t; + +#define MM_SOUND_HANDLE_MAX 32 +static struct { + uint32_t handle_count; /* use amotic operations */ + GList* handles; + pthread_mutex_t lock; + + int state; + pa_threaded_mainloop *mainloop; + pa_context *context; +} mm_sound_handle_mgr; + +#define CHECK_HANDLE_RANGE(x) \ + do { \ + if(x == 0) { \ + debug_msg("invalid handle(%d)", x); \ + return MM_ERROR_INVALID_ARGUMENT; \ + } \ + } while(0); + +#define CHECK_VOLUME_TYPE_RANGE(x) \ + do { \ + if(x < VOLUME_TYPE_SYSTEM || x >= VOLUME_TYPE_MAX) { \ + debug_msg("invalid volume type(%d)", x); \ + return MM_ERROR_INVALID_ARGUMENT; \ + } \ + } while(0); + +#define ATOMIC_INC(l, x) \ + do { \ + pthread_mutex_lock(l); \ + x = x + 1; \ + if(x == 0) \ + x = x + 1; \ + pthread_mutex_unlock(l); \ + } while(0); + +// phandle(ret), GList, userdata, coimpare func +#define GET_HANDLE_DATA(p, l, u, func) \ + do { \ + GList* list = 0; \ + list = g_list_find_custom(l, u, func); \ + if(list != 0) \ + p = (mm_sound_handle_t*)list->data; \ + else \ + p = NULL; \ + } while(0); + + +#define CHECK_CONNECT_TO_PULSEAUDIO() __mm_sound_pa_connect_to_pa() + +// should be call after pa_ext function. +#define WAIT_PULSEAUDIO_OPERATION(x, y) \ + do { \ + while (pa_operation_get_state(y) == PA_OPERATION_RUNNING) { \ + debug_msg("waiting.................."); \ + pa_threaded_mainloop_wait(x.mainloop); \ + debug_msg("waiting DONE"); \ + } \ + } while(0); + +static const pa_tizen_volume_type_t mm_sound_volume_type_to_pa[VOLUME_TYPE_MAX] = { + [VOLUME_TYPE_SYSTEM] = PA_TIZEN_VOLUME_TYPE_SYSTEM, + [VOLUME_TYPE_NOTIFICATION] = PA_TIZEN_VOLUME_TYPE_NOTIFICATION, + [VOLUME_TYPE_ALARM] = PA_TIZEN_VOLUME_TYPE_ALARM, + [VOLUME_TYPE_RINGTONE] = PA_TIZEN_VOLUME_TYPE_RINGTONE, + [VOLUME_TYPE_MEDIA] = PA_TIZEN_VOLUME_TYPE_MEDIA, + [VOLUME_TYPE_CALL] = PA_TIZEN_VOLUME_TYPE_CALL, + [VOLUME_TYPE_VOIP] = PA_TIZEN_VOLUME_TYPE_VOIP, + [VOLUME_TYPE_VOICE] = PA_TIZEN_VOLUME_TYPE_VOICE, + [VOLUME_TYPE_FIXED] = PA_TIZEN_VOLUME_TYPE_FIXED, +// [VOLUME_TYPE_EXT_SYSTEM_JAVA] = PA_TIZEN_VOLUME_TYPE_EXT_JAVA, +}; + +#define PA_SIMPLE_FADE_INTERVAL_USEC 20000 + +#define PA_SIMPLE_SAMPLES_PER_PERIOD_DEFAULT 1536 /* frames */ +#define PA_SIMPLE_PERIODS_PER_BUFFER_FASTMODE 4 +#define PA_SIMPLE_PERIODS_PER_BUFFER_DEFAULT 6 +#define PA_SIMPLE_PERIODS_PER_BUFFER_VOIP 2 +#define PA_SIMPLE_PERIODS_PER_BUFFER_PLAYBACK 8 +#define PA_SIMPLE_PERIODS_PER_BUFFER_CAPTURE 12 +#define PA_SIMPLE_PERIODS_PER_BUFFER_VIDEO 10 + +#define PA_SIMPLE_PERIOD_TIME_FOR_ULOW_LATENCY_MSEC 20 +#define PA_SIMPLE_PERIOD_TIME_FOR_LOW_LATENCY_MSEC 25 +#define PA_SIMPLE_PERIOD_TIME_FOR_MID_LATENCY_MSEC 50 +#define PA_SIMPLE_PERIOD_TIME_FOR_HIGH_LATENCY_MSEC 75 +#define PA_SIMPLE_PERIOD_TIME_FOR_VERY_HIGH_LATENCY_MSEC 150 +#define PA_SIMPLE_PERIOD_TIME_FOR_VOIP_LATENCY_MSEC 20 + +#define IS_INPUT_HANDLE(x) \ + if( x == HANDLE_MODE_INPUT || x == HANDLE_MODE_INPUT_HIGH_LATENCY || \ + x == HANDLE_MODE_INPUT_LOW_LATENCY || x == HANDLE_MODE_INPUT_AP_CALL ) + +__attribute__ ((constructor)) void __mm_sound_pa_init(void) +{ + memset(&mm_sound_handle_mgr, 0, sizeof(mm_sound_handle_mgr)); + mm_sound_handle_mgr.state = FALSE; + + mm_sound_handle_mgr.handles = g_list_alloc(); + mm_sound_handle_mgr.handle_count = 1; + pthread_mutex_init(&mm_sound_handle_mgr.lock, NULL); +} + +__attribute__ ((destructor)) void __mm_sound_pa_deinit(void) +{ + g_list_free(mm_sound_handle_mgr.handles); + pthread_mutex_destroy(&mm_sound_handle_mgr.lock); + mm_sound_handle_mgr.handle_count = 0; + + if(mm_sound_handle_mgr.state) { + debug_msg("mainloop(%x), context(%x)", mm_sound_handle_mgr.mainloop, mm_sound_handle_mgr.context); + pa_threaded_mainloop_stop(mm_sound_handle_mgr.mainloop); + pa_context_disconnect(mm_sound_handle_mgr.context); + pa_context_unref(mm_sound_handle_mgr.context); + pa_threaded_mainloop_free(mm_sound_handle_mgr.mainloop); + } +} + +gint __mm_sound_handle_comparefunc(gconstpointer a, gconstpointer b) +{ + mm_sound_handle_t* phandle = (mm_sound_handle_t*)a; + int* handle = (int*)b; + + if(phandle == NULL) + return -1; + + if(phandle->handle == *handle) + return 0; + else + return -1; +} + +EXPORT_API +int mm_sound_pa_open(MMSoundHandleMode mode, mm_sound_handle_route_info *route_info, MMSoundHandlePriority priority, int volume_config, pa_sample_spec* ss, pa_channel_map* channel_map, int* size) +{ + pa_simple *s = NULL; + pa_channel_map maps; + pa_buffer_attr attr; + + int vol_conf_type, vol_conf_gain; + int prop_vol_type, prop_gain_type; + + int err = MM_ERROR_SOUND_INTERNAL; + int period_time = PA_SIMPLE_PERIOD_TIME_FOR_MID_LATENCY_MSEC; + int samples_per_period = PA_SIMPLE_SAMPLES_PER_PERIOD_DEFAULT; + int periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_DEFAULT; + + const char *prop_policy = NULL; + + unsigned long latency = 0; + int handle_mode = mode; + int handle_inout = HANDLE_DIRECTION_NONE; + int sample_size = 0; + pa_proplist *proplist = pa_proplist_new(); + + mm_sound_handle_t* handle = NULL; + MMSoundHandleRoutePolicy policy = HANDLE_ROUTE_POLICY_DEFAULT; + + if(route_info) { + policy = route_info->policy; + } + + if (ss->channels < MM_SOUND_CHANNEL_MIN || ss->channels > MM_SOUND_CHANNEL_MAX) { + err = MM_ERROR_INVALID_ARGUMENT; + goto fail; + } + + if(channel_map == NULL) { + pa_channel_map_init_auto(&maps, ss->channels, PA_CHANNEL_MAP_ALSA); + channel_map = &maps; + } + + switch(ss->format) { + case PA_SAMPLE_U8: + sample_size = 1 * ss->channels; + break; + case PA_SAMPLE_S16LE: + sample_size = 2 * ss->channels; + break; + default : + sample_size = 0; + debug_error("Invalid sample size (%d)", sample_size); + break; + } + + /* Set volume type of stream */ + vol_conf_type = volume_config & 0x000000FF; + prop_vol_type = mm_sound_volume_type_to_pa[vol_conf_type]; + pa_proplist_setf(proplist, PA_PROP_MEDIA_TIZEN_VOLUME_TYPE, "%d", prop_vol_type); + + /* Set gain type of stream */ + prop_gain_type = (volume_config >> 8) & 0x000000FF; + + pa_proplist_setf(proplist, PA_PROP_MEDIA_TIZEN_GAIN_TYPE, "%d", prop_gain_type); + + IS_INPUT_HANDLE(handle_mode) { + handle_inout = HANDLE_DIRECTION_IN; + + if (policy == HANDLE_ROUTE_POLICY_IN_MIRRORING) { + prop_policy = MEDIA_POLICY_MIRRORING; + } else if (policy == HANDLE_ROUTE_POLICY_IN_VOIP) { + prop_policy = MEDIA_POLICY_VOIP; + handle_mode = HANDLE_MODE_INPUT_AP_CALL; + } + } else { + handle_inout = HANDLE_DIRECTION_OUT; + + /* Set policy property*/ + if (policy == HANDLE_ROUTE_POLICY_OUT_HANDSET) { + prop_policy = MEDIA_POLICY_PHONE; + + } else if (policy == HANDLE_ROUTE_POLICY_OUT_ALL) { + prop_policy = MEDIA_POLICY_ALL; + } + } + + /* If not set any yet, set based on volume type */ + if (prop_policy == NULL) { + /* check stream type (vol type) */ + switch (vol_conf_type) + { + case VOLUME_TYPE_NOTIFICATION: + case VOLUME_TYPE_ALARM: + prop_policy = MEDIA_POLICY_ALL; + break; + + case VOLUME_TYPE_MEDIA: + /* Set High-Latency for Music stream */ + if (handle_mode == HANDLE_MODE_OUTPUT_CLOCK) { + latency = PA_SIMPLE_PERIOD_TIME_FOR_VERY_HIGH_LATENCY_MSEC; + prop_policy = MEDIA_POLICY_HIGH_LATENCY; + } else { + prop_policy = MEDIA_POLICY_AUTO; + } + break; + + case VOLUME_TYPE_CALL: + case VOLUME_TYPE_RINGTONE: + case VOLUME_TYPE_FIXED: /* Used for Emergency */ + prop_policy = MEDIA_POLICY_PHONE; + break; + + case VOLUME_TYPE_VOIP: + prop_policy = MEDIA_POLICY_VOIP; + + if(handle_inout == HANDLE_DIRECTION_OUT) + handle_mode = HANDLE_MODE_OUTPUT_AP_CALL; /* need to move to session */ + else + debug_error("VOLUME_TYPE_VOIP unknown handle_inout(%d)", handle_inout); + + break; + + default: + prop_policy = MEDIA_POLICY_AUTO; + break; + } + } + pa_proplist_sets(proplist, PA_PROP_MEDIA_POLICY, prop_policy); + + if (priority) { + debug_msg("Set HIGH priority [%d]", priority); + pa_proplist_sets(proplist, PA_PROP_MEDIA_ROLE, "solo"); + } + + memset(&attr, '\0', sizeof(attr)); + + switch (handle_mode) { + case HANDLE_MODE_INPUT: + period_time = PA_SIMPLE_PERIOD_TIME_FOR_MID_LATENCY_MSEC; + samples_per_period = (ss->rate * period_time) / 1000; + periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_DEFAULT; + attr.prebuf = 0; + attr.minreq = -1; + attr.tlength = -1; + attr.maxlength = -1; + attr.fragsize = samples_per_period * pa_sample_size(ss); + + s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_RECORD, NULL, "CAPTURE", ss, channel_map, &attr, proplist, &err); + break; + + case HANDLE_MODE_INPUT_LOW_LATENCY: + period_time = PA_SIMPLE_PERIOD_TIME_FOR_ULOW_LATENCY_MSEC; + samples_per_period = (ss->rate * period_time) / 1000; + periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_FASTMODE; + attr.prebuf = 0; + attr.minreq = -1; + attr.tlength = -1; + attr.maxlength = -1; + attr.fragsize = samples_per_period * pa_sample_size(ss); + + s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_RECORD, NULL, "LOW LATENCY CAPTURE", ss, channel_map, &attr, proplist, &err); + break; + + case HANDLE_MODE_INPUT_HIGH_LATENCY: + period_time = PA_SIMPLE_PERIOD_TIME_FOR_HIGH_LATENCY_MSEC; + samples_per_period = (ss->rate * period_time) / 1000; + periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_CAPTURE; + attr.prebuf = 0; + attr.minreq = -1; + attr.tlength = -1; + attr.maxlength = -1; + attr.fragsize = samples_per_period * pa_sample_size(ss); + + s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_RECORD, NULL, "HIGH LATENCY CAPTURE", ss, channel_map, &attr, proplist, &err); + break; + + case HANDLE_MODE_OUTPUT: + period_time = PA_SIMPLE_PERIOD_TIME_FOR_MID_LATENCY_MSEC; + samples_per_period = (ss->rate * period_time) / 1000; + periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_DEFAULT; + attr.prebuf = -1; + attr.minreq = -1; + attr.tlength = (ss->rate / 10) * pa_sample_size(ss) * ss->channels; + attr.maxlength = -1; + attr.fragsize = 0; + + s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_PLAYBACK, NULL, "PLAYBACK", ss, channel_map, &attr, proplist, &err); + break; + + case HANDLE_MODE_OUTPUT_LOW_LATENCY: + period_time = PA_SIMPLE_PERIOD_TIME_FOR_LOW_LATENCY_MSEC; + samples_per_period = (ss->rate * period_time) / 1000; + periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_FASTMODE; + attr.prebuf = (ss->rate / 100) * pa_sample_size(ss) * ss->channels; + attr.minreq = -1; + attr.tlength = (ss->rate / 10) * pa_sample_size(ss) * ss->channels; + attr.maxlength = -1; + attr.fragsize = 0; + debug_msg("rate(%d), samplesize(%d), ch(%d) format(%d)", ss->rate, pa_sample_size(ss), ss->channels, ss->format); + + debug_msg("prebuf(%d), minreq(%d), tlength(%d), maxlength(%d), fragsize(%d)", attr.prebuf, attr.minreq, attr.tlength, attr.maxlength, attr.fragsize); + + s = pa_simple_new_proplist(NULL,"MM_SOUND_PA_CLIENT", PA_STREAM_PLAYBACK, NULL, "LOW LATENCY PLAYBACK", ss, channel_map, &attr, proplist, &err); + break; + + case HANDLE_MODE_OUTPUT_CLOCK: + period_time = (!latency) ? PA_SIMPLE_PERIOD_TIME_FOR_HIGH_LATENCY_MSEC : latency; + samples_per_period = (ss->rate * period_time) / 1000; + periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_PLAYBACK; + attr.prebuf = -1; + attr.minreq = -1; + attr.tlength = (!latency) ? (uint32_t)-1 : periods_per_buffer * samples_per_period * pa_sample_size(ss); + attr.maxlength = -1; + attr.fragsize = 0; + + s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_PLAYBACK, NULL, "HIGH LATENCY PLAYBACK", ss, channel_map, &attr, proplist, &err); + break; + + case HANDLE_MODE_OUTPUT_VIDEO: /* low latency playback */ + period_time = PA_SIMPLE_PERIOD_TIME_FOR_LOW_LATENCY_MSEC; + samples_per_period = (ss->rate * period_time) / 1000; + periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_VIDEO; + attr.prebuf = 4*(samples_per_period * pa_sample_size(ss)); + attr.minreq = samples_per_period * pa_sample_size(ss); + attr.tlength = periods_per_buffer * samples_per_period * pa_sample_size(ss); + attr.maxlength = -1; + attr.fragsize = 0; + + s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_PLAYBACK, NULL, "LOW LATENCY PLAYBACK", ss, channel_map, &attr, proplist, &err); + break; + + case HANDLE_MODE_OUTPUT_AP_CALL: +#if defined(_MMFW_I386_ALL_SIMULATOR) + debug_msg("Does not support AP call mode at i386 simulator\n"); + s = NULL; +#else + period_time = PA_SIMPLE_PERIOD_TIME_FOR_VOIP_LATENCY_MSEC; + samples_per_period = (ss->rate * period_time) / 1000; + periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_VOIP; + attr.prebuf = -1; + attr.minreq = pa_usec_to_bytes(20*PA_USEC_PER_MSEC, ss); + attr.tlength = pa_usec_to_bytes(100*PA_USEC_PER_MSEC, ss); + attr.maxlength = -1; + attr.fragsize = 0; + + s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_PLAYBACK, NULL, "VoIP PLAYBACK", ss, channel_map, &attr, proplist, &err); +#endif + break; + case HANDLE_MODE_INPUT_AP_CALL: +#if defined(_MMFW_I386_ALL_SIMULATOR) + debug_msg("Does not support AP call mode at i386 simulator\n"); + s = NULL; +#else + period_time = PA_SIMPLE_PERIOD_TIME_FOR_VOIP_LATENCY_MSEC; + samples_per_period = (ss->rate * period_time) / 1000; + periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_VOIP; + attr.prebuf = 0; + attr.minreq = -1; + attr.tlength = -1; + attr.maxlength = -1; + attr.fragsize = samples_per_period * pa_sample_size(ss); + + s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_RECORD, NULL, "VoIP CAPTURE", ss, channel_map, &attr, proplist, &err); +#endif + break; + case HANDLE_MODE_CALL_OUT: + case HANDLE_MODE_CALL_IN: + debug_error("Does not support call device handling\n"); + assert(0); + break; + default: + err = MM_ERROR_SOUND_INTERNAL; + goto fail; + assert(0); + break; + } + + if (!s) { + debug_error("Open pulseaudio handle has failed - %s\n", pa_strerror(err)); + if (err == PA_ERR_ACCESS_BY_SECURITY) { + err = MM_ERROR_SOUND_PERMISSION_DENIED; + } else { + err = MM_ERROR_SOUND_INTERNAL; + } + goto fail; + } + + if((handle = (mm_sound_handle_t*)malloc(sizeof(mm_sound_handle_t))) == NULL) { + debug_error("Allocate memory for handle failed\n"); + err = MM_ERROR_OUT_OF_MEMORY; + goto fail; + } + + handle->mode = mode; + handle->policy = policy; + handle->volume_type = prop_vol_type; + handle->gain_type = prop_gain_type; + handle->rate = ss->rate; + handle->channels = ss->channels; + handle->s = s; + handle->period = samples_per_period * sample_size; + *size = handle->period; + handle->handle = mm_sound_handle_mgr.handle_count; + ATOMIC_INC(&mm_sound_handle_mgr.lock, mm_sound_handle_mgr.handle_count); // 0 is not used + + if (0 > pa_simple_get_stream_index(s, &handle->stream_idx, &err)) { + debug_msg("Can not get stream index %s\n", pa_strerror(err)); + err = MM_ERROR_SOUND_INTERNAL; + goto fail; + } + mm_sound_handle_mgr.handles = g_list_append(mm_sound_handle_mgr.handles, handle); + + if(handle->handle == 0) { + debug_msg("out of range. handle(%d)\n", handle->handle); + goto fail; + } + + mm_sound_pa_set_mute(handle->handle, prop_vol_type, handle_inout, 0); + + debug_msg("created handle[%d]. mode(%d), policy(%d), volumetype(%d), gain(%d), rate(%d), channels(%d), format(%d), stream_idx(%d), s(%x), source_type(%d) handle_inout(%d)", + handle->handle, handle->mode, handle->policy, handle->volume_type, handle->gain_type, + handle->rate, handle->channels, ss->format, handle->stream_idx, handle->s, handle->source_type, handle_inout); + + return handle->handle; + +fail: + if (proplist) + pa_proplist_free(proplist); + + if(handle) + free(handle); + + return err; + +} + +EXPORT_API +int mm_sound_pa_read(const int handle, void* buf, const int size) +{ + mm_sound_handle_t* phandle = NULL; + int err = MM_ERROR_NONE; + +#ifdef __STREAM_DEBUG__ + debug_msg("handle(%d), buf(%p), size(%d)", handle, buf, size); +#endif + if (buf == NULL) + return MM_ERROR_INVALID_ARGUMENT; + + if (size < 0) + return MM_ERROR_INVALID_ARGUMENT; + else if (size == 0) + return size; + + CHECK_HANDLE_RANGE(handle); + GET_HANDLE_DATA(phandle, mm_sound_handle_mgr.handles, &handle, __mm_sound_handle_comparefunc); + if(phandle == NULL) { + debug_msg("phandle is null"); + return MM_ERROR_SOUND_INTERNAL; + } + + if (0 > pa_simple_read(phandle->s, buf, size, &err)) { + debug_error("pa_simple_read() failed with %s", pa_strerror(err)); + return MM_ERROR_SOUND_INTERNAL; + } + + return size; +} + +EXPORT_API +int mm_sound_pa_write(const int handle, void* buf, const int size) +{ + mm_sound_handle_t* phandle = NULL; + int err = MM_ERROR_NONE; + + if (buf == NULL) + return MM_ERROR_INVALID_ARGUMENT; + + if (size < 0) + return MM_ERROR_INVALID_ARGUMENT; + else if (size == 0) + return MM_ERROR_NONE; + + CHECK_HANDLE_RANGE(handle); + GET_HANDLE_DATA(phandle, mm_sound_handle_mgr.handles, &handle, __mm_sound_handle_comparefunc); + +#ifdef __STREAM_DEBUG__ + debug_msg("phandle(%x) s(%x), handle(%d), rate(%d), ch(%d) stream_idx(%d), buf(%p), size(%d)", + phandle, phandle->s, phandle->handle, phandle->rate, phandle->channels, phandle->stream_idx. buf, size); +#endif + + if(phandle == NULL) { + debug_msg("phandle is null"); + return MM_ERROR_SOUND_INTERNAL; + } + + if (0 > pa_simple_write(phandle->s, buf, size, &err)) { + debug_error("pa_simple_write() failed with %s\n", pa_strerror(err)); + return MM_ERROR_SOUND_INTERNAL; + } + + return size; + +} + +EXPORT_API +int mm_sound_pa_close(const int handle) +{ + mm_sound_handle_t* phandle = NULL; + int err = MM_ERROR_NONE; + + CHECK_HANDLE_RANGE(handle); + GET_HANDLE_DATA(phandle, mm_sound_handle_mgr.handles, &handle, __mm_sound_handle_comparefunc); + if(phandle == NULL) { + debug_msg("phandle is null"); + return MM_ERROR_SOUND_INTERNAL; + } + + debug_msg("phandle(%x) s(%x), handle(%d), rate(%d), ch(%d) stream_idx(%d)", + phandle, phandle->s, phandle->handle, phandle->rate, phandle->channels, phandle->stream_idx); + + switch (phandle->mode) { + case HANDLE_MODE_OUTPUT: + case HANDLE_MODE_OUTPUT_CLOCK: + case HANDLE_MODE_OUTPUT_LOW_LATENCY: + case HANDLE_MODE_OUTPUT_AP_CALL: + case HANDLE_MODE_OUTPUT_VIDEO: + if (0 > pa_simple_flush(phandle->s, &err)) { + err = MM_ERROR_SOUND_INTERNAL; + debug_msg("pa_simple_flush() failed with %s\n", pa_strerror(err)); + } + break; + default: + break; + } + + pa_simple_free(phandle->s); + phandle->s = NULL; + + debug_msg("leave: handle[%d] stream_index[%d]\n", handle, phandle->stream_idx); + + g_list_remove(mm_sound_handle_mgr.handles, phandle); + if(phandle != NULL) { + free(phandle); + phandle = NULL; + } + + return err; + +} + +EXPORT_API +int mm_sound_pa_cork(const int handle, const int cork) +{ + mm_sound_handle_t* phandle = NULL; + int err = MM_ERROR_NONE; + + CHECK_HANDLE_RANGE(handle); + GET_HANDLE_DATA(phandle, mm_sound_handle_mgr.handles, &handle, __mm_sound_handle_comparefunc); + if(phandle == NULL) { + debug_msg("phandle is null"); + return MM_ERROR_SOUND_INTERNAL; + } + + if (0 > pa_simple_cork(phandle->s, cork, &err)) { + debug_error("pa_simple_cork() failed with %s\n", pa_strerror(err)); + err = MM_ERROR_SOUND_INTERNAL; + } + + return err; +} + +EXPORT_API +int mm_sound_pa_drain(const int handle) +{ + mm_sound_handle_t* phandle = NULL; + int err = MM_ERROR_NONE; + + CHECK_HANDLE_RANGE(handle); + GET_HANDLE_DATA(phandle, mm_sound_handle_mgr.handles, &handle, __mm_sound_handle_comparefunc); + if(phandle == NULL) + return MM_ERROR_SOUND_INTERNAL; + + if (0 > pa_simple_drain(phandle->s, &err)) { + debug_error("pa_simple_drain() failed with %s\n", pa_strerror(err)); + err = MM_ERROR_SOUND_INTERNAL; + } + + return err; +} + +EXPORT_API +int mm_sound_pa_get_latency(const int handle, int* latency) +{ + mm_sound_handle_t* phandle = NULL; + int err = MM_ERROR_NONE; + pa_usec_t latency_time = 0; + + CHECK_HANDLE_RANGE(handle); + GET_HANDLE_DATA(phandle, mm_sound_handle_mgr.handles, &handle, __mm_sound_handle_comparefunc); + if(phandle == NULL) { + debug_msg("phandle is null"); + return MM_ERROR_SOUND_INTERNAL; + } + + latency_time = pa_simple_get_final_latency(phandle->s, &err); + if (err > 0 && latency_time == 0) { + debug_error("pa_simple_get_latency() failed with %s\n", pa_strerror(err)); + err = MM_ERROR_SOUND_INTERNAL; + } + *latency = latency_time / 1000; // usec to msec + + return err; +} + +static void __mm_sound_pa_state_cb(pa_context *c, void *userdata) +{ + pa_threaded_mainloop *mainloop = userdata; + + switch (pa_context_get_state(c)) { + case PA_CONTEXT_READY: + pa_threaded_mainloop_signal(mainloop, 0); + break; + case PA_CONTEXT_TERMINATED: + case PA_CONTEXT_FAILED: + pa_threaded_mainloop_signal(mainloop, 0); + break; + + case PA_CONTEXT_UNCONNECTED: + case PA_CONTEXT_CONNECTING: + case PA_CONTEXT_AUTHORIZING: + case PA_CONTEXT_SETTING_NAME: + break; + } +} + +static void __mm_sound_pa_connect_to_pa() +{ + if(mm_sound_handle_mgr.state) + return; + + if (!(mm_sound_handle_mgr.mainloop = pa_threaded_mainloop_new())) { + debug_error("mainloop create failed"); + } + + if (!(mm_sound_handle_mgr.context = pa_context_new(pa_threaded_mainloop_get_api(mm_sound_handle_mgr.mainloop), NULL))) { + debug_error("context create failed"); + } + + pa_threaded_mainloop_lock(mm_sound_handle_mgr.mainloop); + pa_context_set_state_callback(mm_sound_handle_mgr.context, __mm_sound_pa_state_cb, (void *)mm_sound_handle_mgr.mainloop); + + if(pa_threaded_mainloop_start(mm_sound_handle_mgr.mainloop) < 0) { + debug_error("mainloop start failed"); + } + + if (pa_context_connect(mm_sound_handle_mgr.context, NULL, 0, NULL) < 0) { + debug_error("context connect failed"); + } + + while (TRUE) { + pa_context_state_t state = pa_context_get_state(mm_sound_handle_mgr.context); + + if (!PA_CONTEXT_IS_GOOD (state)) { + break; + } + + if (state == PA_CONTEXT_READY) { + break; + } + + debug_msg("waiting.................."); + pa_threaded_mainloop_wait(mm_sound_handle_mgr.mainloop); + debug_msg("waiting DONE. check again..."); + } + + mm_sound_handle_mgr.state = TRUE; + + pa_threaded_mainloop_unlock(mm_sound_handle_mgr.mainloop); + +} + +static void __mm_sound_pa_success_cb(pa_context *c, int success, void *userdata) +{ + pa_threaded_mainloop *mainloop = (pa_threaded_mainloop *)userdata; + + if (!success) { + debug_error("pa control failed: %s\n", pa_strerror(pa_context_errno(c))); + } else { + debug_msg("pa control success\n"); + } + pa_threaded_mainloop_signal(mainloop, 0); +} + +EXPORT_API +int mm_sound_pa_set_volume_by_type(const int type, const int value) +{ + pa_operation *o = NULL; + + CHECK_VOLUME_TYPE_RANGE(type); + CHECK_CONNECT_TO_PULSEAUDIO(); + + pa_threaded_mainloop_lock(mm_sound_handle_mgr.mainloop); + + o = pa_ext_policy_set_volume_level(mm_sound_handle_mgr.context, -1, type, value, __mm_sound_pa_success_cb, (void*)mm_sound_handle_mgr.mainloop); + WAIT_PULSEAUDIO_OPERATION(mm_sound_handle_mgr, o); + + if(o) + pa_operation_unref(o); + + pa_threaded_mainloop_unlock(mm_sound_handle_mgr.mainloop); + + return MM_ERROR_NONE; +} + +EXPORT_API +int mm_sound_pa_set_call_mute(const int type, const int mute, int direction) +{ + pa_operation *o = NULL; + + CHECK_VOLUME_TYPE_RANGE(type); + CHECK_CONNECT_TO_PULSEAUDIO(); + + pa_threaded_mainloop_lock(mm_sound_handle_mgr.mainloop); + + o = pa_ext_policy_set_mute(mm_sound_handle_mgr.context, -1, type, direction, mute, __mm_sound_pa_success_cb, (void *)mm_sound_handle_mgr.mainloop); + WAIT_PULSEAUDIO_OPERATION(mm_sound_handle_mgr, o); + + if(o) + pa_operation_unref(o); + + pa_threaded_mainloop_unlock(mm_sound_handle_mgr.mainloop); + + return MM_ERROR_NONE; +} + +typedef struct _get_volume_max_userdata_t +{ + pa_threaded_mainloop* mainloop; + int value; +} get_volume_max_userdata_t; + +static void __mm_sound_pa_get_cb(pa_context *c, uint32_t value, void *userdata) +{ + get_volume_max_userdata_t* u = (get_volume_max_userdata_t*)userdata; + + assert(c); + assert(u); + + u->value = value; + + pa_threaded_mainloop_signal(u->mainloop, 0); +} + + +EXPORT_API +int mm_sound_pa_get_volume_max(const int type, int* step) +{ + get_volume_max_userdata_t userdata; + pa_operation *o = NULL; + + CHECK_VOLUME_TYPE_RANGE(type); + CHECK_CONNECT_TO_PULSEAUDIO(); + + pa_threaded_mainloop_lock(mm_sound_handle_mgr.mainloop); + + userdata.mainloop = mm_sound_handle_mgr.mainloop; + userdata.value = -1; + + o = pa_ext_policy_get_volume_level_max(mm_sound_handle_mgr.context, type, __mm_sound_pa_get_cb, (void *)&userdata); + WAIT_PULSEAUDIO_OPERATION(mm_sound_handle_mgr, o); + + if(userdata.value < 0) { + debug_error("pa_ext_policy_get_volume_level_max() failed, userdata.value(%d)", userdata.value); + *step = -1; + pa_threaded_mainloop_unlock(mm_sound_handle_mgr.mainloop); + return MM_ERROR_SOUND_INTERNAL; + } else + pa_operation_unref(o); + + *step = userdata.value; + + pa_threaded_mainloop_unlock(mm_sound_handle_mgr.mainloop); + + return MM_ERROR_NONE; +} + +EXPORT_API +int mm_sound_pa_get_volume_level(int handle, const int type, int* level) +{ + mm_sound_handle_t* phandle = NULL; + get_volume_max_userdata_t userdata; + pa_operation *o = NULL; + + CHECK_HANDLE_RANGE(handle); + CHECK_VOLUME_TYPE_RANGE(type); + CHECK_CONNECT_TO_PULSEAUDIO(); + + GET_HANDLE_DATA(phandle, mm_sound_handle_mgr.handles, &handle, __mm_sound_handle_comparefunc); + if(phandle == NULL) { + debug_msg("phandle is null"); + return MM_ERROR_SOUND_INTERNAL; + } + + pa_threaded_mainloop_lock(mm_sound_handle_mgr.mainloop); + + userdata.mainloop = mm_sound_handle_mgr.mainloop; + userdata.value = -1; + + o = pa_ext_policy_get_volume_level(mm_sound_handle_mgr.context, phandle->stream_idx, type, __mm_sound_pa_get_cb, (void *)&userdata); + WAIT_PULSEAUDIO_OPERATION(mm_sound_handle_mgr, o); + + if(userdata.value < 0) { + debug_error("pa_ext_policy_get_volume_level() failed"); + *level = -1; + pa_threaded_mainloop_unlock(mm_sound_handle_mgr.mainloop); + return MM_ERROR_SOUND_INTERNAL; + } else + pa_operation_unref(o); + + + *level = userdata.value; + + pa_threaded_mainloop_unlock(mm_sound_handle_mgr.mainloop); + + return MM_ERROR_NONE; +} + +EXPORT_API +int mm_sound_pa_set_volume_level(int handle, const int type, int level) +{ + mm_sound_handle_t* phandle = NULL; + pa_operation *o = NULL; + + CHECK_HANDLE_RANGE(handle); + CHECK_VOLUME_TYPE_RANGE(type); + CHECK_CONNECT_TO_PULSEAUDIO(); + + GET_HANDLE_DATA(phandle, mm_sound_handle_mgr.handles, &handle, __mm_sound_handle_comparefunc); + if(phandle == NULL) { + debug_msg("phandle is null"); + return MM_ERROR_SOUND_INTERNAL; + } + + pa_threaded_mainloop_lock(mm_sound_handle_mgr.mainloop); + + o = pa_ext_policy_set_volume_level(mm_sound_handle_mgr.context, phandle->stream_idx, type, level, __mm_sound_pa_success_cb, (void *)mm_sound_handle_mgr.mainloop); + WAIT_PULSEAUDIO_OPERATION(mm_sound_handle_mgr, o); + + if(o) + pa_operation_unref(o); + + pa_threaded_mainloop_unlock(mm_sound_handle_mgr.mainloop); + + return MM_ERROR_NONE; +} + +EXPORT_API +int mm_sound_pa_get_mute(int handle, const int type, int direction, int* mute) +{ + mm_sound_handle_t* phandle = NULL; + get_volume_max_userdata_t userdata; + pa_operation *o = NULL; + + CHECK_HANDLE_RANGE(handle); + CHECK_VOLUME_TYPE_RANGE(type); + CHECK_CONNECT_TO_PULSEAUDIO(); + + GET_HANDLE_DATA(phandle, mm_sound_handle_mgr.handles, &handle, __mm_sound_handle_comparefunc); + if(phandle == NULL) { + debug_msg("phandle is null"); + return MM_ERROR_SOUND_INTERNAL; + } + + pa_threaded_mainloop_lock(mm_sound_handle_mgr.mainloop); + + userdata.mainloop = mm_sound_handle_mgr.mainloop; + userdata.value = -1; + + o = pa_ext_policy_get_mute(mm_sound_handle_mgr.context, phandle->stream_idx, type, direction, __mm_sound_pa_get_cb, (void *)&userdata); + WAIT_PULSEAUDIO_OPERATION(mm_sound_handle_mgr, o); + + if(userdata.value < 0) { + debug_error("mm_sound_pa_get_mute() failed"); + *mute = -1; + pa_threaded_mainloop_unlock(mm_sound_handle_mgr.mainloop); + return MM_ERROR_SOUND_INTERNAL; + } else + pa_operation_unref(o); + + pa_threaded_mainloop_unlock(mm_sound_handle_mgr.mainloop); + + return MM_ERROR_NONE; +} + +EXPORT_API +int mm_sound_pa_set_mute(int handle, const int type, int direction, int mute) +{ + mm_sound_handle_t* phandle = NULL; + pa_operation *o = NULL; + + CHECK_HANDLE_RANGE(handle); + CHECK_VOLUME_TYPE_RANGE(type); + CHECK_CONNECT_TO_PULSEAUDIO(); + + GET_HANDLE_DATA(phandle, mm_sound_handle_mgr.handles, &handle, __mm_sound_handle_comparefunc); + if(phandle == NULL) { + debug_msg("phandle is null"); + return MM_ERROR_SOUND_INTERNAL; + } + + pa_threaded_mainloop_lock(mm_sound_handle_mgr.mainloop); + + o = pa_ext_policy_set_mute(mm_sound_handle_mgr.context, phandle->stream_idx, type, direction, mute, __mm_sound_pa_success_cb, (void *)mm_sound_handle_mgr.mainloop); + WAIT_PULSEAUDIO_OPERATION(mm_sound_handle_mgr, o); + + if(o) + pa_operation_unref(o); + + pa_threaded_mainloop_unlock(mm_sound_handle_mgr.mainloop); + + return MM_ERROR_NONE; +} + +EXPORT_API +int mm_sound_pa_corkall(int cork) +{ + pa_operation *o = NULL; + + CHECK_CONNECT_TO_PULSEAUDIO(); + + pa_threaded_mainloop_lock(mm_sound_handle_mgr.mainloop); + + o = pa_context_set_cork_all(mm_sound_handle_mgr.context, cork, __mm_sound_pa_success_cb, (void *)mm_sound_handle_mgr.mainloop); + WAIT_PULSEAUDIO_OPERATION(mm_sound_handle_mgr, o); + + if(o) + pa_operation_unref(o); + + pa_threaded_mainloop_unlock(mm_sound_handle_mgr.mainloop); + + return MM_ERROR_NONE; +} + diff --git a/mm_sound_pcm.c b/mm_sound_pcm.c new file mode 100644 index 0000000..8e11481 --- /dev/null +++ b/mm_sound_pcm.c @@ -0,0 +1,1249 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * 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 + +#include +#include + +#include +#include +#include +#include +#include "include/mm_sound_private.h" +#include "include/mm_sound.h" +#include "include/mm_sound_utils.h" +#include "include/mm_sound_common.h" +#include "include/mm_sound_pa_client.h" + +#include +#include +#include + + +#define _MIN_SYSTEM_SAMPLERATE 8000 +#define _MAX_SYSTEM_SAMPLERATE 48000 +#define RW_LOG_PERIOD 5 /* period(second) for print log in capture read or play write*/ + +#define PCM_LOCK_INTERNAL(LOCK) do { pthread_mutex_lock(LOCK); } while (0) +#define PCM_UNLOCK_INTERNAL(LOCK) do { pthread_mutex_unlock(LOCK); } while (0) +#define PCM_LOCK_DESTROY_INTERNAL(LOCK) do { pthread_mutex_destroy(LOCK); } while (0) + +int g_capture_h_count = 0; +#define PCM_CAPTURE_H_COUNT_INC() do { g_capture_h_count++; } while (0) +#define PCM_CAPTURE_H_COUNT_DEC() do { g_capture_h_count--; if(g_capture_h_count < 0) debug_error ("g_capture_h_count[%d] is not valid, check application side for proper handle usage\n", g_capture_h_count); } while (0) +#define PCM_CAPTURE_H_COUNT_GET(x_val) do { x_val = g_capture_h_count; } while (0) + +typedef enum { + MMSOUND_SESSION_TYPE_PLAYBACK, + MMSOUND_SESSION_TYPE_CAPTURE, +}MMSound_session_type_e; + +enum { + MMSOUND_SESSION_REGISTERED_INTERNALLY, + MMSOUND_SESSION_REGISTERED_BY_OUTSIDE_MEDIA, +}; + +typedef struct { + int handle; + int asm_handle; + ASM_sound_events_t asm_event; + int asm_options; + int session_registered_type; + + bool is_started; + bool is_playback; + bool skip_session; + ASM_resource_t resource; + pthread_mutex_t pcm_mutex_internal; + MMMessageCallback msg_cb; + void *msg_cb_param; + + unsigned int rate; + MMSoundPcmChannel_t channel; + MMSoundPcmFormat_t format; + unsigned int byte_per_sec; + + int volume_config; + +} mm_sound_pcm_t; + +static int _pcm_sound_start (MMSoundPcmHandle_t handle); +static int _pcm_sound_stop_internal (MMSoundPcmHandle_t handle); +static int _pcm_sound_stop(MMSoundPcmHandle_t handle); +static void __sound_pcm_send_message (mm_sound_pcm_t *pcmHandle, int message, int code); +static int _pcm_sound_ignore_session (MMSoundPcmHandle_t handle, MMSound_session_type_e type); + +static char* __get_channel_str(MMSoundPcmChannel_t channel) +{ + if (channel == MMSOUND_PCM_MONO) + return "Mono"; + else if (channel == MMSOUND_PCM_STEREO) + return "Stereo"; + else + return "Unknown"; +} + +static char* __get_format_str(MMSoundPcmFormat_t format) +{ + if (format == MMSOUND_PCM_S16_LE) + return "S16LE"; + else if (format == MMSOUND_PCM_U8) + return "U8"; + else + return "Unknown"; +} + +static int _get_asm_information(MMSound_session_type_e session_type, ASM_sound_events_t *type, int *options, int *session_registered_type) +{ + int cur_session = MM_SESSION_TYPE_MEDIA; + int session_options = 0; + int ret = MM_ERROR_NONE; + ASM_sound_events_t asm_event; + + if(type == NULL) + return MM_ERROR_SOUND_INVALID_POINTER; + + /* read session information */ + if(_mm_session_util_read_information(-1, &cur_session, &session_options) < 0) { + debug_log("Read Session Information failed. Set default \"Media\" type\n"); + if (session_type == MMSOUND_SESSION_TYPE_PLAYBACK) { + cur_session = MM_SESSION_TYPE_MEDIA; + } else if (session_type == MMSOUND_SESSION_TYPE_CAPTURE) { + cur_session = MM_SESSION_TYPE_MEDIA_RECORD; + } + ret = _mm_session_util_write_type(-1, cur_session); + if (ret) { + debug_error("_mm_session_util_write_type() failed\n"); + return MM_ERROR_SOUND_INTERNAL; + } + *session_registered_type = MMSOUND_SESSION_REGISTERED_INTERNALLY; + } else { + /* session was already registered */ + if (session_type == MMSOUND_SESSION_TYPE_CAPTURE) { + if (cur_session > MM_SESSION_TYPE_MEDIA && cur_session < MM_SESSION_TYPE_CALL) { + debug_error("current session type(%d) does not support capture\n", session_type); + return MM_ERROR_POLICY_BLOCKED; + } else if (cur_session == MM_SESSION_TYPE_MEDIA) { + debug_log("session was already registered to MEDIA, update it to MEDIA_RECORD"); + /* update session information */ + ret = _mm_session_util_write_information(-1, MM_SESSION_TYPE_MEDIA_RECORD, session_options); + if (ret) { + debug_error("_mm_session_util_write_type() failed\n"); + return MM_ERROR_SOUND_INTERNAL; + } + *session_registered_type = MMSOUND_SESSION_REGISTERED_BY_OUTSIDE_MEDIA; + } + } + } + + /* convert MM_SESSION_TYPE to ASM_EVENT_TYPE */ + switch (cur_session) + { + case MM_SESSION_TYPE_MEDIA: + case MM_SESSION_TYPE_MEDIA_RECORD: + asm_event = ASM_EVENT_MEDIA_MMSOUND; + break; + case MM_SESSION_TYPE_NOTIFY: + asm_event = ASM_EVENT_NOTIFY; + break; + case MM_SESSION_TYPE_ALARM: + asm_event = ASM_EVENT_ALARM; + break; + case MM_SESSION_TYPE_CALL: + asm_event = ASM_EVENT_CALL; + break; + case MM_SESSION_TYPE_VIDEOCALL: + asm_event = ASM_EVENT_VIDEOCALL; + break; + case MM_SESSION_TYPE_VOIP: + asm_event = ASM_EVENT_VOIP; + break; + case MM_SESSION_TYPE_EMERGENCY: + asm_event = ASM_EVENT_EMERGENCY; + break; + case MM_SESSION_TYPE_VOICE_RECOGNITION: + asm_event = ASM_EVENT_VOICE_RECOGNITION; + break; + case MM_SESSION_TYPE_RECORD_AUDIO: + asm_event = ASM_EVENT_MMCAMCORDER_AUDIO; + break; + case MM_SESSION_TYPE_RECORD_VIDEO: + asm_event = ASM_EVENT_MMCAMCORDER_VIDEO; + break; + default: + debug_error("Unexpected %d\n", cur_session); + return MM_ERROR_SOUND_INTERNAL; + } + + *type = asm_event; + *options = session_options; + return MM_ERROR_NONE; +} + +static bool _check_skip_session_type_for_capture(mm_sound_pcm_t *pcmHandle, mm_sound_source_type_e type) +{ + bool ret = false; + int session_result = MM_ERROR_NONE; + switch (type) + { + case SUPPORT_SOURCE_TYPE_DEFAULT: + case SUPPORT_SOURCE_TYPE_VOICECONTROL: + ret = false; + break; + case SUPPORT_SOURCE_TYPE_MIRRORING: + ret = true; + break; + default: + debug_error("Unexpected %d\n", type); + return false; + } + if (ret) { + int capture_h_count = 0; + PCM_CAPTURE_H_COUNT_GET(capture_h_count); + if (capture_h_count == 1) { /* if it is last one */ + /* Recover session information */ + session_result = _mm_session_util_write_information(-1, MM_SESSION_TYPE_MEDIA, pcmHandle->asm_options); + if (session_result) { + debug_error("_mm_session_util_write_information() [type %d, options %x] failed[%x]", MM_SESSION_TYPE_MEDIA, pcmHandle->asm_options, session_result); + } + } + } + return ret; +} + +static void __sound_pcm_send_message (mm_sound_pcm_t *pcmHandle, int message, int code) +{ + int ret = 0; + if (pcmHandle->msg_cb) { + MMMessageParamType msg; + msg.union_type = MM_MSG_UNION_CODE; + msg.code = code; + + debug_log ("calling msg callback(%p) with message(%d), code(%d), msg callback param(%p)\n", + pcmHandle->msg_cb, message, msg.code, pcmHandle->msg_cb_param); + ret = pcmHandle->msg_cb(message, &msg, pcmHandle->msg_cb_param); + debug_log ("msg callback returned (%d)\n", ret); + } else { + debug_log ("No pcm msg callback\n"); + } +} + +static ASM_cb_result_t sound_pcm_asm_callback(int handle, ASM_event_sources_t event_src, ASM_sound_commands_t command, unsigned int sound_status, void *cb_data) +{ + mm_sound_pcm_t *pcmHandle = (mm_sound_pcm_t *)cb_data; + ASM_cb_result_t cb_res = ASM_CB_RES_IGNORE; + int message = MM_MESSAGE_SOUND_PCM_INTERRUPTED; + + /* Check input param */ + if(pcmHandle == NULL) { + debug_error("sound_pcm_asm_callback cb_data is null\n"); + return cb_res; + } + + debug_log ("command = %d, handle = %p, is_started = %d\n",command, pcmHandle, pcmHandle->is_started); + switch(command) + { + case ASM_COMMAND_PAUSE: + case ASM_COMMAND_STOP: + /* Do stop */ + PCM_LOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + _pcm_sound_stop_internal (pcmHandle); + PCM_UNLOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + cb_res = ASM_CB_RES_PAUSE; + break; + + case ASM_COMMAND_RESUME: + cb_res = ASM_CB_RES_IGNORE; + message = MM_MESSAGE_READY_TO_RESUME; + break; + + case ASM_COMMAND_PLAY: + case ASM_COMMAND_NONE: + debug_error ("Not an expected case!!!!\n"); + break; + } + + /* execute user callback if callback available */ + __sound_pcm_send_message (pcmHandle, message, event_src); + + return cb_res; +} + +static int _pcm_sound_ignore_session (MMSoundPcmHandle_t handle, MMSound_session_type_e type) +{ + int result = MM_ERROR_NONE; + int session_result = MM_ERROR_NONE; + mm_sound_pcm_t *pcmHandle = (mm_sound_pcm_t*)handle; + int errorcode = 0; + + debug_fenter(); + + /* Check input param */ + if(pcmHandle == NULL) { + debug_error ("Handle is null, return Invalid Argument\n"); + result = MM_ERROR_INVALID_ARGUMENT; + goto EXIT; + } + + if (pcmHandle->is_started) { + debug_error ("Operation is not permitted while started\n"); + result = MM_ERROR_SOUND_INVALID_STATE; + goto EXIT; + } + + PCM_LOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + + /* Unregister ASM */ + if (pcmHandle->skip_session == false && pcmHandle->asm_handle) { + if(!ASM_unregister_sound(pcmHandle->asm_handle, pcmHandle->asm_event, &errorcode)) { + debug_error("ASM_unregister failed with 0x%x\n", errorcode); + result = MM_ERROR_SOUND_INTERNAL; + } + pcmHandle->skip_session = true; + pcmHandle->asm_handle = 0; + } + if (type == MMSOUND_SESSION_TYPE_CAPTURE){ + int capture_h_count = 0; + PCM_CAPTURE_H_COUNT_GET(capture_h_count); + if (capture_h_count == 1) { /* if it is last one */ + /* Recover session information */ + session_result = _mm_session_util_write_information(-1, MM_SESSION_TYPE_MEDIA, pcmHandle->asm_options); + if (session_result) { + debug_error("_mm_session_util_write_information() [type %d, options %x] failed[%x]", MM_SESSION_TYPE_MEDIA, pcmHandle->asm_options, session_result); + } + } + } + + PCM_UNLOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + +EXIT: + debug_fleave(); + return result; +} + +EXPORT_API +int mm_sound_pcm_capture_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format) +{ + mm_sound_pcm_t *pcmHandle = NULL; + int size = 0; + int result = MM_ERROR_NONE; + int errorcode = 0; + int ret_mutex = 0; + int ret = MM_ERROR_NONE; + + int volume_config = 0; + pa_sample_spec ss; + + mm_sound_handle_route_info route_info; + route_info.policy = HANDLE_ROUTE_POLICY_DEFAULT; + + debug_warning ("enter : rate=[%d], channel=[%x], format=[%x]\n", rate, channel, format); + + if (rate < _MIN_SYSTEM_SAMPLERATE || rate > _MAX_SYSTEM_SAMPLERATE) { + debug_error("unsupported sample rate %u", rate); + return MM_ERROR_SOUND_DEVICE_INVALID_SAMPLERATE; + } else { + ss.rate = rate; + } + + switch(channel) + { + case MMSOUND_PCM_MONO: + ss.channels = 1; + break; + case MMSOUND_PCM_STEREO: + ss.channels = 2; + break; + + default: + debug_error("Unsupported channel type\n"); + return MM_ERROR_SOUND_DEVICE_INVALID_CHANNEL; + } + + switch(format) + { + case MMSOUND_PCM_U8: + ss.format = PA_SAMPLE_U8; + break; + case MMSOUND_PCM_S16_LE: + ss.format = PA_SAMPLE_S16LE; + break; + default: + debug_error("Unsupported format type\n"); + return MM_ERROR_SOUND_DEVICE_INVALID_FORMAT; + } + + pcmHandle = calloc(sizeof(mm_sound_pcm_t), 1); + if(pcmHandle == NULL) + return MM_ERROR_OUT_OF_MEMORY; + + ret_mutex = pthread_mutex_init(&pcmHandle->pcm_mutex_internal, NULL); + if(ret_mutex != 0) + { + free(pcmHandle); + return MM_ERROR_OUT_OF_MEMORY; + } + + /* Register ASM */ + /* get session information */ + ret = _get_asm_information(MMSOUND_SESSION_TYPE_CAPTURE, &pcmHandle->asm_event, &pcmHandle->asm_options, &pcmHandle->session_registered_type); + if(ret) { + PCM_LOCK_DESTROY_INTERNAL(&pcmHandle->pcm_mutex_internal); + free(pcmHandle); + return ret; + } + PCM_CAPTURE_H_COUNT_INC(); + + /* register asm */ + if(pcmHandle->asm_event != ASM_EVENT_CALL && + pcmHandle->asm_event != ASM_EVENT_VIDEOCALL && + pcmHandle->asm_event != ASM_EVENT_VOIP && + pcmHandle->asm_event != ASM_EVENT_VOICE_RECOGNITION && + pcmHandle->asm_event != ASM_EVENT_MMCAMCORDER_AUDIO && + pcmHandle->asm_event != ASM_EVENT_MMCAMCORDER_VIDEO && + pcmHandle->skip_session == false) { + if(!ASM_register_sound(-1, &pcmHandle->asm_handle, pcmHandle->asm_event, + /* ASM_STATE_PLAYING */ ASM_STATE_NONE, sound_pcm_asm_callback, (void*)pcmHandle, pcmHandle->resource, &errorcode)) + { + debug_error("ASM_register_sound() failed 0x%x\n", errorcode); + PCM_LOCK_DESTROY_INTERNAL(&pcmHandle->pcm_mutex_internal); + free(pcmHandle); + PCM_CAPTURE_H_COUNT_DEC(); + return MM_ERROR_POLICY_BLOCKED; + } + if(!ASM_set_session_option(pcmHandle->asm_handle, pcmHandle->asm_options, &errorcode)) { + debug_error("ASM_set_session_option() failed 0x%x\n", errorcode); + } + } else { + pcmHandle->skip_session = true; + } + + /* Open */ + if(pcmHandle->asm_event == ASM_EVENT_VOIP) + volume_config = VOLUME_TYPE_VOIP; + else + volume_config = VOLUME_TYPE_SYSTEM; //dose not effect at capture mode + + pcmHandle->handle = mm_sound_pa_open(HANDLE_MODE_INPUT, &route_info, 0, volume_config, &ss, NULL, &size); + if(pcmHandle->handle<0) { + result = pcmHandle->handle; + debug_error("Device Open Error 0x%x\n", result); + PCM_LOCK_DESTROY_INTERNAL(&pcmHandle->pcm_mutex_internal); + free(pcmHandle); + PCM_CAPTURE_H_COUNT_DEC(); + return result; + } + + pcmHandle->is_playback = false; + pcmHandle->rate = rate; + pcmHandle->channel = channel; + pcmHandle->format = format; + pcmHandle->byte_per_sec = rate*(format==MMSOUND_PCM_U8?1:2)*(channel==MMSOUND_PCM_MONO?1:2); + + /* Set handle to return */ + *handle = (MMSoundPcmHandle_t)pcmHandle; + + debug_warning ("success : handle=[%p], size=[%d]\n", pcmHandle, size); + + return size; +} + +EXPORT_API +int mm_sound_pcm_capture_open_ex(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, mm_sound_source_type_e source_type) +{ + mm_sound_pcm_t *pcmHandle = NULL; + int size = 0; + int result = MM_ERROR_NONE; + int errorcode = 0; + int ret_mutex = 0; + + int volume_config = 0; + pa_sample_spec ss; + mm_sound_handle_route_info route_info; + route_info.policy = HANDLE_ROUTE_POLICY_DEFAULT; + + debug_warning ("enter : rate=[%d Hz], channel=[%x][%s], format=[%x][%s], source_type=[%x]\n", + rate, channel, __get_channel_str(channel), format, __get_format_str(format), source_type); + + if (rate < _MIN_SYSTEM_SAMPLERATE || rate > _MAX_SYSTEM_SAMPLERATE) { + debug_error("unsupported sample rate %u", rate); + return MM_ERROR_SOUND_DEVICE_INVALID_SAMPLERATE; + } else { + ss.rate = rate; + } + + switch(channel) + { + case MMSOUND_PCM_MONO: + ss.channels = 1; + break; + case MMSOUND_PCM_STEREO: + ss.channels = 2; + break; + + default: + debug_error("Unsupported channel type\n"); + return MM_ERROR_SOUND_DEVICE_INVALID_CHANNEL; + } + + switch(format) + { + case MMSOUND_PCM_U8: + ss.format = PA_SAMPLE_U8; + break; + case MMSOUND_PCM_S16_LE: + ss.format = PA_SAMPLE_S16LE; + break; + default: + debug_error("Unsupported format type\n"); + return MM_ERROR_SOUND_DEVICE_INVALID_FORMAT; + } + + pcmHandle = calloc(sizeof(mm_sound_pcm_t), 1); + if(pcmHandle == NULL) + return MM_ERROR_OUT_OF_MEMORY; + + ret_mutex = pthread_mutex_init(&pcmHandle->pcm_mutex_internal, NULL); + if(ret_mutex != 0) + { + free(pcmHandle); + return MM_ERROR_OUT_OF_MEMORY; + } + + /* Register ASM */ + /* get session information */ + if(MM_ERROR_NONE != _get_asm_information(MMSOUND_SESSION_TYPE_CAPTURE, &pcmHandle->asm_event, &pcmHandle->asm_options, &pcmHandle->session_registered_type)) { + PCM_LOCK_DESTROY_INTERNAL(&pcmHandle->pcm_mutex_internal); + free(pcmHandle); + return MM_ERROR_POLICY_INTERNAL; + } + PCM_CAPTURE_H_COUNT_INC(); + + switch (source_type) { + case SUPPORT_SOURCE_TYPE_VOIP: + route_info.policy = HANDLE_ROUTE_POLICY_IN_VOIP; + break; + case SUPPORT_SOURCE_TYPE_MIRRORING: + route_info.policy = HANDLE_ROUTE_POLICY_IN_MIRRORING; + break; + case SUPPORT_SOURCE_TYPE_DEFAULT: + case SUPPORT_SOURCE_TYPE_VIDEOCALL: + case SUPPORT_SOURCE_TYPE_VOICERECORDING: + break; + case SUPPORT_SOURCE_TYPE_VOICECONTROL: + pcmHandle->asm_event = ASM_EVENT_EXCLUSIVE_RESOURCE; + pcmHandle->resource = ASM_RESOURCE_VOICECONTROL; + break; + default: + break; + } + + /* register asm */ + if(pcmHandle->asm_event != ASM_EVENT_CALL && + pcmHandle->asm_event != ASM_EVENT_VIDEOCALL && + pcmHandle->asm_event != ASM_EVENT_VOIP && + pcmHandle->asm_event != ASM_EVENT_VOICE_RECOGNITION && + pcmHandle->asm_event != ASM_EVENT_MMCAMCORDER_AUDIO && + pcmHandle->asm_event != ASM_EVENT_MMCAMCORDER_VIDEO && + pcmHandle->skip_session == false && + _check_skip_session_type_for_capture(pcmHandle, source_type) == false) { + if(!ASM_register_sound(-1, &pcmHandle->asm_handle, pcmHandle->asm_event, + /* ASM_STATE_PLAYING */ ASM_STATE_NONE, sound_pcm_asm_callback, (void*)pcmHandle, pcmHandle->resource, &errorcode)) { + debug_error("ASM_register_sound() failed 0x%x\n", errorcode); + PCM_LOCK_DESTROY_INTERNAL(&pcmHandle->pcm_mutex_internal); + free(pcmHandle); + PCM_CAPTURE_H_COUNT_DEC(); + return MM_ERROR_POLICY_BLOCKED; + } + if(!ASM_set_session_option(pcmHandle->asm_handle, pcmHandle->asm_options, &errorcode)) { + debug_error("ASM_set_session_option() failed 0x%x\n", errorcode); + } + } else { + pcmHandle->skip_session = true; + } + + /* For Video Call or VoIP select volume type VOLUME_TYPE_VOIP for sink/source */ + if( (pcmHandle->asm_event == ASM_EVENT_VIDEOCALL) || (pcmHandle->asm_event == ASM_EVENT_VOIP) ) + volume_config = VOLUME_TYPE_VOIP; + else + volume_config = VOLUME_TYPE_SYSTEM; //dose not effect at capture mode + + pcmHandle->handle = mm_sound_pa_open(HANDLE_MODE_INPUT, &route_info, 0, volume_config, &ss, NULL, &size); + if(pcmHandle->handle<0) { + result = pcmHandle->handle; + debug_error("Device Open Error 0x%x\n", result); + PCM_LOCK_DESTROY_INTERNAL(&pcmHandle->pcm_mutex_internal); + free(pcmHandle); + PCM_CAPTURE_H_COUNT_DEC(); + return result; + } + + pcmHandle->is_playback = false; + pcmHandle->rate = rate; + pcmHandle->channel = channel; + pcmHandle->format = format; + pcmHandle->byte_per_sec = rate*(format==MMSOUND_PCM_U8?1:2)*(channel==MMSOUND_PCM_MONO?1:2); + + /* Set handle to return */ + *handle = (MMSoundPcmHandle_t)pcmHandle; + + debug_warning ("success : handle=[%p], size=[%d]\n", handle, size); + + return size; +} + +EXPORT_API +int mm_sound_pcm_capture_ignore_session(MMSoundPcmHandle_t *handle) +{ + return _pcm_sound_ignore_session(handle, MMSOUND_SESSION_TYPE_CAPTURE); +} + +static int _pcm_sound_start (MMSoundPcmHandle_t handle) +{ + mm_sound_pcm_t *pcmHandle = (mm_sound_pcm_t*)handle; + int errorcode = 0; + int ret = 0; + + debug_fenter(); + + /* Check input param */ + if(pcmHandle == NULL) { + debug_error ("Handle is null, return Invalid Argument\n"); + ret = MM_ERROR_INVALID_ARGUMENT; + goto NULL_HANDLE; + } + + PCM_LOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + + if (pcmHandle->skip_session == false) { + /* ASM set state to PLAYING */ + if (!ASM_set_sound_state(pcmHandle->asm_handle, pcmHandle->asm_event, ASM_STATE_PLAYING, pcmHandle->resource, &errorcode)) { + debug_error("ASM_set_sound_state(PLAYING) failed 0x%x\n", errorcode); + ret = MM_ERROR_POLICY_BLOCKED; + goto EXIT; + } + } + + /* Update State */ + pcmHandle->is_started = true; + + /* Un-Cork */ + mm_sound_pa_cork(pcmHandle->handle, 0); + +EXIT: + PCM_UNLOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + +NULL_HANDLE: + debug_fleave(); + return ret; +} + +EXPORT_API +int mm_sound_pcm_capture_start(MMSoundPcmHandle_t handle) +{ + int ret = MM_ERROR_NONE; + + debug_warning ("enter : handle=[%p]\n", handle); + + ret = _pcm_sound_start (handle); + if (ret != MM_ERROR_NONE) { + debug_error ("_pcm_sound_start() failed (%x)\n", ret); + goto EXIT; + } + +EXIT: + debug_warning ("leave : handle=[%p], ret=[0x%X]", handle, ret); + + return ret; +} + +static int _pcm_sound_stop_internal (MMSoundPcmHandle_t handle) +{ + mm_sound_pcm_t *pcmHandle = (mm_sound_pcm_t*)handle; + + /* Check input param */ + if(pcmHandle == NULL) + return MM_ERROR_INVALID_ARGUMENT; + + /* Check State */ + if (pcmHandle->is_started == false) { + debug_warning ("Can't stop because not started\n"); + return MM_ERROR_SOUND_INVALID_STATE; + } + + /* Drain if playback mode */ + if (pcmHandle->is_playback) { + if(MM_ERROR_NONE != mm_sound_pa_drain(pcmHandle->handle)) { + debug_error("drain failed\n"); + } + } + + /* Update State */ + pcmHandle->is_started = false; + + /* Cork */ + return mm_sound_pa_cork(pcmHandle->handle, 1); +} + +static int _pcm_sound_stop(MMSoundPcmHandle_t handle) +{ + mm_sound_pcm_t *pcmHandle = (mm_sound_pcm_t*)handle; + int errorcode = 0; + int ret = MM_ERROR_NONE; + + debug_fenter(); + + /* Check input param */ + if(pcmHandle == NULL) { + debug_error ("Handle is null, return Invalid Argument\n"); + ret = MM_ERROR_INVALID_ARGUMENT; + goto NULL_HANDLE; + } + + PCM_LOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + + /* Do stop procedure */ + ret = _pcm_sound_stop_internal(handle); + if (ret == MM_ERROR_NONE) { + /* Set ASM State to STOP */ + if (pcmHandle->skip_session == false) { + if (!ASM_set_sound_state(pcmHandle->asm_handle, pcmHandle->asm_event, ASM_STATE_STOP, pcmHandle->resource, &errorcode)) { + debug_error("ASM_set_sound_state(STOP) failed 0x%x\n", errorcode); + ret = MM_ERROR_POLICY_BLOCKED; + goto EXIT; + } + } + } + +EXIT: + PCM_UNLOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); +NULL_HANDLE: + debug_fleave(); + return ret; +} + +EXPORT_API +int mm_sound_pcm_capture_stop(MMSoundPcmHandle_t handle) +{ + int ret = 0; + + debug_warning ("enter : handle=[%p]\n", handle); + ret = _pcm_sound_stop(handle); + debug_warning ("leave : handle=[%p], ret=[0x%X]\n", handle, ret); + + return ret; +} + +EXPORT_API +int mm_sound_pcm_capture_read(MMSoundPcmHandle_t handle, void *buffer, const unsigned int length ) +{ + int ret = 0; + static int read_byte = 0; + mm_sound_pcm_t *pcmHandle = (mm_sound_pcm_t*)handle; + + /* Check input param */ + if(pcmHandle == NULL) { + debug_error ("Handle is null, return Invalid Argument\n"); + ret = MM_ERROR_INVALID_ARGUMENT; + goto NULL_HANDLE; + } + PCM_LOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + + if(buffer == NULL) { + debug_error("Invalid buffer pointer\n"); + ret = MM_ERROR_SOUND_INVALID_POINTER; + goto EXIT; + } + if(length == 0 ) { + debug_error ("length is 0, return 0\n"); + ret = 0; + goto EXIT; + } + + /* Check State : return fail if not started */ + if (!pcmHandle->is_started) { + /* not started, return fail */ + debug_error ("Not started yet, return Invalid State \n"); + ret = MM_ERROR_SOUND_INVALID_STATE; + goto EXIT; + } + + /* Read */ + ret = mm_sound_pa_read(pcmHandle->handle, buffer, length); + +EXIT: + PCM_UNLOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); +NULL_HANDLE: + read_byte += length; + + if(ret > 0 && read_byte>pcmHandle->byte_per_sec*RW_LOG_PERIOD){ + debug_log ("(%d)/read-once, (%d)/%dsec bytes read \n", length, read_byte, RW_LOG_PERIOD); + read_byte = 0; + } + return ret; +} + +EXPORT_API +int mm_sound_pcm_capture_close(MMSoundPcmHandle_t handle) +{ + int result = MM_ERROR_NONE; + mm_sound_pcm_t *pcmHandle = (mm_sound_pcm_t*)handle; + int errorcode = 0; + + debug_warning ("enter : handle=[%p]\n", handle); + + /* Check input param */ + if(pcmHandle == NULL) { + debug_error ("Handle is null, return Invalid Argument\n"); + result = MM_ERROR_INVALID_ARGUMENT; + goto NULL_HDL; + } + PCM_LOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + /* Close */ + if(MM_ERROR_NONE != mm_sound_pa_close(pcmHandle->handle)) { + debug_error("handle close failed 0x%X", result); + result = MM_ERROR_SOUND_INTERNAL; + goto EXIT; + } + + /* Unregister ASM */ + if (pcmHandle->skip_session == false) { + if(pcmHandle->asm_event != ASM_EVENT_CALL && + pcmHandle->asm_event != ASM_EVENT_VIDEOCALL && + pcmHandle->asm_event != ASM_EVENT_VOIP && + pcmHandle->asm_event != ASM_EVENT_VOICE_RECOGNITION && + pcmHandle->asm_event != ASM_EVENT_MMCAMCORDER_AUDIO && + pcmHandle->asm_event != ASM_EVENT_MMCAMCORDER_VIDEO) { + if (pcmHandle->asm_handle) { + if(!ASM_unregister_sound(pcmHandle->asm_handle, pcmHandle->asm_event, &errorcode)) { + debug_error("ASM_unregister failed with 0x%x\n", errorcode); + result = MM_ERROR_SOUND_INTERNAL; + goto EXIT; + } + } + } + int capture_h_count = 0; + PCM_CAPTURE_H_COUNT_GET(capture_h_count); + if (capture_h_count == 1) { /* if it is last one */ + /* Recover session information */ + result = _mm_session_util_write_information(-1, MM_SESSION_TYPE_MEDIA, pcmHandle->asm_options); + if (result) { + debug_error("_mm_session_util_write_information() [type %d, options %x] failed[%x]", MM_SESSION_TYPE_MEDIA, pcmHandle->asm_options, result); + } + } + } + +EXIT: + PCM_UNLOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); +NULL_HDL: + debug_warning ("leave : handle=[%p], ret=[0x%X]\n", handle, result); + /* Free handle */ + if (pcmHandle) { + PCM_LOCK_DESTROY_INTERNAL(&pcmHandle->pcm_mutex_internal); + free(pcmHandle); + pcmHandle = NULL; + } + PCM_CAPTURE_H_COUNT_DEC(); + + return result; +} + +EXPORT_API +int mm_sound_pcm_set_message_callback (MMSoundPcmHandle_t handle, MMMessageCallback callback, void *user_param) +{ + mm_sound_pcm_t *pcmHandle = (mm_sound_pcm_t*)handle; + + if(pcmHandle == NULL || callback == NULL) + return MM_ERROR_INVALID_ARGUMENT; + + pcmHandle->msg_cb = callback; + pcmHandle->msg_cb_param = user_param; + + debug_log ("set pcm message callback (%p,%p)\n", callback, user_param); + + return MM_ERROR_NONE; +} + +EXPORT_API +int mm_sound_pcm_play_open_ex (MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, int volume_config, ASM_sound_events_t asm_event) +{ + mm_sound_pcm_t *pcmHandle = NULL; + int size = 0; + int result = MM_ERROR_NONE; + int errorcode = 0; + int volume_type = MM_SOUND_VOLUME_CONFIG_TYPE(volume_config); + int ret_mutex = 0; + mm_sound_handle_route_info route_info; + route_info.policy = HANDLE_ROUTE_POLICY_OUT_AUTO; + + pa_sample_spec ss; + + debug_warning ("enter : rate=[%d], channel=[%x][%s], format=[%x][%s], volconf=[%d], event=[%d]\n", + rate, channel, __get_channel_str(channel), format, __get_format_str(format), volume_config, asm_event); + + /* Check input param */ + if (volume_type < 0 || volume_type >= VOLUME_TYPE_MAX) { + debug_error("Volume type is invalid %d\n", volume_type); + return MM_ERROR_INVALID_ARGUMENT; + } + if (rate < _MIN_SYSTEM_SAMPLERATE || rate > _MAX_SYSTEM_SAMPLERATE) { + debug_error("unsupported sample rate %u", rate); + return MM_ERROR_SOUND_DEVICE_INVALID_SAMPLERATE; + } else { + ss.rate = rate; + } + + switch(channel) + { + case MMSOUND_PCM_MONO: + ss.channels = 1; + break; + case MMSOUND_PCM_STEREO: + ss.channels = 2; + break; + default: + debug_error("Unsupported channel type\n"); + return MM_ERROR_SOUND_DEVICE_INVALID_CHANNEL; + } + + switch(format) + { + case MMSOUND_PCM_U8: + ss.format = PA_SAMPLE_U8; + break; + case MMSOUND_PCM_S16_LE: + ss.format = PA_SAMPLE_S16LE; + break; + default: + debug_error("Unsupported format type\n"); + return MM_ERROR_SOUND_DEVICE_INVALID_FORMAT; + } + + pcmHandle = calloc(sizeof(mm_sound_pcm_t),1); + if(pcmHandle == NULL) + return MM_ERROR_OUT_OF_MEMORY; + + ret_mutex = pthread_mutex_init(&pcmHandle->pcm_mutex_internal, NULL); + if(ret_mutex != 0) { + debug_error ("error mutex init....%d"); + result = MM_ERROR_OUT_OF_MEMORY; + goto ERROR; + } + + /* Register ASM */ + debug_log ("session start : input asm_event = %d-------------\n", asm_event); + if (asm_event == ASM_EVENT_MONITOR) { + debug_log ("Skip SESSION for event (%d)\n", asm_event); + pcmHandle->skip_session = true; + } else if (asm_event == ASM_EVENT_NONE) { + /* get session information */ + if(MM_ERROR_NONE != _get_asm_information(MMSOUND_SESSION_TYPE_PLAYBACK, &pcmHandle->asm_event, &pcmHandle->asm_options, &pcmHandle->session_registered_type)) { + debug_error ("_get_asm_information failed....\n"); + result = MM_ERROR_POLICY_INTERNAL; + goto ERROR; + } + + // should be fixed. call forwarding engine(voip) use call volume type. + if(volume_type == VOLUME_TYPE_CALL) { + pcmHandle->skip_session = true; + } + + if(pcmHandle->asm_event != ASM_EVENT_CALL && + pcmHandle->asm_event != ASM_EVENT_VIDEOCALL && + pcmHandle->asm_event != ASM_EVENT_VOIP && + pcmHandle->asm_event != ASM_EVENT_VOICE_RECOGNITION && + pcmHandle->asm_event != ASM_EVENT_MMCAMCORDER_AUDIO && + pcmHandle->asm_event != ASM_EVENT_MMCAMCORDER_VIDEO && + pcmHandle->skip_session == false) { + + /* register asm */ + if(!ASM_register_sound(-1, &pcmHandle->asm_handle, pcmHandle->asm_event, + ASM_STATE_NONE, sound_pcm_asm_callback, (void*)pcmHandle, pcmHandle->resource, &errorcode)) { + debug_error("ASM_register_sound() failed 0x%x\n", errorcode); + result = MM_ERROR_POLICY_BLOCKED; + goto ERROR; + } + if(!ASM_set_session_option(pcmHandle->asm_handle, pcmHandle->asm_options, &errorcode)) { + debug_error("ASM_set_session_option() failed 0x%x\n", errorcode); + } + } else { + pcmHandle->skip_session = true; + } + } else { + /* register asm using asm_event input */ + if(!ASM_register_sound(-1, &pcmHandle->asm_handle, asm_event, + ASM_STATE_NONE, NULL, (void*)pcmHandle, pcmHandle->resource, &errorcode)) { + debug_error("ASM_register_sound() failed 0x%x\n", errorcode); + result = MM_ERROR_POLICY_BLOCKED; + goto ERROR; + } + } + + + /* Open */ + pcmHandle->handle = mm_sound_pa_open(HANDLE_MODE_OUTPUT, &route_info, 0, volume_config, &ss, NULL, &size); + if(!pcmHandle->handle) { + debug_error("Device Open Error 0x%x\n"); + result = MM_ERROR_SOUND_DEVICE_NOT_OPENED; + goto ERROR; + } + + /* Set corked state, uncork will be done at prepare() + FIXME: we should consider audio_open() return with corked state */ + result = mm_sound_pa_cork(pcmHandle->handle, 1); + if(result) { + debug_error("Cork Error 0x%x\n", result); + result = MM_ERROR_SOUND_INTERNAL; + goto ERROR; + } + + pcmHandle->is_playback = true; + pcmHandle->rate = rate; + pcmHandle->channel = channel; + pcmHandle->format = format; + pcmHandle->byte_per_sec = rate*(format==MMSOUND_PCM_U8?1:2)*(channel==MMSOUND_PCM_MONO?1:2); + pcmHandle->volume_config = volume_config; + + /* Set handle to return */ + *handle = (MMSoundPcmHandle_t)pcmHandle; + + debug_warning ("success : handle=[%p], size=[%d]\n", pcmHandle, size); + return size; + +ERROR: + if (pcmHandle) { + if(ret_mutex == 0) { + PCM_LOCK_DESTROY_INTERNAL(&pcmHandle->pcm_mutex_internal); + } + free(pcmHandle); + } + return result; +} + +EXPORT_API +int mm_sound_pcm_play_open_no_session(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, int volume_config) +{ + return mm_sound_pcm_play_open_ex (handle, rate, channel, format, volume_config, ASM_EVENT_MONITOR); +} + +EXPORT_API +int mm_sound_pcm_play_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, int volume_config) +{ + return mm_sound_pcm_play_open_ex (handle, rate, channel, format, volume_config, ASM_EVENT_NONE); +} + +EXPORT_API +int mm_sound_pcm_play_start(MMSoundPcmHandle_t handle) +{ + int ret = 0; + + debug_warning ("enter : handle=[%p]\n", handle); + ret = _pcm_sound_start (handle); + debug_warning ("leave : handle=[%p], ret=[0x%X]\n", handle, ret); + + return ret; +} + +EXPORT_API +int mm_sound_pcm_play_stop(MMSoundPcmHandle_t handle) +{ + int ret = 0; + + debug_warning ("enter : handle=[%p]\n", handle); + ret = _pcm_sound_stop(handle); + debug_warning ("leave : handle=[%p], ret=[0x%X]\n", handle, ret); + + return ret; +} + +EXPORT_API +int mm_sound_pcm_play_write(MMSoundPcmHandle_t handle, void* ptr, unsigned int length_byte) +{ + int ret = 0; + static int written_byte = 0; + mm_sound_pcm_t *pcmHandle = (mm_sound_pcm_t*)handle; + int vr_state = 0; + + /* Check input param */ + if(pcmHandle == NULL) { + debug_error ("Handle is null, return Invalid Argument\n"); + ret = MM_ERROR_INVALID_ARGUMENT; + goto NULL_HANDLE; + } + + PCM_LOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + + if(ptr == NULL) { + debug_error("Invalid buffer pointer\n"); + ret = MM_ERROR_SOUND_INVALID_POINTER; + goto EXIT; + } + if(length_byte == 0 ) { + debug_error ("length is 0, return 0\n"); + ret = 0; + goto EXIT; + } + + /* Check State : return fail if not started */ + if (!pcmHandle->is_started) { + /* not started, return fail */ + debug_error ("Not started yet, return Invalid State \n"); + ret = MM_ERROR_SOUND_INVALID_STATE; + goto EXIT; + } + + /* check skip condition. + * if accessibility screen reader (VOICE type with NoSession), no need to check, always do write */ + if (!pcmHandle->skip_session || MM_SOUND_VOLUME_CONFIG_TYPE(pcmHandle->volume_config) != VOLUME_TYPE_VOICE) { + /* Check whether voicerecorder is running */ + vconf_get_int(VCONFKEY_RECORDER_STATE, &vr_state); + + if (vr_state == VCONFKEY_RECORDER_STATE_RECORDING) { + debug_log ("During VoiceRecording....MUTE!!!"); + goto EXIT; + } + } + + /* Write */ + ret = mm_sound_pa_write(pcmHandle->handle, ptr, length_byte); + + +EXIT: + PCM_UNLOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); +NULL_HANDLE: + written_byte += length_byte; + if(ret > 0 && written_byte>pcmHandle->byte_per_sec*RW_LOG_PERIOD){ + debug_log ("(%d)/write-once, (%d)/%dsec bytes written\n", length_byte, written_byte, RW_LOG_PERIOD); + written_byte = 0; + } + + return ret; +} + +EXPORT_API +int mm_sound_pcm_play_close(MMSoundPcmHandle_t handle) +{ + int result = MM_ERROR_NONE; + mm_sound_pcm_t *pcmHandle = (mm_sound_pcm_t*)handle; + int errorcode = 0; + + debug_warning ("enter : handle=[%p]\n", handle); + + /* Check input param */ + if(pcmHandle == NULL) { + debug_error ("Handle is null, return Invalid Argument\n"); + result = MM_ERROR_INVALID_ARGUMENT; + goto NULL_HANDLE; + } + PCM_LOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + /* Drain if needed */ + if (pcmHandle->is_started) { + /* stop() is not called before close(), drain is needed */ + if(MM_ERROR_NONE != mm_sound_pa_drain(pcmHandle->handle)) { + debug_error("drain failed\n"); + result = MM_ERROR_SOUND_INTERNAL; + goto EXIT; + } + } + pcmHandle->is_started = false; + /* Close */ + if(MM_ERROR_NONE != mm_sound_pa_close(pcmHandle->handle)) { + debug_error("handle close failed. handle(%d)", pcmHandle->handle); + result = MM_ERROR_SOUND_INTERNAL; + goto EXIT; + } + + if (pcmHandle->skip_session == false) { + /* Unregister ASM */ + if(pcmHandle->asm_event != ASM_EVENT_CALL && + pcmHandle->asm_event != ASM_EVENT_VIDEOCALL && + pcmHandle->asm_event != ASM_EVENT_VOIP && + pcmHandle->asm_event != ASM_EVENT_VOICE_RECOGNITION && + pcmHandle->asm_event != ASM_EVENT_MMCAMCORDER_AUDIO && + pcmHandle->asm_event != ASM_EVENT_MMCAMCORDER_VIDEO) { + if(!ASM_unregister_sound(pcmHandle->asm_handle, pcmHandle->asm_event, &errorcode)) { + debug_error("ASM_unregister failed with 0x%x\n", errorcode); + } + } + } + +EXIT: + PCM_UNLOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); +NULL_HANDLE: + debug_warning ("leave : handle=[%p], result[0x%X]\n", handle, result); + if (pcmHandle) { + /* Free handle */ + PCM_LOCK_DESTROY_INTERNAL(&pcmHandle->pcm_mutex_internal); + free(pcmHandle); + pcmHandle= NULL; + } + + return result; +} + +EXPORT_API +int mm_sound_pcm_play_ignore_session(MMSoundPcmHandle_t *handle) +{ + return _pcm_sound_ignore_session(handle, MMSOUND_SESSION_TYPE_PLAYBACK); +} + +EXPORT_API +int mm_sound_pcm_get_latency(MMSoundPcmHandle_t handle, int *latency) +{ + mm_sound_pcm_t *pcmHandle = (mm_sound_pcm_t*)handle; + int result = MM_ERROR_NONE; + int mlatency = 0; + + /* Check input param */ + if (latency == NULL) + return MM_ERROR_INVALID_ARGUMENT; + + if(MM_ERROR_NONE != mm_sound_pa_get_latency(pcmHandle->handle, &mlatency)) { + debug_error("Get Latency Error"); + return MM_ERROR_SOUND_DEVICE_NOT_OPENED; + } + + *latency = mlatency; + + return MM_ERROR_NONE; +} + +EXPORT_API +int mm_sound_pcm_is_started(MMSoundPcmHandle_t handle, bool *is_started) +{ + mm_sound_pcm_t *pcmHandle = (mm_sound_pcm_t*)handle; + + /* Check input param */ + if (is_started == NULL) + return MM_ERROR_INVALID_ARGUMENT; + + *is_started = pcmHandle->is_started; + + return MM_ERROR_NONE; +} diff --git a/mm_sound_pcm_async.c b/mm_sound_pcm_async.c new file mode 100644 index 0000000..def8897 --- /dev/null +++ b/mm_sound_pcm_async.c @@ -0,0 +1,1431 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * 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 + +#include +#include + +#include +#include +#include +#include +#include "include/mm_sound_private.h" +#include "include/mm_sound.h" +#include "include/mm_sound_utils.h" +#include "include/mm_sound_common.h" +#include "include/mm_sound_pcm_async.h" + + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + +#define _MIN_SYSTEM_SAMPLERATE 8000 +#define _MAX_SYSTEM_SAMPLERATE 48000 +#define RW_LOG_PERIOD 5 /* period(second) for print log in capture read or play write*/ + +#define PCM_LOCK_INTERNAL(LOCK) do { pthread_mutex_lock(LOCK); } while (0) +#define PCM_UNLOCK_INTERNAL(LOCK) do { pthread_mutex_unlock(LOCK); } while (0) +#define PCM_LOCK_DESTROY_INTERNAL(LOCK) do { pthread_mutex_destroy(LOCK); } while (0) + +#define MAINLOOP_LOCK(LOCK) do { pa_threaded_mainloop_lock(LOCK); debug_msg("MAINLOOP locked"); } while (0) +#define MAINLOOP_UNLOCK(LOCK) do { pa_threaded_mainloop_unlock(LOCK); debug_msg("MAINLOOP unlocked"); } while (0) + +typedef struct { + int asm_handle; + ASM_sound_events_t asm_event; + int asm_options; + + bool is_started; + bool is_playback; + bool skip_session; + ASM_resource_t resource; + pthread_mutex_t pcm_mutex_internal; + MMMessageCallback msg_cb; + void *msg_cb_param; + + unsigned int rate; + MMSoundPcmChannel_t channel; + MMSoundPcmFormat_t format; + unsigned int byte_per_sec; + + pa_threaded_mainloop *mainloop; + pa_context *context; + pa_stream* s; + + int operation_success; + +} mm_sound_pcm_async_t; + +static int _pcm_sound_start (MMSoundPcmHandle_t handle); +static int _pcm_sound_stop_internal (MMSoundPcmHandle_t handle); +static int _pcm_sound_stop(MMSoundPcmHandle_t handle); +static void __sound_pcm_send_message (mm_sound_pcm_async_t *pcmHandle, int message, int code); + +static int mm_sound_pa_open(mm_sound_pcm_async_t* handle, int mode, int policy, int priority, int volume_config, pa_sample_spec* ss, + pa_channel_map* channel_map, int* size, mm_sound_pcm_stream_cb_t callback, void* userdata); +static int _mm_sound_pa_close(mm_sound_pcm_async_t* handle); +static int _mm_sound_pa_cork(mm_sound_pcm_async_t* handle, int cork); +static int _mm_sound_pa_drain(mm_sound_pcm_async_t* handle); +static int _mm_sound_pa_get_latency(mm_sound_pcm_async_t* handle, int* latency);; +static void __mm_sound_pa_success_cb(pa_context *c, int success, void *userdata); + +/////////////////////////////////// +//// MMSOUND PCM APIs +/////////////////////////////////// + + +static char* __get_channel_str(MMSoundPcmChannel_t channel) +{ + if (channel == MMSOUND_PCM_MONO) + return "Mono"; + else if (channel == MMSOUND_PCM_STEREO) + return "Stereo"; + else + return "Unknown"; +} + +static char* __get_format_str(MMSoundPcmFormat_t format) +{ + if (format == MMSOUND_PCM_S16_LE) + return "S16LE"; + else if (format == MMSOUND_PCM_U8) + return "U8"; + else + return "Unknown"; +} + +static int _get_asm_information(ASM_sound_events_t *type, int *options) +{ + int session_type = MM_SESSION_TYPE_MEDIA; + int session_options = 0; + ASM_sound_events_t asm_event; + + if(type == NULL) + return MM_ERROR_SOUND_INVALID_POINTER; + + /* read session information */ + if(_mm_session_util_read_information(-1, &session_type, &session_options) < 0) { + debug_log("Read Session Information failed. Set default \"Media\" type\n"); + session_type = MM_SESSION_TYPE_MEDIA; + if(mm_session_init(session_type) < 0) { + debug_error("mm_session_init() failed\n"); + return MM_ERROR_SOUND_INTERNAL; + } + } + + /* convert MM_SESSION_TYPE to ASM_EVENT_TYPE */ + switch (session_type) + { + case MM_SESSION_TYPE_MEDIA: + case MM_SESSION_TYPE_MEDIA_RECORD: + asm_event = ASM_EVENT_MEDIA_MMSOUND; + break; + case MM_SESSION_TYPE_NOTIFY: + asm_event = ASM_EVENT_NOTIFY; + break; + case MM_SESSION_TYPE_ALARM: + asm_event = ASM_EVENT_ALARM; + break; + case MM_SESSION_TYPE_CALL: + asm_event = ASM_EVENT_CALL; + break; + case MM_SESSION_TYPE_VIDEOCALL: + asm_event = ASM_EVENT_VIDEOCALL; + break; + case MM_SESSION_TYPE_VOIP: + asm_event = ASM_EVENT_VOIP; + break; + case MM_SESSION_TYPE_EMERGENCY: + asm_event = ASM_EVENT_EMERGENCY; + break; + case MM_SESSION_TYPE_VOICE_RECOGNITION: + asm_event = ASM_EVENT_VOICE_RECOGNITION; + break; + case MM_SESSION_TYPE_RECORD_AUDIO: + asm_event = ASM_EVENT_MMCAMCORDER_AUDIO; + break; + case MM_SESSION_TYPE_RECORD_VIDEO: + asm_event = ASM_EVENT_MMCAMCORDER_VIDEO; + break; + default: + debug_error("Unexpected %d\n", session_type); + return MM_ERROR_SOUND_INTERNAL; + } + + *type = asm_event; + *options = session_options; + return MM_ERROR_NONE; +} + +static bool _check_skip_session_type(mm_sound_source_type_e type) +{ + bool ret = false; + switch (type) + { + case SUPPORT_SOURCE_TYPE_DEFAULT: + case SUPPORT_SOURCE_TYPE_VOICECONTROL: + ret = false; + break; + case SUPPORT_SOURCE_TYPE_MIRRORING: + case SUPPORT_SOURCE_TYPE_CALL_FORWARDING: + case SUPPORT_SOURCE_TYPE_LOOPBACK: + ret = true; + break; + default: + debug_error("Unexpected %d\n", type); + return false; + } + + return ret; +} + +static void __sound_pcm_send_message (mm_sound_pcm_async_t *pcmHandle, int message, int code) +{ + int ret = 0; + if (pcmHandle->msg_cb) { + MMMessageParamType msg; + msg.union_type = MM_MSG_UNION_CODE; + msg.code = code; + + debug_log ("calling msg callback(%p) with message(%d), code(%d), msg callback param(%p)\n", + pcmHandle->msg_cb, message, msg.code, pcmHandle->msg_cb_param); + ret = pcmHandle->msg_cb(message, &msg, pcmHandle->msg_cb_param); + debug_log ("msg callback returned (%d)\n", ret); + } else { + debug_log ("No pcm msg callback\n"); + } +} + +static ASM_cb_result_t sound_pcm_asm_callback(int handle, ASM_event_sources_t event_src, ASM_sound_commands_t command, unsigned int sound_status, void *cb_data) +{ + mm_sound_pcm_async_t *pcmHandle = (mm_sound_pcm_async_t *)cb_data; + ASM_cb_result_t cb_res = ASM_CB_RES_IGNORE; + int message = MM_MESSAGE_SOUND_PCM_INTERRUPTED; + + /* Check input param */ + if(pcmHandle == NULL) { + debug_error("sound_pcm_asm_callback cb_data is null\n"); + return cb_res; + } + + debug_log ("command = %d, handle = %p, is_started = %d\n",command, pcmHandle, pcmHandle->is_started); + switch(command) + { + case ASM_COMMAND_PAUSE: + case ASM_COMMAND_STOP: + /* Do stop */ + //MAINLOOP_LOCK(pcmHandle->mainloop); + PCM_LOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + _pcm_sound_stop_internal (pcmHandle); + PCM_UNLOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + //MAINLOOP_LOCK(pcmHandle->mainloop); + cb_res = ASM_CB_RES_PAUSE; + break; + + case ASM_COMMAND_RESUME: + cb_res = ASM_CB_RES_IGNORE; + message = MM_MESSAGE_READY_TO_RESUME; + break; + + case ASM_COMMAND_PLAY: + case ASM_COMMAND_NONE: + debug_error ("Not an expected case!!!!\n"); + break; + } + + /* execute user callback if callback available */ + __sound_pcm_send_message (pcmHandle, message, event_src); + + return cb_res; +} + +EXPORT_API +int mm_sound_pcm_capture_open_async(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, + MMSoundPcmFormat_t format, mm_sound_source_type_e source_type, + mm_sound_pcm_stream_cb_t callback, void* userdata) +{ + mm_sound_pcm_async_t *pcmHandle = NULL; + int size = 0; + int result = MM_ERROR_NONE; + int errorcode = 0; + int ret_mutex = 0; + + int volume_config = 0; + int src_type = 0; + pa_sample_spec ss; + + debug_warning ("enter : rate=[%d Hz], channel=[%x][%s], format=[%x][%s], source_type=[%x]\n", + rate, channel, __get_channel_str(channel), format, __get_format_str(format), source_type); + + if (rate < _MIN_SYSTEM_SAMPLERATE || rate > _MAX_SYSTEM_SAMPLERATE) { + debug_error("unsupported sample rate %u", rate); + return MM_ERROR_SOUND_DEVICE_INVALID_SAMPLERATE; + } else { + ss.rate = rate; + } + + switch(channel) + { + case MMSOUND_PCM_MONO: + ss.channels = 1; + break; + case MMSOUND_PCM_STEREO: + ss.channels = 2; + break; + + default: + debug_error("Unsupported channel type\n"); + return MM_ERROR_SOUND_DEVICE_INVALID_CHANNEL; + } + + switch(format) + { + case MMSOUND_PCM_U8: + ss.format = PA_SAMPLE_U8; + break; + case MMSOUND_PCM_S16_LE: + ss.format = PA_SAMPLE_S16LE; + break; + default: + debug_error("Unsupported format type\n"); + return MM_ERROR_SOUND_DEVICE_INVALID_FORMAT; + } + + //pcmHandle = calloc(sizeof(mm_sound_pcm_async_t), 1); + pcmHandle = malloc (sizeof(mm_sound_pcm_async_t)); + if(pcmHandle == NULL) + return MM_ERROR_OUT_OF_MEMORY; + + memset (pcmHandle, 0, sizeof(mm_sound_pcm_async_t)); + + ret_mutex = pthread_mutex_init(&pcmHandle->pcm_mutex_internal, NULL); + if(ret_mutex != 0) + { + free(pcmHandle); + return MM_ERROR_OUT_OF_MEMORY; + } + + /* Register ASM */ + /* get session information */ + if(MM_ERROR_NONE != _get_asm_information(&pcmHandle->asm_event, &pcmHandle->asm_options)) { + PCM_LOCK_DESTROY_INTERNAL(&pcmHandle->pcm_mutex_internal); + free(pcmHandle); + return MM_ERROR_POLICY_INTERNAL; + } + + switch (source_type) + { + case SUPPORT_SOURCE_TYPE_VOICECONTROL: + pcmHandle->asm_event = ASM_EVENT_EXCLUSIVE_RESOURCE; + pcmHandle->resource = ASM_RESOURCE_VOICECONTROL; + break; + + case SUPPORT_SOURCE_TYPE_VOICERECORDING: + break; + + case SUPPORT_SOURCE_TYPE_MIRRORING: + case SUPPORT_SOURCE_TYPE_SVR: + /* Noise reduction is already present in VoIP source so secrec is no more required. */ + case SUPPORT_SOURCE_TYPE_VOIP: + default: + /* Skip any specific asm setting or secrec */ + break; + } + + /* register asm */ + if(pcmHandle->asm_event != ASM_EVENT_CALL && + pcmHandle->asm_event != ASM_EVENT_VIDEOCALL && + pcmHandle->asm_event != ASM_EVENT_VOIP && + pcmHandle->asm_event != ASM_EVENT_VOICE_RECOGNITION && + pcmHandle->asm_event != ASM_EVENT_MMCAMCORDER_VIDEO && + _check_skip_session_type(source_type) == false) { + if(!ASM_register_sound(-1, &pcmHandle->asm_handle, pcmHandle->asm_event, + /* ASM_STATE_PLAYING */ ASM_STATE_NONE, sound_pcm_asm_callback, (void*)pcmHandle, pcmHandle->resource, &errorcode)) { + debug_error("ASM_register_sound() failed 0x%x\n", errorcode); + PCM_LOCK_DESTROY_INTERNAL(&pcmHandle->pcm_mutex_internal); + free(pcmHandle); + return MM_ERROR_POLICY_BLOCKED; + } + if(!ASM_set_session_option(pcmHandle->asm_handle, pcmHandle->asm_options, &errorcode)) { + debug_error("ASM_set_session_option() failed 0x%x\n", errorcode); + } + } else { + pcmHandle->skip_session = true; + } + + /* For Video Call or VoIP select volume type VOLUME_TYPE_VOIP for sink/source */ + if( (pcmHandle->asm_event == ASM_EVENT_VIDEOCALL) || (pcmHandle->asm_event == ASM_EVENT_VOIP) ) + volume_config = VOLUME_TYPE_VOIP; + else + volume_config = VOLUME_TYPE_SYSTEM; //dose not effect at capture mode + + src_type = source_type; + /* FIXME : remove after quality issue is fixed */ + + mm_sound_pa_open(pcmHandle, 1, src_type, 0, volume_config, &ss, NULL, &size, callback, userdata); + if(!pcmHandle->s) { + debug_error("Device Open Error 0x%x\n", result); + PCM_LOCK_DESTROY_INTERNAL(&pcmHandle->pcm_mutex_internal); + free(pcmHandle); + return MM_ERROR_SOUND_DEVICE_NOT_OPENED; + } + + pcmHandle->is_playback = false; + pcmHandle->rate = rate; + pcmHandle->channel = channel; + pcmHandle->format = format; + pcmHandle->byte_per_sec = rate*(format==MMSOUND_PCM_U8?1:2)*(channel==MMSOUND_PCM_MONO?1:2); + + /* Set handle to return */ + *handle = (MMSoundPcmHandle_t)pcmHandle; + + debug_warning ("success : handle=[%p], handle->s=[%p], size=[%d]\n", handle, pcmHandle->s, size); + + return size; +} + +static int _pcm_sound_start (MMSoundPcmHandle_t handle) +{ + mm_sound_pcm_async_t *pcmHandle = (mm_sound_pcm_async_t*)handle; + int errorcode = 0; + int ret = 0; + + debug_fenter(); + + /* Check input param */ + if(pcmHandle == NULL) { + debug_error ("Handle is null, return Invalid Argument\n"); + ret = MM_ERROR_INVALID_ARGUMENT; + goto NULL_HANDLE; + } + + PCM_LOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + + if (pcmHandle->skip_session == false) { + /* ASM set state to PLAYING */ + if (!ASM_set_sound_state(pcmHandle->asm_handle, pcmHandle->asm_event, ASM_STATE_PLAYING, pcmHandle->resource, &errorcode)) { + debug_error("ASM_set_sound_state(PLAYING) failed 0x%x\n", errorcode); + ret = MM_ERROR_POLICY_BLOCKED; + goto EXIT; + } + } + + /* Update State */ + pcmHandle->is_started = true; + + /* Un-Cork */ + ret = _mm_sound_pa_cork(pcmHandle, 0); +EXIT: + PCM_UNLOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + +NULL_HANDLE: + debug_fleave(); + return ret; +} + +EXPORT_API +int mm_sound_pcm_capture_start_async(MMSoundPcmHandle_t handle) +{ + int ret = MM_ERROR_NONE; + + debug_warning ("enter : handle=[%p]\n", handle); + + ret = _pcm_sound_start (handle); + if (ret != MM_ERROR_NONE) { + debug_error ("_pcm_sound_start() failed (%x)\n", ret); + goto EXIT; + } + +EXIT: + debug_warning ("leave : handle=[%p], ret=[0x%X]", handle, ret); + + return ret; +} + +static int _pcm_sound_stop_internal (MMSoundPcmHandle_t handle) +{ + mm_sound_pcm_async_t *pcmHandle = (mm_sound_pcm_async_t*)handle; + + /* Check input param */ + if(pcmHandle == NULL) + return MM_ERROR_INVALID_ARGUMENT; + + /* Check State */ + if (pcmHandle->is_started == false) { + debug_warning ("Can't stop because not started\n"); + return MM_ERROR_SOUND_INVALID_STATE; + } + +#if 0 + /* Drain if playback mode */ + if (pcmHandle->is_playback) { + if(MM_ERROR_NONE != _mm_sound_pa_drain(pcmHandle)) { + debug_error("drain failed\n"); + } + } +#endif + /* Update State */ + pcmHandle->is_started = false; + + /* Cork */ + return _mm_sound_pa_cork(pcmHandle, 1); +} + +static int _pcm_sound_stop(MMSoundPcmHandle_t handle) +{ + mm_sound_pcm_async_t *pcmHandle = (mm_sound_pcm_async_t*)handle; + int errorcode = 0; + int ret = MM_ERROR_NONE; + + debug_fenter(); + + /* Check input param */ + if(pcmHandle == NULL) { + debug_error ("Handle is null, return Invalid Argument\n"); + ret = MM_ERROR_INVALID_ARGUMENT; + goto NULL_HANDLE; + } + +// MAINLOOP_LOCK(pcmHandle->mainloop); + PCM_LOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + + /* Do stop procedure */ + ret = _pcm_sound_stop_internal(handle); + if (ret == MM_ERROR_NONE) { + /* Set ASM State to STOP */ + if (pcmHandle->skip_session == false) { + if (!ASM_set_sound_state(pcmHandle->asm_handle, pcmHandle->asm_event, ASM_STATE_STOP, pcmHandle->resource, &errorcode)) { + debug_error("ASM_set_sound_state(STOP) failed 0x%x\n", errorcode); + ret = MM_ERROR_POLICY_BLOCKED; + goto EXIT; + } + } + } + +EXIT: + PCM_UNLOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); +// MAINLOOP_UNLOCK(pcmHandle->mainloop); +NULL_HANDLE: + debug_fleave(); + return ret; +} + +EXPORT_API +int mm_sound_pcm_capture_stop_async(MMSoundPcmHandle_t handle) +{ + int ret = 0; + + debug_warning ("enter : handle=[%p]\n", handle); + ret = _pcm_sound_stop(handle); + + debug_warning ("leave : handle=[%p], ret=[0x%X]\n", handle, ret); + + return ret; +} + +EXPORT_API +int mm_sound_pcm_capture_peek(MMSoundPcmHandle_t handle, const void **buffer, const unsigned int *length) +{ + int ret = 0; + mm_sound_pcm_async_t *pcmHandle = (mm_sound_pcm_async_t*)handle; + + /* Check input param */ + if(pcmHandle == NULL) { + debug_error ("Handle is null, return Invalid Argument\n"); + ret = MM_ERROR_INVALID_ARGUMENT; + goto NULL_HANDLE; + } +// PCM_LOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + + if(buffer == NULL) { + debug_error("Invalid buffer pointer\n"); + ret = MM_ERROR_SOUND_INVALID_POINTER; + goto EXIT; + } + if(length == 0 ) { + debug_error ("length is 0, return 0\n"); + ret = 0; + goto EXIT; + } + +#if 0 /* FIXME */ + /* Check State : return fail if not started */ + if (!pcmHandle->is_started) { + /* not started, return fail */ + debug_error ("Not started yet, return Invalid State \n"); + ret = MM_ERROR_SOUND_INVALID_STATE; + goto EXIT; + } +#endif + ret = pa_stream_peek (pcmHandle->s, buffer, (unsigned int *)length); + +EXIT: +// PCM_UNLOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); +NULL_HANDLE: + return ret; +} + +EXPORT_API +int mm_sound_pcm_capture_drop(MMSoundPcmHandle_t handle) +{ + int ret = 0; + mm_sound_pcm_async_t *pcmHandle = (mm_sound_pcm_async_t*)handle; + + /* Check input param */ + if(pcmHandle == NULL) { + debug_error ("Handle is null, return Invalid Argument\n"); + ret = MM_ERROR_INVALID_ARGUMENT; + goto NULL_HANDLE; + } +// PCM_LOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + + /* Check State : return fail if not started */ + if (!pcmHandle->is_started) { + /* not started, return fail */ + debug_error ("Not started yet, return Invalid State \n"); + ret = MM_ERROR_SOUND_INVALID_STATE; + goto EXIT; + } + + if (pa_stream_drop(pcmHandle->s) != 0) + ret = MM_ERROR_SOUND_INTERNAL; +EXIT: +// PCM_UNLOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); +NULL_HANDLE: + return ret; +} + + +EXPORT_API +int mm_sound_pcm_capture_close_async(MMSoundPcmHandle_t handle) +{ + int result = MM_ERROR_NONE; + mm_sound_pcm_async_t *pcmHandle = (mm_sound_pcm_async_t*)handle; + int errorcode = 0; + + debug_warning ("enter : handle=[%p]\n", handle); + + /* Check input param */ + if(pcmHandle == NULL) { + debug_error ("Handle is null, return Invalid Argument\n"); + result = MM_ERROR_INVALID_ARGUMENT; + goto NULL_HDL; + } + PCM_LOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + /* Close */ + + + result = _mm_sound_pa_close(pcmHandle); + if (result != 0) { + debug_error("pa_stream_disconnect failed 0x%X", result); + result = MM_ERROR_SOUND_INTERNAL; + goto EXIT; + } + + /* Unregister ASM */ + if(pcmHandle->asm_event != ASM_EVENT_CALL && + pcmHandle->asm_event != ASM_EVENT_VIDEOCALL && + pcmHandle->asm_event != ASM_EVENT_VOIP && + pcmHandle->asm_event != ASM_EVENT_VOICE_RECOGNITION) { + if (pcmHandle->skip_session == false && pcmHandle->asm_handle) { + if(!ASM_unregister_sound(pcmHandle->asm_handle, pcmHandle->asm_event, &errorcode)) { + debug_error("ASM_unregister failed with 0x%x\n", errorcode); + result = MM_ERROR_SOUND_INTERNAL; + goto EXIT; + } + } + } + +EXIT: + PCM_UNLOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); +NULL_HDL: + debug_warning ("leave : handle=[%p], ret=[0x%X]\n", handle, result); + /* Free handle */ + if (pcmHandle) { + PCM_LOCK_DESTROY_INTERNAL(&pcmHandle->pcm_mutex_internal); + free(pcmHandle); + pcmHandle = NULL; + } + + return result; +} + +EXPORT_API +int mm_sound_pcm_set_message_callback_async (MMSoundPcmHandle_t handle, MMMessageCallback callback, void *user_param) +{ + mm_sound_pcm_async_t *pcmHandle = (mm_sound_pcm_async_t*)handle; + + if(pcmHandle == NULL || callback == NULL) + return MM_ERROR_INVALID_ARGUMENT; + + pcmHandle->msg_cb = callback; + pcmHandle->msg_cb_param = user_param; + + debug_log ("set pcm message callback (%p,%p)\n", callback, user_param); + + return MM_ERROR_NONE; +} + +EXPORT_API +int mm_sound_pcm_play_open_async (MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, + MMSoundPcmFormat_t format, int volume_config, + mm_sound_pcm_stream_cb_t callback, void* userdata) +{ + mm_sound_pcm_async_t *pcmHandle = NULL; + int size = 0; + int result = MM_ERROR_NONE; + int errorcode = 0; + int volume_type = MM_SOUND_VOLUME_CONFIG_TYPE(volume_config); + int ret_mutex = 0; + + pa_sample_spec ss; + + debug_warning ("enter : rate=[%d], channel=[%x][%s], format=[%x][%s], volconf=[%d]", + rate, channel, __get_channel_str(channel), format, __get_format_str(format), volume_config); + + /* Check input param */ + if (volume_type < 0 || volume_type >= VOLUME_TYPE_MAX) { + debug_error("Volume type is invalid %d\n", volume_type); + return MM_ERROR_INVALID_ARGUMENT; + } + if (rate < _MIN_SYSTEM_SAMPLERATE || rate > _MAX_SYSTEM_SAMPLERATE) { + debug_error("unsupported sample rate %u", rate); + return MM_ERROR_SOUND_DEVICE_INVALID_SAMPLERATE; + } else { + ss.rate = rate; + } + + switch(channel) + { + case MMSOUND_PCM_MONO: + ss.channels = 1; + break; + case MMSOUND_PCM_STEREO: + ss.channels = 2; + break; + default: + debug_error("Unsupported channel type\n"); + return MM_ERROR_SOUND_DEVICE_INVALID_CHANNEL; + } + + switch(format) + { + case MMSOUND_PCM_U8: + ss.format = PA_SAMPLE_U8; + break; + case MMSOUND_PCM_S16_LE: + ss.format = PA_SAMPLE_S16LE; + break; + default: + debug_error("Unsupported format type\n"); + return MM_ERROR_SOUND_DEVICE_INVALID_FORMAT; + } + + pcmHandle = calloc(sizeof(mm_sound_pcm_async_t),1); + if(pcmHandle == NULL) + return MM_ERROR_OUT_OF_MEMORY; + + ret_mutex = pthread_mutex_init(&pcmHandle->pcm_mutex_internal, NULL); + if(ret_mutex != 0) { + debug_error ("error mutex init....%d"); + result = MM_ERROR_OUT_OF_MEMORY; + goto ERROR; + } + + /* Register ASM */ + debug_log ("session start"); + + /* get session information */ + if(MM_ERROR_NONE != _get_asm_information(&pcmHandle->asm_event, &pcmHandle->asm_options)) { + debug_error ("_get_asm_information failed....\n"); + result = MM_ERROR_POLICY_INTERNAL; + goto ERROR; + } + + // should be fixed. call forwarding engine(voip) use call volume type. + if(volume_type == VOLUME_TYPE_CALL) { + pcmHandle->skip_session = true; + } + + if(pcmHandle->asm_event != ASM_EVENT_CALL && + pcmHandle->asm_event != ASM_EVENT_VIDEOCALL && + pcmHandle->asm_event != ASM_EVENT_VOIP && + pcmHandle->asm_event != ASM_EVENT_VOICE_RECOGNITION && + pcmHandle->skip_session == false) { + + /* register asm */ + if(!ASM_register_sound(-1, &pcmHandle->asm_handle, pcmHandle->asm_event, + ASM_STATE_NONE, sound_pcm_asm_callback, (void*)pcmHandle, pcmHandle->resource, &errorcode)) { + debug_error("ASM_register_sound() failed 0x%x\n", errorcode); + result = MM_ERROR_POLICY_BLOCKED; + goto ERROR; + } + if(!ASM_set_session_option(pcmHandle->asm_handle, pcmHandle->asm_options, &errorcode)) { + debug_error("ASM_set_session_option() failed 0x%x\n", errorcode); + } + } else { + pcmHandle->skip_session = true; + } + + pcmHandle->is_playback = true; + pcmHandle->rate = rate; + pcmHandle->channel = channel; + pcmHandle->format = format; + pcmHandle->byte_per_sec = rate*(format==MMSOUND_PCM_U8?1:2)*(channel==MMSOUND_PCM_MONO?1:2); + + /* Set handle to return */ + *handle = (MMSoundPcmHandle_t)pcmHandle; + + /* Open */ + mm_sound_pa_open(pcmHandle, 0, 0, 0, + volume_config, &ss, NULL, &size, callback, userdata); + if(!pcmHandle->s) { + debug_error("Device Open Error 0x%x\n", result); + result = MM_ERROR_SOUND_DEVICE_NOT_OPENED; + goto ERROR; + } + + debug_warning ("success : handle=[%p], handle->s=[%p], size=[%d]\n", handle, pcmHandle->s, size); + return size; + +ERROR: + if (pcmHandle) { + if(ret_mutex == 0) { + PCM_LOCK_DESTROY_INTERNAL(&pcmHandle->pcm_mutex_internal); + } + free(pcmHandle); + } + return result; + + + +} + +EXPORT_API +int mm_sound_pcm_play_start_async(MMSoundPcmHandle_t handle) +{ + int ret = 0; + + debug_warning ("enter : handle=[%p]\n", handle); + ret = _pcm_sound_start (handle); + debug_warning ("leave : handle=[%p], ret=[0x%X]\n", handle, ret); + + return ret; +} + +EXPORT_API +int mm_sound_pcm_play_stop_async(MMSoundPcmHandle_t handle) +{ + int ret = 0; + + debug_warning ("enter : handle=[%p]\n", handle); + ret = _pcm_sound_stop(handle); + debug_warning ("leave : handle=[%p], ret=[0x%X]\n", handle, ret); + + return ret; +} + +EXPORT_API +int mm_sound_pcm_play_write_async(MMSoundPcmHandle_t handle, void* ptr, unsigned int length_byte) +{ + int ret = 0; + static int written_byte = 0; + mm_sound_pcm_async_t *pcmHandle = (mm_sound_pcm_async_t*)handle; + int vr_state = 0; + + /* Check input param */ + if(pcmHandle == NULL) { + debug_error ("Handle is null, return Invalid Argument\n"); + ret = MM_ERROR_INVALID_ARGUMENT; + goto NULL_HANDLE; + } + +// PCM_LOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + + if(ptr == NULL) { + debug_error("Invalid buffer pointer\n"); + ret = MM_ERROR_SOUND_INVALID_POINTER; + goto EXIT; + } + if(length_byte == 0 ) { + debug_error ("length is 0, return 0\n"); + ret = 0; + goto EXIT; + } + +#if 0 + /* Check State : return fail if not started */ + if (!pcmHandle->is_started) { + /* not started, return fail */ + debug_error ("Not started yet, return Invalid State \n"); + ret = MM_ERROR_SOUND_INVALID_STATE; + goto EXIT; + } +#endif + /* Write */ + + /* Check whether voicerecorder is running */ + vconf_get_int(VCONFKEY_VOICERECORDER_STATE, &vr_state); + + if (vr_state == VCONFKEY_VOICERECORDER_RECORDING) { + debug_log ("During VoiceRecording....MUTE!!!"); + } else { + ret = pa_stream_write(pcmHandle->s, ptr, length_byte, NULL, 0LL, PA_SEEK_RELATIVE); + if (ret == 0) { + ret = length_byte; + } + } + +EXIT: +// PCM_UNLOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); +NULL_HANDLE: + written_byte += length_byte; + if(ret > 0 && written_byte>pcmHandle->byte_per_sec*RW_LOG_PERIOD){ + debug_log ("(%d)/write-once, (%d)/%dsec bytes written\n", length_byte, written_byte, RW_LOG_PERIOD); + written_byte = 0; + } + + return ret; +} + +EXPORT_API +int mm_sound_pcm_play_close_async(MMSoundPcmHandle_t handle) +{ + int result = MM_ERROR_NONE; + mm_sound_pcm_async_t *pcmHandle = (mm_sound_pcm_async_t*)handle; + int errorcode = 0; + + debug_warning ("enter : handle=[%p]\n", handle); + + /* Check input param */ + if(pcmHandle == NULL) { + debug_error ("Handle is null, return Invalid Argument\n"); + result = MM_ERROR_INVALID_ARGUMENT; + goto NULL_HANDLE; + } + PCM_LOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); + /* Drain if needed */ + if (pcmHandle->is_started) { + /* stop() is not called before close(), drain is needed */ + if(MM_ERROR_NONE != _mm_sound_pa_drain(pcmHandle)) { + debug_error("drain failed\n"); + result = MM_ERROR_SOUND_INTERNAL; + goto EXIT; + } + } + pcmHandle->is_started = false; + /* Close */ + result = _mm_sound_pa_close(pcmHandle); + if (result != 0) { + debug_error("pa_stream_disconnect failed 0x%X", result); + result = MM_ERROR_SOUND_INTERNAL; + goto EXIT; + } + + if (pcmHandle->skip_session == false) { + /* Unregister ASM */ + if(pcmHandle->asm_event != ASM_EVENT_CALL && + pcmHandle->asm_event != ASM_EVENT_VIDEOCALL && + pcmHandle->asm_event != ASM_EVENT_VOIP && + pcmHandle->asm_event != ASM_EVENT_VOICE_RECOGNITION) { + if(!ASM_unregister_sound(pcmHandle->asm_handle, pcmHandle->asm_event, &errorcode)) { + debug_error("ASM_unregister failed with 0x%x\n", errorcode); + result = MM_ERROR_SOUND_INTERNAL; + goto EXIT; + } + } + } + +EXIT: + PCM_UNLOCK_INTERNAL(&pcmHandle->pcm_mutex_internal); +NULL_HANDLE: + debug_warning ("leave : handle=[%p], result[0x%X]\n", handle, result); + if (pcmHandle) { + /* Free handle */ + PCM_LOCK_DESTROY_INTERNAL(&pcmHandle->pcm_mutex_internal); + free(pcmHandle); + pcmHandle= NULL; + } + + return result; +} + +EXPORT_API +int mm_sound_pcm_get_latency_async(MMSoundPcmHandle_t handle, int *latency) +{ + mm_sound_pcm_async_t *pcmHandle = (mm_sound_pcm_async_t*)handle; + int mlatency = 0; + + /* Check input param */ + if (latency == NULL) + return MM_ERROR_INVALID_ARGUMENT; + + if(MM_ERROR_NONE != _mm_sound_pa_get_latency(pcmHandle, &mlatency)) { + debug_error("Get Latency Error"); + return MM_ERROR_SOUND_DEVICE_NOT_OPENED; + } + + *latency = mlatency; + + return MM_ERROR_NONE; +} + +EXPORT_API +int mm_sound_pcm_is_started_async(MMSoundPcmHandle_t handle, bool *is_started) +{ + mm_sound_pcm_async_t *pcmHandle = (mm_sound_pcm_async_t*)handle; + + /* Check input param */ + if (is_started == NULL) + return MM_ERROR_INVALID_ARGUMENT; + + *is_started = pcmHandle->is_started; + + return MM_ERROR_NONE; +} + +/* --------------------------------- pa client ----------------------------------*/ + +#define IS_INPUT_HANDLE(x) \ + if( x == HANDLE_MODE_INPUT || x == HANDLE_MODE_INPUT_HIGH_LATENCY || \ + x == HANDLE_MODE_INPUT_LOW_LATENCY || x == HANDLE_MODE_INPUT_AP_CALL ) + +#define MEDIA_POLICY_AUTO "auto" +#define MEDIA_POLICY_PHONE "phone" +#define MEDIA_POLICY_ALL "all" +#define MEDIA_POLICY_VOIP "voip" +#define MEDIA_POLICY_MIRRORING "mirroring" +#define MEDIA_POLICY_HIGH_LATENCY "high-latency" + +enum mm_sound_handle_mode_t { + HANDLE_MODE_OUTPUT, /**< Output mode of handle */ + HANDLE_MODE_OUTPUT_CLOCK, /**< Output mode of gst audio only mode */ + HANDLE_MODE_OUTPUT_VIDEO, /**< Output mode of gst video mode */ + HANDLE_MODE_OUTPUT_LOW_LATENCY, /**< Output mode for low latency play mode. typically for game */ + HANDLE_MODE_INPUT, /**< Input mode of handle */ + HANDLE_MODE_INPUT_HIGH_LATENCY, /**< Input mode for high latency capture mode. */ + HANDLE_MODE_INPUT_LOW_LATENCY, /**< Input mode for low latency capture mode. typically for VoIP */ + HANDLE_MODE_CALL_OUT, /**< for voice call establish */ + HANDLE_MODE_CALL_IN, /**< for voice call establish */ + HANDLE_MODE_OUTPUT_AP_CALL, /**< for VT call on thin modem */ + HANDLE_MODE_INPUT_AP_CALL, /**< for VT call on thin modem */ + HANDLE_MODE_NUM, /**< Number of mode */ +}; + +static void __mm_sound_pa_success_cb(pa_context *c, int success, void *userdata) +{ + mm_sound_pcm_async_t* handle = (mm_sound_pcm_async_t*) userdata; + + if (!success) { + debug_error("pa control failed: %s\n", pa_strerror(pa_context_errno(c))); + } else { + debug_msg("pa control success\n"); + } + handle->operation_success = success; + pa_threaded_mainloop_signal(handle->mainloop, 0); +} + +static void _context_state_cb(pa_context *c, void *userdata) +{ + pa_context_state_t state; + mm_sound_pcm_async_t* handle = (mm_sound_pcm_async_t*) userdata; + assert(c); + + state = pa_context_get_state(c); + debug_msg ("[%p] context state = [%d]", handle, state); + switch (state) { + case PA_CONTEXT_READY: + case PA_CONTEXT_TERMINATED: + case PA_CONTEXT_FAILED: + debug_msg ("signaling mainloop!!!!"); + pa_threaded_mainloop_signal(handle->mainloop, 0); + break; + + case PA_CONTEXT_UNCONNECTED: + case PA_CONTEXT_CONNECTING: + case PA_CONTEXT_AUTHORIZING: + case PA_CONTEXT_SETTING_NAME: + break; + } +} + +static void _stream_state_cb(pa_stream *s, void * userdata) +{ + pa_stream_state_t state; + mm_sound_pcm_async_t* handle = (mm_sound_pcm_async_t*) userdata; + assert(s); + + state = pa_stream_get_state(s); + debug_msg ("[%p] stream [%d] state = [%d]", handle, pa_stream_get_index(s), state); + + switch (state) { + case PA_STREAM_READY: + case PA_STREAM_FAILED: + case PA_STREAM_TERMINATED: + debug_msg ("signaling mainloop!!!!"); + pa_threaded_mainloop_signal(handle->mainloop, 0); + break; + + case PA_STREAM_UNCONNECTED: + case PA_STREAM_CREATING: + break; + } +} + + +static int _pa_stream_create (mm_sound_pcm_async_t* handle, int is_capture, pa_sample_spec* ss, + pa_channel_map* channel_map, pa_proplist *proplist, mm_sound_pcm_stream_cb_t callback, void* userdata) +{ + pa_buffer_attr attr; + pa_stream_flags_t flags = PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_START_CORKED;// | PA_STREAM_ADJUST_LATENCY; + + int error = PA_OK, r; + int latency = 0; + + memset (&attr, 0, sizeof(pa_buffer_attr)); + + if (!is_capture) { + latency = 100000; + } + + attr.maxlength = (uint32_t) -1; /* common */ + attr.tlength = latency > 0 ? (uint32_t) pa_usec_to_bytes(latency, ss) : (uint32_t) -1; /* for playback only */ + attr.prebuf = (uint32_t) 0; /* for playback only */ + attr.minreq = (uint32_t) -1; /* for playback only */ + attr.fragsize = (uint32_t) 512; /* for recording only */ + + + /* PULSE STREAM CREATION */ + if (!(handle->mainloop = pa_threaded_mainloop_new())) + goto fail; + + if (!(handle->context = pa_context_new(pa_threaded_mainloop_get_api(handle->mainloop), NULL))) + goto fail; + + pa_context_set_state_callback(handle->context, _context_state_cb, handle); + + if (pa_context_connect(handle->context, NULL, 0, NULL) < 0) { + error = pa_context_errno(handle->context); + goto fail; + } + + MAINLOOP_LOCK(handle->mainloop); + + if (pa_threaded_mainloop_start(handle->mainloop) < 0) + goto unlock_and_fail; + + for (;;) { + pa_context_state_t state; + + state = pa_context_get_state(handle->context); + + if (state == PA_CONTEXT_READY) + break; + + if (!PA_CONTEXT_IS_GOOD(state)) { + error = pa_context_errno(handle->context); + goto unlock_and_fail; + } + + /* Wait until the context is ready */ + pa_threaded_mainloop_wait(handle->mainloop); + } + + + if (is_capture) { + handle->s = pa_stream_new_with_proplist(handle->context, "capture", ss, channel_map, proplist); + pa_stream_set_state_callback(handle->s, _stream_state_cb, handle); + pa_stream_set_read_callback(handle->s, (pa_stream_request_cb_t)callback, userdata); + } else { + handle->s = pa_stream_new_with_proplist(handle->context, "playback", ss, channel_map, proplist); + pa_stream_set_state_callback(handle->s, _stream_state_cb, handle); + pa_stream_set_write_callback(handle->s, (pa_stream_request_cb_t)callback, userdata); + } +// pa_stream_set_latency_update_callback(p->stream, stream_latency_update_cb, p); + + if (is_capture) { + r = pa_stream_connect_record(handle->s, NULL, &attr, flags); + } else { + r = pa_stream_connect_playback(handle->s, NULL, &attr, flags, NULL, NULL); + } + + if (r < 0) { + error = pa_context_errno(handle->context); + goto unlock_and_fail; + } + + for (;;) { + pa_stream_state_t state; + + state = pa_stream_get_state(handle->s); + + if (state == PA_STREAM_READY) + break; + + if (!PA_STREAM_IS_GOOD(state)) { + error = pa_context_errno(handle->context); + assert(0); + } + + /* Wait until the stream is ready */ + pa_threaded_mainloop_wait(handle->mainloop); + } + + MAINLOOP_UNLOCK(handle->mainloop); + + return error; + +unlock_and_fail: + debug_error ("error!!!!"); + MAINLOOP_UNLOCK(handle->mainloop); + +fail: +// if (rerror) +// *rerror = error; + + return error; +} + +static const pa_tizen_volume_type_t mm_sound_volume_type_to_pa[VOLUME_TYPE_MAX] = { + [VOLUME_TYPE_SYSTEM] = PA_TIZEN_VOLUME_TYPE_SYSTEM, + [VOLUME_TYPE_NOTIFICATION] = PA_TIZEN_VOLUME_TYPE_NOTIFICATION, + [VOLUME_TYPE_ALARM] = PA_TIZEN_VOLUME_TYPE_ALARM, + [VOLUME_TYPE_RINGTONE] = PA_TIZEN_VOLUME_TYPE_RINGTONE, + [VOLUME_TYPE_MEDIA] = PA_TIZEN_VOLUME_TYPE_MEDIA, + [VOLUME_TYPE_CALL] = PA_TIZEN_VOLUME_TYPE_CALL, + [VOLUME_TYPE_VOIP] = PA_TIZEN_VOLUME_TYPE_VOIP, + [VOLUME_TYPE_FIXED] = PA_TIZEN_VOLUME_TYPE_FIXED, +// [VOLUME_TYPE_EXT_SYSTEM_JAVA] = PA_TIZEN_VOLUME_TYPE_EXT_JAVA, +}; + +static int mm_sound_pa_open(mm_sound_pcm_async_t* handle, int is_capture, int policy, int priority, int volume_config, pa_sample_spec* ss, + pa_channel_map* channel_map, int* size, mm_sound_pcm_stream_cb_t callback, void* userdata) +{ + int vol_conf_type; + int prop_vol_type, prop_gain_type; + int err = MM_ERROR_NONE; + const char *prop_policy = NULL; + pa_proplist *proplist = NULL; + pa_channel_map maps; + + /* ---------- prepare ChannelMap ------------ */ + if(channel_map == NULL) { + pa_channel_map_init_auto(&maps, ss->channels, PA_CHANNEL_MAP_ALSA); + channel_map = &maps; + } + + /* ---------- prepare PROPLIST ------------ */ + proplist = pa_proplist_new(); + + /* Set volume type of stream */ + vol_conf_type = volume_config & 0x000000FF; + prop_vol_type = mm_sound_volume_type_to_pa[vol_conf_type]; + pa_proplist_setf(proplist, PA_PROP_MEDIA_TIZEN_VOLUME_TYPE, "%d", prop_vol_type); + + /* Set gain type of stream */ + prop_gain_type = (volume_config >> 8) & 0x000000FF; + pa_proplist_setf(proplist, PA_PROP_MEDIA_TIZEN_GAIN_TYPE, "%d", prop_gain_type); + + /* If not set any yet, set based on volume type */ + if (prop_policy == NULL) { + /* check stream type (vol type) */ + switch (vol_conf_type) + { + case VOLUME_TYPE_NOTIFICATION: + case VOLUME_TYPE_ALARM: + prop_policy = MEDIA_POLICY_ALL; + break; + + case VOLUME_TYPE_MEDIA: + prop_policy = MEDIA_POLICY_AUTO; + break; + + case VOLUME_TYPE_CALL: + case VOLUME_TYPE_RINGTONE: + case VOLUME_TYPE_FIXED: /* Used for Emergency */ + prop_policy = MEDIA_POLICY_PHONE; + break; + + case VOLUME_TYPE_VOIP: + prop_policy = MEDIA_POLICY_VOIP; + break; + + default: + prop_policy = MEDIA_POLICY_AUTO; + break; + } + } + pa_proplist_sets(proplist, PA_PROP_MEDIA_POLICY, prop_policy); + + if (priority) { + debug_msg("Set HIGH priority [%d]", priority); + pa_proplist_sets(proplist, PA_PROP_MEDIA_ROLE, "solo"); + } + + /* ---------- create Stream ------------ */ + err = _pa_stream_create (handle, is_capture, ss, channel_map, proplist, callback, userdata); + if (!handle->s) { + debug_error("Open pulseaudio handle has failed - %s\n", pa_strerror(err)); + if (err == PA_ERR_ACCESS_BY_SECURITY) { + err = MM_ERROR_SOUND_PERMISSION_DENIED; + } else { + err = MM_ERROR_SOUND_INTERNAL; + } + goto fail; + } + + //mm_sound_pa_set_mute(handle->handle, prop_vol_type, handle_inout, 0); + +fail: + if (proplist) + pa_proplist_free(proplist); + + return err; +} + +static int _mm_sound_pa_close(mm_sound_pcm_async_t* handle) +{ + //int err = MM_ERROR_NONE; + + if (handle->mainloop) + pa_threaded_mainloop_stop(handle->mainloop); + + if (handle->s) { + pa_stream_disconnect(handle->s); + pa_stream_unref(handle->s); + } + + if (handle->context) { + pa_context_disconnect(handle->context); + pa_context_unref(handle->context); + } + + if (handle->mainloop) + pa_threaded_mainloop_free(handle->mainloop); + + return 0; +} + +static int _mm_sound_pa_cork(mm_sound_pcm_async_t* handle, int cork) +{ + pa_operation *o = NULL; + + MAINLOOP_LOCK(handle->mainloop); + + o = pa_stream_cork(handle->s, cork, (pa_stream_success_cb_t)__mm_sound_pa_success_cb, handle); + if (!(o)) { + goto unlock_and_fail; + } + handle->operation_success = 0; + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(handle->mainloop); + } + if (!(handle->operation_success)) { + goto unlock_and_fail; + } + pa_operation_unref(o); + + MAINLOOP_UNLOCK(handle->mainloop); + + return 0; + +unlock_and_fail: + debug_error ("error!!!!"); + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + + MAINLOOP_UNLOCK(handle->mainloop); + return -1; +} + +static int _mm_sound_pa_drain(mm_sound_pcm_async_t* handle) +{ + pa_operation *o = NULL; + + MAINLOOP_LOCK(handle->mainloop); + + o = pa_stream_drain(handle->s, (pa_stream_success_cb_t)__mm_sound_pa_success_cb, handle); + if (!(o)) { + goto unlock_and_fail; + } + handle->operation_success = 0; + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(handle->mainloop); + } + if (!(handle->operation_success)) { + goto unlock_and_fail; + } + pa_operation_unref(o); + + MAINLOOP_UNLOCK(handle->mainloop); + + return 0; + +unlock_and_fail: + debug_error ("error!!!!"); + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + + MAINLOOP_UNLOCK(handle->mainloop); + return -1; +} + + +static int _mm_sound_pa_get_latency(mm_sound_pcm_async_t* handle, int* latency) +{ + int err = MM_ERROR_NONE; + pa_usec_t latency_time = 0; + +#if 0 /* FIXME */ + /* code from pa_simple_get_final_latency() */ + if (phandle->s->direction == PA_STREAM_PLAYBACK) { + latency_time = (pa_bytes_to_usec(phandle->s->buffer_attr.tlength, &phandle->s->sample_spec) + phandle->s->timing_info.configured_sink_usec); + } else if (phandle->s->direction == PA_STREAM_RECORD) { + latency_time = (pa_bytes_to_usec(phandle->s->buffer_attr.fragsize, &phandle->s->sample_spec) + phandle->s->timing_info.configured_source_usec); + } +#endif + + *latency = latency_time / 1000; // usec to msec + + return err; +} + diff --git a/packaging/libmm-sound.spec b/packaging/libmm-sound.spec index 503fc96..5c27929 100644 --- a/packaging/libmm-sound.spec +++ b/packaging/libmm-sound.spec @@ -1,24 +1,32 @@ Name: libmm-sound Summary: MMSound Package contains client lib and sound_server binary -Version: 0.6.0 -Release: 17 +Version: 0.9.189 +Release: 0 Group: System/Libraries -License: LGPL +License: Apache-2.0 Source0: %{name}-%{version}.tar.gz -Requires(pre): /bin/pidof +Source1: sound-server.service +Source2: sound-server.path Requires(post): /sbin/ldconfig Requires(post): /usr/bin/vconftool Requires(postun): /sbin/ldconfig BuildRequires: pkgconfig(mm-common) -BuildRequires: pkgconfig(avsystem) BuildRequires: pkgconfig(mm-log) BuildRequires: pkgconfig(mm-session) BuildRequires: pkgconfig(audio-session-mgr) -BuildRequires: pkgconfig(sysman) BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(vconf) -BuildRequires: pkgconfig(heynoti) -BuildRequires: pkgconfig(security-server) +BuildRequires: pkgconfig(libpulse) +BuildRequires: pkgconfig(iniparser) +BuildRequires: pkgconfig(capi-network-bluetooth) +%ifarch %{arm} +%endif +%if "%{?tizen_profile_name}" == "wearable" +BuildRequires: pkgconfig(bluetooth-api) +%endif +BuildRequires: pkgconfig(libtremolo) +BuildRequires: model-build-features %description MMSound Package contains client lib and sound_server binary for sound system @@ -48,91 +56,142 @@ Requires: %{name} = %{version}-%{release} %description tool MMSound utility package - contians mm_sound_testsuite, sound_check for sound system - - %prep %setup -q - %build -./autogen.sh +%define tizen_audio_feature_ogg_enable 1 +%define tizen_audio_feature_bluetooth_enable 1 + +%if "%{?tizen_profile_name}" == "wearable" +%define tizen_audio_feature_hfp 1 +%else if +%define tizen_audio_feature_hfp 0 +%endif + %ifarch %{arm} -CFLAGS="%{optflags} -fvisibility=hidden -DMM_DEBUG_FLAG -DSEPARATE_EARPHONE_VOLUME -DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\""; export CFLAGS + CFLAGS="%{optflags} -fvisibility=hidden -DMM_DEBUG_FLAG -DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\"" ;export CFLAGS %else -CFLAGS="%{optflags} -fvisibility=hidden -DMM_DEBUG_FLAG -DSEPARATE_EARPHONE_VOLUME -DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\""; export CFLAGS + CFLAGS="%{optflags} -fvisibility=hidden -DMM_DEBUG_FLAG -DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\"" ;export CFLAGS %endif -%configure --prefix=/usr --enable-pulse --enable-security -make %{?jobs:-j%jobs} -%install -rm -rf %{buildroot} -%make_install +%if "%{?tizen_profile_name}" == "wearable" + CFLAGS+=" -DTIZEN_MICRO";export CFLAGS +%else if "%{?tizen_profile_name}" == "mobile" +%endif + +%if 0%{?tizen_audio_feature_bluetooth_enable} + CFLAGS+=" -DSUPPORT_BT_SCO";export CFLAGS +%endif +./autogen.sh +%configure \ +%if 0%{?tizen_audio_feature_hfp} + --enable-hfp \ +%endif +%if 0%{?tizen_audio_feature_ogg_enable} + --enable-ogg \ +%endif +%if 0%{?tizen_audio_feature_bluetooth_enable} + --enable-bluetooth \ +%endif +%ifarch %{arm} + --prefix=/usr --enable-pulse +%else + --prefix=/usr --enable-pulse +%endif -mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc3.d -mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc4.d -mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc5.d -ln -s %{_sysconfdir}/rc.d/init.d/soundserver %{buildroot}%{_sysconfdir}/rc.d/rc3.d/S23soundserver -ln -s %{_sysconfdir}/rc.d/init.d/soundserver %{buildroot}%{_sysconfdir}/rc.d/rc4.d/S23soundserver +make %{?_smp_mflags} +%install +rm -rf %{buildroot} +mkdir -p %{buildroot}/usr/share/license +cp LICENSE.APLv2 %{buildroot}/usr/share/license/%{name} +cp LICENSE.APLv2 %{buildroot}/usr/share/license/libmm-sound-tool +mkdir -p %{buildroot}/opt/etc/dump.d/module.d/ +cp dump_audio.sh %{buildroot}/opt/etc/dump.d/module.d/dump_audio.sh +%make_install +install -d %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants +install -m0644 %{SOURCE1} %{buildroot}%{_libdir}/systemd/system/ +install -m0644 %{SOURCE2} %{buildroot}%{_libdir}/systemd/system/ +ln -sf ../sound-server.path %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/sound-server.path %post /sbin/ldconfig -# -DSEPARATE_EARPHONE_VOLUME -/usr/bin/vconftool set -t int db/private/sound/volume/system 1285 -g 29 -/usr/bin/vconftool set -t int db/private/sound/volume/notification 1799 -g 29 -/usr/bin/vconftool set -t int db/private/sound/volume/alarm 1799 -g 29 -/usr/bin/vconftool set -t int db/private/sound/volume/ringtone 3341 -g 29 -/usr/bin/vconftool set -t int db/private/sound/volume/media 1799 -g 29 -/usr/bin/vconftool set -t int db/private/sound/volume/call 1799 -g 29 -/usr/bin/vconftool set -t int db/private/sound/volume/fixed 0 -g 29 -/usr/bin/vconftool set -t int db/private/sound/volume/java 3084 -g 29 - -# No -DSEPARATE_EARPHONE_VOLUME -#/usr/bin/vconftool set -t int db/private/sound/volume/system 5 -g 29 -#/usr/bin/vconftool set -t int db/private/sound/volume/notification 7 -g 29 -#/usr/bin/vconftool set -t int db/private/sound/volume/alarm 7 -g 29 -#/usr/bin/vconftool set -t int db/private/sound/volume/ringtone 13 -g 29 -#/usr/bin/vconftool set -t int db/private/sound/volume/media 7 -g 29 -#/usr/bin/vconftool set -t int db/private/sound/volume/call 7 -g 29 -#/usr/bin/vconftool set -t int db/private/sound/volume/fixed 0 -g 29 -#/usr/bin/vconftool set -t int db/private/sound/volume/java 11 -g 29 +/usr/bin/vconftool set -t int memory/private/Sound/ASMReady 0 -g 29 -f -i -s system::vconf_multimedia +/usr/bin/vconftool set -t double file/private/sound/volume/balance 0.0 -g 29 -f -s system::vconf_multimedia +/usr/bin/vconftool set -t int file/private/sound/volume/muteall 0 -g 29 -f -s system::vconf_multimedia +/usr/bin/vconftool set -t int memory/private/Sound/VoiceControlOn 0 -g 29 -f -i -s system::vconf_multimedia +/usr/bin/vconftool set -t string memory/private/sound/booting "/usr/share/keysound/poweron.wav" -g 29 -f -i -s system::vconf_multimedia +/usr/bin/vconftool set -t int memory/private/sound/PrimaryVolumetypeForce -1 -g 29 -f -i -s system::vconf_multimedia +/usr/bin/vconftool set -t int memory/private/sound/PrimaryVolumetype -1 -g 29 -f -i -s system::vconf_multimedia +/usr/bin/vconftool set -t int memory/private/sound/hdmisupport 0 -g 29 -f -i -s system::vconf_multimedia +/usr/bin/vconftool set -t int memory/factory/loopback 0 -g 29 -f -i -s system::vconf_multimedia + +/usr/bin/vconftool set -t int file/private/sound/volume/system 9 -g 29 -f -s system::vconf_multimedia +/usr/bin/vconftool set -t int file/private/sound/volume/notification 11 -g 29 -f -s system::vconf_multimedia +/usr/bin/vconftool set -t int file/private/sound/volume/alarm 7 -g 29 -f -s system::vconf_multimedia +/usr/bin/vconftool set -t int file/private/sound/volume/ringtone 11 -g 29 -f -s system::vconf_multimedia +/usr/bin/vconftool set -t int file/private/sound/volume/media 7 -g 29 -f -s system::vconf_multimedia +/usr/bin/vconftool set -t int file/private/sound/volume/call 4 -g 29 -f -s system::vconf_multimedia +/usr/bin/vconftool set -t int file/private/sound/volume/voip 4 -g 29 -f -s system::vconf_multimedia +/usr/bin/vconftool set -t int file/private/sound/volume/voice 7 -g 29 -f -s system::vconf_multimedia +/usr/bin/vconftool set -t int file/private/sound/volume/fixed 0 -g 29 -f -s system::vconf_multimedia + %postun -p /sbin/ldconfig %files +%manifest libmm-sound.manifest %defattr(-,root,root,-) %{_bindir}/sound_server %{_libdir}/libmmfsound.so.* %{_libdir}/libmmfsoundcommon.so.* %{_libdir}/libmmfkeysound.so.* +%{_libdir}/libmmfbootsound.so.* %{_libdir}/libsoundplugintone.so* %{_libdir}/libsoundpluginwave.so* %{_libdir}/libsoundpluginkeytone.so* +%if 0%{?tizen_audio_feature_ogg_enable} +%{_libdir}/libsoundplugintremoloogg.so* +%endif %{_libdir}/soundplugins/libsoundplugintone.so %{_libdir}/soundplugins/libsoundpluginwave.so %{_libdir}/soundplugins/libsoundpluginkeytone.so -%{_sysconfdir}/rc.d/init.d/soundserver -%{_sysconfdir}/rc.d/rc3.d/S23soundserver -%{_sysconfdir}/rc.d/rc4.d/S23soundserver +%if 0%{?tizen_audio_feature_ogg_enable} +%{_libdir}/soundplugins/libsoundplugintremoloogg.so +%endif +%{_libdir}/systemd/system/multi-user.target.wants/sound-server.path +%{_libdir}/systemd/system/sound-server.service +%{_libdir}/systemd/system/sound-server.path +/usr/share/sounds/sound-server/* +%{_datadir}/license/%{name} +%{_datadir}/license/libmm-sound-tool +/usr/share/sounds/sound-server/* +/opt/etc/dump.d/module.d/dump_audio.sh %files devel %defattr(-,root,root,-) %{_libdir}/libmmfkeysound.so +%{_libdir}/libmmfbootsound.so %{_libdir}/libmmfsound.so %{_libdir}/libmmfsoundcommon.so %{_includedir}/mmf/mm_sound_private.h - +%exclude %{_includedir}/mmf/mm_sound_pa_client.h %files sdk-devel %defattr(-,root,root,-) %{_includedir}/mmf/mm_sound.h +%{_includedir}/mmf/mm_sound_pcm_async.h +%exclude %{_includedir}/mmf/mm_sound_pa_client.h %{_libdir}/pkgconfig/mm-keysound.pc +%{_libdir}/pkgconfig/mm-bootsound.pc %{_libdir}/pkgconfig/mm-sound.pc %files tool +%manifest libmm-sound-tool.manifest %defattr(-,root,root,-) %{_bindir}/mm_sound_testsuite diff --git a/packaging/sound-server.path b/packaging/sound-server.path new file mode 100644 index 0000000..5f605f8 --- /dev/null +++ b/packaging/sound-server.path @@ -0,0 +1,5 @@ +[Unit] +Description=Path activation for the "sound-server" programme + +[Path] +PathExists=/tmp/.pa_ready diff --git a/packaging/sound-server.service b/packaging/sound-server.service new file mode 100644 index 0000000..288cdbf --- /dev/null +++ b/packaging/sound-server.service @@ -0,0 +1,12 @@ +[Unit] +Description=Start the sound profile service + +[Service] +ExecStart=/usr/bin/sound_server -S +ExecStop=/usr/bin/sound_server --poweroff +Restart=always +RestartSec=0 +MemoryLimit=50M + +[Install] +WantedBy=tizen-system.target diff --git a/pkgconfig/Makefile.am b/pkgconfig/Makefile.am index 58e6f5e..c5bb35c 100644 --- a/pkgconfig/Makefile.am +++ b/pkgconfig/Makefile.am @@ -1,4 +1,4 @@ -pcfiles = mm-sound.pc mm-keysound.pc +pcfiles = mm-sound.pc mm-keysound.pc mm-bootsound.pc all-local: $(pcfiles) @@ -10,7 +10,7 @@ pkgconfig_DATA= $(pcfiles) CLEANFILES= $(pcfiles) -pcinfiles= mm-sound.pc.in mm-keysound.pc.in +pcinfiles= mm-sound.pc.in mm-keysound.pc.in mm-bootsound.pc.in EXTRA_DIST= $(pcinfiles) diff --git a/pkgconfig/mm-bootsound.pc.in b/pkgconfig/mm-bootsound.pc.in new file mode 100644 index 0000000..07bed81 --- /dev/null +++ b/pkgconfig/mm-bootsound.pc.in @@ -0,0 +1,11 @@ +prefix = @prefix@ +exec_prefix= @exec_prefix@ +libdir = @libdir@ +includedir = @includedir@ + +Name : mmfbootsound +Description : Multimedia Framework Boot Sound Library +Requires : mm-common mm-log +Version : @VERSION@ +Libs : -L${libdir} -lmmfbootsound +Cflags : -I${includedir}/mmf diff --git a/pkgconfig/mm-sound.pc.in b/pkgconfig/mm-sound.pc.in index 100cfbd..ff6c187 100644 --- a/pkgconfig/mm-sound.pc.in +++ b/pkgconfig/mm-sound.pc.in @@ -5,7 +5,7 @@ includedir = @includedir@ Name : mmfsound Description : Multimedia Framework Sound Library -Requires : mm-keysound avsysaudio mm-session glib-2.0 vconf +Requires : mm-keysound mm-bootsound mm-session glib-2.0 vconf Version : @VERSION@ Libs : -L${libdir} -lmmfsound Cflags : -I${includedir}/mmf diff --git a/server/Makefile.am b/server/Makefile.am index 8509f7e..06d65e0 100644 --- a/server/Makefile.am +++ b/server/Makefile.am @@ -6,49 +6,56 @@ sound_server_SOURCES = mm_sound_mgr_codec.c \ mm_sound_mgr_pulse.c \ mm_sound_mgr_asm.c \ mm_sound_mgr_device.c \ - mm_sound_mgr_headset.c \ - mm_sound_mgr_dock.c \ + mm_sound_mgr_device_headset.c \ + mm_sound_mgr_device_dock.c \ + mm_sound_mgr_device_hdmi.c \ + mm_sound_mgr_device_wfd.c \ mm_sound_mgr_session.c \ mm_sound_mgr_run.c \ mm_sound_plugin.c \ mm_sound_server.c \ - mm_sound_thread_pool.c \ - mm_sound_recovery.c + mm_sound_thread_pool.c sound_server_CFLAGS = -I$(srcdir)/../include \ -I$(srcdir)/include \ $(MMCOMMON_CFLAGS) \ $(MMLOGSVR_CFLAGS) \ - -DMMF_LOG_OWNER=0x020 \ + -DMMF_LOG_OWNER=0x002 \ -DMMF_DEBUG_PREFIX=\"MMF-SOUND\" \ -D__DEBUG_MODE__ -DUSE_VCONF -D__USE_LOGMANAGER__ \ $(MMSESSION_CFLAGS) \ - $(AVSYSTEM_CFLAGS) \ $(AUDIOSESSIONMGR_CFLAGS) \ $(VCONF_CFLAGS) \ $(GLIB2_CFLAGS) \ + $(GIO_CFLAGS) \ $(HEYNOTI_CFLAGS) sound_server_LDADD = $(MMLOGSVR_LIBS) \ -ldl \ $(MMCOMMON_LIBS) \ $(MMSESSION_LIBS) \ - $(AVSYSTEM_LIBS) \ $(AUDIOSESSIONMGR_LIBS) \ $(GLIB2_LIBS) \ + $(GIO_LIBS) \ $(VCONF_LIBS) \ $(HEYNOTI_LIBS) \ $(srcdir)/../libmmfsound.la \ - $(srcdir)/../common/libmmfsoundcommon.la + $(srcdir)/../common/libmmfsoundcommon.la + +sound_server_CFLAGS += $(BLUETOOTH_API_CFLAGS) +sound_server_LDADD += $(BLUETOOTH_API_LIBS) + +if SUPPORT_BT_SCO +sound_server_CFLAGS += $(BLUETOOTH_CFLAGS) +sound_server_LDADD += $(BLUETOOTH_LIBS) +endif if USE_PULSE sound_server_CFLAGS += -DPULSE_CLIENT $(PULSE_CFLAGS) sound_server_LDADD += $(PULSE_LIBS) endif -if USE_SECURITY -sound_server_CFLAGS += $(SECURITY_CFLAGS) -DUSE_SECURITY -sound_server_LDADD += $(SECURITY_LIBS) -endif - sound_server_DEPENDENCIES = $(srcdir)/../common/libmmfsoundcommon.la +sound_server_CFLAGS += -fPIC -pie +installsounddir = $(prefix)/share/sounds/sound-server +installsound_DATA = sounds/dock.ogg sounds/undock.ogg sounds/Tizen_HW_Touch.ogg diff --git a/server/include/asm-log.h b/server/include/asm-log.h deleted file mode 100644 index 75cf615..0000000 --- a/server/include/asm-log.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * audio-session-manager - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Jonghyuk Choi - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef __ASM_LOG_H__ -#define __ASM_LOG_H__ - -#ifdef __DEBUG_MODE__ -#include -#ifdef __USE_LOGMANAGER__ -#include -#endif -#endif - -#ifdef __DEBUG_MODE__ - -#ifdef __USE_LOGMANAGER__ -#define asm_info_r(msg, args...) log_print_rel((MMF_LOG_OWNER), (LOG_CLASS_INFO), (msg), ##args) -#define asm_warning_r(msg, args...) log_print_rel((MMF_LOG_OWNER), (LOG_CLASS_WARNING), (msg), ##args) -#define asm_error_r(msg, args...) log_print_rel((MMF_LOG_OWNER), (LOG_CLASS_ERR), (msg), ##args) -#define asm_critical_r(msg, args...) log_print_rel((MMF_LOG_OWNER), (LOG_CLASS_CRITICAL), (msg), ##args) -#define asm_assert_r(condition) log_assert_rel((condition)) - -#define asm_info(msg, args...) log_print_dbg((MMF_LOG_OWNER), LOG_CLASS_INFO, (msg), ##args) -#define asm_warning(msg, args...) log_print_dbg((MMF_LOG_OWNER), LOG_CLASS_WARNING, (msg), ##args) -#define asm_error(msg, args...) log_print_dbg((MMF_LOG_OWNER), LOG_CLASS_ERR, (msg), ##args) -#define asm_critical(msg, args...) log_print_dbg((MMF_LOG_OWNER), LOG_CLASS_CRITICAL, (msg), ##args) -#define asm_assert(condition) log_assert_dbg((condition)) - -#else //__USE_LOGMANAGER__ - -#define asm_info_r(msg, args...) fprintf(stderr, msg, ##args) -#define asm_warning_r(msg, args...) fprintf(stderr, msg, ##args) -#define asm_error_r(msg, args...) fprintf(stderr, msg, ##args) -#define asm_critical_r(msg, args...) fprintf(stderr, msg, ##args) -#define asm_assert_r(condition) (condition) - -#define asm_info(msg, args...) fprintf(stderr, msg, ##args) -#define asm_warning(msg, args...) fprintf(stderr, msg, ##args) -#define asm_error(msg, args...) fprintf(stderr, msg, ##args) -#define asm_critical(msg, args...) fprintf(stderr, msg, ##args) -#define asm_assert(condition) (condition) - -#endif //__USE_LOGMANAGER__ - -#else //__DEBUG_MODE__ - -#define asm_info_r(msg, args...) -#define asm_warning_r(msg, args...) -#define asm_error_r(msg, args...) -#define asm_critical_r(msg, args...) -#define asm_assert_r(condition) (condition) - -#define asm_info(msg, args...) -#define asm_warning(msg, args...) -#define asm_error(msg, args...) -#define asm_critical(msg, args...) -#define asm_assert(condition) (condition) - -#endif // __DEBUG_MODE__ - -#endif /* __ASM_LOG_H__ */ diff --git a/server/include/mm_sound_mgr_asm.h b/server/include/mm_sound_mgr_asm.h index b69c28a..3bd9f94 100644 --- a/server/include/mm_sound_mgr_asm.h +++ b/server/include/mm_sound_mgr_asm.h @@ -28,7 +28,7 @@ int MMSoundMgrASMInit(void); int MMSoundMgrASMFini(void); -int __asm_process_message (ASM_msg_lib_to_asm_t *asm_rcv_msg, ASM_msg_asm_to_lib_t *asm_ret_msg); +int __asm_process_message (void *asm_rcv_msg, void *asm_ret_msg); #endif /* __MM_SOUND_MGR_ASM_H__ */ diff --git a/server/include/mm_sound_mgr_codec.h b/server/include/mm_sound_mgr_codec.h index 6f230fd..549d47d 100644 --- a/server/include/mm_sound_mgr_codec.h +++ b/server/include/mm_sound_mgr_codec.h @@ -30,19 +30,21 @@ typedef struct { int repeat_count; double volume; int session_type; + int session_options; int session_handle; int keytone; void *stopcb; - int (*callback)(int, void *, void *); + int (*callback)(int, void *, void *, int); void *msgcallback; /* Client callback function */ void *msgdata; /* Client callback data */ void *param; MMSourceType *source; /* Will free plugin */ int samplerate; int channels; - int volume_table; + int volume_config; int priority; int handle_route; + bool enable_session; } mmsound_mgr_codec_param_t; enum diff --git a/server/include/mm_sound_mgr_device.h b/server/include/mm_sound_mgr_device.h index 36fa536..e5f16ec 100644 --- a/server/include/mm_sound_mgr_device.h +++ b/server/include/mm_sound_mgr_device.h @@ -24,14 +24,34 @@ #define __MM_SOUND_MGR_DEVICE_H__ #include "../include/mm_sound.h" +#include "../include/mm_sound_device.h" +#include "../include/mm_ipc.h" typedef struct { int pid; mm_sound_route route; void *callback; void *cbdata; + int device_flags; + bool need_broadcast; + char name[MM_SOUND_NAME_NUM]; } _mm_sound_mgr_device_param_t; +typedef enum +{ + DEVICE_EARJACK_TYPE_SPK_WITH_MIC = 3, +} device_earjack_type_e; + +#define DEVICE_ID_AUTO -1 + +#define DEVICE_NAME_BUILTIN_SPK "built-in speaker" +#define DEVICE_NAME_BUILTIN_RCV "built-in receiver" +#define DEVICE_NAME_BUILTIN_MIC "built-in mic" +#define DEVICE_NAME_AUDIOJACK_3P "headphone" +#define DEVICE_NAME_AUDIOJACK_4P "headset" +#define DEVICE_NAME_HDMI "hdmi" +#define DEVICE_NAME_MIRRORING "mirroring" + int _mm_sound_mgr_device_init(void); int _mm_sound_mgr_device_fini(void); int _mm_sound_mgr_device_is_route_available(const _mm_sound_mgr_device_param_t *param, bool *is_available); @@ -44,6 +64,21 @@ int _mm_sound_mgr_device_active_device_callback(mm_sound_device_in device_in, mm int _mm_sound_mgr_device_add_available_route_callback(const _mm_sound_mgr_device_param_t *param); int _mm_sound_mgr_device_remove_available_route_callback(const _mm_sound_mgr_device_param_t *param); int _mm_sound_mgr_device_available_device_callback(mm_sound_device_in device_in, mm_sound_device_out device_out, bool available); +int _mm_sound_mgr_device_get_volume_value_by_active_device(char *buf, mm_sound_device_out device_out, unsigned int *value); +int _mm_sound_mgr_device_set_volume_value_by_active_device(char *buf, mm_sound_device_out device_out, int value); +int _mm_sound_mgr_device_set_active_route_auto(void); +int _mm_sound_mgr_device_set_sound_path_for_active_device(mm_sound_device_out playback, mm_sound_device_in capture); +int _mm_sound_mgr_device_add_volume_callback(const _mm_sound_mgr_device_param_t *param); +int _mm_sound_mgr_device_remove_volume_callback(const _mm_sound_mgr_device_param_t *param); +int _mm_sound_mgr_device_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out); +int _mm_sound_mgr_device_get_current_connected_dev_list(const _mm_sound_mgr_device_param_t *param, GList **device_list); +int _mm_sound_mgr_device_add_connected_callback(const _mm_sound_mgr_device_param_t *param); +int _mm_sound_mgr_device_remove_connected_callback(const _mm_sound_mgr_device_param_t *param); +int _mm_sound_mgr_device_add_info_changed_callback(const _mm_sound_mgr_device_param_t *param); +int _mm_sound_mgr_device_remove_info_changed_callback(const _mm_sound_mgr_device_param_t *param); +int MMSoundMgrDeviceGetIoDirectionById (int id, device_io_direction_e *io_direction); +int MMSoundMgrDeviceUpdateStatus (device_update_status_e update_status, device_type_e device_type, device_io_direction_e io_direction, int id, const char* name, device_state_e state, int *alloc_id); +int MMSoundMgrDeviceUpdateStatusWithoutNotification (device_update_status_e update_status, device_type_e device_type, device_io_direction_e io_direction, int id, const char* name, device_state_e state, int *alloc_id); #endif /* __MM_SOUND_MGR_DEVICE_H__ */ diff --git a/server/include/mm_sound_mgr_device_dock.h b/server/include/mm_sound_mgr_device_dock.h new file mode 100644 index 0000000..7f53bc1 --- /dev/null +++ b/server/include/mm_sound_mgr_device_dock.h @@ -0,0 +1,41 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * 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 __MM_SOUND_MGR_DOCK_H__ +#define __MM_SOUND_MGR_DOCK_H__ + +#include "../../include/mm_ipc.h" + +typedef enum +{ + DOCK_NONE = 0, + DOCK_DESKDOCK = 1, + DOCK_CARDOCK = 2, + DOCK_AUDIODOCK = 7, + DOCK_SMARTDOCK = 8 +} DOCK_STATUS; + +int MMSoundMgrDockInit(void); +int MMSoundMgrDockFini(void); + + +#endif /* __MM_SOUND_MGR_DOCK_H__ */ + diff --git a/server/include/mm_sound_mgr_device_hdmi.h b/server/include/mm_sound_mgr_device_hdmi.h new file mode 100644 index 0000000..84d56dd --- /dev/null +++ b/server/include/mm_sound_mgr_device_hdmi.h @@ -0,0 +1,30 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * 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 __MM_SOUND_MGR_HDMI_H__ +#define __MM_SOUND_MGR_HDMI_H__ + +int MMSoundMgrHdmiInit(void); +int MMSoundMgrHdmiFini(void); + + +#endif /* __MM_SOUND_MGR_HDMI_H__ */ + diff --git a/server/include/mm_sound_mgr_device_headset.h b/server/include/mm_sound_mgr_device_headset.h new file mode 100644 index 0000000..5db2105 --- /dev/null +++ b/server/include/mm_sound_mgr_device_headset.h @@ -0,0 +1,31 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * 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 __MM_SOUND_MGR_HEADSET_H__ +#define __MM_SOUND_MGR_HEADSET_H__ + +#include "../../include/mm_ipc.h" + +int MMSoundMgrHeadsetInit(void); +int MMSoundMgrHeadsetFini(void); + +#endif /* __MM_SOUND_MGR_HEADSET_H__ */ + diff --git a/server/include/mm_sound_mgr_device_wfd.h b/server/include/mm_sound_mgr_device_wfd.h new file mode 100644 index 0000000..e4d7365 --- /dev/null +++ b/server/include/mm_sound_mgr_device_wfd.h @@ -0,0 +1,30 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * 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 __MM_SOUND_MGR_WFD_H__ +#define __MM_SOUND_MGR_WFD_H__ + +int MMSoundMgrWfdInit(void); +int MMSoundMgrWfdFini(void); + + +#endif /* __MM_SOUND_MGR_WFD_H__ */ + diff --git a/server/include/mm_sound_mgr_dock.h b/server/include/mm_sound_mgr_dock.h deleted file mode 100644 index 387fdfd..0000000 --- a/server/include/mm_sound_mgr_dock.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * libmm-sound - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Seungbae Shin - * - * 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 __MM_SOUND_MGR_DOCK_H__ -#define __MM_SOUND_MGR_DOCK_H__ - -#include "../../include/mm_ipc.h" - -int MMSoundMgrDockInit(void); -int MMSoundMgrDockFini(void); - - -#endif /* __MM_SOUND_MGR_DOCK_H__ */ - diff --git a/server/include/mm_sound_mgr_headset.h b/server/include/mm_sound_mgr_headset.h deleted file mode 100644 index 26c519d..0000000 --- a/server/include/mm_sound_mgr_headset.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * libmm-sound - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Seungbae Shin - * - * 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 __MM_SOUND_MGR_HEADSET_H__ -#define __MM_SOUND_MGR_HEADSET_H__ - -#include "../../include/mm_ipc.h" - -int MMSoundMgrHeadsetInit(void); -int MMSoundMgrHeadsetFini(void); -int MMSoundMgrHeadsetGetType (int *type); - - -#endif /* __MM_SOUND_MGR_HEADSET_H__ */ - diff --git a/server/include/mm_sound_mgr_ipc.h b/server/include/mm_sound_mgr_ipc.h index 9d86817..d087b6e 100644 --- a/server/include/mm_sound_mgr_ipc.h +++ b/server/include/mm_sound_mgr_ipc.h @@ -32,11 +32,16 @@ do { \ sound_msg.msgid = x_msgid; \ } while(0) +#define FREEZE_COMMAND_EXCLUDE "exclude" +#define FREEZE_COMMAND_INCLUDE "include" +#define FREEZE_COMMAND_WAKEUP "wakeup" + int MMSoundMgrIpcInit(void); int MMSoundMgrIpcFini(void); int MMSoundMgrIpcReady(void); int _MMIpcCBSndMsg(mm_ipc_msg_t *msg); +int __mm_sound_mgr_ipc_freeze_send (char* command, int pid); #endif /* __MM_SOUND_MGR_H__ */ diff --git a/server/include/mm_sound_mgr_pulse.h b/server/include/mm_sound_mgr_pulse.h old mode 100644 new mode 100755 index e6a19c4..5a9bf75 --- a/server/include/mm_sound_mgr_pulse.h +++ b/server/include/mm_sound_mgr_pulse.h @@ -24,17 +24,42 @@ #include "../../include/mm_ipc.h" +#include "mm_sound_mgr_session.h" void* MMSoundMgrPulseInit(void); int MMSoundMgrPulseFini(void* handle); -void MMSoundMgrPulseSetDefaultSink (char* default_sink_name); +void MMSoundMgrPulseSetUSBDefaultSink (int usb_device); +void MMSoundMgrPulseSetDefaultSink (char* device_api_name, char* device_bus_name); +void MMSoundMgrPulseSetDefaultSinkByName (char* name); +void MMSoundMgrPulseSetSourcemutebyname (char* sourcename, int mute); int MMSoundMgrPulseHandleRegisterMonoAudio (void* pinfo); +int MMSoundMgrPulseHandleRegisterAudioBalance (void* pinfo); int MMSoundMgrPulseHandleRegisterBluetoothStatus (void* pinfo); +int MMSoundMgrPulseHandleRegisterSurroundSoundStatus(void *pinfo); int MMSoundMgrPulseHandleIsBtA2DPOnReq (mm_ipc_msg_t *msg, int (*sendfunc)(mm_ipc_msg_t*)); void MMSoundMgrPulseGetInitialBTStatus (bool *a2dp, bool *sco); +int MMSoundMgrPulseGetBluetoothInfo(bool* is_nrec, int* bandwidth); + +void MMSoundMgrPulseUpdateBluetoothAGCodec (void); +bool MMSoundMgrPulseBTSCONRECStatus(void); +bool MMSoundMgrPulseBTSCOWBStatus(void); + +void MMSoundMgrPulseSetSession(session_t session, session_state_t state); +void MMSoundMgrPulseSetSubsession(subsession_t subsession, int subsession_opt); +void MMSoundMgrPulseSetActiveDevice(mm_sound_device_in device_in, mm_sound_device_out device_out); +void MMSoundMgrPulseUpdateVolume(void); + +void MMSoundMgrPulseSetCorkAll (bool cork); +void MMSoundMgrPulseUnLoadHDMI(); +void MMSoundMgrPulseGetPathInfo(mm_sound_device_out *device_out, mm_sound_device_in *device_in); +#ifdef TIZEN_MICRO +void MMSoundMgrPulseSetMuteall(int mute); +void MMSoundMgrPulseSetVolumeLevel(volume_type_t volume_type, unsigned int volume_level); +#endif +void MMSoundMgrPulseSetVoicecontrolState (bool state); #endif /* __MM_SOUND_MGR_PULSE_H__ */ diff --git a/server/include/mm_sound_mgr_session.h b/server/include/mm_sound_mgr_session.h old mode 100644 new mode 100755 index 1ca8fed..afca283 --- a/server/include/mm_sound_mgr_session.h +++ b/server/include/mm_sound_mgr_session.h @@ -39,21 +39,32 @@ typedef enum AVAILABLE, } device_status_t; +/* MMSoundMgrPulseSetSession & pa_tizen_session_t should be updated for PA */ typedef enum { SESSION_MEDIA = 0, SESSION_VOICECALL, + SESSION_VIDEOCALL, SESSION_VOIP, SESSION_FMRADIO, SESSION_NOTIFICATION, + SESSION_ALARM, + SESSION_EMERGENCY, + SESSION_VOICE_RECOGNITION, SESSION_NUM } session_t; +/* MMSoundMgrPulseSetSubsession & pa_tizen_subsession_t should be updated for PA */ typedef enum { SUBSESSION_VOICE = 0, SUBSESSION_RINGTONE, SUBSESSION_MEDIA, + SUBSESSION_INIT, + SUBSESSION_VR_NORMAL, + SUBSESSION_VR_DRIVE, + SUBSESSION_RECORD_STEREO, + SUBSESSION_RECORD_MONO, SUBSESSION_NUM } subsession_t; @@ -64,13 +75,35 @@ typedef enum DEVICE_BT_A2DP, DEVICE_BT_SCO, DEVICE_DOCK, + DEVICE_HDMI, + DEVICE_MIRRORING, + DEVICE_USB_AUDIO, + DEVICE_MULTIMEDIA_DOCK, } device_type_t; +enum mm_sound_audio_mute_t { + MM_SOUND_AUDIO_UNMUTE = 0, /**< Unmute state */ + MM_SOUND_AUDIO_MUTE, /**< Mute state */ +}; + +#ifdef TIZEN_MICRO +enum mm_sound_bandwidth { + MM_SOUND_BANDWIDTH_UNKNOWN = 0, + MM_SOUND_BANDWIDTH_NB = 1, + MM_SOUND_BANDWIDTH_WB = 2, +}; + +enum mm_sound_hfp_connection_state { + MM_SOUND_HFP_STATUS_UNKNOWN = 0, + MM_SOUND_HFP_STATUS_INCOMMING_CALL = 1, /* ringtone */ +}; +#endif + int MMSoundMgrSessionInit(void); int MMSoundMgrSessionFini(void); /* called by mgr headset, pulse */ -int MMSoundMgrSessionSetDeviceAvailable (device_type_t device, int available, int type, char* name); +int MMSoundMgrSessionSetDeviceAvailable (device_type_t device, int available, int type, const char* name); int MMSoundMgrSessionIsDeviceAvailable (mm_sound_device_out playback, mm_sound_device_in capture, bool *available); @@ -78,20 +111,34 @@ int MMSoundMgrSessionIsDeviceAvailableNoLock (mm_sound_device_out playback, mm_s int MMSoundMgrSessionGetAvailableDevices (int *playback, int *capture); -int MMSoundMgrSessionSetDeviceActive (mm_sound_device_out playback, mm_sound_device_in capture); +int MMSoundMgrSessionSetDeviceActive (mm_sound_device_out playback, mm_sound_device_in capture, bool need_broadcast); int MMSoundMgrSessionGetDeviceActive (mm_sound_device_out *playback, mm_sound_device_in *capture); int MMSoundMgrSessionSetSession(session_t session, session_state_t state); /* called by mgr_asm */ int MMSoundMgrSessionGetSession(session_t *session); -int MMSoundMgrSessionSetSubSession(subsession_t subsession); /* called by mgr_asm */ +int MMSoundMgrSessionSetSubSession(subsession_t subsession, int subsession_opt); /* called by mgr_asm */ int MMSoundMgrSessionGetSubSession(subsession_t *subsession); char* MMSoundMgrSessionGetBtA2DPName (); -int MMSoundMgrSessionSetDefaultSink (char *default_sink_name); +int MMSoundMgrSessionSetDefaultSink (const char * const default_sink_name); int MMSoundMgrSessionSCOChanged (bool connected); +void MMSoundMgrSessionSetVoiceControlState (bool enable); +bool MMSoundMgrSessionGetVoiceControlState (); +int MMSoundMgrSessionSetSCO (bool is_sco_on, bool is_bt_nrec, bool is_bt_wb); +int MMSoundMgrSessionSetDeviceActiveAuto (void); +int MMSoundMgrSessionSetSoundPathForActiveDevice (mm_sound_device_out playback, mm_sound_device_in capture); + +#ifdef TIZEN_MICRO +int MMSoundMgrSessionEnableAgSCO (bool enable); +int MMSoundMgrSessionSetHFBandwidth (int bandwidth); +int MMSoundMgrSessionSetHFState (int stat); +int MMSoundMgrSessionMediaPause(); +int MMSoundMgrSessionSetDuplicateSubSession(void); +const char* MMSoundMgrSessionGetSessionString(session_t session); +#endif #endif /* __MM_SOUND_MGR_SESSION_H__ */ diff --git a/server/include/mm_sound_plugin_codec.h b/server/include/mm_sound_plugin_codec.h index 7bee996..8248165 100644 --- a/server/include/mm_sound_plugin_codec.h +++ b/server/include/mm_sound_plugin_codec.h @@ -29,6 +29,7 @@ enum MMSoundSupportedCodec { MM_SOUND_SUPPORTED_CODEC_INVALID = -1, /**< Invalid codec type */ MM_SOUND_SUPPORTED_CODEC_WAVE, /**< WAVE codec */ + MM_SOUND_SUPPORTED_CODEC_OGG, /**< OGG codec */ MM_SOUND_SUPPORTED_CODEC_DTMF, /**< DTMF codec */ MM_SOUND_SUPPORTED_CODEC_MP3, /**< MP3 codec */ MM_SOUND_SUPPORTED_CODEC_NUM, /**< Number of audio codec type */ @@ -41,6 +42,7 @@ typedef struct { int format; int doffset; int size; + int duration; /**the wav file play duration, Unit: ms*/ } mmsound_codec_info_t; typedef struct { @@ -51,10 +53,11 @@ typedef struct { int repeat_count; double volume; int priority; - int volume_table; + int volume_config; int keytone; MMSourceType *source; int handle_route; + pthread_mutex_t *codec_wave_mutex; } mmsound_codec_param_t; typedef struct { diff --git a/server/include/mm_sound_recovery.h b/server/include/mm_sound_recovery.h deleted file mode 100644 index 34d5f37..0000000 --- a/server/include/mm_sound_recovery.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * libmm-sound - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Seungbae Shin - * - * 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 MM_SOUND_RECOVERY_H_ -#define MM_SOUND_RECOVERY_H_ - - - -int sound_system_bootup_recovery(); - -#endif /* MM_SOUND_RECOVERY_H_ */ diff --git a/server/mm_sound_mgr_asm.c b/server/mm_sound_mgr_asm.c index 2ae3921..e2057e7 100644 --- a/server/mm_sound_mgr_asm.c +++ b/server/mm_sound_mgr_asm.c @@ -33,23 +33,19 @@ #include #include "include/mm_sound_mgr_common.h" +#include "include/mm_sound_thread_pool.h" #include "../include/mm_sound_common.h" #include #include - -#include - #include "include/mm_sound_mgr_asm.h" #include "include/mm_sound_mgr_session.h" +#include "include/mm_sound_mgr_ipc.h" +#include "../include/mm_sound_utils.h" pthread_mutex_t g_mutex_asm = PTHREAD_MUTEX_INITIALIZER; - - - - /******************************* ASM Code **********************************/ #include @@ -70,101 +66,170 @@ pthread_mutex_t g_mutex_asm = PTHREAD_MUTEX_INITIALIZER; #include #include -#include #include #include -#include -#ifdef USE_SECURITY -#include -#endif +#define USE_SYSTEM_SERVER_PROCESS_MONITORING -#include +#define ROW_NUM_OF_SUB_EVENT 12 /* it should be exactly same with number of ASM_CASE_SUB_EVENT in ASM_sound_case table */ +#define NUM_OF_ADV_ASM_EVENT 3 -#define USE_SYSTEM_SERVER_PROCESS_MONITORING +#define SERVER_HANDLE_MAX_COUNT 256 + +/* check whether if it is advanced event type */ +#define ASM_IS_ADVANCED_ASM_EVENT(x_sound_event) (x_sound_event == ASM_EVENT_VOICE_RECOGNITION || x_sound_event == ASM_EVENT_MMCAMCORDER_AUDIO || x_sound_event == ASM_EVENT_MMCAMCORDER_VIDEO) + +static const ASM_sound_cases_t ASM_sound_case[ASM_EVENT_MAX][ASM_EVENT_MAX] = +{ + /* + 0 == ASM_CASE_NONE + 1 == ASM_CASE_1PLAY_2STOP + 2 == ASM_CASE_1STOP_2PLAY + 3 == ASM_CASE_1PAUSE_2PLAY + 4 == ASM_CASE_1PLAY_2PLAY_MIX + 5 == ASM_CASE_RESOURCE_CHECK + 6 == ASM_CASE_SUB_EVENT + */ + /* MP MC MS MO MF MW NT AL EU CL VC VO MT EM ER VR CA CV */ + { 4, 4, 4, 4, 3, 4, 3, 3, 3, 3, 3, 3, 4, 3, 5, 6, 6, 6}, /* 00 Media MMPlayer */ + { 4, 4, 4, 4, 4, 4, 4, 3, 4, 3, 3, 3, 4, 3, 5, 6, 6, 6}, /* 01 Media MMCamcorder */ + { 4, 4, 4, 4, 3, 4, 3, 3, 2, 3, 3, 3, 4, 3, 5, 6, 6, 6}, /* 02 Media MMSound */ + { 4, 4, 4, 4, 3, 4, 3, 3, 4, 3, 3, 3, 4, 3, 5, 6, 6, 6}, /* 03 Media OpenAL */ + { 3, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 5, 6, 6, 6}, /* 04 Media FMradio */ + { 4, 4, 4, 4, 3, 4, 3, 3, 3, 3, 3, 3, 4, 3, 5, 6, 6, 6}, /* 05 Media Webkit */ + + { 4, 4, 4, 4, 4, 4, 4, 2, 4, 2, 2, 2, 4, 2, 5, 4, 4, 4}, /* 06 Notify */ + { 1, 1, 1, 1, 1, 1, 4, 4, 4, 2, 2, 2, 4, 2, 5, 1, 1, 1}, /* 07 Alarm */ + { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4}, /* 08 Earjack Unplug */ + + { 1, 1, 1, 1, 1, 1, 1, 4, 4, 1, 1, 1, 4, 1, 5, 1, 6, 6}, /* 09 Call */ + { 1, 1, 1, 1, 1, 1, 1, 4, 4, 1, 1, 1, 4, 1, 5, 1, 6, 1}, /* 10 Video Call */ + { 1, 1, 1, 1, 1, 1, 1, 4, 4, 2, 2, 2, 4, 1, 5, 1, 6, 1}, /* 11 VOIP */ + + { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4}, /* 12 Monitor */ + { 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 4, 2, 5, 1, 1, 1}, /* 13 Emergency */ + { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, /* 14 Exclusive Resource */ + + { 6, 6, 6, 6, 6, 6, 4, 2, 4, 2, 2, 2, 4, 2, 5, 6, 6, 6}, /* 15 Voice Recognition */ + { 6, 6, 6, 6, 6, 6, 6, 2, 4, 4, 2, 2, 4, 2, 5, 6, 6, 6}, /* 16 MMCamcorder Audio */ + { 6, 6, 6, 6, 6, 6, 6, 2, 4, 2, 2, 2, 4, 2, 5, 6, 6, 2}, /* 17 MMCamcorder Video */ + +}; + +static const ASM_sound_cases_t ASM_sound_case_sub[NUM_OF_ADV_ASM_EVENT][ASM_SUB_EVENT_MAX][ROW_NUM_OF_SUB_EVENT] = +{ + /* + 0 == ASM_CASE_NONE + 1 == ASM_CASE_1PLAY_2STOP + 2 == ASM_CASE_1STOP_2PLAY + 3 == ASM_CASE_1PAUSE_2PLAY + 4 == ASM_CASE_1PLAY_2PLAY_MIX + 5 == ASM_CASE_RESOURCE_CHECK + 6 == ASM_CASE_SUB_EVENT + */ + /* MP MC MS MO MF MW NT CL ER VR CA CV <== Current playing event */ + {{ 4, 4, 4, 4, 4, 4, 4, 4, 5, 2, 6, 6 }, /* Voice Recognition - SH */ + { 3, 3, 3, 3, 2, 3, 4, 1, 5, 2, 2, 2 }},/* Voice Recognition - EX */ + + {{ 4, 4, 4, 4, 4, 4, 4, 4, 5, 2, 2, 2 }, /* MMCamcorder Audio - SH */ + { 3, 3, 3, 3, 2, 3, 4, 1, 5, 6, 2, 2 }},/* MMCamcorder Audio - EX */ -#define SUPPORT_GCF /* currently in use */ - -static const ASM_sound_cases_t ASM_sound_case[ASM_PRIORITY_MATRIX_MIN+1][ASM_PRIORITY_MATRIX_MIN+1] = -{ - /* SP SC SS SO SA, EP EC ES EO EA, N C SF EF EU, A VC M RC*/ - { 8, 8, 8, 8, 8, 6, 6, 6, 6, 6, 8, 8, 8, 6, 6, 6, 6, 8, 8 }, /* 00 Shared MMPlayer */ - { 8, 8, 8, 8, 8, 5, 5, 5, 5, 5, 8, 5, 8, 5, 8, 5, 5, 8, 5}, /* 01 Shared MMCamcorder */ - { 8, 8, 8, 8, 8, 5, 5, 5, 5, 5, 8, 5, 8, 5, 5, 5, 5, 8, 5}, /* 02 Shared MMSound */ - { 8, 8, 8, 8, 8, 5, 5, 5, 5, 5, 8, 5, 8, 5, 6, 5, 5, 8, 5}, /* 03 Shared OpenAL */ - { 8, 8, 8, 8, 8, 5, 5, 5, 5, 5, 8, 5, 8, 5, 8, 5, 5, 8, 5}, /* 04 Shared AVsystem */ - { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 8, 6, 6, 6, 6, 6, 8, 8}, /* 05 Exclusive MMPlayer */ - { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 8, 5, 5, 5, 8, 5, 5 ,8, 5}, /* 06 Exclusive MMCamcorder */ - { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 8, 5, 5, 5, 5, 5, 5, 8, 5}, /* 07 Exclusive MMSound */ - { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 8, 5, 5, 5, 6, 5, 5, 8, 5}, /* 08 Exclusive OpenAL */ - { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 8, 5, 5, 5, 8, 5, 5, 8, 5}, /* 09 Exclusive AVsystem */ - { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 5, 8, 8, 8, 5, 5, 8, 5}, /* 10 Notify */ - { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8, 0, 1, 1, 8, 8, 1, 8, 0}, /* 11 Call */ - { 8, 8, 8, 8, 8, 5, 5, 5, 5, 5, 8, 5, 5, 5, 5, 5, 5, 8, 5}, /* 12 Shared FMradio */ - { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 8, 5, 5, 5, 5, 5, 5, 8, 5}, /* 13 Exclusive FMradio */ - { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}, /* 14 Earjack Unplug */ - { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8, 5, 1, 1, 8, 8, 5, 8, 5}, /* 15 Alarm */ - { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8, 1, 1, 1, 8, 8, 0, 8, 1}, /* 16 Video Call */ - { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}, /* 17 Monitor */ - { 1, 8, 1, 1, 1, 1, 1, 1, 1, 1, 8, 0, 1, 1, 8, 8, 1, 8, 0}, /* 18 Rich Call */ + {{ 4, 4, 4, 4, 4, 4, 4, 4, 5, 6, 2, 2 }, /* MMCamcorder Video - SH */ + { 3, 3, 3, 3, 2, 3, 4, 1, 5, 2, 2, 2 }} /* MMCamcorder Video - EX */ }; +typedef struct _paused_by_id +{ + int pid; + int sound_handle; + ASM_event_sources_t eventsrc; +} asm_paused_by_id_t; + +typedef struct asm_subsession_option +{ + int pid; + ASM_resource_t resource; +} asm_subsession_option_t; + typedef struct _list { - long int instance_id; - int sound_handle; - ASM_sound_events_t sound_event; - ASM_sound_states_t sound_state; + int instance_id; /* pid */ + int sound_handle; /* unique id */ + ASM_sound_events_t sound_event; + ASM_sound_sub_events_t sound_sub_event; + ASM_sound_states_t sound_state; + ASM_sound_states_t prev_sound_state; ASM_resume_states_t need_resume; ASM_resource_t mm_resource; + asm_paused_by_id_t paused_by_id; + int option_flags; + asm_subsession_option_t option; unsigned short monitor_active; unsigned short monitor_dirty; + bool is_registered_for_watching; struct _list *next; } asm_instance_list_t; -asm_instance_list_t *head_list, *tail_list; +asm_instance_list_t *head_list_ptr = NULL; +asm_instance_list_t *tail_list_ptr = NULL; + +typedef struct handle_info +{ + int is_registered; + int option_flags; + ASM_resource_t resource; +}handle_info; + +/* struct array for fast access information */ +handle_info g_handle_info[SERVER_HANDLE_MAX_COUNT]; + +typedef struct asm_compare_result +{ + int previous_num_of_changes; + int incoming_num_of_changes; + asm_instance_list_t* previous_asm_handle[SERVER_HANDLE_MAX_COUNT]; + asm_instance_list_t* incoming_asm_handle[SERVER_HANDLE_MAX_COUNT]; +} asm_compare_result_t; int asm_snd_msgid; int asm_rcv_msgid; int asm_cb_msgid; -//ASM_msg_lib_to_asm_t asm_rcv_msg; -//ASM_msg_asm_to_lib_t asm_snd_msg; -//ASM_msg_asm_to_cb_t asm_cb_msg; bool asm_is_send_msg_to_cb = false; -#ifdef SUPPORT_GCF -#define GCF_DEFAULT 0 -int is_gcf = GCF_DEFAULT; -#endif - unsigned int g_sound_status_pause = 0; unsigned int g_sound_status_playing = 0; +unsigned int g_sound_status_waiting = 0; +int g_session_ref_count = 0; -#define SERVER_HANDLE_MAX_COUNT 256 - -static const char* ASM_sound_events_str[] = -{ - "SHARE_MMPLAYER", - "SHARE_MMCAMCORDER", - "SHARE_MMSOUND", - "SHARE_OPENAL", - "SHARE_AVSYSTEM", - "EXCLUSIVE_MMPLAYER", - "EXCLUSIVE_MMCAMCORDER", - "EXCLUSIVE_MMSOUND", - "EXCLUSIVE_OPENAL", - "EXCLUSIVE_AVSYSTEM", +static const char* ASM_sound_event_str[] = +{ + "MEDIA_MMPLAYER", + "MEDIA_MMCAMCORDER", + "MEDIA_MMSOUND", + "MEDIA_OPENAL", + "MEDIA_FMRADIO", + "MEDIA_WEBKIT", "NOTIFY", - "CALL", - "SHARE_FMRADIO", - "EXCLUSIVE_FMRADIO", - "EARJACK_UNPLUG", "ALARM", + "EARJACK_UNPLUG", + "CALL", "VIDEOCALL", + "VOIP", "MONITOR", - "RICH_CALL" + "EMERGENCY", + "EXCLUSIVE_RESOURCE", + "VOICE_RECOGNITION", + "MMCAMCORDER_AUDIO", + "MMCAMCORDER_VIDEO" +}; + +static const char* ASM_sound_sub_event_str[] = +{ + "SUB_EVENT_NONE", + "SUB_EVENT_SHARE", + "SUB_EVENT_EXCLUSIVE" }; static const char* ASM_sound_state_str[] = @@ -174,8 +239,6 @@ static const char* ASM_sound_state_str[] = "STATE_WAITING", "STATE_STOP", "STATE_PAUSE", - "STATE_PAUSE_BY_APP", - "STATE_ALTER_PLAYING" }; @@ -189,27 +252,32 @@ static const char* ASM_sound_request_str[] = "REQUEST_EMEGENT_EXIT", "REQUEST_DUMP", "REQUEST_SET_SUBSESSION", - "REQUEST_GET_SUBSESSION" + "REQUEST_GET_SUBSESSION", + "REQUEST_REGISTER_WATCHER", + "REQUEST_UNREGISTER_WATCHER", + "REQUEST_SET_SUBEVENT", + "REQUEST_GET_SUBEVENT", + "REQUEST_RESET_RESUME_TAG", + "REQUEST_SET_SESSION_OPTIONS", + "REQUEST_GET_SESSION_OPTIONS" }; -static const char* ASM_sound_cases_str[] = +static const char* ASM_sound_case_str[] = { "CASE_NONE", "CASE_1PLAY_2STOP", - "CASE_1PLAY_2ALTER_PLAY", - "CASE_1PLAY_2WAIT", - "CASE_1ALTER_PLAY_2PLAY", "CASE_1STOP_2PLAY", "CASE_1PAUSE_2PLAY", - "CASE_1VIRTUAL_2PLAY", - "CASE_1PLAY_2PLAY_MIX" + "CASE_1PLAY_2PLAY_MIX", + "CASE_RESOURCE_CHECK", + "CASE_SUB_EVENT", }; static const char* ASM_sound_resume_str[] = { - "NO-RESUME", - "RESUME" + "NO-RESUME", + "RESUME" }; @@ -220,25 +288,115 @@ static const char* ASM_sound_command_str[] = "CMD_PLAY", "CMD_STOP", "CMD_PAUSE", - "CMD_RESUME", + "CMD_RESUME" }; static char *subsession_str[] = { "VOICE", "RINGTONE", - "MEDIA" + "MEDIA", + "VOICE_ANSWER_PLAY", + "VOICE_ANSWER_REC", + "VOICE_CALL_FORWARDING", + "INIT", + "VR_NORMAL", + "VR_DRIVE", + "RECORD_STEREO", + "RECORD_STEREO_INTERVIEW", + "RECORD_STEREO_CONVERSATION", + "RECORD_MONO", +}; + +static char *subevent_str[] = +{ + "SUB_EVENT_NONE", + "SUB_EVENT_SHARE", + "SUB_EVENT_EXCLUSIVE" }; -#define ASM_SND_MSG_SET(asm_snd_msg, x_alloc_handle, x_cmd_handle, x_result_sound_command, x_result_sound_state) \ +#define ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, x_instance_id, x_alloc_handle, x_cmd_handle, x_source_request_id) \ +do { \ + asm_snd_msg.instance_id = x_instance_id; \ + asm_snd_msg.data.alloc_handle = x_alloc_handle; \ + asm_snd_msg.data.cmd_handle = x_cmd_handle; \ + asm_snd_msg.data.source_request_id = x_source_request_id; \ +} while (0) + +#define ASM_SND_MSG_SET_RESULT(asm_snd_msg, x_result_sound_command, x_result_sound_state) \ +do { \ + asm_snd_msg->data.result_sound_command = x_result_sound_command; \ + asm_snd_msg->data.result_sound_state = x_result_sound_state; \ +} while (0) + +/* reference count of session */ +#define SESSION_REF(x_cur_session) \ +do { \ + g_session_ref_count++; \ + debug_log("session ref.count is increased:%d (by cur_session(%d))", g_session_ref_count, x_cur_session); \ +} while (0) + +#define SESSION_UNREF(x_cur_session) \ +do { \ + g_session_ref_count--; \ + debug_log("session ref.count is decreased:%d (by cur_session(%d))", g_session_ref_count, x_cur_session); \ +} while (0) + +#define SESSION_REF_INIT() \ +do { \ + g_session_ref_count = 0; \ + debug_log("session ref.count is initialized:%d", g_session_ref_count); \ +} while (0) + +#define IS_ON_GOING_SESSION() (g_session_ref_count > 0) + +/* execute watch callback */ +#define ASM_DO_WATCH_CALLBACK(x_interest_event, x_interest_state) \ +do { \ + if (__do_watch_callback(x_interest_event, x_interest_state)) { \ + debug_error(" oops! failed to _do_watch_callback(%d, %d)\n", x_interest_event, x_interest_state); \ + } \ +} while (0) + +/* execute monitor callback */ +#define ASM_DO_MONITOR_CALLBACK(x_current_instance_id, x_monitor_handle, x_asm_command, x_event_src) \ +do { \ + int cb_res = 0; \ + if (__find_clean_monitor_handle(x_current_instance_id, &x_monitor_handle)) { \ + cb_res = __do_callback(x_current_instance_id, x_monitor_handle, x_asm_command, x_event_src); \ + debug_warning(" send stop callback for monitor handle of pid %d\n", x_current_instance_id); \ + if (cb_res != ASM_CB_RES_NONE && cb_res != ASM_CB_RES_STOP) { \ + debug_error(" oops! not suspected callback result %d\n", cb_res); \ + } \ + __set_monitor_dirty(x_current_instance_id); \ + } \ +} while (0) + +/* execute watch callback from result structure */ +#define ASM_DO_WATCH_CALLBACK_FROM_RESULT(x_compare_result) \ do { \ - asm_snd_msg->data.alloc_handle = x_alloc_handle; \ - asm_snd_msg->data.cmd_handle = x_cmd_handle; \ - asm_snd_msg->data.result_sound_command = x_result_sound_command; \ - asm_snd_msg->data.result_sound_state = x_result_sound_state; \ + while(x_compare_result.incoming_num_of_changes--) { \ + ASM_DO_WATCH_CALLBACK(x_compare_result.incoming_asm_handle[x_compare_result.incoming_num_of_changes]->sound_event, x_compare_result.incoming_asm_handle[x_compare_result.incoming_num_of_changes]->sound_state); \ + } \ + while(x_compare_result.previous_num_of_changes--) { \ + ASM_DO_WATCH_CALLBACK(x_compare_result.previous_asm_handle[x_compare_result.previous_num_of_changes]->sound_event, x_compare_result.previous_asm_handle[x_compare_result.previous_num_of_changes]->sound_state); \ + } \ } while (0) -void selectSleep(int secs) +/* check whether if it needs to be resumed later */ +#define ASM_CHECK_RESUME(x_sound_event, x_resource, x_current_sound_event, x_current_instance_id, x_current_state, x_current_handle, x_paused_by_pid, x_paused_by_sound_handle, x_paused_by_eventsrc) \ +do { \ + if ( __is_need_resume(x_sound_event, x_resource, x_current_sound_event, x_current_handle) && (x_current_state == ASM_STATE_PLAYING || x_current_state == ASM_STATE_WAITING) ) { \ + __asm_change_need_resume_list(x_current_instance_id, x_current_handle, ASM_NEED_RESUME, x_paused_by_pid, x_paused_by_sound_handle, x_paused_by_eventsrc); \ + } \ +} while (0) + +/* defines for special cases */ +subsession_t g_camcorder_ex_subsession = SUBSESSION_NUM; + +#define MAX_WATCH_CALLBACK_CALCUL_NUM 128 + +void ___select_sleep(int secs) { struct timeval timeout; timeout.tv_sec = (secs < 1 || secs > 10) ? 3 : secs; @@ -247,30 +405,259 @@ void selectSleep(int secs) return; } -gboolean __is_need_resume (ASM_sound_events_t sound_event) +int __get_adv_event_idx_for_subtable(ASM_sound_events_t sound_event, int *index) +{ + int ret = MM_ERROR_NONE; + if (!index) { + debug_error("index is null"); + return MM_ERROR_INVALID_ARGUMENT; + } + + switch (sound_event) { + case ASM_EVENT_VOICE_RECOGNITION: + *index = 0; + break; + case ASM_EVENT_MMCAMCORDER_AUDIO: + *index = 1; + break; + case ASM_EVENT_MMCAMCORDER_VIDEO: + *index = 2; + break; + default: + debug_error("Not supported advanced sound_type(%d) for subtable", sound_event); + ret = MM_ERROR_SOUND_INTERNAL; + break; + } + + return ret; +} + +int __get_sub_case_table_idx(ASM_sound_events_t sound_event, int *index) +{ + int ret = MM_ERROR_NONE; + if (!index) { + debug_error("index is null"); + return MM_ERROR_INVALID_ARGUMENT; + } + + switch (sound_event) { + case ASM_EVENT_MEDIA_MMPLAYER: + case ASM_EVENT_MEDIA_MMCAMCORDER: + case ASM_EVENT_MEDIA_MMSOUND: + case ASM_EVENT_MEDIA_OPENAL: + case ASM_EVENT_MEDIA_FMRADIO: + case ASM_EVENT_MEDIA_WEBKIT: + case ASM_EVENT_NOTIFY: + *index = sound_event; + break; + case ASM_EVENT_CALL: + case ASM_EVENT_VIDEOCALL: + case ASM_EVENT_VOIP: + *index = ASM_EVENT_NOTIFY + 1; + break; + case ASM_EVENT_EXCLUSIVE_RESOURCE: + *index = ASM_EVENT_NOTIFY + 2; + break; + case ASM_EVENT_VOICE_RECOGNITION: + *index = ASM_EVENT_NOTIFY + 3; + break; + case ASM_EVENT_MMCAMCORDER_AUDIO: + *index = ASM_EVENT_NOTIFY + 4; + break; + case ASM_EVENT_MMCAMCORDER_VIDEO: + *index = ASM_EVENT_NOTIFY + 5; + break; + default: + debug_error("Not supported sound_type(%d) for subtable index", sound_event); + ret = MM_ERROR_SOUND_INTERNAL; + break; + } + + return ret; +} + +gboolean __is_media_session (ASM_sound_events_t sound_event) { gboolean result = FALSE; - switch (sound_event) - { + switch (sound_event) { + case ASM_EVENT_MEDIA_MMPLAYER: + case ASM_EVENT_MEDIA_MMCAMCORDER: + case ASM_EVENT_MEDIA_MMSOUND: + case ASM_EVENT_MEDIA_OPENAL: + case ASM_EVENT_MEDIA_FMRADIO: + case ASM_EVENT_MEDIA_WEBKIT: + result = TRUE; + break; + default: + break; + } + return result; +} + +ASM_event_sources_t __mapping_sound_event_to_event_src(ASM_sound_events_t sound_event, ASM_resource_t resource, ASM_sound_cases_t sound_case) +{ + ASM_event_sources_t event_src = ASM_EVENT_SOURCE_MEDIA; + + switch (sound_event) { + case ASM_EVENT_CALL: + case ASM_EVENT_VIDEOCALL: + case ASM_EVENT_VOIP: + event_src = ASM_EVENT_SOURCE_CALL_START; + break; + + case ASM_EVENT_EARJACK_UNPLUG: + event_src = ASM_EVENT_SOURCE_EARJACK_UNPLUG; + break; + + case ASM_EVENT_ALARM: + event_src = ASM_EVENT_SOURCE_ALARM_START; + break; + + case ASM_EVENT_EMERGENCY: + event_src = ASM_EVENT_SOURCE_EMERGENCY_START; + break; + + case ASM_EVENT_NOTIFY: + event_src = ASM_EVENT_SOURCE_NOTIFY_START; + break; + + case ASM_EVENT_MMCAMCORDER_AUDIO: + case ASM_EVENT_MMCAMCORDER_VIDEO: + event_src = ASM_EVENT_SOURCE_MEDIA; + break; + + case ASM_EVENT_MEDIA_MMPLAYER: + event_src = ASM_EVENT_SOURCE_OTHER_PLAYER_APP; + break; + + default: + event_src = ASM_EVENT_SOURCE_MEDIA; + break; + } + + return event_src; +} + +ASM_event_sources_t __convert_eventsrc_interrupted_to_completed(ASM_event_sources_t eventsrc) +{ + ASM_event_sources_t completed_eventsrc = ASM_EVENT_SOURCE_MEDIA; + + switch(eventsrc) { + case ASM_EVENT_SOURCE_CALL_START: + completed_eventsrc = ASM_EVENT_SOURCE_CALL_END; + break; + case ASM_EVENT_SOURCE_ALARM_START: + completed_eventsrc = ASM_EVENT_SOURCE_ALARM_END; + break; + case ASM_EVENT_SOURCE_EMERGENCY_START: + completed_eventsrc = ASM_EVENT_SOURCE_EMERGENCY_END; + break; + case ASM_EVENT_SOURCE_NOTIFY_START: + completed_eventsrc = ASM_EVENT_SOURCE_NOTIFY_END; + break; + default: + completed_eventsrc = eventsrc; + break; + } + debug_warning(" completed EventSrc[%d]", completed_eventsrc); + return completed_eventsrc; +} + +gboolean __is_valid_session_options(ASM_sound_events_t sound_event, int option_flags, int *error_code) +{ + gboolean result = true; + *error_code = ERR_ASM_ERROR_NONE; + + /* Check if those flags are valid according to sound_event */ + switch (sound_event) { + case ASM_EVENT_MEDIA_MMPLAYER: + case ASM_EVENT_MEDIA_MMCAMCORDER: + case ASM_EVENT_MEDIA_MMSOUND: + case ASM_EVENT_MEDIA_OPENAL: + case ASM_EVENT_MEDIA_FMRADIO: + case ASM_EVENT_MEDIA_WEBKIT: + result = true; + break; + default : + *error_code = ERR_ASM_NOT_SUPPORTED; + result = false; + break; + } + + return result; +} + +gboolean __is_need_resume (ASM_sound_events_t incoming_sound_event, ASM_resource_t incoming_resource, ASM_sound_events_t current_sound_event, int current_handle) +{ + gboolean result = FALSE; + switch (incoming_sound_event) { case ASM_EVENT_CALL: - case ASM_EVENT_RICH_CALL: case ASM_EVENT_VIDEOCALL: + case ASM_EVENT_VOIP: + case ASM_EVENT_NOTIFY: case ASM_EVENT_ALARM: + case ASM_EVENT_EMERGENCY: + case ASM_EVENT_VOICE_RECOGNITION: + case ASM_EVENT_MMCAMCORDER_AUDIO: + case ASM_EVENT_MMCAMCORDER_VIDEO: result = TRUE; break; default: result = FALSE; break; } + + /* exception case : if current playing sound event is one of below list, check false*/ + switch (current_sound_event) { + case ASM_EVENT_VOICE_RECOGNITION: + case ASM_EVENT_MMCAMCORDER_VIDEO: + return FALSE; + break; + default: + break; + } + + if (__is_media_session(current_sound_event) && __is_media_session(incoming_sound_event)) { + if (g_handle_info[current_handle].option_flags & ASM_SESSION_OPTION_RESUME_BY_MEDIA_PAUSED) { + result = TRUE; + } + } + if (current_sound_event == ASM_EVENT_MEDIA_OPENAL) { + result = TRUE; + } + + debug_warning(" resume check(%d)", result); + return result; +} + +gboolean __is_session_using_media_volume (ASM_sound_events_t sound_event) +{ + gboolean result = FALSE; + switch (sound_event) { + case ASM_EVENT_MEDIA_MMPLAYER: + case ASM_EVENT_MEDIA_MMCAMCORDER: + case ASM_EVENT_MEDIA_MMSOUND: + case ASM_EVENT_MEDIA_OPENAL: + case ASM_EVENT_MEDIA_FMRADIO: + case ASM_EVENT_MEDIA_WEBKIT: + case ASM_EVENT_MMCAMCORDER_AUDIO: + case ASM_EVENT_MMCAMCORDER_VIDEO: + case ASM_EVENT_VOICE_RECOGNITION: + debug_log("it's a session type using media volume (%d)", sound_event); + result = TRUE; + break; + default: + break; + } return result; } gboolean __find_clean_monitor_handle(int instance_id, int *handle) { - asm_instance_list_t *temp_list = head_list; - int lhandle = -1; + asm_instance_list_t *temp_list = head_list_ptr; + int lhandle = ASM_HANDLE_INIT_VAL; - while (temp_list->next != tail_list) { + while (temp_list != NULL) { if (temp_list->instance_id == instance_id && temp_list->sound_event == ASM_EVENT_MONITOR) { if (temp_list->monitor_dirty == 0) { lhandle = temp_list->sound_handle; @@ -279,22 +666,24 @@ gboolean __find_clean_monitor_handle(int instance_id, int *handle) } temp_list = temp_list->next; } - if (lhandle == -1) { + if (lhandle == ASM_HANDLE_INIT_VAL) { + debug_warning(" could not find a clean monitor handle"); return FALSE; } else { *handle = lhandle; + debug_log(" found a clean monitor handle(%d)", *handle); return TRUE; } } -void __update_monitor_active(long int instance_id) +void __update_monitor_active(int instance_id) { - asm_instance_list_t *temp_list = head_list; + asm_instance_list_t *temp_list = head_list_ptr; asm_instance_list_t *monitor_list = NULL; unsigned short active = 0; - asm_info("[ASM_Server] %s\n",__func__); + debug_log(" \n"); - while (temp_list->next != tail_list) { + while (temp_list != NULL) { if (temp_list->instance_id == instance_id && temp_list->sound_event == ASM_EVENT_MONITOR) { /* backup monitor pointer */ monitor_list = temp_list; @@ -303,12 +692,12 @@ void __update_monitor_active(long int instance_id) temp_list = temp_list->next; } if (NULL == monitor_list) { - asm_warning("[ASM_Server] %s : No monitor instance for %d\n",__func__, instance_id); + debug_warning(" No monitor instance for %d\n", instance_id); return; } - temp_list = head_list; - while (temp_list->next != tail_list) { + temp_list = head_list_ptr; + while (temp_list != NULL) { if (temp_list->instance_id == instance_id && temp_list->sound_event != ASM_EVENT_MONITOR) { if (ASM_STATE_PLAYING == temp_list->sound_state) { active = 1; @@ -323,9 +712,9 @@ void __update_monitor_active(long int instance_id) void __set_all_monitor_clean() { - asm_instance_list_t *temp_list = head_list; + asm_instance_list_t *temp_list = head_list_ptr; - while (temp_list->next != tail_list) { + while (temp_list != NULL) { if (temp_list->sound_event == ASM_EVENT_MONITOR) { temp_list->monitor_dirty = 0; } @@ -333,11 +722,11 @@ void __set_all_monitor_clean() } } -void __set_monitor_dirty(long int instance_id) +void __set_monitor_dirty(int instance_id) { - asm_instance_list_t *temp_list = head_list; + asm_instance_list_t *temp_list = head_list_ptr; - while (temp_list->next != tail_list) { + while (temp_list != NULL) { if (temp_list->instance_id == instance_id && temp_list->sound_event == ASM_EVENT_MONITOR) { temp_list->monitor_dirty = 1; break; @@ -349,41 +738,43 @@ void __set_monitor_dirty(long int instance_id) /* callback without retcb */ void __do_callback_wo_retcb(int instance_id,int handle,int command) { - int fd_ASM = 0, cur_handle = 0; + int fd_ASM = -1, cur_handle = 0; char *filename = g_strdup_printf("/tmp/ASM.%d.%d", instance_id, handle); if ((fd_ASM = open(filename,O_WRONLY|O_NONBLOCK)) < 0) { - asm_info("[ASM_Server][CallCB] %s open error",filename); + debug_log("[CallCB] %s open error",filename); g_free(filename); return; } cur_handle = (unsigned int)(handle |(command << 4)); if (write(fd_ASM, (void *)&cur_handle, sizeof(cur_handle)) < 0) { - asm_info("[ASM_Server][CallCB] %s write error",filename); + debug_log("[CallCB] %s write error",filename); g_free(filename); + if (fd_ASM != -1) { + close(fd_ASM); + } return; } close(fd_ASM); g_free(filename); - selectSleep(2); /* if return immediately bad sound occur */ + ___select_sleep(2); /* if return immediately bad sound occur */ } - -int __do_callback(int instance_id,int handle,int command, ASM_event_sources_t event_src) +int __do_callback(int instance_id, int handle, int command, ASM_event_sources_t event_src) { char *filename = NULL; char *filename2 = NULL; struct timeval time; int starttime = 0; int endtime = 0; - int fd=0,nread = 0; - int fd_ASM = 0, cur_handle = 0; + int fd=-1; + int fd_ASM = -1, cur_handle = 0; int buf = 0; struct pollfd pfd; int pret = 0; - int pollingTimeout = 1500; /* NOTE : This is temporary code, because of Deadlock issues. If you fix that issue, remove this comment */ + int pollingTimeout = 2500; /* NOTE : This is temporary code, because of Deadlock issues. If you fix that issue, remove this comment */ - asm_info("[ASM_Server] __do_callback for pid(%d) handle(%d)\n", instance_id, handle); + debug_log(" __do_callback for pid(%d) handle(%d)\n", instance_id, handle); /* Set start time */ gettimeofday(&time, NULL); @@ -396,7 +787,7 @@ int __do_callback(int instance_id,int handle,int command, ASM_event_sources_t ev **************************************/ filename = g_strdup_printf("/tmp/ASM.%d.%d", instance_id, handle); if ((fd_ASM = open(filename, O_WRONLY|O_NONBLOCK)) < 0) { - asm_error("[ASM_Server][CallCB] %s open error\n", filename); + debug_error("[CallCB] %s open error\n", filename); goto fail; } @@ -410,18 +801,19 @@ int __do_callback(int instance_id,int handle,int command, ASM_event_sources_t ev if ((fd=open(filename2,O_RDONLY|O_NONBLOCK))== -1) { char str_error[256]; strerror_r (errno, str_error, sizeof(str_error)); - asm_error("[ASM_Server][RETCB] Fail to open fifo (%s)\n", str_error); + debug_error("[RETCB] Fail to open fifo (%s)\n", str_error); goto fail; } - asm_info("[ASM_Server] open return cb %s\n", filename2); - + debug_log(" open return cb %s\n", filename2); + g_free (filename2); + filename2 = NULL; /******************************************* * Write Callback msg *******************************************/ cur_handle = (unsigned int)((0x0000ffff & handle) |(command << 16) | (event_src << 24)); if (write(fd_ASM, (void *)&cur_handle, sizeof(cur_handle)) < 0) { - asm_error("[ASM_Server][CallCB] %s write error\n", filename); + debug_error("[CallCB] %s write error\n", filename); goto fail; } /************************************** @@ -429,53 +821,59 @@ int __do_callback(int instance_id,int handle,int command, ASM_event_sources_t ev * Close callback cmd pipe * **************************************/ - close(fd_ASM); - fd_ASM = -1; + if (fd_ASM != -1) { + close(fd_ASM); + fd_ASM = -1; + } g_free(filename); filename = NULL; - /* If command is RESUME, then do not wait for client return */ + /* Check if do not need to wait for client return */ if (command == ASM_COMMAND_RESUME) { - asm_info("[ASM_Server][RETCB] No need to wait return from client. \n"); + debug_log("[RETCB] No need to wait return from client. \n"); + if (fd != -1) { + close (fd); + fd = -1; + } return ASM_CB_RES_NONE; } pfd.fd = fd; pfd.events = POLLIN; - asm_instance_list_t *temp_list = head_list; - - /********************************************* * * Wait callback result msg * ********************************************/ - asm_critical("[ASM_Server][RETCB]wait callback(tid=%d, handle=%d, cmd=%d, timeout=%d)\n", instance_id, handle, command, pollingTimeout); + debug_log("[RETCB]wait callback(tid=%d, handle=%d, cmd=%d, timeout=%d)\n", instance_id, handle, command, pollingTimeout); pret = poll(&pfd, 1, pollingTimeout); //timeout 7sec if (pret < 0) { - asm_error("[ASM_Server][RETCB]poll failed (%d)\n", pret); + debug_error("[RETCB]poll failed (%d)\n", pret); goto fail; } if (pfd.revents & POLLIN) { - nread=read(fd, (void *)&buf, sizeof(buf)); + if (read(fd, (void *)&buf, sizeof(buf)) == -1) { + debug_error("read error\n"); + goto fail; + } } - g_free(filename2); - filename2 = NULL; /* Calculate endtime and display*/ gettimeofday(&time, NULL); endtime = time.tv_sec * 1000000 + time.tv_usec; - asm_critical("[ASM_Server][RETCB] ASM_CB_END cbtimelab=%3.3f(second), timeout=%d(milli second) (reciever=%d)\n", ((endtime-starttime)/1000000.), pollingTimeout, instance_id); + debug_log("[RETCB] ASM_CB_END cbtimelab=%3.3f(second), timeout=%d(milli second) (reciever=%d)\n", ((endtime-starttime)/1000000.), pollingTimeout, instance_id); /************************************** * * Close callback result pipe * **************************************/ - close(fd); - fd = -1; - asm_info("[ASM_Server][RETCB] Return value 0x%x\n", buf); + if (fd != -1) { + close(fd); + fd = -1; + } + debug_log("[RETCB] Return value 0x%x\n", buf); return buf; fail: @@ -499,140 +897,380 @@ fail: return -1; } -gboolean __isPlayingNow() +gboolean __is_it_redundant_request(int instance_id, ASM_sound_events_t sound_event, ASM_sound_states_t sound_state) { - asm_instance_list_t *temp_list = head_list; - while (temp_list->next != tail_list) { - if (temp_list->sound_state == ASM_STATE_PLAYING ) { - return TRUE; + asm_instance_list_t *temp_list = head_list_ptr; + while (temp_list != NULL) { + if (temp_list->is_registered_for_watching) { + if (temp_list->instance_id == instance_id && temp_list->sound_event == sound_event && temp_list->sound_state == sound_state) { + return TRUE; + } } - temp_list = temp_list->next; } return FALSE; } -gboolean __isItPlayingNow(int instance_id, int handle) +int __get_watcher_list (ASM_sound_events_t interest_sound_event, ASM_sound_states_t interest_sound_state, int *instance_id_list, int *handle_list) { - asm_instance_list_t *temp_list = head_list; - while (temp_list->next != tail_list) { - if (temp_list->instance_id == instance_id && temp_list->sound_handle == handle) { - if (temp_list->sound_state == ASM_STATE_PLAYING) { - return TRUE; + asm_instance_list_t *temp_list = head_list_ptr; + int num = 0; + + while (temp_list != NULL) { + if (temp_list->is_registered_for_watching) { + if (temp_list->sound_event == interest_sound_event && temp_list->sound_state == interest_sound_state) { + instance_id_list[num] = temp_list->instance_id; + handle_list[num] = temp_list->sound_handle; + num++; + debug_warning(" found a watcher[pid:%d] for :: INTEREST event(%s) state(%s)", temp_list->instance_id, ASM_sound_event_str[interest_sound_event], ASM_sound_state_str[interest_sound_state]); + if (__mm_sound_mgr_ipc_freeze_send(FREEZE_COMMAND_WAKEUP, temp_list->instance_id)) { + debug_warning("failed to send wake-up msg to the client pid(%d)",temp_list->instance_id); + } } } - + if (num >= MAX_WATCH_CALLBACK_CALCUL_NUM) { + debug_warning(" out of bound for checking registered watch handles, num(%d)"); + break; + } temp_list = temp_list->next; } - return FALSE; + + return num; } -void __temp_print_list(char * msg) +int __do_watch_callback(ASM_sound_events_t sound_event, ASM_sound_states_t updated_sound_state) { - asm_instance_list_t *temp_list = head_list; - int i = 0; + char *filename = NULL; + char *filename2 = NULL; + struct timeval time; + int starttime = 0; + int endtime = 0; + int fd = -1; + int fd_ASM = -1; + int cur_handle = 0; + int buf = 0; + struct pollfd pfd; + int pret = 0; + int pollingTimeout = 1500; /* NOTE : This is temporary code, because of Deadlock issues. If you fix that issue, remove this comment */ + int instance_id_list[MAX_WATCH_CALLBACK_CALCUL_NUM] = {0}; + int handle_list[MAX_WATCH_CALLBACK_CALCUL_NUM] = {0}; + int num = 0; - if (NULL != msg) { - asm_warning("[ASM_Server] %s\n", msg); - } - while (temp_list->next != tail_list) { - asm_info("[ASM_Server] List[%02d] ( %5ld, %2d, %-20s, %-20s, %9s, 0x%04x)\n", i, temp_list->instance_id, temp_list->sound_handle, - ASM_sound_events_str[temp_list->sound_event], - ASM_sound_state_str[temp_list->sound_state], - ASM_sound_resume_str[temp_list->need_resume], - temp_list->mm_resource); - temp_list = temp_list->next; - i++; - } -} + debug_fenter(); -void updatePhoneStatus() -{ - asm_instance_list_t *temp_list = head_list; - int i = 0, error = 0; + /* find candidates' instance_id and handle for providing session-changed notification, get number of candidates */ + num = __get_watcher_list (sound_event, updated_sound_state, instance_id_list, handle_list); - g_sound_status_pause = 0; - g_sound_status_playing = 0; + while (num--) { - while (temp_list->next != tail_list) { - if (temp_list->sound_state == ASM_STATE_PLAYING) { - if (temp_list->sound_event >= ASM_EVENT_SHARE_MMPLAYER && temp_list->sound_event < ASM_EVENT_MAX) { - g_sound_status_playing |= ASM_sound_type[(temp_list->sound_event) + 1].sound_status; - } - } else if (temp_list->sound_state == ASM_STATE_PAUSE ) { - if (temp_list->sound_event >= ASM_EVENT_SHARE_MMPLAYER && temp_list->sound_event < ASM_EVENT_MAX) { - g_sound_status_pause |= ASM_sound_type[(temp_list->sound_event) + 1].sound_status; + debug_log(" pid(%d), handle(%d), sound_event(%d), sound_state(%d)\n", instance_id_list[num], handle_list[num], sound_event, updated_sound_state); + + /* Set start time */ + gettimeofday(&time, NULL); + starttime = time.tv_sec * 1000000 + time.tv_usec; + + /************************************** + * + * Open callback cmd pipe + * + **************************************/ + filename = g_strdup_printf("/tmp/ASM.%d.%d", instance_id_list[num], handle_list[num]); + if ((fd_ASM = open(filename, O_WRONLY|O_NONBLOCK)) < 0) { + debug_error("[CallCB] %s open error\n", filename); + goto fail; + } + + /****************************************** + * + * Open callback result pipe + * before writing callback cmd to pipe + * + ******************************************/ + filename2 = g_strdup_printf("/tmp/ASM.%d.%dr", instance_id_list[num], handle_list[num]); + if ((fd=open(filename2,O_RDONLY|O_NONBLOCK))== -1) { + char str_error[256]; + strerror_r (errno, str_error, sizeof(str_error)); + debug_error("[RETCB] Fail to open fifo (%s)\n", str_error); + goto fail; + } + debug_log(" open return cb %s\n", filename2); + + + /******************************************* + * Write Callback msg + *******************************************/ + //cur_handle = (unsigned int)((0x0000ffff & handle_list[num])); + cur_handle = (unsigned int)((0x0000ffff & handle_list[num]) | (sound_event << 16) | (updated_sound_state << 24)); + if (write(fd_ASM, (void *)&cur_handle, sizeof(cur_handle)) < 0) { + debug_error("[CallCB] %s write error\n", filename); + goto fail; + } + /************************************** + * + * Close callback cmd pipe + * + **************************************/ + if (fd_ASM != -1) { + close(fd_ASM); + fd_ASM = -1; + } + g_free(filename); + filename = NULL; + + pfd.fd = fd; + pfd.events = POLLIN; + + /********************************************* + * + * Wait callback result msg + * + ********************************************/ + debug_log("[RETCB]wait callback(tid=%d, handle=%d, timeout=%d)\n", + instance_id_list[num], handle_list[num], pollingTimeout); + pret = poll(&pfd, 1, pollingTimeout); //timeout 7sec + if (pret < 0) { + debug_error("[RETCB]poll failed (%d)\n", pret); + goto fail; + } + if (pfd.revents & POLLIN) { + if (read(fd, (void *)&buf, sizeof(buf)) == -1) { + debug_error("read error\n"); + goto fail; } } - temp_list = temp_list->next; - } + g_free(filename2); + filename2 = NULL; - if (vconf_set_int(SOUND_STATUS_KEY, g_sound_status_playing)) { - asm_info("[ASM_Server[Error = %d][1st try] phonestatus_set \n", error); - if (vconf_set_int(SOUND_STATUS_KEY, g_sound_status_playing)) { - asm_critical("[ASM_Server][Error = %d][2nd try] phonestatus_set \n", error); + /* Calculate endtime and display*/ + gettimeofday(&time, NULL); + endtime = time.tv_sec * 1000000 + time.tv_usec; + debug_log("[RETCB] ASM_CB_END cbtimelab=%3.3f(second), timeout=%d(milli second) (reciever=%d)\n", + ((endtime-starttime)/1000000.), pollingTimeout, instance_id_list[num]); + + /************************************** + * + * Close callback result pipe + * + **************************************/ + if (fd != -1) { + close(fd); + fd = -1; } + debug_log("[RETCB] Return value 0x%x\n", buf); + //return buf; + } - asm_info("[ASM_Server] soundstatus set to (0x%08x)\n", g_sound_status_playing); -} + debug_fleave(); + return 0; -void __asm_register_list(long int instance_id, int handle, ASM_sound_events_t sound_event, ASM_sound_states_t sound_state, ASM_resource_t mm_resource) +fail: + if (filename) { + g_free (filename); + filename = NULL; + } + if (filename2) { + g_free (filename2); + filename2 = NULL; + } + if (fd_ASM != -1) { + close(fd_ASM); + fd_ASM = -1; + } + if (fd != -1) { + close (fd); + fd = -1; + } + + return -1; +} + +gboolean __is_it_playing_now(int instance_id, int handle) +{ + asm_instance_list_t *temp_list = head_list_ptr; + while (temp_list != NULL) { + if (temp_list->instance_id == instance_id && temp_list->sound_handle == handle) { + if (temp_list->sound_state == ASM_STATE_PLAYING) { + return TRUE; + } + } + + temp_list = temp_list->next; + } + return FALSE; +} + +void __temp_print_list(char * msg) +{ + asm_instance_list_t *temp_list = head_list_ptr; + int i = 0; + + if (NULL != msg) { + debug_warning(" => MSG: %s\n", msg); + } + while (temp_list != NULL) { + if (!temp_list->is_registered_for_watching) { + if (!ASM_IS_ADVANCED_ASM_EVENT(temp_list->sound_event)) { + debug_msg(" List[%02d] ( %5d, %2d, %-22s, %-15s, %9s checked by%5d/%d, 0x%04x, 0x%04x)\n" , i, + temp_list->instance_id, temp_list->sound_handle, + ASM_sound_event_str[temp_list->sound_event], + ASM_sound_state_str[temp_list->sound_state], + ASM_sound_resume_str[temp_list->need_resume], + temp_list->paused_by_id.pid, + temp_list->paused_by_id.sound_handle, + temp_list->mm_resource, + temp_list->option_flags); + } else { + debug_msg(" List[%02d] ( %5d, %2d, %-22s, %-15s, %-15s, 0x%04x)\n", i, + temp_list->instance_id, + temp_list->sound_handle, + ASM_sound_event_str[temp_list->sound_event], + ASM_sound_state_str[temp_list->sound_state], + ASM_sound_sub_event_str[temp_list->sound_sub_event], + temp_list->mm_resource); + } + i++; + } + temp_list = temp_list->next; + } + temp_list = head_list_ptr; + debug_log(" listed below are requests for watching session\n"); + while (temp_list != NULL) { + if (temp_list->is_registered_for_watching) { + debug_msg(" List[%02d] ( %5d, %2d, %-22s, %-15s, %5s)\n", i, temp_list->instance_id, temp_list->sound_handle, + ASM_sound_event_str[temp_list->sound_event], + ASM_sound_state_str[temp_list->sound_state], + "WATCHING"); + i++; + } + temp_list = temp_list->next; + } +} + +void ___update_phone_status() +{ + asm_instance_list_t *temp_list = head_list_ptr; + int error = 0; + + g_sound_status_pause = 0; + g_sound_status_playing = 0; + g_sound_status_waiting = 0; + + while (temp_list != NULL) { + if (!temp_list->is_registered_for_watching) { + if (temp_list->sound_state == ASM_STATE_PLAYING) { + if (temp_list->sound_event >= ASM_EVENT_MEDIA_MMPLAYER && temp_list->sound_event < ASM_EVENT_MAX) { + g_sound_status_playing |= ASM_sound_type[(temp_list->sound_event) + 1].sound_status; + } + } else if (temp_list->sound_state == ASM_STATE_PAUSE ) { + if (temp_list->sound_event >= ASM_EVENT_MEDIA_MMPLAYER && temp_list->sound_event < ASM_EVENT_MAX) { + g_sound_status_pause |= ASM_sound_type[(temp_list->sound_event) + 1].sound_status; + } + } else if (temp_list->sound_state == ASM_STATE_WAITING ) { + if (temp_list->sound_event >= ASM_EVENT_MEDIA_MMPLAYER && temp_list->sound_event < ASM_EVENT_MAX) { + g_sound_status_waiting |= ASM_sound_type[(temp_list->sound_event) + 1].sound_status; + } + } + } + temp_list = temp_list->next; + } + + if (vconf_set_int(SOUND_STATUS_KEY, g_sound_status_playing)) { + debug_error("[ASM_Server[Error = %d][1st try] phonestatus_set \n", error); + if (vconf_set_int(SOUND_STATUS_KEY, g_sound_status_playing)) { + debug_error("[Error = %d][2nd try] phonestatus_set \n", error); + } + } + + //debug_log(" soundstatus : playing(0x%08x), pause(0x%08x), waiting(0x%08x)\n", g_sound_status_playing, g_sound_status_pause, g_sound_status_waiting); +} + +asm_instance_list_t* __asm_register_list(int instance_id, int handle, ASM_sound_events_t sound_event, ASM_sound_states_t sound_state, ASM_resource_t mm_resource, bool is_requested_for_watching) { asm_instance_list_t *temp_list; temp_list = (asm_instance_list_t *)malloc(sizeof(asm_instance_list_t)); + if (!temp_list) { + debug_error("could not allocate memory for asm_instance_list_t\n"); + return NULL; + } temp_list->instance_id = instance_id; temp_list->sound_handle = handle; temp_list->sound_event = sound_event; + temp_list->sound_sub_event = ASM_SUB_EVENT_NONE; temp_list->sound_state = sound_state; temp_list->need_resume = 0; temp_list->mm_resource = mm_resource; + temp_list->option_flags = 0; + temp_list->paused_by_id.pid = 0; + temp_list->paused_by_id.sound_handle = ASM_HANDLE_INIT_VAL; + temp_list->paused_by_id.eventsrc = ASM_EVENT_SOURCE_MEDIA; temp_list->monitor_active = 0; temp_list->monitor_dirty = 0; - temp_list->next = head_list; - head_list = temp_list; + temp_list->is_registered_for_watching = is_requested_for_watching; + temp_list->next = head_list_ptr; + head_list_ptr = temp_list; + if (tail_list_ptr == NULL) { + tail_list_ptr = temp_list; + debug_warning("tail_list_ptr is null, this is the first entry"); + } __temp_print_list("Register List"); - updatePhoneStatus(); + ___update_phone_status(); + + return temp_list; } int __asm_unregister_list(int handle) { - asm_instance_list_t *temp_list = head_list; - asm_instance_list_t *temp_list2 = head_list; - int instance_id = -1; + asm_instance_list_t *temp_list = head_list_ptr; + asm_instance_list_t *temp_list_prev = head_list_ptr; + int instance_id = ASM_HANDLE_INIT_VAL; - asm_info("[ASM_Server] __asm_unregister_list \n"); + debug_log(" __asm_unregister_list \n"); - while (temp_list->next != tail_list) { + while (temp_list != NULL) { if (temp_list->sound_handle == handle) { instance_id = temp_list->instance_id; - if (temp_list == head_list) - head_list = temp_list->next; - else - temp_list2->next = temp_list->next; + g_handle_info[temp_list->sound_handle].is_registered = 0; + g_handle_info[temp_list->sound_handle].option_flags = 0; + g_handle_info[temp_list->sound_handle].resource = 0; + if (temp_list == head_list_ptr) { + head_list_ptr = temp_list->next; + } else { + temp_list_prev->next = temp_list->next; + } + if (temp_list == tail_list_ptr) { + if (head_list_ptr == NULL) { + tail_list_ptr = NULL; + debug_warning (" this entry is the last one, set tail_list_ptr to NULL"); + } else { + tail_list_ptr = temp_list_prev; + debug_warning (" this entry is the last of this list, set tail_list_ptr to temp_list_prev"); + } + } free(temp_list); break; } - temp_list2 = temp_list; + temp_list_prev = temp_list; temp_list = temp_list->next; } __temp_print_list("Unregister List for handle"); - updatePhoneStatus(); + ___update_phone_status(); return instance_id; } - /* ------------------------- * if PID exist return true, else return false */ -gboolean isPIDExist(int pid) +gboolean ___is_pid_exist(int pid) { if (pid > 999999 || pid < 2) return FALSE; gchar *tmp = g_malloc0(25); + if (!tmp) + return FALSE; g_sprintf(tmp, "/proc/%d", pid); if (access(tmp, R_OK)==0) { g_free(tmp); @@ -642,41 +1280,78 @@ gboolean isPIDExist(int pid) return FALSE; } - /* ------------------------- * */ void __check_dead_process() { - asm_instance_list_t *temp_list = head_list; - asm_instance_list_t *temp_list2 = head_list; - while (temp_list->next != tail_list) { - if (!isPIDExist(temp_list->instance_id)) { - asm_critical_r("[ASM_Server] PID(%ld) not exist! -> ASM_Server resource of pid(%ld) will be cleared \n", temp_list->instance_id, temp_list->instance_id); - - if (temp_list == head_list) { - head_list = temp_list->next; + asm_instance_list_t *temp_list = head_list_ptr; + asm_instance_list_t *temp_list_prev = head_list_ptr; + while (temp_list != NULL) { + if (!___is_pid_exist(temp_list->instance_id)) { + debug_warning(" PID(%d) not exist! -> ASM_Server resource of pid(%d) will be cleared \n", temp_list->instance_id, temp_list->instance_id); + if(temp_list->sound_event == ASM_EVENT_MMCAMCORDER_AUDIO || temp_list->sound_event == ASM_EVENT_MMCAMCORDER_VIDEO) { + debug_warning("dead process was camcorder init vconf"); + vconf_set_int(VCONFKEY_RECORDER_STATE, 0); + } + g_handle_info[temp_list->sound_handle].is_registered = 0; + g_handle_info[temp_list->sound_handle].option_flags = 0; + g_handle_info[temp_list->sound_handle].resource = 0; + if (temp_list == head_list_ptr) { + head_list_ptr = temp_list->next; + temp_list_prev = head_list_ptr; + free(temp_list); + temp_list = temp_list_prev; + if (head_list_ptr == NULL) { + tail_list_ptr = NULL; + } + } else { + temp_list_prev->next = temp_list->next; + if (temp_list->next == NULL) { + tail_list_ptr = temp_list_prev; + } + free(temp_list); + temp_list = temp_list_prev->next; } - temp_list2->next = temp_list->next; - free(temp_list); } else { - temp_list2 = temp_list; + if (temp_list->paused_by_id.pid) { + if (!___is_pid_exist(temp_list->paused_by_id.pid)) { + temp_list->need_resume = ASM_NEED_NOT_RESUME; + temp_list->paused_by_id.pid = 0; + temp_list->paused_by_id.sound_handle = ASM_HANDLE_INIT_VAL; + temp_list->paused_by_id.eventsrc = ASM_EVENT_SOURCE_MEDIA; + } + } + temp_list_prev = temp_list; + temp_list = temp_list->next; } - temp_list = temp_list2->next; } - updatePhoneStatus(); + ___update_phone_status(); } +void __reset_resume_check(int instance_id, int handle) +{ + asm_instance_list_t *temp_list = head_list_ptr; + while (temp_list != NULL) { + if (handle == ASM_HANDLE_INIT_VAL) { + if (temp_list->instance_id == instance_id && temp_list->paused_by_id.pid) { + temp_list->need_resume = ASM_NEED_NOT_RESUME; + temp_list->paused_by_id.pid = 0; + temp_list->paused_by_id.sound_handle = ASM_HANDLE_INIT_VAL; + temp_list->paused_by_id.eventsrc = ASM_EVENT_SOURCE_MEDIA; + } + } + temp_list = temp_list->next; + } +} - - -void emergent_exit(int exit_pid) +void __emergent_exit(int exit_pid) { - asm_instance_list_t *temp_list = head_list; - int handle = -1; + asm_instance_list_t *temp_list = head_list_ptr; + int handle = ASM_HANDLE_INIT_VAL; int instance_id = -1; - while (temp_list->next != tail_list) { + while (temp_list != NULL) { if (temp_list->instance_id == exit_pid) { handle = temp_list->sound_handle; @@ -687,39 +1362,37 @@ void emergent_exit(int exit_pid) char* filename = g_strdup_printf("/tmp/ASM.%d.%d", instance_id, handle); char* filename2 = g_strdup_printf("/tmp/ASM.%d.%dr", instance_id, handle); if (!remove(filename)) { - asm_info("[ASM_Server] remove %s success\n", filename); + debug_log(" remove %s success\n", filename); } else { strerror_r (errno, str_error, sizeof (str_error)); - asm_error("[ASM_Server] remove %s failed with %s\n", filename, str_error); + debug_error(" remove %s failed with %s\n", filename, str_error); } if (!remove(filename2)) { - asm_info("[ASM_Server] remove %s success\n", filename2); + debug_log(" remove %s success\n", filename2); } else { strerror_r (errno, str_error, sizeof (str_error)); - asm_error("[ASM_Server] remove %s failed with %s\n", filename2, str_error); + debug_error(" remove %s failed with %s\n", filename2, str_error); } g_free(filename); g_free(filename2); } - temp_list = head_list; + temp_list = head_list_ptr; } else { temp_list = temp_list->next; } } - asm_info("[ASM_Server][EMERGENT_EXIT] complete\n"); + debug_warning("[EMERGENT_EXIT] complete\n"); return; } - int ___reorder_state(ASM_sound_states_t input) { int res = 0; switch (input) { - case ASM_STATE_IGNORE: case ASM_STATE_NONE: res = 0; break; @@ -728,7 +1401,6 @@ int ___reorder_state(ASM_sound_states_t input) res = 1; break; case ASM_STATE_PAUSE: - case ASM_STATE_PAUSE_BY_APP: res = 2; break; case ASM_STATE_PLAYING: @@ -740,13 +1412,13 @@ int ___reorder_state(ASM_sound_states_t input) ASM_sound_states_t __asm_find_process_status(int pid) { - asm_instance_list_t *temp_list = head_list; + asm_instance_list_t *temp_list = head_list_ptr; ASM_sound_states_t result_state = ASM_STATE_NONE; - asm_info("[ASM_Server] __asm_find_process_status for pid %d\n", pid); + debug_log(" __asm_find_process_status for pid %d\n", pid); - while (temp_list->next != tail_list) { - if (temp_list->instance_id == pid) { + while (temp_list != NULL) { + if (temp_list->instance_id == pid && !temp_list->is_registered_for_watching) { if ( ___reorder_state(temp_list->sound_state) >= ___reorder_state(result_state)) { result_state = temp_list->sound_state; } @@ -757,59 +1429,132 @@ ASM_sound_states_t __asm_find_process_status(int pid) return result_state; } -ASM_sound_states_t __asm_find_list(ASM_requests_t request_id, int handle) +asm_instance_list_t* __asm_find_list(int handle) { - asm_instance_list_t *temp_list = head_list; + asm_instance_list_t* temp_list = head_list_ptr; - asm_info("[ASM_Server] __asm_find_list\n"); + debug_fenter(); - while (temp_list->next != tail_list) { - if ((request_id == ASM_REQUEST_GETSTATE && temp_list->sound_handle == handle)) { - return temp_list->sound_state; + while (temp_list != NULL) { + if (temp_list->sound_handle == handle) { + debug_fleave(); + return temp_list; } else { temp_list = temp_list->next; } } + debug_warning("could not find handle for handle id(%d)", handle); + + return NULL; +} + +ASM_sound_states_t __asm_find_state_of_handle(int handle) +{ + asm_instance_list_t *temp_list = head_list_ptr; + + debug_fenter(); + + while (temp_list != NULL) { + if (temp_list->sound_handle == handle) { + return temp_list->sound_state; + } + temp_list = temp_list->next; + } + + debug_fleave(); + return ASM_STATE_NONE; } -void __asm_change_state_list(long int instance_id, int handle, ASM_sound_states_t sound_state, ASM_resource_t mm_resource) +ASM_sound_events_t __asm_find_event_of_handle(int instance_id, int handle) { - asm_instance_list_t *temp_list = head_list; - int monitor_handle = -1; - asm_info("[ASM_Server] __asm_change_state_list\n"); - if (sound_state == ASM_STATE_IGNORE) { - asm_info("[ASM_Server] skip update state list %ld-%d\n", instance_id, handle); - return; + asm_instance_list_t *temp_list = head_list_ptr; + + debug_fenter(); + + while (temp_list != NULL) { + if (temp_list->instance_id == instance_id && temp_list->sound_handle == handle) { + return temp_list->sound_event; + } + temp_list = temp_list->next; + } + + debug_fleave(); + + return ASM_EVENT_NONE; +} + +int __asm_find_pid_of_resume_tagged(int paused_by_handle) +{ + asm_instance_list_t *temp_list = head_list_ptr; + + debug_fenter(); + + while (temp_list != NULL) { + if (temp_list->need_resume == ASM_NEED_RESUME && temp_list->paused_by_id.sound_handle == paused_by_handle) { + return temp_list->instance_id; + } + temp_list = temp_list->next; } - while (temp_list->next != tail_list) { + debug_fleave(); + + return -1; +} + +asm_instance_list_t* __asm_change_state_list(int instance_id, int handle, ASM_sound_states_t sound_state, ASM_resource_t mm_resource) +{ + asm_instance_list_t *temp_list = head_list_ptr; + debug_log(" __asm_change_state_list\n"); + + while (temp_list != NULL) { if (temp_list->instance_id == instance_id && temp_list->sound_handle == handle) { + temp_list->prev_sound_state = temp_list->sound_state; temp_list->sound_state = sound_state; temp_list->mm_resource = mm_resource; + __update_monitor_active(instance_id); + ___update_phone_status(); + return temp_list; + } + temp_list = temp_list->next; + } + + debug_warning("could not find handle for pid(%d), handle(%d)", instance_id, handle); + + return NULL; +} + +void __asm_change_sub_event_list(int instance_id, int handle, ASM_sound_sub_events_t sub_event) +{ + asm_instance_list_t *temp_list = head_list_ptr; + debug_log("[ASM_Server] __asm_change_sub_event_list\n"); + + while (temp_list != NULL) { + if (temp_list->instance_id == instance_id && temp_list->sound_handle == handle) { + temp_list->sound_sub_event = sub_event; break; } temp_list = temp_list->next; } - __update_monitor_active(instance_id); - updatePhoneStatus(); } -void __asm_change_need_resume_list(long int instance_id, int handle, ASM_resume_states_t need_resume) +void __asm_change_need_resume_list(int instance_id, int handle, ASM_resume_states_t need_resume, int paused_by_pid, int paused_by_sound_handle, ASM_event_sources_t paused_by_eventsrc) { - asm_instance_list_t *temp_list = head_list; - asm_info("[ASM_Server] __asm_change_need_resume_list\n"); - while (temp_list->next != tail_list) { + asm_instance_list_t *temp_list = head_list_ptr; + debug_log(" __asm_change_need_resume_list\n"); + while (temp_list != NULL) { if (temp_list->instance_id == instance_id && temp_list->sound_handle == handle) { temp_list->need_resume = need_resume; + temp_list->paused_by_id.pid = paused_by_pid; + temp_list->paused_by_id.sound_handle = paused_by_sound_handle; + temp_list->paused_by_id.eventsrc = paused_by_eventsrc; break; } temp_list = temp_list->next; } } - void __asm_create_message_queue() { asm_rcv_msgid = msgget((key_t)2014, 0666 | IPC_CREAT); @@ -817,7 +1562,7 @@ void __asm_create_message_queue() asm_cb_msgid = msgget((key_t)4103, 0666 | IPC_CREAT); if (asm_snd_msgid == -1 || asm_rcv_msgid == -1 || asm_cb_msgid == -1) { - asm_critical("[ASM_Server] msgget failed with error(%d,%s) \n", errno, strerror(errno)); + debug_error(" msgget failed with error(%d,%s) \n", errno, strerror(errno)); exit(EXIT_FAILURE); } } @@ -825,663 +1570,1358 @@ void __asm_create_message_queue() void __asm_snd_message(ASM_msg_asm_to_lib_t *asm_snd_msg) { if (msgsnd(asm_snd_msgid, (void *)asm_snd_msg, sizeof(asm_snd_msg->data), 0) == -1) { - asm_critical("[ASM_Server] msgsnd failed with error %d\n", errno); + debug_error(" msgsnd failed with error %d\n", errno); exit(EXIT_FAILURE); + } else { + debug_warning(" success : handle(%d), pid(%d), result_state(%s), result_command(%s), source_request(%s)", + asm_snd_msg->data.alloc_handle, asm_snd_msg->instance_id, + ASM_sound_state_str[asm_snd_msg->data.result_sound_state], + ASM_sound_command_str[asm_snd_msg->data.result_sound_command], + ASM_sound_request_str[asm_snd_msg->data.source_request_id]); + asm_snd_msg->data.result_sound_state = ASM_STATE_NONE; + asm_snd_msg->data.result_sound_command = ASM_COMMAND_NONE; } } void __asm_rcv_message(ASM_msg_lib_to_asm_t *asm_rcv_msg) { if (msgrcv(asm_rcv_msgid, (void *)asm_rcv_msg, sizeof(asm_rcv_msg->data), 0, 0) == -1) { - asm_critical_r("[ASM_Server] msgrcv failed with error %d\n", errno); + debug_error(" msgrcv failed with error %d\n", errno); exit(EXIT_FAILURE); + } else { + debug_log(" success"); } } -void __asm_get_empty_handle(long int instance_id, int *handle) +void __asm_get_empty_handle(int instance_id, int *handle) { - asm_instance_list_t *temp_list = head_list; - unsigned int i = 0, find_empty = 0, j = 0; - char handle_info[SERVER_HANDLE_MAX_COUNT]; + asm_instance_list_t *temp_list = head_list_ptr; + unsigned int i = 0, find_empty = 0; - asm_info("[ASM_Server] __asm_make_handle for %ld\n", instance_id); - __temp_print_list("current list before get new handle"); + debug_log(" __asm_make_handle for %d\n", instance_id); + //__temp_print_list("current list before get new handle"); - memset(handle_info, 0, sizeof(char) * SERVER_HANDLE_MAX_COUNT); - - while (temp_list->next != tail_list) { - handle_info[temp_list->sound_handle] = 1; + while (temp_list != NULL) { + g_handle_info[temp_list->sound_handle].is_registered = 1; temp_list = temp_list->next; } for (i = 0; i < ASM_SERVER_HANDLE_MAX; i++) { - if (handle_info[i] == 0) { + if (g_handle_info[i].is_registered == 0) { find_empty = 1; break; } } if (find_empty && (i != ASM_SERVER_HANDLE_MAX)) { - asm_error_r("[ASM_Server] New handle for %ld is %d\n", instance_id, i); + debug_log(" New handle for %d is %d\n", instance_id, i); *handle = i; + g_handle_info[i].is_registered = 1; } else { - asm_error_r("[ASM_Server] Handle is full for pid %ld\n", instance_id); - *handle = -1; + debug_error(" Handle is full for pid %d\n", instance_id); + *handle = ASM_HANDLE_INIT_VAL; } - } -void __print_resource(unsigned short resource_status) +void __print_resource(unsigned int resource_status) { if (resource_status == ASM_RESOURCE_NONE) - asm_info("[ASM_Server] resource NONE\n"); - if (resource_status | ASM_RESOURCE_CAMERA) - asm_info("[ASM_Server] resource CAMERA\n"); - if (resource_status | ASM_RESOURCE_VIDEO_OVERLAY) - asm_info("[ASM_Server] resource VIDEO OVERLAY\n"); - if (resource_status | ASM_RESOURCE_HW_ENCORDER) - asm_info("[ASM_Server] resource HW ENCORDER\n"); - if (resource_status | ASM_RESOURCE_HW_DECORDER) - asm_info("[ASM_Server] resource HW DECORDER\n"); - if (resource_status | ASM_RESOURCE_RADIO_TUNNER) - asm_info("[ASM_Server] resource RADIO TUNNER\n"); - if (resource_status | ASM_RESOURCE_TV_TUNNER) - asm_info("[ASM_Server] resource TV TUNNER\n"); + debug_warning(" resource NONE\n"); + if (resource_status & ASM_RESOURCE_CAMERA) + debug_warning(" resource CAMERA\n"); + if (resource_status & ASM_RESOURCE_VIDEO_OVERLAY) + debug_warning(" resource VIDEO OVERLAY\n"); + if (resource_status & ASM_RESOURCE_STREAMING) + debug_warning(" resource STREAMING\n"); + if (resource_status & ASM_RESOURCE_HW_ENCODER) + debug_warning(" resource HW ENCODER\n"); + if (resource_status & ASM_RESOURCE_HW_DECODER) + debug_warning(" resource HW DECODER\n"); + if (resource_status & ASM_RESOURCE_RADIO_TUNNER) + debug_warning(" resource RADIO TUNNER\n"); + if (resource_status & ASM_RESOURCE_TV_TUNNER) + debug_warning(" resource TV TUNNER\n"); + if (resource_status & ASM_RESOURCE_VOICECONTROL) + debug_warning(" resource for VOICECONTROL\n"); +} + +gboolean __need_to_compare_again(ASM_sound_events_t current_playing_event, int current_playing_handle, ASM_sound_events_t incoming_playing_event, int incoming_playing_handle, int *sound_case, int *blocked_reason) +{ + *blocked_reason = ERR_ASM_ERROR_NONE; + + switch(*sound_case) { + case ASM_CASE_1PLAY_2STOP: + break; + case ASM_CASE_1STOP_2PLAY: + break; + case ASM_CASE_1PAUSE_2PLAY: + { + int ret = MM_ERROR_NONE; + mm_sound_device_out device_out_wired_accessory = MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY; + mm_sound_device_in device_in = MM_SOUND_DEVICE_IN_NONE; + bool available = false; + + if (incoming_playing_event == ASM_EVENT_NOTIFY && (_mm_sound_is_recording() || _mm_sound_is_mute_policy()) ) { + ret = MMSoundMgrSessionIsDeviceAvailable (device_out_wired_accessory, device_in, &available); + if (ret) { + debug_error("Failed to IsDeviceAvailable()\n"); + } else { + /* if current playing event is NOTIFY with external device out, then we're going to jump to 1STOP_2PLAY */ + if (!available) { + debug_warning("EXCEPTION case in 1PAUSE_2PLAY => go to 1PLAY_2STOP\n"); + *sound_case = ASM_CASE_1PLAY_2STOP; + *blocked_reason = ERR_ASM_POLICY_CANNOT_PLAY_BY_PROFILE; /* check this value to let client know via message */ + return TRUE; + } + } + } + } + break; + case ASM_CASE_1PLAY_2PLAY_MIX: + { + int ret = MM_ERROR_NONE; + mm_sound_device_out device_out = MM_SOUND_DEVICE_OUT_NONE; + mm_sound_device_in device_in = MM_SOUND_DEVICE_IN_NONE; + + if (__is_media_session(current_playing_event) && __is_media_session(incoming_playing_event)) { + if ((!(g_handle_info[current_playing_handle].option_flags & ASM_SESSION_OPTION_UNINTERRUPTIBLE)) && + (g_handle_info[incoming_playing_handle].option_flags & ASM_SESSION_OPTION_PAUSE_OTHERS)) { + *sound_case = ASM_CASE_1PAUSE_2PLAY; + return TRUE; + } + } else if (current_playing_event == ASM_EVENT_NOTIFY && + (incoming_playing_event != ASM_EVENT_EARJACK_UNPLUG && __is_session_using_media_volume(incoming_playing_event))) { + ret = MMSoundMgrSessionGetDeviceActive(&device_out, &device_in); + if (ret) { + debug_error("Failed to GetDeviceActive()\n"); + } else { + /* if current playing event is NOTIFY with external device out, then we're going to jump to 1STOP_2PLAY */ + if (device_out == MM_SOUND_DEVICE_OUT_HDMI || + device_out == MM_SOUND_DEVICE_OUT_MIRRORING || + device_out == MM_SOUND_DEVICE_OUT_USB_AUDIO || + device_out == MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK) { + debug_warning("EXCEPTION case for external device in 1PLAY_2PLAY_MIX => go to 1STOP_2PLAY\n"); + *sound_case = ASM_CASE_1STOP_2PLAY; + *blocked_reason = ERR_ASM_POLICY_CANNOT_PLAY_BY_CUSTOM; + return TRUE; + } + } + } else if (current_playing_event == ASM_EVENT_ALARM && incoming_playing_event == ASM_EVENT_NOTIFY) { + if ((_mm_sound_is_recording() || _mm_sound_is_mute_policy())) { + debug_warning("EXCEPTION case for notification on alarm in 1PAUSE_2PLAY => go to 1PLAY_2STOP\n"); + *sound_case = ASM_CASE_1PLAY_2STOP; + *blocked_reason = ERR_ASM_POLICY_CANNOT_PLAY_BY_PROFILE; + return TRUE; + } + } else if ((current_playing_event == ASM_EVENT_MMCAMCORDER_VIDEO) && (incoming_playing_event == ASM_EVENT_MEDIA_MMPLAYER)) { + if ((g_handle_info[incoming_playing_handle].option_flags & ASM_SESSION_OPTION_PAUSE_OTHERS) && + (g_handle_info[incoming_playing_handle].resource & ASM_RESOURCE_HW_DECODER)) { + debug_warning("EXCEPTION case for current MMCAMCORDER_VIDEO / incoming MEDIA_MMPLAYER(PAUSE_OTHERS with HW_DECODER resource)\n"); + *sound_case = ASM_CASE_1PAUSE_2PLAY; + return TRUE; + } + } + +#if 0 /*as new UX defined camera can be launch during call*/ + else if (current_playing_event == ASM_EVENT_CALL && incoming_playing_event == ASM_EVENT_MMCAMCORDER_VIDEO) { + int shutter_policy_state = 0; + vconf_get_int(VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY, &shutter_policy_state); + if (shutter_policy_state == 1) { + debug_warning("EXCEPTION case for shutter policy in 1PLAY_2PLAY_MIX => go to 1PLAY_2STOP\n"); + *sound_case = ASM_CASE_1PLAY_2STOP; + *blocked_reason = ERR_ASM_POLICY_CANNOT_PLAY_BY_CUSTOM; + return TRUE; + } + } +#endif + } + break; + default: + break; + } + debug_log("no need to compare again, sound_case:%d, event_type:current(%d), incoming(%d)\n", *sound_case, current_playing_event, incoming_playing_event); + return FALSE; } -void __asm_compare_priority_matrix(ASM_msg_asm_to_lib_t *asm_snd_msg, ASM_msg_asm_to_lib_t *asm_ret_msg, - long int instance_id, int handle, ASM_requests_t request_id, - ASM_sound_events_t sound_event,ASM_sound_states_t sound_state, ASM_resource_t mm_resource) +asm_compare_result_t __asm_compare_priority_matrix(ASM_msg_asm_to_lib_t *asm_snd_msg, ASM_msg_asm_to_lib_t *asm_ret_msg, + int instance_id, int handle, ASM_requests_t request_id, + ASM_sound_events_t sound_event, ASM_sound_states_t sound_state, ASM_resource_t mm_resource) { int no_conflict_flag = 0; + asm_instance_list_t *incoming_list = NULL; + asm_compare_result_t compare_result; + memset(&compare_result, 0, sizeof(asm_compare_result_t)); + + debug_log(" ENTER >>>>>> \n"); - asm_info("[ASM_Server][%s] ENTER >>>>>> \n", __func__); + g_handle_info[handle].resource = mm_resource; - /* If nobody is playing now, this means no conflict */ - if (ASM_STATUS_NONE == g_sound_status_playing) { - asm_info("[ASM_Server][%s] No conflict ( No existing Sound )\n", __func__); + /* If nobody is playing and waiting now, this means no conflict */ + if (ASM_STATUS_NONE == g_sound_status_playing && ASM_STATUS_NONE == g_sound_status_waiting) { + debug_log(" No conflict ( No existing Sound )\n"); - ASM_SND_MSG_SET(asm_snd_msg, handle, -1, ASM_COMMAND_NONE, sound_state); + ASM_SND_MSG_SET_RESULT(asm_snd_msg, ASM_COMMAND_NONE, sound_state); no_conflict_flag = 1; } else { /* Somebody is playing */ - asm_instance_list_t *temp_list = head_list; - int updatedflag = 0; + asm_instance_list_t *temp_list = head_list_ptr; + int is_already_updated = 0; int cb_res = 0; int update_state = ASM_STATE_NONE; + ASM_sound_sub_events_t incoming_sound_sub_event = sound_event; - while (temp_list->next != tail_list) { + while (temp_list != NULL) { - asm_info("[ASM_Server][%s]( %5ld, %2d, %-20s, %-20s, %9s, 0x%04x) ..... [%s]\n", __func__, + /* Find who's playing now (include waiting state) */ + if ((temp_list->sound_state != ASM_STATE_PLAYING && temp_list->sound_state != ASM_STATE_WAITING) + || temp_list->is_registered_for_watching) { + temp_list = temp_list->next; + continue; + } + + debug_warning("( %5d, %2d, %-20s, %-20s, %9s, 0x%04x) ..... [%s]\n", temp_list->instance_id, temp_list->sound_handle, - ASM_sound_events_str[temp_list->sound_event], + ASM_sound_event_str[temp_list->sound_event], ASM_sound_state_str[temp_list->sound_state], ASM_sound_resume_str[temp_list->need_resume], temp_list->mm_resource, (temp_list->sound_state != ASM_STATE_PLAYING)? "PASS" : "CHECK"); - /* Find who's playing now */ - if (temp_list->sound_state != ASM_STATE_PLAYING) { - temp_list = temp_list->next; - continue; - } /* Found it */ - ASM_sound_states_t current_play_state = temp_list->sound_state; - ASM_sound_events_t current_play_sound_event = temp_list->sound_event; - long int current_play_instance_id = temp_list->instance_id; - int current_play_handle = temp_list->sound_handle; + ASM_sound_states_t current_playing_state = temp_list->sound_state; + ASM_sound_events_t current_playing_sound_event = temp_list->sound_event; + int current_playing_instance_id = temp_list->instance_id; + int current_playing_handle = temp_list->sound_handle; ASM_resource_t current_using_resource = temp_list->mm_resource; - if ((current_play_instance_id == instance_id) && (current_play_handle == handle)) { - asm_warning("[ASM_Server][%s] This is my handle. skip %d %d\n", __func__, instance_id, handle); + if ((current_playing_instance_id == instance_id) && (current_playing_handle == handle)) { + debug_warning(" This is my handle. skip %d %d\n", instance_id, handle); temp_list = temp_list->next; + if (current_playing_state != sound_state) { + __asm_change_state_list(instance_id, handle, sound_state, mm_resource); + } continue; } /* Request is PLAYING */ if (sound_state == ASM_STATE_PLAYING) { - /* Determine sound policy */ - ASM_sound_cases_t sound_case = ASM_sound_case[current_play_sound_event][sound_event]; + ASM_sound_cases_t sound_case = ASM_CASE_NONE; + ASM_sound_sub_events_t current_playing_sound_sub_event = ASM_SUB_EVENT_NONE; + + if (request_id == ASM_REQUEST_SET_SUBEVENT) { + int adv_asm_idx = 0; + int subtable_row_idx = 0; + int ret = MM_ERROR_NONE; + current_playing_sound_sub_event = temp_list->sound_sub_event; + /* Determine sound policy using SubTable */ + ret = __get_sub_case_table_idx(current_playing_sound_event, &subtable_row_idx); + if (ret) { + temp_list = temp_list->next; + continue; + } + + sound_event = __asm_find_event_of_handle(instance_id, handle); + ret = __get_adv_event_idx_for_subtable(sound_event, &adv_asm_idx); + if (ret) { + temp_list = temp_list->next; + continue; + } -#ifdef SUPPORT_GCF - /* GCF case is exception case */ - /* NOTE : GCF exception case only */ - if ((is_gcf) && (sound_case != ASM_CASE_1PLAY_2PLAY_MIX)) { - sound_case = ASM_CASE_1PLAY_2PLAY_MIX;; + sound_case = ASM_sound_case_sub[adv_asm_idx][incoming_sound_sub_event][subtable_row_idx]; + if (sound_case == ASM_CASE_SUB_EVENT) { + switch (incoming_sound_sub_event) { + case ASM_SUB_EVENT_NONE: + case ASM_SUB_EVENT_SHARE: + if (current_playing_sound_sub_event == ASM_SUB_EVENT_NONE || + current_playing_sound_sub_event == ASM_SUB_EVENT_SHARE) { + sound_case = ASM_CASE_1PLAY_2PLAY_MIX; + } + break; + case ASM_SUB_EVENT_EXCLUSIVE: + sound_case = ASM_CASE_1STOP_2PLAY; + break; + default: + sound_case = ASM_CASE_SUB_EVENT; + debug_warning("incoming_sound_sub_event is not valid: %d", incoming_sound_sub_event); + break; + } + } + debug_warning(" SubTable result:%s, sub-event:%s, adv. event type:%s", + ASM_sound_case_str[sound_case], ASM_sound_sub_event_str[incoming_sound_sub_event+1], ASM_sound_event_str[sound_event]); + } else { + /* Determine sound policy using MainTable */ + sound_case = ASM_sound_case[current_playing_sound_event][sound_event]; } -#endif - asm_critical("[ASM_Server][%s] Conflict policy[%x][%x]: %s\n", __func__, current_play_sound_event,sound_event,ASM_sound_cases_str[sound_case]); + debug_warning(" Conflict policy[0x%x][0x%x]: %s\n", current_playing_sound_event,sound_event,ASM_sound_case_str[sound_case]); +CONFLICT_AGAIN: switch (sound_case) { case ASM_CASE_1PLAY_2STOP: { - if (current_play_instance_id == instance_id) { + if (current_playing_instance_id == instance_id) { /* PID is policy group.*/ - asm_info("[ASM_Server][%s] Do not send Stop callback in same pid %ld\n", __func__, instance_id); - } else { - ASM_SND_MSG_SET(asm_snd_msg, handle, handle, ASM_COMMAND_STOP, sound_state); - temp_list = tail_list; /* skip all remain list */ - break; - } + debug_log(" Do not send Stop callback in same pid %d\n", instance_id); - /* Prepare msg to send */ - ASM_SND_MSG_SET(asm_snd_msg, handle, handle, ASM_COMMAND_PLAY, sound_state); + /* Prepare msg to send */ + ASM_SND_MSG_SET_RESULT(asm_snd_msg, ASM_COMMAND_PLAY, sound_state); - if (!updatedflag) { - if (request_id == ASM_REQUEST_REGISTER){ - __asm_register_list(instance_id, handle, sound_event, sound_state, mm_resource); + if (!is_already_updated && request_id == ASM_REQUEST_REGISTER){ + __asm_register_list(instance_id, handle, sound_event, sound_state, mm_resource, false); + is_already_updated = 1; } else { __asm_change_state_list(instance_id, handle, sound_state, mm_resource); } - updatedflag = 1; + break; + } else { + switch(current_playing_sound_event) { + case ASM_EVENT_ALARM: + debug_warning("blocked by ALARM"); + asm_snd_msg->data.error_code = ERR_ASM_POLICY_CANNOT_PLAY_BY_ALARM; + break; + case ASM_EVENT_CALL: + case ASM_EVENT_VIDEOCALL: + case ASM_EVENT_VOIP: + debug_warning("blocked by CALL/VIDEOCALL/VOIP"); + asm_snd_msg->data.error_code = ERR_ASM_POLICY_CANNOT_PLAY_BY_CALL; + break; + default: + debug_warning("blocked by Other(sound_event num:%d)", current_playing_sound_event); + asm_snd_msg->data.error_code = ERR_ASM_POLICY_CANNOT_PLAY; + break; + } + ASM_SND_MSG_SET_RESULT(asm_snd_msg, ASM_COMMAND_STOP, ASM_STATE_STOP); + temp_list = tail_list_ptr; /* skip all remain list */ + __asm_change_state_list(instance_id, handle, ASM_STATE_STOP, mm_resource); + break; } - break; } case ASM_CASE_1STOP_2PLAY: { - if (current_play_instance_id == instance_id) { + if (current_playing_instance_id == instance_id) { /* PID is policy group. */ - asm_info("[ASM_Server][%s] Do not send Stop callback in same pid %ld\n", __func__, instance_id); + debug_warning(" Do not send Stop callback in same pid %d\n", instance_id); + } else { ASM_event_sources_t event_src; - unsigned short resource_status = current_using_resource & mm_resource; /* Determine root cause of conflict */ - if (resource_status != ASM_RESOURCE_NONE) { - event_src = ASM_EVENT_SOURCE_RESOURCE_CONFLICT; - } else { - switch (sound_event) { - case ASM_EVENT_CALL: - case ASM_EVENT_RICH_CALL: - case ASM_EVENT_VIDEOCALL: - event_src = ASM_EVENT_SOURCE_CALL_START; - break; - - case ASM_EVENT_EARJACK_UNPLUG: - event_src = ASM_EVENT_SOURCE_EARJACK_UNPLUG; - break; - - case ASM_EVENT_ALARM: - event_src = ASM_EVENT_SOURCE_ALARM_START; - break; - - default: - event_src = ASM_EVENT_SOURCE_OTHER_APP; - break; - } - } + event_src = __mapping_sound_event_to_event_src(sound_event, mm_resource, ASM_CASE_1STOP_2PLAY); /* Execute callback function for monitor handle */ int monitor_handle = -1; - if (__find_clean_monitor_handle(current_play_instance_id, &monitor_handle)) { - cb_res = __do_callback(current_play_instance_id, monitor_handle, ASM_COMMAND_STOP, event_src); - asm_warning("[ASM_Server][%s] send stop callback for monitor handle of pid %d\n", __func__, current_play_instance_id); - if (cb_res != ASM_CB_RES_NONE && cb_res != ASM_CB_RES_STOP) { - asm_error_r("[ASM_Server][%s] oops! not suspected callback result %d\n", __func__, cb_res); - } - __set_monitor_dirty(current_play_instance_id); - - /* If current is playing and input event is CALL/VIDEOCALL/ALARM, set to need resume */ - if ( __is_need_resume(sound_event) && (current_play_state == ASM_STATE_PLAYING) ) { - __asm_change_need_resume_list(current_play_instance_id, monitor_handle, ASM_NEED_RESUME); - } - } + ASM_DO_MONITOR_CALLBACK(current_playing_instance_id, monitor_handle, ASM_COMMAND_STOP, event_src); /* Execute callback function for worker handle */ - cb_res = __do_callback(current_play_instance_id,current_play_handle,ASM_COMMAND_STOP, event_src); - if (cb_res != ASM_CB_RES_NONE && cb_res != ASM_CB_RES_STOP) - asm_error_r("[ASM_Server][%s] oops! not suspected result %d\n", __func__, cb_res); - asm_warning("[ASM_Server][%s] __asm_compare_priority_matrix(1STOP_2PLAY) : __do_callback Complete : TID=%ld, handle=%d", - __func__, current_play_instance_id,current_play_handle ); - - /* If current is playing and input event is CALL/VIDEOCALL/ALARM, set to need resume */ - if( __is_need_resume(sound_event) && (current_play_state == ASM_STATE_PLAYING) ) { - __asm_change_need_resume_list(current_play_instance_id, current_play_handle, ASM_NEED_RESUME); + cb_res = __do_callback(current_playing_instance_id,current_playing_handle, ASM_COMMAND_STOP, event_src); + if (cb_res != ASM_CB_RES_NONE && cb_res != ASM_CB_RES_STOP) { + debug_error(" oops! not suspected result %d\n", cb_res); } + debug_warning(" 1STOP_2PLAY : __do_callback Complete, TID=%d, handle=%d", + current_playing_instance_id,current_playing_handle ); - /* Set state to NONE */ - /* FIXME: is it okay to set none instead on STOP? */ - //__asm_change_state_list(current_play_instance_id, current_play_handle, ASM_STATE_NONE, ASM_RESOURCE_NONE); - __asm_change_state_list(current_play_instance_id, current_play_handle, - (cb_res == ASM_CB_RES_STOP)? ASM_STATE_STOP : ASM_STATE_NONE, - ASM_RESOURCE_NONE); - - - /* TODO: what if stopped is fmradio???? */ - if (current_play_sound_event == ASM_EVENT_SHARE_FMRADIO || - current_play_sound_event == ASM_EVENT_EXCLUSIVE_FMRADIO) - { - session_t cur_session; - MMSoundMgrSessionGetSession(&cur_session); - if (cur_session == SESSION_FMRADIO) { - asm_info ("[ASM_Server][%s] ****** SESSION_FMRADIO end ******\n", __func__); - MMSoundMgrSessionSetSession(SESSION_FMRADIO, SESSION_END); - } - } + /* Set state to STOP or NONE */ + __asm_change_state_list(current_playing_instance_id, current_playing_handle, ASM_STATE_STOP, current_using_resource); + + compare_result.previous_asm_handle[compare_result.previous_num_of_changes++] = temp_list; } /* Prepare msg to send */ - ASM_SND_MSG_SET(asm_snd_msg, handle, handle, ASM_COMMAND_PLAY, sound_state); + ASM_SND_MSG_SET_RESULT(asm_snd_msg, ASM_COMMAND_PLAY, sound_state); - if (!updatedflag) { - if (request_id == ASM_REQUEST_REGISTER) { - __asm_register_list(instance_id, handle, sound_event, sound_state, mm_resource); - } else { - __asm_change_state_list(instance_id, handle, sound_state, mm_resource); - } - updatedflag = 1; + if (!is_already_updated && request_id == ASM_REQUEST_REGISTER) { + incoming_list = __asm_register_list(instance_id, handle, sound_event, sound_state, mm_resource, false); + is_already_updated = 1; + } else { + incoming_list = __asm_change_state_list(instance_id, handle, sound_state, mm_resource); + } + if (incoming_list) { + compare_result.incoming_asm_handle[compare_result.incoming_num_of_changes++] = incoming_list; } + break; } case ASM_CASE_1PAUSE_2PLAY: { ASM_resource_t update_resource = current_using_resource; - if (current_play_instance_id == instance_id) { - asm_info("[ASM_Server][%s] Do not send Pause callback in same pid %ld\n", __func__, instance_id); + if (current_playing_instance_id == instance_id) { + debug_warning(" Do not send Pause callback in same pid %d\n", instance_id); } else { ASM_event_sources_t event_src; ASM_sound_commands_t command; - unsigned short resource_status = current_using_resource & mm_resource; + /* Check exception */ + if (__need_to_compare_again(current_playing_sound_event, current_playing_handle, sound_event, handle, (int *)(&sound_case), &asm_snd_msg->data.error_code)) { + goto CONFLICT_AGAIN; + } + + unsigned int resource_status = current_using_resource & mm_resource; if (resource_status != ASM_RESOURCE_NONE) { - asm_info("[ASM_Server][%s] resource conflict found 0x%x\n", __func__, resource_status); + debug_log(" resource conflict found 0x%x\n", resource_status); event_src = ASM_EVENT_SOURCE_RESOURCE_CONFLICT; command = ASM_COMMAND_STOP; } else { - switch (sound_event) { - case ASM_EVENT_CALL: - case ASM_EVENT_RICH_CALL: - case ASM_EVENT_VIDEOCALL: - event_src = ASM_EVENT_SOURCE_CALL_START; - break; - - case ASM_EVENT_EARJACK_UNPLUG: - event_src = ASM_EVENT_SOURCE_EARJACK_UNPLUG; - break; - - case ASM_EVENT_ALARM: - event_src = ASM_EVENT_SOURCE_ALARM_START; - break; - - case ASM_EVENT_SHARE_MMPLAYER: - case ASM_EVENT_EXCLUSIVE_MMPLAYER: - if ( current_play_sound_event == ASM_EVENT_SHARE_MMPLAYER || - current_play_sound_event == ASM_EVENT_EXCLUSIVE_MMPLAYER ) { - event_src = ASM_EVENT_SOURCE_OTHER_PLAYER_APP; - break; - } - - default: - event_src = ASM_EVENT_SOURCE_OTHER_APP; - break; - } + event_src = __mapping_sound_event_to_event_src(sound_event, mm_resource, ASM_CASE_1PAUSE_2PLAY); command = ASM_COMMAND_PAUSE; } /* Execute callback function for monitor handle */ int monitor_handle = -1; - if (__find_clean_monitor_handle(current_play_instance_id, &monitor_handle)) { - cb_res = __do_callback(current_play_instance_id, monitor_handle, ASM_COMMAND_STOP, event_src); - asm_warning("[ASM_Server][%s] send stop callback for monitor handle of pid %d\n", __func__, current_play_instance_id); - if (cb_res != ASM_CB_RES_NONE && cb_res != ASM_CB_RES_STOP) { - asm_error_r("[ASM_Server][%s] oops! not suspected callback result %d\n", __func__, cb_res); - } - __set_monitor_dirty(current_play_instance_id); - - /* If current is playing and input event is CALL/VIDEOCALL/ALARM, set to need resume */ - if( __is_need_resume(sound_event) && (current_play_state == ASM_STATE_PLAYING)) { - __asm_change_need_resume_list(current_play_instance_id, monitor_handle, ASM_NEED_RESUME); - } - } + ASM_DO_MONITOR_CALLBACK(current_playing_instance_id, monitor_handle, command, event_src); + ASM_CHECK_RESUME (sound_event, mm_resource, current_playing_sound_event, current_playing_instance_id, current_playing_state, monitor_handle, + instance_id, handle, event_src); /* Execute callback function for worker handle */ - cb_res = __do_callback(current_play_instance_id,current_play_handle,command, event_src); - asm_warning("[ASM_Server][%s] (1PAUSE_2PLAY) : Callback of %s: TID(%ld)\n", - __func__,ASM_sound_command_str[command], current_play_instance_id); + cb_res = __do_callback(current_playing_instance_id,current_playing_handle, command, event_src); + debug_warning(" 1PAUSE_2PLAY : Callback of %s, TID(%d), result(%d)", + ASM_sound_command_str[command], current_playing_instance_id, cb_res); /*Change current sound' state when it is in 1Pause_2Play case */ switch (cb_res) { case ASM_CB_RES_PAUSE: update_state = ASM_STATE_PAUSE; break; - + case ASM_CB_RES_IGNORE: case ASM_CB_RES_NONE: - case ASM_CB_RES_STOP: update_state = ASM_STATE_NONE; - update_resource = ASM_RESOURCE_NONE; break; - - case ASM_CB_RES_IGNORE: - update_state = ASM_STATE_IGNORE; + case ASM_CB_RES_STOP: + update_state = ASM_STATE_STOP; break; - default: - asm_error_r("[ASM_Server][%s] oops! not suspected result %d\n", __func__, cb_res); + debug_error(" oops! not suspected result %d\n", cb_res); update_state = ASM_STATE_NONE; break; } - - /* If current is playing and input event is CALL/VIDEOCALL/ALARM, set to need resume */ - if( __is_need_resume(sound_event) - &&(current_play_state == ASM_STATE_PLAYING)) { - __asm_change_need_resume_list(current_play_instance_id, current_play_handle, ASM_NEED_RESUME); + if(current_playing_sound_event == ASM_EVENT_MEDIA_OPENAL) { + update_state = ASM_STATE_PLAYING; } + ASM_CHECK_RESUME (sound_event, mm_resource, current_playing_sound_event, current_playing_instance_id, current_playing_state, current_playing_handle, + instance_id, handle, event_src); - __asm_change_state_list(current_play_instance_id, current_play_handle, update_state, update_resource); + __asm_change_state_list(current_playing_instance_id, current_playing_handle, update_state, update_resource); + + compare_result.previous_asm_handle[compare_result.previous_num_of_changes++] = temp_list; } /* Prepare msg to send */ - ASM_SND_MSG_SET(asm_snd_msg, handle, handle, ASM_COMMAND_PLAY, sound_state); + ASM_SND_MSG_SET_RESULT(asm_snd_msg, ASM_COMMAND_PLAY, sound_state); - if (!updatedflag) { - if (request_id == ASM_REQUEST_REGISTER) { - __asm_register_list(instance_id, handle, sound_event, sound_state, mm_resource); - } else { - __asm_change_state_list(instance_id, handle, sound_state, mm_resource); - } - updatedflag = 1; + if (!is_already_updated && request_id == ASM_REQUEST_REGISTER) { + incoming_list = __asm_register_list(instance_id, handle, sound_event, sound_state, mm_resource, false); + is_already_updated = 1; + } else { + incoming_list = __asm_change_state_list(instance_id, handle, sound_state, mm_resource); + } + if (incoming_list) { + compare_result.incoming_asm_handle[compare_result.incoming_num_of_changes++] = incoming_list; } break; } case ASM_CASE_1PLAY_2PLAY_MIX: { - if (current_play_instance_id == instance_id) { - asm_info("[ASM_Server] Do not send check resource conflict in same pid %ld\n", instance_id); + if (current_playing_instance_id == instance_id) { + debug_warning(" Do not send check resource conflict in same pid %d\n", instance_id); } else { /* MIX but need to check resource conflict */ - asm_warning("[ASM_Server][%s] 1PLAY_2PLAY_MIX : !!!\n", __func__); + debug_warning(" 1PLAY_2PLAY_MIX\n"); + + /* Check exception */ + if (__need_to_compare_again(current_playing_sound_event, current_playing_handle, sound_event, handle, (int *)(&sound_case), &asm_snd_msg->data.error_code)) { + goto CONFLICT_AGAIN; + } + ASM_resource_t update_resource = current_using_resource; - unsigned short resource_status = current_using_resource & mm_resource; + unsigned int resource_status = current_using_resource & mm_resource; if (resource_status) { /* Resouce conflict */ - asm_warning("[ASM_Server][%s] there is system resource conflict 0x%x\n", __func__, resource_status); + debug_warning(" there is system resource conflict 0x%x\n", resource_status); __print_resource(resource_status); /* Execute callback function for monitor handle */ int monitor_handle = -1; - if (__find_clean_monitor_handle(current_play_instance_id, &monitor_handle)) { - cb_res = __do_callback(current_play_instance_id, monitor_handle, ASM_COMMAND_STOP, ASM_EVENT_SOURCE_RESOURCE_CONFLICT); - if (cb_res != ASM_CB_RES_NONE && cb_res != ASM_CB_RES_STOP) { - asm_error_r("[ASM_Server][%s] oops! not suspected callback result %d\n", __func__, cb_res); - } - asm_warning("[ASM_Server][%s] send stop callback for monitor handle of pid %d\n", __func__, current_play_instance_id); - __set_monitor_dirty(current_play_instance_id); - - /* If current is playing and input event is CALL/VIDEOCALL/ALARM, set to need resume */ - if( __is_need_resume(sound_event) - && (current_play_state == ASM_STATE_PLAYING) ) { - __asm_change_need_resume_list(current_play_instance_id, monitor_handle, ASM_NEED_RESUME); - } - } + ASM_DO_MONITOR_CALLBACK(current_playing_instance_id, monitor_handle, ASM_COMMAND_STOP, ASM_EVENT_SOURCE_RESOURCE_CONFLICT); /* Execute callback function for worker handle */ /* Stop current resource holding instance */ - cb_res = __do_callback(current_play_instance_id, current_play_handle, ASM_COMMAND_STOP, ASM_EVENT_SOURCE_RESOURCE_CONFLICT); - asm_warning("[ASM_Server][%s] 1PLAY_2PLAY_MIX : Resource Conflict : TID(%ld)\n", - __func__, current_play_instance_id); + cb_res = __do_callback(current_playing_instance_id, current_playing_handle, ASM_COMMAND_STOP, ASM_EVENT_SOURCE_RESOURCE_CONFLICT); + debug_warning(" 1PLAY_2PLAY_MIX : Resource Conflict, TID(%d)\n", current_playing_instance_id); /* Change current sound */ switch (cb_res) { + case ASM_CB_RES_IGNORE: case ASM_CB_RES_NONE: - case ASM_CB_RES_STOP: update_state = ASM_STATE_NONE; - update_resource = ASM_RESOURCE_NONE; break; - - case ASM_CB_RES_IGNORE: - update_state = ASM_STATE_IGNORE; + case ASM_CB_RES_STOP: + update_state = ASM_STATE_STOP; break; - default: - asm_error_r("[ASM_Server][%s] oops! not suspected result %d\n", __func__, cb_res); + debug_error(" oops! not suspected result %d\n", cb_res); update_state = ASM_STATE_NONE; break; } - __asm_change_state_list(current_play_instance_id, current_play_handle, update_state, update_resource); + __asm_change_state_list(current_playing_instance_id, current_playing_handle, update_state, update_resource); + + compare_result.previous_asm_handle[compare_result.previous_num_of_changes++] = temp_list; } } /* Prepare msg to send */ - ASM_SND_MSG_SET(asm_snd_msg, handle, handle, ASM_COMMAND_PLAY, sound_state); + ASM_SND_MSG_SET_RESULT(asm_snd_msg, ASM_COMMAND_PLAY, sound_state); - if (!updatedflag) { - if (request_id == ASM_REQUEST_REGISTER) { - __asm_register_list(instance_id, handle, sound_event, sound_state, mm_resource); + if (!is_already_updated && request_id == ASM_REQUEST_REGISTER) { + incoming_list = __asm_register_list(instance_id, handle, sound_event, sound_state, mm_resource, false); + is_already_updated = 1; + } else { + incoming_list = __asm_change_state_list(instance_id, handle, sound_state, mm_resource); + } + if (incoming_list) { + compare_result.incoming_asm_handle[compare_result.incoming_num_of_changes++] = incoming_list; + } + + break; + } + + case ASM_CASE_RESOURCE_CHECK: + { + unsigned int resource_status = current_using_resource & mm_resource; + if (resource_status!= ASM_RESOURCE_NONE) { + debug_log(" ASM_CASE_RESOURCE_CHECK : resource conflict found 0x%x\n", resource_status); + + switch (resource_status){ + case ASM_RESOURCE_CAMERA: + if (current_playing_sound_event == ASM_EVENT_MMCAMCORDER_VIDEO || + current_playing_sound_event == ASM_EVENT_VIDEOCALL) { + /* 1PLAY,2STOP */ + debug_log(" ASM_CASE_RESOURCE_CHECK : 1PLAY_2STOP"); + + ASM_SND_MSG_SET_RESULT(asm_snd_msg, ASM_COMMAND_STOP, ASM_STATE_STOP); + temp_list = tail_list_ptr; /* skip all remain list */ + __asm_change_state_list(instance_id, handle, ASM_STATE_STOP, mm_resource); + + } else if (current_playing_sound_event == ASM_EVENT_EXCLUSIVE_RESOURCE){ + /* 1STOP,2PLAY */ + ASM_event_sources_t event_src; + event_src = ASM_EVENT_SOURCE_RESOURCE_CONFLICT; + + /* Execute callback function for worker handle */ + cb_res = __do_callback(current_playing_instance_id,current_playing_handle,ASM_COMMAND_STOP, event_src); + if (cb_res != ASM_CB_RES_NONE && cb_res != ASM_CB_RES_STOP) { + debug_error(" oops! not suspected result %d\n", cb_res); + } + debug_warning(" ASM_CASE_RESOURCE_CHECK : 1STOP_2PLAY, __do_callback Complete : TID=%d, handle=%d", + current_playing_instance_id,current_playing_handle ); + + /* Set state to STOP */ + __asm_change_state_list(current_playing_instance_id, current_playing_handle, ASM_STATE_STOP, current_using_resource); + + /* Prepare msg to send */ + ASM_SND_MSG_SET_RESULT(asm_snd_msg, ASM_COMMAND_PLAY, sound_state); + + if (!is_already_updated && request_id == ASM_REQUEST_REGISTER) { + incoming_list = __asm_register_list(instance_id, handle, sound_event, sound_state, mm_resource, false); + is_already_updated = 1; + } else { + incoming_list = __asm_change_state_list(instance_id, handle, sound_state, mm_resource); + } + if (incoming_list) { + compare_result.incoming_asm_handle[compare_result.incoming_num_of_changes++] = incoming_list; + } + } + break; + default: + debug_warning(" ASM_CASE_RESOURCE_CHECK : Not support it(0x%x)", resource_status); + break; + } + } else { + debug_log(" ASM_CASE_RESOURCE_CHECK : do MIX"); + /* Prepare msg to send */ + ASM_SND_MSG_SET_RESULT(asm_snd_msg, ASM_COMMAND_PLAY, sound_state); + + if (!is_already_updated && request_id == ASM_REQUEST_REGISTER) { + incoming_list = __asm_register_list(instance_id, handle, sound_event, sound_state, mm_resource, false); + is_already_updated = 1; } else { - __asm_change_state_list(instance_id, handle, sound_state, mm_resource); + incoming_list = __asm_change_state_list(instance_id, handle, sound_state, mm_resource); + } + if (incoming_list) { + compare_result.incoming_asm_handle[compare_result.incoming_num_of_changes++] = incoming_list; } - updatedflag = 1; + } + break; + } + + case ASM_CASE_SUB_EVENT: + { + ASM_sound_commands_t result_command = ASM_COMMAND_PLAY; + ASM_sound_states_t result_sound_state = sound_state; + if (current_playing_instance_id == instance_id) { + /* PID is policy group. */ + debug_warning(" Do not compare with same pid %d in case of ASM_CASE_SUB_EVENT\n", instance_id); + + } else if (!ASM_IS_ADVANCED_ASM_EVENT(sound_event)) { + /* (current)advanced event type VS. (incoming)common event type */ + /* get previous sub-event type */ + asm_instance_list_t *asm_instance_h = NULL; + asm_instance_h = __asm_find_list(current_playing_handle); + if (!asm_instance_h) { + debug_error(" Something is wrong, skip this request.."); + } else { + debug_warning("current playing sub-event type : %s", subevent_str[asm_instance_h->sound_sub_event]); + /* get sub event type of current */ + if (asm_instance_h->sound_sub_event == ASM_SUB_EVENT_NONE || asm_instance_h->sound_sub_event == ASM_SUB_EVENT_SHARE) { + debug_warning(" ASM_CASE_SUB_EVENT : 1PLAY_2PLAY_MIX\n"); + sound_case = ASM_CASE_1PLAY_2PLAY_MIX; + goto CONFLICT_AGAIN; + + } else { + /* define exception case */ + bool is_exception_case = false; + is_exception_case = (sound_event == ASM_EVENT_NOTIFY); + if (is_exception_case) { + /* exception case : do not start it */ + debug_warning("EXCEPTION case ASM_CASE_SUB_EVENT : Do not start it"); + sound_case = ASM_CASE_1PLAY_2STOP; + } else { + sound_case = ASM_CASE_1STOP_2PLAY; + } + goto CONFLICT_AGAIN; + + } + } + } + + /* Prepare msg to send */ + ASM_SND_MSG_SET_RESULT(asm_snd_msg, result_command, result_sound_state); + + if (!is_already_updated && request_id == ASM_REQUEST_REGISTER) { + incoming_list = __asm_register_list(instance_id, handle, sound_event, result_sound_state, mm_resource, false); + is_already_updated = 1; + } else { + incoming_list = __asm_change_state_list(instance_id, handle, result_sound_state, mm_resource); + } + if (incoming_list) { + compare_result.incoming_asm_handle[compare_result.incoming_num_of_changes++] = incoming_list; } break; } default: { - ASM_SND_MSG_SET(asm_snd_msg, handle, handle, ASM_COMMAND_NONE, sound_state); - asm_warning("[ASM_Server][%s] ASM_CASE_NONE [It should not be seen] !!!\n", __func__); + ASM_SND_MSG_SET_RESULT(asm_snd_msg, ASM_COMMAND_NONE, sound_state); + debug_warning(" ASM_CASE_NONE [It should not be seen] !!!\n"); break; } } /* switch (sound_case) */ } else { /* Request was not PLAYING, this means no conflict, just do set */ - asm_info("[ASM_Server][%s] No Conflict (Just Register or Set State) !!!\n",__func__); - ASM_SND_MSG_SET(asm_snd_msg, handle, handle, ASM_COMMAND_NONE, sound_state); + debug_log(" No Conflict (Just Register or Set State) !!!\n"); + ASM_SND_MSG_SET_RESULT(asm_snd_msg, ASM_COMMAND_NONE, sound_state); if (sound_state == ASM_STATE_NONE) { - asm_info("[ASM_Server][%s] 1PLAY_2NONE : No Conflict !!!\n", __func__); + debug_log(" 1PLAY_2NONE : No Conflict !!!\n"); } else if (sound_state == ASM_STATE_WAITING) { - asm_info("[ASM_Server][%s] 1PLAY_2WAIT : No Conflict !!!\n", __func__); - } - - if (!updatedflag) { - if (request_id == ASM_REQUEST_REGISTER) { - __asm_register_list(instance_id, handle, sound_event, sound_state, mm_resource); + /* Request is WAITING */ + if (current_playing_instance_id == instance_id) { + debug_warning(" Do not check in same pid %d\n", instance_id); } else { - __asm_change_state_list(instance_id, handle, sound_state, mm_resource); + ASM_resource_t update_resource = current_using_resource; + unsigned int resource_status = current_using_resource & mm_resource; + if (resource_status) { /* Resouce conflict */ + debug_warning(" there is system resource conflict 0x%x\n", resource_status); + __print_resource(resource_status); + + /* Execute callback function for monitor handle */ + int monitor_handle = -1; + ASM_DO_MONITOR_CALLBACK(current_playing_instance_id, monitor_handle, ASM_COMMAND_STOP, ASM_EVENT_SOURCE_RESOURCE_CONFLICT); + + /* Execute callback function for worker handle */ + /* Stop current resource holding instance */ + cb_res = __do_callback(current_playing_instance_id, current_playing_handle, ASM_COMMAND_STOP, ASM_EVENT_SOURCE_RESOURCE_CONFLICT); + debug_warning(" Resource Conflict, TID(%d)\n", current_playing_instance_id); + + /* Change current sound */ + switch (cb_res) { + case ASM_CB_RES_IGNORE: + case ASM_CB_RES_NONE: + update_state = ASM_STATE_NONE; + break; + case ASM_CB_RES_STOP: + update_state = ASM_STATE_STOP; + break; + default: + debug_error(" oops! not suspected result %d\n", cb_res); + update_state = ASM_STATE_NONE; + break; + } + __asm_change_state_list(current_playing_instance_id, current_playing_handle, update_state, update_resource); + compare_result.previous_asm_handle[compare_result.previous_num_of_changes++] = temp_list; + } } - updatedflag = 1; + } + + if (!is_already_updated && request_id == ASM_REQUEST_REGISTER) { + incoming_list = __asm_register_list(instance_id, handle, sound_event, sound_state, mm_resource, false); + is_already_updated = 1; + } else { + incoming_list = __asm_change_state_list(instance_id, handle, sound_state, mm_resource); + } + if (incoming_list) { + compare_result.incoming_asm_handle[compare_result.incoming_num_of_changes++] = incoming_list; } } temp_list = temp_list->next; - } /* while (temp_list->next != tail_list) */ + } /* while (temp_list != NULL) */ /* Make all monitor handle dirty flag clean. */ __set_all_monitor_clean(); } - /* Find if resource confilct exists in case of 1Pause 2Play or 1Stop 2Play */ + /* Find if resource conflict exists in case of 1Pause 2Play or 1Stop 2Play */ if (ASM_STATUS_NONE != g_sound_status_pause && mm_resource != ASM_RESOURCE_NONE && (asm_snd_msg->data.result_sound_command == ASM_COMMAND_PLAY || no_conflict_flag)) { - asm_instance_list_t *temp_list = head_list; + asm_instance_list_t *temp_list = head_list_ptr; int cb_res = 0; - while (temp_list->next != tail_list) { + while (temp_list != NULL) { /* Who is in PAUSE state? */ if (temp_list->sound_state == ASM_STATE_PAUSE) { /* Found PAUSE state */ - asm_warning("[ASM_Server][%s] Now list's state is pause. %d %d\n", __func__, instance_id, handle); - ASM_sound_states_t current_play_state = temp_list->sound_state; - ASM_sound_events_t current_play_sound_event = temp_list->sound_event; - long int current_play_instance_id = temp_list->instance_id; - int current_play_handle = temp_list->sound_handle; + debug_warning(" Now list's state is pause. %d %d\n", temp_list->instance_id, temp_list->sound_handle); + ASM_sound_events_t current_playing_sound_event = temp_list->sound_event; + int current_playing_instance_id = temp_list->instance_id; + int current_playing_handle = temp_list->sound_handle; ASM_resource_t current_using_resource = temp_list->mm_resource; - if ((current_play_instance_id == instance_id) && (current_play_handle == handle)) { + if ((current_playing_instance_id == instance_id) && (current_playing_handle == handle)) { if (request_id == ASM_REQUEST_SETSTATE) { - asm_warning("[ASM_Server][%s] Own handle. Pause state change to play. %d %d\n", __func__, instance_id, handle); + debug_warning(" Own handle. Pause state change to play. %d %d\n", instance_id, handle); __asm_change_state_list(instance_id, handle, sound_state, mm_resource); } else { - asm_warning("[ASM_Server][%s] This is my handle. skip %d %d\n", __func__, instance_id, handle); + debug_warning(" This is my handle. skip %d %d\n", instance_id, handle); } temp_list = temp_list->next; continue; } if (sound_state == ASM_STATE_PLAYING) { - ASM_sound_cases_t sound_case = ASM_sound_case[current_play_sound_event][sound_event]; + ASM_sound_cases_t sound_case = ASM_sound_case[current_playing_sound_event][sound_event]; - asm_critical("[ASM_Server][%s] Conflict policy[%x][%x]: %s\n", __func__, current_play_sound_event, sound_event, ASM_sound_cases_str[sound_case]); + debug_log(" Conflict policy[0x%x][0x%x]: %s\n", current_playing_sound_event, sound_event, ASM_sound_case_str[sound_case]); switch (sound_case) { case ASM_CASE_1PAUSE_2PLAY: case ASM_CASE_1STOP_2PLAY: { - if (current_play_instance_id == instance_id) { + if (current_playing_instance_id == instance_id) { //PID is policy group. - asm_info("[ASM_Server][%s] Do not send Stop callback in same pid %ld\n", __func__, instance_id); + debug_log(" Do not send Stop callback in same pid %d\n", instance_id); } else { - unsigned short resource_status = current_using_resource & mm_resource; + unsigned int resource_status = current_using_resource & mm_resource; /* Check conflict with paused instance */ if (resource_status != ASM_RESOURCE_NONE) { - asm_warning("[ASM_Server][%s] there is system resource conflict with paused instance 0x%x\n", __func__, resource_status); + debug_warning(" there is system resource conflict with paused instance 0x%x\n", resource_status); __print_resource(resource_status); } else { - asm_info("[ASM_Server][%s] no resource conflict with paused instance\n", __func__); + debug_log(" no resource conflict with paused instance\n"); break; } /* Execute callback function for monitor handle */ int monitor_handle = -1; - if (__find_clean_monitor_handle(current_play_instance_id, &monitor_handle)) { - cb_res = __do_callback(current_play_instance_id, monitor_handle, ASM_COMMAND_STOP, ASM_EVENT_SOURCE_RESOURCE_CONFLICT); - if (cb_res != ASM_CB_RES_NONE && cb_res != ASM_CB_RES_STOP) { - asm_error_r("[ASM_Server][%s] oops! not suspected callback result %d\n", __func__, cb_res); - } - asm_warning("[ASM_Server][%s] send stop callback for monitor handle of pid %d\n", __func__, current_play_instance_id); - - __set_monitor_dirty(current_play_instance_id); - } + ASM_DO_MONITOR_CALLBACK(current_playing_instance_id, monitor_handle, ASM_COMMAND_STOP, ASM_EVENT_SOURCE_RESOURCE_CONFLICT); /* Execute callback function for worker handle */ - cb_res = __do_callback(current_play_instance_id,current_play_handle, ASM_COMMAND_STOP, ASM_EVENT_SOURCE_RESOURCE_CONFLICT); + cb_res = __do_callback(current_playing_instance_id,current_playing_handle, ASM_COMMAND_STOP, ASM_EVENT_SOURCE_RESOURCE_CONFLICT); if (cb_res != ASM_CB_RES_NONE && cb_res != ASM_CB_RES_STOP) { - asm_error_r("[ASM_Server][%s] oops! not suspected result %d\n", __func__, cb_res); + debug_error(" oops! not suspected result %d\n", cb_res); } - asm_warning("[ASM_Server][%s] 1STOP_2PLAY cause RESOURCE : __do_callback Complete : TID=%ld, handle=%d", - __func__, current_play_instance_id,current_play_handle ); + debug_warning(" 1STOP_2PLAY cause RESOURCE, __do_callback Complete : TID=%d, handle=%d", + current_playing_instance_id,current_playing_handle ); - __asm_change_state_list(current_play_instance_id, current_play_handle, ASM_STATE_NONE, ASM_RESOURCE_NONE); + __asm_change_state_list(current_playing_instance_id, current_playing_handle, ASM_STATE_NONE, ASM_RESOURCE_NONE); + + compare_result.previous_asm_handle[compare_result.previous_num_of_changes++] = temp_list; } - asm_info("[ASM_Server][%s] 1STOP_2PLAY cause RESOURCE : msg sent and then received msg !!!\n",__func__); + debug_log(" 1STOP_2PLAY cause RESOURCE : msg sent and then received msg !!!\n"); break; } default: - /* asm_warning("[ASM_Server] >>>> __asm_compare_priority_matrix : ASM_CASE_NONE [do not anything] !!!\n"); */ + /* debug_warning(" >>>> __asm_compare_priority_matrix : ASM_CASE_NONE [do not anything] !!!\n"); */ break; } /* switch (sound_case) */ } else { - /* asm_warning("[ASM_Server] >>>> __asm_compare_priority_matrix : ASM_CASE_NONE [do not anything] !!!\n"); */ + /* debug_warning(" >>>> __asm_compare_priority_matrix : ASM_CASE_NONE [do not anything] !!!\n"); */ } } /* if (temp_list->sound_state == ASM_STATE_PAUSE) */ temp_list = temp_list->next; - } /* while (temp_list->next != tail_list) */ + } /* while (temp_list != NULL) */ } /* Finally, no conflict */ if (no_conflict_flag) { if (request_id == ASM_REQUEST_REGISTER) { - __asm_register_list(instance_id, handle, sound_event, sound_state, mm_resource); + incoming_list = __asm_register_list(instance_id, handle, sound_event, sound_state, mm_resource, false); } else { - __asm_change_state_list(instance_id, handle, sound_state, mm_resource); + incoming_list = __asm_change_state_list(instance_id, handle, sound_state, mm_resource); } - } - /* Send response to client */ - asm_snd_msg->instance_id = instance_id; + if (incoming_list) { + compare_result.incoming_asm_handle[compare_result.incoming_num_of_changes++] = incoming_list; + } + } -#if 1 if (asm_ret_msg) { *asm_ret_msg = *asm_snd_msg; - } else { - __asm_snd_message(asm_snd_msg); } -#else - __asm_snd_message(asm_snd_msg); -#endif - asm_info("[ASM_Server][%s] LEAVE <<<<<< \n", __func__); + debug_log(" LEAVE <<<<<< \n"); + + return compare_result; } -void __asm_do_all_resume_callback(ASM_event_sources_t eventsrc) +void __asm_do_all_resume_callback(asm_paused_by_id_t paused_by_id) { - asm_instance_list_t *temp_list = head_list; + asm_instance_list_t *temp_list = head_list_ptr; int cb_res = 0; - asm_info("[ASM_Server][%s] >>>>>>>>>> ENTER with EventSrc [%d]\n", __func__, eventsrc); + debug_log(" >>>>>>>>>> ENTER\n"); - while (temp_list->next != tail_list) { - if (temp_list->need_resume == ASM_NEED_RESUME) { - { - cb_res = __do_callback(temp_list->instance_id, temp_list->sound_handle, ASM_COMMAND_RESUME, eventsrc); - switch (cb_res) { - case ASM_CB_RES_PLAYING: - temp_list->sound_state = ASM_STATE_PLAYING; - break; - case ASM_CB_RES_IGNORE: - case ASM_CB_RES_NONE: - case ASM_CB_RES_STOP: - case ASM_CB_RES_PAUSE: - default: - /* do nothing */ - break; - } + while (temp_list != NULL) { + if ((temp_list->need_resume == ASM_NEED_RESUME) && + temp_list->paused_by_id.pid == paused_by_id.pid && temp_list->paused_by_id.sound_handle == paused_by_id.sound_handle) { + if (__mm_sound_mgr_ipc_freeze_send (FREEZE_COMMAND_WAKEUP, temp_list->instance_id)) { + debug_warning("failed to send wake-up msg to the client pid(%d)",temp_list->instance_id); + } + debug_warning("EXECUTE RESUME CALLBACKS with interrupted EventSrc[%d], paused_by_pid[%d]/handle[%d], resumption pid[%d]/handle[%d]\n", + temp_list->paused_by_id.eventsrc, paused_by_id.pid, paused_by_id.sound_handle, temp_list->instance_id, temp_list->sound_handle); + cb_res = __do_callback(temp_list->instance_id, temp_list->sound_handle, temp_list->need_resume == ASM_NEED_RESUME ? ASM_COMMAND_RESUME : ASM_COMMAND_PAUSE, __convert_eventsrc_interrupted_to_completed(temp_list->paused_by_id.eventsrc)); + debug_warning("RESUME CALLBACKS END, cb_res(%d)\n", cb_res); + switch (cb_res) { + case ASM_CB_RES_PLAYING: + temp_list->sound_state = ASM_STATE_PLAYING; + break; + case ASM_CB_RES_IGNORE: + case ASM_CB_RES_NONE: + case ASM_CB_RES_STOP: + case ASM_CB_RES_PAUSE: + default: + /* do nothing */ + break; } temp_list->need_resume = ASM_NEED_NOT_RESUME; + temp_list->paused_by_id.pid = 0; + temp_list->paused_by_id.sound_handle = ASM_HANDLE_INIT_VAL; + temp_list->paused_by_id.eventsrc = ASM_EVENT_SOURCE_MEDIA;; } temp_list = temp_list->next; } - asm_info("[ASM_Server][%s] <<<<<<<<<< LEAVE\n", __func__); + debug_log(" <<<<<<<<<< LEAVE\n"); } -#ifdef USE_SECURITY -gboolean __asm_check_check_privilege (unsigned char* cookie) +void ___check_camcorder_status(int instance_id, int handle, ASM_sound_events_t sound_event, ASM_sound_states_t sound_state, ASM_resource_t mm_resource) { - int asm_gid = -1; - int retval = 0; + asm_instance_list_t *temp_list = head_list_ptr; + int camcordering = 0; + asm_instance_list_t *incoming_list = NULL; + asm_compare_result_t compare_result; + memset(&compare_result, 0x00, sizeof(asm_compare_result_t)); + + while (temp_list != NULL) { + if (temp_list->sound_state == ASM_STATE_PLAYING && (temp_list->sound_event == ASM_EVENT_MMCAMCORDER_VIDEO || temp_list->sound_event == ASM_EVENT_MMCAMCORDER_AUDIO)) { + camcordering = 1; + break; + } + temp_list = temp_list->next; + } + if (camcordering == 1) { + ASM_event_sources_t event_src; + int cb_res = 0; + + /* Determine root cause of conflict */ + event_src = __mapping_sound_event_to_event_src(sound_event, mm_resource, ASM_CASE_1STOP_2PLAY); + + /* Execute callback function for monitor handle */ + int monitor_handle = -1; + ASM_DO_MONITOR_CALLBACK(temp_list->instance_id, monitor_handle, ASM_COMMAND_STOP, event_src); + + /* Execute callback function for worker handle */ + cb_res = __do_callback(temp_list->instance_id, temp_list->sound_handle, ASM_COMMAND_STOP, event_src); + if (cb_res != ASM_CB_RES_NONE && cb_res != ASM_CB_RES_STOP) { + debug_error(" oops! not suspected result %d\n", cb_res); + } + debug_warning(" 1STOP_2PLAY : __do_callback Complete, TID=%d, handle=%d", + temp_list->instance_id, temp_list->sound_handle); + + /* Set state to STOP or NONE */ + __asm_change_state_list(temp_list->instance_id, temp_list->sound_handle, ASM_STATE_STOP, temp_list->mm_resource); - /* Get ASM server group id */ - asm_gid = security_server_get_gid("asm"); - asm_info ("[ASM_Server][Security] asm server gid = [%d]\n", asm_gid); - if (asm_gid < 0) { - asm_error ("[ASM_Server][Security] security_server_get_gid() failed. error=[%d]\n", asm_gid); - return false; + compare_result.previous_asm_handle[compare_result.previous_num_of_changes++] = temp_list; + + incoming_list = __asm_change_state_list(instance_id, handle, sound_state, mm_resource); + if (incoming_list) { + compare_result.incoming_asm_handle[compare_result.incoming_num_of_changes++] = incoming_list; + } + ASM_DO_WATCH_CALLBACK_FROM_RESULT(compare_result); + } +} + +int __asm_change_session (ASM_requests_t rcv_request, ASM_sound_events_t rcv_sound_event, ASM_sound_states_t rcv_sound_state, ASM_resource_t rcv_resource, bool is_for_recovery, bool *need_to_resume) +{ + int ret = MM_ERROR_NONE; + session_t cur_session; + + MMSoundMgrSessionGetSession(&cur_session); + debug_warning (" cur_session[%d] (0:MEDIA 1:VC 2:VT 3:VOIP 4:FM 5:NOTI 6:ALARM 7:EMER 8:VR)\n",cur_session); + if (is_for_recovery) { + if (need_to_resume) { + *need_to_resume = false; + } else { + debug_error (" need_to_resume(%x) is null..", need_to_resume); + return MM_ERROR_SOUND_INTERNAL; + } } - /* Check privilege with valid group id */ - retval = security_server_check_privilege((char *)cookie, asm_gid); - if (retval == SECURITY_SERVER_API_SUCCESS) { - asm_info("[ASM_Server][Security] security_server_check_privilege() returns [%d]\n", retval); - return true; + if (!is_for_recovery) { + /* change session setting for new sound event */ + if (rcv_request == ASM_REQUEST_REGISTER) { + + switch (rcv_sound_event) { + case ASM_EVENT_CALL: + debug_warning (" ****** SESSION_VOICECALL start ******\n"); + ret = MMSoundMgrSessionSetSession(SESSION_VOICECALL, SESSION_START); + if (ret) { + goto ERROR_CASE; + } + break; + case ASM_EVENT_VIDEOCALL: + debug_warning (" ****** SESSION_VIDEOCALL start ******\n"); + ret = MMSoundMgrSessionSetSession(SESSION_VIDEOCALL, SESSION_START); + if (ret) { + goto ERROR_CASE; + } + break; + case ASM_EVENT_VOIP: + debug_warning (" ****** SESSION_VOIP start ******\n"); + ret = MMSoundMgrSessionSetSession(SESSION_VOIP, SESSION_START); + if (ret) { + goto ERROR_CASE; + } + break; + case ASM_EVENT_EXCLUSIVE_RESOURCE: + if ( rcv_resource & ASM_RESOURCE_VOICECONTROL ) { + debug_warning (" ****** ASM_RESOURCE_VOICECONTROL START ******\n"); + if (vconf_set_int(VCONFKEY_SOUND_VOICE_CONTROL_STATUS, 1)) { + debug_error(" vconf_set_int(SOUND_VOICE_CONTROL_KEY, 1) fail\n"); + } + MMSoundMgrSessionSetVoiceControlState(true); + } + break; + default: + break; + } + + } else if (rcv_request == ASM_REQUEST_SETSTATE) { + + switch (rcv_sound_event) { + case ASM_EVENT_NOTIFY: + if (cur_session == SESSION_NOTIFICATION) { + debug_warning (" ****** SESSION_NOTIFICATION ongoing ******\n"); + SESSION_REF(cur_session); + } else if (cur_session == SESSION_ALARM) { + debug_warning (" ****** SESSION_ALARM ongoing ******\n"); + SESSION_REF(cur_session); + } else if (cur_session == SESSION_VOICECALL || cur_session == SESSION_VIDEOCALL || cur_session == SESSION_VOIP) { + debug_warning (" ****** Notify starts on Call/Voip session ******\n"); + } else { + debug_warning (" ****** SESSION_NOTIFICATION start ******\n"); + ret = MMSoundMgrSessionSetSession(SESSION_NOTIFICATION, SESSION_START); + if (ret) { + goto ERROR_CASE; + } + SESSION_REF_INIT(); + SESSION_REF(cur_session); + } + break; + case ASM_EVENT_ALARM: + if (cur_session == SESSION_ALARM) { + debug_warning (" ****** SESSION_ALARM ongoing ******\n"); + SESSION_REF(cur_session); + } else if (cur_session == SESSION_VOICECALL || cur_session == SESSION_VIDEOCALL || cur_session == SESSION_VOIP) { + debug_warning (" ****** Alarm starts on Call/Voip session ******\n"); + } else { + debug_warning (" ****** SESSION_ALARM start ******\n"); + ret = MMSoundMgrSessionSetSession(SESSION_ALARM, SESSION_START); + if (ret) { + goto ERROR_CASE; + } + SESSION_REF_INIT(); + SESSION_REF(cur_session); + } + break; + case ASM_EVENT_EMERGENCY: + if (cur_session == SESSION_EMERGENCY) { + debug_warning (" ****** SESSION_EMERGENCY ongoing ******\n"); + SESSION_REF(cur_session); + } else { + debug_warning (" ****** SESSION_EMERGENCY start ******\n"); + ret = MMSoundMgrSessionSetSession(SESSION_EMERGENCY, SESSION_START); + if (ret) { + goto ERROR_CASE; + } + SESSION_REF_INIT(); + SESSION_REF(cur_session); + } + break; + case ASM_EVENT_MEDIA_FMRADIO: + if (cur_session == SESSION_FMRADIO) { + debug_warning (" ****** SESSION_FMRADIO ongoing ******\n"); + SESSION_REF(cur_session); + } else { + debug_warning (" ****** SESSION_FMRADIO start ******\n"); + ret = MMSoundMgrSessionSetSession(SESSION_FMRADIO, SESSION_START); + if (ret) { + goto ERROR_CASE; + } + SESSION_REF_INIT(); + SESSION_REF(cur_session); + } + break; + case ASM_EVENT_MEDIA_MMPLAYER: + if (cur_session != SESSION_MEDIA) { + if (cur_session == SESSION_VOICE_RECOGNITION) { + /* Media and Voice Recognition can be mixed */ + debug_warning (" SESSION_VOICE_RECOGNITION exception case, no change\n"); + } else { + goto RECOVERY_CASE; + } + } + break; + case ASM_EVENT_MMCAMCORDER_AUDIO: + case ASM_EVENT_MMCAMCORDER_VIDEO: + if (cur_session != SESSION_MEDIA) { + if (cur_session == SESSION_VOICECALL || cur_session == SESSION_VIDEOCALL || + cur_session == SESSION_VOIP || cur_session == SESSION_FMRADIO) { + debug_warning (" ****** Voice/FMRadio recording starts on Call/Voip/FMRadio session ******\n"); + } else if (cur_session == SESSION_MEDIA) { + debug_warning (" ****** SESSION_MEDIA ongoing ******\n"); + } else { + goto RECOVERY_CASE; + } + } + break; + case ASM_EVENT_EARJACK_UNPLUG: + case ASM_EVENT_CALL: + case ASM_EVENT_VIDEOCALL: + case ASM_EVENT_VOIP: + case ASM_EVENT_EXCLUSIVE_RESOURCE: + break; + case ASM_EVENT_VOICE_RECOGNITION: + if (cur_session == SESSION_VOICE_RECOGNITION) { + debug_warning (" ****** SESSION_VOICE_RECOGNITION ongoing ******\n"); + SESSION_REF(cur_session); + } else { + debug_warning (" ****** SESSION_VOICE_RECOGNITION start ******\n"); + ret = MMSoundMgrSessionSetSession(SESSION_VOICE_RECOGNITION, SESSION_START); + if (ret) { + goto ERROR_CASE; + } + SESSION_REF_INIT(); + SESSION_REF(cur_session); + } + break; + + default: + /* recovery path for normal ASM event type */ + if (cur_session != SESSION_MEDIA) { + if (cur_session == SESSION_VOICE_RECOGNITION) { + /* Media and Voice Recognition can be mixed */ + debug_warning (" SESSION_VOICE_RECOGNITION exception case, no change\n"); + } else if (cur_session == SESSION_VOICECALL || cur_session == SESSION_VIDEOCALL || cur_session == SESSION_VOIP) { + debug_warning (" SESSION_VOICECALL/VIDEOCALL/VOIP exception case, no change\n"); + } else { + goto RECOVERY_CASE; + } + } + break; + } + } else if (rcv_request == ASM_REQUEST_SET_SUBEVENT) { + + switch (rcv_sound_event) { + case ASM_SUB_EVENT_SHARE: + /* wakeup mode */ + if (cur_session == SESSION_VOICE_RECOGNITION) { + subsession_t subsession = 0; + MMSoundMgrSessionGetSubSession(&subsession); + if (subsession == SUBSESSION_VR_NORMAL || subsession == SUBSESSION_VR_DRIVE) { + /* do nothing */ + } + } + break; + case ASM_SUB_EVENT_EXCLUSIVE: + /* command mode */ + if (cur_session == SESSION_VOICE_RECOGNITION) { + subsession_t subsession = 0; + MMSoundMgrSessionGetSubSession(&subsession); + if (subsession == SUBSESSION_VR_NORMAL || subsession == SUBSESSION_VR_DRIVE) { + /* do nothing */ + } + } + break; + default: + /* recovery path for normal ASM event type */ + if (cur_session != SESSION_MEDIA) { + goto RECOVERY_CASE; + } + break; + } + } } else { - asm_error("[ASM_Server][Security] security_server_check_privilege() returns [%d]\n", retval); - return false; + /* change session setting for recovery */ + if (rcv_request == ASM_REQUEST_UNREGISTER) { + + switch (rcv_sound_event) { + case ASM_EVENT_CALL: + debug_warning (" ****** SESSION_VOICECALL end ******\n"); + ret = MMSoundMgrSessionSetSession(SESSION_VOICECALL, SESSION_END); + if (ret) { + goto ERROR_CASE; + } + *need_to_resume = true; + break; + case ASM_EVENT_VIDEOCALL: + debug_warning (" ****** SESSION_VIDEOCALL end ******\n"); + ret = MMSoundMgrSessionSetSession(SESSION_VIDEOCALL, SESSION_END); + if (ret) { + goto ERROR_CASE; + } + *need_to_resume = true; + break; + case ASM_EVENT_VOIP: + debug_warning (" ****** SESSION_VOIP end ******\n"); + ret = MMSoundMgrSessionSetSession(SESSION_VOIP, SESSION_END); + if (ret) { + goto ERROR_CASE; + } + *need_to_resume = true; + break; + case ASM_EVENT_NOTIFY: + *need_to_resume = true; + break; + case ASM_EVENT_ALARM: + *need_to_resume = true; + break; + case ASM_EVENT_VOICE_RECOGNITION: + if (cur_session == SESSION_VOICE_RECOGNITION) { + SESSION_UNREF(cur_session); + if (IS_ON_GOING_SESSION()) { + debug_warning (" ****** KEEP GOING SESSION_VOICE_RECOGNITION ****** current ref.count(%d)\n", g_session_ref_count); + } else { + debug_warning (" ****** SESSION_VOICE_RECOGNITION end ******\n"); + ret = MMSoundMgrSessionSetSession(SESSION_VOICE_RECOGNITION, SESSION_END); + if (ret) { + goto ERROR_CASE; + } + } + } + *need_to_resume = true; + break; + case ASM_EVENT_MMCAMCORDER_AUDIO: + case ASM_EVENT_MMCAMCORDER_VIDEO: + if (cur_session == SESSION_MEDIA) { + debug_warning (" ****** SESSION_MEDIA for MMCAMCORDER end ******\n"); + ret = MMSoundMgrSessionSetSession(SESSION_MEDIA, SESSION_END); + if (ret) { + goto ERROR_CASE; + } + } + break; + case ASM_EVENT_EXCLUSIVE_RESOURCE: + if ( rcv_resource & ASM_RESOURCE_VOICECONTROL ) { + debug_warning (" ****** ASM_RESOURCE_VOICECONTROL END ******\n"); + MMSoundMgrSessionSetVoiceControlState(false); + if (vconf_set_int(VCONFKEY_SOUND_VOICE_CONTROL_STATUS, 0)) { + debug_error(" vconf_set_int(SOUND_VOICE_CONTROL_KEY, 0) fail\n"); + } + } + break; + default: + *need_to_resume = true; + break; + } + + } else if (rcv_request == ASM_REQUEST_SETSTATE) { + + if (rcv_sound_state == ASM_STATE_STOP) { + switch (rcv_sound_event) { + case ASM_EVENT_NOTIFY: + if (cur_session == SESSION_NOTIFICATION) { + SESSION_UNREF(cur_session); + if (IS_ON_GOING_SESSION()) { + debug_warning (" ****** KEEP GOING SESSION_NOTIFICATION ****** current ref.count(%d)\n", g_session_ref_count); + } else { + debug_warning (" ****** SESSION_NOTIFICATON end ******\n"); + ret = MMSoundMgrSessionSetSession(SESSION_NOTIFICATION, SESSION_END); + if (ret) { + goto ERROR_CASE; + } + } + } else if (cur_session == SESSION_ALARM) { + SESSION_UNREF(cur_session); + if (IS_ON_GOING_SESSION()) { + debug_warning (" ****** KEEP GOING SESSION_ALARM ****** current ref.count(%d)\n", g_session_ref_count); + } else { + debug_warning (" ****** SESSION_ALARM end ******\n"); + ret = MMSoundMgrSessionSetSession(SESSION_ALARM, SESSION_END); + if (ret) { + goto ERROR_CASE; + } + } + } else { + debug_warning (" ****** No need to end session : current session was [%d] ******\n", cur_session); + } + *need_to_resume = true; + break; + case ASM_EVENT_ALARM: + if (cur_session == SESSION_ALARM) { + SESSION_UNREF(cur_session); + if (IS_ON_GOING_SESSION()) { + debug_warning (" ****** KEEP GOING SESSION_ALARM ****** current ref.count(%d)\n", g_session_ref_count); + } else { + debug_warning (" ****** SESSION_ALARM end ******\n"); + ret = MMSoundMgrSessionSetSession(SESSION_ALARM, SESSION_END); + if (ret) { + goto ERROR_CASE; + } + } + } else if (cur_session == SESSION_VOICECALL || cur_session == SESSION_VIDEOCALL || cur_session == SESSION_VOIP) { + debug_warning (" ****** Alarm ends on Call/Voip session ******\n"); + } else { + debug_warning (" ****** Not expected case : current session was [%d] ******\n", cur_session); + } + *need_to_resume = true; + break; + case ASM_EVENT_EMERGENCY: + if (cur_session == SESSION_EMERGENCY) { + SESSION_UNREF(cur_session); + if (IS_ON_GOING_SESSION()) { + debug_warning (" ****** KEEP GOING SESSION_EMERGENCY ****** current ref.count(%d)\n", g_session_ref_count); + } else { + debug_warning (" ****** SESSION_EMERGENCY end ******\n"); + ret = MMSoundMgrSessionSetSession(SESSION_EMERGENCY, SESSION_END); + if (ret) { + goto ERROR_CASE; + } + } + } else { + debug_warning (" ****** Not expected case : current session was [%d] ******\n", cur_session); + } + *need_to_resume = true; + break; + case ASM_EVENT_MEDIA_FMRADIO: + if (cur_session == SESSION_FMRADIO) { + SESSION_UNREF(cur_session); + if (IS_ON_GOING_SESSION()) { + debug_warning (" ****** KEEP GOING SESSION_FMRADIO ****** current ref.count(%d)\n", g_session_ref_count); + } else { + debug_warning (" ****** SESSION_FMRADIO end ******"); + ret = MMSoundMgrSessionSetSession(SESSION_FMRADIO, SESSION_END); + if (ret) { + goto ERROR_CASE; + } + } + } else { + debug_warning (" Session is not SESSION_FMRADIO"); + } + *need_to_resume = true; + break; + case ASM_EVENT_MEDIA_MMPLAYER: + case ASM_EVENT_MEDIA_MMSOUND: + case ASM_EVENT_MEDIA_OPENAL: + case ASM_EVENT_MEDIA_WEBKIT: + *need_to_resume = true; + break; + case ASM_EVENT_VOICE_RECOGNITION: + if (cur_session == SESSION_VOICE_RECOGNITION) { + SESSION_UNREF(cur_session); + if (IS_ON_GOING_SESSION()) { + debug_warning (" ****** KEEP GOING SESSION_VOICE_RECOGNITION ****** current ref.count(%d)\n", g_session_ref_count); + } else { + debug_warning (" ****** SESSION_VOICE_RECOGNITION end ******\n"); + ret = MMSoundMgrSessionSetSession(SESSION_VOICE_RECOGNITION, SESSION_END); + if (ret) { + goto ERROR_CASE; + } + } + } else { + debug_warning (" ****** Not expected case : current session was [%d] ******\n", cur_session); + } + break; + default: + break; + } + } else if (rcv_sound_state == ASM_STATE_PAUSE) { + if (cur_session == SESSION_NOTIFICATION || + cur_session == SESSION_ALARM || + cur_session == SESSION_VOICE_RECOGNITION) { + if (IS_ON_GOING_SESSION()) { + SESSION_UNREF(cur_session); + } + } else if (cur_session == SESSION_MEDIA) { + if (__is_media_session(rcv_sound_event)) { + *need_to_resume = true; + } + } + } + } + debug_warning (" need_to_resume[%d]", *need_to_resume); + } + + MMSoundMgrSessionGetSession(&cur_session); + debug_msg (" cur_session[%d] : leave", cur_session); + + return ret; + +RECOVERY_CASE: + debug_warning (" ****** recovery case : current session(%d) end ******\n", cur_session); + ret = MMSoundMgrSessionSetSession(cur_session, SESSION_END); + if (ret) { + goto ERROR_CASE; } + SESSION_REF_INIT(); + return ret; + +ERROR_CASE: + debug_error (" failed to MMSoundMgrSessionSetSession()"); + return ret; } -#endif /* USE_SECURITY */ -int __asm_process_message (ASM_msg_lib_to_asm_t *asm_rcv_msg, ASM_msg_asm_to_lib_t *asm_ret_msg) + +int __asm_process_message (void *rcv_msg, void *ret_msg) { - long int rcv_instance_id; + int rcv_instance_id; ASM_requests_t rcv_request_id; ASM_sound_events_t rcv_sound_event; ASM_sound_states_t rcv_sound_state; ASM_resource_t rcv_resource; int rcv_sound_handle; - ASM_msg_asm_to_lib_t asm_snd_msg; + ASM_msg_lib_to_asm_t *asm_rcv_msg = (ASM_msg_lib_to_asm_t *)rcv_msg; + ASM_msg_asm_to_lib_t *asm_ret_msg = (ASM_msg_asm_to_lib_t *)ret_msg; + int ret = MM_ERROR_NONE; + asm_instance_list_t *asm_instance_h = NULL; - asm_info ("[ASM_Server] ===================================================================== [%s] Starting.... ", __func__); pthread_mutex_lock(&g_mutex_asm); - asm_info ("[ASM_Server] ===================================================================== [%s] Started!!! (LOCKED) ", __func__); + debug_log (" ===================================================================== Started!!! (LOCKED) "); rcv_instance_id = asm_rcv_msg->instance_id; rcv_sound_handle = asm_rcv_msg->data.handle; @@ -1491,181 +2931,196 @@ int __asm_process_message (ASM_msg_lib_to_asm_t *asm_rcv_msg, ASM_msg_asm_to_lib rcv_resource = asm_rcv_msg->data.system_resource; /*******************************************************************/ - asm_info("[ASM_Server] received msg (tid=%ld,handle=%d,req=%d,event=0x%x,state=0x%x,resource=0x%x)\n", - rcv_instance_id, rcv_sound_handle, rcv_request_id, rcv_sound_event, rcv_sound_state, rcv_resource); + debug_warning(" received msg (tid=%d,handle=%d,req=%d[%s],event=%d,state=%d[%s],resource=0x%x)\n", + rcv_instance_id, rcv_sound_handle, rcv_request_id, ASM_sound_request_str[rcv_request_id], + rcv_sound_event, rcv_sound_state, ASM_sound_state_str[rcv_sound_state], rcv_resource); if (rcv_request_id != ASM_REQUEST_EMERGENT_EXIT) { - asm_warning("[ASM_Server] request_id : %s\n", ASM_sound_request_str[rcv_request_id]); if (rcv_request_id == ASM_REQUEST_SET_SUBSESSION) { - asm_warning("[ASM_Server] subsession : %s\n", subsession_str[rcv_sound_event]); + debug_warning(" sub-session : %s\n", subsession_str[rcv_sound_event]); + } else if (rcv_request_id == ASM_REQUEST_SET_SUBEVENT) { + debug_warning(" sub-event : %s\n", subevent_str[rcv_sound_event]); + } else if (rcv_request_id == ASM_REQUEST_SET_SESSION_OPTIONS) { + debug_warning(" session-options : %x\n", rcv_sound_event); + } else if (rcv_request_id == ASM_REQUEST_GET_SUBSESSION || rcv_request_id == ASM_REQUEST_GET_SUBEVENT || ASM_REQUEST_GET_SESSION_OPTIONS) { + /* no log */ } else { - asm_warning("[ASM_Server] sound_event : %s\n", ASM_sound_events_str[rcv_sound_event]); - asm_warning("[ASM_Server] sound_state : %s\n", ASM_sound_state_str[rcv_sound_state]); - asm_warning("[ASM_Server] resource : 0x%x\n", rcv_resource); + debug_warning(" sound_event : %s\n", ASM_sound_event_str[rcv_sound_event]); } } /*******************************************************************/ - asm_info ("[ASM_Server] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ [%s]", __func__); + + memset(&asm_snd_msg, 0, sizeof(ASM_msg_asm_to_lib_t)); + + debug_log (" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); switch (rcv_request_id) { case ASM_REQUEST_REGISTER: -#ifdef USE_SECURITY - /* do security check */ - if (__asm_check_check_privilege(asm_rcv_msg->data.cookie) == 0) { - asm_error ("[ASM_Server][Security] __asm_check_check_privilege() failed....\n"); - asm_snd_msg.instance_id = rcv_instance_id; - asm_snd_msg.data.alloc_handle = -1; - asm_snd_msg.data.cmd_handle = -1; - asm_snd_msg.data.check_privilege = 0; - if (asm_ret_msg == NULL) - __asm_snd_message(&asm_snd_msg); - break; - } - asm_info ("[ASM_Server][Security] __asm_check_check_privilege() success\n"); - asm_snd_msg.data.check_privilege = 1; -#endif /* USE_SECURITY */ __check_dead_process(); __asm_get_empty_handle(rcv_instance_id, &rcv_sound_handle); - if (rcv_sound_handle == -1) { - asm_snd_msg.instance_id = rcv_instance_id; - asm_snd_msg.data.alloc_handle = -1; - asm_snd_msg.data.cmd_handle = -1; - if (asm_ret_msg == NULL) + if (rcv_sound_handle == ASM_HANDLE_INIT_VAL) { + ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, ASM_HANDLE_INIT_VAL, ASM_HANDLE_INIT_VAL, rcv_request_id); + if (asm_ret_msg == NULL) { __asm_snd_message(&asm_snd_msg); + } } else { - __asm_compare_priority_matrix(&asm_snd_msg, asm_ret_msg, - rcv_instance_id, rcv_sound_handle, rcv_request_id, rcv_sound_event, rcv_sound_state, rcv_resource); - - /* FIXME: Is this right place? */ - if (rcv_sound_event == ASM_EVENT_CALL || rcv_sound_event == ASM_EVENT_RICH_CALL) { - asm_info ("[ASM_Server] ****** SESSION_VOICECALL start ******\n"); - MMSoundMgrSessionSetSession(SESSION_VOICECALL, SESSION_START); - } else if (rcv_sound_event == ASM_EVENT_VIDEOCALL) { - asm_info ("[ASM_Server] ****** SESSION_VOIP start ******\n"); - MMSoundMgrSessionSetSession(SESSION_VOIP, SESSION_START); + asm_compare_result_t compare_result = __asm_compare_priority_matrix(&asm_snd_msg, asm_ret_msg, + rcv_instance_id, rcv_sound_handle, rcv_request_id, rcv_sound_event, rcv_sound_state, rcv_resource); + + if (asm_snd_msg.data.result_sound_command != ASM_COMMAND_STOP) { + /* do not execute below when the result is ASM_COMMAND_STOP */ + ret = __asm_change_session (rcv_request_id, rcv_sound_event, rcv_sound_state, rcv_resource, false, NULL); + if (ret) { + debug_error (" failed to __asm_change_session(), error(0x%x)", ret); + } + } + ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id); + if (asm_ret_msg == NULL) { + __asm_snd_message(&asm_snd_msg); } + ASM_DO_WATCH_CALLBACK_FROM_RESULT(compare_result); } break; case ASM_REQUEST_UNREGISTER: + asm_instance_h = __asm_find_list(rcv_sound_handle); + + bool need_to_resume = false; + ret = __asm_change_session (rcv_request_id, rcv_sound_event, rcv_sound_state, + (asm_instance_h)? asm_instance_h->mm_resource : rcv_resource, + true, &need_to_resume); + + /* enforce calling watch callback when current state of rcv_instance_id is still ASM_STATE_PLAYING */ + /* need to call the watch callback of Call event(STOP) because Call session is changed in ASM_REQUEST_UNREGISTER */ + if (__asm_find_state_of_handle(rcv_sound_handle) == ASM_STATE_PLAYING || + rcv_sound_event == ASM_EVENT_CALL) { + ASM_DO_WATCH_CALLBACK(rcv_sound_event, ASM_STATE_STOP); + } __asm_unregister_list(rcv_sound_handle); - /* only support resuming at end of call & alarm interrupt */ - switch (rcv_sound_event) { - case ASM_EVENT_CALL: - case ASM_EVENT_RICH_CALL: - case ASM_EVENT_VIDEOCALL: - if (rcv_sound_event == ASM_EVENT_CALL || rcv_sound_event == ASM_EVENT_RICH_CALL) { - asm_info ("[ASM_Server] ****** SESSION_VOICECALL end ******\n"); - MMSoundMgrSessionSetSession(SESSION_VOICECALL, SESSION_END); - } else if (rcv_sound_event == ASM_EVENT_VIDEOCALL) { - asm_info ("[ASM_Server] ****** SESSION_VOIP end ******\n"); - MMSoundMgrSessionSetSession(SESSION_VOIP, SESSION_END); + + if (ret) { + debug_error (" failed to __asm_change_session(), error(0x%x)", ret); + } else { + if (need_to_resume) { + asm_paused_by_id_t paused_by_id; + paused_by_id.pid = rcv_instance_id; + paused_by_id.sound_handle = rcv_sound_handle; + __asm_do_all_resume_callback(paused_by_id); } - __asm_do_all_resume_callback(ASM_EVENT_SOURCE_CALL_END); - break; - case ASM_EVENT_ALARM: - asm_info ("[ASM_Server] ****** SESSION_NOTIFICATION end ******\n"); - MMSoundMgrSessionSetSession(SESSION_NOTIFICATION, SESSION_END); - __asm_do_all_resume_callback(ASM_EVENT_SOURCE_ALARM_END); - break; - default: - break; } - break; case ASM_REQUEST_SETSTATE: __check_dead_process(); - if ( rcv_sound_state == ASM_STATE_PLAYING ) { - if ( __isItPlayingNow(rcv_instance_id, rcv_sound_handle)) { + ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id); + if (rcv_sound_state == ASM_STATE_PLAYING || rcv_sound_state == ASM_STATE_WAITING) { + if ( __is_it_playing_now(rcv_instance_id, rcv_sound_handle)) { __asm_change_state_list(rcv_instance_id, rcv_sound_handle, rcv_sound_state, rcv_resource); - - asm_snd_msg.data.cmd_handle = rcv_sound_handle; asm_snd_msg.data.result_sound_command = ASM_COMMAND_NONE; asm_snd_msg.data.result_sound_state = rcv_sound_state; - asm_snd_msg.instance_id = rcv_instance_id; - if (asm_ret_msg == NULL) + if (asm_ret_msg == NULL && rcv_sound_state == ASM_STATE_PLAYING) { __asm_snd_message(&asm_snd_msg); + } + } else if (_mm_sound_is_mute_policy() && (ASM_EVENT_NOTIFY == rcv_sound_event)) { + /*do not play notify sound in mute profile.*/ + asm_snd_msg.data.result_sound_command = ASM_COMMAND_STOP; + asm_snd_msg.data.result_sound_state = ASM_STATE_STOP; + asm_snd_msg.data.error_code = ERR_ASM_POLICY_CANNOT_PLAY_BY_PROFILE; + __asm_change_state_list(rcv_instance_id, rcv_sound_handle, ASM_STATE_STOP, rcv_resource); + if (asm_ret_msg == NULL) { + __asm_snd_message(&asm_snd_msg); + } + __temp_print_list("Set State (Not Play)"); + break; } else { - __asm_compare_priority_matrix(&asm_snd_msg, asm_ret_msg, - rcv_instance_id, rcv_sound_handle, rcv_request_id, rcv_sound_event, rcv_sound_state, rcv_resource); + __reset_resume_check(rcv_instance_id, ASM_HANDLE_INIT_VAL); + asm_compare_result_t compare_result = __asm_compare_priority_matrix(&asm_snd_msg, asm_ret_msg, + rcv_instance_id, rcv_sound_handle, rcv_request_id, rcv_sound_event, rcv_sound_state, rcv_resource); - /* FIXME: Is this right place? */ - /* If compare result is play and event was alarm, set session to notification */ if (asm_snd_msg.data.result_sound_command == ASM_COMMAND_PLAY || - asm_snd_msg.data.result_sound_command == ASM_COMMAND_NONE) { - switch (rcv_sound_event) - { - case ASM_EVENT_ALARM: - { - session_t cur_session; - MMSoundMgrSessionGetSession(&cur_session); - if (cur_session == SESSION_NOTIFICATION) { - asm_info ("[ASM_Server] ****** SESSION_NOTIFICATION ongoing ******\n"); - } else { - asm_info ("[ASM_Server] ****** SESSION_NOTIFICATION start ******\n"); - MMSoundMgrSessionSetSession(SESSION_NOTIFICATION, SESSION_START); - } - } - break; + asm_snd_msg.data.result_sound_command == ASM_COMMAND_NONE) { - case ASM_EVENT_SHARE_FMRADIO: - case ASM_EVENT_EXCLUSIVE_FMRADIO: - { - session_t cur_session; - MMSoundMgrSessionGetSession(&cur_session); - if (cur_session == SESSION_FMRADIO) { - asm_info ("[ASM_Server] ****** SESSION_FMRADIO ongoing ******\n"); - } else { - asm_info ("[ASM_Server] ****** SESSION_FMRADIO start ******\n"); - MMSoundMgrSessionSetSession(SESSION_FMRADIO, SESSION_START); - } - } - break; + ret = __asm_change_session (rcv_request_id, rcv_sound_event, rcv_sound_state, rcv_resource, false, NULL); + if (ret) { + debug_error (" failed to __asm_change_session(), error(0x%x)", ret); } } + if (asm_ret_msg == NULL && rcv_sound_state == ASM_STATE_PLAYING) { + __asm_snd_message(&asm_snd_msg); + } + + ASM_DO_WATCH_CALLBACK_FROM_RESULT(compare_result); } __temp_print_list("Set State (Play)"); } else { - __asm_change_state_list(rcv_instance_id, rcv_sound_handle, rcv_sound_state, rcv_resource); - - if (rcv_sound_state == ASM_STATE_STOP) { - switch (rcv_sound_event) - { - case ASM_EVENT_SHARE_FMRADIO: - case ASM_EVENT_EXCLUSIVE_FMRADIO: - { - session_t cur_session; - MMSoundMgrSessionGetSession(&cur_session); - if (cur_session == SESSION_FMRADIO) { - asm_info ("[ASM_Server] ****** SESSION_FMRADIO end ******\n"); - MMSoundMgrSessionSetSession(SESSION_FMRADIO, SESSION_END); + asm_instance_h = __asm_change_state_list(rcv_instance_id, rcv_sound_handle, rcv_sound_state, rcv_resource); + if(asm_instance_h) { + bool need_to_resume = false; + if (asm_instance_h->prev_sound_state == ASM_STATE_PLAYING) { + if (rcv_sound_state == ASM_STATE_STOP || rcv_sound_state == ASM_STATE_PAUSE) { + ret = __asm_change_session (rcv_request_id, rcv_sound_event, rcv_sound_state, rcv_resource, true, &need_to_resume); + if (ret) { + debug_error (" failed to __asm_change_session(), error(0x%x)", ret); } else { - asm_info ("[ASM_Server] Session is not SESSION_FMRADIO"); + if (need_to_resume) { + asm_paused_by_id_t paused_by_id; + paused_by_id.pid = rcv_instance_id; + paused_by_id.sound_handle = rcv_sound_handle; + __asm_do_all_resume_callback(paused_by_id); + } + } + /* Call session is changed in ASM_REQUEST_UNREGISTER */ + if (rcv_sound_event != ASM_EVENT_CALL) { // exception case for the watch callback(STOP) + ASM_DO_WATCH_CALLBACK(rcv_sound_event, rcv_sound_state); + } + } + } else if (asm_instance_h->prev_sound_state == ASM_STATE_PAUSE) { + if (rcv_sound_state == ASM_STATE_STOP) { + ret = __asm_change_session (rcv_request_id, rcv_sound_event, rcv_sound_state, rcv_resource, true, &need_to_resume); + if (ret) { + debug_error (" failed to __asm_change_session(), error(0x%x)", ret); + } else { + if (need_to_resume) { + asm_paused_by_id_t paused_by_id; + paused_by_id.pid = rcv_instance_id; + paused_by_id.sound_handle = rcv_sound_handle; + __asm_do_all_resume_callback(paused_by_id); + } + } + /* Call session is changed in ASM_REQUEST_UNREGISTER */ + if (rcv_sound_event != ASM_EVENT_CALL) { // exception case for the watch callback(STOP) + ASM_DO_WATCH_CALLBACK(rcv_sound_event, rcv_sound_state); } } - break; } } - __temp_print_list("Set State (Not Play)"); } break; case ASM_REQUEST_GETSTATE: - asm_snd_msg.instance_id = rcv_instance_id; - asm_snd_msg.data.result_sound_state = __asm_find_list(rcv_request_id, rcv_sound_handle); - if (asm_ret_msg == NULL) + { + asm_instance_list_t *asm_instance_h = NULL; + asm_instance_h = __asm_find_list(rcv_sound_handle); + if (asm_instance_h) { + asm_snd_msg.data.result_sound_state = asm_instance_h->sound_state; + asm_snd_msg.data.source_request_id = rcv_request_id; + } + ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id); + if (asm_ret_msg == NULL) { __asm_snd_message(&asm_snd_msg); + } break; + } case ASM_REQUEST_GETMYSTATE: __check_dead_process(); - asm_snd_msg.instance_id = rcv_instance_id; + ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id); asm_snd_msg.data.result_sound_state = __asm_find_process_status(rcv_instance_id); - if (asm_ret_msg == NULL) + if (asm_ret_msg == NULL) { __asm_snd_message(&asm_snd_msg); + } break; case ASM_REQUEST_DUMP: @@ -1674,76 +3129,406 @@ int __asm_process_message (ASM_msg_lib_to_asm_t *asm_rcv_msg, ASM_msg_asm_to_lib case ASM_REQUEST_SET_SUBSESSION: { - int rcv_subsession = rcv_sound_event; - int ret = 0; + subsession_t rcv_subsession = rcv_sound_event; //latest rcv_subsession is needed + bool do_set_subsession = true; - /* FIXME: have to check only call instance with playing stsate can request this */ if (rcv_subsession < SUBSESSION_VOICE || rcv_subsession >= SUBSESSION_NUM) { - /* TODO : Error Handling */ - debug_error ("[ASM_Server] Invalid subsession [%d] to set\n", rcv_subsession); + debug_error (" Invalid subsession [%d] to set\n", rcv_subsession); + break; } - asm_info ("[ASM_Server] ****** SUB-SESSION [%s] ******\n", subsession_str[rcv_subsession]); - ret = MMSoundMgrSessionSetSubSession(rcv_subsession); - if (ret != MM_ERROR_NONE) { - /* TODO : Error Handling */ - debug_error ("[ASM_Server] MMSoundMgrSessionSetSubSession failed....ret = [%x]\n", ret); + debug_warning (" ****** SUB-SESSION [%s] ******\n", subsession_str[rcv_subsession]); + + ASM_sound_events_t sound_event = __asm_find_event_of_handle(rcv_instance_id, rcv_sound_handle); + switch (sound_event) { + case ASM_EVENT_CALL: + case ASM_EVENT_VIDEOCALL: + case ASM_EVENT_VOIP: + { + if (rcv_subsession == SUBSESSION_VOICE) { + /*check camcoder status + special case check : + call & camcorder EX session can be mixed in Call Ringtone subsession + but in Call Voice subsession case , camcorder should stop.*/ + debug_warning("g_camcorder_ex_subsession %d", g_camcorder_ex_subsession); + if (g_camcorder_ex_subsession == SUBSESSION_RECORD_STEREO || g_camcorder_ex_subsession == SUBSESSION_RECORD_MONO) { + ___check_camcorder_status(rcv_instance_id, rcv_sound_handle, sound_event, rcv_sound_state, rcv_resource); + } + } + break; + } + case ASM_EVENT_VOICE_RECOGNITION: + { + int ret = 0; + int session_order = -1; + + session_t cur_session; + MMSoundMgrSessionGetSession(&cur_session); + debug_warning (" cur_session[%d] (0:MEDIA 1:VC 2:VT 3:VOIP 4:FM 5:NOTI 6:ALARM 7:EMER 8:VR)\n",cur_session); + if (cur_session == SESSION_VOICECALL || + cur_session == SESSION_VIDEOCALL || + cur_session == SESSION_VOIP ) { + debug_warning (" skip REQUEST_SET_SUBSESSION\n"); + do_set_subsession = false; + break; + } + if (cur_session != SESSION_VOICE_RECOGNITION && + (rcv_subsession == SUBSESSION_VR_NORMAL || rcv_subsession == SUBSESSION_VR_DRIVE)) { + /* if current session is not for VR, so we need to set it first */ + debug_warning (" ****** SESSION_VOICE_RECOGNITION start in REQUEST_SET_SUBSESSION ******\n"); + session_order = SESSION_START; + } else if (cur_session == SESSION_VOICE_RECOGNITION && rcv_subsession == SUBSESSION_INIT) { + /* if current session is for VR, but user request set sub-session to NONE, so we need to end it */ + debug_warning (" ****** SESSION_VOICE_RECOGNITION end in REQUEST_SET_SUBSESSION ******\n"); + session_order = SESSION_END; + } + if (session_order != -1) { + ret = MMSoundMgrSessionSetSession(SESSION_VOICE_RECOGNITION, session_order); + if (ret) { + debug_error (" failed to MMSoundMgrSessionSetSession() for VOICE_RECOGNITION\n"); + do_set_subsession = false; + } else { + if (session_order == SESSION_START) { + SESSION_REF_INIT(); + SESSION_REF(SESSION_VOICE_RECOGNITION); + } else { + SESSION_UNREF(SESSION_VOICE_RECOGNITION); + } + } + } + MMSoundMgrSessionGetSession(&cur_session); + debug_msg (" cur_session[%d] : leave", cur_session); + break; + } + case ASM_EVENT_MMCAMCORDER_AUDIO: + case ASM_EVENT_MMCAMCORDER_VIDEO: + { + int ret = 0; + int session_order = -1; + session_t cur_session; + MMSoundMgrSessionGetSession(&cur_session); + debug_warning (" cur_session[%d] (0:MEDIA 1:VC 2:VT 3:VOIP 4:FM 5:NOTI 6:ALARM 7:EMER 8:VR)\n",cur_session); + if (cur_session == SESSION_VOICECALL || + cur_session == SESSION_VIDEOCALL || + cur_session == SESSION_VOIP ) { + debug_warning (" skip REQUEST_SET_SUBSESSION\n"); + do_set_subsession = false; + break; + } + if (cur_session != SESSION_MEDIA) { + /* if current session is not for MMCAMCOARDER_AUDIO/VIDEO, so we need to set it first */ + debug_warning (" ****** SESSION_MEDIA start in REQUEST_SET_SUBSESSION ******\n"); + session_order = SESSION_START; + } else if (cur_session == SESSION_MEDIA && rcv_subsession == SUBSESSION_INIT) { + /* if current session is for MMCAMCORDRE_AUDIO/VIDEO, but user request set sub-session to NONE, so we need to end it */ + debug_warning (" ****** SESSION_MEDIA end(initialization) in REQUEST_SET_SUBSESSION ******\n"); + session_order = SESSION_END; + } + if (session_order != -1) { + ret = MMSoundMgrSessionSetSession(SESSION_MEDIA, session_order); + if (ret) { + debug_error (" failed to MMSoundMgrSessionSetSession() for MMCAMCORDER_AUDIO/VIDEO\n"); + do_set_subsession = false; + } + } + MMSoundMgrSessionGetSession(&cur_session); + debug_msg (" cur_session[%d] : leave", cur_session); + + break; + } + default: + if (sound_event == ASM_EVENT_NONE) { + debug_error (" Could not find event type of the handle(%d)\n", rcv_sound_handle); + } else { + debug_error (" Not supported ASM Event(%s) for this SUBSESSION(%s)\n", ASM_sound_event_str[sound_event], subsession_str[rcv_subsession]); + } + do_set_subsession = false; + break; + } + + if (do_set_subsession) { + int result_resource = ASM_RESOURCE_NONE; + ASM_sound_events_t sound_event = __asm_find_event_of_handle(rcv_instance_id, rcv_sound_handle); + + /* resource converting for sub-session */ + asm_instance_h = __asm_find_list(rcv_sound_handle); + if (asm_instance_h) { + switch (sound_event) { + default: + /* set resource of asm handle to rcv_resource forcedly */ + result_resource = rcv_resource = asm_instance_h->mm_resource; + break; + } + } + + ret = MMSoundMgrSessionSetSubSession(rcv_subsession, result_resource); + if (ret != MM_ERROR_NONE) { + /* TODO : Error Handling */ + debug_error (" MMSoundMgrSessionSetSubSession failed....ret = [%x]\n", ret); + } else { + if (rcv_subsession != SUBSESSION_RINGTONE) { + /*only keep for special case : + camcording ex subsession & call voice subsession : camcording stop,call play + camcording ex subsession & call ringtong subsession: mix two session*/ + g_camcorder_ex_subsession = rcv_subsession; + } + } + + __asm_change_state_list(rcv_instance_id, rcv_sound_handle, rcv_sound_state, rcv_resource); + __temp_print_list("Set Sub-session"); } /* Return result msg */ - asm_snd_msg.instance_id = rcv_instance_id; - if (asm_ret_msg == NULL) + ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id); + if (asm_ret_msg == NULL) { __asm_snd_message(&asm_snd_msg); + } } break; case ASM_REQUEST_GET_SUBSESSION: { - int subsession = 0; - int ret = 0; + subsession_t subsession = 0; /* FIXME: have to check only call instance with playing stsate can request this */ - asm_info ("[ASM_Server] ****** GET SUB-SESSION ******\n"); + debug_warning (" ****** GET SUB-SESSION ******\n"); ret = MMSoundMgrSessionGetSubSession(&subsession); if (ret != MM_ERROR_NONE) { /* TODO : Error Handling */ - debug_error ("[ASM_Server] MMSoundMgrSessionGetSubSession failed....ret = [%x]\n", ret); + debug_error (" MMSoundMgrSessionGetSubSession failed....ret = [%x]\n", ret); } /* Return result msg */ - asm_snd_msg.instance_id = rcv_instance_id; asm_snd_msg.data.result_sound_command = subsession; - if (asm_ret_msg == NULL) + ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id); + if (asm_ret_msg == NULL) { __asm_snd_message(&asm_snd_msg); } + } + break; + + case ASM_REQUEST_SET_SUBEVENT: + { + ASM_sound_sub_events_t rcv_subevent = rcv_sound_event; //latest rcv_subsession is needed + ASM_sound_events_t sound_event = ASM_EVENT_NONE; + if (rcv_subevent < ASM_SUB_EVENT_NONE || rcv_subevent >= ASM_SUB_EVENT_MAX) { + debug_error (" Invalid sub-event type[%d] to set\n", rcv_subevent); + } + sound_event = __asm_find_event_of_handle(rcv_instance_id, rcv_sound_handle); + + /* get previous sub-session option */ + asm_instance_list_t *asm_instance_h = NULL; + asm_instance_h = __asm_find_list(rcv_sound_handle); + if (asm_instance_h) { + switch (sound_event) { + case ASM_EVENT_VOICE_RECOGNITION: + if (asm_instance_h->option.pid == rcv_instance_id) { + rcv_resource = asm_instance_h->option.resource; + } + break; + default: + /* set resource of asm handle to rcv_resource forcedly */ + rcv_resource = asm_instance_h->mm_resource; + break; + } + } + debug_warning (" ****** SUB-EVENT [%s] ******\n", ASM_sound_sub_event_str[rcv_subevent]); + __asm_change_sub_event_list(rcv_instance_id, rcv_sound_handle, rcv_subevent); + + ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id); + + if (rcv_subevent == ASM_SUB_EVENT_NONE) { + /* NOTE: special case, resume paused list here */ + asm_paused_by_id_t paused_by_id; + paused_by_id.pid = rcv_instance_id; + paused_by_id.sound_handle = rcv_sound_handle; + __asm_do_all_resume_callback(paused_by_id); + + __asm_change_state_list(rcv_instance_id, rcv_sound_handle, rcv_sound_state, rcv_resource); + + } else { + __asm_compare_priority_matrix(&asm_snd_msg, asm_ret_msg, + rcv_instance_id, rcv_sound_handle, rcv_request_id, rcv_subevent-1, rcv_sound_state, rcv_resource); + + if (asm_snd_msg.data.result_sound_command == ASM_COMMAND_PLAY || + asm_snd_msg.data.result_sound_command == ASM_COMMAND_NONE) { + + ret = __asm_change_session (rcv_request_id, rcv_subevent, rcv_sound_state, rcv_resource, false, NULL); + if (ret) { + debug_error (" failed to __asm_change_session(), error(0x%x)", ret); + } + } + if (asm_ret_msg == NULL) { + __asm_snd_message(&asm_snd_msg); + } + } + + __temp_print_list("Set Sub-event"); + break; + } + + case ASM_REQUEST_GET_SUBEVENT: + ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id); + /* Return result msg */ + asm_instance_h = __asm_find_list(rcv_sound_handle); + asm_snd_msg.data.result_sound_command = (asm_instance_h ? asm_instance_h->sound_sub_event : ASM_SUB_EVENT_NONE); + if (asm_ret_msg == NULL) { + __asm_snd_message(&asm_snd_msg); + } + break; + + case ASM_REQUEST_SET_SESSION_OPTIONS: + { + ASM_sound_events_t sound_event = ASM_EVENT_NONE; + int rcv_options = rcv_sound_event; + asm_instance_list_t *asm_instance_h = NULL; + asm_instance_h = __asm_find_list(rcv_sound_handle); + if (asm_instance_h) { + sound_event = asm_instance_h->sound_event; + + /* validate options */ + if (!__is_valid_session_options(sound_event, rcv_options, &asm_snd_msg.data.error_code)) { + /* not supported for this type */ + asm_snd_msg.data.result_sound_command = ASM_COMMAND_STOP; + } else { + g_handle_info[asm_instance_h->sound_handle].option_flags = rcv_options; + asm_instance_h->option_flags = rcv_options; + asm_snd_msg.data.result_sound_command = ASM_COMMAND_PLAY; + /* TODO : do action according to these options */ + } + + } else { + asm_snd_msg.data.result_sound_command = ASM_COMMAND_STOP; + asm_snd_msg.data.error_code = ERR_ASM_SERVER_HANDLE_IS_INVALID; + } + + ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id); + if (asm_ret_msg == NULL) { + __asm_snd_message(&asm_snd_msg); + } + break; + } + + case ASM_REQUEST_GET_SESSION_OPTIONS: + ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id); + /* Return result msg */ + asm_instance_h = __asm_find_list(rcv_sound_handle); + asm_snd_msg.data.option_flags = (asm_instance_h ? asm_instance_h->option_flags : 0); + if (!asm_instance_h) { + asm_snd_msg.data.result_sound_command = ASM_COMMAND_STOP; + } + if (asm_ret_msg == NULL) { + __asm_snd_message(&asm_snd_msg); + } break; case ASM_REQUEST_EMERGENT_EXIT: - emergent_exit(rcv_instance_id); + { + asm_instance_h = __asm_find_list(rcv_sound_handle); + bool need_to_resume = false; + + /* change session forcedly */ + if (asm_instance_h && (asm_instance_h->sound_state == ASM_STATE_PLAYING || asm_instance_h->sound_state == ASM_STATE_PAUSE)) { + ret = __asm_change_session (ASM_REQUEST_SETSTATE, rcv_sound_event, ASM_STATE_STOP, + (asm_instance_h)? asm_instance_h->mm_resource : rcv_resource, + true, &need_to_resume); + if (ret) { + debug_error (" failed to __asm_change_session(), error(0x%x)", ret); + } else { + if (need_to_resume) { + asm_paused_by_id_t paused_by_id; + paused_by_id.pid = rcv_instance_id; + paused_by_id.sound_handle = rcv_sound_handle; + __asm_do_all_resume_callback(paused_by_id); + } + } + } + ret = __asm_change_session (ASM_REQUEST_UNREGISTER, rcv_sound_event, rcv_sound_state, + (asm_instance_h)? asm_instance_h->mm_resource : rcv_resource, + true, &need_to_resume); + if (ret) { + debug_error (" failed to __asm_change_session(), error(0x%x)", ret); + } else { + if (need_to_resume) { + asm_paused_by_id_t paused_by_id; + paused_by_id.pid = rcv_instance_id; + paused_by_id.sound_handle = rcv_sound_handle; + __asm_do_all_resume_callback(paused_by_id); + } + } + __emergent_exit(rcv_instance_id); + } break; - default: + case ASM_REQUEST_REGISTER_WATCHER: + debug_log (" ****** REQUEST_REGISTER_WATCHER ******\n"); + __check_dead_process(); + + /* check if it is redundant */ + if (__is_it_redundant_request(rcv_instance_id, rcv_sound_event, rcv_sound_state)) { + debug_error (" it is redundant request for adding watch list..."); + return false; + } + + __asm_get_empty_handle(rcv_instance_id, &rcv_sound_handle); + if (rcv_sound_handle == ASM_HANDLE_INIT_VAL) { + ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, ASM_HANDLE_INIT_VAL, ASM_HANDLE_INIT_VAL, rcv_request_id); + if (asm_ret_msg == NULL) { + __asm_snd_message(&asm_snd_msg); + } + } else { + ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id); + asm_snd_msg.data.result_sound_command = ASM_COMMAND_PLAY; + asm_snd_msg.data.result_sound_state = rcv_sound_state; + if (asm_ret_msg == NULL) { + __asm_snd_message(&asm_snd_msg); + } + __asm_register_list(rcv_instance_id, rcv_sound_handle, rcv_sound_event, rcv_sound_state, 0, true); + } + break; + + case ASM_REQUEST_UNREGISTER_WATCHER: + debug_log (" ****** REQUEST_UNREGISTER_WATCHER ******\n"); + __asm_unregister_list(rcv_sound_handle); + break; + + case ASM_REQUEST_RESET_RESUME_TAG: + { + int found_pid = -1; + debug_log (" ****** REQUEST_RESET_RESUME_TAG ******\n"); + found_pid = __asm_find_pid_of_resume_tagged(rcv_sound_handle); + if (found_pid == -1) { + debug_warning (" could not find any pid tagged for resumption"); + } else { + __reset_resume_check(found_pid, rcv_sound_handle); + } + ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id); + asm_snd_msg.data.result_sound_command = ASM_COMMAND_PLAY; + asm_snd_msg.data.result_sound_state = rcv_sound_state; + if (asm_ret_msg == NULL) { + __asm_snd_message(&asm_snd_msg); + } break; } + default: + break; + } if (asm_ret_msg) { *asm_ret_msg = asm_snd_msg; } pthread_mutex_unlock(&g_mutex_asm); - asm_info ("[ASM_Server] --------------------------------------------------------------------- [%s] End (UNLOCKED) ", __func__); + debug_log (" ===================================================================== End (UNLOCKED) "); + + return 0; } -int __asm_main_run (void* param) +void __asm_main_run (void* param) { - int pid = 0, ret = 0; - ASM_msg_lib_to_asm_t asm_rcv_msg; - if (sysconf_set_mempolicy(OOM_IGNORE)) { - fprintf(stderr, "set mem policy failed\n"); - } signal(SIGPIPE, SIG_IGN); /* Init Msg Queue */ @@ -1754,7 +3539,7 @@ int __asm_main_run (void* param) int temp_msgctl_id3 = msgctl(asm_cb_msgid, IPC_RMID, 0); if (temp_msgctl_id1 == -1 || temp_msgctl_id2 == -1 || temp_msgctl_id3 == -1) { - asm_critical("[ASM_Server] msgctl failed with error(%d,%s) \n", errno, strerror(errno)); + debug_error(" msgctl failed with error(%d,%s) \n", errno, strerror(errno)); exit(EXIT_FAILURE); } //------------------------------------------------------------------- @@ -1764,38 +3549,24 @@ int __asm_main_run (void* param) /* FIXME: Do we need to do this again ? */ __asm_create_message_queue(); - /* Init List */ - head_list = (asm_instance_list_t *)malloc(sizeof(asm_instance_list_t)); - tail_list = (asm_instance_list_t *)malloc(sizeof(asm_instance_list_t)); - head_list->next = tail_list; - tail_list->next = tail_list; - - /* * Init Vconf */ if (vconf_set_int(SOUND_STATUS_KEY, 0)) { - asm_critical("[ASM_Server] vconf_set_int fail\n"); + debug_error(" vconf_set_int fail\n"); if (vconf_set_int(SOUND_STATUS_KEY, 0)) { - asm_critical_r("[ASM_Server] vconf_set_int fail\n"); + debug_error(" vconf_set_int fail\n"); } } -#ifdef SUPPORT_GCF - if (vconf_get_int(VCONFKEY_ADMIN_GCF_TEST, &is_gcf)) { - asm_warning_r("[ASM_Server] vconf_get_int for VCONFKEY_ADMIN_GCF_TEST failed, set as default\n"); - is_gcf = GCF_DEFAULT; - } -#endif - /* Set READY flag */ if (vconf_set_int(ASM_READY_KEY, 1)) { - asm_critical("[ASM_Server] vconf_set_int fail\n"); + debug_error(" vconf_set_int fail\n"); } /* Msg Loop */ while (true) { - asm_info("[ASM_Server] asm_Server is waiting message(%d)!!!\n", asm_is_send_msg_to_cb); + debug_log(" asm_Server is waiting message(%d)!!!\n", asm_is_send_msg_to_cb); if (asm_is_send_msg_to_cb) continue; @@ -1807,8 +3578,6 @@ int __asm_main_run (void* param) /* TODO : Error Handling */ } - - return 0; } diff --git a/server/mm_sound_mgr_codec.c b/server/mm_sound_mgr_codec.c index 789e083..feb1f5a 100644 --- a/server/mm_sound_mgr_codec.c +++ b/server/mm_sound_mgr_codec.c @@ -34,7 +34,7 @@ #include "include/mm_sound_mgr_codec.h" #include "include/mm_sound_plugin_codec.h" #include "include/mm_sound_thread_pool.h" - +#include "include/mm_sound_pa_client.h" #include "include/mm_sound_mgr_asm.h" @@ -42,7 +42,7 @@ #define _ENABLE_KEYTONE /* Temporal test code */ typedef struct { - int (*callback)(int, void *, void *); /* msg_type(pid) client callback & client data info */ + int (*callback)(int, void *, void *, int); /* msg_type(pid) client callback & client data info */ void *param; int pid; void *msgcallback; @@ -52,14 +52,17 @@ typedef struct { int pluginid; int status; int session_type; + int session_options; int session_handle; + + bool enable_session; } __mmsound_mgr_codec_handle_t; static MMSoundPluginType *g_codec_plugins = NULL; static __mmsound_mgr_codec_handle_t g_slots[MANAGER_HANDLE_MAX]; static mmsound_codec_interface_t g_plugins[MM_SOUND_SUPPORTED_CODEC_NUM]; static pthread_mutex_t g_slot_mutex; - +static pthread_mutex_t codec_wave_mutex; static int _MMSoundMgrCodecStopCallback(int param); static int _MMSoundMgrCodecFindKeytoneSlot(int *slotid); static int _MMSoundMgrCodecGetEmptySlot(int *slotid); @@ -90,6 +93,9 @@ sound_codec_asm_callback(int handle, ASM_event_sources_t event_src, ASM_sound_co case ASM_COMMAND_PAUSE: debug_log("Got msg from asm to Stop or Pause %d\n", command); result = MMSoundMgrCodecStop(slotid); + if (result != MM_ERROR_NONE) { + debug_log("result error %d\n", result); + } cb_res = ASM_CB_RES_STOP; break; case ASM_COMMAND_RESUME: @@ -113,13 +119,18 @@ int MMSoundMgrCodecInit(const char *targetdir) memset (g_slots, 0, sizeof(g_slots)); if(pthread_mutex_init(&g_slot_mutex, NULL)) { - debug_error("pthread_mutex_init failed [%s][%d]\n", __func__, __LINE__); + debug_error("pthread_mutex_init failed\n"); + return MM_ERROR_SOUND_INTERNAL; + } + + if(pthread_mutex_init(&codec_wave_mutex, NULL)) { + debug_error("pthread_mutex_init failed\n"); return MM_ERROR_SOUND_INTERNAL; } for (count = 0; count < MANAGER_HANDLE_MAX; count++) { g_slots[count].status = STATUS_IDLE; - g_slots[count].plughandle = -1; + g_slots[count].plughandle = 0; } if (g_codec_plugins) { @@ -145,7 +156,7 @@ int MMSoundMgrCodecFini(void) MMSoundPluginRelease(g_codec_plugins); g_codec_plugins = NULL; pthread_mutex_destroy(&g_slot_mutex); - + pthread_mutex_destroy(&codec_wave_mutex); debug_leave("\n"); return MM_ERROR_NONE; } @@ -157,20 +168,21 @@ int MMSoundMgrCodecPlay(int *slotid, const mmsound_mgr_codec_param_t *param) mmsound_codec_info_t info; mmsound_codec_param_t codec_param; int err = MM_ERROR_NONE; + int errorcode = 0; + int need_asm_unregister = 0; +#ifdef DEBUG_DETAIL debug_enter("\n"); - - debug_msg("DTMF : [%d]\n",param->tone); - debug_msg("Repeat : [%d]\n",param->repeat_count); - debug_msg("Volume : [%f]\n",param->volume); +#endif for (count = 0; g_plugins[count].GetSupportTypes; count++) { /* Find codec */ - if (g_plugins[count].Parse(param->source, &info) == MM_ERROR_NONE) + if (g_plugins[count].Parse(param->source, &info) == MM_ERROR_NONE) break; } - debug_msg("Find plugin codec ::: [%d]\n", count); /*The count num means codec type WAV, MP3 */ + /*The count num means codec type WAV, MP3 */ + debug_msg("DTMF[%d] Repeat[%d] Volume[%f] plugin_codec[%d]\n", param->tone, param->repeat_count, param->volume, count); if (g_plugins[count].GetSupportTypes == NULL) { /* Codec not found */ debug_error("unsupported file type %d\n", count); @@ -202,18 +214,20 @@ int MMSoundMgrCodecPlay(int *slotid, const mmsound_mgr_codec_param_t *param) } codec_param.keytone = param->keytone; } else { +#ifdef DEBUG_DETAIL debug_msg("Get New handle\n"); +#endif codec_param.keytone = 0; } err = _MMSoundMgrCodecGetEmptySlot(slotid); - if(err != MM_ERROR_NONE) { + if (err != MM_ERROR_NONE) { debug_error("Empty g_slot is not found\n"); goto cleanup; } codec_param.tone = param->tone; - codec_param.volume_table = param->volume_table; + codec_param.volume_config = param->volume_config; codec_param.repeat_count = param->repeat_count; codec_param.volume = param->volume; codec_param.source = param->source; @@ -222,9 +236,11 @@ int MMSoundMgrCodecPlay(int *slotid, const mmsound_mgr_codec_param_t *param) codec_param.param = *slotid; codec_param.pid = (int)param->param; codec_param.handle_route = param->handle_route; - + codec_param.codec_wave_mutex = &codec_wave_mutex; pthread_mutex_lock(&g_slot_mutex); +#ifdef DEBUG_DETAIL debug_msg("After Slot_mutex LOCK\n"); +#endif /* In case of KEYTONE */ if (param->keytone == 1) @@ -232,23 +248,36 @@ int MMSoundMgrCodecPlay(int *slotid, const mmsound_mgr_codec_param_t *param) /* In case of LOCALE */ if (param->keytone == 2) /* KeyTone */ - g_slots[*slotid].status = STATUS_LOCALE; - + g_slots[*slotid].status = STATUS_LOCALE; - // /* * Register ASM here */ - int errorcode = 0; - int need_asm_unregister = 0; - - if(param->session_type != ASM_EVENT_CALL && param->session_type != ASM_EVENT_VIDEOCALL) { - if(!ASM_register_sound_ex((int)param->param, ¶m->session_handle, param->session_type, ASM_STATE_PLAYING, - sound_codec_asm_callback, (void*)*slotid, ASM_RESOURCE_NONE, &errorcode, __asm_process_message)) { - debug_critical("ASM_register_sound() failed %d\n", errorcode); + if (param->session_type != ASM_EVENT_CALL && + param->session_type != ASM_EVENT_VIDEOCALL && + param->session_type != ASM_EVENT_VOIP && + param->session_type != ASM_EVENT_VOICE_RECOGNITION && + param->priority != HANDLE_PRIORITY_SOLO && + param->enable_session) { + if(!ASM_register_sound_ex((int)param->param, (int *)(¶m->session_handle), param->session_type, ASM_STATE_NONE, + sound_codec_asm_callback, (void*)*slotid, ASM_RESOURCE_NONE, &errorcode, __asm_process_message)) { + debug_critical("ASM_register_sound_ex() failed 0x%X\n", errorcode); pthread_mutex_unlock(&g_slot_mutex); return MM_ERROR_POLICY_INTERNAL; } + if(param->session_options) { + if(!ASM_set_session_option(param->session_handle, param->session_options, &errorcode)) { + debug_error("ASM_set_session_option() failed 0x%x\n", errorcode); + } + } + if(!ASM_set_sound_state_ex(param->session_handle, param->session_type, ASM_STATE_PLAYING, ASM_RESOURCE_NONE, &errorcode, __asm_process_message)) { + debug_critical("ASM_set_sound_state_ex() failed 0x%X\n", errorcode); + pthread_mutex_unlock(&g_slot_mutex); + if(!ASM_unregister_sound_ex(param->session_handle, param->session_type, &errorcode,__asm_process_message)) { + debug_error("ASM_unregister_sound_ex() failed 0x%X\n", errorcode); + } + return MM_ERROR_POLICY_INTERNAL; + } } // @@ -259,11 +288,11 @@ int MMSoundMgrCodecPlay(int *slotid, const mmsound_mgr_codec_param_t *param) g_slots[*slotid].msgdata = param->msgdata; g_slots[*slotid].param = param->param; /* This arg is used callback data */ g_slots[*slotid].session_type = param->session_type; + g_slots[*slotid].session_options = param->session_options; g_slots[*slotid].session_handle = param->session_handle; - - debug_msg("Using Slotid : [%d] Slot Status : [%d]\n", *slotid, g_slots[*slotid].status); - + g_slots[*slotid].enable_session = true; + debug_msg("Using Slotid : [%d] Slot Status : [%d]\n", *slotid, g_slots[*slotid].status); err = g_plugins[g_slots[*slotid].pluginid].Create(&codec_param, &info, &(g_slots[*slotid].plughandle)); debug_msg("Created audio handle : [%d]\n", g_slots[*slotid].plughandle); @@ -272,7 +301,9 @@ int MMSoundMgrCodecPlay(int *slotid, const mmsound_mgr_codec_param_t *param) g_slots[*slotid].status = STATUS_IDLE; pthread_mutex_unlock(&g_slot_mutex); debug_warning("After Slot_mutex UNLOCK\n"); - need_asm_unregister = 1; + if (param->session_handle) { + need_asm_unregister = 1; + } goto cleanup; } @@ -280,21 +311,35 @@ int MMSoundMgrCodecPlay(int *slotid, const mmsound_mgr_codec_param_t *param) if (err != MM_ERROR_NONE) { debug_error("Fail to play : 0x%08X\n", err); g_plugins[g_slots[*slotid].pluginid].Destroy(g_slots[*slotid].plughandle); - need_asm_unregister = 1; + if (param->session_handle) { + need_asm_unregister = 1; + } } pthread_mutex_unlock(&g_slot_mutex); +#ifdef DEBUG_DETAIL debug_msg("After Slot_mutex UNLOCK\n"); +#endif cleanup: - if(param->session_type != ASM_EVENT_CALL && param->session_type != ASM_EVENT_VIDEOCALL && need_asm_unregister == 1) { + if(param->session_type != ASM_EVENT_CALL && + param->session_type != ASM_EVENT_VIDEOCALL && + param->session_type != ASM_EVENT_VOIP && + param->session_type != ASM_EVENT_VOICE_RECOGNITION && + param->enable_session && + need_asm_unregister == 1) { + if(!ASM_set_sound_state_ex(param->session_handle, param->session_type, ASM_STATE_STOP, ASM_RESOURCE_NONE, &errorcode, __asm_process_message)) { + debug_critical("ASM_set_sound_state_ex() failed 0x%X\n", errorcode); + } if(!ASM_unregister_sound_ex(param->session_handle, param->session_type, &errorcode,__asm_process_message)) { - debug_error("Unregister sound failed 0x%X\n", errorcode); + debug_error("ASM_unregister_sound_ex() failed 0x%X\n", errorcode); return MM_ERROR_POLICY_INTERNAL; } } +#ifdef DEBUG_DETAIL debug_leave("\n"); +#endif return err; } @@ -307,21 +352,22 @@ int MMSoundMgrCodecPlayDtmf(int *slotid, const mmsound_mgr_codec_param_t *param) mmsound_codec_info_t info; mmsound_codec_param_t codec_param; int err = MM_ERROR_NONE; - + int errorcode = 0; + int need_asm_unregister = 0; + +#ifdef DEBUG_DETAIL debug_enter("\n"); +#endif - debug_msg("DTMF : [%d]\n",param->tone); - debug_msg("Repeat : [%d]\n",param->repeat_count); - debug_msg("Volume : [%f]\n",param->volume); - for (count = 0; g_plugins[count].GetSupportTypes; count++) { /* Find codec */ codec_type = g_plugins[count].GetSupportTypes(); if(codec_type && (MM_SOUND_SUPPORTED_CODEC_DTMF == codec_type[0])) break; } - - debug_msg("Find plugin codec ::: [%d]\n", count); /*The count num means codec type DTMF */ + + /*The count num means codec type DTMF */ + debug_msg("DTMF[%d] Repeat[%d] Volume[%f] plugin_codec[%d]\n", param->tone, param->repeat_count, param->volume, count); if (g_plugins[count].GetSupportTypes == NULL) { /* Codec not found */ debug_error("unsupported file type %d\n", count); @@ -330,7 +376,9 @@ int MMSoundMgrCodecPlayDtmf(int *slotid, const mmsound_mgr_codec_param_t *param) goto cleanup; } +#ifdef DEBUG_DETAIL debug_msg("Get New handle\n"); +#endif codec_param.keytone = 0; err = _MMSoundMgrCodecGetEmptySlot(slotid); @@ -342,7 +390,7 @@ int MMSoundMgrCodecPlayDtmf(int *slotid, const mmsound_mgr_codec_param_t *param) codec_param.tone = param->tone; codec_param.priority = 0; - codec_param.volume_table = param->volume_table; + codec_param.volume_config = param->volume_config; codec_param.repeat_count = param->repeat_count; codec_param.volume = param->volume; codec_param.stop_cb = _MMSoundMgrCodecStopCallback; @@ -350,20 +398,37 @@ int MMSoundMgrCodecPlayDtmf(int *slotid, const mmsound_mgr_codec_param_t *param) codec_param.pid = (int)param->param; pthread_mutex_lock(&g_slot_mutex); +#ifdef DEBUG_DETAIL debug_msg("After Slot_mutex LOCK\n"); - +#endif + // /* * Register ASM here */ - int errorcode = 0; - int need_asm_unregister = 0; - if(param->session_type != ASM_EVENT_CALL && param->session_type != ASM_EVENT_VIDEOCALL) { - if(!ASM_register_sound_ex((int)param->param, ¶m->session_handle, param->session_type, ASM_STATE_PLAYING, + if (param->session_type != ASM_EVENT_CALL && + param->session_type != ASM_EVENT_VIDEOCALL && + param->session_type != ASM_EVENT_VOIP && + param->session_type != ASM_EVENT_VOICE_RECOGNITION && + param->enable_session) { + if(!ASM_register_sound_ex((int)param->param, (int *)(¶m->session_handle), param->session_type, ASM_STATE_NONE, sound_codec_asm_callback, (void*)*slotid, ASM_RESOURCE_NONE, &errorcode, __asm_process_message)) { - debug_critical("ASM_register_sound() failed %d\n", errorcode); + debug_critical("ASM_register_sound_ex() failed 0x%X\n", errorcode); + pthread_mutex_unlock(&g_slot_mutex); + return MM_ERROR_POLICY_INTERNAL; + } + if(param->session_options) { + if(!ASM_set_session_option(param->session_handle, param->session_options, &errorcode)) { + debug_error("ASM_set_session_option() failed 0x%x\n", errorcode); + } + } + if(!ASM_set_sound_state_ex(param->session_handle, param->session_type, ASM_STATE_PLAYING, ASM_RESOURCE_NONE, &errorcode, __asm_process_message)) { + debug_critical("ASM_set_sound_state_ex() failed 0x%X\n", errorcode); pthread_mutex_unlock(&g_slot_mutex); + if(!ASM_unregister_sound_ex(param->session_handle, param->session_type, &errorcode,__asm_process_message)) { + debug_error("ASM_unregister_sound_ex() failed 0x%X\n", errorcode); + } return MM_ERROR_POLICY_INTERNAL; } } @@ -372,9 +437,13 @@ int MMSoundMgrCodecPlayDtmf(int *slotid, const mmsound_mgr_codec_param_t *param) g_slots[*slotid].callback = param->callback; g_slots[*slotid].param = param->param; /* This arg is used callback data */ g_slots[*slotid].session_type = param->session_type; + g_slots[*slotid].session_options = param->session_options; g_slots[*slotid].session_handle = param->session_handle; - + g_slots[*slotid].enable_session = param->enable_session; + +#ifdef DEBUG_DETAIL debug_msg("Using Slotid : [%d] Slot Status : [%d]\n", *slotid, g_slots[*slotid].status); +#endif err = g_plugins[g_slots[*slotid].pluginid].Create(&codec_param, &info, &(g_slots[*slotid].plughandle)); debug_msg("Created audio handle : [%d]\n", g_slots[*slotid].plughandle); @@ -393,14 +462,30 @@ int MMSoundMgrCodecPlayDtmf(int *slotid, const mmsound_mgr_codec_param_t *param) g_plugins[g_slots[*slotid].pluginid].Destroy(g_slots[*slotid].plughandle); need_asm_unregister = 1; } - + pthread_mutex_unlock(&g_slot_mutex); debug_msg("Using Slotid : [%d] Slot Status : [%d]\n", *slotid, g_slots[*slotid].status); +#ifdef DEBUG_DETAIL debug_msg("After Slot_mutex UNLOCK\n") +#endif -cleanup: +cleanup: + if (param->session_type != ASM_EVENT_CALL && + param->session_type != ASM_EVENT_VIDEOCALL && + param->session_type != ASM_EVENT_VOIP && + param->session_type != ASM_EVENT_VOICE_RECOGNITION && + param->enable_session && + need_asm_unregister == 1) { + if(!ASM_unregister_sound_ex(param->session_handle, param->session_type, &errorcode,__asm_process_message)) { + debug_error("Unregister sound failed 0x%X\n", errorcode); + return MM_ERROR_POLICY_INTERNAL; + } + } + +#ifdef DEBUG_DETAIL debug_leave("\n"); +#endif return err; } @@ -417,13 +502,17 @@ int MMSoundMgrCodecStop(const int slotid) } pthread_mutex_lock (&g_slot_mutex); +#ifdef DEBUG_DETAIL debug_msg("After Slot_mutex LOCK\n"); +#endif if (g_slots[slotid].status == STATUS_IDLE) { err = MM_ERROR_SOUND_INVALID_STATE; debug_warning("The playing slots is not found, Slot ID : [%d]\n", slotid); goto cleanup; } +#ifdef DEBUG_DETAIL debug_msg("Found slot, Slotid [%d] State [%d]\n", slotid, g_slots[slotid].status); +#endif err = g_plugins[g_slots[slotid].pluginid].Stop(g_slots[slotid].plughandle); if (err != MM_ERROR_NONE) { @@ -432,7 +521,9 @@ int MMSoundMgrCodecStop(const int slotid) debug_msg("Found slot, Slotid [%d] State [%d]\n", slotid, g_slots[slotid].status); cleanup: pthread_mutex_unlock(&g_slot_mutex); +#ifdef DEBUG_DETAIL debug_msg("After Slot_mutex UNLOCK\n"); +#endif debug_leave("(err : 0x%08X)\n", err); return err; @@ -453,21 +544,29 @@ static int _MMSoundMgrCodecStopCallback(int param) */ int errorcode = 0; - - if(g_slots[param].session_type != ASM_EVENT_CALL && g_slots[param].session_type != ASM_EVENT_VIDEOCALL) { - debug_msg("[CODEC MGR] ASM unregister\n"); - if(!ASM_unregister_sound_ex(g_slots[param].session_handle, g_slots[param].session_type, &errorcode, __asm_process_message)) { - debug_error("[CODEC MGR] Unregister sound failed 0x%X\n", errorcode); + debug_msg("[CODEC MGR] enable_session %d ",g_slots[param].enable_session); + + if (g_slots[param].session_handle) { + if(g_slots[param].session_type != ASM_EVENT_CALL && + g_slots[param].session_type != ASM_EVENT_VIDEOCALL && + g_slots[param].session_type != ASM_EVENT_VOIP && + g_slots[param].session_type != ASM_EVENT_VOICE_RECOGNITION && + g_slots[param].enable_session ) { + if(!ASM_set_sound_state_ex(g_slots[param].session_handle, g_slots[param].session_type, ASM_STATE_STOP, ASM_RESOURCE_NONE, &errorcode, __asm_process_message)) { + debug_error("[CODEC MGR] ASM_set_sound_state_ex() failed 0x%X\n", errorcode); + } + debug_msg("[CODEC MGR] ASM unregister\n"); + if(!ASM_unregister_sound_ex(g_slots[param].session_handle, g_slots[param].session_type, &errorcode, __asm_process_message)) { + debug_error("[CODEC MGR] ASM_unregister_sound_ex() failed 0x%X\n", errorcode); + } } } - - if (g_slots[param].msgcallback) { debug_msg("[CODEC MGR] msgcallback : %p\n", g_slots[param].msgcallback); debug_msg("[CODEC MGR] msg data : %p\n", g_slots[param].msgdata); debug_msg("[CODEC MGR] mgr codec callback : %p\n", g_slots[param].callback); - g_slots[param].callback((int)g_slots[param].param, g_slots[param].msgcallback, g_slots[param].msgdata); /*param means client msg_type */ + g_slots[param].callback((int)g_slots[param].param, g_slots[param].msgcallback, g_slots[param].msgdata, param); /*param means client msg_type */ } debug_msg("Client callback msg_type (instance) : [%d]\n", (int)g_slots[param].param); debug_msg("Handle allocated handle : [0x%08X]\n", g_slots[param].plughandle); @@ -488,10 +587,14 @@ static int _MMSoundMgrCodecFindKeytoneSlot(int *slotid) int count = 0; int err = MM_ERROR_NONE; +#ifdef DEBUG_DETAIL debug_enter("\n"); +#endif pthread_mutex_lock(&g_slot_mutex); +#ifdef DEBUG_DETAIL debug_warning("After Slot_mutex LOCK\n"); +#endif for (count = SOUND_SLOT_START; count < MANAGER_HANDLE_MAX ; count++) { if (g_slots[count].status == STATUS_KEYTONE) { @@ -499,7 +602,9 @@ static int _MMSoundMgrCodecFindKeytoneSlot(int *slotid) } } pthread_mutex_unlock(&g_slot_mutex); +#ifdef DEBUG_DETAIL debug_warning("After Slot_mutex UNLOCK\n"); +#endif if (count < MANAGER_HANDLE_MAX) { debug_msg("Found keytone handle allocated (Slot : [%d])\n", count); *slotid = count; @@ -509,7 +614,9 @@ static int _MMSoundMgrCodecFindKeytoneSlot(int *slotid) err = MM_ERROR_SOUND_INTERNAL; } +#ifdef DEBUG_DETAIL debug_leave("\n"); +#endif return err; } @@ -519,10 +626,14 @@ static int _MMSoundMgrCodecFindLocaleSlot(int *slotid) int count = 0; int err = MM_ERROR_NONE; +#ifdef DEBUG_DETAIL debug_enter("\n"); +#endif pthread_mutex_lock(&g_slot_mutex); +#ifdef DEBUG_DETAIL debug_warning("After Slot_mutex LOCK\n"); +#endif for (count = SOUND_SLOT_START; count < MANAGER_HANDLE_MAX ; count++) { if (g_slots[count].status == STATUS_LOCALE) { @@ -531,7 +642,9 @@ static int _MMSoundMgrCodecFindLocaleSlot(int *slotid) } pthread_mutex_unlock(&g_slot_mutex); +#ifdef DEBUG_DETAIL debug_warning("After Slot_mutex UNLOCK\n"); +#endif if (count < MANAGER_HANDLE_MAX) { debug_msg("Found locale handle allocated (Slot : [%d])\n", count); *slotid = count; @@ -541,7 +654,9 @@ static int _MMSoundMgrCodecFindLocaleSlot(int *slotid) err = MM_ERROR_SOUND_INTERNAL; } +#ifdef DEBUG_DETAIL debug_leave("\n"); +#endif return err; } @@ -551,10 +666,14 @@ static int _MMSoundMgrCodecGetEmptySlot(int *slot) int count = 0; int err = MM_ERROR_NONE; +#ifdef DEBUG_DETAIL debug_enter("\n"); +#endif debug_msg("Codec slot ID : [%d]\n", *slot); pthread_mutex_lock(&g_slot_mutex); +#ifdef DEBUG_DETAIL debug_msg("After Slot_mutex LOCK\n"); +#endif for (count = SOUND_SLOT_START; count < MANAGER_HANDLE_MAX ; count++) { if (g_slots[count].status == STATUS_IDLE) { @@ -563,7 +682,9 @@ static int _MMSoundMgrCodecGetEmptySlot(int *slot) } } pthread_mutex_unlock(&g_slot_mutex); +#ifdef DEBUG_DETAIL debug_msg("After Slot_mutex UNLOCK\n"); +#endif if (count < MANAGER_HANDLE_MAX) { debug_msg("New handle allocated (codec slot ID : [%d])\n", count); @@ -579,7 +700,9 @@ static int _MMSoundMgrCodecGetEmptySlot(int *slot) err = MM_ERROR_SOUND_INTERNAL; } +#ifdef DEBUG_DETAIL debug_leave("\n"); +#endif return err; } @@ -590,7 +713,9 @@ static int _MMSoundMgrCodecRegisterInterface(MMSoundPluginType *plugin) int count = 0; void *getinterface = NULL; +#ifdef DEBUG_DETAIL debug_enter("\n"); +#endif /* find emptry slot */ for (count = 0; count < MM_SOUND_SUPPORTED_CODEC_NUM; count++) { @@ -602,21 +727,19 @@ static int _MMSoundMgrCodecRegisterInterface(MMSoundPluginType *plugin) debug_critical("The plugin support type is not valid\n"); return MM_ERROR_COMMON_OUT_OF_RANGE; } - - debug_msg("Empty slot find : %d\n", count); err = MMSoundPluginGetSymbol(plugin, CODEC_GET_INTERFACE_FUNC_NAME, &getinterface); if (err != MM_ERROR_NONE) { debug_error("Get Symbol CODEC_GET_INTERFACE_FUNC_NAME is fail : %x\n", err); goto cleanup; } - debug_msg("Getinterface name : %s\n", (char*)getinterface ); + debug_msg("interface[%s] empty_slot[%d]\n", (char*)getinterface, count); err = MMSoundPlugCodecCastGetInterface(getinterface)(&g_plugins[count]); if (err != MM_ERROR_NONE) { debug_error("Get interface fail : %x\n", err); -cleanup: +cleanup: /* If error occur, clean interface */ memset(&g_plugins[count], 0, sizeof(mmsound_codec_interface_t)); } else { @@ -624,7 +747,9 @@ cleanup: g_plugins[count].SetThreadPool(MMSoundThreadPoolRun); } +#ifdef DEBUG_DETAIL debug_leave("\n"); +#endif return err; } diff --git a/server/mm_sound_mgr_device.c b/server/mm_sound_mgr_device.c old mode 100644 new mode 100755 index 2f9c0e7..c6158b2 --- a/server/mm_sound_mgr_device.c +++ b/server/mm_sound_mgr_device.c @@ -24,6 +24,9 @@ #include #include #include +#include +#include + #include #include @@ -31,16 +34,26 @@ #include #include #include - +#include #include "include/mm_sound_mgr_common.h" #include "include/mm_sound_mgr_ipc.h" #include "include/mm_sound_mgr_device.h" +#include "include/mm_sound_mgr_device_headset.h" + #include "include/mm_sound_thread_pool.h" #include "../include/mm_sound_msg.h" #include "../include/mm_sound_common.h" +#include "../include/mm_sound_device.h" #include "../include/mm_sound_utils.h" +#include +#include + #include "include/mm_sound_mgr_session.h" +#include "include/mm_sound_mgr_pulse.h" + +#define MAX_SUPPORT_DEVICE_NUM 256 +static char g_device_id_array[MAX_SUPPORT_DEVICE_NUM]; void _mm_sound_get_devices_from_route(mm_sound_route route, mm_sound_device_in *device_in, mm_sound_device_out *device_out); @@ -48,11 +61,60 @@ static GList *g_active_device_cb_list = NULL; static pthread_mutex_t g_active_device_cb_mutex = PTHREAD_MUTEX_INITIALIZER; static GList *g_available_route_cb_list = NULL; static pthread_mutex_t g_available_route_cb_mutex = PTHREAD_MUTEX_INITIALIZER; +static GList *g_volume_cb_list = NULL; +static pthread_mutex_t g_volume_cb_mutex = PTHREAD_MUTEX_INITIALIZER; + +static GList *g_device_connected_cb_list = NULL; +static pthread_mutex_t g_device_connected_cb_mutex = PTHREAD_MUTEX_INITIALIZER; +static GList *g_device_info_changed_cb_list = NULL; +static pthread_mutex_t g_device_info_changed_cb_mutex = PTHREAD_MUTEX_INITIALIZER; +static GList *g_connected_device_list = NULL; +static pthread_mutex_t g_connected_device_list_mutex = PTHREAD_MUTEX_INITIALIZER; +typedef struct { + GList *list; +}connected_device_list_s; +connected_device_list_s g_connected_device_list_s; + +static int _mm_sound_mgr_device_volume_callback(keynode_t* node, void* data); + +static char *g_volume_vconf[VOLUME_TYPE_MAX] = { + VCONF_KEY_VOLUME_TYPE_SYSTEM, /* VOLUME_TYPE_SYSTEM */ + VCONF_KEY_VOLUME_TYPE_NOTIFICATION, /* VOLUME_TYPE_NOTIFICATION */ + VCONF_KEY_VOLUME_TYPE_ALARM, /* VOLUME_TYPE_ALARM */ + VCONF_KEY_VOLUME_TYPE_RINGTONE, /* VOLUME_TYPE_RINGTONE */ + VCONF_KEY_VOLUME_TYPE_MEDIA, /* VOLUME_TYPE_MEDIA */ + VCONF_KEY_VOLUME_TYPE_CALL, /* VOLUME_TYPE_CALL */ + VCONF_KEY_VOLUME_TYPE_VOIP, /* VOLUME_TYPE_VOIP */ + VCONF_KEY_VOLUME_TYPE_VOICE, /* VOLUME_TYPE_VOICE */ + VCONF_KEY_VOLUME_TYPE_ANDROID /* VOLUME_TYPE_FIXED */ +}; int _mm_sound_mgr_device_init(void) { + int i = 0; + int ret = MM_ERROR_NONE; debug_fenter(); + for(i = 0 ; i < VOLUME_TYPE_MAX; i++) { + vconf_notify_key_changed(g_volume_vconf[i], (void (*) (keynode_t *, void *))_mm_sound_mgr_device_volume_callback, (void *)i); + } + g_connected_device_list_s.list = g_connected_device_list; + memset(g_device_id_array, 0, MAX_SUPPORT_DEVICE_NUM); + + /* forcedly, add internal sound device info. */ + ret = MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_BUILTIN_SPEAKER, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, DEVICE_NAME_BUILTIN_SPK, DEVICE_STATE_DEACTIVATED, NULL); + if (ret) { + debug_error("failed to MMSoundMgrDeviceUpdateStatus() failed (%d)\n", ret); + } + ret = MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_BUILTIN_RECEIVER, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, DEVICE_NAME_BUILTIN_RCV, DEVICE_STATE_DEACTIVATED, NULL); + if (ret) { + debug_error("failed to MMSoundMgrDeviceUpdateStatus() failed (%d)\n", ret); + } + ret = MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_BUILTIN_MIC, DEVICE_IO_DIRECTION_IN, DEVICE_ID_AUTO, DEVICE_NAME_BUILTIN_MIC, DEVICE_STATE_DEACTIVATED, NULL); + if (ret) { + debug_error("failed to MMSoundMgrDeviceUpdateStatus() failed (%d)\n", ret); + } + debug_fleave(); return MM_ERROR_NONE; } @@ -77,7 +139,7 @@ int _mm_sound_mgr_device_is_route_available(const _mm_sound_mgr_device_param_t * _mm_sound_get_devices_from_route(route, &device_in, &device_out); /* check given input & output device is available */ - MMSoundMgrSessionIsDeviceAvailable(device_out, device_in, is_available); + ret = MMSoundMgrSessionIsDeviceAvailable(device_out, device_in, is_available); debug_fleave(); return ret; @@ -101,17 +163,23 @@ int _mm_sound_mgr_device_foreach_available_route_cb(mm_ipc_msg_t *msg) _mm_sound_get_devices_from_route(route_list[route_index], &device_in, &device_out); /* check input & output device of given route is available */ - MMSoundMgrSessionIsDeviceAvailable(device_out, device_in, &is_available); + ret = MMSoundMgrSessionIsDeviceAvailable(device_out, device_in, &is_available); + if (ret != MM_ERROR_NONE) { + debug_error("MMSoundMgrSessionIsDeviceAvailable() failed (%d)\n", ret); + goto FINISH; + } /* add route to avaiable route list */ if (is_available) { if (available_count >= (sizeof(msg->sound_msg.route_list) / sizeof(int))) { debug_error("Cannot add available route, list is full\n"); + ret = MM_ERROR_SOUND_INTERNAL; + goto FINISH; } msg->sound_msg.route_list[available_count++] = route_list[route_index]; } } - +FINISH: debug_fleave(); return ret; } @@ -133,106 +201,559 @@ int _mm_sound_mgr_device_set_active_route(const _mm_sound_mgr_device_param_t *pa } - MMSoundMgrSessionSetDeviceActive(device_out, device_in); + ret = MMSoundMgrSessionSetDeviceActive(device_out, device_in, param->need_broadcast); debug_fleave(); return ret; } +int _mm_sound_mgr_device_set_active_route_auto(void) +{ + int ret = MM_ERROR_NONE; + + debug_fenter(); + + ret = MMSoundMgrSessionSetDeviceActiveAuto(); + if (ret != MM_ERROR_NONE) { + debug_error("fail to _mm_sound_mgr_device_set_active_route_auto.\n"); + } else { + debug_msg ("success : _mm_sound_mgr_device_set_active_route_auto\n"); + } + + debug_fleave(); + return ret; +} int _mm_sound_mgr_device_get_active_device(const _mm_sound_mgr_device_param_t *param, mm_sound_device_in *device_in, mm_sound_device_out *device_out) { int ret = MM_ERROR_NONE; +#ifdef DEBUG_DETAIL debug_fenter(); +#endif - MMSoundMgrSessionGetDeviceActive(device_out, device_in); + ret = MMSoundMgrSessionGetDeviceActive(device_out, device_in); +#ifdef DEBUG_DETAIL debug_fleave(); +#endif + return ret; +} + +int _mm_sound_mgr_device_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out) +{ + int ret = MM_ERROR_NONE; + +#ifdef DEBUG_DETAIL + debug_fenter(); +#endif + + ret = MMSoundMgrSessionGetAudioPath(device_out, device_in); + +#ifdef DEBUG_DETAIL + debug_fleave(); +#endif return ret; } int _mm_sound_mgr_device_add_active_device_callback(const _mm_sound_mgr_device_param_t *param) { int ret = MM_ERROR_NONE; - GList *list; - _mm_sound_mgr_device_param_t *cb_param; + GList *list = NULL; + _mm_sound_mgr_device_param_t *cb_param = NULL; bool is_already_set = FALSE; +#ifdef DEBUG_DETAIL debug_fenter(); +#endif MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_active_device_cb_mutex, MM_ERROR_SOUND_INTERNAL); - for (list = g_active_device_cb_list; list != NULL; list = list->next) - { + for (list = g_active_device_cb_list; list != NULL; list = list->next) { cb_param = (_mm_sound_mgr_device_param_t *)list->data; - if ((cb_param) && (cb_param->pid == param->pid)) - { + if ((cb_param) && (cb_param->pid == param->pid) && (!strcmp(cb_param->name, param->name))) { cb_param->callback = param->callback; cb_param->cbdata = param->cbdata; is_already_set = TRUE; break; } } + if (!is_already_set) { - cb_param = g_malloc(sizeof(_mm_sound_mgr_device_param_t)); + if(!(cb_param = g_malloc(sizeof(_mm_sound_mgr_device_param_t)))) { + ret = MM_ERROR_SOUND_INTERNAL; + goto FINISH; + } memcpy(cb_param, param, sizeof(_mm_sound_mgr_device_param_t)); g_active_device_cb_list = g_list_append(g_active_device_cb_list, cb_param); if (g_active_device_cb_list) { debug_log("active device cb registered for pid [%d]", cb_param->pid); } else { debug_error("g_list_append failed\n"); + ret = MM_ERROR_SOUND_INTERNAL; + goto FINISH; } + + __mm_sound_mgr_ipc_freeze_send (FREEZE_COMMAND_EXCLUDE, param->pid); } +FINISH: MMSOUND_LEAVE_CRITICAL_SECTION(&g_active_device_cb_mutex); - +#ifdef DEBUG_DETAIL debug_fleave(); +#endif return ret; } int _mm_sound_mgr_device_remove_active_device_callback(const _mm_sound_mgr_device_param_t *param) { int ret = MM_ERROR_NONE; - GList *list; - _mm_sound_mgr_device_param_t *cb_param; + GList *list = NULL; + bool is_same_pid_exists = false; + _mm_sound_mgr_device_param_t *cb_param = NULL; debug_fenter(); MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_active_device_cb_mutex, MM_ERROR_SOUND_INTERNAL); - for (list = g_active_device_cb_list; list != NULL; list = list->next) - { + for (list = g_active_device_cb_list; list != NULL; list = list->next) { cb_param = (_mm_sound_mgr_device_param_t *)list->data; - if ((cb_param) && (cb_param->pid == param->pid)) - { + if ((cb_param) && (cb_param->pid == param->pid) && (!strcmp(cb_param->name, param->name))) { g_active_device_cb_list = g_list_remove(g_active_device_cb_list, cb_param); g_free(cb_param); break; } } + /* Check for PID still exists in the list, if not include freeze */ + for (list = g_active_device_cb_list; list != NULL; list = list->next) { + cb_param = (_mm_sound_mgr_device_param_t *)list->data; + if ((cb_param) && (cb_param->pid == param->pid)) { + is_same_pid_exists = true; + break; + } + } + if (!is_same_pid_exists) { + __mm_sound_mgr_ipc_freeze_send (FREEZE_COMMAND_INCLUDE, param->pid); + } MMSOUND_LEAVE_CRITICAL_SECTION(&g_active_device_cb_mutex); debug_fleave(); return ret; } +int _mm_sound_mgr_device_add_volume_callback(const _mm_sound_mgr_device_param_t *param) +{ + int ret = MM_ERROR_NONE; + GList *list = NULL; + _mm_sound_mgr_device_param_t *cb_param = NULL; + bool is_already_set = FALSE; + +#ifdef DEBUG_DETAIL + debug_fenter(); +#endif + + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_volume_cb_mutex, MM_ERROR_SOUND_INTERNAL); + + for (list = g_volume_cb_list; list != NULL; list = list->next) { + cb_param = (_mm_sound_mgr_device_param_t *)list->data; + if ((cb_param) && (cb_param->pid == param->pid) && (!strcmp(cb_param->name, param->name))) { + cb_param->callback = param->callback; + cb_param->cbdata = param->cbdata; + is_already_set = TRUE; + break; + } + } + if (!is_already_set) { + if(!(cb_param = g_malloc(sizeof(_mm_sound_mgr_device_param_t)))) { + ret = MM_ERROR_SOUND_INTERNAL; + goto FINISH; + } + memcpy(cb_param, param, sizeof(_mm_sound_mgr_device_param_t)); + g_volume_cb_list = g_list_append(g_volume_cb_list, cb_param); + if (g_volume_cb_list) { + debug_log("volume cb registered for pid [%d]", cb_param->pid); + } else { + debug_error("g_list_append failed\n"); + ret = MM_ERROR_SOUND_INTERNAL; + goto FINISH; + } + + __mm_sound_mgr_ipc_freeze_send (FREEZE_COMMAND_EXCLUDE, param->pid); + } + +FINISH: + MMSOUND_LEAVE_CRITICAL_SECTION(&g_volume_cb_mutex); +#ifdef DEBUG_DETAIL + debug_fleave(); +#endif + return ret; +} + +int _mm_sound_mgr_device_remove_volume_callback(const _mm_sound_mgr_device_param_t *param) +{ + int ret = MM_ERROR_SOUND_INTERNAL; + GList *list = NULL; + _mm_sound_mgr_device_param_t *cb_param = NULL; + + debug_fenter(); + + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_volume_cb_mutex, MM_ERROR_SOUND_INTERNAL); + + for (list = g_volume_cb_list; list != NULL; list = list->next) { + cb_param = (_mm_sound_mgr_device_param_t *)list->data; + if ((cb_param) && (cb_param->pid == param->pid) && (!strcmp(cb_param->name, param->name))) { + g_volume_cb_list = g_list_remove(g_volume_cb_list, cb_param); + __mm_sound_mgr_ipc_freeze_send (FREEZE_COMMAND_INCLUDE, param->pid); + g_free(cb_param); + ret = MM_ERROR_NONE; + break; + } + } + + MMSOUND_LEAVE_CRITICAL_SECTION(&g_volume_cb_mutex); + + debug_fleave(); + return ret; +} + +int __mm_sound_mgr_device_check_process(int pid) +{ + DIR *dir = NULL; + char check_path[128] = ""; + int exist = MM_ERROR_NONE; + + memset(check_path, '\0', sizeof(check_path)); + snprintf(check_path, sizeof(check_path) - 1, "/proc/%d", pid); + + dir = opendir(check_path); + if (dir == NULL) { + switch (errno) { + case ENOENT: + debug_error("pid %d does not exist anymore\n", pid); + exist = MM_ERROR_SOUND_INTERNAL; + break; + case EACCES: + debug_error("Permission denied\n"); + break; + case EMFILE: + debug_error("Too many file descriptors in use by process\n"); + break; + case ENFILE: + debug_error("Too many files are currently open in the system\n"); + break; + default: + debug_error("Other error : %d\n", errno); + break; + } + } else { + debug_warning("pid : %d still alive\n", pid); + if (-1 == closedir(dir)) { + debug_error("closedir failed with errno : %d\n", errno); + } + } + return exist; +} + +int _mm_sound_mgr_device_get_current_connected_dev_list(const _mm_sound_mgr_device_param_t *param, GList **device_list) +{ + int ret = MM_ERROR_NONE; + mm_sound_device_t *device_node = NULL; + +#ifdef DEBUG_DETAIL + debug_fenter(); +#endif + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_connected_device_list_mutex, MM_ERROR_SOUND_INTERNAL); + + *device_list = g_connected_device_list; + debug_msg("address of g_connected_device_list[0x%x]", g_connected_device_list); + +FINISH: + MMSOUND_LEAVE_CRITICAL_SECTION(&g_connected_device_list_mutex); +#ifdef DEBUG_DETAIL + debug_fleave(); +#endif + return ret; +} + +int _mm_sound_mgr_device_add_connected_callback(const _mm_sound_mgr_device_param_t *param) +{ + int ret = MM_ERROR_NONE; + GList *list = NULL; + _mm_sound_mgr_device_param_t *cb_param = NULL; + bool is_already_set = FALSE; + +#ifdef DEBUG_DETAIL + debug_fenter(); +#endif + + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_connected_cb_mutex, MM_ERROR_SOUND_INTERNAL); + + for (list = g_device_connected_cb_list; list != NULL; list = list->next) { + cb_param = (_mm_sound_mgr_device_param_t *)list->data; + if (cb_param && (cb_param->pid == param->pid)) { + cb_param->callback = param->callback; + cb_param->cbdata = param->cbdata; + is_already_set = TRUE; + break; + } + } + + if (!is_already_set) { + if(!(cb_param = g_malloc(sizeof(_mm_sound_mgr_device_param_t)))) { + ret = MM_ERROR_SOUND_INTERNAL; + goto FINISH; + } + memcpy(cb_param, param, sizeof(_mm_sound_mgr_device_param_t)); + g_device_connected_cb_list = g_list_append(g_device_connected_cb_list, cb_param); + if (g_device_connected_cb_list) { + debug_log("device connected cb registered for pid [%d]", cb_param->pid); + } else { + debug_error("g_list_append failed\n"); + ret = MM_ERROR_SOUND_INTERNAL; + goto FINISH; + } + + __mm_sound_mgr_ipc_freeze_send (FREEZE_COMMAND_EXCLUDE, param->pid); + } + +FINISH: + MMSOUND_LEAVE_CRITICAL_SECTION(&g_device_connected_cb_mutex); +#ifdef DEBUG_DETAIL + debug_fleave(); +#endif + return ret; +} + +int _mm_sound_mgr_device_remove_connected_callback(const _mm_sound_mgr_device_param_t *param) +{ + int ret = MM_ERROR_SOUND_INTERNAL; + GList *list = NULL; + bool is_same_pid_exists = false; + _mm_sound_mgr_device_param_t *cb_param = NULL; + + debug_fenter(); + + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_connected_cb_mutex, MM_ERROR_SOUND_INTERNAL); + + for (list = g_device_connected_cb_list; list != NULL; list = list->next) { + cb_param = (_mm_sound_mgr_device_param_t *)list->data; + if (cb_param && (cb_param->pid == param->pid)) { + g_device_connected_cb_list = g_list_remove(g_device_connected_cb_list, cb_param); + g_free(cb_param); + ret = MM_ERROR_NONE; + break; + } + } + + /* Check for PID still exists in the list, if not include freeze */ + for (list = g_device_connected_cb_list; list != NULL; list = list->next) { + cb_param = (_mm_sound_mgr_device_param_t *)list->data; + if ((cb_param) && (cb_param->pid == param->pid)) { + is_same_pid_exists = true; + break; + } + } + if (!is_same_pid_exists) { + __mm_sound_mgr_ipc_freeze_send (FREEZE_COMMAND_INCLUDE, param->pid); + } + MMSOUND_LEAVE_CRITICAL_SECTION(&g_device_connected_cb_mutex); + + debug_fleave(); + return ret; +} + +int _mm_sound_mgr_device_add_info_changed_callback(const _mm_sound_mgr_device_param_t *param) +{ + int ret = MM_ERROR_NONE; + GList *list = NULL; + _mm_sound_mgr_device_param_t *cb_param = NULL; + bool is_already_set = FALSE; + +#ifdef DEBUG_DETAIL + debug_fenter(); +#endif + + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_info_changed_cb_mutex, MM_ERROR_SOUND_INTERNAL); + + for (list = g_device_info_changed_cb_list; list != NULL; list = list->next) { + cb_param = (_mm_sound_mgr_device_param_t *)list->data; + if (cb_param && (cb_param->pid == param->pid)) { + cb_param->callback = param->callback; + cb_param->cbdata = param->cbdata; + is_already_set = TRUE; + break; + } + } + + if (!is_already_set) { + if(!(cb_param = g_malloc(sizeof(_mm_sound_mgr_device_param_t)))) { + ret = MM_ERROR_SOUND_INTERNAL; + goto FINISH; + } + memcpy(cb_param, param, sizeof(_mm_sound_mgr_device_param_t)); + g_device_info_changed_cb_list = g_list_append(g_device_info_changed_cb_list, cb_param); + if (g_device_info_changed_cb_list) { + debug_log("device information changed cb registered for pid [%d]", cb_param->pid); + } else { + debug_error("g_list_append failed\n"); + ret = MM_ERROR_SOUND_INTERNAL; + goto FINISH; + } + + __mm_sound_mgr_ipc_freeze_send (FREEZE_COMMAND_EXCLUDE, param->pid); + } + +FINISH: + MMSOUND_LEAVE_CRITICAL_SECTION(&g_device_info_changed_cb_mutex); +#ifdef DEBUG_DETAIL + debug_fleave(); +#endif + return ret; +} + +int _mm_sound_mgr_device_remove_info_changed_callback(const _mm_sound_mgr_device_param_t *param) +{ + int ret = MM_ERROR_SOUND_INTERNAL; + GList *list = NULL; + bool is_same_pid_exists = false; + _mm_sound_mgr_device_param_t *cb_param = NULL; + + debug_fenter(); + + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_info_changed_cb_mutex, MM_ERROR_SOUND_INTERNAL); + + for (list = g_device_info_changed_cb_list; list != NULL; list = list->next) { + cb_param = (_mm_sound_mgr_device_param_t *)list->data; + if (cb_param && (cb_param->pid == param->pid)) { + g_device_info_changed_cb_list = g_list_remove(g_device_info_changed_cb_list, cb_param); + g_free(cb_param); + ret = MM_ERROR_NONE; + break; + } + } + + /* Check for PID still exists in the list, if not include freeze */ + for (list = g_device_info_changed_cb_list; list != NULL; list = list->next) { + cb_param = (_mm_sound_mgr_device_param_t *)list->data; + if ((cb_param) && (cb_param->pid == param->pid)) { + is_same_pid_exists = true; + break; + } + } + if (!is_same_pid_exists) { + __mm_sound_mgr_ipc_freeze_send (FREEZE_COMMAND_INCLUDE, param->pid); + } + MMSOUND_LEAVE_CRITICAL_SECTION(&g_device_info_changed_cb_mutex); + + debug_fleave(); + return ret; +} + +/* debug_warning ("cb_list = %p, cb_param = %p, pid=[%d]", x, cb_param, (cb_param)? cb_param->pid : -1); \ remove logs*/ +#define CLEAR_DEAD_CB_LIST(x) do { \ + debug_warning ("cb_list = %p, cb_param = %p, pid=[%d]", x, cb_param, (cb_param)? cb_param->pid : -1); \ + if (x && cb_param && __mm_sound_mgr_device_check_process (cb_param->pid) != 0) { \ + debug_warning("PID:%d does not exist now! remove from device cb list\n", cb_param->pid); \ + g_free (cb_param); \ + x = g_list_remove (x, cb_param); \ + } \ +}while(0) + +static void _clear_available_cb_list_func (_mm_sound_mgr_device_param_t * cb_param, gpointer user_data) +{ + CLEAR_DEAD_CB_LIST(g_available_route_cb_list); +} + +static void _clear_active_cb_list_func (_mm_sound_mgr_device_param_t * cb_param, gpointer user_data) +{ + CLEAR_DEAD_CB_LIST(g_active_device_cb_list); +} + +static void _clear_volume_cb_list_func (_mm_sound_mgr_device_param_t * cb_param, gpointer user_data) +{ + CLEAR_DEAD_CB_LIST(g_volume_cb_list); +} + +static void _clear_device_connected_cb_list_func (_mm_sound_mgr_device_param_t * cb_param, gpointer user_data) +{ + CLEAR_DEAD_CB_LIST(g_device_connected_cb_list); +} + +static void _clear_device_info_changed_cb_list_func (_mm_sound_mgr_device_param_t * cb_param, gpointer user_data) +{ + CLEAR_DEAD_CB_LIST(g_device_info_changed_cb_list); +} + +static int _mm_sound_mgr_device_volume_callback(keynode_t* node, void* data) +{ + int ret = MM_ERROR_NONE; + GList *list = NULL; + _mm_sound_mgr_device_param_t *cb_param = NULL; + mm_ipc_msg_t msg; + volume_type_t type = (volume_type_t)data; + mm_sound_device_in device_in; + mm_sound_device_out device_out; + char *str = NULL; + unsigned int value; + + debug_enter("[%s] changed callback called", vconf_keynode_get_name(node)); + + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_volume_cb_mutex, MM_ERROR_SOUND_INTERNAL); + + MMSoundMgrSessionGetDeviceActive(&device_out, &device_in); + /* Get volume value from VCONF */ + if (vconf_get_int(g_volume_vconf[type], &value)) { + debug_error ("vconf_get_int(%s) failed..\n", g_volume_vconf[type]); + ret = MM_ERROR_SOUND_INTERNAL; + goto FINISH; + } + + /* Update list for dead process */ + g_list_foreach (g_volume_cb_list, (GFunc)_clear_volume_cb_list_func, NULL); + + for (list = g_volume_cb_list; list != NULL; list = list->next) { + cb_param = (_mm_sound_mgr_device_param_t *)list->data; + if ((cb_param) && (cb_param->callback)) { + memset(&msg, 0, sizeof(mm_ipc_msg_t)); + SOUND_MSG_SET(msg.sound_msg, MM_SOUND_MSG_INF_VOLUME_CB, 0, MM_ERROR_NONE, cb_param->pid); + msg.sound_msg.type = type; + msg.sound_msg.val = value; + msg.sound_msg.callback = cb_param->callback; + msg.sound_msg.cbdata = cb_param->cbdata; + + ret = _MMIpcCBSndMsg(&msg); + if (ret != MM_ERROR_NONE) { + debug_error("Fail to send callback message (%x)\n", ret); + goto FINISH; + } + } + } + +FINISH: + MMSOUND_LEAVE_CRITICAL_SECTION(&g_volume_cb_mutex); + + debug_leave(); + return ret; +} + int _mm_sound_mgr_device_active_device_callback(mm_sound_device_in device_in, mm_sound_device_out device_out) { int ret = MM_ERROR_NONE; - GList *list; - _mm_sound_mgr_device_param_t *cb_param; + GList *list = NULL; + _mm_sound_mgr_device_param_t *cb_param = NULL; mm_ipc_msg_t msg; debug_fenter(); MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_active_device_cb_mutex, MM_ERROR_SOUND_INTERNAL); - for (list = g_active_device_cb_list; list != NULL; list = list->next) - { + /* Update list for dead process */ + g_list_foreach (g_active_device_cb_list, (GFunc)_clear_active_cb_list_func, NULL); + + for (list = g_active_device_cb_list; list != NULL; list = list->next) { cb_param = (_mm_sound_mgr_device_param_t *)list->data; - if ((cb_param) && (cb_param->callback)) - { + if ((cb_param) && (cb_param->callback)) { + memset(&msg, 0, sizeof(mm_ipc_msg_t)); SOUND_MSG_SET(msg.sound_msg, MM_SOUND_MSG_INF_ACTIVE_DEVICE_CB, 0, MM_ERROR_NONE, cb_param->pid); msg.sound_msg.device_in = device_in; msg.sound_msg.device_out = device_out; @@ -240,11 +761,13 @@ int _mm_sound_mgr_device_active_device_callback(mm_sound_device_in device_in, mm msg.sound_msg.cbdata = cb_param->cbdata; ret = _MMIpcCBSndMsg(&msg); - if (ret != MM_ERROR_NONE) - debug_error("Fail to send callback message\n"); + if (ret != MM_ERROR_NONE) { + debug_error("Fail to send callback message (%x)\n", ret); + goto FINISH; + } } } - +FINISH: MMSOUND_LEAVE_CRITICAL_SECTION(&g_active_device_cb_mutex); debug_fleave(); @@ -254,19 +777,17 @@ int _mm_sound_mgr_device_active_device_callback(mm_sound_device_in device_in, mm int _mm_sound_mgr_device_add_available_route_callback(const _mm_sound_mgr_device_param_t *param) { int ret = MM_ERROR_NONE; - GList *list; - _mm_sound_mgr_device_param_t *cb_param; + GList *list = NULL; + _mm_sound_mgr_device_param_t *cb_param = NULL; bool is_already_set = FALSE; debug_fenter(); MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_available_route_cb_mutex, MM_ERROR_SOUND_INTERNAL); - for (list = g_available_route_cb_list; list != NULL; list = list->next) - { + for (list = g_available_route_cb_list; list != NULL; list = list->next) { cb_param = (_mm_sound_mgr_device_param_t *)list->data; - if ((cb_param) && (cb_param->pid == param->pid)) - { + if ((cb_param) && (cb_param->pid == param->pid)) { cb_param->callback = param->callback; cb_param->cbdata = param->cbdata; is_already_set = TRUE; @@ -274,16 +795,23 @@ int _mm_sound_mgr_device_add_available_route_callback(const _mm_sound_mgr_device } } if (!is_already_set) { - cb_param = g_malloc(sizeof(_mm_sound_mgr_device_param_t)); + if(!(cb_param = g_malloc(sizeof(_mm_sound_mgr_device_param_t)))) { + ret = MM_ERROR_SOUND_INTERNAL; + goto FINISH; + } memcpy(cb_param, param, sizeof(_mm_sound_mgr_device_param_t)); g_available_route_cb_list = g_list_append(g_available_route_cb_list, cb_param); if (g_available_route_cb_list) { debug_log("available route cb registered for pid [%d]", cb_param->pid); } else { debug_error("g_list_append failed\n"); + ret = MM_ERROR_SOUND_INTERNAL; + goto FINISH; } - } + __mm_sound_mgr_ipc_freeze_send (FREEZE_COMMAND_EXCLUDE, param->pid); + } +FINISH: MMSOUND_LEAVE_CRITICAL_SECTION(&g_available_route_cb_mutex); debug_fleave(); @@ -293,19 +821,18 @@ int _mm_sound_mgr_device_add_available_route_callback(const _mm_sound_mgr_device int _mm_sound_mgr_device_remove_available_route_callback(const _mm_sound_mgr_device_param_t *param) { int ret = MM_ERROR_NONE; - GList *list; - _mm_sound_mgr_device_param_t *cb_param; + GList *list = NULL; + _mm_sound_mgr_device_param_t *cb_param = NULL; debug_fenter(); MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_available_route_cb_mutex, MM_ERROR_SOUND_INTERNAL); - for (list = g_available_route_cb_list; list != NULL; list = list->next) - { + for (list = g_available_route_cb_list; list != NULL; list = list->next) { cb_param = (_mm_sound_mgr_device_param_t *)list->data; - if ((cb_param) && (cb_param->pid == param->pid)) - { + if ((cb_param) && (cb_param->pid == param->pid)) { g_available_route_cb_list = g_list_remove(g_available_route_cb_list, cb_param); + __mm_sound_mgr_ipc_freeze_send (FREEZE_COMMAND_INCLUDE, param->pid); g_free(cb_param); break; } @@ -317,27 +844,41 @@ int _mm_sound_mgr_device_remove_available_route_callback(const _mm_sound_mgr_dev return ret; } +int _mm_sound_mgr_device_set_sound_path_for_active_device(mm_sound_device_out playback, mm_sound_device_in capture) +{ + int ret = MM_ERROR_NONE; + + debug_fenter(); + ret = MMSoundMgrSessionSetSoundPathForActiveDevice(playback, capture); + + debug_fleave(); + return ret; +} + int _mm_sound_mgr_device_available_device_callback(mm_sound_device_in device_in, mm_sound_device_out device_out, bool available) { int ret = MM_ERROR_NONE; - _mm_sound_mgr_device_param_t *cb_param; + _mm_sound_mgr_device_param_t *cb_param = NULL; mm_ipc_msg_t msg; int route_list_count = 0; int route_index = 0; int available_count = 0; mm_sound_route *route_list = NULL; GList *list = NULL; - GList *available_route_list = NULL; debug_fenter(); + memset (&msg, 0, sizeof(mm_ipc_msg_t)); + route_list_count = _mm_sound_get_valid_route_list(&route_list); + debug_log("in=[%x], out=[%x], route_list_count = [%d], available = [%d]", device_in, device_out, route_list_count, available); for (route_index = 0; route_index < route_list_count; route_index++) { mm_sound_device_in route_device_in = MM_SOUND_DEVICE_IN_NONE; mm_sound_device_out route_device_out = MM_SOUND_DEVICE_OUT_NONE; bool is_changed = 0; _mm_sound_get_devices_from_route(route_list[route_index], &route_device_in, &route_device_out); + if ((device_in != MM_SOUND_DEVICE_IN_NONE) && (device_in == route_device_in)) { /* device(in&out) changed together & they can be combined as this route */ if ((device_out != MM_SOUND_DEVICE_OUT_NONE) && (device_out == route_device_out)) { @@ -359,37 +900,777 @@ int _mm_sound_mgr_device_available_device_callback(mm_sound_device_in device_in, MMSoundMgrSessionIsDeviceAvailableNoLock(MM_SOUND_DEVICE_OUT_NONE, route_device_in, &is_changed); } } - /* add route to avaiable route list */ if (is_changed) { if (available_count >= (sizeof(msg.sound_msg.route_list) / sizeof(int))) { debug_error("Cannot add available route, list is full\n"); + return MM_ERROR_SOUND_INTERNAL; } + debug_log("route_index [%d] is added to route_list [%d]", route_index, available_count); msg.sound_msg.route_list[available_count++] = route_list[route_index]; } } MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_available_route_cb_mutex, MM_ERROR_SOUND_INTERNAL); - for (list = g_available_route_cb_list; list != NULL; list = list->next) - { + /* Update list for dead process */ + g_list_foreach (g_available_route_cb_list, (GFunc)_clear_available_cb_list_func, NULL); + + for (list = g_available_route_cb_list; list != NULL; list = list->next) { cb_param = (_mm_sound_mgr_device_param_t *)list->data; - if ((cb_param) && (cb_param->callback)) - { + if ((cb_param) && (cb_param->callback)) { SOUND_MSG_SET(msg.sound_msg, MM_SOUND_MSG_INF_AVAILABLE_ROUTE_CB, 0, MM_ERROR_NONE, cb_param->pid); msg.sound_msg.is_available = available; msg.sound_msg.callback = cb_param->callback; msg.sound_msg.cbdata = cb_param->cbdata; ret = _MMIpcCBSndMsg(&msg); - if (ret != MM_ERROR_NONE) + if (ret != MM_ERROR_NONE) { debug_error("Fail to send callback message\n"); + goto FINISH; + } } } - +FINISH: MMSOUND_LEAVE_CRITICAL_SECTION(&g_available_route_cb_mutex); debug_fleave(); return ret; } +int _mm_sound_mgr_device_update_volume() +{ + int i=0; + char* str = NULL; + int ret = MM_ERROR_NONE; + + for (i=0; iid = device_id; \ +} while(0) + +#define GET_DEVICE_INFO_ID(x_device_h, x_id) \ +do { \ + if (!x_device_h) { \ + debug_error("device_h is null, could not get device id"); \ + break; \ + } \ + if (x_id) \ + *x_id = x_device_h->id; \ +} while(0) + +#define SET_DEVICE_INFO_TYPE(x_device_h, x_type) \ +do { \ + if (!x_device_h) { \ + debug_error("device_h is null, could not set device type"); \ + break; \ + } \ + x_device_h->type = x_type; \ +} while(0) + +#define SET_DEVICE_INFO_IO_DIRECTION(x_device_h, x_io_direction) \ +do { \ + if (!x_device_h) { \ + debug_error("device_h is null, could not set device io direction"); \ + break; \ + } \ + x_device_h->io_direction = x_io_direction; \ +} while(0) + +#define GET_DEVICE_INFO_IO_DIRECTION(x_device_h, x_io_direction) \ +do { \ + if (!x_device_h) { \ + debug_error("device_h is null, could not get device io direction"); \ + break; \ + } \ + x_io_direction = x_device_h->io_direction; \ +} while(0) + +#define SET_DEVICE_INFO_NAME(x_device_h, x_name) \ +do { \ + if (!x_device_h) { \ + debug_error("device_h is null, could not set device name"); \ + break; \ + } \ + if(x_name) { \ + int size = strlen(x_name); \ + memcpy (x_device_h->name, x_name, (MAX_DEVICE_NAME_NUM > size)? size : MAX_DEVICE_NAME_NUM-1); \ + } \ +} while(0) + +#define SET_DEVICE_INFO_STATE(x_device_h, x_state) \ +do { \ + if (!x_device_h) { \ + debug_error("device_h is null, could not set device state"); \ + break; \ + } \ + x_device_h->state = x_state; \ +} while(0) + +#define GET_DEVICE_INFO_STATE(x_device_h, x_state) \ +do { \ + if (!x_device_h) { \ + debug_error("device_h is null, could not get device state"); \ + break; \ + } \ + x_state = x_device_h->state; \ +} while(0) + +static const char* device_update_str[] = +{ + "DISCONNECTED", + "CONNECTED", + "STATE", + "IO-DIRECTION", +}; + +static const char* device_type_str[] = +{ + "BUILTIN_SPK", + "BUILTIN_RCV", + "BUILTIN_MIC", + "AUDIOJACK", + "BLUETOOTH", + "HDMI", + "MIRRORING", + "USB_AUDIO", +}; + +static const char* device_state_str[] = +{ + "DEACTIVATED", + "ACTIVATED", +}; + +static const char* device_io_direction_str[] = +{ + "IN", + "OUT", + "BOTH", +}; + +static int __mm_sound_mgr_device_check_flags_to_trigger (int device_flags, mm_sound_device_t *device_h, bool *is_good_to_go) +{ + bool need_to_go = false; + int need_to_check_for_io_direction = device_flags & DEVICE_IO_DIRECTION_FLAGS; + int need_to_check_for_state = device_flags & DEVICE_STATE_FLAGS; + int need_to_check_for_type = device_flags & DEVICE_TYPE_FLAGS; + + debug_warning("device_h[0x%x], device_flags[0x%x], need_to_check(io_direction[0x%x],state[0x%x],type[0x%x])\n", + device_h, device_flags, need_to_check_for_io_direction, need_to_check_for_state, need_to_check_for_type); + + if(!device_h) { + return MM_ERROR_INVALID_ARGUMENT; + } + if (device_flags == DEVICE_ALL_FLAG) { + *is_good_to_go = true; + return MM_ERROR_NONE; + } + + if (need_to_check_for_io_direction) { + if ((device_h->io_direction == DEVICE_IO_DIRECTION_IN) && (device_flags & DEVICE_IO_DIRECTION_IN_FLAG)) { + need_to_go = true; + } else if ((device_h->io_direction == DEVICE_IO_DIRECTION_OUT) && (device_flags & DEVICE_IO_DIRECTION_OUT_FLAG)) { + need_to_go = true; + } else if ((device_h->io_direction == DEVICE_IO_DIRECTION_BOTH) && (device_flags & DEVICE_IO_DIRECTION_BOTH_FLAG)) { + need_to_go = true; + } + if (need_to_go) { + if (!need_to_check_for_state && !need_to_check_for_type) { + *is_good_to_go = true; + return MM_ERROR_NONE; + } + } else { + *is_good_to_go = false; + return MM_ERROR_NONE; + } + } + if (need_to_check_for_state) { + need_to_go = false; + if ((device_h->state == DEVICE_STATE_DEACTIVATED) && (device_flags & DEVICE_STATE_DEACTIVATED_FLAG)) { + need_to_go = true; + } else if ((device_h->state == DEVICE_STATE_ACTIVATED) && (device_flags & DEVICE_STATE_ACTIVATED_FLAG)) { + need_to_go = true; + } + if (need_to_go) { + if (!need_to_check_for_type) { + *is_good_to_go = true; + return MM_ERROR_NONE; + } + } else { + *is_good_to_go = false; + return MM_ERROR_NONE; + } + } + if (need_to_check_for_type) { + need_to_go = false; + bool is_internal_device = IS_INTERNAL_DEVICE(device_h->type); + if (is_internal_device && (device_flags & DEVICE_TYPE_INTERNAL_FLAG)) { + need_to_go = true; + } else if (!is_internal_device && (device_flags & DEVICE_TYPE_EXTERNAL_FLAG)) { + need_to_go = true; + } + if (need_to_go) { + *is_good_to_go = true; + return MM_ERROR_NONE; + } else { + *is_good_to_go = false; + return MM_ERROR_NONE; + } + } + return MM_ERROR_NONE; +} + +int _mm_sound_mgr_device_connected_callback(mm_sound_device_t *device_h, bool is_connected) +{ + int ret = MM_ERROR_NONE; + GList *list = NULL; + _mm_sound_mgr_device_param_t *cb_param = NULL; + mm_ipc_msg_t msg; + bool is_good_to_go = true; + + debug_fenter(); + + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_connected_cb_mutex, MM_ERROR_SOUND_INTERNAL); + + /* Update list for dead process */ + g_list_foreach (g_device_connected_cb_list, (GFunc)_clear_device_connected_cb_list_func, NULL); + + for (list = g_device_connected_cb_list; list != NULL; list = list->next) { + cb_param = (_mm_sound_mgr_device_param_t *)list->data; + if (!cb_param) { + continue; + } + /* check flags */ + ret = __mm_sound_mgr_device_check_flags_to_trigger (cb_param->device_flags, device_h, &is_good_to_go); + if (!ret && is_good_to_go) { + if (cb_param->callback) { + memset(&msg, 0, sizeof(mm_ipc_msg_t)); + SOUND_MSG_SET(msg.sound_msg, MM_SOUND_MSG_INF_DEVICE_CONNECTED_CB, 0, MM_ERROR_NONE, cb_param->pid); + //msg.sound_msg.device_handle = device_h; + memcpy (&(msg.sound_msg.device_handle), device_h, sizeof(mm_sound_device_t)); + msg.sound_msg.is_connected = is_connected; + msg.sound_msg.callback = cb_param->callback; + msg.sound_msg.cbdata = cb_param->cbdata; + + ret = _MMIpcCBSndMsg(&msg); + if (ret != MM_ERROR_NONE) { + debug_error("Fail to send callback message (%x)\n", ret); + goto FINISH; + } + } + } else { + if (ret) { + debug_error("failed to __mm_sound_mgr_device_check_flags_to_trigger(), ret[0x%x], is_good_to_go[%d]\n", ret, is_good_to_go); + } else { + debug_warning("No need to trigger the callback, is_good_to_go[%d]\n", ret, is_good_to_go); + } + } + } + +FINISH: + MMSOUND_LEAVE_CRITICAL_SECTION(&g_device_connected_cb_mutex); + + debug_fleave(); + return ret; +} + +int _mm_sound_mgr_device_info_changed_callback(mm_sound_device_t *device_h, int changed_info_type) +{ + int ret = MM_ERROR_NONE; + GList *list = NULL; + _mm_sound_mgr_device_param_t *cb_param = NULL; + mm_ipc_msg_t msg; + bool is_good_to_go = true; + + debug_fenter(); + + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_info_changed_cb_mutex, MM_ERROR_SOUND_INTERNAL); + + /* Update list for dead process */ + g_list_foreach (g_device_info_changed_cb_list, (GFunc)_clear_device_info_changed_cb_list_func, NULL); + + for (list = g_device_info_changed_cb_list; list != NULL; list = list->next) { + cb_param = (_mm_sound_mgr_device_param_t *)list->data; + if (!cb_param) { + continue; + } + /* check flags */ + ret = __mm_sound_mgr_device_check_flags_to_trigger (cb_param->device_flags, device_h, &is_good_to_go); + if (!ret && is_good_to_go) { + if (cb_param->callback) { + memset(&msg, 0, sizeof(mm_ipc_msg_t)); + SOUND_MSG_SET(msg.sound_msg, MM_SOUND_MSG_INF_DEVICE_INFO_CHANGED_CB, 0, MM_ERROR_NONE, cb_param->pid); + memcpy (&(msg.sound_msg.device_handle), device_h, sizeof(mm_sound_device_t)); + msg.sound_msg.changed_device_info_type = changed_info_type; + msg.sound_msg.callback = cb_param->callback; + msg.sound_msg.cbdata = cb_param->cbdata; + + ret = _MMIpcCBSndMsg(&msg); + if (ret != MM_ERROR_NONE) { + debug_error("Fail to send callback message (%x)\n", ret); + goto FINISH; + } + } + } else { + debug_error("failed to __mm_sound_mgr_device_check_flags_to_trigger(), ret[0x%x], is_good_to_go[%d]\n", ret, is_good_to_go); + } + } + +FINISH: + MMSOUND_LEAVE_CRITICAL_SECTION(&g_device_info_changed_cb_mutex); + + debug_fleave(); + return ret; +} + +int _mm_sound_mgr_device_connected_dev_list_find_item (mm_sound_device_t **device_h, device_type_e device_type, int id) +{ + int ret = MM_ERROR_NONE; + + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_connected_device_list_mutex, MM_ERROR_SOUND_INTERNAL); + + GList *list = NULL; + mm_sound_device_t *device_node = NULL; + for (list = g_connected_device_list; list != NULL; list = list->next) { + device_node = (mm_sound_device_t *)list->data; + if (((device_node) && (device_node->type == device_type) && (id == DEVICE_ID_AUTO)) || ((device_node) && (device_node->id == id))) { + debug_log("found the suitable item, device_type[%d], id[%d]\n", device_node->type, device_node->id); + break; + } + } + if (list != NULL) { + *device_h = device_node; + } else { + debug_error("no suitable item for device_type[%d], id[%d]\n", device_type, id); + ret = MM_ERROR_SOUND_NO_DATA; + } + + MMSOUND_LEAVE_CRITICAL_SECTION(&g_connected_device_list_mutex); + + return ret; +} + +int _mm_sound_mgr_device_connected_dev_list_add_item (mm_sound_device_t **device_h) +{ + int ret = MM_ERROR_NONE; + mm_sound_device_t *device_node = g_malloc0(sizeof(mm_sound_device_t)); + debug_log("new device_node[0x%x]\n", device_node); + + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_connected_device_list_mutex, MM_ERROR_SOUND_INTERNAL); + + g_connected_device_list = g_list_append(g_connected_device_list, device_node); + + MMSOUND_LEAVE_CRITICAL_SECTION(&g_connected_device_list_mutex); + + *device_h = device_node; + + return ret; +} + +int _mm_sound_mgr_device_connected_dev_list_remove_item (mm_sound_device_t *device_h) +{ + int ret = MM_ERROR_NONE; + GList *list = NULL; + mm_sound_device_t *device_node = NULL; + if (!device_h) { + debug_error("device_h is null\n"); + ret = MM_ERROR_INVALID_ARGUMENT; + } else { + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_connected_device_list_mutex, MM_ERROR_SOUND_INTERNAL); + for (list = g_connected_device_list; list != NULL; list = list->next) { + device_node = (mm_sound_device_t *)list->data; + if ((device_node) && (device_node->type == device_h->type)) { + RELEASE_DEVICE_INFO_ID(device_node->id); + g_connected_device_list = g_list_remove(g_connected_device_list, device_node); + g_free(device_node); + break; + } + } + MMSOUND_LEAVE_CRITICAL_SECTION(&g_connected_device_list_mutex); + } + + debug_log("=============== Remain devices =========================================================\n"); + _mm_sound_mgr_device_connected_dev_list_dump(); + + return ret; +} + +int _mm_sound_mgr_device_connected_dev_list_dump () +{ + int ret = MM_ERROR_NONE; + GList *list = NULL; + mm_sound_device_t *device_node = NULL; + int count = 0; + + debug_log("================================== device list : start =====================================\n"); + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_connected_device_list_mutex, MM_ERROR_SOUND_INTERNAL); + for (list = g_connected_device_list; list != NULL; list = list->next) { + device_node = (mm_sound_device_t *)list->data; + if (device_node) { + debug_log(" idx[%d] >>> type[%12s], id[%2d], io_direction[%4s], state[%12s], name[%s]\n", + count++, device_type_str[device_node->type], device_node->id, device_io_direction_str[device_node->io_direction], device_state_str[device_node->state], device_node->name); + } + } + MMSOUND_LEAVE_CRITICAL_SECTION(&g_connected_device_list_mutex); + debug_log("================================== device list : end =======================================\n"); + + return ret; +} + +int MMSoundMgrDeviceGetIoDirectionById (int id, device_io_direction_e *io_direction) +{ + int ret = MM_ERROR_NONE; + /* find the device handle by device_type and(or) id */ + mm_sound_device_t *device_h = NULL; + ret = _mm_sound_mgr_device_connected_dev_list_find_item (&device_h, 0, id); + if(!ret && device_h) { + debug_log("found device_h[0x%x] for id[%d], io_direction[%d]\n", device_h, id, device_h->io_direction); + *io_direction = device_h->io_direction; + } else { + debug_error("failed to _mm_sound_mgr_device_connected_dev_list_find_item() for id[%d], ret[0x%x]\n", id, ret); + ret = MM_ERROR_SOUND_NO_DATA; + } + return ret; +} + +/* if DEVICE is connected => add new entry (alloc id) => update status => call callback func */ +/* if DEVICE is disconnected => update status(deactivated) => call changed info callback => copy disconnected entry */ +/* => remove the entry (dealloc id) => call disconnected callback with copied entry */ +/* if DEVICE's info. is changed => get device_h (by type and(or) id) => update status => call callback func */ +int MMSoundMgrDeviceUpdateStatus (device_update_status_e update_status, device_type_e device_type, device_io_direction_e io_direction, int id, const char* name, device_state_e state, int *alloc_id) +{ + debug_warning ("[UpdateDeviceStatus] update_for[%12s], type[%11s], direction[%4s], id[%d], name[%s], state[%11s], alloc_id[0x%x]\n", + device_update_str[update_status], device_type_str[device_type], device_io_direction_str[io_direction], id, name, device_state_str[state], alloc_id); + switch (update_status) { + case DEVICE_UPDATE_STATUS_CONNECTED: + { + int ret = MM_ERROR_NONE; + /* find the device handle by device_type and(or) id */ + mm_sound_device_t *device_h = NULL; + ret = _mm_sound_mgr_device_connected_dev_list_find_item (&device_h, device_type, id); + if(ret == MM_ERROR_SOUND_NO_DATA && !device_h) { + /* add new entry for the type */ + ret = _mm_sound_mgr_device_connected_dev_list_add_item (&device_h); + if (ret || !device_h) { + debug_error("could not add a new item for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret); + } else { + debug_error("update info for this device_h[0x%x]\n", device_h); + /* update device information */ + /* 1. type */ + SET_DEVICE_INFO_TYPE(device_h, device_type); + /* 2. io direction */ + SET_DEVICE_INFO_IO_DIRECTION(device_h, io_direction); + /* 3. name */ + SET_DEVICE_INFO_NAME(device_h, name); + /* 4. state */ + SET_DEVICE_INFO_STATE(device_h, DEVICE_STATE_DEACTIVATED); + /* 4. id */ + SET_DEVICE_INFO_ID_AUTO(device_h); + GET_DEVICE_INFO_ID(device_h, alloc_id); + + _mm_sound_mgr_device_connected_dev_list_dump(); + + /* trigger callback functions */ + ret = _mm_sound_mgr_device_connected_callback(device_h, true); + if (ret) { + debug_error("failed to _mm_sound_mgr_device_connected_callback() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret); + } + /******************************************************/ + /* ACTIVATE this device for routing if needed */ + /* do here */ + /******************************************************/ + + } + } else { + debug_error("failed to _mm_sound_mgr_device_connected_dev_list_find_item() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret); + } + } + break; + + case DEVICE_UPDATE_STATUS_DISCONNECTED: + { + int ret = MM_ERROR_NONE; + /* find the device handle by device_type and(or) id */ + mm_sound_device_t *device_h = NULL; + _mm_sound_mgr_device_connected_dev_list_dump(); + ret = _mm_sound_mgr_device_connected_dev_list_find_item (&device_h, device_type, id); + if(!ret && device_h) { + debug_log("found device_h[0x%x] for this type[%d]/id[%d]\n", device_h, device_type, id); + + /********************************************************/ + /* DEACTIVATE this device for routing if needed */ + /* do here */ + /********************************************************/ + + /* update device information */ + /* 1. state */ + device_state_e prev_state = DEVICE_STATE_DEACTIVATED; + GET_DEVICE_INFO_STATE(device_h, prev_state); + SET_DEVICE_INFO_STATE(device_h, DEVICE_STATE_DEACTIVATED); + + /* trigger callback functions */ + if (prev_state == DEVICE_STATE_ACTIVATED) { + ret = _mm_sound_mgr_device_info_changed_callback(device_h, DEVICE_CHANGED_INFO_STATE); + if (ret) { + debug_error("failed to _mm_sound_mgr_device_info_changed_callback(DEVICE_CHANGED_INFO_STATE), device_h[0x%x], ret[0x%x]\n", device_h, ret); + } + } + /* copy this device structure */ + mm_sound_device_t copied_device_h; + memcpy ((void*)&copied_device_h, (void*)device_h, sizeof(mm_sound_device_t)); + + /* remove this device from the list */ + ret = _mm_sound_mgr_device_connected_dev_list_remove_item (device_h); + if (ret) { + debug_error("failed to _mm_sound_mgr_device_connected_dev_list_remove_item(), device_h[0x%x], ret[0x%x]\n", device_h, ret); + } + + ret = _mm_sound_mgr_device_connected_callback(&copied_device_h, false); + if (ret) { + debug_error("failed to _mm_sound_mgr_device_connected_callback() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, copied_device_h, ret); + } + + } else { + debug_error("failed to _mm_sound_mgr_device_connected_dev_list_find_item() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret); + } + } + break; + + case DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE: + { + int ret = MM_ERROR_NONE; + /* find the device handle by device_type and(or) id */ + mm_sound_device_t *device_h = NULL; + ret = _mm_sound_mgr_device_connected_dev_list_find_item (&device_h, device_type, id); + if(!ret && device_h) { + debug_log("we are going to change STATE[to %d] of this item[0x%x]\n", state, device_h); + + device_state_e prev_state = DEVICE_STATE_DEACTIVATED; + GET_DEVICE_INFO_STATE(device_h, prev_state); + if (prev_state == state) { + debug_log("previous state is same as new one, no need to set\n"); + } else { + SET_DEVICE_INFO_STATE(device_h, state); + _mm_sound_mgr_device_connected_dev_list_dump(); + ret = _mm_sound_mgr_device_info_changed_callback(device_h, DEVICE_CHANGED_INFO_STATE); + if (ret) { + debug_error("failed to _mm_sound_mgr_device_info_changed_callback(DEVICE_CHANGED_INFO_STATE), device_h[0x%x], ret[0x%x]\n", device_h, ret); + } + } + + } else { + debug_error("failed to _mm_sound_mgr_device_connected_dev_list_find_item() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret); + } + } + break; + + case DEVICE_UPDATE_STATUS_CHANGED_INFO_IO_DIRECTION: + { + int ret = MM_ERROR_NONE; + /* find the device handle by device_type and(or) id */ + mm_sound_device_t *device_h = NULL; + ret = _mm_sound_mgr_device_connected_dev_list_find_item (&device_h, device_type, id); + if(!ret && device_h) { + debug_log("we are going to change IO DIRECTION[to %d] of this item[0x%x]\n", io_direction, device_h); + + device_io_direction_e prev_io_direction = DEVICE_IO_DIRECTION_IN; + GET_DEVICE_INFO_IO_DIRECTION(device_h, prev_io_direction); + if (prev_io_direction == io_direction) { + debug_log("previous io_direction is same as new one, no need to set\n"); + } else { + SET_DEVICE_INFO_IO_DIRECTION(device_h, io_direction); + _mm_sound_mgr_device_connected_dev_list_dump(); + ret = _mm_sound_mgr_device_info_changed_callback(device_h, DEVICE_CHANGED_INFO_IO_DIRECTION); + if (ret) { + debug_error("failed to _mm_sound_mgr_device_info_changed_callback(DEVICE_CHANGED_INFO_DIRECTION), device_h[0x%x], ret[0x%x]\n", device_h, ret); + } + } + + } else { + debug_error("failed to _mm_sound_mgr_device_connected_dev_list_find_item() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret); + } + } + break; + } + + return MM_ERROR_NONE; +} + +int MMSoundMgrDeviceUpdateStatusWithoutNotification (device_update_status_e update_status, device_type_e device_type, device_io_direction_e io_direction, int id, const char* name, device_state_e state, int *alloc_id) +{ + debug_warning ("[Update Device Status] update_status[%d], device type[%11s], io_direction[%4s], id[%d], name[%s], state[%11s], alloc_id[0x%x]\n", + update_status, device_type_str[device_type], device_io_direction_str[io_direction], id, name, device_state_str[state], alloc_id); + switch (update_status) { + case DEVICE_UPDATE_STATUS_CONNECTED: + { + int ret = MM_ERROR_NONE; + /* find the device handle by device_type and(or) id */ + mm_sound_device_t *device_h = NULL; + ret = _mm_sound_mgr_device_connected_dev_list_find_item (&device_h, device_type, id); + if(ret == MM_ERROR_SOUND_NO_DATA && !device_h) { + debug_log("we are going to add new item for this type[%d]/id[%d]\n", device_type, id); + /* add new entry for the type */ + ret = _mm_sound_mgr_device_connected_dev_list_add_item (&device_h); + if (ret || !device_h) { + debug_error("could not add a new item for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret); + } else { + debug_error("update info for this device_h[0x%x]\n", device_h); + /* update device information */ + /* 1. type */ + SET_DEVICE_INFO_TYPE(device_h, device_type); + /* 2. io direction */ + SET_DEVICE_INFO_IO_DIRECTION(device_h, io_direction); + /* 3. name */ + SET_DEVICE_INFO_NAME(device_h, name); + /* 4. state */ + SET_DEVICE_INFO_STATE(device_h, DEVICE_STATE_DEACTIVATED); + /* 4. id */ + SET_DEVICE_INFO_ID_AUTO(device_h); + GET_DEVICE_INFO_ID(device_h, alloc_id); + + _mm_sound_mgr_device_connected_dev_list_dump(); + + /******************************************************/ + /* ACTIVATE this device for routing if needed */ + /* do here */ + /******************************************************/ + + } + } else { + debug_error("failed to _mm_sound_mgr_device_connected_dev_list_find_item() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret); + } + } + break; + + case DEVICE_UPDATE_STATUS_DISCONNECTED: + { + int ret = MM_ERROR_NONE; + /* find the device handle by device_type and(or) id */ + mm_sound_device_t *device_h = NULL; + _mm_sound_mgr_device_connected_dev_list_dump(); + ret = _mm_sound_mgr_device_connected_dev_list_find_item (&device_h, device_type, id); + if(!ret && device_h) { + debug_log("found device_h[0x%x] for this type[%d]/id[%d]\n", device_h, device_type, id); + + /********************************************************/ + /* DEACTIVATE this device for routing if needed */ + /* do here */ + /********************************************************/ + + /* update device information */ + /* 1. state */ + device_state_e prev_state = DEVICE_STATE_DEACTIVATED; + GET_DEVICE_INFO_STATE(device_h, prev_state); + SET_DEVICE_INFO_STATE(device_h, DEVICE_STATE_DEACTIVATED); + + /* remove this device from the list */ + ret = _mm_sound_mgr_device_connected_dev_list_remove_item (device_h); + if (ret) { + debug_error("failed to _mm_sound_mgr_device_connected_dev_list_remove_item(), device_h[0x%x], ret[0x%x]\n", device_h, ret); + } + + } else { + debug_error("failed to _mm_sound_mgr_device_connected_dev_list_find_item() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret); + } + } + break; + + case DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE: + { + int ret = MM_ERROR_NONE; + /* find the device handle by device_type and(or) id */ + mm_sound_device_t *device_h = NULL; + ret = _mm_sound_mgr_device_connected_dev_list_find_item (&device_h, device_type, id); + if(!ret && device_h) { + debug_log("we are going to change STATE[to %d] of this item[0x%x]\n", state, device_h); + + device_state_e prev_state = DEVICE_STATE_DEACTIVATED; + GET_DEVICE_INFO_STATE(device_h, prev_state); + if (prev_state == state) { + debug_warning("previous state is same as new one, no need to set\n"); + } else { + SET_DEVICE_INFO_STATE(device_h, state); + _mm_sound_mgr_device_connected_dev_list_dump(); + } + + } else { + debug_error("failed to _mm_sound_mgr_device_connected_dev_list_find_item() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret); + } + } + break; + + case DEVICE_UPDATE_STATUS_CHANGED_INFO_IO_DIRECTION: + { + int ret = MM_ERROR_NONE; + /* find the device handle by device_type and(or) id */ + mm_sound_device_t *device_h = NULL; + ret = _mm_sound_mgr_device_connected_dev_list_find_item (&device_h, device_type, id); + if(!ret && device_h) { + debug_log("we are going to change IO DIRECTION[to %d] of this item[0x%x]\n", io_direction, device_h); + + device_io_direction_e prev_io_direction = DEVICE_IO_DIRECTION_IN; + GET_DEVICE_INFO_IO_DIRECTION(device_h, prev_io_direction); + if (prev_io_direction == io_direction) { + debug_warning("previous io_direction is same as new one, no need to set\n"); + } else { + SET_DEVICE_INFO_IO_DIRECTION(device_h, io_direction); + _mm_sound_mgr_device_connected_dev_list_dump(); + } + + } else { + debug_error("failed to _mm_sound_mgr_device_connected_dev_list_find_item() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret); + } + } + break; + } + + return MM_ERROR_NONE; +} diff --git a/server/mm_sound_mgr_device_dock.c b/server/mm_sound_mgr_device_dock.c new file mode 100644 index 0000000..61dbba7 --- /dev/null +++ b/server/mm_sound_mgr_device_dock.c @@ -0,0 +1,215 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * 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 +#include + +#include + +#include "include/mm_sound_mgr_common.h" +#include "../include/mm_sound_common.h" + +#include +#include + +#include "include/mm_sound_mgr_device.h" +#include "include/mm_sound_mgr_device_dock.h" +#include "include/mm_sound_mgr_session.h" + +/******************************* Dock Code **********************************/ + +#include +#include +#include +#include + +#include "mm_ipc.h" +#include "mm_sound_common.h" +#include "mm_sound.h" + +#include +#include + +#define SOUND_DOCK_ON "/usr/share/sounds/sound-server/dock.ogg" +#define SOUND_DOCK_OFF "/usr/share/sounds/sound-server/undock.ogg" +#define SOUND_DOCK_ON_DELAY 1000000 +#define SOUND_DOCK_OFF_DELAY 10000 + +#define DOCK_OFF false +#define DOCK_ON true + +#define DOCK_NO_RESTORE false +#define DOCK_RESTORE true + +int g_saved_dock_status; + +static void __dock_sound_finished_cb(void *data , int id) +{ + bool* is_finish = (bool*)data; + debug_log ("dock sound play finished!!!\n"); + + if (is_finish) { + *is_finish = true; + } +} + +static void __play_dock_sound_sync(bool is_on, bool need_restore) +{ + int handle; + bool is_play_finished = false; + bool dock_sound = false; + + if (g_saved_dock_status == -1) { + debug_log ("skip dock sound because status is not valid [%d]\n", g_saved_dock_status); + return; + } + + /* check dock sound */ + vconf_get_bool(VCONFKEY_SETAPPL_ACCESSORY_DOCK_SOUND, &dock_sound); + if (dock_sound == false) { + debug_log ("dock sound is disabled in setting app"); + return; + } + + debug_log ("start to play dock sound : is_on=[%d], need_restore=[%d]\n", is_on, need_restore); + + if (need_restore) { + mm_sound_play_loud_solo_sound((is_on? SOUND_DOCK_ON:SOUND_DOCK_OFF), VOLUME_TYPE_FIXED, __dock_sound_finished_cb, &is_play_finished, &handle); + debug_log ("waiting for dock sound finish\n"); + while (!is_play_finished) { + usleep (SOUND_DOCK_OFF_DELAY); + } + } else { + mm_sound_play_loud_solo_sound_no_restore((is_on? SOUND_DOCK_ON:SOUND_DOCK_OFF), VOLUME_TYPE_FIXED, __dock_sound_finished_cb, &is_play_finished, &handle); + debug_log ("waiting for dock sound finish\n"); + usleep (SOUND_DOCK_ON_DELAY); + } + + debug_log ("dock sound finished!!!\n"); +} + +/* DOCK status value from system server */ +static void _dock_status_changed_cb(keynode_t* node, void* data) +{ + int ret = 0; + int dock_status = 0; + + if (node == NULL) { + debug_error ("node is null...\n"); + return; + } + + debug_msg ("Handling [%s] Starts\n", vconf_keynode_get_name(node)); + + /* Get actual vconf value */ + vconf_get_int(VCONFKEY_SYSMAN_CRADLE_STATUS, &dock_status); + debug_msg ("DOCK : [%s]=[%d]\n", VCONFKEY_SYSMAN_CRADLE_STATUS, dock_status); + + if (g_saved_dock_status == dock_status) { + debug_warning ("No changes in DOCK STATUS, do nothing....\n"); + return; + } + + /* Set available/non-available based on current dock status value */ + switch (dock_status) + { + case DOCK_DESKDOCK: + case DOCK_CARDOCK: + /* Play ON sound, no path restore due to dock routing */ + __play_dock_sound_sync (DOCK_ON, DOCK_NO_RESTORE); + + /* Update device available status (available) */ + ret = MMSoundMgrSessionSetDeviceAvailable (DEVICE_DOCK, DOCK_ON, 0, NULL); + if (ret != MM_ERROR_NONE) { + debug_error ("MMSoundMgrSessionSetDeviceAvailable() failed...ret=%x\n", ret); + } + break; + + case DOCK_AUDIODOCK: + case DOCK_SMARTDOCK: + /* Play ON sound, no path restore due to USB Audio routing */ + __play_dock_sound_sync (DOCK_ON, DOCK_NO_RESTORE); + break; + + case DOCK_NONE: + /* Update device available status (non-available) */ + ret = MMSoundMgrSessionSetDeviceAvailable (DEVICE_DOCK, DOCK_OFF, 0, NULL); + if (ret != MM_ERROR_NONE) { + debug_error ("MMSoundMgrSessionSetDeviceAvailable() failed...ret=%x\n", ret); + } + + /* Play OFF sound */ + __play_dock_sound_sync (DOCK_OFF, DOCK_RESTORE); + + break; + + default: + debug_warning ("Unexpected Dock Status = [%d]\n", dock_status); + break; + } + + g_saved_dock_status = dock_status; + debug_msg ("Handling [%s] Ends normally\n", vconf_keynode_get_name(node)); +} + +static int _register_dock_status () +{ + /* set callback for vconf key change */ + int ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_CRADLE_STATUS, _dock_status_changed_cb, NULL); + debug_msg ("vconf [%s] set ret = [%d]\n", VCONFKEY_SYSMAN_CRADLE_STATUS, ret); + return ret; +} + +int MMSoundMgrDockInit(void) +{ + int ret = 0; + debug_enter("\n"); + + g_saved_dock_status = -1; + + ret = vconf_get_int(VCONFKEY_SYSMAN_CRADLE_STATUS, &g_saved_dock_status); + debug_warning ("Initial status is [%d], ret=[%d]\n", g_saved_dock_status, ret); + + if (_register_dock_status () != 0) { + debug_error ("Registering dock status failed\n"); + return MM_ERROR_SOUND_INTERNAL; + } + + debug_leave("\n"); + return MM_ERROR_NONE; +} + +int MMSoundMgrDockFini(void) +{ + debug_enter("\n"); + + debug_leave("\n"); + return MM_ERROR_NONE; +} + diff --git a/server/mm_sound_mgr_device_hdmi.c b/server/mm_sound_mgr_device_hdmi.c new file mode 100755 index 0000000..54ad42e --- /dev/null +++ b/server/mm_sound_mgr_device_hdmi.c @@ -0,0 +1,213 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * 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 +#include +#include +#include + +#include + +#include "include/mm_sound_mgr_common.h" +#include "../include/mm_sound_common.h" + +#include +#include + +#include "include/mm_sound_mgr_device.h" +#include "include/mm_sound_mgr_device_hdmi.h" +#include "include/mm_sound_mgr_session.h" + +/******************************* HDMI Code **********************************/ + +#include "mm_sound.h" + +#define SUPPORT_DBUS_HDMI_AUDIO +#ifdef SUPPORT_DBUS_HDMI_AUDIO + +#include +#define DEVICED_SYSNOTI_PATH "/Org/Tizen/System/DeviceD/SysNoti" +#define DEVICED_SYSNOTI_INTERFACE "org.tizen.system.deviced.SysNoti" +#define HDMI_AUDIO_CHANGED_SIGNAL "ChangedHDMIAudio" + +#define VCONFKEY_SOUND_HDMI_SUPPORT "memory/private/sound/hdmisupport" +enum { + MM_SOUND_HDMI_AUDIO_UNPLUGGED = -1, + MM_SOUND_HDMI_AUDIO_NOT_AVAILABLE = 0, + MM_SOUND_HDMI_AUDIO_AVAILABLE = 1 +}; + +typedef enum { + MM_SOUND_HDMI_SUPPORT_NOTHING = -1, + MM_SOUND_HDMI_SUPPORT_ONLY_STEREO = 0, + MM_SOUND_HDMI_SUPPORT_ONLY_SURROUND = 1, + MM_SOUND_HDMI_SUPPORT_STEREO_AND_SURROUND =2, +} hdmi_support_type_t; + +GDBusConnection *conn_hdmiaudio, *conn_popup; +guint sig_id_hdmiaudio, sig_id_popup; +int hdmi_available = false; + +int _parse_hdmi_support_info(int hdmi_support, hdmi_support_type_t* support){ + int channels = 0; + bool support_stereo = false, support_surround = false; + + channels = hdmi_support & 0x000000FF; + + if(channels == 0xFF){ + channels = 0; + return 0; + } + + if ((channels & 0x20) > 0) + support_surround = true; + if ((channels & 0x02) > 0) + support_stereo = true; + + if (support_stereo && support_surround) + *support = MM_SOUND_HDMI_SUPPORT_STEREO_AND_SURROUND; + else if (!support_stereo && support_surround) + *support = MM_SOUND_HDMI_SUPPORT_ONLY_SURROUND; + else if (support_stereo && !support_surround) + *support = MM_SOUND_HDMI_SUPPORT_ONLY_STEREO; + else + *support = MM_SOUND_HDMI_SUPPORT_NOTHING; + + return 1; +} + + +static void hdmi_audio_changed(GDBusConnection *conn, + const gchar *sender_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *signal_name, + GVariant *parameters, + gpointer user_data) +{ + int value=0; + hdmi_support_type_t hdmi_support_type = MM_SOUND_HDMI_SUPPORT_NOTHING; + const GVariantType* value_type; + + debug_msg ("sender : %s, object : %s, interface : %s, signal : %s", + sender_name, object_path, interface_name, signal_name); + if(g_variant_is_of_type(parameters, G_VARIANT_TYPE("(i)"))) + { + g_variant_get(parameters, "(i)",&value); + debug_msg("singal[%s] = %X\n", HDMI_AUDIO_CHANGED_SIGNAL, value); + vconf_set_int(VCONFKEY_SOUND_HDMI_SUPPORT, value); + + if(value >= MM_SOUND_HDMI_AUDIO_AVAILABLE) { + hdmi_available = true; + _parse_hdmi_support_info(value, &hdmi_support_type); + debug_msg("HDMI support type : %d\n", hdmi_support_type); + MMSoundMgrSessionSetDeviceAvailable (DEVICE_HDMI, hdmi_available, 0, NULL); + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_HDMI, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, 0, NULL); + } + + if(value == MM_SOUND_HDMI_AUDIO_NOT_AVAILABLE || value == MM_SOUND_HDMI_AUDIO_UNPLUGGED){ + hdmi_available = false; + MMSoundMgrSessionSetDeviceAvailable (DEVICE_HDMI, hdmi_available, 0, NULL); + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_DISCONNECTED, DEVICE_TYPE_HDMI, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, 0, NULL); + } + } + else + { + value_type = g_variant_get_type(parameters); + debug_warning("signal type is %s", value_type); + } + +} + +void _deinit_hdmi_audio_dbus(void) +{ + debug_fenter (); + g_dbus_connection_signal_unsubscribe(conn_hdmiaudio, sig_id_hdmiaudio); + g_object_unref(conn_hdmiaudio); + debug_fleave (); +} + +int _init_hdmi_audio_dbus(void) +{ + GError *err = NULL; + debug_fenter (); + + g_type_init(); + + conn_hdmiaudio = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err); + if (!conn_hdmiaudio && err) { + debug_error ("g_bus_get_sync() error (%s) ", err->message); + g_error_free (err); + goto error; + } + + sig_id_hdmiaudio = g_dbus_connection_signal_subscribe(conn_hdmiaudio, + NULL, DEVICED_SYSNOTI_INTERFACE, HDMI_AUDIO_CHANGED_SIGNAL, DEVICED_SYSNOTI_PATH, NULL, 0, + hdmi_audio_changed, NULL, NULL); + if (sig_id_hdmiaudio == 0) { + debug_error ("g_dbus_connection_signal_subscribe() error (%d)", sig_id_hdmiaudio); + goto sig_error; + } + + debug_fleave (); + return 0; + +sig_error: + g_dbus_connection_signal_unsubscribe(conn_hdmiaudio, sig_id_hdmiaudio); + g_object_unref(conn_hdmiaudio); + +error: + return -1; + +} +#endif + +int MMSoundMgrHdmiInit(void) +{ + debug_enter("\n"); +#ifdef SUPPORT_DBUS_HDMI_AUDIO + if (_init_hdmi_audio_dbus() != 0) { + debug_error ("Registering hdmi audio signal handler failed\n"); + return MM_ERROR_SOUND_INTERNAL; + } +#endif + debug_leave("\n"); + return MM_ERROR_NONE; +} + +int MMSoundMgrHdmiFini(void) +{ + debug_enter("\n"); +#ifdef SUPPORT_DBUS_HDMI_AUDIO + _deinit_hdmi_audio_dbus(); +#endif + debug_leave("\n"); + return MM_ERROR_NONE; +} + diff --git a/server/mm_sound_mgr_device_headset.c b/server/mm_sound_mgr_device_headset.c new file mode 100644 index 0000000..8cb7121 --- /dev/null +++ b/server/mm_sound_mgr_device_headset.c @@ -0,0 +1,107 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * 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 +#include + +#include + +#include "include/mm_sound_mgr_common.h" +#include "include/mm_sound_thread_pool.h" +#include "../include/mm_sound_common.h" + +#include +#include + +#include "include/mm_sound_mgr_device.h" +#include "include/mm_sound_mgr_device_headset.h" +#include "include/mm_sound_mgr_session.h" + +/******************************* Headset Code **********************************/ + +#include +#include +#include +#include +#include + +#include "mm_ipc.h" +#include "mm_sound_common.h" +#include "mm_sound.h" + +#include +#include + +/* earjack status value */ +static void _earjack_status_changed_cb(keynode_t* node, void* data) +{ + int earjack_status = 0; + device_io_direction_e io_direction = DEVICE_IO_DIRECTION_OUT; + char *name = NULL; + + /* Get actual vconf value */ + vconf_get_int(VCONFKEY_SYSMAN_EARJACK, &earjack_status); + debug_msg ("[%s] changed callback called, status=[%d]\n", vconf_keynode_get_name(node), earjack_status); + + if (earjack_status == DEVICE_EARJACK_TYPE_SPK_WITH_MIC) { + io_direction = DEVICE_IO_DIRECTION_BOTH; + name = DEVICE_NAME_AUDIOJACK_4P; + } else { + io_direction = DEVICE_IO_DIRECTION_OUT; + name = DEVICE_NAME_AUDIOJACK_3P; + } + MMSoundMgrDeviceUpdateStatus (earjack_status ? DEVICE_UPDATE_STATUS_CONNECTED : DEVICE_UPDATE_STATUS_DISCONNECTED, DEVICE_TYPE_AUDIOJACK, io_direction, DEVICE_ID_AUTO, name, 0, NULL); + MMSoundMgrSessionSetDeviceAvailable (DEVICE_WIRED, earjack_status, earjack_status, NULL); +} + +static int _register_earjack_status(void) +{ + /* set callback for vconf key change */ + int ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_EARJACK, _earjack_status_changed_cb, NULL); + debug_msg ("vconf [%s] set ret = [%d]\n", VCONFKEY_SYSMAN_EARJACK, ret); + return ret; +} + +int MMSoundMgrHeadsetInit(void) +{ + debug_enter("\n"); + _register_earjack_status(); + debug_leave("\n"); + + return MM_ERROR_NONE; +} + +int MMSoundMgrHeadsetFini(void) +{ + debug_enter("\n"); + debug_leave("\n"); + + return MM_ERROR_NONE; +} + diff --git a/server/mm_sound_mgr_device_wfd.c b/server/mm_sound_mgr_device_wfd.c new file mode 100644 index 0000000..c36aa4f --- /dev/null +++ b/server/mm_sound_mgr_device_wfd.c @@ -0,0 +1,94 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * 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 +#include + +#include + +#include "include/mm_sound_mgr_common.h" +#include "../include/mm_sound_common.h" + +#include +#include + +#include "include/mm_sound_mgr_device.h" +#include "include/mm_sound_mgr_device_wfd.h" +#include "include/mm_sound_mgr_session.h" + +/******************************* WFD Code **********************************/ + +#include "mm_sound.h" + +#include +#include + + +/* WFD status value */ +static void _miracast_wfd_status_changed_cb(keynode_t* node, void* data) +{ + int miracast_wfd_status = 0; + + /* Get actual vconf value */ + vconf_get_bool(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, &miracast_wfd_status); + debug_msg ("[%s] changed callback called, status=[%d]\n", vconf_keynode_get_name(node), miracast_wfd_status); + + MMSoundMgrSessionSetDeviceAvailable (DEVICE_MIRRORING, miracast_wfd_status, 0, NULL); + MMSoundMgrDeviceUpdateStatus (miracast_wfd_status ? DEVICE_UPDATE_STATUS_CONNECTED : DEVICE_UPDATE_STATUS_DISCONNECTED, DEVICE_TYPE_MIRRORING, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, 0, NULL); +} + +static int _register_wfd_status(void) +{ + /* set callback for vconf key change */ + int ret = vconf_notify_key_changed(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, _miracast_wfd_status_changed_cb, NULL); + debug_msg ("vconf [%s] set ret = [%d]\n", VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, ret); + return ret; +} + +int MMSoundMgrWfdInit(void) +{ + debug_enter("\n"); + + if (_register_wfd_status() != 0) { + debug_error ("Registering WFD status failed\n"); + return MM_ERROR_SOUND_INTERNAL; + } + + debug_leave("\n"); + return MM_ERROR_NONE; +} + +int MMSoundMgrWfdFini(void) +{ + debug_enter("\n"); + + debug_leave("\n"); + return MM_ERROR_NONE; +} + diff --git a/server/mm_sound_mgr_dock.c b/server/mm_sound_mgr_dock.c deleted file mode 100644 index 275e04a..0000000 --- a/server/mm_sound_mgr_dock.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * libmm-sound - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Seungbae Shin - * - * 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 -#include - -#include - -#include "include/mm_sound_mgr_common.h" -#include "../include/mm_sound_common.h" - -#include -#include - -#include "include/mm_sound_mgr_dock.h" -#include "include/mm_sound_mgr_session.h" - -/******************************* Dock Code **********************************/ - -#include -#include -#include -#include - -#include "mm_ipc.h" -#include "mm_sound_common.h" -#include "mm_sound.h" - -#include -#include - -static void dock_changed_cb(keynode_t* node, void* data) -{ - int dock_available = 0; - - /* Get actual vconf value */ - vconf_get_int(VCONFKEY_SYSMAN_CRADLE_STATUS, &dock_available); - - debug_msg ("[%s] changed callback called, key value is [%d]\n", vconf_keynode_get_name(node), dock_available); - - /* Set device available based on vconf key value */ - MMSoundMgrSessionSetDeviceAvailable (DEVICE_DOCK, dock_available, 0, NULL); -} - -int _register_dock_status () -{ - /* set callback for vconf key change */ - int ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_CRADLE_STATUS, dock_changed_cb, NULL); - debug_msg ("vconf [%s] set ret = %d\n", VCONFKEY_SYSMAN_CRADLE_STATUS, ret); - return ret; -} - - -int MMSoundMgrDockInit(void) -{ - debug_enter("\n"); - - _register_dock_status (); - - debug_leave("\n"); - return MM_ERROR_NONE; -} - -int MMSoundMgrDockFini(void) -{ - debug_enter("\n"); - - debug_leave("\n"); - return MM_ERROR_NONE; -} - diff --git a/server/mm_sound_mgr_headset.c b/server/mm_sound_mgr_headset.c deleted file mode 100644 index 80a8ddf..0000000 --- a/server/mm_sound_mgr_headset.c +++ /dev/null @@ -1,245 +0,0 @@ -/* - * libmm-sound - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Seungbae Shin - * - * 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 -#include - -#include - -#include "include/mm_sound_mgr_common.h" -#include "../include/mm_sound_common.h" - -#include -#include - -//#include -#include - -#include "include/mm_sound_mgr_headset.h" -//#include "include/mm_sound_mgr_asm.h" -#include "include/mm_sound_mgr_session.h" - -/******************************* Headset Code **********************************/ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "mm_ipc.h" -#include "mm_sound_common.h" -#include "mm_sound.h" - -#include - -#define EARJACK_EJECTED 0 -#define NO_FORCE_RESET 0 - -int __headset_main_run (void* param) -{ - int current_type = 0; - int new_type = 0; - int waitfd = 0; - int err = AVSYS_STATE_SUCCESS; - int eject_event_count = 0; - int need_mute = 0; - int ret = 0; - - /* re-check current path */ - avsys_audio_path_ex_reset(NO_FORCE_RESET); - - if(AVSYS_FAIL(avsys_audio_earjack_manager_init(¤t_type, &waitfd))) - return MM_ERROR_SOUND_DEVICE_NOT_OPENED; - - while(1) - { - //waiting earjack event - err = avsys_audio_earjack_manager_wait(waitfd, ¤t_type, &new_type, &need_mute); - debug_log ("wait result = %x, current_type= %d, new_type = %d, need_mute = %d\n", err, current_type, new_type, need_mute); - if(err & AVSYS_STATE_ERROR) { -#if !defined(_MMFW_I386_ALL_SIMULATOR) - if(err != AVSYS_STATE_ERR_NULL_POINTER) { - if(AVSYS_FAIL(avsys_audio_earjack_manager_unlock())) { - debug_error("avsys_audio_earjack_manager_unlock() failed in %s\n",__func__); - err = MM_ERROR_SOUND_INTERNAL; - goto fail; - } - } -#endif - break; - } else if((err & AVSYS_STATE_WARING)) { - if(err != AVSYS_STATE_WAR_INVALID_VALUE) { - if(AVSYS_FAIL(avsys_audio_earjack_manager_unlock())) { - debug_error("avsys_audio_earjack_manager_unlock() failed in %s\n",__func__); - err = MM_ERROR_SOUND_INTERNAL; - goto fail; - } - } - continue; /* Ignore current changes and do wait again */ - } - debug_warning("Current type is %d, New type is %d\n", current_type, new_type); - - if(current_type == new_type) { - if(AVSYS_FAIL(avsys_audio_earjack_manager_unlock())) { - debug_error("avsys_audio_earjack_manager_unlock() failed in %s\n",__func__); - err = MM_ERROR_SOUND_INTERNAL; - goto fail; - } - continue; /* Ignore current changes and do wait again */ - } else { - current_type = new_type; - } - debug_warning("Current type is %d\n", current_type); - - /* mute if needed, unmute will be done end of this loop */ - if(need_mute) { - if(AVSYS_FAIL(avsys_audio_set_global_mute(AVSYS_AUDIO_MUTE_NOLOCK))) - debug_error("Set mute failed\n"); - } - - //current_type '0' means earjack ejected - if(current_type == EARJACK_EJECTED) { - eject_event_count++; - if(eject_event_count == 1) { - debug_msg ("earjack [EJECTED]\n"); - - /* ToDo: Device Update */ - MMSoundMgrSessionSetDeviceAvailable (DEVICE_WIRED, NOT_AVAILABLE, 0, NULL); - - } - } else if(current_type != EARJACK_EJECTED) { /* INSERT */ - debug_msg ("earjack is [INSERTED]\n"); - eject_event_count = 0; - - /* ToDo: Device Update */ - ret = MMSoundMgrSessionSetDeviceAvailable (DEVICE_WIRED, AVAILABLE, current_type, NULL); - if (ret != MM_ERROR_NONE) { - /* TODO : Error Handling */ - debug_error ("MMSoundMgrSessionSetDeviceAvailable failed....ret = [%x]\n", ret); - } - } - - //process change - err = avsys_audio_earjack_manager_process(current_type); - if(err & AVSYS_STATE_ERROR) { - debug_error("Earjack Managing Fatal Error 0x%x\n", err); - if(need_mute) { - if(AVSYS_FAIL(avsys_audio_set_global_mute(AVSYS_AUDIO_UNMUTE_NOLOCK))) { - debug_error("Set unmute failed\n"); - } - } -#if !defined(_MMFW_I386_ALL_SIMULATOR) - if(AVSYS_FAIL(avsys_audio_earjack_manager_unlock())) { - debug_error("avsys_audio_earjack_manager_unlock() failed in %s\n",__func__); - err = MM_ERROR_SOUND_INTERNAL; - goto fail; - } -#endif - break; - } else if(err & AVSYS_STATE_WARING) { - debug_error("Earjack Managing Warning 0x%x\n", err); - if(need_mute) { - if(AVSYS_FAIL(avsys_audio_set_global_mute(AVSYS_AUDIO_UNMUTE_NOLOCK))) { - debug_error("Set unmute failed\n"); - } - } - - if(AVSYS_FAIL(avsys_audio_earjack_manager_unlock())) { - debug_error("avsys_audio_earjack_manager_unlock() failed in %s\n",__func__); - err = MM_ERROR_SOUND_INTERNAL; - goto fail; - } - continue; - } - - /* Unmute if muted */ - if(need_mute) { - if(AVSYS_FAIL(avsys_audio_set_global_mute(AVSYS_AUDIO_UNMUTE_NOLOCK))) { - debug_error("Set unmute failed\n"); - } - } - - if(AVSYS_FAIL(avsys_audio_earjack_manager_unlock())) { - debug_error("avsys_audio_earjack_manager_unlock() failed in %s\n",__func__); - err = MM_ERROR_SOUND_INTERNAL; - goto fail; - } - } /* while (1) */ - - if(AVSYS_FAIL(avsys_audio_earjack_manager_deinit(waitfd))) { - err = MM_ERROR_SOUND_INTERNAL; - goto fail; - } - - return MM_ERROR_NONE; - -unlock_and_fail: - debug_error("earjack plugin unlock_and_fail\n"); - -fail: - debug_error("earjack plugin fail\n"); - debug_error("earphone plugin exit with 0x%x\n", err); - - return err; -} - -int MMSoundMgrHeadsetGetType (int *type) -{ - if (type) { - *type = avsys_audio_earjack_manager_get_type(); - } - return MM_ERROR_NONE; -} - - -int MMSoundMgrHeadsetInit(void) -{ - debug_enter("\n"); - - MMSoundThreadPoolRun(NULL, __headset_main_run); - - debug_leave("\n"); - return MM_ERROR_NONE; -} - -int MMSoundMgrHeadsetFini(void) -{ - debug_enter("\n"); - - debug_leave("\n"); - return MM_ERROR_NONE; -} - diff --git a/server/mm_sound_mgr_ipc.c b/server/mm_sound_mgr_ipc.c index 15ebccd..70876fb 100644 --- a/server/mm_sound_mgr_ipc.c +++ b/server/mm_sound_mgr_ipc.c @@ -30,10 +30,11 @@ #include #include - +#include #include "include/mm_sound_mgr_common.h" #include "include/mm_sound_mgr_ipc.h" +#include "../include/mm_sound_common.h" #include "../include/mm_sound_msg.h" #include "include/mm_sound_thread_pool.h" #include "include/mm_sound_mgr_codec.h" @@ -43,21 +44,30 @@ #include +#include + #define SHM_OPEN #ifdef PULSE_CLIENT #include "include/mm_sound_mgr_pulse.h" #endif +/* workaround for AF volume gain tuning */ +#define MM_SOUND_AF_FILE_PREFIX "/opt/ug/res/sounds/ug-camera-efl/sounds/af_" +#define PROC_DBUS_OBJECT "/Org/Tizen/ResourceD/Process" +#define PROC_DBUS_INTERFACE "org.tizen.resourced.process" +#define PROC_DBUS_METHOD "ProcExclude" + /* message id */ int g_rcvid; int g_sndid; int g_cbid; +static pthread_mutex_t g_msg_snd_cb_mutex = PTHREAD_MUTEX_INITIALIZER; /* Msg processing */ -static void _MMSoundMgrRun(mm_ipc_msg_t *msg); -static int _MMSoundMgrStopCB(int msgid, void* msgcallback, void *msgdata); /* msg_type means instance for client */ +static void _MMSoundMgrRun(void *data); +static int _MMSoundMgrStopCB(int msgid, void* msgcallback, void *msgdata, int id); /* msg_type means instance for client */ static int _MMSoundMgrIpcPlayFile(int *codechandle, mm_ipc_msg_t *msg); /* codechandle means codec slotid */ static int _MMSoundMgrIpcPlayMemory(int *codechandle, mm_ipc_msg_t *msg); static int _MMSoundMgrIpcStop(mm_ipc_msg_t *msg); @@ -65,13 +75,24 @@ static int _MMSoundMgrIpcPlayDTMF(int *codechandle, mm_ipc_msg_t *msg); static int __mm_sound_mgr_ipc_is_route_available(mm_ipc_msg_t *msg, bool *is_available); static int __mm_sound_mgr_ipc_foreach_available_route_cb(mm_ipc_msg_t *msg); static int __mm_sound_mgr_ipc_set_active_route(mm_ipc_msg_t *msg); +static int __mm_sound_mgr_ipc_set_active_route_auto(void); static int __mm_sound_mgr_ipc_get_active_device(mm_ipc_msg_t *msg, mm_sound_device_in *device_in, mm_sound_device_out *device_out); static int __mm_sound_mgr_ipc_add_active_device_changed_cb(mm_ipc_msg_t *msg); static int __mm_sound_mgr_ipc_remove_active_device_changed_cb(mm_ipc_msg_t *msg); static int __mm_sound_mgr_ipc_add_available_device_changed_cb(mm_ipc_msg_t *msg); static int __mm_sound_mgr_ipc_remove_available_device_changed_cb(mm_ipc_msg_t *msg); +static int __mm_sound_mgr_ipc_add_volume_changed_cb(mm_ipc_msg_t *msg); +static int __mm_sound_mgr_ipc_remove_volume_changed_cb(mm_ipc_msg_t *msg); static int _MMIpcRecvMsg(int msgtype, mm_ipc_msg_t *msg); static int _MMIpcSndMsg(mm_ipc_msg_t *msg); +static int __mm_sound_mgr_ipc_set_sound_path_for_active_device(mm_ipc_msg_t *msg); +static int __mm_sound_mgr_ipc_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out); +static int __mm_sound_mgr_ipc_get_current_connected_device_list(mm_ipc_msg_t *msg, GList **device_list, int *total_num); +static int __mm_sound_mgr_ipc_add_device_connected_cb(mm_ipc_msg_t *msg); +static int __mm_sound_mgr_ipc_remove_device_connected_cb(mm_ipc_msg_t *msg); +static int __mm_sound_mgr_ipc_add_device_info_changed_cb(mm_ipc_msg_t *msg); +static int __mm_sound_mgr_ipc_remove_device_info_changed_cb(mm_ipc_msg_t *msg); + int MMSoundMgrIpcInit(void) { @@ -84,24 +105,24 @@ int MMSoundMgrIpcInit(void) g_cbid = msgget(ftok(KEY_BASE_PATH, CB_MSG), IPC_CREAT |0666); if ((g_rcvid == -1 || g_sndid == -1 || g_cbid == -1) != MM_ERROR_NONE) { - if(errno == EACCES) + if(errno == EACCES) { printf("Require ROOT permission.\n"); - else if(errno == EEXIST) + } else if(errno == EEXIST) { printf("System memory is empty.\n"); - else if(errno == ENOMEM) + } else if(errno == ENOMEM) { printf("System memory is empty.\n"); - else if(errno == ENOSPC) + } else if(errno == ENOSPC) { printf("Resource is empty.\n"); - + } debug_error("Fail to create msgid\n"); exit(1); return MM_ERROR_SOUND_INTERNAL; } - debug_msg("Created server msg queue id : [%d]\n", g_rcvid); - debug_msg("Created server msg queue id : [%d]\n", g_sndid); - debug_msg("Created server msg queue id : [%d]\n", g_cbid); - + debug_msg("Created server msg queue id : rcv[%d], snd[%d], cb[%d]\n", g_rcvid, g_sndid, g_cbid ); + + g_type_init(); + debug_fleave(); return MM_ERROR_NONE; } @@ -118,11 +139,7 @@ int MMSoundMgrIpcReady(void) mm_ipc_msg_t msg = {0,}; mm_ipc_msg_t resp = {0,}; - debug_fenter(); - - debug_msg("Created server msg queue id : [%d]\n", g_rcvid); - debug_msg("Created server msg queue id : [%d]\n", g_sndid); - debug_msg("Created server msg queue id : [%d]\n", g_cbid); + debug_msg("Created server msg queue id : rcv[%d], snd[%d], cb[%d]\n", g_rcvid, g_sndid, g_cbid ); /* Ready to recive message */ while(1) { @@ -132,17 +149,9 @@ int MMSoundMgrIpcReady(void) exit(1); } - debug_msg("msgtype : %d\n", msg.sound_msg.msgtype); - debug_msg("instance msgid : %d\n", msg.sound_msg.msgid); - debug_msg("handle : %d\n", msg.sound_msg.handle); - debug_msg("volume : %d\n", msg.sound_msg.volume); - debug_msg("keytone : %d\n", msg.sound_msg.keytone); - debug_msg("tone : %d\n", msg.sound_msg.tone); - debug_msg("callback : %p\n", msg.sound_msg.callback); - debug_msg("volume_table : %d\n", msg.sound_msg.volume_table); - debug_msg("priority : %d\n", msg.sound_msg.priority); - debug_msg("data : %p\n", msg.sound_msg.cbdata); - debug_msg("route : %d\n", msg.sound_msg.handle_route); + debug_msg("[ type:%d, id:%d, h:%d, vol:%d, vol_conf:%x keytone:%d, tone:%d, cb:%p, data:%p, prio:%d, route:%d ]\n", + msg.sound_msg.msgtype, msg.sound_msg.msgid, msg.sound_msg.handle, msg.sound_msg.volume, msg.sound_msg.volume_config, + msg.sound_msg.keytone, msg.sound_msg.tone, msg.sound_msg.callback, msg.sound_msg.cbdata, msg.sound_msg.priority, msg.sound_msg.handle_route); switch (msg.sound_msg.msgtype) { @@ -158,17 +167,27 @@ int MMSoundMgrIpcReady(void) case MM_SOUND_MSG_REQ_IS_ROUTE_AVAILABLE: case MM_SOUND_MSG_REQ_FOREACH_AVAILABLE_ROUTE_CB: case MM_SOUND_MSG_REQ_SET_ACTIVE_ROUTE: + case MM_SOUND_MSG_REQ_SET_ACTIVE_ROUTE_AUTO: case MM_SOUND_MSG_REQ_GET_ACTIVE_DEVICE: case MM_SOUND_MSG_REQ_ADD_ACTIVE_DEVICE_CB: case MM_SOUND_MSG_REQ_REMOVE_ACTIVE_DEVICE_CB: case MM_SOUND_MSG_REQ_ADD_AVAILABLE_ROUTE_CB: case MM_SOUND_MSG_REQ_REMOVE_AVAILABLE_ROUTE_CB: + case MM_SOUND_MSG_REQ_ADD_VOLUME_CB: + case MM_SOUND_MSG_REQ_REMOVE_VOLUME_CB: + case MM_SOUND_MSG_REQ_SET_PATH_FOR_ACTIVE_DEVICE: + case MM_SOUND_MSG_REQ_GET_AUDIO_PATH: + case MM_SOUND_MSG_REQ_GET_CONNECTED_DEVICE_LIST: + case MM_SOUND_MSG_REQ_ADD_DEVICE_CONNECTED_CB: + case MM_SOUND_MSG_REQ_REMOVE_DEVICE_CONNECTED_CB: + case MM_SOUND_MSG_REQ_ADD_DEVICE_INFO_CHANGED_CB: + case MM_SOUND_MSG_REQ_REMOVE_DEVICE_INFO_CHANGED_CB: { /* Create msg to queue : this will be freed inside thread function after use */ mm_ipc_msg_t* msg_to_queue = malloc (sizeof(mm_ipc_msg_t)); if (msg_to_queue) { memcpy (msg_to_queue, &msg, sizeof (mm_ipc_msg_t)); - debug_msg ("func = %p, alloc param(msg_to_queue) = %p\n", _MMSoundMgrRun, msg_to_queue); + debug_log ("func = %p, alloc param(msg_to_queue) = %p\n", _MMSoundMgrRun, msg_to_queue); ret = MMSoundThreadPoolRun(msg_to_queue, _MMSoundMgrRun); /* In case of error condition */ if (ret != MM_ERROR_NONE) { @@ -177,9 +196,10 @@ int MMSoundMgrIpcReady(void) SOUND_MSG_SET(resp.sound_msg, MM_SOUND_MSG_RES_ERROR, ret, -1, msg.sound_msg.msgid); ret = _MMIpcSndMsg(&resp); - if (ret != MM_ERROR_NONE) + if (ret != MM_ERROR_NONE) { debug_error("Fail to send message in IPC ready\n"); } + } } else { debug_error ("failed to alloc msg\n"); } @@ -192,8 +212,9 @@ int MMSoundMgrIpcReady(void) debug_msg("The message Msg [%d] client id [%d]\n", msg.sound_msg.msgtype, msg.sound_msg.msgid); SOUND_MSG_SET(resp.sound_msg, MM_SOUND_MSG_RES_ERROR, ret, -1, msg.sound_msg.msgid); ret = _MMIpcSndMsg(&resp); - if (ret != MM_ERROR_NONE) + if (ret != MM_ERROR_NONE) { debug_error("Fail to send message in IPC ready\n"); + } break; } /* end : switch (msg.sound_msg.msgtype) */ } @@ -208,11 +229,10 @@ int MMSoundMgrIpcReady(void) return MM_ERROR_SOUND_INTERNAL; } - debug_fleave(); return MM_ERROR_NONE; } -static void _MMSoundMgrRun(mm_ipc_msg_t *msg) +static void _MMSoundMgrRun(void *data) { mm_ipc_msg_t respmsg = {0,}; int ret = MM_ERROR_NONE; @@ -221,15 +241,14 @@ static void _MMSoundMgrRun(mm_ipc_msg_t *msg) bool is_available = 0; mm_sound_device_in device_in = MM_SOUND_DEVICE_IN_NONE; mm_sound_device_out device_out = MM_SOUND_DEVICE_OUT_NONE; - - debug_fenter(); + mm_ipc_msg_t *msg = (mm_ipc_msg_t *)data; instance = msg->sound_msg.msgid; switch (msg->sound_msg.msgtype) { case MM_SOUND_MSG_REQ_FILE: - debug_msg("Recv REQUEST FILE MSG\n"); + debug_msg("==================== Recv REQUEST FILE MSG from pid(%d) ====================\n", instance); ret = _MMSoundMgrIpcPlayFile(&handle, msg); if ( ret != MM_ERROR_NONE) { debug_error("Error to MM_SOUND_MSG_REQ_FILE\n"); @@ -240,7 +259,7 @@ static void _MMSoundMgrRun(mm_ipc_msg_t *msg) break; case MM_SOUND_MSG_REQ_MEMORY: - debug_msg("Recv REQUEST MEMORY MSG\n"); + debug_msg("==================== Recv REQUEST MEMORY MSG from pid(%d) ====================\n", instance); ret =_MMSoundMgrIpcPlayMemory(&handle, msg); if (ret != MM_ERROR_NONE) { debug_error("Error to MM_SOUND_MSG_REQ_MEMORY.\n"); @@ -251,7 +270,7 @@ static void _MMSoundMgrRun(mm_ipc_msg_t *msg) break; case MM_SOUND_MSG_REQ_STOP: - debug_msg("Recv STOP msg\n"); + debug_msg("==================== Recv STOP msg from pid(%d) ====================\n", instance); debug_msg("STOP Handle(codec slot ID) %d \n", msg->sound_msg.handle); ret = _MMSoundMgrIpcStop(msg); if ( ret != MM_ERROR_NONE) { @@ -264,13 +283,13 @@ static void _MMSoundMgrRun(mm_ipc_msg_t *msg) #ifdef PULSE_CLIENT case MM_SOUND_MSG_REQ_IS_BT_A2DP_ON: - debug_msg("Recv REQ_IS_BT_A2DP_ON msg\n"); + debug_msg("==================== Recv REQ_IS_BT_A2DP_ON msg from pid(%d) ====================\n", instance); MMSoundMgrPulseHandleIsBtA2DPOnReq (msg,_MMIpcSndMsg); return; #endif // PULSE_CLIENT case MM_SOUND_MSG_REQ_DTMF: - debug_msg("Recv DTMF msg\n"); + debug_msg("==================== Recv DTMF msg from pid(%d) ====================\n", instance); debug_msg(" Handle(codec slot ID) %d \n", msg->sound_msg.handle); ret = _MMSoundMgrIpcPlayDTMF(&handle, msg); if ( ret != MM_ERROR_NONE) { @@ -282,7 +301,7 @@ static void _MMSoundMgrRun(mm_ipc_msg_t *msg) break; case MM_SOUND_MSG_REQ_IS_ROUTE_AVAILABLE: - debug_msg("Recv REQ_SET_ACTIVE_ROUTE msg\n"); + debug_msg("==================== Recv MM_SOUND_MSG_REQ_IS_ROUTE_AVAILABLE msg from pid(%d) ====================\n", instance); ret = __mm_sound_mgr_ipc_is_route_available(msg, &is_available); if (ret != MM_ERROR_NONE) { debug_error("Error to MM_SOUND_MSG_REQ_IS_ROUTE_AVAILABLE.\n"); @@ -294,7 +313,7 @@ static void _MMSoundMgrRun(mm_ipc_msg_t *msg) break; case MM_SOUND_MSG_REQ_FOREACH_AVAILABLE_ROUTE_CB: - debug_msg("Recv REQ_FOREACH_AVAILABLE_ROUTE_CB msg\n"); + debug_msg("==================== Recv REQ_FOREACH_AVAILABLE_ROUTE_CB msg from pid(%d) ====================\n", instance); ret = __mm_sound_mgr_ipc_foreach_available_route_cb(&respmsg); if (ret != MM_ERROR_NONE) { debug_error("Error to MM_SOUND_MSG_REQ_FOREACH_AVAILABLE_ROUTE_CB.\n"); @@ -305,7 +324,7 @@ static void _MMSoundMgrRun(mm_ipc_msg_t *msg) break; case MM_SOUND_MSG_REQ_SET_ACTIVE_ROUTE: - debug_msg("Recv REQ_SET_ACTIVE_ROUTE msg\n"); + debug_msg("==================== Recv REQ_SET_ACTIVE_ROUTE msg from pid(%d) ====================\n", instance); ret = __mm_sound_mgr_ipc_set_active_route(msg); if (ret != MM_ERROR_NONE) { debug_error("Error to MM_SOUND_MSG_REQ_SET_ACTIVE_ROUTE.\n"); @@ -314,9 +333,19 @@ static void _MMSoundMgrRun(mm_ipc_msg_t *msg) SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_SET_ACTIVE_ROUTE, 0, MM_ERROR_NONE, instance); } break; + case MM_SOUND_MSG_REQ_SET_ACTIVE_ROUTE_AUTO: + debug_msg("==================== Recv REQ_SET_ACTIVE_ROUTE_AUTO msg from pid(%d) ====================\n", instance); + ret = __mm_sound_mgr_ipc_set_active_route_auto(); + if (ret != MM_ERROR_NONE) { + debug_error("Error to MM_SOUND_MSG_REQ_SET_ACTIVE_ROUTE_AUTO.\n"); + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_ERROR, -1, ret, instance); + } else { + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_SET_ACTIVE_ROUTE_AUTO, 0, MM_ERROR_NONE, instance); + } + break; case MM_SOUND_MSG_REQ_GET_ACTIVE_DEVICE: - debug_msg("Recv REQ_GET_ACTIVE_DEVICE msg\n"); + debug_msg("==================== Recv REQ_GET_ACTIVE_DEVICE msg from pid(%d) ====================\n", instance); ret = __mm_sound_mgr_ipc_get_active_device(msg, &device_in, &device_out); if (ret != MM_ERROR_NONE) { debug_error("Error to MM_SOUND_MSG_REQ_GET_ACTIVE_DEVICE.\n"); @@ -329,7 +358,7 @@ static void _MMSoundMgrRun(mm_ipc_msg_t *msg) break; case MM_SOUND_MSG_REQ_ADD_ACTIVE_DEVICE_CB: - debug_msg("Recv REQ_ADD_ACTIVE_DEVICE_CB msg\n"); + debug_msg("==================== Recv REQ_ADD_ACTIVE_DEVICE_CB msg from pid(%d) ====================\n", instance); ret = __mm_sound_mgr_ipc_add_active_device_changed_cb(msg); if (ret != MM_ERROR_NONE) { debug_error("Error to MM_SOUND_MSG_REQ_ADD_DEVICE_CB.\n"); @@ -340,7 +369,7 @@ static void _MMSoundMgrRun(mm_ipc_msg_t *msg) break; case MM_SOUND_MSG_REQ_REMOVE_ACTIVE_DEVICE_CB: - debug_msg("Recv REQ_REMOVE_ACTIVE_DEVICE_CB msg\n"); + debug_msg("==================== Recv REQ_REMOVE_ACTIVE_DEVICE_CB msg from pid(%d) ====================\n", instance); ret = __mm_sound_mgr_ipc_remove_active_device_changed_cb(msg); if (ret != MM_ERROR_NONE) { debug_error("Error to MM_SOUND_MSG_REQ_REMOVE_DEVICE_CB.\n"); @@ -350,8 +379,30 @@ static void _MMSoundMgrRun(mm_ipc_msg_t *msg) } break; + case MM_SOUND_MSG_REQ_ADD_VOLUME_CB: + debug_msg("==================== Recv REQ_ADD_VOLUME_CB msg from pid(%d) ====================\n", instance); + ret = __mm_sound_mgr_ipc_add_volume_changed_cb(msg); + if (ret != MM_ERROR_NONE) { + debug_error("Error to MM_SOUND_MSG_REQ_VOLUME_CB.\n"); + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_ERROR, -1, ret, instance); + } else { + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_ADD_VOLUME_CB, 0, MM_ERROR_NONE, instance); + } + break; + + case MM_SOUND_MSG_REQ_REMOVE_VOLUME_CB: + debug_msg("==================== Recv REQ_REMOVE_VOLUME_CB msg from pid(%d) ====================\n", instance); + ret = __mm_sound_mgr_ipc_remove_volume_changed_cb(msg); + if (ret != MM_ERROR_NONE) { + debug_error("Error to MM_SOUND_MSG_REQ_REMOVE_VOLUME_CB.\n"); + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_ERROR, -1, ret, instance); + } else { + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_REMOVE_VOLUME_CB, 0, MM_ERROR_NONE, instance); + } + break; + case MM_SOUND_MSG_REQ_ADD_AVAILABLE_ROUTE_CB: - debug_msg("Recv REQ_ADD_AVAILABLE_ROUTE_CB msg\n"); + debug_msg("==================== Recv REQ_ADD_AVAILABLE_ROUTE_CB msg from pid(%d)====================\n", instance); ret = __mm_sound_mgr_ipc_add_available_device_changed_cb(msg); if (ret != MM_ERROR_NONE) { debug_error("Error to MM_SOUND_MSG_REQ_ADD_DEVICE_CB.\n"); @@ -362,7 +413,7 @@ static void _MMSoundMgrRun(mm_ipc_msg_t *msg) break; case MM_SOUND_MSG_REQ_REMOVE_AVAILABLE_ROUTE_CB: - debug_msg("Recv REQ_REMOVE_AVAILABLE_ROUTE_CB msg\n"); + debug_msg("==================== Recv REQ_REMOVE_AVAILABLE_ROUTE_CB msg from pid(%d)====================\n", instance); ret = __mm_sound_mgr_ipc_remove_available_device_changed_cb(msg); if (ret != MM_ERROR_NONE) { debug_error("Error to MM_SOUND_MSG_REQ_REMOVE_DEVICE_CB.\n"); @@ -372,6 +423,102 @@ static void _MMSoundMgrRun(mm_ipc_msg_t *msg) } break; + case MM_SOUND_MSG_REQ_SET_PATH_FOR_ACTIVE_DEVICE: + debug_msg("Recv MM_SOUND_MSG_REQ_SET_PATH_FOR_ACTIVE_DEVICE msg\n"); + ret = __mm_sound_mgr_ipc_set_sound_path_for_active_device(msg); + if (ret != MM_ERROR_NONE) { + debug_error("Error to MM_SOUND_MSG_REQ_SET_PATH_FOR_ACTIVE_DEVICE.\n"); + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_ERROR, -1, ret, instance); + } else { + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_SET_PATH_FOR_ACTIVE_DEVICE, 0, MM_ERROR_NONE, instance); + } + break; + case MM_SOUND_MSG_REQ_GET_AUDIO_PATH: + debug_msg("Recv MM_SOUND_MSG_REQ_GET_AUDIO_PATH msg\n"); + ret = __mm_sound_mgr_ipc_get_audio_path(&device_in, &device_out); + if (ret != MM_ERROR_NONE) { + debug_error("Error to MM_SOUND_MSG_REQ_GET_AUDIO_PATH.\n"); + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_ERROR, -1, ret, instance); + } else { + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_GET_AUDIO_PATH, 0, MM_ERROR_NONE, instance); + respmsg.sound_msg.device_in = device_in; + respmsg.sound_msg.device_out = device_out; + } + break; + + case MM_SOUND_MSG_REQ_GET_CONNECTED_DEVICE_LIST: + { + GList *device_list = NULL; + GList *list = NULL; + int total_num_of_device = 0; + int i = 0; + debug_msg("==================== Recv REQ_GET_CONNECTED_DEVICE_LIST msg from pid(%d) ====================\n", instance); + ret = __mm_sound_mgr_ipc_get_current_connected_device_list(msg, &device_list, &total_num_of_device); + if (ret != MM_ERROR_NONE) { + debug_error("Error to REQ_GET_CONNECTED_DEVICE_LIST. ret[0x%x]\n", ret); + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_ERROR, -1, ret, instance); + } else { + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_GET_CONNECTED_DEVICE_LIST, 0, MM_ERROR_NONE, instance); + respmsg.sound_msg.total_device_num = total_num_of_device; + for (list = device_list; list != NULL; list = list->next) { + memcpy(&(respmsg.sound_msg.device_handle), (mm_sound_device_t*)list->data, sizeof(mm_sound_device_t)); + debug_msg("[Server] memory copied to msg device handle(handle[0x%x], type[%d], id[%d]), before sending device info, total [%d] msg remains\n", + &(respmsg.sound_msg.device_handle), ((mm_sound_device_t*)list->data)->type, ((mm_sound_device_t*)list->data)->id, total_num_of_device); + if (total_num_of_device-- > 1) { + ret = _MMIpcSndMsg(&respmsg); + if (ret != MM_ERROR_NONE) { + debug_error ("Fail to send message \n"); + } + } + } + } + } + break; + + case MM_SOUND_MSG_REQ_ADD_DEVICE_CONNECTED_CB: + debug_msg("==================== Recv REQ_ADD_DEVICE_CONNECTED_CB msg from pid(%d) ====================\n", instance); + ret = __mm_sound_mgr_ipc_add_device_connected_cb(msg); + if (ret != MM_ERROR_NONE) { + debug_error("Error to MM_SOUND_MSG_REQ_ADD_DEVICE_CONNECTED_CB.\n"); + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_ERROR, -1, ret, instance); + } else { + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_ADD_DEVICE_CONNECTED_CB, 0, MM_ERROR_NONE, instance); + } + break; + + case MM_SOUND_MSG_REQ_REMOVE_DEVICE_CONNECTED_CB: + debug_msg("==================== Recv REQ_REMOVE_DEVICE_CONNECTED_CB msg from pid(%d) ====================\n", instance); + ret = __mm_sound_mgr_ipc_remove_device_connected_cb(msg); + if (ret != MM_ERROR_NONE) { + debug_error("Error to MM_SOUND_MSG_REQ_REMOVE_DEVICE_CONNECTED_CB.\n"); + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_ERROR, -1, ret, instance); + } else { + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_REMOVE_DEVICE_CONNECTED_CB, 0, MM_ERROR_NONE, instance); + } + break; + + case MM_SOUND_MSG_REQ_ADD_DEVICE_INFO_CHANGED_CB: + debug_msg("==================== Recv REQ_ADD_DEVICE_INFO_CHANGED_CB msg from pid(%d) ====================\n", instance); + ret = __mm_sound_mgr_ipc_add_device_info_changed_cb(msg); + if (ret != MM_ERROR_NONE) { + debug_error("Error to MM_SOUND_MSG_REQ_ADD_DEVICE_INFO_CHANGED_CB.\n"); + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_ERROR, -1, ret, instance); + } else { + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_ADD_DEVICE_INFO_CHANGED_CB, 0, MM_ERROR_NONE, instance); + } + break; + + case MM_SOUND_MSG_REQ_REMOVE_DEVICE_INFO_CHANGED_CB: + debug_msg("==================== Recv REQ_REMOVE_DEVICE_INFO_CHANGED_CB msg from pid(%d) ====================\n", instance); + ret = __mm_sound_mgr_ipc_remove_device_info_changed_cb(msg); + if (ret != MM_ERROR_NONE) { + debug_error("Error to MM_SOUND_MSG_REQ_REMOVE_DEVICE_INFO_CHANGED_CB.\n"); + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_ERROR, -1, ret, instance); + } else { + SOUND_MSG_SET(respmsg.sound_msg, MM_SOUND_MSG_RES_REMOVE_DEVICE_INFO_CHANGED_CB, 0, MM_ERROR_NONE, instance); + } + break; + default: /* Response error unknown operation */; debug_critical("Unexpected msg. %d for PID:%d\n", msg->sound_msg.msgtype, msg->sound_msg.msgid ); @@ -384,35 +531,33 @@ static void _MMSoundMgrRun(mm_ipc_msg_t *msg) debug_error ("Fail to send message \n"); } - debug_msg("Sent msg to client msgid [%d] [codechandle %d][message type %d] (code 0x%08X)\n", + debug_log("Sent msg to client msgid [%d] [codechandle %d][message type %d] (code 0x%08X)\n", msg->sound_msg.msgid, respmsg.sound_msg.handle, respmsg.sound_msg.msgtype, respmsg.sound_msg.code); if (msg) { +#ifdef DEBUG_DETAIL debug_log ("Free mm_ipc_msg_t [%p]\n", msg); +#endif free (msg); } - - debug_msg("Ready to next msg\n"); - debug_fleave(); } -static int _MMSoundMgrStopCB(int msgid, void* msgcallback, void *msgdata) +static int _MMSoundMgrStopCB(int msgid, void* msgcallback, void *msgdata, int id) { /* msgid means client instance(msg_type) must be unique */ mm_ipc_msg_t resp = {0,}; int ret = MM_ERROR_SOUND_INTERNAL; - debug_fenter(); - SOUND_MSG_SET(resp.sound_msg, MM_SOUND_MSG_INF_STOP_CB, 0, MM_ERROR_NONE, msgid); resp.sound_msg.callback = msgcallback; resp.sound_msg.cbdata = msgdata; + resp.sound_msg.handle = id; ret = _MMIpcCBSndMsg(&resp); - if (ret != MM_ERROR_NONE) + if (ret != MM_ERROR_NONE) { debug_error("Fail to send callback message\n"); + } - debug_fleave(); return MM_ERROR_NONE; } @@ -421,18 +566,21 @@ static int _MMSoundMgrIpcPlayFile(int *codechandle, mm_ipc_msg_t *msg) mmsound_mgr_codec_param_t param = {0,}; MMSourceType *source = NULL; int ret = MM_ERROR_NONE; - int mm_session_type = MM_SESSION_TYPE_SHARE; + int mm_session_type = MM_SESSION_TYPE_MEDIA; - debug_fenter(); - /* Set source */ source = (MMSourceType*)malloc(sizeof(MMSourceType)); + if (!source) { + debug_error("malloc fail!!\n"); + return MM_ERROR_OUT_OF_MEMORY; + } ret = mm_source_open_file(msg->sound_msg.filename, source, MM_SOURCE_CHECK_DRM_CONTENTS); if(ret != MM_ERROR_NONE) { debug_error("Fail to open file\n"); - if (source) + if (source) { free(source); + } return ret; } @@ -441,7 +589,7 @@ static int _MMSoundMgrIpcPlayFile(int *codechandle, mm_ipc_msg_t *msg) param.repeat_count = msg->sound_msg.repeat; param.param = (void*)msg->sound_msg.msgid; //this is pid of client param.volume = msg->sound_msg.volume; - param.volume_table = msg->sound_msg.volume_table; + param.volume_config = msg->sound_msg.volume_config; param.priority = msg->sound_msg.priority; mm_session_type = msg->sound_msg.session_type; param.callback = _MMSoundMgrStopCB; @@ -450,27 +598,24 @@ static int _MMSoundMgrIpcPlayFile(int *codechandle, mm_ipc_msg_t *msg) param.msgdata = msg->sound_msg.cbdata; param.source = source; param.handle_route = msg->sound_msg.handle_route; + param.enable_session = msg->sound_msg.enable_session; - debug_msg("DTMF %d\n", param.tone); - debug_msg("Loop %d\n", param.repeat_count); - debug_msg("Volume %d\n",param.volume); - debug_msg("Priority %d\n",param.priority); - debug_msg("VolumeTable %d\n",param.volume_table); - debug_msg("callback %p\n", param.callback); - debug_msg("param %d\n", (int)param.param); - debug_msg("source type %d\n", param.source->type); - debug_msg("source ptr %p\n", param.source->ptr); - debug_msg("keytone %d\n", param.keytone); - debug_msg("Handle route %d\n", param.handle_route); + /* workaround for AF volume gain tuning */ + if (strncmp(msg->sound_msg.filename, MM_SOUND_AF_FILE_PREFIX, strlen(MM_SOUND_AF_FILE_PREFIX)) == 0) { + param.volume_config |= VOLUME_GAIN_AF; + debug_msg("Volume Gain AF\n"); + } + + debug_msg("File[%s] DTMF[%d] Loop[%d] Volume[%f] Priority[%d] VolCfg[0x%x] callback[%p] param[%d] src_type[%d] src_ptr[%p] keytone[%d] route[%d] enable_session[%d]", + msg->sound_msg.filename, + param.tone, param.repeat_count, param.volume, param.priority, param.volume_config, param.callback, + (int)param.param, param.source->type, param.source->ptr, param.keytone, param.handle_route, param.enable_session); //convert mm_session_type to asm_event_type switch(mm_session_type) { - case MM_SESSION_TYPE_SHARE: - param.session_type = ASM_EVENT_SHARE_MMSOUND; - break; - case MM_SESSION_TYPE_EXCLUSIVE: - param.session_type = ASM_EVENT_EXCLUSIVE_MMSOUND; + case MM_SESSION_TYPE_MEDIA: + param.session_type = ASM_EVENT_MEDIA_MMSOUND; break; case MM_SESSION_TYPE_NOTIFY: param.session_type = ASM_EVENT_NOTIFY; @@ -478,15 +623,21 @@ static int _MMSoundMgrIpcPlayFile(int *codechandle, mm_ipc_msg_t *msg) case MM_SESSION_TYPE_ALARM: param.session_type = ASM_EVENT_ALARM; break; + case MM_SESSION_TYPE_EMERGENCY: + param.session_type = ASM_EVENT_EMERGENCY; + break; case MM_SESSION_TYPE_CALL: param.session_type = ASM_EVENT_CALL; break; case MM_SESSION_TYPE_VIDEOCALL: param.session_type = ASM_EVENT_VIDEOCALL; break; + case MM_SESSION_TYPE_VOIP: + param.session_type = ASM_EVENT_VOIP; + break; default: debug_error("Unknown session type - use default shared type. %s %d\n", __FUNCTION__, __LINE__); - param.session_type = ASM_EVENT_SHARE_MMSOUND; + param.session_type = ASM_EVENT_MEDIA_MMSOUND; break; } @@ -494,19 +645,20 @@ static int _MMSoundMgrIpcPlayFile(int *codechandle, mm_ipc_msg_t *msg) ret = MMSoundMgrCodecPlay(codechandle, ¶m); if ( ret != MM_ERROR_NONE) { debug_error("Will be closed a sources, codechandle : 0x%08X\n", *codechandle); - - return ret; + mm_source_close(source); + if (source) { + free(source); + source = NULL; + } + return ret; } - debug_fleave(); return MM_ERROR_NONE; } static int _MMSoundMgrIpcStop(mm_ipc_msg_t *msg) { int ret = MM_ERROR_NONE; - debug_fenter(); - ret = MMSoundMgrCodecStop(msg->sound_msg.handle); if (ret != MM_ERROR_NONE) { @@ -514,7 +666,6 @@ static int _MMSoundMgrIpcStop(mm_ipc_msg_t *msg) return ret; } - debug_fleave(); return MM_ERROR_NONE; } @@ -526,8 +677,6 @@ static int _MMSoundMgrIpcPlayMemory(int *codechandle, mm_ipc_msg_t *msg) int shm_fd = -1; void* mmap_buf = NULL; - debug_fenter(); - #ifndef SHM_OPEN if ((shmid = shmget((key_t)(msg->sound_msg.sharedkey), msg->sound_msg.memsize, 0)) == -1) { @@ -580,6 +729,8 @@ static int _MMSoundMgrIpcPlayMemory(int *codechandle, mm_ipc_msg_t *msg) source = (MMSourceType*)malloc(sizeof(MMSourceType)); if(!source) { debug_error("Can not allocate memory"); + munmap(mmap_buf, MEMTYPE_SUPPORT_MAX); + mmap_buf = NULL; return MM_ERROR_OUT_OF_MEMORY; } @@ -595,88 +746,116 @@ static int _MMSoundMgrIpcPlayMemory(int *codechandle, mm_ipc_msg_t *msg) param.repeat_count = msg->sound_msg.repeat; param.param = (void*)msg->sound_msg.msgid; param.volume = msg->sound_msg.volume; - param.volume_table = msg->sound_msg.volume_table; + param.volume_config = msg->sound_msg.volume_config; param.callback = _MMSoundMgrStopCB; param.keytone = msg->sound_msg.keytone; param.msgcallback = msg->sound_msg.callback; param.msgdata = msg->sound_msg.cbdata; param.priority = msg->sound_msg.priority; param.source = source; + param.enable_session = msg->sound_msg.enable_session; debug_msg("DTMF %d\n", param.tone); debug_msg("Loop %d\n", param.repeat_count); debug_msg("Volume %d\n",param.volume); debug_msg("Priority %d\n",param.priority); - debug_msg("VolumeTable %d\n",param.volume_table); + debug_msg("VolumeConfig %x\n",param.volume_config); debug_msg("callback %p\n", param.callback); debug_msg("param %d\n", (int)param.param); debug_msg("source type %d\n", param.source->type); debug_msg("source ptr %p\n", param.source->ptr); debug_msg("keytone %d\n", param.keytone); + debug_msg("enable_session %d\n", param.enable_session); ret = MMSoundMgrCodecPlay(codechandle, ¶m); if ( ret != MM_ERROR_NONE) { debug_error("Will be closed a sources, codec handle : [0x%d]\n", *codechandle); mm_source_close(source); - if (source) + if (source) { free(source); + } return ret; } - debug_fleave(); return ret; } static int _MMSoundMgrIpcPlayDTMF(int *codechandle, mm_ipc_msg_t *msg) { - mmsound_mgr_codec_param_t param = {0,}; int ret = MM_ERROR_NONE; - debug_fenter(); - /* Set sound player parameter */ param.tone = msg->sound_msg.tone; param.repeat_count = msg->sound_msg.repeat; param.param = (void*)msg->sound_msg.msgid; param.volume = msg->sound_msg.volume; - param.volume_table = msg->sound_msg.volume_table; + param.volume_config = msg->sound_msg.volume_config; param.priority = msg->sound_msg.priority; param.callback = _MMSoundMgrStopCB; param.msgcallback = msg->sound_msg.callback; param.msgdata = msg->sound_msg.cbdata; - param.session_type = ASM_EVENT_SHARE_MMSOUND; + param.session_options = msg->sound_msg.session_options; + param.enable_session = msg->sound_msg.enable_session; + + //convert mm_session_type to asm_event_type + switch(msg->sound_msg.session_type) + { + case MM_SESSION_TYPE_MEDIA: + param.session_type = ASM_EVENT_MEDIA_MMSOUND; + break; + case MM_SESSION_TYPE_NOTIFY: + param.session_type = ASM_EVENT_NOTIFY; + break; + case MM_SESSION_TYPE_ALARM: + param.session_type = ASM_EVENT_ALARM; + break; + case MM_SESSION_TYPE_EMERGENCY: + param.session_type = ASM_EVENT_EMERGENCY; + break; + case MM_SESSION_TYPE_CALL: + param.session_type = ASM_EVENT_CALL; + break; + case MM_SESSION_TYPE_VIDEOCALL: + param.session_type = ASM_EVENT_VIDEOCALL; + break; + case MM_SESSION_TYPE_VOIP: + param.session_type = ASM_EVENT_VOIP; + break; + default: + debug_error("Unknown session type - use default media type. %s %d\n", __FUNCTION__, __LINE__); + param.session_type = ASM_EVENT_MEDIA_MMSOUND; + break; + } debug_msg("DTMF %d\n", param.tone); debug_msg("Loop %d\n", param.repeat_count); debug_msg("Volume %d\n",param.volume); - debug_msg("VolumeTable %d\n",param.volume_table); + debug_msg("VolumeConfig %x\n",param.volume_config); debug_msg("Priority %d\n", param.priority); debug_msg("callback %p\n", param.callback); debug_msg("param %d\n", (int)param.param); + debug_msg("session %d\n", param.session_type); + debug_msg("session options %x\n", param.session_options); + debug_msg("enable_session %d\n", param.enable_session); ret = MMSoundMgrCodecPlayDtmf(codechandle, ¶m); if ( ret != MM_ERROR_NONE) { debug_error("Will be closed a sources, codec handle : [0x%d]\n", *codechandle); return ret; } - - debug_fleave(); + return ret; } static int __mm_sound_mgr_ipc_is_route_available(mm_ipc_msg_t *msg, bool *is_available) { _mm_sound_mgr_device_param_t param; - mm_sound_route route; int ret = MM_ERROR_NONE; - debug_fenter(); - param.route = msg->sound_msg.route; ret = _mm_sound_mgr_device_is_route_available(¶m, is_available); - debug_fleave(); return ret; } @@ -684,11 +863,8 @@ static int __mm_sound_mgr_ipc_foreach_available_route_cb(mm_ipc_msg_t *msg) { int ret = MM_ERROR_NONE; - debug_fenter(); - ret = _mm_sound_mgr_device_foreach_available_route_cb(msg); - debug_fleave(); return ret; } @@ -697,13 +873,21 @@ static int __mm_sound_mgr_ipc_set_active_route(mm_ipc_msg_t *msg) _mm_sound_mgr_device_param_t param; int ret = MM_ERROR_NONE; - debug_fenter(); - param.pid = msg->sound_msg.msgid; param.route = msg->sound_msg.route; + param.need_broadcast = msg->sound_msg.need_broadcast; + ret = _mm_sound_mgr_device_set_active_route(¶m); - debug_fleave(); + return ret; +} + +static int __mm_sound_mgr_ipc_set_active_route_auto(void) +{ + int ret = MM_ERROR_NONE; + + ret = _mm_sound_mgr_device_set_active_route_auto(); + return ret; } @@ -712,14 +896,11 @@ static int __mm_sound_mgr_ipc_get_active_device(mm_ipc_msg_t *msg, mm_sound_devi _mm_sound_mgr_device_param_t param; int ret = MM_ERROR_NONE; - debug_fenter(); - memset(¶m, 0x00, sizeof(_mm_sound_mgr_device_param_t)); param.pid = msg->sound_msg.msgid; ret = _mm_sound_mgr_device_get_active_device(¶m, device_in, device_out); - debug_fleave(); return ret; } @@ -728,16 +909,14 @@ static int __mm_sound_mgr_ipc_add_active_device_changed_cb(mm_ipc_msg_t *msg) _mm_sound_mgr_device_param_t param; int ret = MM_ERROR_NONE; - debug_fenter(); - memset(¶m, 0x00, sizeof(_mm_sound_mgr_device_param_t)); param.pid = msg->sound_msg.msgid; param.callback = msg->sound_msg.callback; param.cbdata = msg->sound_msg.cbdata; + MMSOUND_STRNCPY(param.name, msg->sound_msg.name, MM_SOUND_NAME_NUM); ret = _mm_sound_mgr_device_add_active_device_callback(¶m); - debug_fleave(); return ret; } @@ -746,23 +925,50 @@ static int __mm_sound_mgr_ipc_remove_active_device_changed_cb(mm_ipc_msg_t *msg) _mm_sound_mgr_device_param_t param; int ret = MM_ERROR_NONE; - debug_fenter(); - memset(¶m, 0x00, sizeof(_mm_sound_mgr_device_param_t)); param.pid = msg->sound_msg.msgid; + MMSOUND_STRNCPY(param.name, msg->sound_msg.name, MM_SOUND_NAME_NUM); ret = _mm_sound_mgr_device_remove_active_device_callback(¶m); - debug_fleave(); return ret; } -static int __mm_sound_mgr_ipc_add_available_device_changed_cb(mm_ipc_msg_t *msg) +static int __mm_sound_mgr_ipc_add_volume_changed_cb(mm_ipc_msg_t *msg) { _mm_sound_mgr_device_param_t param; int ret = MM_ERROR_NONE; - debug_fenter(); + memset(¶m, 0x00, sizeof(_mm_sound_mgr_device_param_t)); + param.pid = msg->sound_msg.msgid; + param.callback = msg->sound_msg.callback; + param.cbdata = msg->sound_msg.cbdata; + MMSOUND_STRNCPY(param.name, msg->sound_msg.name, MM_SOUND_NAME_NUM); + + ret = _mm_sound_mgr_device_add_volume_callback(¶m); + + return ret; +} + +static int __mm_sound_mgr_ipc_remove_volume_changed_cb(mm_ipc_msg_t *msg) +{ + _mm_sound_mgr_device_param_t param; + int ret = MM_ERROR_NONE; + + memset(¶m, 0x00, sizeof(_mm_sound_mgr_device_param_t)); + param.pid = msg->sound_msg.msgid; + MMSOUND_STRNCPY(param.name, msg->sound_msg.name, MM_SOUND_NAME_NUM); + + ret = _mm_sound_mgr_device_remove_volume_callback(¶m); + + return ret; +} + + +static int __mm_sound_mgr_ipc_add_available_device_changed_cb(mm_ipc_msg_t *msg) +{ + _mm_sound_mgr_device_param_t param; + int ret = MM_ERROR_NONE; memset(¶m, 0x00, sizeof(_mm_sound_mgr_device_param_t)); param.pid = msg->sound_msg.msgid; @@ -771,7 +977,6 @@ static int __mm_sound_mgr_ipc_add_available_device_changed_cb(mm_ipc_msg_t *msg) ret = _mm_sound_mgr_device_add_available_route_callback(¶m); - debug_fleave(); return ret; } @@ -780,17 +985,161 @@ static int __mm_sound_mgr_ipc_remove_available_device_changed_cb(mm_ipc_msg_t *m _mm_sound_mgr_device_param_t param; int ret = MM_ERROR_NONE; - debug_fenter(); - memset(¶m, 0x00, sizeof(_mm_sound_mgr_device_param_t)); param.pid = msg->sound_msg.msgid; ret = _mm_sound_mgr_device_remove_available_route_callback(¶m); - debug_fleave(); return ret; } +static int __mm_sound_mgr_ipc_set_sound_path_for_active_device(mm_ipc_msg_t *msg) +{ + int ret = MM_ERROR_NONE; + mm_sound_device_in device_in = MM_SOUND_DEVICE_IN_NONE; + mm_sound_device_out device_out = MM_SOUND_DEVICE_OUT_NONE; + device_in = msg->sound_msg.device_in; + device_out = msg->sound_msg.device_out; + ret = _mm_sound_mgr_device_set_sound_path_for_active_device(device_out, device_in); + + return ret; +} + +static int __mm_sound_mgr_ipc_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out) +{ + int ret = MM_ERROR_NONE; + + ret = _mm_sound_mgr_device_get_audio_path(device_in, device_out); + + return ret; +} + +static int __mm_sound_mgr_ipc_get_current_connected_device_list(mm_ipc_msg_t *msg, GList **device_list, int *total_num) +{ + _mm_sound_mgr_device_param_t param; + int ret = MM_ERROR_NONE; + int num = 0; + + memset(¶m, 0x00, sizeof(_mm_sound_mgr_device_param_t)); + param.pid = msg->sound_msg.msgid; + param.device_flags = msg->sound_msg.device_flags; + + ret = _mm_sound_mgr_device_get_current_connected_dev_list(¶m, device_list); + + num = g_list_length(*device_list); + if (num) { + *total_num = num; + } else { + *device_list = NULL; + ret = MM_ERROR_SOUND_NO_DATA; + } + debug_msg("address of device_list[0x%x], number of device [%d]", *device_list, num); + + return ret; +} + +static int __mm_sound_mgr_ipc_add_device_connected_cb(mm_ipc_msg_t *msg) +{ + _mm_sound_mgr_device_param_t param; + int ret = MM_ERROR_NONE; + + memset(¶m, 0x00, sizeof(_mm_sound_mgr_device_param_t)); + param.pid = msg->sound_msg.msgid; + param.callback = msg->sound_msg.callback; + param.cbdata = msg->sound_msg.cbdata; + param.device_flags = msg->sound_msg.device_flags; + + ret = _mm_sound_mgr_device_add_connected_callback(¶m); + + return ret; +} + +static int __mm_sound_mgr_ipc_remove_device_connected_cb(mm_ipc_msg_t *msg) +{ + _mm_sound_mgr_device_param_t param; + int ret = MM_ERROR_NONE; + + memset(¶m, 0x00, sizeof(_mm_sound_mgr_device_param_t)); + param.pid = msg->sound_msg.msgid; + + ret = _mm_sound_mgr_device_remove_connected_callback(¶m); + + return ret; +} + +static int __mm_sound_mgr_ipc_add_device_info_changed_cb(mm_ipc_msg_t *msg) +{ + _mm_sound_mgr_device_param_t param; + int ret = MM_ERROR_NONE; + + memset(¶m, 0x00, sizeof(_mm_sound_mgr_device_param_t)); + param.pid = msg->sound_msg.msgid; + param.callback = msg->sound_msg.callback; + param.cbdata = msg->sound_msg.cbdata; + param.device_flags = msg->sound_msg.device_flags; + + ret = _mm_sound_mgr_device_add_info_changed_callback(¶m); + + return ret; +} + +static int __mm_sound_mgr_ipc_remove_device_info_changed_cb(mm_ipc_msg_t *msg) +{ + _mm_sound_mgr_device_param_t param; + int ret = MM_ERROR_NONE; + + memset(¶m, 0x00, sizeof(_mm_sound_mgr_device_param_t)); + param.pid = msg->sound_msg.msgid; + + ret = _mm_sound_mgr_device_remove_info_changed_callback(¶m); + + return ret; +} + +int __mm_sound_mgr_ipc_freeze_send (char* command, int pid) +{ + GError *err = NULL; + GDBusConnection *conn = NULL; + gboolean ret; + + if (command == NULL || pid <= 0) { + debug_error ("invalid arguments [%s][%d]", command, pid); + return -1; + } + + conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err); + if (!conn && err) { + debug_error ("g_bus_get_sync() error (%s) ", err->message); + g_error_free (err); + return -1; + } + + ret = g_dbus_connection_emit_signal (conn, + NULL, PROC_DBUS_OBJECT, PROC_DBUS_INTERFACE, PROC_DBUS_METHOD, + g_variant_new ("(si)", command, pid), + &err); + if (!ret && err) { + debug_error ("g_dbus_connection_emit_signal() error (%s) ", err->message); + goto error; + } + + ret = g_dbus_connection_flush_sync(conn, NULL, &err); + if (!ret && err) { + debug_error ("g_dbus_connection_flush_sync() error (%s) ", err->message); + goto error; + } + + g_object_unref(conn); + debug_msg ("sending [%s] for pid (%d) success", command, pid); + + return 0; + +error: + g_error_free (err); + g_object_unref(conn); + return -1; +} + static int _MMIpcRecvMsg(int msgtype, mm_ipc_msg_t *msg) { /* rcv message */ @@ -820,8 +1169,10 @@ int _MMIpcSndMsg(mm_ipc_msg_t *msg) { /* snd message */ int error = MM_ERROR_NONE; + msg->msg_type = msg->sound_msg.msgid; - debug_msg("Send message type (for client) : [%ld]\n",msg->msg_type); + + debug_log("Send message type (for client) : [%ld]\n",msg->msg_type); error = msgsnd(g_sndid, msg,DSIZE, 0); if ( error == -1) { @@ -850,24 +1201,50 @@ int _MMIpcSndMsg(mm_ipc_msg_t *msg) int _MMIpcCBSndMsg(mm_ipc_msg_t *msg) { /* rcv message */ + int try_again = 0; + + MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_msg_snd_cb_mutex, MM_ERROR_SOUND_INTERNAL); msg->msg_type = msg->sound_msg.msgid; - debug_msg("Send CB message type (for client) : [%ld]\n",msg->msg_type); - if (msgsnd(g_cbid, msg,DSIZE, 0)== -1) - { - if(errno == EACCES) { - debug_warning("Not acces.\n"); - } else if(errno == EAGAIN) { - debug_warning("Blocked process [msgflag & IPC_NOWAIT != 0]\n"); - } else if(errno == EIDRM) { - debug_warning("Removed msgid from system\n"); - } else if(errno == EINTR) { - debug_warning("Iterrrupted by singnal\n"); - } else if(errno == EINVAL) { - debug_warning("Invalid msgid or msgtype < 1 or out of data size \n"); + debug_log("Send CB message type (for client) : [%ld]\n",msg->msg_type); + /* message queue is full ,we try to send it again*/ + while(try_again <= 10) { + if (msgsnd(g_cbid, msg, DSIZE, IPC_NOWAIT) == -1) + { + if (errno == EACCES) { + debug_warning("Not acces.\n"); + } else if (errno == EAGAIN) { + mm_ipc_msg_t msgdata = {0,}; + debug_warning("Blocked process [msgflag & IPC_NOWAIT != 0]\n"); + /* wait 10 msec ,then it will try again */ + usleep(10000); + /* it will try 5 times, after 5 times ,if it still fail ,then it will clear the message queue */ + if (try_again <= 5) { + try_again ++; + continue; + } + /* message queue is full ,it need to clear the queue */ + while( msgrcv(g_cbid, &msgdata, DSIZE, 0, IPC_NOWAIT) != -1 ) { + debug_warning("msg queue is full ,remove msgtype:[%d] from the queue",msgdata.sound_msg.msgtype); + } + try_again++; + continue; + } else if (errno == EIDRM) { + debug_warning("Removed msgid from system\n"); + } else if (errno == EINTR) { + debug_warning("Iterrrupted by singnal\n"); + } else if (errno == EINVAL) { + debug_warning("Invalid msgid or msgtype < 1 or out of data size \n"); + } + debug_critical("Fail to callback send message msg queue : [%d] \n", g_cbid); + MMSOUND_LEAVE_CRITICAL_SECTION(&g_msg_snd_cb_mutex); + return MM_ERROR_SOUND_INTERNAL; + } else { + break; } - debug_critical("Fail to callback send message msg queue : [%d] \n", g_cbid); - return MM_ERROR_SOUND_INTERNAL; } + + MMSOUND_LEAVE_CRITICAL_SECTION(&g_msg_snd_cb_mutex); return MM_ERROR_NONE; } + diff --git a/server/mm_sound_mgr_pulse.c b/server/mm_sound_mgr_pulse.c old mode 100644 new mode 100755 index 1fe93c2..8f966a9 --- a/server/mm_sound_mgr_pulse.c +++ b/server/mm_sound_mgr_pulse.c @@ -33,50 +33,164 @@ #include #include "include/mm_sound_mgr_common.h" +#include "include/mm_sound_mgr_device_dock.h" #include "../include/mm_sound_common.h" +#include "../include/mm_sound.h" #include #include - -//#include -//#include +#include +#include +#include #include #include +#include #define SUPPORT_MONO_AUDIO - +#define SUPPORT_AUDIO_BALANCE +#ifdef SUPPORT_BT_SCO #define SUPPORT_BT_SCO_DETECT +#endif +#define SUPPORT_AUDIO_MUTEALL #include "include/mm_sound_mgr_pulse.h" #include "include/mm_sound_mgr_session.h" +#include "include/mm_sound_mgr_device.h" #include "include/mm_sound_msg.h" #include "include/mm_sound_mgr_ipc.h" - #include #include -#define MAX_STRING 64 +#ifdef SUPPORT_BT_SCO_DETECT +#include "bluetooth.h" +#ifdef TIZEN_MICRO +#include "bluetooth-api.h" +#include "bluetooth-audio-api.h" +#endif +#include "../include/mm_sound_utils.h" +#endif + +#define VCONF_BT_STATUS "db/bluetooth/status" + +#define MAX_STRING 32 +enum{ + DEVICE_NONE, + DEVICE_IN_MIC_OUT_SPEAKER, + DEVICE_IN_MIC_OUT_RECEIVER, + DEVICE_IN_MIC_OUT_WIRED, + DEVICE_IN_WIRED_OUT_WIRED, + DEVICE_IN_BT_SCO_OUT_BT_SCO, +}; + +typedef struct _path_info +{ + int device_in; + int device_out; +} path_info_t; typedef struct _pulse_info { pa_threaded_mainloop *m; + pa_threaded_mainloop *m_operation; + pa_context *context; - char sink_to_find[MAX_STRING]; + + char device_api_name[MAX_STRING]; + char device_bus_name[MAX_STRING]; + char *usb_sink_name; + char *dock_sink_name; bool init_bt_status; + + bool is_sco_init; +//#ifdef TIZEN_MICRO + bool ag_init; + bool hf_init; +//#endif + int bt_idx; + int usb_idx; + int dock_idx; + int device_in_out; + int aec_module_idx; + int card_idx; + int sink_idx; + int device_type; +#ifdef TIZEN_MICRO + int need_update_vol; +#endif + pthread_t thread; + GAsyncQueue *queue; }pulse_info_t; +typedef enum { + PA_CLIENT_NOT_USED, + PA_CLIENT_GET_CARD_INFO_BY_INDEX, + PA_CLIENT_GET_SERVER_INFO, + PA_CLIENT_SET_DEVICE_NOT_AVAILABLE, + PA_CLIENT_DESTROY, + PA_CLIENT_MAX +}pa_client_command_t; + +static const char* command_str[] = +{ + "NotUsed", + "GetCardInfoByIndex", + //"GetSinkInfoByIndex", + "GetServerInfo", + "SetDeviceNotAvailable", + "Destroy", + "Max" +}; + pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER; +pthread_mutex_t g_bt_info_mutex = PTHREAD_MUTEX_INITIALIZER; +int g_alloc_device_id = -1; +path_info_t g_path_info; pulse_info_t* pulse_info = NULL; +#ifdef TIZEN_MICRO +static int g_bt_hf_volume_control = 0; +static int g_bt_hf_sco_nb = 0; +#define SPK_VOL_MAX 6 +#define CLIENT_VOLUME_MAX 16.0f +#endif +#define DEVICE_BUS_USB "usb" +#define DEVICE_BUS_BUILTIN "builtin" +#define IS_STREQ(str1, str2) (strcmp (str1, str2) == 0) +#define IS_BUS_USB(bus) IS_STREQ(bus, DEVICE_BUS_USB) + +#define CHECK_CONTEXT_SUCCESS_GOTO(p, expression, label) \ + do { \ + if (!(expression)) { \ + goto label; \ + } \ + } while(0); + +#define CHECK_CONTEXT_DEAD_GOTO(c, label) \ + do { \ + if (!PA_CONTEXT_IS_GOOD(pa_context_get_state(c))) {\ + goto label; \ + } \ + } while(0); + /* -------------------------------- PULSEAUDIO --------------------------------------------*/ + +static void pa_context_subscribe_success_cb(pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t*)userdata; + debug_msg("\n"); + pa_threaded_mainloop_signal(pinfo->m, 0); + return; +} + static void server_info_cb(pa_context *c, const pa_server_info *i, void *userdata) { int ret = 0; + pulse_info_t *pinfo = (pulse_info_t*)userdata; if (!i) { debug_error("error in server info callback\n"); @@ -91,11 +205,21 @@ static void server_info_cb(pa_context *c, const pa_server_info *i, void *userdat debug_error ("MMSoundMgrSessionSetDefaultSink failed....ret = [%x]\n", ret); } } + + pa_threaded_mainloop_signal(pinfo->m, 0); + return; } static void init_card_info_cb (pa_context *c, const pa_card_info *i, int eol, void *userdata) { pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null, return"); + return; + } + + debug_msg("\n"); + if (eol || i == NULL) { debug_msg ("signaling--------------\n"); pa_threaded_mainloop_signal (pinfo->m, 0); @@ -105,103 +229,314 @@ static void init_card_info_cb (pa_context *c, const pa_card_info *i, int eol, vo if (strstr (i->name, "bluez")) { pinfo->init_bt_status = true; } + + return; +} + +static void _store_usb_info (pulse_info_t *pinfo, bool is_usb_dock, int index, const char* name) +{ + if (is_usb_dock) { + if (pinfo->dock_sink_name) { + free(pinfo->dock_sink_name); + } + pinfo->dock_sink_name = strdup((name) ? name : "NONAME"); + pinfo->dock_idx = index; + } else { + if (pinfo->usb_sink_name) { + free(pinfo->usb_sink_name); + } + pinfo->usb_sink_name = strdup((name) ? name : "NONAME"); + pinfo->usb_idx = index; + } } -static void card_info_cb (pa_context *c, const pa_card_info *i, int eol, void *userdata) +static void new_card_info_cb (pa_context *c, const pa_card_info *i, int eol, void *userdata) { int ret = 0; - char* desc = NULL; + const char* bus = NULL; + + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (!userdata) { + debug_error ("NULL PARAM"); + return; + } if (eol || i == NULL) { + pa_threaded_mainloop_signal(pinfo->m, 0); return; } - /* Get device name : eg. SBH-600 */ - desc = pa_proplist_gets(i->proplist, PA_PROP_DEVICE_DESCRIPTION); - debug_msg ("[%s][%d] card name is [%s], card.property.device.description = [%s]\n", __func__, __LINE__, i->name, desc); + bus = pa_proplist_gets(i->proplist, PA_PROP_DEVICE_BUS); + if (bus && IS_BUS_USB(bus)) { + int dock_status = 0; + const char* serial = pa_proplist_gets(i->proplist, PA_PROP_DEVICE_SERIAL); + debug_msg ("name=[%s], bus=[%s], serial=[%s]\n", i->name, bus, serial); + + vconf_get_int(VCONFKEY_SYSMAN_CRADLE_STATUS, &dock_status); + if ((pinfo->dock_idx == PA_INVALID_INDEX) && + ((dock_status == DOCK_AUDIODOCK) || (dock_status == DOCK_SMARTDOCK))) { + _store_usb_info(pinfo, true, i->index, serial); + ret = MMSoundMgrSessionSetDeviceAvailable (DEVICE_MULTIMEDIA_DOCK, AVAILABLE, 0, (serial)? serial : "NONAME"); + if (ret != MM_ERROR_NONE) { + /* TODO : Error Handling */ + debug_error ("MMSoundMgrSessionSetDeviceAvailable failed....ret = [%x]", ret); + } + } else { + _store_usb_info(pinfo, false, i->index, serial); + ret = MMSoundMgrSessionSetDeviceAvailable (DEVICE_USB_AUDIO, AVAILABLE, 0, (serial)? serial : "NONAME"); + if (ret != MM_ERROR_NONE) { + /* TODO : Error Handling */ + debug_error ("MMSoundMgrSessionSetDeviceAvailable failed....ret = [%x]", ret); + } + device_io_direction_e io_direction = DEVICE_IO_DIRECTION_OUT; + ret = MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_USB_AUDIO, io_direction, DEVICE_ID_AUTO, (serial)? serial : "NONAME", 0, NULL); + if (ret != MM_ERROR_NONE) { + /* TODO : Error Handling */ + debug_error ("MMSoundMgrDeviceUpdateStatus failed....ret = [%x]", ret); + } + } + } else { /* other than USB, we assume this is BT */ + /* Get device name : eg. SBH-600 */ + const char* desc = pa_proplist_gets(i->proplist, PA_PROP_DEVICE_DESCRIPTION); + debug_msg ("name=[%s], bus=[%s], desc=[%s]", i->name, bus, desc); + + if (g_alloc_device_id == -1) { + ret = MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_BLUETOOTH, DEVICE_IO_DIRECTION_BOTH, DEVICE_ID_AUTO, (desc)? desc : "NONAME", 0, &g_alloc_device_id); + if (ret != MM_ERROR_NONE) { + /* TODO : Error Handling */ + debug_error ("MMSoundMgrDeviceUpdateStatus failed....ret = [%x]", ret); + } + + } + ret = MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_IO_DIRECTION, DEVICE_TYPE_BLUETOOTH, DEVICE_IO_DIRECTION_OUT, g_alloc_device_id, (desc)? desc : "NONAME", 0, NULL); + if (ret != MM_ERROR_NONE) { + /* TODO : Error Handling */ + debug_error ("MMSoundMgrDeviceUpdateStatus failed....ret = [%x]", ret); + } + + /* Store BT index for future removal */ + pinfo->bt_idx = i->index; + ret = MMSoundMgrSessionSetDeviceAvailable (DEVICE_BT_A2DP, AVAILABLE, 0, (desc)? desc : "NONAME"); + if (ret != MM_ERROR_NONE) { + /* TODO : Error Handling */ + debug_error ("MMSoundMgrSessionSetDeviceAvailable failed....ret = [%x]", ret); + } - /* ToDo: Update Device */ - ret = MMSoundMgrSessionSetDeviceAvailable (DEVICE_BT_A2DP, AVAILABLE, 0, (desc)? desc : "NONAME"); - if (ret != MM_ERROR_NONE) { - /* TODO : Error Handling */ - debug_error ("MMSoundMgrSessionSetDeviceAvailable failed....ret = [%x]\n", ret); } + return; } static void context_subscribe_cb (pa_context * c, pa_subscription_event_type_t t, uint32_t idx, void *userdata) { - debug_msg (">>>>>>>>> [%s][%d] type=(0x%x) idx=(%u)\n", __func__, __LINE__, t, idx); + pulse_info_t *pinfo = (pulse_info_t *)userdata; + + if (pinfo == NULL) { + debug_error ("pinfo is null, return"); + return; + } if ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_CARD) { + debug_msg ("EVENT CARD : type=(0x%x) idx=(%u) pinfo=(%p)\n", t, idx, pinfo); /* FIXME: We assumed that card is bt, card new/remove = bt new/remove */ - - if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { /* BT is removed */ - /* ToDo: Update Device */ - //MMSoundMgrSessionSetDeviceBT (STATUS_NONE, NULL); - MMSoundMgrSessionSetDeviceAvailable (DEVICE_BT_A2DP, NOT_AVAILABLE, 0, NULL); - - } else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) { /* BT is loaded */ - /* Get Card info for BT name. Update device after that */ - pa_operation *o; - if (!(o = pa_context_get_card_info_by_index (c, idx, card_info_cb, NULL))) { - return; + if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { /* BT/USB is removed */ + if (idx == pinfo->bt_idx) { + pinfo->device_type = DEVICE_BT_A2DP; + g_async_queue_push(pinfo->queue, (gpointer)PA_CLIENT_SET_DEVICE_NOT_AVAILABLE); + } else if (idx == pinfo->usb_idx) { + pinfo->device_type = DEVICE_USB_AUDIO; + g_async_queue_push(pinfo->queue, (gpointer)PA_CLIENT_SET_DEVICE_NOT_AVAILABLE); + } else if (idx == pinfo->dock_idx) { + pinfo->device_type = DEVICE_MULTIMEDIA_DOCK; + g_async_queue_push(pinfo->queue, (gpointer)PA_CLIENT_SET_DEVICE_NOT_AVAILABLE); + } else { + debug_warning ("Unexpected card index [%d] is removed. (Current bt index=[%d], usb index=[%d], dock index=[%d]", idx, pinfo->bt_idx, pinfo->usb_idx, pinfo->dock_idx); } - pa_operation_unref(o); - + } else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) { /* BT/USB is loaded */ + /* Get more additional information for this card */ + pinfo->card_idx = idx; + g_async_queue_push(pinfo->queue, (gpointer)PA_CLIENT_GET_CARD_INFO_BY_INDEX); } - } else if ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SERVER) { - - pa_operation_unref(pa_context_get_server_info(c, server_info_cb, NULL)); - - + debug_msg ("EVENT SERVER : type=(0x%x) idx=(%u) pinfo=(%p)\n", t, idx, pinfo); +#ifndef TIZEN_MICRO + /* FIXME : This cause crash on TIZEN_MICRO, to be removed completely */ + g_async_queue_push(pinfo->queue, (gpointer)PA_CLIENT_GET_SERVER_INFO); +#endif } else { - debug_msg ("[%s][%d] type=(0x%x) idx=(%u) is not card or server event, skip...\n", __func__, __LINE__, t, idx); + debug_msg ("type=(0x%x) idx=(%u) is not card or server event, skip...\n", t, idx); return; } } - static void context_state_cb (pa_context *c, void *userdata) { pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + switch (pa_context_get_state(c)) { case PA_CONTEXT_UNCONNECTED: case PA_CONTEXT_CONNECTING: case PA_CONTEXT_AUTHORIZING: case PA_CONTEXT_SETTING_NAME: + break; case PA_CONTEXT_FAILED: + { + // wait for pa_ready file creation. + int fd = -1; + + do { + fd = open(PA_READY, O_RDONLY); + if(fd < 0) { + usleep(20000); + } + } while(fd < 0); + close(fd); + + debug_error("pulseaudio crash!! sound_server will be restart!!"); + kill(getpid(), SIGKILL); + } + break; case PA_CONTEXT_TERMINATED: + pa_threaded_mainloop_signal(pinfo->m, 0); break; case PA_CONTEXT_READY: - { - if (pinfo->context == c) { + pa_threaded_mainloop_signal(pinfo->m, 0); + break; + } +} - /* Do CARD and SERVER Subscribe */ - pa_context_set_subscribe_callback(c, context_subscribe_cb, pinfo); - pa_operation *o; - if (!(o = pa_context_subscribe(c, (pa_subscription_mask_t)PA_SUBSCRIPTION_MASK_CARD | PA_SUBSCRIPTION_MASK_SERVER, NULL, NULL))) { - return; +void *pulse_client_thread_run (void *args) +{ + pulse_info_t *pinfo = (pulse_info_t*)args; + pa_operation *o = NULL; + pa_client_command_t cmd = PA_CLIENT_NOT_USED; + + while(1) + { + cmd = (pa_client_command_t)g_async_queue_pop(pinfo->queue); + debug_msg("pop cmd = [%d][%s]", cmd, command_str[cmd]); + if(cmd <= PA_CLIENT_NOT_USED || cmd >= PA_CLIENT_MAX) { + continue; + } + if ((pa_client_command_t)cmd == PA_CLIENT_SET_DEVICE_NOT_AVAILABLE) { + if (pinfo->device_type == DEVICE_BT_A2DP) { + debug_msg("DEVICE_BT_A2DP"); + MMSoundMgrSessionSetDeviceAvailable (DEVICE_BT_A2DP, NOT_AVAILABLE, 0, NULL); + if (g_alloc_device_id != -1) { + device_io_direction_e prev_io_direction; + MMSoundMgrDeviceGetIoDirectionById (g_alloc_device_id, &prev_io_direction); + if (prev_io_direction == MM_SOUND_DEVICE_IO_DIRECTION_OUT) { + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_IO_DIRECTION, DEVICE_TYPE_BLUETOOTH, MM_SOUND_DEVICE_IO_DIRECTION_BOTH, g_alloc_device_id, NULL, 0, 0); + } + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_DISCONNECTED, DEVICE_TYPE_BLUETOOTH, MM_SOUND_DEVICE_IO_DIRECTION_BOTH, g_alloc_device_id, NULL, 0, 0); + g_alloc_device_id = -1; } - pa_operation_unref(o); + pinfo->bt_idx = PA_INVALID_INDEX; + pinfo->device_type = PA_INVALID_INDEX; + } else if(pinfo->device_type == DEVICE_USB_AUDIO) { + debug_msg("DEVICE_USB_AUDIO"); + MMSoundMgrSessionSetDeviceAvailable (DEVICE_USB_AUDIO, NOT_AVAILABLE, 0, NULL); + device_io_direction_e io_direction = DEVICE_IO_DIRECTION_OUT; + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_DISCONNECTED, DEVICE_TYPE_USB_AUDIO, io_direction, DEVICE_ID_AUTO, NULL, 0, NULL); + pinfo->usb_idx = PA_INVALID_INDEX; + pinfo->device_type = PA_INVALID_INDEX; + if (pinfo->usb_sink_name) { + free(pinfo->usb_sink_name); + pinfo->usb_sink_name = NULL; + } + } else if(pinfo->device_type == DEVICE_MULTIMEDIA_DOCK) { + debug_msg("DEVICE_MULTIMEDIA_DOCK"); + MMSoundMgrSessionSetDeviceAvailable (DEVICE_MULTIMEDIA_DOCK, NOT_AVAILABLE, 0, NULL); + pinfo->dock_idx = PA_INVALID_INDEX; + pinfo->device_type = PA_INVALID_INDEX; + if (pinfo->dock_sink_name) { + free(pinfo->dock_sink_name); + pinfo->dock_sink_name = NULL; + } + } + continue; + } + pa_threaded_mainloop_lock(pinfo->m); + CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail); - pa_operation_unref(pa_context_get_card_info_list (pinfo->context, init_card_info_cb, pinfo)); + switch((pa_client_command_t)cmd) + { + case PA_CLIENT_GET_CARD_INFO_BY_INDEX: + debug_msg("new card(usb/a2dp) detected."); + o = pa_context_get_card_info_by_index (pinfo->context, pinfo->card_idx, new_card_info_cb, pinfo); + break; + + case PA_CLIENT_GET_SERVER_INFO: + o = pa_context_get_server_info(pinfo->context, server_info_cb, pinfo); + break; + + case PA_CLIENT_DESTROY: + goto destroy; + /* FALL THROUGH */ + default: + debug_msg("unsupported command\n"); + goto unlock_and_fail; + /* FALL THROUGH */ + } - /* signaling will be done after get card info in card info callback */ - } - break; + CHECK_CONTEXT_SUCCESS_GOTO(pinfo->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pinfo->m); + CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail); + } + pa_operation_unref(o); + pa_threaded_mainloop_unlock(pinfo->m); + + continue; + +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); } + pa_threaded_mainloop_unlock(pinfo->m); } + + return 0; + +destroy: + pa_threaded_mainloop_unlock(pinfo->m); + + return 0; } +static int pulse_client_thread_init(pulse_info_t *pinfo) +{ + debug_msg("\n"); + + pinfo->queue = g_async_queue_new(); + if(!pinfo->queue) { + return -1; + } + + if(pthread_create(&pinfo->thread, NULL, pulse_client_thread_run, pinfo) < 0) { + return -1; + } + + return 0; +} static int pulse_init (pulse_info_t * pinfo) { int res; + pa_operation *o = NULL; + + debug_msg (">>>>>>>>> \n"); - debug_msg (">>>>>>>>> [%s][%d]\n", __func__, __LINE__); + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return -1; + } /* Create new mainloop */ pinfo->m = pa_threaded_mainloop_new(); @@ -228,10 +563,7 @@ static int pulse_init (pulse_info_t * pinfo) } for (;;) { - pa_context_state_t state; - - state = pa_context_get_state (pinfo->context); - + pa_context_state_t state = pa_context_get_state (pinfo->context); debug_msg ("context state is now %d\n", state); if (!PA_CONTEXT_IS_GOOD (state)) { @@ -239,58 +571,63 @@ static int pulse_init (pulse_info_t * pinfo) break; } - if (state == PA_CONTEXT_READY) + if (state == PA_CONTEXT_READY) { break; + } /* Wait until the context is ready */ debug_msg ("waiting..................\n"); pa_threaded_mainloop_wait (pinfo->m); } - /* UNLOCK thread */ - pa_threaded_mainloop_unlock (pinfo->m); + pa_context_set_subscribe_callback(pinfo->context, context_subscribe_cb, pinfo); + o = pa_context_subscribe(pinfo->context, + (pa_subscription_mask_t)PA_SUBSCRIPTION_MASK_CARD | PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SERVER, + pa_context_subscribe_success_cb,pinfo); - debug_msg ("<<<<<<<<<< [%s][%d]\n", __func__, __LINE__); + CHECK_CONTEXT_SUCCESS_GOTO(pinfo->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pinfo->m); + CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail); + } + pa_operation_unref(o); - return res; -} + /* Get initial card info */ + o = pa_context_get_card_info_list (pinfo->context, init_card_info_cb, pinfo); + CHECK_CONTEXT_SUCCESS_GOTO(pinfo->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pinfo->m); + CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail); + } + pa_operation_unref(o); -static void sink_info_cb (pa_context *c, const pa_sink_info *i, int is_last, void *userdata) -{ - pulse_info_t * pinfo = (pulse_info_t *)userdata; + /* UNLOCK thread */ + pa_threaded_mainloop_unlock (pinfo->m); - if (is_last || i == NULL || pinfo == NULL) { - if (is_last < 0) { - debug_error("Failed to get sink information: %s\n", pa_strerror(pa_context_errno(c))); - } - return; - } + debug_msg ("<<<<<<<<<<\n"); - if (i->name && i->proplist) { - const char *api_string = pa_proplist_gets (i->proplist, "device.api"); - if (api_string) { - debug_log ("sink name = [%s], api = [%s]\n", i->name, api_string); - if (strcmp (api_string, pinfo->sink_to_find) == 0) { - debug_log ("FOUND!!! set default sink to [%s]\n", i->name); - pa_operation_unref(pa_context_set_default_sink(pinfo->context, i->name, NULL, NULL)); + return res; - } else { - debug_warning ("No string [%s] match!!!!\n", pinfo->sink_to_find); - } - } +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); } -} + pa_threaded_mainloop_unlock(pinfo->m); + debug_msg ("<<<<<<<<<<\n"); -static void pulse_set_default_sink (pulse_info_t * pinfo, char *default_sink_name) -{ - strcpy (pinfo->sink_to_find, default_sink_name); - pa_operation_unref(pa_context_get_sink_info_list(pinfo->context, sink_info_cb, pinfo)); + return res; } static int pulse_deinit (pulse_info_t * pinfo) { + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return -1; + } + pa_threaded_mainloop_lock (pinfo->m); if (pinfo->context) { pa_context_disconnect (pinfo->context); @@ -306,154 +643,2057 @@ static int pulse_deinit (pulse_info_t * pinfo) pa_threaded_mainloop_stop (pinfo->m); pa_threaded_mainloop_free (pinfo->m); - debug_msg ("<<<<<<<<<< [%s][%d]\n", __func__, __LINE__); + debug_msg ("<<<<<<<<<<\n"); return 0; } +#ifdef _TIZEN_PUBLIC_ +#define AEC_ARGUMENT "aec_method=speex" +#else +#define AEC_ARGUMENT "aec_method=lvvefs sink_master=alsa_output.0.analog-stereo source_master=alsa_input.0.analog-stereo" +#endif + +static void unload_hdmi_cb(pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg ("[PA_CB] m[%p] c[%p] HDMI unload success", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] HDMI unload fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } + + pa_threaded_mainloop_signal(pinfo->m, 0); +} + /* -------------------------------- MONO AUDIO --------------------------------------------*/ #ifdef SUPPORT_MONO_AUDIO -#define MONO_KEY VCONFKEY_SETAPPL_ACCESSIBILITY_MONO_AUDIO +#define TOUCH_SOUND_PLAY_COMLETE_TIME 50000 -static void success_cb (pa_context *c, int success, void *userdata) +static void set_mono_cb (pa_context *c, int success, void *userdata) { - debug_msg ("success = %d\n", success); + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg ("[PA_CB] m[%p] c[%p] set mono success", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] set mono fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } + pa_threaded_mainloop_signal(pinfo->m, 0); } static void mono_changed_cb(keynode_t* node, void* data) { int key_value; + pa_operation *o = NULL; pulse_info_t* pinfo = (pulse_info_t*)data; - debug_msg ("%s changed callback called\n",vconf_keynode_get_name(node)); + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + vconf_get_bool(VCONF_KEY_MONO_AUDIO, &key_value); + debug_msg ("%s changed callback called, key value = %d\n",vconf_keynode_get_name(node), key_value); + /*for make sure touch sound play complete*/ + usleep(TOUCH_SOUND_PLAY_COMLETE_TIME); - vconf_get_bool(MONO_KEY, &key_value); - debug_msg ("key value = %d\n", key_value); + pa_threaded_mainloop_lock(pinfo->m); + CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail); - pa_operation_unref (pa_ext_policy_set_mono (pinfo->context, key_value, success_cb, NULL)); + debug_msg("[PA] pa_ext_policy_set_mono m[%p] c[%p] mono:%d", pinfo->m, pinfo->context, key_value); + o = pa_ext_policy_set_mono (pinfo->context, key_value, set_mono_cb, pinfo); + CHECK_CONTEXT_SUCCESS_GOTO(pinfo->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pinfo->m); + CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail); + } + pa_operation_unref(o); + + pa_threaded_mainloop_unlock(pinfo->m); + return; + +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + pa_threaded_mainloop_unlock(pinfo->m); } int MMSoundMgrPulseHandleRegisterMonoAudio (void* pinfo) { - int ret = vconf_notify_key_changed(MONO_KEY, mono_changed_cb, pinfo); - debug_msg ("vconf [%s] set ret = %d\n", MONO_KEY, ret); + int ret = vconf_notify_key_changed(VCONF_KEY_MONO_AUDIO, mono_changed_cb, pinfo); + debug_msg ("vconf [%s] set ret = %d\n", VCONF_KEY_MONO_AUDIO, ret); return ret; } #endif /* SUPPORT_MONO_AUDIO */ +/* -------------------------------- Audio Balance --------------------------------------------*/ +#ifdef SUPPORT_AUDIO_BALANCE +static void set_balance_cb (pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } -/* -------------------------------- BT SCO --------------------------------------------*/ -#ifdef SUPPORT_BT_SCO_DETECT + if (success) { + debug_msg ("[PA_CB] m[%p] c[%p] set balance success", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] set balance fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } + pa_threaded_mainloop_signal(pinfo->m, 0); +} -static void bt_changed_cb(keynode_t* node, void* data) +static void _balance_changed_cb(keynode_t* node, void* data) { - int bt_status = VCONFKEY_BT_DEVICE_NONE; - int available = 0; + double balance_value; pulse_info_t* pinfo = (pulse_info_t*)data; + pa_operation *o = NULL; + + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } - debug_msg ("[%s] changed callback called\n", vconf_keynode_get_name(node)); + vconf_get_dbl(VCONF_KEY_VOLUME_BALANCE, &balance_value); + debug_msg ("%s changed callback called, balance value = %f\n",vconf_keynode_get_name(node), balance_value); - /* Get actual vconf value */ - vconf_get_int(VCONFKEY_BT_DEVICE, &bt_status); - debug_msg ("key value = 0x%x\n", bt_status); + pa_threaded_mainloop_lock(pinfo->m); + CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail); - /* Set device available based on vconf key value */ - available = (bt_status & VCONFKEY_BT_DEVICE_HEADSET_CONNECTED)? AVAILABLE : NOT_AVAILABLE; - MMSoundMgrSessionSetDeviceAvailable (DEVICE_BT_SCO, available, 0, NULL); + debug_msg("[PA] pa_ext_policy_set_balance m[%p] c[%p] balance:%.2f", pinfo->m, pinfo->context, balance_value); + o = pa_ext_policy_set_balance (pinfo->context, &balance_value, set_balance_cb, pinfo); + CHECK_CONTEXT_SUCCESS_GOTO(pinfo->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pinfo->m); + CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail); + } + pa_operation_unref(o); + + pa_threaded_mainloop_unlock(pinfo->m); + return; + +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + pa_threaded_mainloop_unlock(pinfo->m); } -int MMSoundMgrPulseHandleRegisterBluetoothStatus (void* pinfo) +int MMSoundMgrPulseHandleRegisterAudioBalance (void* pinfo) { - /* set callback for vconf key change */ - int ret = vconf_notify_key_changed(VCONFKEY_BT_DEVICE , bt_changed_cb, pinfo); - debug_msg ("vconf [%s] set ret = %d\n", VCONFKEY_BT_DEVICE, ret); + int ret = vconf_notify_key_changed(VCONF_KEY_VOLUME_BALANCE, _balance_changed_cb, pinfo); + debug_msg ("vconf [%s] set ret = %d\n", VCONF_KEY_VOLUME_BALANCE, ret); return ret; } -#endif /* SUPPORT_BT_SCO_DETECT */ - -/* -------------------------------- MGR MAIN --------------------------------------------*/ -int MMSoundMgrPulseHandleIsBtA2DPOnReq (mm_ipc_msg_t *msg, int (*sendfunc)(mm_ipc_msg_t*)) +void MMSoundMgrPulseHandleResetAudioBalanceOnBoot(void* data) { - int ret = 0; - mm_ipc_msg_t respmsg = {0,}; - char* bt_name; - bool is_bt_on = false; - pthread_mutex_lock(&g_mutex); - - debug_enter("msg = %p, sendfunc = %p\n", msg, sendfunc); + double balance_value; + pulse_info_t* pinfo = (pulse_info_t*)data; + pa_operation *o = NULL; - bt_name = MMSoundMgrSessionGetBtA2DPName(); - if (bt_name && strlen(bt_name) > 0) { - is_bt_on = true; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; } - debug_log ("is_bt_on = [%d], name = [%s]\n", is_bt_on, bt_name); + if (vconf_get_dbl(VCONF_KEY_VOLUME_BALANCE, &balance_value)) { + debug_error ("vconf_get_dbl(VCONF_KEY_VOLUME_BALANCE) failed..\n"); + balance_value = 0; + vconf_set_dbl(VCONF_KEY_VOLUME_BALANCE, balance_value); + } else { + pa_threaded_mainloop_lock(pinfo->m); + CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail); + + debug_msg("[PA] pa_ext_policy_set_balance m[%p] c[%p] balance:%.2f", pinfo->m, pinfo->context, balance_value); + o = pa_ext_policy_set_balance (pinfo->context, &balance_value, set_balance_cb, pinfo); + CHECK_CONTEXT_SUCCESS_GOTO(pinfo->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pinfo->m); + CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail); + } + pa_operation_unref(o); - SOUND_MSG_SET(respmsg.sound_msg, - MM_SOUND_MSG_RES_IS_BT_A2DP_ON, msg->sound_msg.handle, is_bt_on, msg->sound_msg.msgid); - strncpy (respmsg.sound_msg.filename, bt_name, sizeof (respmsg.sound_msg.filename)-1); + pa_threaded_mainloop_unlock(pinfo->m); + } + return; - /* Send Response */ - ret = sendfunc (&respmsg); - if (ret != MM_ERROR_NONE) { - /* TODO : Error Handling */ - debug_error ("sendfunc failed....ret = [%x]\n", ret); +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); } + pa_threaded_mainloop_unlock(pinfo->m); +} +#endif /* SUPPORT_AUDIO_BALANCE */ - pthread_mutex_unlock(&g_mutex); - debug_leave("\n"); +#ifdef SUPPORT_AUDIO_MUTEALL +static void set_muteall_cb (pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } - return ret; + if (success) { + debug_msg ("[PA_CB] m[%p] c[%p] set muteall success", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] set muteall fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } + pa_threaded_mainloop_signal(pinfo->m, 0); } -void MMSoundMgrPulseSetDefaultSink (char* default_sink_name) +static void _muteall_changed_cb(keynode_t* node, void* data) { - debug_enter("\n"); + int key_value; + int i; + pulse_info_t* pinfo = (pulse_info_t*)data; + pa_operation *o = NULL; - pulse_set_default_sink(pulse_info, default_sink_name); + if (pinfo == NULL) { + debug_error ("pinfo is null\n"); + return; + } - debug_leave("\n"); -} + vconf_get_int(VCONF_KEY_MUTE_ALL, &key_value); + debug_msg ("%s changed callback called, muteall value = %d\n", vconf_keynode_get_name(node), key_value); -void MMSoundMgrPulseGetInitialBTStatus (bool *a2dp, bool *sco) -{ - int bt_status = VCONFKEY_BT_DEVICE_NONE; + mm_sound_mute_all(key_value); - if (a2dp == NULL || sco == NULL) { - debug_error ("Invalide arguments!!!\n"); - return; + pa_threaded_mainloop_lock(pinfo->m); + CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail); + + debug_msg("[PA] pa_ext_policy_set_muteall m[%p] c[%p] muteall:%d", pinfo->m, pinfo->context, key_value); + o = pa_ext_policy_set_muteall (pinfo->context, key_value, set_muteall_cb, pinfo); + CHECK_CONTEXT_SUCCESS_GOTO(pinfo->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pinfo->m); + CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail); } + pa_operation_unref(o); - /* Get saved bt status */ - *a2dp = pulse_info->init_bt_status; + pa_threaded_mainloop_unlock(pinfo->m); - /* Get actual vconf value */ - vconf_get_int(VCONFKEY_BT_DEVICE, &bt_status); - debug_msg ("key value = 0x%x\n", bt_status); - *sco = (bt_status & VCONFKEY_BT_DEVICE_HEADSET_CONNECTED)? true : false; + if (!key_value) { + for (i =0;im); } -void* MMSoundMgrPulseInit(void) +int MMSoundMgrPulseHandleRegisterAudioMuteall (void* pinfo) { - pulse_info = (pulse_info_t*) malloc (sizeof(pulse_info_t)); - memset (pulse_info, 0, sizeof(pulse_info_t)); + int ret = vconf_notify_key_changed(VCONF_KEY_MUTE_ALL, _muteall_changed_cb, pinfo); + debug_msg ("vconf [%s] set ret = %d\n", VCONF_KEY_MUTE_ALL, ret); + return ret; +} - debug_enter("\n"); +void MMSoundMgrPulseHandleResetAudioMuteallOnBoot(void* data) +{ + int key_value; + pulse_info_t* pinfo = (pulse_info_t*)data; + pa_operation *o = NULL; - pulse_init(pulse_info); + if (pinfo == NULL) { + debug_error ("pinfo is null\n"); + return; + } -#ifdef SUPPORT_MONO_AUDIO - MMSoundMgrPulseHandleRegisterMonoAudio(pulse_info); -#endif + if (vconf_get_int(VCONF_KEY_MUTE_ALL, &key_value)) { + debug_error ("vconf_get_int(VCONF_KEY_MUTE_ALL) failed..\n"); + key_value = 0; + vconf_set_int(VCONF_KEY_MUTE_ALL, key_value); + } else { + mm_sound_mute_all(key_value); + + pa_threaded_mainloop_lock(pinfo->m); + CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail); + + debug_msg("[PA] pa_ext_policy_set_muteall m[%p] c[%p] muteall:%d", pinfo->m, pinfo->context, key_value); + o = pa_ext_policy_set_muteall (pinfo->context, key_value, set_muteall_cb, pinfo); + CHECK_CONTEXT_SUCCESS_GOTO(pinfo->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pinfo->m); + CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail); + } + pa_operation_unref(o); + + pa_threaded_mainloop_unlock(pinfo->m); + } + return; + +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + pa_threaded_mainloop_unlock(pinfo->m); +} +#endif /* SUPPORT_AUDIO_MUTEALL */ + +/* -------------------------------- BT SCO --------------------------------------------*/ +#ifdef SUPPORT_BT_SCO_DETECT + +bool MMSoundMgrPulseBTSCOWBStatus() +{ + int ret = 0; + bool is_wb_enabled = 0; + bool sco_on = 1; + + /* BT Api support thread safty */ + debug_log ("Get WB status"); +#ifdef BT_THREAD_SAFTY_SUPPORT + ret = bt_ag_is_sco_opened(&sco_on); + if (ret != BT_ERROR_NONE) { + debug_error("SCO is not opened [%d]", sco_on); + } +#endif + + /* Check enabled if opened */ + if (sco_on) { + /* FIXME : check with product api of bluetooth */ + } + return is_wb_enabled; +} + +bool MMSoundMgrPulseBTSCONRECStatus() +{ + int ret = 0; + bool is_nrec_enabled = 0; + bool sco_on = 1; + + /* BT Api support thread safty */ + debug_log ("Get NREC status"); +#ifdef BT_THREAD_SAFTY_SUPPORT + ret = bt_ag_is_sco_opened(&sco_on); + if (ret != BT_ERROR_NONE) { + debug_error("SCO is not opened [%d]", sco_on); + } +#endif + + /* Check enabled if opened */ + if (sco_on) { + ret = bt_ag_is_nrec_enabled (&is_nrec_enabled); + if (ret != BT_ERROR_NONE) { + debug_error ("Fail to get nrec status [%d]", ret); + } + } + return is_nrec_enabled; +} + +void MMSoundMgrPulseUpdateBluetoothAGCodec(void) +{ + int ret = 0; + bool is_nrec_enabled = 0; + bool is_wb_enabled = 0; + bool sco_on = 1; + + /* BT Api support thread safty */ + debug_log ("Updating BT SCO info"); +#ifdef BT_THREAD_SAFTY_SUPPORT + ret = bt_ag_is_sco_opened(&sco_on); + if (ret != BT_ERROR_NONE) { + debug_error("SCO is not opened [%d]", sco_on); + } +#endif + + /* Check NREC enabled if opened */ + if (sco_on) { + ret = bt_ag_is_nrec_enabled (&is_nrec_enabled); + if (ret != BT_ERROR_NONE) { + debug_error ("Fail to get nrec status [%d]", ret); + } + /* FIXME : check with product api of bluetooth */ + } + + debug_warning("BT SCO info :: sco[%d], is_nrec_enabled[%d], is_wb_enabled[%d]", sco_on, is_nrec_enabled, is_wb_enabled); + MMSoundMgrSessionSetSCO (sco_on, is_nrec_enabled, is_wb_enabled); +} + +static void __bt_audio_connection_state_changed_cb(int result, + bool connected, const char *remote_address, + bt_audio_profile_type_e type, void *user_data) +{ + /* 0 : BT_AUDIO_PROFILE_TYPE_ALL + 1 : BT_AUDIO_PROFILE_TYPE_HSP_HFP + 2 : BT_AUDIO_PROFILE_TYPE_A2DP + 3 : BT_AUDIO_PROFILE_TYPE_AG */ + + const static char * type_str[4] = { "ALL", "HSP/HFP", "A2DP", "AG" }; + int length = sizeof(type_str) / sizeof(char*); + pulse_info_t* pinfo = (pulse_info_t*)user_data; + + if(pinfo->ag_init == true) { + if (type > length) { + debug_warning("Not supportted bt audio profile type. type(%d)\n", type); + return; + } + + debug_msg("connection state changed. connected(%s), type(%s), address(%s), result(%d)\n", + connected == true ? "connected" : "disconnected", + (type >= 0 && type < length) ? type_str[type] : "unknown type", + remote_address != NULL ? remote_address : "NULL", result); + + /* Set SCO Device available */ + if (type == BT_AUDIO_PROFILE_TYPE_HSP_HFP) { + device_io_direction_e io_direction = DEVICE_IO_DIRECTION_BOTH; + if (connected && (g_alloc_device_id == -1) ) { + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_BLUETOOTH, io_direction, DEVICE_ID_AUTO, NULL, 0, &g_alloc_device_id); + } + MMSoundMgrSessionSetDeviceAvailable (DEVICE_BT_SCO, connected, 0, NULL); + + if (!connected && (g_alloc_device_id != -1)) { + int ret = MM_ERROR_NONE; + device_io_direction_e prev_io_direction; + ret = MMSoundMgrDeviceGetIoDirectionById (g_alloc_device_id, &prev_io_direction); + if (prev_io_direction == MM_SOUND_DEVICE_IO_DIRECTION_OUT) { + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_IO_DIRECTION, DEVICE_TYPE_BLUETOOTH, MM_SOUND_DEVICE_IO_DIRECTION_BOTH, g_alloc_device_id, NULL, 0, 0); + } + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_DISCONNECTED, DEVICE_TYPE_BLUETOOTH, MM_SOUND_DEVICE_IO_DIRECTION_BOTH, g_alloc_device_id, NULL, 0, 0); + g_alloc_device_id = -1; + } + } + debug_msg("connection state changed end\n"); + } else + debug_msg("bt ag-sco is not ready. ag_init(%d)\n", pinfo->ag_init); + +} + +static void __bt_ag_sco_state_changed_cb(int result, bool opened, void *user_data) +{ + session_t session = 0; + pulse_info_t* pinfo = (pulse_info_t*)user_data; + + debug_msg("bt ag-sco state changed. opend(%d), ag_init(%d)\n", opened, pinfo->ag_init); + + if(pinfo->ag_init == true) { + MMSoundMgrSessionGetSession(&session); + if (session == SESSION_VOICECALL) { + debug_warning("SESSION(SESSION_VOICECALL), we don't handle sco stat in call session. sound-path should be routed in active device function by call app\n"); + return; + } + + MMSoundMgrSessionEnableAgSCO (opened); + } else + debug_msg ("bt ag-sco is not ready. opened(%d), ag_init(%d)\n", pinfo->ag_init); + +} + +static int __bt_ag_initialize(pulse_info_t* pinfo) +{ + int ret = 0; + + debug_msg("__bt_ag_initialize start"); + + ret = bt_audio_initialize(); + if (ret != BT_ERROR_NONE) { + debug_error ("bt_audio_initialize error!!! [%d]", ret); + goto FAIL; + } + + ret = bt_audio_set_connection_state_changed_cb(__bt_audio_connection_state_changed_cb, pinfo); + if (ret != BT_ERROR_NONE) { + debug_error ("bt_audio_set_connection_state_changed_cb error!!! [%d]", ret); + goto FAIL; + } + + ret = bt_ag_set_sco_state_changed_cb(__bt_ag_sco_state_changed_cb, pinfo); + if (ret != BT_ERROR_NONE) { + debug_error ("bt_ag_set_sco_state_changed_cb error!!! [%d]", ret); + goto FAIL; + } + + debug_msg("__bt_ag_initialize success"); + +FAIL: + debug_error("__bt_ag_initialize failed(%d)", ret); + return ret; +} + +static int __bt_ag_deinitialize(pulse_info_t* pinfo) +{ + int ret = 0; + + debug_msg("__bt_ag_deinitialize start"); + + ret = bt_audio_unset_connection_state_changed_cb(); + if (ret != BT_ERROR_NONE) { + debug_error ("bt_audio_unset_connection_state_changed_cb error!!! [%d]", ret); + goto FAIL; + } + ret = bt_ag_unset_sco_state_changed_cb(); + if (ret != BT_ERROR_NONE) { + debug_error ("bt_ag_unset_sco_state_changed_cb error!!! [%d]", ret); + goto FAIL; + } + ret = bt_audio_deinitialize(); + if (ret != BT_ERROR_NONE) { + debug_error ("bt_audio_deinitialize error!!! [%d]", ret); + goto FAIL; + } + + debug_msg("__bt_ag_deinitialize success"); + +FAIL: + debug_warning("__bt_ag_deinitialize failed. ret(%d)", ret); + return ret; +} + +#ifdef TIZEN_MICRO +void _speaker_volume_changed_cb() +{ + unsigned int vconf_value = 0; + int ret = 0; + session_t cur_session = 0; + float ratio = 0.0f; + float client_vol_max = CLIENT_VOLUME_MAX; + int voltype = VOLUME_TYPE_CALL; + int max_vol = 0; + int native_vol = 0; + int client_vol = 0; + + int mapping_table[2][9] = { + {0, 0, 3, 9, 11, 13, 15, 15, 15}, // call volume max : 6 + {0, 0, 3, 6, 9, 8, 10, 13, 15} // call volume max: 8 + }; + + if(g_bt_hf_volume_control) { + g_bt_hf_volume_control = 0; + return; + } + + /* In case of changing vconf key call/voip volume by pulse audio */ + ret = MMSoundMgrSessionGetSession(&cur_session); + if(ret) + debug_warning("Fail to get current session"); + + if(cur_session == SESSION_VOICECALL) { + ret = _mm_sound_volume_get_value_by_type(VOLUME_TYPE_CALL, &vconf_value); + voltype = VOLUME_TYPE_CALL; + } else if(cur_session == SESSION_VOIP) { + ret = _mm_sound_volume_get_value_by_type(VOLUME_TYPE_VOIP, &vconf_value); + voltype = VOLUME_TYPE_VOIP; + } else { + debug_warning("Invalid volume control by [%d] session", cur_session); + return; + } + + if(ret) { + debug_warning("Fail to get volume value %x", ret); + return; + } + + if(MM_ERROR_NONE != mm_sound_volume_get_step(voltype, &max_vol)) { + debug_warning("get volume max failed. voltype(%d)\n", voltype); + return; + } + + native_vol = vconf_value; + + /* limitation : should be matched between client volume 9 to native volume and + native volume to client volume 9 for BLUETOOTH certification.*/ + if(max_vol >= 9) { + client_vol = mapping_table[1][native_vol]; + } else { + client_vol = mapping_table[0][native_vol]; + } + + /* Set in case of control by application */ + ret = bluetooth_hf_set_speaker_gain(client_vol); + if(ret) + debug_warning("Set bt hf speaker gain failed %x", ret); + + debug_msg("send paired device volume change msg by BT. voltype(%d), native_vol(%d), client_vol(%d), max_vol(%d)", + voltype, native_vol, client_vol, max_vol); +} + +static int __bt_hf_enable_volume_changed_cb(int enable) +{ + if(enable) { + if(vconf_notify_key_changed(VCONF_KEY_VOLUME_TYPE_CALL, _speaker_volume_changed_cb, NULL)) { + debug_error("vconf_notify_key_changed fail\n"); + } + if(vconf_notify_key_changed(VCONF_KEY_VOLUME_TYPE_VOIP, _speaker_volume_changed_cb, NULL)) { + debug_error("vconf_notify_key_changed fail\n"); + } + } else { + if(vconf_ignore_key_changed(VCONF_KEY_VOLUME_TYPE_CALL, _speaker_volume_changed_cb)) { + debug_error("vconf_ignore_key_changed fail\n"); + } + if(vconf_ignore_key_changed(VCONF_KEY_VOLUME_TYPE_VOIP, _speaker_volume_changed_cb)) { + debug_error("vconf_ignore_key_changed fail\n"); + } + } + return 0; +} + +static int _bt_hf_set_volume_by_client(const unsigned int vol) +{ + session_t session; + volume_type_t voltype = VOLUME_TYPE_CALL; + float ratio = 0; + int native_vol = 0; + int max_vol = 0; + int ret = MM_ERROR_NONE; + + int mapping_table[2][16] = { + { 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6 }, // call volume max : 6 + { 1, 1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 8 } // call volume max: 8 + }; + + ret = MMSoundMgrSessionGetSession(&session); + if(ret) + debug_warning("Fail to get session\ns"); + + if(session != SESSION_VOICECALL && session != SESSION_VOIP) { + debug_warning("session is not voice/voip. we handle only voice/voip volume. session(%s)\n", + MMSoundMgrSessionGetSessionString(session)); + return MM_ERROR_NONE; + } else { + if(session == SESSION_VOICECALL) + voltype = VOLUME_TYPE_CALL; + else + voltype = VOLUME_TYPE_VOIP; + } + + if(MM_ERROR_NONE != mm_sound_volume_get_step(voltype, &max_vol)) { + debug_warning("get volume max failed. voltype(%d)\n", voltype); + } + + /* limitation : should be matched between client volume 9 to native volume 3 and + native volume 3 to client volume 9 for BLUETOOTH certification.*/ + if(max_vol >= 9) { + native_vol = mapping_table[1][vol]; + } else { + native_vol = mapping_table[0][vol]; + } + + /* we should check volume change callback for voice/voip. + because hf client device(me) send paired device volume changed message again. */ + g_bt_hf_volume_control = 1; + _mm_sound_volume_set_value_by_type(voltype, native_vol); + MMSoundMgrPulseSetVolumeLevel(voltype, native_vol); + + debug_msg("set volume by HF client. voltype(%d), client_vol(%d), native_vol(%d), max_vol(%d)\n", + voltype, vol, native_vol, max_vol); + + return ret; +} + +void _bt_hf_cb (int event, bt_hf_event_param_t *event_param, void * user_data) +{ + unsigned int vol_value = 0; + char str_message[256]; + int ret = 0; + unsigned int codec_id; + subsession_t sub = 0; + + if (event_param == NULL) { + debug_critical("Param data is NULL\n"); + return; + } + + sprintf (str_message, "HF event : [0x%04x], event_param : 0x%p, user_data : 0x%p", event, event_param, user_data); + + switch (event) { + case BLUETOOTH_EVENT_HF_CONNECTED: + /* get WB capability here and set */ + ret = bluetooth_hf_get_codec(&codec_id); + if (ret == BLUETOOTH_ERROR_NONE) { + switch (codec_id) { + case BLUETOOTH_CODEC_ID_CVSD: /* NB */ + g_bt_hf_sco_nb = 1; + MMSoundMgrSessionSetHFBandwidth (MM_SOUND_BANDWIDTH_NB); + break; + case BLUETOOTH_CODEC_ID_MSBC: /* WB */ + g_bt_hf_sco_nb = 0; + MMSoundMgrSessionSetHFBandwidth (MM_SOUND_BANDWIDTH_WB); + break; + default: + break; + } + } + MMSoundMgrSessionSetHFPConnectionState(MM_SOUND_HFP_STATUS_UNKNOWN); + debug_msg("%s >> %s", str_message, "BLUETOOTH_EVENT_HF_CONNECTED"); + break; + + case BLUETOOTH_EVENT_HF_DISCONNECTED: + MMSoundMgrSessionSetHFPConnectionState(MM_SOUND_HFP_STATUS_UNKNOWN); + debug_msg("%s >> %s", str_message, "BLUETOOTH_EVENT_HF_DISCONNECTED"); + break; + + case BLUETOOTH_EVENT_HF_CALL_STATUS: + { + bt_hf_call_list_s * call_list = event_param->param_data; + bt_hf_call_status_info_t **call_info; + int i = 0; + + if (call_list == NULL) { + debug_error("call_list is NULL"); + break; + } + + debug_msg("%s >> %s : call_list_count = %d", str_message, "BLUETOOTH_EVENT_HF_CALL_STATUS", call_list->count); + + if (call_list->count > 0) { + call_info = g_malloc0(sizeof(bt_hf_call_status_info_t *) * call_list->count); + if (call_info) { + if (bluetooth_hf_get_call_list(call_list->list, call_info) == BLUETOOTH_ERROR_NONE) { + /* o 1 = Held + o 2 = Dialing (outgoing calls only) + o 3 = Alerting (outgoing calls only) + o 4 = Incoming (incoming calls only) + o 5 = Waiting (incoming calls only) + o 6 = Call held by Response and Hold */ + if (call_list->count >= 1) { + for(i=0; icount; i++) { + debug_msg("Call status call_count(%d), call_status(%d)", i, call_info[i]->status); + if(call_info[i]->status == 4) + MMSoundMgrSessionSetHFPConnectionState(MM_SOUND_HFP_STATUS_INCOMMING_CALL); + else + MMSoundMgrSessionSetHFPConnectionState(MM_SOUND_HFP_STATUS_UNKNOWN); + } + } + } + + g_free(call_info); + call_info = NULL; + } else { + debug_error("call_info is NULL"); + } + } + } + break; + + case BLUETOOTH_EVENT_HF_AUDIO_CONNECTED: + __bt_hf_enable_volume_changed_cb(TRUE); + ret = MMSoundMgrSessionGetSubSession(&sub); + + /* get WB capability here and set */ + ret = bluetooth_hf_get_codec(&codec_id); + if (ret == BLUETOOTH_ERROR_NONE) { + switch (codec_id) { + case BLUETOOTH_CODEC_ID_CVSD: /* NB */ + MMSoundMgrSessionSetHFBandwidth (MM_SOUND_BANDWIDTH_NB); + debug_msg("Previous band NB %d",g_bt_hf_sco_nb); + if(!g_bt_hf_sco_nb && sub == SUBSESSION_VOICE ) { + ret = MMSoundMgrSessionSetDuplicateSubSession(); + if(!ret) + debug_warning("Fail to set duplicate sub session"); + } + g_bt_hf_sco_nb = 1; + break; + case BLUETOOTH_CODEC_ID_MSBC: /* WB */ + MMSoundMgrSessionSetHFBandwidth (MM_SOUND_BANDWIDTH_WB); + debug_msg("Previous band NB %d",g_bt_hf_sco_nb); + if(g_bt_hf_sco_nb && sub == SUBSESSION_VOICE) { + ret = MMSoundMgrSessionSetDuplicateSubSession(); + if(!ret) + debug_warning("Fail to set duplicate sub session"); + } + g_bt_hf_sco_nb = 0; + break; + default: + break; + } + } + debug_msg("%s >> %s : codec_id=%d(NB:1, WB:2)", str_message, "BLUETOOTH_EVENT_HF_AUDIO_CONNECTED", codec_id); + break; + + case BLUETOOTH_EVENT_HF_AUDIO_DISCONNECTED: + __bt_hf_enable_volume_changed_cb(FALSE); + MMSoundMgrSessionSetHFPConnectionState(MM_SOUND_HFP_STATUS_UNKNOWN); + debug_msg("%s >> %s", str_message, "BLUETOOTH_EVENT_HF_AUDIO_DISCONNECTED"); + break; + + case BLUETOOTH_EVENT_HF_RING_INDICATOR: + debug_msg("%s >> %s : %s", str_message, "BLUETOOTH_EVENT_HF_RING_INDICATOR", + (event_param->param_data)? event_param->param_data : "NULL"); + break; + + case BLUETOOTH_EVENT_HF_CALL_TERMINATED: + MMSoundMgrSessionSetHFPConnectionState(MM_SOUND_HFP_STATUS_UNKNOWN); + debug_msg("%s >> %s", str_message, "BLUETOOTH_EVENT_HF_CALL_TERMINATED"); + break; + + case BLUETOOTH_EVENT_HF_CALL_STARTED: + debug_msg("%s >> %s", str_message, "BLUETOOTH_EVENT_HF_CALL_STARTED"); + strcat (str_message, ""); + break; + + case BLUETOOTH_EVENT_HF_CALL_ENDED: + MMSoundMgrSessionSetHFPConnectionState(MM_SOUND_HFP_STATUS_UNKNOWN); + debug_msg("%s >> %s", str_message, "BLUETOOTH_EVENT_HF_CALL_ENDED"); + break; + + case BLUETOOTH_EVENT_HF_VOICE_RECOGNITION_ENABLED: + debug_msg("%s >> %s", str_message, "BLUETOOTH_EVENT_HF_VOICE_RECOGNITION_ENABLED"); + /* BT connection signal before audio connected */ + break; + + case BLUETOOTH_EVENT_HF_VOICE_RECOGNITION_DISABLED: + debug_msg("%s >> %s", str_message, "BLUETOOTH_EVENT_HF_VOICE_RECOGNITION_DISABLED"); + break; + + case BLUETOOTH_EVENT_HF_VOLUME_SPEAKER: + vol_value = *(unsigned int *)(event_param->param_data); + debug_msg("%s >> %s : %d", str_message, "BLUETOOTH_EVENT_HF_VOLUME_SPEAKER", vol_value); + _bt_hf_set_volume_by_client(vol_value); + break; + + default: + debug_log("%s >> %s", str_message, "Unhandled event..."); + break; + } +} + +static int __bt_hf_initialize(pulse_info_t* pinfo) +{ + int ret = 0; + + debug_log ("__bt_hf_initialize start"); + ret = bluetooth_hf_init(_bt_hf_cb, NULL); + if (ret != BLUETOOTH_ERROR_NONE) { + debug_error ("bluetooth_hf_init error!!! [%d]", ret); + goto FAIL; + } + + MMSoundMgrSessionSetHFBandwidth(MM_SOUND_BANDWIDTH_UNKNOWN); + + debug_msg ("__bt_hf_initialize success"); + return ret; + +FAIL: + debug_error ("__bt_hf_initialize failed"); + return ret; +} + +static int __bt_hf_deinitialize(pulse_info_t* pinfo) +{ + int ret = 0; + + debug_msg ("__bt_hf_deinitialize start"); + ret = bluetooth_hf_deinit(); + if (ret != BLUETOOTH_ERROR_NONE) { + debug_error ("bluetooth_hf_deinit error!!! [%d]", ret); + goto FAIL; + } + + MMSoundMgrSessionSetHFBandwidth(MM_SOUND_BANDWIDTH_UNKNOWN); + + debug_msg ("__bt_hf_deinitialize success"); + return ret; +FAIL: + debug_error ("__bt_hf_deinitialize failed"); + return ret; +} +#endif /* TIZEN_MICRO */ + +static void set_bt_status(pulse_info_t* pinfo, int bt_status) +{ + debug_warning ("BLUETOOTH state change detected(%s), hf_init(%d), ag_init(%d)\n", + bt_status > 0 ? "connected" : "disconnected", + pinfo->hf_init, pinfo->ag_init); + + /* Init/Deinit BT AG */ + if (bt_status) { +#ifdef TIZEN_MICRO + if (pinfo->hf_init == false) { + if (!__bt_hf_initialize(pinfo)) { + pinfo->hf_init = true; + } + } +#endif + if (pinfo->ag_init == false) { + if (!__bt_ag_initialize(pinfo)) { + pinfo->ag_init = true; + } + } + } else { +#ifdef TIZEN_MICRO + if (pinfo->hf_init == true) { + if (!__bt_hf_deinitialize(pinfo)) { + pinfo->hf_init = false; + } + } +#endif + if (pinfo->ag_init == true) { + if (!__bt_ag_deinitialize(pinfo)) { + pinfo->ag_init = false; + } + } + } +#ifndef TIZEN_MICRO + pinfo->hf_init = false; +#endif +} + +static void bt_changed_cb(int result, bt_adapter_state_e bt_status, void *data) +{ + pulse_info_t* pinfo = (pulse_info_t*)data; + + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + set_bt_status(pinfo, bt_status); +} + +int MMSoundMgrPulseHandleRegisterBluetoothStatus (void* pinfo) +{ + int ret = 0; + bt_adapter_state_e bt_status = BT_ADAPTER_DISABLED; + + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return MM_ERROR_INVALID_ARGUMENT; + } + + ret = bt_initialize(); + if (ret != BT_ERROR_NONE) { + debug_error("bt_initialize error [%d]", ret); + } + + /* Get actual BT status */ + ret = bt_adapter_get_state(&bt_status); + if (bt_status == BT_ADAPTER_ENABLED) { + set_bt_status((pulse_info_t*)pinfo, bt_status); + debug_msg ("Initial BT Status"); + } + + /* set callback for bt status change */ + ret = bt_adapter_set_state_changed_cb(bt_changed_cb, pinfo); + debug_msg ("State set cb [%d]", ret); + return ret; +} + +int MMSoundMgrPulseGetBluetoothInfo(bool* is_nrec, int* bandwidth) +{ + int ret = 0; + bool wb = 0; + bool nrec = false; + + debug_msg ("Try to get AG SCO information."); + + ret = bt_ag_is_nrec_enabled(&nrec); + if (ret != BT_ERROR_NONE) { + debug_error ("ERROR : bt_ag_is_nrec_enabled error!!! [%d]", ret); + } + /* FIXME : check with product api of bluetooth */ + wb = 1; + +#ifdef TIZEN_MICRO + if(wb == 0) { + *bandwidth = MM_SOUND_BANDWIDTH_NB; + } else if(wb == 1) { + *bandwidth = MM_SOUND_BANDWIDTH_WB; + } else { + debug_error ("unknow band with. wb(%d), bt_bandwidth(%d)", wb, *bandwidth); + } +#else + /* FIXME : Think over in case of not supportted hfp */ + *bandwidth = 1; + *is_nrec = nrec; +#endif /* TIZEN_MICRO */ + + debug_msg ("Get AG SCO information. is_nrec=%d, bandwidth=%d", *is_nrec, *bandwidth); + + return MM_ERROR_NONE; +} + +#endif /* SUPPORT_BT_SCO_DETECT */ + +/* -------------------------------- MGR MAIN --------------------------------------------*/ + +int MMSoundMgrPulseHandleIsBtA2DPOnReq (mm_ipc_msg_t *msg, int (*sendfunc)(mm_ipc_msg_t*)) +{ + int ret = 0; + mm_ipc_msg_t respmsg = {0,}; + char* bt_name; + bool is_bt_on = false; + pthread_mutex_lock(&g_mutex); + + debug_enter("msg = %p, sendfunc = %p\n", msg, sendfunc); + + bt_name = MMSoundMgrSessionGetBtA2DPName(); + if (bt_name && strlen(bt_name) > 0) { + is_bt_on = true; + } + + debug_log ("is_bt_on = [%d], name = [%s]\n", is_bt_on, bt_name); + + SOUND_MSG_SET(respmsg.sound_msg, + MM_SOUND_MSG_RES_IS_BT_A2DP_ON, msg->sound_msg.handle, is_bt_on, msg->sound_msg.msgid); + MMSOUND_STRNCPY(respmsg.sound_msg.filename, bt_name, FILE_PATH); + + /* Send Response */ + ret = sendfunc (&respmsg); + if (ret != MM_ERROR_NONE) { + /* TODO : Error Handling */ + debug_error ("sendfunc failed....ret = [%x]\n", ret); + } + + pthread_mutex_unlock(&g_mutex); + + debug_leave("\n"); + + return ret; +} + +static void set_default_sink_cb(pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg("[PA_CB] m[%p] c[%p] set default sink success\n", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] set default sink fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } + pa_threaded_mainloop_signal(pinfo->m, 0); +} + +static void set_default_sink_nosignal_cb(pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg("[PA_CB] m[%p] c[%p] set default sink success\n", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] set default sink fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } +} + +static void set_cork_all_cb(pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg("[PA_CB] m[%p] c[%p] set cork all success\n", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] set cork all fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } + pa_threaded_mainloop_signal(pinfo->m, 0); +} + +static void set_cork_all_nosignal_cb(pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg("[PA_CB] m[%p] c[%p] set cork all success\n", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] set cork all fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } +} + +static void set_voicecontrol_state_cb(pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg("[PA_CB] m[%p] c[%p] set voicecontrol state success\n", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] set voicecontrol state fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } + pa_threaded_mainloop_signal(pinfo->m, 0); +} + +static void set_voicecontrol_state_nosignal_cb(pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg("[PA_CB] m[%p] c[%p] set voicecontrol state success\n", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] set voicecontrol state fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } +} + +void MMSoundMgrPulseSetUSBDefaultSink (int usb_device) +{ + pa_operation *o = NULL; + + debug_enter("\n"); + + if (pa_threaded_mainloop_in_thread(pulse_info->m)) { + o = pa_context_set_default_sink_for_usb(pulse_info->context, + (usb_device == MM_SOUND_DEVICE_OUT_USB_AUDIO)? pulse_info->usb_sink_name : pulse_info->dock_sink_name, + set_default_sink_nosignal_cb, pulse_info); + pa_operation_unref(o); + } else { + pa_threaded_mainloop_lock(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + + debug_msg("[PA] pa_context_set_default_sink m[%p] c[%p]", pulse_info->m, pulse_info->context); + o = pa_context_set_default_sink_for_usb(pulse_info->context, + (usb_device == MM_SOUND_DEVICE_OUT_USB_AUDIO)? pulse_info->usb_sink_name : pulse_info->dock_sink_name, + set_default_sink_cb, pulse_info); + CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + } + pa_operation_unref(o); + + pa_threaded_mainloop_unlock(pulse_info->m); + } + + debug_leave("\n"); + return; + +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + pa_threaded_mainloop_unlock(pulse_info->m); + + debug_leave("\n"); +} + +void MMSoundMgrPulseSetDefaultSink (char* device_api_name, char* device_bus_name) +{ + pa_operation *o = NULL; + + debug_enter("\n"); + + if (device_api_name == NULL || device_bus_name == NULL) { + debug_error ("one of string is null\n"); + return; + } + + MMSOUND_STRNCPY(pulse_info->device_api_name, device_api_name, MAX_STRING); + MMSOUND_STRNCPY(pulse_info->device_bus_name, device_bus_name, MAX_STRING); + + if (pa_threaded_mainloop_in_thread(pulse_info->m)) { + o = pa_context_set_default_sink_by_api_bus(pulse_info->context, pulse_info->device_api_name, pulse_info->device_bus_name, set_default_sink_nosignal_cb, pulse_info); + pa_operation_unref(o); + } else { + pa_threaded_mainloop_lock(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + + debug_msg("[PA] pa_context_set_default_sink_by_api_bus m[%p] c[%p]", pulse_info->m, pulse_info->context); + o = pa_context_set_default_sink_by_api_bus(pulse_info->context, pulse_info->device_api_name, pulse_info->device_bus_name, set_default_sink_cb, pulse_info); + CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + } + pa_operation_unref(o); + + pa_threaded_mainloop_unlock(pulse_info->m); + } + debug_leave("\n"); + return; + +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + pa_threaded_mainloop_unlock(pulse_info->m); + debug_leave("\n"); +} + + +void MMSoundMgrPulseSetDefaultSinkByName (char* name) +{ + pa_operation *o = NULL; + + debug_enter("\n"); + + if (!name) { + debug_error ("Invalid param\n"); + return; + } + + if (pa_threaded_mainloop_in_thread(pulse_info->m)) { + o = pa_context_set_default_sink(pulse_info->context, name, set_default_sink_cb, pulse_info); + pa_operation_unref(o); + } else { + pa_threaded_mainloop_lock(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + + debug_msg("[PA] MMSoundMgrPulseSetDefaultSinkByName m[%p] c[%p]", pulse_info->m, pulse_info->context); + o = pa_context_set_default_sink(pulse_info->context, name, set_default_sink_cb, pulse_info); + CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + } + pa_operation_unref(o); + + pa_threaded_mainloop_unlock(pulse_info->m); + } + debug_leave("\n"); + return; + +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + pa_threaded_mainloop_unlock(pulse_info->m); + debug_leave("\n"); +} + +void MMSoundMgrPulseSetCorkAll (bool cork) +{ + pa_operation *o = NULL; + + debug_enter("\n"); + + if (pa_threaded_mainloop_in_thread(pulse_info->m)) { + o = pa_context_set_cork_all(pulse_info->context, cork, set_cork_all_nosignal_cb, pulse_info); + pa_operation_unref(o); + } else { + pa_threaded_mainloop_lock(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + + debug_msg("[PA] MMSoundMgrPulseSetCorkAll m[%p] c[%p]", pulse_info->m, pulse_info->context); + o = pa_context_set_cork_all(pulse_info->context, cork, set_cork_all_cb, pulse_info); + CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + } + pa_operation_unref(o); + + pa_threaded_mainloop_unlock(pulse_info->m); + } + debug_leave("\n"); + return; + +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + pa_threaded_mainloop_unlock(pulse_info->m); + debug_leave("\n"); +} + +void MMSoundMgrPulseSetMuteall(int mute) +{ + pa_operation *o = NULL; + + debug_msg("all streams are %s. pulse_info(0x%x)", mute ? "muted" : "unmuted", pulse_info); + + if (pa_threaded_mainloop_in_thread(pulse_info->m)) { + o = pa_ext_policy_set_muteall (pulse_info->context, mute, set_muteall_cb, pulse_info); + pa_operation_unref(o); + } else { + pa_threaded_mainloop_lock(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, muteall_and_fail); + o = pa_ext_policy_set_muteall (pulse_info->context, mute, set_muteall_cb, pulse_info); + CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, muteall_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, muteall_and_fail); + } + pa_operation_unref(o); + + pa_threaded_mainloop_unlock(pulse_info->m); + } + debug_leave("\n"); + return; + +muteall_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + pa_threaded_mainloop_unlock(pulse_info->m); + debug_leave("\n"); +} + +void MMSoundMgrPulseSetVoicecontrolState (bool state) +{ + pa_operation *o = NULL; + + debug_enter("\n"); + + if (pa_threaded_mainloop_in_thread(pulse_info->m)) { + //o = pa_ext_policy_set_voicecontrol_state(pulse_info->context, (uint32_t)state, set_voicecontrol_state_nosignal_cb, pulse_info); + pa_operation_unref(o); + } else { + pa_threaded_mainloop_lock(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + + debug_msg("[PA] MMSoundMgrPulseSetCorkAll m[%p] c[%p]", pulse_info->m, pulse_info->context); + //o = pa_ext_policy_set_voicecontrol_state(pulse_info->context, (uint32_t)state, set_voicecontrol_state_cb, pulse_info); + CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + } + pa_operation_unref(o); + + pa_threaded_mainloop_unlock(pulse_info->m); + } + debug_leave("\n"); + return; + +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + pa_threaded_mainloop_unlock(pulse_info->m); + debug_leave("\n"); +} + +static void _recorder_changed_cb(keynode_t* node, void* data) +{ + int key_value; + pulse_info_t* pinfo = (pulse_info_t*)data; + session_t session = 0; + + if (pinfo == NULL) { + debug_error ("pinfo is null\n"); + return; + } + + vconf_get_int(VCONFKEY_RECORDER_STATE, &key_value); + debug_msg ("%s changed callback called, recorder state value = %d\n", vconf_keynode_get_name(node), key_value); + + MMSoundMgrSessionGetSession(&session); + + if ((key_value == VCONFKEY_RECORDER_STATE_RECORDING || key_value == VCONFKEY_RECORDER_STATE_RECORDING_PAUSE) && session == SESSION_FMRADIO) { + vconf_set_int(VCONF_KEY_FMRADIO_RECORDING, 1); + } else { + vconf_set_int(VCONF_KEY_FMRADIO_RECORDING, 0); + } +} + +int MMSoundMgrPulseHandleRegisterFMRadioRecording(void* pinfo) +{ + int ret = vconf_notify_key_changed(VCONFKEY_RECORDER_STATE, _recorder_changed_cb, pinfo); + debug_msg ("vconf [%s] set ret = %d\n", VCONFKEY_RECORDER_STATE, ret); + + return ret; +} + +static void _poweroff_changed_cb(keynode_t* node, void* data) +{ + int key_value; + pulse_info_t* pinfo = (pulse_info_t*)data; + + if (pinfo == NULL) { + debug_error ("pinfo is null\n"); + return; + } + + vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &key_value); + debug_msg ("%s changed callback called, poweroff value = %d\n", vconf_keynode_get_name(node), key_value); + + if (key_value >= VCONFKEY_SYSMAN_POWER_OFF_DIRECT) { + MMSoundMgrPulseSetMuteall(1); + } +} + +int MMSoundMgrPulseHandleRegisterPowerOffMuteall(void* pinfo) +{ + int ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, _poweroff_changed_cb, pinfo); + debug_msg ("vconf [%s] set ret = %d\n", VCONFKEY_SYSMAN_POWER_OFF_STATUS, ret); + return ret; +} + +void MMSoundMgrPulseUnLoadHDMI() +{ + pa_operation *o = NULL; + if (pulse_info == NULL) { + debug_error ("Pulse module in sound server not loaded"); + return; + } + + pa_threaded_mainloop_lock(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + + debug_msg("[PA] pa_context_unload_hdmi m[%p] c[%p]", pulse_info->m, pulse_info->context); + o = pa_ext_policy_unload_hdmi(pulse_info->context, unload_hdmi_cb, pulse_info); + CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + } + pa_operation_unref(o); + + pa_threaded_mainloop_unlock(pulse_info->m); + return; + +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + pa_threaded_mainloop_unlock(pulse_info->m); +} + +#if 0 +static void set_source_mute_by_name_cb (pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg("[PA_CB] m[%p] c[%p] set source mute by name success\n", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] set source mute by name fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } + pa_threaded_mainloop_signal(pinfo->m, 0); +} + +static void set_source_mute_by_name_nosignal_cb (pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg("[PA_CB] m[%p] c[%p] set source mute by name success\n", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] set source mute by name fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } +} +#endif -#ifdef SUPPORT_BT_SCO_DETECT +void MMSoundMgrPulseSetSourcemutebyname (char* sourcename, int mute) +{ +#if 0 + pa_operation *o = NULL; + + debug_enter("\n"); + + if (sourcename == NULL) { + debug_error ("Invalid arguments!!!\n"); + return; + } + + if (pa_threaded_mainloop_in_thread(pulse_info->m)) { + o = pa_context_set_source_mute_by_name(pulse_info->context, sourcename, mute, set_source_mute_by_name_nosignal_cb, pulse_info); + pa_operation_unref(o); + } else { + pa_threaded_mainloop_lock(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + + debug_msg("[PA] pa_context_set_source_mute_by_name m[%p] c[%p] name:%s mute:%d", pulse_info->m, pulse_info->context, sourcename, mute); + o = pa_context_set_source_mute_by_name (pulse_info->context, sourcename, mute, set_source_mute_by_name_cb, pulse_info); + CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + } + pa_operation_unref(o); + + pa_threaded_mainloop_unlock(pulse_info->m); + } + debug_leave("\n"); + return; + +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + pa_threaded_mainloop_unlock(pulse_info->m); + + debug_leave("\n"); +#endif +} + +void MMSoundMgrPulseGetInitialBTStatus (bool *a2dp, bool *sco) +{ + int bt_status = VCONFKEY_BT_DEVICE_NONE; + + if (a2dp == NULL || sco == NULL) { + debug_error ("Invalid arguments!!!\n"); + return; + } + + /* Get saved bt status */ + *a2dp = pulse_info->init_bt_status; + + /* Get actual vconf value */ + vconf_get_int(VCONFKEY_BT_DEVICE, &bt_status); + debug_msg ("key value = 0x%x\n", bt_status); + *sco = (bt_status & VCONFKEY_BT_DEVICE_HEADSET_CONNECTED)? true : false; + + debug_msg ("returning a2dp=[%d], sco=[%d]\n", *a2dp, *sco); +} + +static void set_session_cb(pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg ("[PA_CB] m[%p] c[%p] set session success", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] set session fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } + + pa_threaded_mainloop_signal(pinfo->m, 0); +} + +static void set_session_nosignal_cb(pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg ("[PA_CB] m[%p] c[%p] set session success", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] set session fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } +} + +void MMSoundMgrPulseSetSession(session_t session, session_state_t state) +{ + pa_operation *o = NULL; + uint32_t session_pa = 0; + + /* convert subsession enum for PA */ + switch (session) { + case SESSION_MEDIA: session_pa = PA_TIZEN_SESSION_MEDIA; break; + case SESSION_VOICECALL: session_pa = PA_TIZEN_SESSION_VOICECALL; break; + case SESSION_VIDEOCALL: session_pa = PA_TIZEN_SESSION_VIDEOCALL; break; + case SESSION_VOIP: session_pa = PA_TIZEN_SESSION_VOIP; break; + case SESSION_FMRADIO: session_pa = PA_TIZEN_SESSION_FMRADIO; break; + case SESSION_NOTIFICATION: session_pa = PA_TIZEN_SESSION_NOTIFICATION; break; + case SESSION_ALARM: session_pa = PA_TIZEN_SESSION_ALARM; break; + case SESSION_EMERGENCY: session_pa = PA_TIZEN_SESSION_EMERGENCY; break; + case SESSION_VOICE_RECOGNITION: session_pa = PA_TIZEN_SESSION_VOICE_RECOGNITION;break; + default: + debug_error("inavlid session:%d", session); + return; + } + + if (pa_threaded_mainloop_in_thread(pulse_info->m)) { + o = pa_ext_policy_set_session(pulse_info->context, session_pa, state, set_session_nosignal_cb, pulse_info); + pa_operation_unref(o); + } else { + pa_threaded_mainloop_lock(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + + debug_msg("[PA] pa_ext_policy_set_session m[%p] c[%p] session:%d state:%d", pulse_info->m, pulse_info->context, session_pa, state); + o = pa_ext_policy_set_session(pulse_info->context, session_pa, state, set_session_cb, pulse_info); + CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + } + pa_operation_unref(o); + pa_threaded_mainloop_unlock(pulse_info->m); + } + return; + +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + pa_threaded_mainloop_unlock(pulse_info->m); +} + +static void set_subsession_cb(pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg ("[PA_CB] m[%p] c[%p] set subsession success", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] set subsession fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } + + pa_threaded_mainloop_signal(pinfo->m, 0); +} + +static void set_subsession_nosignal_cb(pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg ("[PA_CB] m[%p] c[%p] set subsession success", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] set subsession fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } +} + +void MMSoundMgrPulseSetSubsession(subsession_t subsession, int subsession_opt) +{ + pa_operation *o = NULL; + uint32_t subsession_pa = 0, subsession_opt_pa = 0; + + /* convert subsession enum for PA */ + switch (subsession) { + case SUBSESSION_VOICE: subsession_pa = PA_TIZEN_SUBSESSION_VOICE; break; + case SUBSESSION_RINGTONE: subsession_pa = PA_TIZEN_SUBSESSION_RINGTONE; break; + case SUBSESSION_MEDIA: subsession_pa = PA_TIZEN_SUBSESSION_MEDIA; break; + case SUBSESSION_INIT: subsession_pa = PA_TIZEN_SUBSESSION_VR_INIT; break; + case SUBSESSION_VR_NORMAL: subsession_pa = PA_TIZEN_SUBSESSION_VR_NORMAL; break; + case SUBSESSION_VR_DRIVE: subsession_pa = PA_TIZEN_SUBSESSION_VR_DRIVE; break; +#ifndef _TIZEN_PUBLIC_ + case SUBSESSION_RECORD_MONO: + case SUBSESSION_RECORD_STEREO: +#endif + default: + debug_error("inavlid subsession:%d", subsession); + return; + } + + if (pa_threaded_mainloop_in_thread(pulse_info->m)) { + o = pa_ext_policy_set_subsession(pulse_info->context, subsession_pa, subsession_opt_pa, set_subsession_nosignal_cb, pulse_info); + pa_operation_unref(o); + } else { + pa_threaded_mainloop_lock(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + + debug_msg("[PA] pa_ext_policy_set_session m[%p] c[%p] subsession:%d opt:%x", pulse_info->m, pulse_info->context, subsession_pa, subsession_opt); + o = pa_ext_policy_set_subsession(pulse_info->context, subsession_pa, subsession_opt_pa, set_subsession_cb, pulse_info); + CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + } + pa_operation_unref(o); + pa_threaded_mainloop_unlock(pulse_info->m); + } + return; + +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + pa_threaded_mainloop_unlock(pulse_info->m); +} + +static void set_active_device_cb(pa_context *c, int success, int need_update, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg ("[PA_CB] c[%p] set active device success. need_update(%d)", c, need_update); + } else { + debug_error("[PA_CB] c[%p] set active device fail:%s", c, pa_strerror(pa_context_errno(c))); + } + + pa_threaded_mainloop_signal(pinfo->m, 0); + + if (need_update) { + debug_msg("[PA] pa_ext_policy_set_active_device need to update volume."); + if(MM_ERROR_NONE != _mm_sound_mgr_device_update_volume()) { + debug_error ("_mm_sound_mgr_device_update_volume failed."); + } + } + +} + +static void set_active_device_nosignal_cb(pa_context *c, int success, int need_update, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg ("[PA_CB] c[%p] set active device success. need_update(%d)", c, need_update); + } else { + debug_error("[PA_CB] c[%p] set active device fail:%s", c, pa_strerror(pa_context_errno(c))); + } + + if (need_update) { + debug_msg("[PA] pa_ext_policy_set_active_device need to update volume."); + if(MM_ERROR_NONE != _mm_sound_mgr_device_update_volume()) { + debug_error ("_mm_sound_mgr_device_update_volume failed."); + } + } +} + +void MMSoundMgrPulseGetPathInfo(mm_sound_device_out *device_out, mm_sound_device_in *device_in) +{ + if(device_in == NULL || device_out == NULL) { + debug_error("inavlid device_in or device_out is null"); + return; + } + *device_in = g_path_info.device_in; + *device_out = g_path_info.device_out; +} + +void MMSoundMgrPulseSetActiveDevice(mm_sound_device_in device_in, mm_sound_device_out device_out) +{ + pa_operation *o = NULL; + uint32_t device_in_pa = 0, device_out_pa = 0; + + /* convert device_in enum for PA */ + switch (device_in) { + case MM_SOUND_DEVICE_IN_NONE: device_in_pa = PA_TIZEN_DEVICE_IN_NONE; break; + case MM_SOUND_DEVICE_IN_MIC: device_in_pa = PA_TIZEN_DEVICE_IN_MIC; break; + case MM_SOUND_DEVICE_IN_WIRED_ACCESSORY: device_in_pa = PA_TIZEN_DEVICE_IN_WIRED_ACCESSORY; break; + case MM_SOUND_DEVICE_IN_BT_SCO: device_in_pa = PA_TIZEN_DEVICE_IN_BT_SCO; break; + default: + debug_error("inavlid device_in:%x", device_in); + return; + } + + /* convert device_out enum for PA */ + switch (device_out) { + case MM_SOUND_DEVICE_OUT_NONE: device_out_pa = PA_TIZEN_DEVICE_OUT_NONE; break; + case MM_SOUND_DEVICE_OUT_SPEAKER: device_out_pa = PA_TIZEN_DEVICE_OUT_SPEAKER; break; + case MM_SOUND_DEVICE_OUT_RECEIVER: device_out_pa = PA_TIZEN_DEVICE_OUT_RECEIVER; break; + case MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY: device_out_pa = PA_TIZEN_DEVICE_OUT_WIRED_ACCESSORY; break; + case MM_SOUND_DEVICE_OUT_BT_SCO: device_out_pa = PA_TIZEN_DEVICE_OUT_BT_SCO; break; + case MM_SOUND_DEVICE_OUT_BT_A2DP: device_out_pa = PA_TIZEN_DEVICE_OUT_BT_A2DP; break; + case MM_SOUND_DEVICE_OUT_DOCK: device_out_pa = PA_TIZEN_DEVICE_OUT_DOCK; break; + case MM_SOUND_DEVICE_OUT_HDMI: device_out_pa = PA_TIZEN_DEVICE_OUT_HDMI; break; + case MM_SOUND_DEVICE_OUT_MIRRORING: device_out_pa = PA_TIZEN_DEVICE_OUT_MIRRORING; break; + case MM_SOUND_DEVICE_OUT_USB_AUDIO: device_out_pa = PA_TIZEN_DEVICE_OUT_USB_AUDIO; break; + case MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK: device_out_pa = PA_TIZEN_DEVICE_OUT_MULTIMEDIA_DOCK; break; + default: + debug_error("inavlid device_out:%x", device_out); + return; + } + + if (pa_threaded_mainloop_in_thread(pulse_info->m)) { + debug_msg("[PA] pa_ext_policy_set_active_device device_in:%d device_out:%d", device_in_pa, device_out_pa); + o = pa_ext_policy_set_active_device(pulse_info->context, device_in_pa, device_out_pa, set_active_device_nosignal_cb, pulse_info); + pa_operation_unref(o); + } else { + pa_threaded_mainloop_lock(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + + debug_msg("[PA] pa_ext_policy_set_active_device m[%p] c[%p] device_in:%d device_out:%d", pulse_info->m, pulse_info->context, device_in_pa, device_out_pa); + o = pa_ext_policy_set_active_device(pulse_info->context, device_in_pa, device_out_pa, set_active_device_cb, pulse_info); + CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + } + pa_operation_unref(o); + pa_threaded_mainloop_unlock(pulse_info->m); + } + g_path_info.device_in = device_in; + g_path_info.device_out = device_out; + debug_msg("device_in:%x device_out:%x",device_in, device_out); + return; + +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + pa_threaded_mainloop_unlock(pulse_info->m); +} + +#ifdef TIZEN_MICRO + +static void set_volume_level_cb(pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg ("[PA_CB] m[%p] c[%p] set volume level success", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] set volume level fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } + + pa_threaded_mainloop_signal(pinfo->m, 0); +} + +static void set_volume_level_nosignal_cb(pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg ("[PA_CB] m[%p] c[%p] set volume level success", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] set volume level fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } +} + +void MMSoundMgrPulseSetVolumeLevel(volume_type_t volume_type, unsigned int volume_level) +{ + pa_operation *o = NULL; + + if (pa_threaded_mainloop_in_thread(pulse_info->m)) { + o = pa_ext_policy_set_volume_level(pulse_info->context, -1, volume_type, volume_level, set_volume_level_nosignal_cb, pulse_info); + pa_operation_unref(o); + } else { + pa_threaded_mainloop_lock(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + + debug_msg("[PA] pa_ext_policy_set_volume_level volume_level(%d)", volume_level); + o = pa_ext_policy_set_volume_level(pulse_info->context, -1, volume_type, volume_level, set_volume_level_cb, pulse_info); + CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + } + pa_operation_unref(o); + pa_threaded_mainloop_unlock(pulse_info->m); + } + return; + +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + pa_threaded_mainloop_unlock(pulse_info->m); +} + +#endif /* TIZEN_MICRO */ + + +static void set_update_volume_cb(pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg ("[PA_CB] m[%p] c[%p] update volume success", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] update volume fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } + + pa_threaded_mainloop_signal(pinfo->m, 0); +} + +static void set_update_volume_nosignal_cb(pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg ("[PA_CB] m[%p] c[%p] update volume success", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] update volume fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } +} + +void MMSoundMgrPulseUpdateVolume(void) +{ + pa_operation *o = NULL; + + if (pa_threaded_mainloop_in_thread(pulse_info->m)) { + o = pa_ext_policy_update_volume(pulse_info->context, set_update_volume_nosignal_cb, pulse_info); + pa_operation_unref(o); + } else { + pa_threaded_mainloop_lock(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + + debug_msg("[PA] pa_ext_update_volume m[%p] c[%p]", pulse_info->m, pulse_info->context); + o = pa_ext_policy_update_volume(pulse_info->context, set_update_volume_cb, pulse_info); + CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pulse_info->m); + CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail); + } + pa_operation_unref(o); + pa_threaded_mainloop_unlock(pulse_info->m); + } + return; + +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + pa_threaded_mainloop_unlock(pulse_info->m); +} + +/* -------------------------------- booting sound --------------------------------------------*/ + +#define VCONF_BOOTING "memory/private/sound/booting" + +static void __pa_context_success_cb (pa_context *c, int success, void *userdata) +{ + pulse_info_t *pinfo = (pulse_info_t *)userdata; + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + if (success) { + debug_msg ("[PA_CB] m[%p] c[%p] set booting success", pinfo->m, c); + } else { + debug_error("[PA_CB] m[%p] c[%p] set booting fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c))); + } + pa_threaded_mainloop_signal(pinfo->m, 0); +} + +static void _booting_changed_cb(keynode_t* node, void* data) +{ + char* booting = NULL; + pulse_info_t* pinfo = (pulse_info_t*)data; + pa_operation *o = NULL; + unsigned int value; + + if (pinfo == NULL) { + debug_error ("pinfo is null"); + return; + } + + booting = vconf_get_str(VCONF_BOOTING); + debug_msg ("%s changed callback called, booting value = %s\n",vconf_keynode_get_name(node), booting); + if (booting) { + free(booting); + } + + pa_threaded_mainloop_lock(pinfo->m); + CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail); + + mm_sound_volume_get_value(VOLUME_TYPE_SYSTEM, &value); + o = pa_ext_policy_play_sample(pinfo->context, "booting", VOLUME_TYPE_SYSTEM, VOLUME_GAIN_BOOTING, value, ( void (*)(pa_context *, uint32_t , void *))__pa_context_success_cb, pinfo); + + CHECK_CONTEXT_SUCCESS_GOTO(pinfo->context, o, unlock_and_fail); + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + pa_threaded_mainloop_wait(pinfo->m); + CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail); + } + pa_operation_unref(o); + + pa_threaded_mainloop_unlock(pinfo->m); + return; + +unlock_and_fail: + if (o) { + pa_operation_cancel(o); + pa_operation_unref(o); + } + pa_threaded_mainloop_unlock(pinfo->m); +} + +int MMSoundMgrPulseHandleRegisterBooting (void* pinfo) +{ + int ret = vconf_notify_key_changed(VCONF_BOOTING, _booting_changed_cb, pinfo); + debug_msg ("vconf [%s] set ret = %d\n", VCONF_BOOTING, ret); + return ret; +} + +void* MMSoundMgrPulseInit(void) +{ + pulse_info = (pulse_info_t*) malloc (sizeof(pulse_info_t)); + memset (pulse_info, 0, sizeof(pulse_info_t)); + + debug_enter("\n"); + + pulse_init(pulse_info); + pulse_client_thread_init(pulse_info); + + pulse_info->device_in_out = PA_INVALID_INDEX; + pulse_info->aec_module_idx = PA_INVALID_INDEX; + pulse_info->bt_idx = PA_INVALID_INDEX; + pulse_info->usb_idx = PA_INVALID_INDEX; + pulse_info->dock_idx = PA_INVALID_INDEX; + pulse_info->device_type = PA_INVALID_INDEX; +#ifdef SUPPORT_MONO_AUDIO + MMSoundMgrPulseHandleRegisterMonoAudio(pulse_info); +#endif +#ifdef SUPPORT_AUDIO_BALANCE + MMSoundMgrPulseHandleRegisterAudioBalance(pulse_info); + MMSoundMgrPulseHandleResetAudioBalanceOnBoot(pulse_info); +#endif + +#ifdef SUPPORT_AUDIO_MUTEALL + MMSoundMgrPulseHandleRegisterAudioMuteall(pulse_info); + MMSoundMgrPulseHandleResetAudioMuteallOnBoot(pulse_info); +#endif +#ifdef SUPPORT_BT_SCO MMSoundMgrPulseHandleRegisterBluetoothStatus(pulse_info); #endif + MMSoundMgrPulseHandleRegisterBooting(pulse_info); debug_leave("\n"); return pulse_info; @@ -461,9 +2701,19 @@ void* MMSoundMgrPulseInit(void) int MMSoundMgrPulseFini(void* handle) { + pulse_info_t *pinfo = (pulse_info_t *)handle; + debug_enter("\n"); - pulse_deinit((pulse_info_t *)handle); + pulse_deinit(pinfo); +#ifdef SUPPORT_BT_SCO + bt_deinitialize(); +#endif + + g_async_queue_push(pinfo->queue, (gpointer)PA_CLIENT_DESTROY); + + pthread_join(pinfo->thread, 0); + g_async_queue_unref(pinfo->queue); debug_leave("\n"); return MM_ERROR_NONE; diff --git a/server/mm_sound_mgr_session.c b/server/mm_sound_mgr_session.c old mode 100644 new mode 100755 index cf5351e..73aa33e --- a/server/mm_sound_mgr_session.c +++ b/server/mm_sound_mgr_session.c @@ -21,7 +21,6 @@ #include #include - #include #include #include @@ -29,42 +28,70 @@ #include #include #include - #include - -#include "include/mm_sound_mgr_common.h" -#include "../include/mm_sound_common.h" -#include "../include/mm_sound.h" - +#ifdef TIZEN_MICRO +#include +#endif +#include #include #include - #include -#include +#include "../include/mm_sound_common.h" +#include "../include/mm_sound_utils.h" +#include "../include/mm_sound_device.h" +#include "include/mm_sound_mgr_common.h" #include "include/mm_sound_mgr_session.h" +#include "include/mm_sound_mgr_device.h" +#include "include/mm_sound_mgr_device_headset.h" +#include "include/mm_sound_mgr_device_dock.h" +#include "include/mm_sound_mgr_pulse.h" #include "include/mm_sound_mgr_asm.h" -#include -#include +#define EARJACK_UNPLUGGED 0 +#define EARJACK_WITH_MIC 3 -#define EARJACK_WITH_MIC 2 +#define MAX_STRING_LEN 256 -#define MAX_STRING_LEN 64 +#define VCONF_SOUND_BURSTSHOT "memory/private/sound/burstshot" -#define DEFAULT_SINK_BT "bluez" -#define DEFAULT_SINK_ALSA "alsa" +#define DEVICE_API_BLUETOOTH "bluez" +#define DEVICE_API_ALSA "alsa" +#define DEVICE_BUS_BLUETOOTH "bluetooth" +#define DEVICE_BUS_USB "usb" +#define DEVICE_BUS_BUILTIN "builtin" -#define MM_SOUND_DEVICE_OUT_ANY 0x0000FF00 +#define MIRRORING_MONITOR_SOURCE "alsa_output.0.analog-stereo.monitor" +#define ALSA_SINK_HDMI "alsa_output.1.analog-stereo" + +#ifdef TIZEN_MICRO +/* Call pause resume scenario with D-bus */ +/* Call application send dbus dbus signal */ +#define DBUS_CALL_STATUS_PATH "/Org/Tizen/Call/Status" +#define DBUS_CALL_STATUS_INTERFACE "org.tizen.call.status" +#define DBUS_CALL_STATUS_CHANGED_SIGNAL "call_status" +#endif + +#define MM_SOUND_DEVICE_OUT_ANY 0x000FFF00 #define MM_SOUND_DEVICE_IN_ANY 0x000000FF #define MM_SOUND_DEVICE_OUT_FILTER 0x000000FF -#define MM_SOUND_DEVICE_IN_FILTER 0x0000FF00 +#define MM_SOUND_DEVICE_IN_FILTER 0x000FFF00 + +#define MAX_BURST_CHECK_RETRY 10 +#define BURST_CHECK_INTERVAL 300000 + +#define STR_LEN 128 pthread_mutex_t g_mutex_session = PTHREAD_MUTEX_INITIALIZER; -#define LOCK_SESSION() do { debug_log("(*)LOCKING\n"); /*pthread_mutex_lock(&g_mutex_session);*/ debug_log("(+)LOCKED\n"); }while(0) -#define UNLOCK_SESSION() do { /* pthread_mutex_unlock(&g_mutex_session);*/ debug_log("(-)UNLOCKED\n"); }while(0) +#define LOCK_SESSION() /* do { debug_log("(*)LOCKING\n"); pthread_mutex_lock(&g_mutex_session); debug_log("(+)LOCKED\n"); }while(0) */ +#define UNLOCK_SESSION() /* do { pthread_mutex_unlock(&g_mutex_session); debug_log("(-)UNLOCKED\n"); }while(0) */ + +pthread_mutex_t g_mutex_path = PTHREAD_MUTEX_INITIALIZER; + +#define LOCK_PATH() do { debug_log("(*)LOCKING\n"); pthread_mutex_lock(&g_mutex_path); debug_log("(+)LOCKED\n"); }while(0) +#define UNLOCK_PATH() do { pthread_mutex_unlock(&g_mutex_path); debug_log("(-)UNLOCKED\n"); }while(0) #define RESET_ACTIVE(x) (g_info.device_active &= x) #define RESET_AVAILABLE(x) (g_info.device_available &= x) @@ -91,11 +118,50 @@ pthread_mutex_t g_mutex_session = PTHREAD_MUTEX_INITIALIZER; #define GET_ACTIVE_PLAYBACK() IS_ACTIVE(MM_SOUND_DEVICE_OUT_ANY) #define GET_ACTIVE_CAPTURE() IS_ACTIVE(MM_SOUND_DEVICE_IN_ANY) -#define IS_COMMUNICATION_SESSION() ((g_info.session == SESSION_VOICECALL) || (g_info.session == SESSION_VOIP)) +#define IS_CALL_SESSION() ((g_info.session == SESSION_VOICECALL) || (g_info.session == SESSION_VIDEOCALL) || (g_info.session == SESSION_VOIP)) +#define IS_ALARM_SESSION() (g_info.session == SESSION_ALARM) #define IS_NOTIFICATION_SESSION() (g_info.session == SESSION_NOTIFICATION) +#define IS_EMERGENCY_SESSION() (g_info.session == SESSION_EMERGENCY) +#define IS_MEDIA_SESSION() (g_info.session == SESSION_MEDIA) + -static int __set_sound_path_for_current_active (); +typedef enum { + ROUTE_PARAM_NONE = 0x00000000, + ROUTE_PARAM_BROADCASTING = 0x00000001, + ROUTE_PARAM_CORK_DEVICE = 0x00000010, +} mm_sound_route_param_t; + +#ifdef TIZEN_MICRO +enum { + MM_SOUND_CALL_STATUS_RESUME = 0, + MM_SOUND_CALL_STATUS_PAUSE = 1, +}; +#endif + +static int __set_route(bool need_broadcast, bool need_cork); +static int __set_sound_path_for_current_active (bool need_broadcast, bool need_cork); static int __set_sound_path_to_dual (); +static int __set_sound_path_to_earphone_only (void); +static int __set_sound_path_to_speaker (); +static int __set_sound_path_for_voicecontrol (void); +static void __select_playback_active_device (void); +static void __select_capture_active_device (void); + +static const char* __get_session_string(session_t session); +static const char* __get_subsession_string(subsession_t session); +#ifndef _TIZEN_PUBLIC_ +#ifndef TIZEN_MICRO +static bool __is_noise_reduction_on (void); +static bool __is_extra_volume_on (void); +#endif +static bool __is_upscaling_needed (void); +static bool __is_right_hand_on (void); +static bool __get_bt_nrec_status (void); +static int __get_ag_wb_status(void); +static int __get_hf_wb_status(void); +static int __get_hf_connection_state(void); +static const char* __get_bt_bandwidth_string(int bandwidth); +#endif #define ENABLE_CALLBACK #ifndef ENABLE_CALLBACK @@ -103,8 +169,17 @@ static int __set_sound_path_to_dual (); #define _mm_sound_mgr_device_active_device_callback(a,b) MM_ERROR_NONE #endif -#define SOUND_DOCK_ON "/usr/share/svi/sound/operation/new_chat.wav" -#define SOUND_DOCK_OFF "/usr/share/svi/sound/operation/sent_chat.wav" +typedef struct _bt_info_struct +{ +#ifdef TIZEN_MICRO + int ag_wb; + int hf_wb; + int hfp_conn_state; +#endif + bool is_nrec; + bool is_wb; + char name[MAX_STRING_LEN]; +} BT_INFO_STRUCT; typedef struct _session_info_struct { @@ -112,79 +187,84 @@ typedef struct _session_info_struct int device_available; int device_active; int headset_type; + bool is_noise_reduction; + bool is_extra_volume; + bool is_upscaling_needed; + bool is_voicecontrol; session_t session; subsession_t subsession; + mm_subsession_option_t option; - char bt_name[MAX_STRING_LEN]; - char default_sink_name[MAX_STRING_LEN]; + device_type_t previous_playback_device; + device_type_t previous_capture_device; + int previous_device_available; + BT_INFO_STRUCT bt_info; + char default_sink_name[MAX_STRING_LEN]; } SESSION_INFO_STRUCT; SESSION_INFO_STRUCT g_info; - -#define PLAYBACK_NUM 6 -#define CAPTURE_NUM 3 - -typedef enum -{ - NO_NOTI = 0, - DO_NOTI -} noti_t; - +#ifdef TIZEN_MICRO +GDBusConnection *conn_callstatus; +guint sig_id_callstatus; +#endif static void dump_info () { int i = 0; - char *playback_device_str[] = { "SPEAKER ", "RECEIVER ", "HEADSET ", "BTSCO ", "BTA2DP ", "DOCK " }; - char *capture_device_str[] = { "MAINMIC ", "HEADSET ", "BTMIC " }; + const char *playback_device_str[] = { "SPEAKER ", "RECEIVER ", "HEADSET ", "BTSCO ", "BTA2DP ", "DOCK ", "HDMI ", "MIRRORING ", "USB " }; + const char *capture_device_str[] = { "MAINMIC ", "HEADSET ", "BTMIC " }; - static char tmp_str[128]; - static char tmp_str2[128]; + int playback_max = sizeof (playback_device_str) / sizeof (char*); + int capture_max = sizeof (capture_device_str) / sizeof (char*); + + static char tmp_str[STR_LEN]; + static char tmp_str2[STR_LEN]; debug_log ("<----------------------------------------------------->\n"); strcpy (tmp_str, "PLAYBACK = [ "); - for (i=0; i> 8) & (0x01 << i)) { - strcat (tmp_str, playback_device_str[i]); + strncat (tmp_str, playback_device_str[i], STR_LEN - strlen(tmp_str) -1); } } strcat (tmp_str, "]"); strcpy (tmp_str2, "CAPTURE = [ "); - for (i=0; i> 8) & (0x01 << i)) { - strcat (tmp_str, playback_device_str[i]); + strncat (tmp_str, playback_device_str[i], STR_LEN - strlen(tmp_str) -1); } } strcat (tmp_str, "]"); strcpy (tmp_str2, "CAPTURE = [ "); - for (i=0; i\n"); } @@ -200,9 +280,9 @@ static bool _asm_register_for_headset (int * handle) return false; } - if(!ASM_register_sound_ex (-1, handle, ASM_EVENT_EARJACK_UNPLUG, ASM_STATE_NONE, NULL, NULL, ASM_RESOURCE_NONE, &asm_error, __asm_process_message)) { - debug_warning("earjack event register failed with 0x%x\n", asm_error); - return false; + if (!ASM_register_sound_ex (-1, handle, ASM_EVENT_EARJACK_UNPLUG, ASM_STATE_NONE, NULL, NULL, ASM_RESOURCE_NONE, &asm_error, __asm_process_message)) { + debug_warning("earjack event register failed with 0x%x\n", asm_error); + return false; } return true; @@ -227,13 +307,13 @@ static void _asm_pause_process(int handle) } //do pause - debug_warning("Send earphone unplug event to Audio Session Manager Server for BT headset\n"); + debug_warning("Send earphone unplug event to Audio Session Manager Server\n"); - if(!ASM_set_sound_state_ex(handle, ASM_EVENT_EARJACK_UNPLUG, ASM_STATE_PLAYING, ASM_RESOURCE_NONE, &asm_error, __asm_process_message)) { + if (!ASM_set_sound_state_ex(handle, ASM_EVENT_EARJACK_UNPLUG, ASM_STATE_PLAYING, ASM_RESOURCE_NONE, &asm_error, __asm_process_message)) { debug_error("earjack event set sound state to playing failed with 0x%x\n", asm_error); } - if(!ASM_set_sound_state_ex(handle, ASM_EVENT_EARJACK_UNPLUG, ASM_STATE_STOP, ASM_RESOURCE_NONE, &asm_error, __asm_process_message)) { + if (!ASM_set_sound_state_ex(handle, ASM_EVENT_EARJACK_UNPLUG, ASM_STATE_STOP, ASM_RESOURCE_NONE, &asm_error, __asm_process_message)) { debug_error("earjack event set sound state to stop failed with 0x%x\n", asm_error); } @@ -249,7 +329,7 @@ static bool _asm_unregister_for_headset (int *handle) return false; } - if(!ASM_unregister_sound_ex(handle, ASM_EVENT_EARJACK_UNPLUG, &asm_error, __asm_process_message)) { + if (!ASM_unregister_sound_ex(*handle, ASM_EVENT_EARJACK_UNPLUG, &asm_error, __asm_process_message)) { debug_error("earjack event unregister failed with 0x%x\n", asm_error); return false; } @@ -259,136 +339,178 @@ static bool _asm_unregister_for_headset (int *handle) /* ------------------------- INTERNAL FUNCTIONS ------------------------------------*/ -static void __update_volume_value(volume_type_t volume_type) +static void __backup_current_active_device() { - int ret = 0; - int volume_value = 0; + g_info.previous_playback_device = GET_ACTIVE_PLAYBACK(); + g_info.previous_capture_device = GET_ACTIVE_CAPTURE(); + g_info.previous_device_available = g_info.device_available; +} - ret = mm_sound_volume_get_value(volume_type, &volume_value); - if (ret == MM_ERROR_NONE) { - ret = mm_sound_volume_set_value(volume_type, volume_value); - if (ret != MM_ERROR_NONE) { - debug_error("mm_sound_volume_get_value failed....ret = [%x]\n", ret); - } +static void __restore_previous_active_device() +{ + RESET_ACTIVE(0); + + debug_msg ("available device (0x%x => 0x%x)", g_info.previous_device_available, g_info.device_available); + if (g_info.previous_device_available == g_info.device_available) { + /* No Changes */ + g_info.device_active |= g_info.previous_playback_device; + g_info.device_active |= g_info.previous_capture_device; } else { - debug_error("mm_sound_volume_get_value failed....ret = [%x]\n", ret); + /* Changes happens */ + __select_playback_active_device(); + __select_capture_active_device(); } } -static void _set_path_with_notification(noti_t noti) + +static int __set_route(bool need_broadcast, bool need_cork) { int ret = MM_ERROR_NONE; - debug_msg ("[%s] noti=%d\n", __func__,noti); + debug_msg ("need_broadcast=%d, need_cork=%d\n", need_broadcast, need_cork); + + LOCK_PATH(); /* Set path based on current active device */ - ret = __set_sound_path_for_current_active(); + ret = __set_sound_path_for_current_active(need_broadcast, need_cork); if (ret != MM_ERROR_NONE) { debug_error ("__set_sound_path_for_current_active() failed [%x]\n", ret); - return; + UNLOCK_PATH(); + return ret; } - if (noti == DO_NOTI) { - /* Notify current active device */ - ret = _mm_sound_mgr_device_active_device_callback(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK()); - if (ret != MM_ERROR_NONE) { - debug_error ("_mm_sound_mgr_device_active_device_callback() failed [%x]\n", ret); - } + UNLOCK_PATH(); + return ret; +} + +static int __set_route_nolock(bool need_broadcast, bool need_cork) +{ + int ret = MM_ERROR_NONE; + + debug_msg ("need_broadcast=%d, need_cork=%d\n", need_broadcast, need_cork); + + /* Set path based on current active device */ + ret = __set_sound_path_for_current_active(need_broadcast, need_cork); + if (ret != MM_ERROR_NONE) { + debug_error ("__set_sound_path_for_current_active() failed [%x]\n", ret); + UNLOCK_PATH(); + return ret; } + + return ret; } -static int __set_playback_route_communication (session_state_t state) +static int __set_playback_route_media (session_state_t state) { int ret = MM_ERROR_NONE; - int gain; debug_fenter(); if (state == SESSION_START) { - SET_AVAILABLE(MM_SOUND_DEVICE_OUT_RECEIVER); - debug_log ("voicecall session started...only receiver available set on..."); + dump_info(); + } else { /* SESSION_END */ + __set_route(false, false); + dump_info(); + } - ret = _mm_sound_mgr_device_available_device_callback(MM_SOUND_DEVICE_IN_NONE, MM_SOUND_DEVICE_OUT_RECEIVER, 1); - if (ret != MM_ERROR_NONE) { - debug_error ("_mm_sound_mgr_device_available_device_callback() failed [%x]\n", ret); - goto ROUTE_COMM_EXIT; - } + debug_fleave(); + return ret; +} + +static int __set_playback_route_voip (session_state_t state) +{ + int ret = MM_ERROR_NONE; + + debug_fenter(); + if (state == SESSION_START) { + /* Enable Receiver Device */ + debug_log ("voip call session started..."); + + /* Backup current active for future restore */ + __backup_current_active_device(); + + /* Set default subsession as VOICE */ +#ifdef TIZEN_MICRO + g_info.subsession = SUBSESSION_MEDIA; +#else + g_info.subsession = SUBSESSION_VOICE; +#endif - /* (speaker = receiver, headset = headset, bt a2dp = bt sco) */ /* OUT */ +#ifdef TIZEN_MICRO + SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_SPEAKER); + SET_CAPTURE_ONLY_ACTIVE(MM_SOUND_DEVICE_IN_MIC); +#else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_SPEAKER)) { debug_log ("active out was SPEAKER => activate receiver!!\n"); SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_RECEIVER); - } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP)) { debug_log ("active out was BT A2DP => activate BT SCO!!\n"); SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_BT_SCO); SET_CAPTURE_ONLY_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO); } - /* FIXME : Do we have to set IN device ??? */ + __set_route(true, false); +#endif + dump_info(); + } else { /* SESSION_END */ + /* RESET */ + if (g_info.session != SESSION_VOIP) { + debug_warning ("Must be VOIP session but current session is [%s]\n", + __get_session_string(g_info.session)); + } + debug_log ("Reset ACTIVE, activate previous active device if still available, if not, set based on priority"); + __restore_previous_active_device(); - _set_path_with_notification(DO_NOTI); + debug_log ("voip call session stopped...set path based on current active device"); + __set_route(true, false); dump_info(); + } + debug_fleave(); + return ret; +} - } else { /* SESSION_END */ - UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_RECEIVER); - - ret = _mm_sound_mgr_device_available_device_callback(MM_SOUND_DEVICE_IN_NONE, MM_SOUND_DEVICE_OUT_RECEIVER, 0); - if (ret != MM_ERROR_NONE) { - debug_error ("_mm_sound_mgr_device_available_device_callback() failed [%x]\n", ret); - goto ROUTE_COMM_EXIT; - } +static int __set_playback_route_call (session_state_t state) +{ + int ret = MM_ERROR_NONE; - // RESET - if (g_info.session == SESSION_VOICECALL) - gain = AVSYS_AUDIO_GAIN_EX_VOICECALL; - else if (g_info.session == SESSION_VOIP) - gain = AVSYS_AUDIO_GAIN_EX_VIDEOCALL; - else { - debug_warning ("Not valid session info....\n"); - gain = AVSYS_AUDIO_GAIN_EX_VOICECALL; - } + debug_fenter(); + if (state == SESSION_START) { + debug_log ("voicecall session started..."); - if (AVSYS_FAIL(avsys_audio_set_path_ex( gain, - AVSYS_AUDIO_PATH_EX_NONE, AVSYS_AUDIO_PATH_EX_NONE, - AVSYS_AUDIO_PATH_OPTION_NONE ))) { - debug_error ("avsys_audio_set_path_ex() failed [%x]\n", ret); - ret = MM_ERROR_SOUND_INTERNAL; - goto ROUTE_COMM_EXIT; - } + /* Backup current active for future restore */ + __backup_current_active_device(); + /* Set default subsession as MEDIA */ + g_info.subsession = SUBSESSION_MEDIA; +#ifndef TIZEN_MICRO /* (speaker = receiver, headset = headset, bt a2dp = bt sco) */ /* OUT */ - if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_RECEIVER)) { - debug_log ("active out was RECEIVER => activate SPEAKER!!\n"); - SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_SPEAKER); - } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_SCO)) { - debug_log ("active out was BT SCO => activate BT A2DP!!\n"); - SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP); - if (IS_AVAILABLE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY)) { - SET_CAPTURE_ONLY_ACTIVE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY); - } else { - SET_CAPTURE_ONLY_ACTIVE(MM_SOUND_DEVICE_IN_MIC); - } - } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_SPEAKER) || IS_ACTIVE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY)) { - debug_log ("Keep current active device\n"); - } else { - debug_error ("Error!!! No active device when call exit!!! Set default one\n"); - /* FIXME : This should be based on priority???? */ - SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_SPEAKER); - SET_CAPTURE_ONLY_ACTIVE(MM_SOUND_DEVICE_IN_MIC); + if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_SPEAKER)) { + debug_log ("active out was SPEAKER => activate receiver!!\n"); + SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_RECEIVER); + } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP)) { + debug_log ("active out was BT A2DP => activate BT SCO!!\n"); + SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_BT_SCO); + SET_CAPTURE_ONLY_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO); } + /* FIXME : Do we have to set IN device ??? */ + /* __set_path_with_notification(DO_NOTI); */ + /* For sharing device information with PulseAudio */ + MMSoundMgrPulseSetActiveDevice(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK()); +#endif + dump_info(); + } else { + /* SESSION_END */ + debug_log ("Reset ACTIVE, activate previous active device if still available, if not, set based on priority"); + __restore_previous_active_device(); debug_log ("voicecall session stopped...set path based on current active device"); - _set_path_with_notification(DO_NOTI); + __set_route(true, false); dump_info(); } - -ROUTE_COMM_EXIT: - debug_fleave(); return ret; @@ -397,69 +519,71 @@ ROUTE_COMM_EXIT: static int __set_playback_route_fmradio (session_state_t state) { int ret = MM_ERROR_NONE; - int out; + int out = MM_SOUND_DEVICE_OUT_NONE; debug_fenter(); if (state == SESSION_START) { - if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_SPEAKER)) - out = AVSYS_AUDIO_PATH_EX_SPK; + out = MM_SOUND_DEVICE_OUT_SPEAKER; else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY)) - out = AVSYS_AUDIO_PATH_EX_HEADSET; + out = MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY; else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP)) - out = AVSYS_AUDIO_PATH_EX_A2DP; - - /* PATH SET */ - if (AVSYS_FAIL(avsys_audio_set_path_ex( AVSYS_AUDIO_GAIN_EX_FMRADIO, - out, AVSYS_AUDIO_PATH_EX_FMINPUT, - AVSYS_AUDIO_PATH_OPTION_NONE))) { - debug_error ("avsys_audio_set_path_ex() failed\n"); - ret = MM_ERROR_SOUND_INTERNAL; - goto ROUTE_FMRADIO_EXIT; - } - - - } else { /* SESSION_END */ - /* PATH RELEASE */ - if (AVSYS_FAIL(avsys_audio_set_path_ex( AVSYS_AUDIO_GAIN_EX_FMRADIO, - AVSYS_AUDIO_PATH_EX_NONE, AVSYS_AUDIO_PATH_EX_NONE, - AVSYS_AUDIO_PATH_OPTION_NONE ))) { - debug_error ("avsys_audio_set_path_ex() failed\n"); - ret = MM_ERROR_SOUND_INTERNAL; - goto ROUTE_FMRADIO_EXIT; - } - + out = MM_SOUND_DEVICE_OUT_BT_A2DP; + /* Note : FM radio input is internal device, not exported */ + } else { + /* SESSION_END */ /* Set as current active status */ - _set_path_with_notification (NO_NOTI); + /* FIXME : Need to release path on fm radio scenario */ + __set_route(false, false); } + /* FIXME : Need to update device status */ + debug_fleave(); + return ret; +} - if (AVSYS_FAIL(avsys_audio_set_ext_device_status(AVSYS_AUDIO_EXT_DEVICE_FMRADIO, state))) { - debug_error ("avsys_audio_set_ext_device_status() failed\n"); - ret = MM_ERROR_SOUND_INTERNAL; - } +static int __set_playback_route_notification (session_state_t state) +{ + int ret = MM_ERROR_NONE; -ROUTE_FMRADIO_EXIT: + debug_fenter(); + if (state == SESSION_START) { + /* FIXME : Need to check using vconf key with check status and policy */ + if (_mm_sound_is_recording() || _mm_sound_is_mute_policy()) { + /* Force earphone path for mute case */ + if ((ret = __set_sound_path_to_earphone_only ()) != MM_ERROR_NONE) { + debug_error ("__set_sound_path_to_earphone_only() failed [%x]\n", ret); + } + } else { + /* In case of B2s, lockup issue is occurred */ + /* No HEADSET device */ + /* No matter on YMU chipset */ + if ((ret = __set_sound_path_to_dual ()) != MM_ERROR_NONE) { + debug_error ("__set_sound_path_to_dual() failed [%x]\n", ret); + } + } + } else { + /* SESSION_END */ + __set_route(false, false); + } debug_fleave(); return ret; } -static int __set_playback_route_notification (session_state_t state) +static int __set_playback_route_alarm (session_state_t state) { int ret = MM_ERROR_NONE; debug_fenter(); if (state == SESSION_START) { - ret = __set_sound_path_to_dual (); - if (ret != MM_ERROR_NONE) { + if ((ret = __set_sound_path_to_dual ()) != MM_ERROR_NONE) { debug_error ("__set_sound_path_to_dual() failed [%x]\n", ret); } - } else { /* SESSION_END */ - _set_path_with_notification (NO_NOTI); + __set_route(false, false); } debug_fleave(); @@ -467,228 +591,782 @@ static int __set_playback_route_notification (session_state_t state) return ret; } - -static int __set_sound_path_for_current_active () +static int __set_playback_route_emergency (session_state_t state) { int ret = MM_ERROR_NONE; - int option = AVSYS_AUDIO_PATH_OPTION_NONE; - int in, out, gain; - bool sound_play; - - if (IS_NOTIFICATION_SESSION()) { - debug_log ("Current session is NOTI, pending path setting. path set will be done after NOTI ends") - return ret; - } debug_fenter(); - /* Pulseaudio route */ - if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP)) { - debug_log ("BT A2DP is active, Set default sink to BLUEZ"); - MMSoundMgrPulseSetDefaultSink (DEFAULT_SINK_BT); - } else { - debug_log ("BT A2DP is not active, Set default sink to ALSA"); - MMSoundMgrPulseSetDefaultSink (DEFAULT_SINK_ALSA); - } - - /* IN */ - if (IS_ACTIVE(MM_SOUND_DEVICE_IN_MIC)) { - in = AVSYS_AUDIO_PATH_EX_MIC; - } else if (IS_ACTIVE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY)) { - in = AVSYS_AUDIO_PATH_EX_HEADSETMIC; - } else if (IS_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO)) { - in = AVSYS_AUDIO_PATH_EX_BTMIC; - } - - /* OUT */ - if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_SPEAKER)) { - out = AVSYS_AUDIO_PATH_EX_SPK; - } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_RECEIVER)) { - out = AVSYS_AUDIO_PATH_EX_RECV; - } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY)) { - out = AVSYS_AUDIO_PATH_EX_HEADSET; - } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_SCO)) { - out = AVSYS_AUDIO_PATH_EX_BTHEADSET; - } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP)) { - out = AVSYS_AUDIO_PATH_EX_A2DP; - } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_DOCK)) { - out = AVSYS_AUDIO_PATH_EX_DOCK; - } - - /* GAIN */ - switch (g_info.session) - { - case SESSION_MEDIA: - case SESSION_NOTIFICATION: - gain = AVSYS_AUDIO_GAIN_EX_KEYTONE; - break; - - case SESSION_VOICECALL: - case SESSION_VOIP: - if (g_info.subsession == SUBSESSION_RINGTONE) { - gain = AVSYS_AUDIO_GAIN_EX_RINGTONE; - in = AVSYS_AUDIO_PATH_EX_NONE; - - /* If sound is mute mode, force ringtone path to headset */ - vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_play); - if (sound_play) { - /* Normal Ringtone */ - out = AVSYS_AUDIO_PATH_EX_SPK; - option = AVSYS_AUDIO_PATH_OPTION_DUAL_OUT; - } else { - /* Mute Ringtone */ - out = AVSYS_AUDIO_PATH_EX_HEADSET; - } - } else if (g_info.subsession == SUBSESSION_MEDIA) { - gain = AVSYS_AUDIO_GAIN_EX_CALLTONE; - in = AVSYS_AUDIO_PATH_EX_NONE; - } else { - gain = (g_info.session == SESSION_VOICECALL)? - AVSYS_AUDIO_GAIN_EX_VOICECALL : AVSYS_AUDIO_GAIN_EX_VIDEOCALL; + if (state == SESSION_START) { + ret = __set_sound_path_to_speaker (); + if (ret != MM_ERROR_NONE) { + debug_error ("__set_sound_path_to_speaker() failed [%x]\n", ret); } - break; - - case SESSION_FMRADIO: - gain = AVSYS_AUDIO_GAIN_EX_FMRADIO; - in = AVSYS_AUDIO_PATH_EX_FMINPUT; - break; - } - debug_log ("Trying to set avsys set path gain[%d], out[%d], in[%d], option[%d]\n", gain, out, in, option); - - /* Set Path */ - if(AVSYS_FAIL(avsys_audio_set_path_ex(gain, out, in, option))) { - debug_error ("avsys_audio_set_path_ex failed\n"); - ret = MM_ERROR_SOUND_INTERNAL; + } else { /* SESSION_END */ + __set_route(false, false); } - /* clean up */ debug_fleave(); + return ret; } - -static int __set_sound_path_to_dual () +static int __set_playback_route_voicerecognition (session_state_t state) { int ret = MM_ERROR_NONE; debug_fenter(); - /* Sound path for ALSA */ - debug_log ("Set path to DUAL.\n"); - if(AVSYS_FAIL(avsys_audio_set_path_ex(AVSYS_AUDIO_GAIN_EX_KEYTONE, - AVSYS_AUDIO_PATH_EX_SPK, AVSYS_AUDIO_PATH_EX_NONE, - AVSYS_AUDIO_PATH_OPTION_DUAL_OUT))) { - debug_error ("avsys_audio_set_path_ex failed\n"); - ret = MM_ERROR_SOUND_INTERNAL; + if (state == SESSION_START) { + g_info.subsession = SUBSESSION_INIT; + /* audio path is changed when subsession is set */ + } else { /* SESSION_END */ + /* FIXME : On MICRO profile, need to check release path here */ + __set_route(true, false); } - /* clean up */ debug_fleave(); + return ret; } +#if 0 +/* FIXME : Need to check for private function */ +static int __set_playback_route_timer_shot_and_recorder (subsession_state_t state) +{ + int ret = MM_ERROR_NONE; + mm_sound_device_in device_in_after = MM_SOUND_DEVICE_IN_NONE; + mm_sound_device_out device_out_after = MM_SOUND_DEVICE_OUT_NONE; + bool is_available = 0; + debug_fenter(); + LOCK_PATH(); + if (state == SUBSESSION_START) { + MMSoundMgrSessionGetDeviceActive(&g_info.device_out_previous, &g_info.device_in_previous); + g_info.device_available_previous = g_info.device_available; + if(g_info.device_out_previous != MM_SOUND_DEVICE_OUT_SPEAKER) { + __set_sound_path_for_active_device_nolock(MM_SOUND_DEVICE_OUT_SPEAKER, MM_SOUND_DEVICE_IN_NONE); + } + /* audio path is changed when subsession is set */ + } else { /* SESSION_END */ + MMSoundMgrSessionGetDeviceActive(&device_out_after, &device_in_after); + if(device_out_after != MM_SOUND_DEVICE_OUT_SPEAKER) { + __set_sound_path_for_active_device_nolock(device_out_after, device_in_after); + } else if(device_out_after == MM_SOUND_DEVICE_OUT_SPEAKER && g_info.device_out_previous != MM_SOUND_DEVICE_OUT_SPEAKER) { + MMSoundMgrSessionIsDeviceAvailable(g_info.device_out_previous, g_info.device_in_previous, &is_available); + if(is_available) { + __set_sound_path_for_active_device_nolock(g_info.device_out_previous, g_info.device_in_previous); + } else { + __select_playback_active_device(); + __select_capture_active_device(); + MMSoundMgrSessionGetDeviceActive(&device_out_after, &device_in_after); + if(device_out_after != MM_SOUND_DEVICE_OUT_SPEAKER) { + __set_sound_path_for_active_device_nolock(device_out_after, device_in_after); + } + } + } + MMSoundMgrSessionGetDeviceActive(&g_info.device_out_previous, &g_info.device_in_previous); + g_info.device_available_previous = g_info.device_available; + } + UNLOCK_PATH(); -static void _select_playback_active_device () -{ - if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_ANY)) { - debug_log ("Active device exists. Nothing needed...\n"); - return; - } + debug_fleave(); - debug_log ("No playback active device, set active based on priority!!\n"); + return ret; +} +#endif - /* set active device based on device priority (bt>ear>spk) */ - if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_A2DP)) { - debug_log ("BT A2DP available, set as active!!\n"); - SET_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP); - } else if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_DOCK)) { - debug_log ("DOCK available, set as active!!\n"); - SET_ACTIVE(MM_SOUND_DEVICE_OUT_DOCK); - } else if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY)) { - debug_log ("WIRED available, set as active!!\n"); - SET_ACTIVE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY); - } else { - debug_log ("SPEAKER available, set as active!!\n"); - SET_ACTIVE(MM_SOUND_DEVICE_OUT_SPEAKER); - } +static bool __is_forced_session () +{ + return (IS_ALARM_SESSION() || IS_NOTIFICATION_SESSION() || IS_EMERGENCY_SESSION())? true : false; } -static void _select_capture_active_device () +static bool __is_recording_subsession () { - if (IS_ACTIVE(MM_SOUND_DEVICE_IN_ANY)) { - debug_log ("Active device exists. Nothing needed...\n"); - return; + /* FIXME : Need to check routing option flag */ + /* On private, by record option routing flag is changed */ + bool is_recording = true; + switch (g_info.subsession) { + case SUBSESSION_RECORD_STEREO: + case SUBSESSION_RECORD_MONO: + break; + default: + is_recording = false; + break; } + return is_recording; +} - debug_log ("No capture active device, set active based on priority!!\n"); - - /* set active device based on device priority (bt>ear>spk) */ - if (IS_AVAILABLE(MM_SOUND_DEVICE_IN_BT_SCO) && IS_COMMUNICATION_SESSION()) { - debug_log ("BT SCO available, set as active!!\n"); - SET_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO); - } else if (IS_AVAILABLE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY)) { - debug_log ("WIRED available, set as active!!\n"); - SET_ACTIVE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY); - } else { - debug_log ("MIC available, set as active!!\n"); - SET_ACTIVE(MM_SOUND_DEVICE_IN_MIC); - } +static void _wait_if_burstshot_exists(void) +{ + int retry = 0; + int is_burstshot = 0; + + do { + if (retry > 0) + usleep (BURST_CHECK_INTERVAL); + if (vconf_get_int(VCONF_SOUND_BURSTSHOT, &is_burstshot) != 0) { + debug_warning ("Faided to get [%s], assume no burstshot....", VCONF_SOUND_BURSTSHOT); + is_burstshot = 0; + } else { + debug_warning ("Is Burstshot [%d], retry...[%d/%d], interval usec = %d", + is_burstshot, retry, MAX_BURST_CHECK_RETRY, BURST_CHECK_INTERVAL); + } + } while (is_burstshot && retry++ < MAX_BURST_CHECK_RETRY); } -static void _set_initial_active_device () + +static int __set_sound_path_for_current_active (bool need_broadcast, bool need_cork) { - int type = 0; - bool a2dp = 0, sco = 0; + int ret = MM_ERROR_NONE; + int in = 0, out = 0; - /* Set SPK & MIC as default available device */ - /* FIXME : spk & mic can be always on??? */ - SET_AVAILABLE(MM_SOUND_DEVICE_OUT_SPEAKER); - SET_AVAILABLE(MM_SOUND_DEVICE_IN_MIC); + debug_fenter(); + debug_msg ("session:%s, subsession:%s, option:%d, active in:0x%x, out:0x%x, need_cork:%d", + __get_session_string(g_info.session), __get_subsession_string(g_info.subsession), + g_info.option, GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK(), need_cork); - /* Get wired status and set available status */ - MMSoundMgrHeadsetGetType (&type); - if (type > 0) { - SET_AVAILABLE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY); - if (type == EARJACK_WITH_MIC) { - SET_AVAILABLE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY); - } + if (__is_forced_session()) { + debug_warning ("Current session is ALARM/NOTI/EMER, pending path setting. path set will be done after session ends"); + return MM_ERROR_SOUND_INVALID_STATE; + } + + /* Wait if BurstShot is ongoing */ + _wait_if_burstshot_exists(); + + if (need_cork) + MMSoundMgrPulseSetCorkAll (true); + + in = GET_ACTIVE_CAPTURE(); + out = GET_ACTIVE_PLAYBACK(); + +#ifdef TIZEN_MICRO + /* Wearable BT SCO headset case. Should be check nrec, wb, hf does't use sco */ + if (in == MM_SOUND_DEVICE_IN_BT_SCO && out == MM_SOUND_DEVICE_OUT_BT_SCO) { + bool nrec = 0; + int bandwidth = MM_SOUND_BANDWIDTH_UNKNOWN; + + ret = MMSoundMgrPulseGetBluetoothInfo(&nrec, &bandwidth); + if(ret == MM_ERROR_NONE) { + g_info.bt_info.is_nrec = nrec; + g_info.bt_info.ag_wb = bandwidth; + debug_msg("get bt information successfully. nrec(%d), wb(%s)", + g_info.bt_info.is_nrec, __get_bt_bandwidth_string(g_info.bt_info.ag_wb)); + } else { + g_info.bt_info.is_nrec = false; + g_info.bt_info.ag_wb = MM_SOUND_BANDWIDTH_NB; + debug_msg("failed to get bt information. use default setting. nrec(off), wb(off)"); + } + /* FIXME : How to send status of nrec & ag wideband state with option flag, on MICRO profile */ + } +#else + if (in == MM_SOUND_DEVICE_IN_BT_SCO && out == MM_SOUND_DEVICE_OUT_BT_SCO) { + /* FIXME : How to send status of nrec & ag wideband state with option flag */ + } +#endif + + /* prepare GAIN */ + switch (g_info.session) { + case SESSION_MEDIA: + case SESSION_NOTIFICATION: + case SESSION_ALARM: + case SESSION_EMERGENCY: + if (IS_MEDIA_SESSION() && __is_recording_subsession()) { + /* gain & recording option */ + } else { + /* gain option */ + if (g_info.is_voicecontrol) { + debug_warning ("VoiceControl"); + /* voice control option */ + } + } + break; + case SESSION_VOIP: + if (g_info.subsession == SUBSESSION_RINGTONE) { + in = MM_SOUND_DEVICE_OUT_NONE; + /* gain option */ + /* If active device was WFD(mirroring), set option */ + if (out == MM_SOUND_DEVICE_OUT_MIRRORING) { + /* mirroring option */ + } + if (_mm_sound_is_mute_policy ()) { + /* Mute Ringtone */ + out = MM_SOUND_DEVICE_OUT_BT_A2DP; + } else { + /* Normal Ringtone */ + out = MM_SOUND_DEVICE_OUT_SPEAKER; + /* dual out option */ + } + } else if (g_info.subsession == SUBSESSION_VOICE) { + /* gain option */ + } else { + debug_warning ("Unexpected SUBSESSION [%s]\n", __get_subsession_string(g_info.subsession)); + /* gain voip option */ + } + break; + + case SESSION_VOICECALL: + case SESSION_VIDEOCALL: + if (g_info.subsession == SUBSESSION_RINGTONE) { +#ifndef _TIZEN_PUBLIC_ +#ifndef TIZEN_MICRO + int vr_enabled = 0; +#endif + int vr_ringtone_enabled = 0; +#endif + in = MM_SOUND_DEVICE_IN_NONE; + /* If active device was WFD(mirroring), set option */ + if (out == MM_SOUND_DEVICE_OUT_MIRRORING) { + /* mirroring option */ + } + +#ifndef _TIZEN_PUBLIC_ +#ifdef TIZEN_MICRO + if (vconf_get_bool(VCONF_KEY_VR_RINGTONE_ENABLED, &vr_ringtone_enabled)) { + debug_warning("vconf_get_bool for %s failed\n", VCONF_KEY_VR_RINGTONE_ENABLED); + } + + if (vr_ringtone_enabled) { + /* bargin option */ + } +#else + /* If voice control for incoming call is enabled, set capture path here for avoiding ringtone breaks */ + if (vconf_get_bool(VCONF_KEY_VR_ENABLED, &vr_enabled)) { + debug_warning("vconf_get_bool for %s failed\n", VCONF_KEY_VR_ENABLED); + } else if (vconf_get_bool(VCONF_KEY_VR_RINGTONE_ENABLED, &vr_ringtone_enabled)) { + debug_warning("vconf_get_bool for %s failed\n", VCONF_KEY_VR_RINGTONE_ENABLED); + } + + if (vr_enabled && vr_ringtone_enabled) { + /* bargin option */ + } +#endif /* TIZEN_MICRO */ +#endif /* #ifndef _TIZEN_PUBLIC_ */ + if (_mm_sound_is_mute_policy ()) { + /* Mute Ringtone */ +#ifdef TIZEN_MICRO + out = MM_SOUND_DEVICE_OUT_SPEAKER; +#else + out = MM_SOUND_DEVICE_OUT_BT_A2DP; +#endif + } else { + out = MM_SOUND_DEVICE_OUT_SPEAKER; +#ifdef TIZEN_MICRO + /* for inband ringtone. hfp call ringtone is not used sco */ + int state = MM_SOUND_HFP_STATUS_UNKNOWN; + state = __get_hf_connection_state(); + + if(state == MM_SOUND_HFP_STATUS_INCOMMING_CALL) { + /* call by BT option */ + } +#endif + /* Normal Ringtone */ + /* dual out option */ + } + } else if (g_info.subsession == SUBSESSION_MEDIA) { + /* call gain option */ + in = MM_SOUND_DEVICE_IN_NONE; + } else if (g_info.subsession == SUBSESSION_VOICE) { + /* gain for voicecall or videocall */ +#ifdef _TIZEN_PUBLIC_ + if (out == MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY) { + debug_log ("Fix in path to headsetmic when out path is headset\n"); + in = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY; + } + /* FIXME : Check to NB / WB option */ +#endif /* _TIZEN_PUBLIC_*/ + } else { + debug_warning ("Unexpected SUBSESSION [%s]\n", __get_subsession_string(g_info.subsession)); + } + break; + + case SESSION_FMRADIO: + break; + + case SESSION_VOICE_RECOGNITION: +#ifdef TIZEN_MICRO + if (__is_right_hand_on()) { + } +#endif + if (g_info.subsession == SUBSESSION_VR_NORMAL) { + /* NORMAL mode */ + } else if (g_info.subsession == SUBSESSION_VR_DRIVE) { + /* DRIVE mode */ + /* FIXME : Need to check private mode or not */ + } else { + debug_warning ("Unexpected SUBSESSION [%s]\n", __get_subsession_string(g_info.subsession)); + } + break; + default: + debug_warning ("session [%s] is not handled...\n", __get_session_string(g_info.session)); + break; + } + + debug_warning ("Trying to set device to pulseaudio : in[%d], out[%d]\n", in, out); + + /* Update Pulseaudio Active Device */ + if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP)) { + MMSoundMgrPulseSetActiveDevice(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK()); + } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_USB_AUDIO)) { + MMSoundMgrPulseSetActiveDevice(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK()); + } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK)) { + MMSoundMgrPulseSetActiveDevice(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK()); + } else { + /* ALSA route */ + MMSoundMgrPulseSetActiveDevice(in, out); + } + + /* Pulseaudio Default Sink route */ + if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP)) { + MMSoundMgrPulseSetDefaultSink (DEVICE_API_BLUETOOTH, DEVICE_BUS_BLUETOOTH); + } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_USB_AUDIO)) { + MMSoundMgrPulseSetUSBDefaultSink (MM_SOUND_DEVICE_OUT_USB_AUDIO); + } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK)) { + MMSoundMgrPulseSetUSBDefaultSink (MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK); + } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_HDMI)) { + MMSoundMgrPulseSetDefaultSinkByName (ALSA_SINK_HDMI); + } else { + MMSoundMgrPulseSetDefaultSink (DEVICE_API_ALSA, DEVICE_BUS_BUILTIN); + } + + /* Set Source Mute */ + MMSoundMgrPulseSetSourcemutebyname(MIRRORING_MONITOR_SOURCE, + IS_ACTIVE(MM_SOUND_DEVICE_OUT_MIRRORING)? MM_SOUND_AUDIO_UNMUTE : MM_SOUND_AUDIO_MUTE); + + if (need_broadcast) { + /* Notify current active device */ + ret = _mm_sound_mgr_device_active_device_callback(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK()); + if (ret != MM_ERROR_NONE) { + debug_error ("_mm_sound_mgr_device_active_device_callback() failed [%x]\n", ret); + } + } + + if (need_cork) { + /* FIXME : Private issues, workaround for earjack inserting scenario during media playback */ + if (g_info.session == SESSION_MEDIA && (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP) || IS_ACTIVE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY))) { + usleep(20000); + } + MMSoundMgrPulseSetCorkAll (false); + } + MMSoundMgrPulseUpdateVolume(); + + /* clean up */ + debug_fleave(); + return ret; +} + +static int __set_sound_path_for_voicecontrol (void) +{ + int ret = MM_ERROR_NONE; + int in = MM_SOUND_DEVICE_IN_NONE, out = MM_SOUND_DEVICE_OUT_NONE; + + debug_fenter(); + + /* prepare IN */ + if (IS_ACTIVE(MM_SOUND_DEVICE_IN_MIC)) { + in = MM_SOUND_DEVICE_IN_MIC; + } else if (IS_ACTIVE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY)) { + in = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY; + } else if (IS_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO)) { + debug_warning ("[NOT EXPECTED CASE] BT SCO"); + } + + debug_warning ("g_info.session = %s ", __get_session_string(g_info.session)); + /* prepare GAIN */ + switch (g_info.session) { + case SESSION_MEDIA: + case SESSION_NOTIFICATION: + case SESSION_ALARM: + case SESSION_EMERGENCY: + case SESSION_VOICECALL: + case SESSION_VIDEOCALL: + case SESSION_VOIP: + if (IS_MEDIA_SESSION() && __is_recording_subsession(NULL)) { + debug_warning ("[NOT EXPECTED CASE] already RECORDING....return"); + return MM_ERROR_NONE; + } + /* gain control KEYTONE */ + if (g_info.is_voicecontrol) { +#ifdef TIZEN_MICRO + /* For inband ringtone. hfp call ringtone is not used sco */ + int state = MM_SOUND_HFP_STATUS_UNKNOWN; + state = __get_hf_connection_state(); + if(state == MM_SOUND_HFP_STATUS_INCOMMING_CALL) { + /* Call by BT option */ + } +#endif + debug_warning ("VoiceControl\n"); + /* Bargein option */ + } + break; + + case SESSION_FMRADIO: + case SESSION_VOICE_RECOGNITION: + debug_warning ("[NOT EXPECTED CASE] "); + break; + + default: + debug_warning ("session [%s] is not handled...\n", __get_session_string(g_info.session)); + break; + } + + debug_warning ("Trying to set device to pulseaudio : in[%d], out[%d]\n", in, GET_ACTIVE_PLAYBACK()); + + /* Set Path (IN, OUT) */ + MMSoundMgrPulseSetActiveDevice(in, GET_ACTIVE_PLAYBACK()); + + debug_fleave(); + return ret; + +} + + +static int __set_sound_path_to_dual (void) +{ + int ret = MM_ERROR_NONE; + int in = MM_SOUND_DEVICE_IN_NONE; + + debug_fenter(); + + in = IS_ACTIVE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY)? MM_SOUND_DEVICE_IN_WIRED_ACCESSORY : MM_SOUND_DEVICE_IN_MIC; + + /* If active device was WFD(mirroring), set option */ + if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_MIRRORING)) { + /* mirorring option */ + } + if (g_info.is_voicecontrol) { + debug_msg ("VoiceControl\n"); + /* bargein option */ + } + /* Sound path for ALSA */ + debug_msg ("not supported, set path to DUAL-OUT"); + MMSoundMgrPulseSetActiveDevice(in, MM_SOUND_DEVICE_OUT_SPEAKER); + + /* clean up */ + debug_fleave(); + return ret; +} + +static int __set_sound_path_to_earphone_only (void) +{ + int ret = MM_ERROR_NONE; + int in = MM_SOUND_DEVICE_IN_NONE; + + debug_fenter(); + + in = IS_ACTIVE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY)? MM_SOUND_DEVICE_IN_WIRED_ACCESSORY : MM_SOUND_DEVICE_IN_MIC; + + if (g_info.is_voicecontrol) { + debug_msg ("VoiceControl\n"); + /* bargein option */ + } + + /* Sound path for ALSA */ + debug_msg ("Set path to EARPHONE only.\n"); + MMSoundMgrPulseSetActiveDevice(in, MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY); + + /* clean up */ + debug_fleave(); + return ret; +} + +int MMSoundMgrSessionSetSoundPathForActiveDevice (mm_sound_device_out playback, mm_sound_device_in capture) +{ + int ret = MM_ERROR_NONE; + + debug_fenter(); + + /* Sound path for ALSA */ + debug_log ("Set path for active device.playback:%x, capture:%x\n",playback,capture); + if ((playback && !IS_AVAILABLE(playback)) || (capture && !IS_AVAILABLE(capture))) { + debug_warning ("Failed to set active state to unavailable device!!!\n"); + ret = MM_ERROR_INVALID_ARGUMENT; + goto END_SET_DEVICE; + } + + LOCK_PATH(); + /* Update active state */ + debug_log ("Update active device as request\n"); + if (playback) { + SET_PLAYBACK_ONLY_ACTIVE(playback); + } + if (capture) { + SET_CAPTURE_ONLY_ACTIVE(capture); + } + MMSoundMgrPulseSetActiveDevice(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK()); + UNLOCK_PATH(); + +END_SET_DEVICE: + debug_fleave(); + return ret; +} + +static int __set_sound_path_for_active_device_nolock (mm_sound_device_out playback, mm_sound_device_in capture) +{ + int ret = MM_ERROR_NONE; + + debug_fenter(); + + /* Sound path for ALSA */ + debug_log ("Set path for active device.playback:%x, capture:%x\n",playback,capture); + if ((playback && !IS_AVAILABLE(playback)) || (capture && !IS_AVAILABLE(capture))) { + debug_warning ("Failed to set active state to unavailable device!!!\n"); + ret = MM_ERROR_INVALID_ARGUMENT; + goto END_SET_DEVICE; + } + + /* Update active state */ + debug_log ("Update active device as request\n"); + if (playback) { + SET_PLAYBACK_ONLY_ACTIVE(playback); + } + if (capture) { + SET_CAPTURE_ONLY_ACTIVE(capture); + } + MMSoundMgrPulseSetActiveDevice(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK()); + +END_SET_DEVICE: + debug_fleave(); + return ret; +} + +static int __set_sound_path_to_speaker (void) +{ + int ret = MM_ERROR_NONE; + + debug_fenter(); + + /* Sound path for ALSA */ + debug_log ("Set path to SPEAKER.\n"); + MMSoundMgrPulseSetActiveDevice(GET_ACTIVE_CAPTURE(), MM_SOUND_DEVICE_OUT_SPEAKER); + + /* clean up */ + debug_fleave(); + return ret; +} + +static void __select_playback_active_device (void) +{ + if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_ANY)) { + debug_log ("Active device exists. Nothing needed...\n"); + return; + } + + debug_warning ("No playback active device, set active based on priority!!\n"); + + /* set active device based on device priority (bt>ear>spk) */ + if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_A2DP)) { + debug_log ("BT A2DP available, set as active!!\n"); + SET_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP); + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_IO_DIRECTION, DEVICE_TYPE_BLUETOOTH, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL); + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BLUETOOTH, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL); + } else if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_MIRRORING)) { + debug_log ("MIRRORING available, set as active!!\n"); + SET_ACTIVE(MM_SOUND_DEVICE_OUT_MIRRORING); + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_MIRRORING, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL); + } else if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_DOCK)) { + debug_log ("DOCK available, set as active!!\n"); + SET_ACTIVE(MM_SOUND_DEVICE_OUT_DOCK); + } else if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_HDMI)) { + debug_log ("HDMI available, set as active!!\n"); + SET_ACTIVE(MM_SOUND_DEVICE_OUT_HDMI); + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_HDMI, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL); + } else if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_USB_AUDIO)) { + debug_log ("USB Audio available, set as active!!\n"); + SET_ACTIVE(MM_SOUND_DEVICE_OUT_USB_AUDIO); + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_USB_AUDIO, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL); + } else if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK)) { + debug_log ("Multimedia Dock available, set as active!!\n"); + SET_ACTIVE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK); + } else if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY)) { + debug_log ("WIRED available, set as active!!\n"); + SET_ACTIVE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY); + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_AUDIOJACK, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL); + } else { + debug_log ("SPEAKER/RECEIVER available, set SPEAKER as active!!\n"); + SET_ACTIVE(MM_SOUND_DEVICE_OUT_SPEAKER); + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BUILTIN_SPEAKER, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL); + } +} + +static void __select_capture_active_device (void) +{ + if (IS_ACTIVE(MM_SOUND_DEVICE_IN_ANY)) { + debug_log ("Active device exists. Nothing needed...\n"); + return; + } + + debug_warning ("No capture active device, set active based on priority!!\n"); + + /* set active device based on device priority (bt>ear>spk) */ + if (IS_AVAILABLE(MM_SOUND_DEVICE_IN_BT_SCO) && IS_CALL_SESSION()) { + debug_log ("BT SCO available, set as active!!\n"); + SET_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO); + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BLUETOOTH, DEVICE_IO_DIRECTION_BOTH, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL); + } else if (IS_AVAILABLE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY)) { + debug_log ("WIRED available, set as active!!\n"); + SET_ACTIVE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY); + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_AUDIOJACK, DEVICE_IO_DIRECTION_BOTH, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL); + } else { + debug_log ("MIC available, set as active!!\n"); + SET_ACTIVE(MM_SOUND_DEVICE_IN_MIC); + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BUILTIN_MIC, DEVICE_IO_DIRECTION_IN, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL); + } +} + +static int __get_device_type_from_old_device (int old_device_type, device_type_e *device_type) +{ + int ret = MM_ERROR_NONE; + + switch(old_device_type) { + case MM_SOUND_DEVICE_IN_MIC: + *device_type = DEVICE_TYPE_BUILTIN_MIC; + break; + case MM_SOUND_DEVICE_IN_WIRED_ACCESSORY: + case MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY: + *device_type = DEVICE_TYPE_AUDIOJACK; + break; + case MM_SOUND_DEVICE_IN_BT_SCO: + case MM_SOUND_DEVICE_OUT_BT_SCO: + case MM_SOUND_DEVICE_OUT_BT_A2DP: + *device_type = DEVICE_TYPE_BLUETOOTH; + break; + case MM_SOUND_DEVICE_OUT_SPEAKER: + *device_type = DEVICE_TYPE_BUILTIN_SPEAKER; + break; + case MM_SOUND_DEVICE_OUT_RECEIVER: + *device_type = DEVICE_TYPE_BUILTIN_RECEIVER; + break; + case MM_SOUND_DEVICE_OUT_HDMI: + *device_type = DEVICE_TYPE_HDMI; + break; + case MM_SOUND_DEVICE_OUT_MIRRORING: + *device_type = DEVICE_TYPE_MIRRORING; + break; + case MM_SOUND_DEVICE_OUT_USB_AUDIO: + *device_type = DEVICE_TYPE_USB_AUDIO; + break; + default: + ret = MM_ERROR_NOT_SUPPORT_API; + break; + } + return ret; +} + +static void __set_deactivate_all_device_auto (mm_sound_device_in exception_in, mm_sound_device_out exception_out) +{ + /* DEACTIVATE OTHERS */ + /* IN */ + if (exception_in != MM_SOUND_DEVICE_IN_MIC) { + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BUILTIN_MIC, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL); + } + if ((exception_in != MM_SOUND_DEVICE_IN_WIRED_ACCESSORY) && (exception_out != MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY)) { + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_AUDIOJACK, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL); + } + if ((exception_in != MM_SOUND_DEVICE_IN_BT_SCO) && (exception_out != MM_SOUND_DEVICE_OUT_BT_A2DP) && (exception_out != MM_SOUND_DEVICE_OUT_BT_SCO)) { + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BLUETOOTH, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL); + } + /* OUT */ + if (exception_out != MM_SOUND_DEVICE_OUT_SPEAKER) { + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BUILTIN_SPEAKER, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL); + } + if (exception_out != MM_SOUND_DEVICE_OUT_RECEIVER) { + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BUILTIN_RECEIVER, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL); + } + if ((exception_out != MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY) && (exception_in != MM_SOUND_DEVICE_IN_WIRED_ACCESSORY)) { + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_AUDIOJACK, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL); + } + if (exception_out != MM_SOUND_DEVICE_OUT_MIRRORING) { + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_MIRRORING, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL); + } + if (exception_out != MM_SOUND_DEVICE_OUT_USB_AUDIO) { + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_USB_AUDIO, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL); + } + if ((exception_out != MM_SOUND_DEVICE_OUT_BT_A2DP) && (exception_out != MM_SOUND_DEVICE_OUT_BT_SCO) && (exception_in != MM_SOUND_DEVICE_IN_BT_SCO)) { + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BLUETOOTH, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL); + } + if (exception_out != MM_SOUND_DEVICE_OUT_HDMI) { + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_HDMI, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL); + } +} + +static void __set_initial_active_device (void) +{ + int dock_type = 0; + bool a2dp = 0, sco = 0; + + /* Set SPK/RECIEVER(for OUT) & MIC(for IN) as default available device */ + /* FIXME : spk & mic can be always on??? */ +#ifdef TIZEN_MICRO + SET_AVAILABLE(MM_SOUND_DEVICE_OUT_SPEAKER); +#else + SET_AVAILABLE(MM_SOUND_DEVICE_OUT_SPEAKER|MM_SOUND_DEVICE_OUT_RECEIVER); +#endif + SET_AVAILABLE(MM_SOUND_DEVICE_IN_MIC); + + /* Get wired status and set available status */ + _mm_sound_get_earjack_type (&g_info.headset_type); + if (g_info.headset_type > EARJACK_UNPLUGGED) { + SET_AVAILABLE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY); + if (g_info.headset_type == DEVICE_EARJACK_TYPE_SPK_WITH_MIC) { + SET_AVAILABLE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY); + MMSoundMgrDeviceUpdateStatus(DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_AUDIOJACK, DEVICE_IO_DIRECTION_BOTH, DEVICE_ID_AUTO, DEVICE_NAME_AUDIOJACK_4P, 0, NULL); + MMSoundMgrDeviceUpdateStatus(DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_AUDIOJACK, DEVICE_IO_DIRECTION_BOTH, DEVICE_ID_AUTO, DEVICE_NAME_AUDIOJACK_4P, DEVICE_STATE_ACTIVATED, NULL); + } else { + MMSoundMgrDeviceUpdateStatus(DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_AUDIOJACK, DEVICE_IO_DIRECTION_BOTH, DEVICE_ID_AUTO, DEVICE_NAME_AUDIOJACK_3P, 0, NULL); + MMSoundMgrDeviceUpdateStatus(DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_AUDIOJACK, DEVICE_IO_DIRECTION_BOTH, DEVICE_ID_AUTO, DEVICE_NAME_AUDIOJACK_3P, DEVICE_STATE_ACTIVATED, NULL); + } + } + + /* Get Dock status and set available status */ + _mm_sound_get_dock_type (&dock_type); + if (dock_type == DOCK_DESKDOCK) { + SET_AVAILABLE(MM_SOUND_DEVICE_OUT_DOCK); } /* Get BT status and set available status */ MMSoundMgrPulseGetInitialBTStatus (&a2dp, &sco); if (a2dp) { SET_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_A2DP); + MMSoundMgrDeviceUpdateStatus(DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_BLUETOOTH, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, 0, NULL); } if (sco) { SET_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_SCO); SET_AVAILABLE(MM_SOUND_DEVICE_IN_BT_SCO); + MMSoundMgrDeviceUpdateStatus(DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_BLUETOOTH, DEVICE_IO_DIRECTION_BOTH, DEVICE_ID_AUTO, NULL, 0, NULL); } /* Set Active device based on priority */ - _select_playback_active_device (); - _select_capture_active_device (); - - _set_path_with_notification (NO_NOTI); + __select_playback_active_device (); + __select_capture_active_device (); + __set_route(true, false); dump_info(); } -static void handle_bt_a2dp_on () +static void __handle_bt_a2dp_on (void) { int ret = MM_ERROR_NONE; /* at this time, pulseaudio default sink is bt sink */ - if (IS_COMMUNICATION_SESSION()) { - debug_log ("Current session is VOICECALL, no auto-activation!!!\n"); + if (IS_CALL_SESSION()) { + debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n"); return; } debug_log ("Activate BT_A2DP device\n"); SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP); + /* ACTIVATE BLUETOOTH */ + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BLUETOOTH, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL); + /* DEACTIVATE OTHERS */ + __set_deactivate_all_device_auto (GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK()); + + /* For sharing device information with PulseAudio */ + MMSoundMgrPulseSetActiveDevice(MM_SOUND_DEVICE_IN_NONE, GET_ACTIVE_PLAYBACK()); + ret = _mm_sound_mgr_device_active_device_callback(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK()); if (ret != MM_ERROR_NONE) { debug_error ("_mm_sound_mgr_device_active_device_callback() failed [%x]\n", ret); @@ -697,10 +1375,10 @@ static void handle_bt_a2dp_on () dump_info (); } -static void handle_bt_a2dp_off () +static void __handle_bt_a2dp_off (void) { if (!IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP)) { - debug_msg("MM_SOUND_DEVICE_OUT_BT_A2DP was not active. nothing to do here."); + debug_warning("MM_SOUND_DEVICE_OUT_BT_A2DP was not active. nothing to do here."); dump_info (); return; } @@ -709,24 +1387,59 @@ static void handle_bt_a2dp_off () debug_msg("Do pause here"); _asm_pause_process (g_info.asm_handle); - /* set bt device to none */ + /* set BT A2DP device to none */ debug_msg("Deactivate BT_A2DP device\n"); UNSET_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP); + /* DEACTIVATE BLUETOOTH */ + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BLUETOOTH, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL); + /* activate current available device based on priority */ - _select_playback_active_device(); + __select_playback_active_device(); + + /* Do set path and notify result */ + __set_route_nolock(true, true); + + dump_info (); +} + +static void __handle_bt_sco_on () +{ + /* if fmradio session, do nothing */ + + /* Skip when noti session */ + /* ToDo : alarm/notification session ???? */ + if (IS_CALL_SESSION()) { + debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n"); + return; + } + + debug_log ("Activate BT SCO IN/OUT device\n"); + SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_BT_SCO); + SET_CAPTURE_ONLY_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO); + + /* For wearable history */ + /* __set_route_nolock(ROUTE_PARAM_BROADCASTING | ROUTE_PARAM_CORK_DEVICE); */ /* Do set path and notify result */ - _set_path_with_notification(DO_NOTI); + __set_route(true, true); + + /* ACTIVATE BLUETOOTH */ + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BLUETOOTH, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL); + /* DEACTIVATE OTHERS */ + __set_deactivate_all_device_auto (GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK()); dump_info (); } -static void handle_bt_sco_off () +static void __handle_bt_sco_off (void) { + /* DEACTIVATE BLUETOOTH */ + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BLUETOOTH, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL); + /* If sco is not activated, just return */ if (!IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_SCO) && !IS_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO)) { - debug_msg("BT SCO was not active. nothing to do here."); + debug_warning("BT SCO was not active. nothing to do here."); dump_info (); return; } @@ -736,181 +1449,499 @@ static void handle_bt_sco_off () UNSET_ACTIVE(MM_SOUND_DEVICE_OUT_BT_SCO); UNSET_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO); + if (IS_CALL_SESSION()) { + debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n"); + return; + } + /* activate current available device based on priority */ - _select_playback_active_device(); - _select_capture_active_device(); + __select_playback_active_device(); + __select_capture_active_device(); /* Do set path and notify result */ - _set_path_with_notification(DO_NOTI); + __set_route_nolock(true, true); dump_info (); } -static void handle_headset_on (int type) +static void __handle_headset_on (int type) { -#ifdef SEPARATE_EARPHONE_VOLUME - int ret = MM_ERROR_NONE; - volume_type_t volume_type = VOLUME_TYPE_MAX; - - /* get current volume type before changing device */ - ret = mm_sound_volume_get_current_playing_type(&volume_type); - if (ret != MM_ERROR_NONE) { - debug_error("mm_sound_volume_get_current_playing_type failed....ret = [%x]\n", ret); - } -#endif - /* at this time, pulseaudio default sink is bt sink */ /* if fmradio session, do nothing */ /* Skip when noti session */ /* ToDo : alarm/notification session ???? */ - if (IS_COMMUNICATION_SESSION()) { - debug_log ("Current session is VOICECALL, no auto-activation!!!\n"); + if (IS_CALL_SESSION()) { + debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n"); return; } debug_log ("Activate WIRED OUT device\n"); SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY); - if (type == EARJACK_WITH_MIC) { + if (type == DEVICE_EARJACK_TYPE_SPK_WITH_MIC) { debug_log ("Activate WIRED IN device\n"); SET_CAPTURE_ONLY_ACTIVE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY); } -#ifdef SEPARATE_EARPHONE_VOLUME - __update_volume_value(volume_type); -#endif - /* Do set path and notify result */ - _set_path_with_notification(DO_NOTI); + __set_route(true, true); + + /* ACTIVATE AUDIOJACK */ + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_AUDIOJACK, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL); + /* DEACTIVATE OTHERS */ + __set_deactivate_all_device_auto (GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK()); + if (type == DEVICE_EARJACK_TYPE_SPK_WITH_MIC) { + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BUILTIN_MIC, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL); + } dump_info (); } -static void handle_headset_off () +static void __handle_headset_off (void) { -#ifdef SEPARATE_EARPHONE_VOLUME - int ret = MM_ERROR_NONE; - volume_type_t volume_type = VOLUME_TYPE_MAX; - - /* get current volume type before changing device */ - ret = mm_sound_volume_get_current_playing_type(&volume_type); - if (ret != MM_ERROR_NONE) { - debug_error("mm_sound_volume_get_current_playing_type failed....ret = [%x]\n", ret); - } -#endif - + /* FIXME : Need to be removed volume seperation on public */ if (!IS_ACTIVE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY)) { - debug_msg("MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY was not active. nothing to do here."); + debug_warning("MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY was not active. nothing to do here."); return; } - /* if bt was active, then do asm pause */ + /* if Headset was active, then do asm pause */ debug_msg("Do pause here"); _asm_pause_process (g_info.asm_handle); - /* set bt device to none */ + /* set Headset device to none */ debug_msg("Deactivate WIRED IN/OUT device\n"); UNSET_ACTIVE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY); UNSET_ACTIVE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY); - /* For voicecall session, activation device is up-to application policy */ - if (IS_COMMUNICATION_SESSION()) { - debug_log ("Current session is VOICECALL, no auto-activation!!!\n"); + /* For call or voip session, activation device is up-to application policy */ + if (IS_CALL_SESSION()) { + debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n"); return; } /* activate current available device based on priority */ - _select_playback_active_device(); - _select_capture_active_device(); + __select_playback_active_device(); + __select_capture_active_device(); -#ifdef SEPARATE_EARPHONE_VOLUME - __update_volume_value(volume_type); -#endif + /* Do set path and notify result */ + __set_route(true, true); + + /* DEACTIVATE AUDIOJACK */ + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_AUDIOJACK, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL); + + dump_info (); +} + +static void __handle_dock_on (void) +{ + /* ToDo : alarm/notification session ???? */ + if (IS_CALL_SESSION()) { + debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n"); + return; + } + + debug_log ("Activate DOCK device\n"); + SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_DOCK); /* Do set path and notify result */ - _set_path_with_notification(DO_NOTI); + __set_route(true, true); dump_info (); } -void _sound_finished_cb (void *data) +static void __handle_dock_off (void) { - debug_log ("sound play finished!!!\n"); - *(bool*)data = true; + if (!IS_ACTIVE(MM_SOUND_DEVICE_OUT_DOCK)) { + debug_warning("MM_SOUND_DEVICE_OUT_DOCK was not active. nothing to do here."); + return; + } + + /* if Dock was active, then do asm pause */ + debug_msg("Do pause here"); + _asm_pause_process (g_info.asm_handle); + + /* set DOCK device to none */ + debug_msg("Deactivate DOCK device\n"); + UNSET_ACTIVE(MM_SOUND_DEVICE_OUT_DOCK); + + /* activate current available device based on priority */ + __select_playback_active_device(); + + /* Do set path and notify result */ + __set_route(true, true); + + dump_info (); } -static void _play_dock_sound_sync(int is_on) +static void __handle_hdmi_on (void) { - int handle; - bool is_play_finished = false; + /* ToDo : alarm/notification session ???? */ + if (IS_CALL_SESSION()) { + debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n"); + return; + } + + debug_log ("Activate HDMI device\n"); + SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_HDMI); + + /* ACTIVATE HDMI */ + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_HDMI, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL); + /* DEACTIVATE OTHERS */ + __set_deactivate_all_device_auto (GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK()); + + /* Do set path and notify result */ + __set_route(true, true); - debug_log ("start to play dock sound [%d]\n", is_on); - mm_sound_play_loud_solo_sound((is_on? SOUND_DOCK_ON : SOUND_DOCK_OFF), VOLUME_TYPE_FIXED, _sound_finished_cb, &is_play_finished, &handle); - /* FIXME : need to enhance waiting method */ - debug_log ("waiting for dock sound finish\n"); - while (!is_play_finished) { - usleep (10000); // 10 ms + dump_info (); +} + +static void __handle_hdmi_off (void) +{ + if (!IS_ACTIVE(MM_SOUND_DEVICE_OUT_HDMI)) { + debug_warning("MM_SOUND_DEVICE_OUT_HDMI was not active. nothing to do here."); + return; } - debug_log ("dock sound finished!!!\n"); + + /* if HDMI was active, then do asm pause */ + debug_msg("Do pause here"); + _asm_pause_process (g_info.asm_handle); + + MMSoundMgrPulseUnLoadHDMI(); + + /* set HDMI device to none */ + debug_msg("Deactivate HDMI device\n"); + UNSET_ACTIVE(MM_SOUND_DEVICE_OUT_HDMI); + + + /* DEACTIVATE HDMI */ + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_HDMI, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL); + + /* activate current available device based on priority */ + __select_playback_active_device(); + + /* Do set path and notify result */ + __set_route(true, true); + + dump_info (); } -static void handle_dock_on () +static void __handle_mirroring_on (void) { /* ToDo : alarm/notification session ???? */ - if (IS_COMMUNICATION_SESSION()) { - debug_log ("Current session is VOICECALL, no auto-activation!!!\n"); + if (IS_CALL_SESSION()) { + debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n"); return; } - debug_log ("Activate DOCK device\n"); - SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_DOCK); + debug_log ("Activate MIRRORING device\n"); + SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_MIRRORING); - /* Enforced audio */ - _play_dock_sound_sync(true); + /* ACTIVATE MIRRORING */ + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_MIRRORING, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL); + /* DEACTIVATE OTHERS */ + __set_deactivate_all_device_auto (GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK()); /* Do set path and notify result */ - _set_path_with_notification(DO_NOTI); + __set_route(true, true); dump_info (); } -static void handle_dock_off () +static void __handle_mirroring_off (void) { - if (!IS_ACTIVE(MM_SOUND_DEVICE_OUT_DOCK)) { - debug_msg("MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY was not active. nothing to do here."); + if (!IS_ACTIVE(MM_SOUND_DEVICE_OUT_MIRRORING)) { + debug_warning("MM_SOUND_DEVICE_OUT_MIRRORING was not active. nothing to do here."); return; } - /* if DOCK was active, then do asm pause */ + /* if MIRRORING was active, then do asm pause */ debug_msg("Do pause here"); _asm_pause_process (g_info.asm_handle); - /* Enforced audio */ - _play_dock_sound_sync(false); + /* set MIRRORING device to none */ + debug_msg("Deactivate MIRRORING device\n"); + UNSET_ACTIVE(MM_SOUND_DEVICE_OUT_MIRRORING); - /* set DOCK device to none */ - debug_msg("Deactivate DOCK device\n"); - UNSET_ACTIVE(MM_SOUND_DEVICE_OUT_DOCK); + /* DEACTIVATE MIRRORING */ + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_MIRRORING, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL); + + /* activate current available device based on priority */ + __select_playback_active_device(); + + /* Do set path and notify result */ + __set_route(true, true); + + dump_info (); +} + +static void __handle_usb_audio_on (void) +{ + int ret = MM_ERROR_NONE; + + if (IS_CALL_SESSION()) { + debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n"); + return; + } + + debug_log ("Activate USB Audio device\n"); + SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_USB_AUDIO); + + /* ACTIVATE USB_AUDIO */ + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_USB_AUDIO, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL); + /* DEACTIVATE OTHERS */ + __set_deactivate_all_device_auto (GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK()); + + /* For sharing device information with PulseAudio */ + MMSoundMgrPulseSetActiveDevice(MM_SOUND_DEVICE_IN_NONE, GET_ACTIVE_PLAYBACK()); + + ret = _mm_sound_mgr_device_active_device_callback(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK()); + if (ret != MM_ERROR_NONE) { + debug_error ("_mm_sound_mgr_device_active_device_callback() failed [%x]\n", ret); + } + + dump_info (); +} + +static void __handle_usb_audio_off (void) +{ + if (!IS_ACTIVE(MM_SOUND_DEVICE_OUT_USB_AUDIO)) { + debug_warning("MM_SOUND_DEVICE_OUT_USB_AUDIO was not active. nothing to do here."); + dump_info (); + return; + } + + /* if device was active, then do asm pause */ + debug_msg("Do pause here"); + _asm_pause_process (g_info.asm_handle); + + /* set USB Audio device to none */ + debug_msg("Deactivate USB Audio device\n"); + UNSET_ACTIVE(MM_SOUND_DEVICE_OUT_USB_AUDIO); + + /* DEACTIVATE USB_AUDIO */ + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_USB_AUDIO, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL); + + /* activate current available device based on priority */ + __select_playback_active_device(); + + /* Do set path and notify result */ + __set_route(true, true); + + dump_info (); +} + +static void __handle_multimedia_dock_on (void) +{ + if (IS_CALL_SESSION()) { + debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n"); + return; + } + + /* If HDMI has already been actived, we just skip active. */ + if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_HDMI)) { + debug_warning ("HDMI device has been already actived. Just skip Multimedia Dock active action.\n"); + return; + } + + debug_log ("Activate Multimedia Dock device\n"); + SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK); + + /* Do set path and notify result */ + __set_route(true, true); + + dump_info (); +} + +static void __handle_multimedia_dock_off (void) +{ + if (!IS_ACTIVE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK)) { + debug_warning("MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK was not active. nothing to do here."); + dump_info (); + return; + } + + /* if device was active, then do asm pause */ + debug_msg("Do pause here"); + _asm_pause_process (g_info.asm_handle); + + /* set MultimediaDock device to none */ + debug_msg("Deactivate Multimedia Dock device\n"); + UNSET_ACTIVE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK); /* activate current available device based on priority */ - _select_playback_active_device(); + __select_playback_active_device(); /* Do set path and notify result */ - _set_path_with_notification(DO_NOTI); + __set_route(true, true); dump_info (); } +static const char* __get_session_string(session_t session) +{ + switch(session) { + case SESSION_MEDIA: + return "MEDIA"; + case SESSION_VOICECALL: + return "VOICECALL"; + case SESSION_VIDEOCALL: + return "VIDEOCALL"; + case SESSION_VOIP: + return "VOIP"; + case SESSION_FMRADIO: + return "FMRADIO"; + case SESSION_NOTIFICATION: + return "NOTOFICATION"; + case SESSION_ALARM: + return "ALARM"; + case SESSION_EMERGENCY: + return "EMERGENCY"; + case SESSION_VOICE_RECOGNITION: + return "VOICE_RECOGNITION"; + default: + return "unknow session"; + } +} + +static const char* __get_subsession_string(subsession_t session) +{ + switch(session) { + case SUBSESSION_VOICE: + return "VOICECALL"; + case SUBSESSION_RINGTONE: + return "RINGTONE"; + case SUBSESSION_MEDIA: + return "MEDIA"; + case SUBSESSION_INIT: + return "SUBSESSION_INIT"; + case SUBSESSION_VR_NORMAL: + return "VR_NORMAL"; + case SUBSESSION_VR_DRIVE: + return "VR_DRIVE"; + case SUBSESSION_RECORD_STEREO: + return "RECORD_STEREO"; + case SUBSESSION_RECORD_MONO: + return "RECORD_MONO"; + default: + return "unknow subsession"; + } +} + +#ifdef TIZEN_MICRO +static const char* __get_bt_bandwidth_string(int bandwidth) +{ + switch(bandwidth) { + case MM_SOUND_BANDWIDTH_UNKNOWN: + return "none. maybe bt is disconnected"; + case MM_SOUND_BANDWIDTH_NB: + return "NB"; + case MM_SOUND_BANDWIDTH_WB: + return "WB"; + default: + return "unknow bandwidth"; + } +} + +static const char* __get_hfp_connection_state_string(int bandwidth) +{ + switch(bandwidth) { + case MM_SOUND_HFP_STATUS_UNKNOWN: + return "unknown"; + case MM_SOUND_HFP_STATUS_INCOMMING_CALL: + return "HFP_INCOMMING_CALL:RINGTONE"; + default: + return "unknow"; + } +} +#endif + +static const char* __get_device_type_string(int device) +{ + switch(device) { + case DEVICE_BUILTIN: + return "builtin"; + case DEVICE_WIRED: + return "wired"; + case DEVICE_BT_A2DP: + return "bt-a2dp"; + case DEVICE_BT_SCO: + return "bt-sco"; + case DEVICE_DOCK: + return "dock"; + case DEVICE_HDMI: + return "hdmi"; + case DEVICE_MIRRORING: + return "mirroring"; + case DEVICE_USB_AUDIO: + return "usb-audio"; + case DEVICE_MULTIMEDIA_DOCK: + return "multimedia-dock"; + default: + return "unknow device"; + } +} /* ------------------------- EXTERNAL FUNCTIONS ------------------------------------*/ +#ifdef TIZEN_MICRO +int MMSoundMgrSessionMediaPause () +{ + debug_msg ("[SESSION] Media pause requested..."); + _asm_pause_process (g_info.asm_handle); + + return MM_ERROR_NONE; +} + +int MMSoundMgrSessionSetHFBandwidth (int bandwidth) +{ + debug_msg ("Set HF SCO bandwidth=(%s)", __get_bt_bandwidth_string(bandwidth)); + g_info.bt_info.hf_wb = bandwidth; + return MM_ERROR_NONE; +} + +int MMSoundMgrSessionSetHFPConnectionState (int stat) +{ + debug_msg ("Set HF SCO Stat=(%s)", __get_hfp_connection_state_string(stat)); + g_info.bt_info.hfp_conn_state = stat; + return MM_ERROR_NONE; +} +#endif /* TIZEN_MICRO */ + +int MMSoundMgrSessionEnableAgSCO (bool enable) +{ + debug_msg ("Set AG SCO enable=%d\n", enable); + + if (enable) { + __handle_bt_sco_on(); + } else { + __handle_bt_sco_off(); + } + return MM_ERROR_NONE; +} + +int MMSoundMgrSessionSetSCO (bool is_sco_on, bool is_bt_nrec, bool is_bt_wb) +{ + debug_msg ("[SESSION] Set SCO enable=%d, nrec=%d, wb=%d", is_sco_on, is_bt_nrec, is_bt_wb); + g_info.bt_info.is_nrec = (is_sco_on)? is_bt_nrec : false; + g_info.bt_info.is_wb = (is_sco_on)? is_bt_wb : false; + + if (is_sco_on) { + __handle_bt_sco_on(); + } else { + __handle_bt_sco_off(); + } + return MM_ERROR_NONE; +} + /* DEVICE : Called by mgr_pulse for updating current default_sink_name */ -int MMSoundMgrSessionSetDefaultSink (char *default_sink_name) +int MMSoundMgrSessionSetDefaultSink (const char * const default_sink_name) { LOCK_SESSION(); - strcpy (g_info.default_sink_name, default_sink_name); - debug_msg ("[SESSION][%s][%d] default sink=[%s]\n", __func__, __LINE__, default_sink_name); + MMSOUND_STRNCPY(g_info.default_sink_name, default_sink_name, MAX_STRING_LEN); + + debug_msg ("[SESSION] default sink=[%s]\n", default_sink_name); /* ToDo: do something */ @@ -920,19 +1951,20 @@ int MMSoundMgrSessionSetDefaultSink (char *default_sink_name) } /* DEVICE : Called by mgr_pulse for bt and mgr_headset for headset */ -int MMSoundMgrSessionSetDeviceAvailable (device_type_t device, int available, int type, char* name) +int MMSoundMgrSessionSetDeviceAvailable (device_type_t device, int available, int type, const char* name) { LOCK_SESSION(); - debug_msg ("[SESSION] device = %d, available = %d, type = %d, name = %s\n", device, available, type, name); - switch (device) - { + debug_warning ("[SESSION]set device available. device(%s), available(%d), type(%d), name(%s)\n", + __get_device_type_string(device), available, type, name != NULL ? name : "null"); + switch (device) { case DEVICE_WIRED: if (available) { if (!IS_AVAILABLE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY)) { SET_AVAILABLE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY); - if (type == EARJACK_WITH_MIC) { + /* available device & send available callback */ + if (type == DEVICE_EARJACK_TYPE_SPK_WITH_MIC) { SET_AVAILABLE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY); _mm_sound_mgr_device_available_device_callback( MM_SOUND_DEVICE_IN_WIRED_ACCESSORY, @@ -944,38 +1976,55 @@ int MMSoundMgrSessionSetDeviceAvailable (device_type_t device, int available, in MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY, AVAILABLE); } - handle_headset_on(type); + + /* Store earphone type */ + g_info.headset_type = type; + + /* activate device & send activated callback */ + __handle_headset_on(type); } else { debug_log ("Already device [%d] is available...\n", device); } } else { - if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY)) { + + /* unavailable earphone & earmic(if available)*/ UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY); - if (IS_AVAILABLE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY)) { + if (g_info.headset_type == DEVICE_EARJACK_TYPE_SPK_WITH_MIC) { UNSET_AVAILABLE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY); + } + /* Clear earphone type */ + g_info.headset_type = EARJACK_UNPLUGGED; + + /* unactivate device & send callback */ + __handle_headset_off(); + + /* Send unavailable callback */ + if (g_info.headset_type == DEVICE_EARJACK_TYPE_SPK_WITH_MIC) { _mm_sound_mgr_device_available_device_callback( MM_SOUND_DEVICE_IN_WIRED_ACCESSORY, MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY, NOT_AVAILABLE); - } else { _mm_sound_mgr_device_available_device_callback( MM_SOUND_DEVICE_IN_NONE, MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY, NOT_AVAILABLE); } - handle_headset_off(); + } else { debug_log ("Already device [%d] is unavailable...\n", device); } - } break; case DEVICE_BT_A2DP: - strcpy (g_info.bt_name, (name)? name : ""); + if (name) + MMSOUND_STRNCPY(g_info.bt_info.name, name, MAX_STRING_LEN); + else + memset(g_info.bt_info.name, 0, MAX_STRING_LEN); + if (available) { if (!IS_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_A2DP)) { SET_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_A2DP); @@ -984,19 +2033,20 @@ int MMSoundMgrSessionSetDeviceAvailable (device_type_t device, int available, in MM_SOUND_DEVICE_OUT_BT_A2DP, AVAILABLE); - handle_bt_a2dp_on(); + __handle_bt_a2dp_on(); } else { debug_log ("Already device [%d] is available...\n", device); } } else { if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_A2DP)) { UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_A2DP); + __handle_bt_a2dp_off(); _mm_sound_mgr_device_available_device_callback( MM_SOUND_DEVICE_IN_NONE, MM_SOUND_DEVICE_OUT_BT_A2DP, NOT_AVAILABLE); - handle_bt_a2dp_off(); + } else { debug_log ("Already device [%d] is unavailable...\n", device); } @@ -1019,12 +2069,12 @@ int MMSoundMgrSessionSetDeviceAvailable (device_type_t device, int available, in if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_SCO)) { UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_SCO); UNSET_AVAILABLE(MM_SOUND_DEVICE_IN_BT_SCO); + __handle_bt_sco_off(); _mm_sound_mgr_device_available_device_callback( MM_SOUND_DEVICE_IN_BT_SCO, MM_SOUND_DEVICE_OUT_BT_SCO, NOT_AVAILABLE); - handle_bt_sco_off(); } else { debug_log ("Already device [%d] is unavailable...\n", device); } @@ -1039,24 +2089,138 @@ int MMSoundMgrSessionSetDeviceAvailable (device_type_t device, int available, in MM_SOUND_DEVICE_IN_NONE, MM_SOUND_DEVICE_OUT_DOCK, AVAILABLE); - handle_dock_on(); + __handle_dock_on(); } else { debug_log ("Already device [%d] is available...\n", device); } } else { if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_DOCK)) { UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_DOCK); + __handle_dock_off(); _mm_sound_mgr_device_available_device_callback( MM_SOUND_DEVICE_IN_NONE, MM_SOUND_DEVICE_OUT_DOCK, NOT_AVAILABLE); - handle_dock_off(); } else { debug_log ("Already device [%d] is unavailable...\n", device); } } break; + + case DEVICE_HDMI: + if (available) { + if (!IS_AVAILABLE(MM_SOUND_DEVICE_OUT_HDMI)) { + SET_AVAILABLE(MM_SOUND_DEVICE_OUT_HDMI); + _mm_sound_mgr_device_available_device_callback( + MM_SOUND_DEVICE_IN_NONE, + MM_SOUND_DEVICE_OUT_HDMI, + AVAILABLE); + __handle_hdmi_on(); + } else { + debug_log ("Already device [%d] is available...\n", device); + } + } else { + if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_HDMI)) { + UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_HDMI); + __handle_hdmi_off(); + _mm_sound_mgr_device_available_device_callback( + MM_SOUND_DEVICE_IN_NONE, + MM_SOUND_DEVICE_OUT_HDMI, + NOT_AVAILABLE); + + } else { + debug_log ("Already device [%d] is unavailable...\n", device); + } + } + break; + + case DEVICE_MIRRORING: + if (available) { + if (!IS_AVAILABLE(MM_SOUND_DEVICE_OUT_MIRRORING)) { + SET_AVAILABLE(MM_SOUND_DEVICE_OUT_MIRRORING); + _mm_sound_mgr_device_available_device_callback( + MM_SOUND_DEVICE_IN_NONE, + MM_SOUND_DEVICE_OUT_MIRRORING, + AVAILABLE); + __handle_mirroring_on(); + } else { + debug_log ("Already device [%d] is available...\n", device); + } + } else { + if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_MIRRORING)) { + UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_MIRRORING); + __handle_mirroring_off(); + _mm_sound_mgr_device_available_device_callback( + MM_SOUND_DEVICE_IN_NONE, + MM_SOUND_DEVICE_OUT_MIRRORING, + NOT_AVAILABLE); + + } else { + debug_log ("Already device [%d] is unavailable...\n", device); + } + } + break; + + case DEVICE_USB_AUDIO: + if (available) { + if (!IS_AVAILABLE(MM_SOUND_DEVICE_OUT_USB_AUDIO)) { + SET_AVAILABLE(MM_SOUND_DEVICE_OUT_USB_AUDIO); + _mm_sound_mgr_device_available_device_callback( + MM_SOUND_DEVICE_IN_NONE, + MM_SOUND_DEVICE_OUT_USB_AUDIO, + AVAILABLE); + __handle_usb_audio_on(); + } else { + debug_log ("Already device [%d] is available...\n", device); + } + } else { + if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_USB_AUDIO)) { + UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_USB_AUDIO); + __handle_usb_audio_off(); + _mm_sound_mgr_device_available_device_callback( + MM_SOUND_DEVICE_IN_NONE, + MM_SOUND_DEVICE_OUT_USB_AUDIO, + NOT_AVAILABLE); + + } else { + debug_log ("Already device [%d] is unavailable...\n", device); + } + } + break; + case DEVICE_MULTIMEDIA_DOCK: + if (available) { + if (!IS_AVAILABLE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK)) { + SET_AVAILABLE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK); + _mm_sound_mgr_device_available_device_callback( + MM_SOUND_DEVICE_IN_NONE, + MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK, + AVAILABLE); + __handle_multimedia_dock_on(); + } else { + debug_log ("Already device [%d] is available...\n", device); + } + } else { + if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK)) { + UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK); + if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_USB_AUDIO)) { + UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_USB_AUDIO); + } + __handle_multimedia_dock_off(); + _mm_sound_mgr_device_available_device_callback( + MM_SOUND_DEVICE_IN_NONE, + MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK, + NOT_AVAILABLE); + + } else { + debug_log ("Already device [%d] is unavailable...\n", device); + } + } + break; + + default: + debug_warning ("device [%d] is not handled...\n", device); + break; } UNLOCK_SESSION(); @@ -1067,8 +2231,8 @@ int MMSoundMgrSessionSetDeviceAvailable (device_type_t device, int available, in int MMSoundMgrSessionIsDeviceAvailableNoLock (mm_sound_device_out playback, mm_sound_device_in capture, bool *available) { int ret = MM_ERROR_NONE; - debug_log ("[SESSION][%s][%d] query playback=[0x%X] capture=[0x%X], current available = [0x%X]\n", - __func__, __LINE__, playback, capture, g_info.device_available); + debug_log ("[SESSION] query playback=[0x%X] capture=[0x%X], current available = [0x%X]\n", + playback, capture, g_info.device_available); if (available) { if (playback == MM_SOUND_DEVICE_OUT_NONE) { @@ -1078,7 +2242,7 @@ int MMSoundMgrSessionIsDeviceAvailableNoLock (mm_sound_device_out playback, mm_s } else { *available = (IS_AVAILABLE(playback) && IS_AVAILABLE(capture)); } - debug_log ("[%s][%d] return available = [%d]\n", __func__, __LINE__, *available); + debug_log ("return available = [%d]\n", *available); } else { debug_warning ("Invalid argument!!!\n"); ret = MM_ERROR_INVALID_ARGUMENT; @@ -1110,30 +2274,22 @@ int MMSoundMgrSessionGetAvailableDevices (int *playback, int *capture) *playback = GET_AVAILABLE_PLAYBACK(); *capture = GET_AVAILABLE_CAPTURE(); - debug_msg ("[SESSION][%s][%d] return available playback=[0x%X]/capture=[0x%X]\n", __func__, __LINE__, *playback, *capture); + debug_msg ("[SESSION] return available playback=[0x%X]/capture=[0x%X]\n", *playback, *capture); UNLOCK_SESSION(); return MM_ERROR_NONE; } -int MMSoundMgrSessionSetDeviceActive (mm_sound_device_out playback, mm_sound_device_in capture) +int MMSoundMgrSessionSetDeviceActive (mm_sound_device_out playback, mm_sound_device_in capture, bool need_broadcast) { int ret = MM_ERROR_NONE; int old_active = g_info.device_active; -#ifdef SEPARATE_EARPHONE_VOLUME - volume_type_t volume_type = VOLUME_TYPE_MAX; - - /* get current volume type before changing device */ - ret = mm_sound_volume_get_current_playing_type(&volume_type); - if (ret != MM_ERROR_NONE) { - debug_error("mm_sound_volume_get_current_playing_type failed....ret = [%x]\n", ret); - } -#endif - + bool need_update = false; + bool need_cork = true; LOCK_SESSION(); - debug_msg ("[SESSION][%s][%d] playback=[0x%X] capture=[0x%X]\n", __func__, __LINE__, playback, capture); + debug_warning ("[SESSION] playback=[0x%X] capture=[0x%X]\n", playback, capture); /* Check whether device is available */ if ((playback && !IS_AVAILABLE(playback)) || (capture && !IS_AVAILABLE(capture))) { @@ -1142,25 +2298,78 @@ int MMSoundMgrSessionSetDeviceActive (mm_sound_device_out playback, mm_sound_dev goto END_SET_DEVICE; } + LOCK_PATH(); /* Update active state */ debug_log ("Update active device as request\n"); if (playback) { + int d_ret = MM_ERROR_NONE; + device_type_e device; + SET_PLAYBACK_ONLY_ACTIVE(playback); + + d_ret = __get_device_type_from_old_device(playback, &device); + if(d_ret) { + debug_warning ("Failed to __get_device_type_from_old_device\n"); + } else { + /* ACTIVATE device */ + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, device, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL); + } } if (capture) { + int d_ret = MM_ERROR_NONE; + device_type_e device; SET_CAPTURE_ONLY_ACTIVE(capture); + + d_ret = __get_device_type_from_old_device(capture, &device); + if(d_ret) { + debug_warning ("Failed to __get_device_type_from_old_device\n"); + } else { + /* ACTIVATE device */ + MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, device, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL); + } + } + /* DEACTIVATE OTHERS */ + __set_deactivate_all_device_auto (GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK()); + + if (((g_info.session == SESSION_VOICECALL) || (g_info.session == SESSION_VIDEOCALL))) { + bool is_wb, is_nrec; +#ifndef TIZEN_MICRO + bool is_noise_reduction, is_extra_volume, is_upscaling_needed; + is_noise_reduction = __is_noise_reduction_on(); + is_extra_volume = __is_extra_volume_on(); + is_upscaling_needed = __is_upscaling_needed(); + if ((g_info.is_noise_reduction != is_noise_reduction) + || (g_info.is_extra_volume != is_extra_volume) + || (g_info.is_upscaling_needed != is_upscaling_needed)) { + need_update = true; + } + g_info.is_noise_reduction = is_noise_reduction; + g_info.is_extra_volume = is_extra_volume; + g_info.is_upscaling_needed = is_upscaling_needed; +#endif /* TIZEN_MICRO */ +#ifdef SUPPORT_BT_SCO + /* FIXME : Check all BT SCO */ + if (playback == MM_SOUND_DEVICE_OUT_BT_SCO && capture == MM_SOUND_DEVICE_IN_BT_SCO) { + is_wb = MMSoundMgrPulseBTSCOWBStatus(); + is_nrec = MMSoundMgrPulseBTSCONRECStatus(); + if ((g_info.bt_info.is_nrec != is_nrec) || (g_info.bt_info.is_wb != is_wb)) { + g_info.bt_info.is_wb = is_wb; + g_info.bt_info.is_nrec = is_nrec; + need_update = true; + } + } +#endif /* SUPPORT_BT_SCO */ + /* NOT need to cork during voice call */ + need_cork = false; } + UNLOCK_PATH(); /* If there's changes do path set and inform callback */ - if (old_active != g_info.device_active) { - debug_msg ("Changes happens....set path based on current active device and inform callback!!!\n"); - -#ifdef SEPARATE_EARPHONE_VOLUME - __update_volume_value(volume_type); -#endif + if (old_active != g_info.device_active || need_update == true) { + debug_msg ("Changes happens....set path based on current active device and inform callback(%d)!!!\n", need_broadcast); /* Do set path based on current active state */ - _set_path_with_notification(DO_NOTI); + __set_route(need_broadcast, need_cork); } else { debug_msg ("No changes....nothing to do...\n"); } @@ -1170,6 +2379,23 @@ END_SET_DEVICE: return ret; } +int MMSoundMgrSessionSetDeviceActiveAuto (void) +{ + int ret = MM_ERROR_NONE; + + /* activate current available device based on priority */ + __select_playback_active_device(); + __select_capture_active_device(); + /* Do set path and notify result */ + ret = __set_route(true, true); + if (ret != MM_ERROR_NONE) { + debug_error("fail to MMSoundMgrSessionSetDeviceActiveAuto.\n"); + } else { + debug_msg ("success : MMSoundMgrSessionSetDeviceActiveAuto\n"); + } + return ret; +} + int MMSoundMgrSessionGetDeviceActive (mm_sound_device_out *playback, mm_sound_device_in *capture) { if (playback == NULL || capture == NULL) { @@ -1181,8 +2407,22 @@ int MMSoundMgrSessionGetDeviceActive (mm_sound_device_out *playback, mm_sound_de *playback = GET_ACTIVE_PLAYBACK(); *capture = GET_ACTIVE_CAPTURE(); - debug_msg ("[SESSION][%s][%d] return active playback=[0x%X]/capture=[0x%X]\n", __func__, __LINE__, - *playback,*capture); + debug_msg ("[SESSION] return active playback=[0x%X]/capture=[0x%X]\n", *playback,*capture); + + UNLOCK_SESSION(); + return MM_ERROR_NONE; +} + +int MMSoundMgrSessionGetAudioPath (mm_sound_device_out *playback, mm_sound_device_in *capture) +{ + if (playback == NULL || capture == NULL) { + debug_error ("Invalid input parameter\n"); + return MM_ERROR_INVALID_ARGUMENT; + } + + LOCK_SESSION(); + MMSoundMgrPulseGetPathInfo(playback, capture); + debug_msg ("[SESSION] return current audio path which is set to ALSA . playback=[0x%X]/capture=[0x%X]\n", *playback,*capture); UNLOCK_SESSION(); return MM_ERROR_NONE; @@ -1193,28 +2433,30 @@ int MMSoundMgrSessionSetSession(session_t session, session_state_t state) { LOCK_SESSION(); - debug_msg ("[SESSION][%s][%d] session=[%d] state=[%d]\n", __func__, __LINE__, session, state); + debug_warning ("[SESSION] session=[%s] state=[%s]\n", __get_session_string(session), state==SESSION_START ? "start" : "end"); - /* Update session */ - if (state) + /* Update Enable session */ + if (state) { g_info.session = session; - else + } else { g_info.session = SESSION_MEDIA; + g_info.subsession = SUBSESSION_VOICE; /* initialize subsession */ + } + + MMSoundMgrPulseSetSession(session, state); /* Do action based on new session */ - switch (session) - { + switch (session) { case SESSION_MEDIA: - /* ToDo: - start - mic setting - end - */ + __set_playback_route_media (state); break; case SESSION_VOICECALL: + case SESSION_VIDEOCALL: + __set_playback_route_call (state); + break; case SESSION_VOIP: - __set_playback_route_communication (state); + __set_playback_route_voip (state); break; case SESSION_FMRADIO: @@ -1224,6 +2466,22 @@ int MMSoundMgrSessionSetSession(session_t session, session_state_t state) case SESSION_NOTIFICATION: __set_playback_route_notification (state); break; + + case SESSION_ALARM: + __set_playback_route_alarm (state); + break; + + case SESSION_EMERGENCY: + __set_playback_route_emergency (state); + break; + + case SESSION_VOICE_RECOGNITION: + __set_playback_route_voicerecognition (state); + break; + + default: + debug_warning ("session [%s] is not handled...\n", __get_session_string(session)); + break; } UNLOCK_SESSION(); @@ -1237,23 +2495,113 @@ int MMSoundMgrSessionGetSession(session_t *session) return MM_ERROR_INVALID_ARGUMENT; } - //LOCK_SESSION(); + /* LOCK_SESSION(); */ *session = g_info.session; - //UNLOCK_SESSION(); + /* UNLOCK_SESSION(); */ + + return MM_ERROR_NONE; +} + +const char* MMSoundMgrSessionGetSessionString(session_t session) +{ + return __get_session_string(session); +} +#ifdef TIZEN_MICRO +int MMSoundMgrSessionSetDuplicateSubSession() +{ + /* This function is for set sub session duplicate + When BT wb/nb is changed, the call application cannot set + normal alsa scenario. + Because call app is set sub session before BT band is decided. + (Actually BT frw can know the band after SCO request + from phone) + + Ref. mm_sound_mgr_pulse.c _bt_hf_cb function. + */ + + int ret = 0; + debug_msg ("Duplicated path control"); + + LOCK_SESSION(); + + ret = __set_route(false, false); + if(ret != MM_ERROR_NONE) + debug_warning("Fail to set route"); + UNLOCK_SESSION(); return MM_ERROR_NONE; } +#endif /* SUBSESSION */ -int MMSoundMgrSessionSetSubSession(subsession_t subsession) +int MMSoundMgrSessionSetSubSession(subsession_t subsession, int subsession_opt) { + bool need_update = false; + bool need_cork = false; + static subsession_t prev_subsession = SUBSESSION_VOICE; /* Initialize subsession */ + bool set_route_flag = true; + int sub_session_opt = 0; LOCK_SESSION(); - g_info.subsession = subsession; - debug_msg ("[SESSION][%s][%d] subsession=[%d]\n", __func__, __LINE__, subsession); + if (g_info.subsession == subsession) { + debug_warning ("[SESSION] already subsession is [%s]. skip this!!\n", __get_subsession_string(subsession)); + } else { + MMSoundMgrPulseSetSubsession(subsession, subsession_opt); + g_info.subsession = subsession; + need_update = true; + } - _set_path_with_notification (NO_NOTI); + /* FIXME : Need to check with private */ + /* FIXME : Need to check with private */ + /* FIXME : Need to check with private */ + switch(subsession) { +#ifdef TIZEN_MICRO + // FIXME: we got timing issue between music and player and sound_server + case SUBSESSION_VOICE: + case SUBSESSION_RINGTONE: + debug_msg("session(%s), subsession(%s). sound path will change to spk/mic", + __get_session_string(g_info.session), __get_subsession_string(subsession)); + SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_SPEAKER); + SET_CAPTURE_ONLY_ACTIVE(MM_SOUND_DEVICE_IN_MIC); + need_update = true; + /* suspend ALSA devices when starting call */ + if (subsession != SUBSESSION_RINGTONE) { + need_cork |= true; + } + dump_info(); + break; +#endif /* TIZEN_MICRO */ + case SUBSESSION_VR_NORMAL: + case SUBSESSION_VR_DRIVE: + if(g_info.option != subsession_opt) { + g_info.option = subsession_opt; + need_update = true; + } + break; + default: + if (g_info.option != subsession_opt) { + g_info.option = MM_SUBSESSION_OPTION_NONE; + need_update = true; + } + break; + } if (g_info.subsession == SUBSESSION_VOICE) { + if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_SCO) && IS_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO)) { + /* Update BT info */ + MMSoundMgrPulseUpdateBluetoothAGCodec(); + } + } + if (g_info.subsession == SUBSESSION_VOICE) { + if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_SCO) && IS_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO)) { + /* Update BT info */ + MMSoundMgrPulseUpdateBluetoothAGCodec(); + } + } + + if (need_update) { + debug_warning ("[SESSION] subsession=[%s], resource=[%d]\n", __get_subsession_string(g_info.subsession), g_info.option); + __set_route(true, need_cork); + } UNLOCK_SESSION(); return MM_ERROR_NONE; @@ -1275,11 +2623,241 @@ int MMSoundMgrSessionGetSubSession(subsession_t *subsession) return MM_ERROR_NONE; } +const char* MMSoundMgrSessionGetSubSessionString(subsession_t subsession) +{ + return __get_subsession_string(subsession); +} + + char* MMSoundMgrSessionGetBtA2DPName () { - return g_info.bt_name; + return g_info.bt_info.name; +} + +void MMSoundMgrSessionSetVoiceControlState (bool enable) +{ + int ret = MM_ERROR_NONE; + LOCK_SESSION(); + g_info.is_voicecontrol = enable; + /* FIXME : Check whether need to set state to pulse, need to check with private */ + /* MMSoundMgrPulseSetVoicecontrolState(enable); */ + + debug_warning("MMSoundMgrSessionSetVoiceControlState --------g_info.session = %s,g_info.subsession = %s ", + __get_session_string(g_info.session), __get_subsession_string(g_info.subsession)); + if (IS_CALL_SESSION() && g_info.subsession == SUBSESSION_VOICE) { + debug_warning("already voice subsession in voice session"); + return; + } + + ret = __set_sound_path_for_voicecontrol(); + UNLOCK_SESSION(); + if (ret != MM_ERROR_NONE) { + debug_error ("__set_sound_path_for_voicecontrol() failed [%x]\n", ret); + return; + } + +} + +bool MMSoundMgrSessionGetVoiceControlState () +{ + return g_info.is_voicecontrol; +} + +#ifndef _TIZEN_PUBLIC_ +#ifndef TIZEN_MICRO +/* -------------------------------- NOISE REDUCTION --------------------------------------------*/ +static bool __is_noise_reduction_on (void) +{ + int noise_reduction_on = 1; + + if (vconf_get_bool(VCONF_KEY_NOISE_REDUCTION, &noise_reduction_on)) { + debug_warning("vconf_get_bool for VCONF_KEY_NOISE_REDUCTION failed\n"); + } + + return (noise_reduction_on == 1) ? true : false; +} + +/* -------------------------------- EXTRA VOLUME --------------------------------------------*/ +static bool __is_extra_volume_on (void) +{ + int extra_volume_on = 1; + + if (vconf_get_bool(VCONF_KEY_EXTRA_VOLUME, &extra_volume_on )) { + debug_warning("vconf_get_bool for VCONF_KEY_EXTRA_VOLUME failed\n"); + } + + return (extra_volume_on == 1) ? true : false; +} +#endif + +/* -------------------------------- UPSCALING --------------------------------------------*/ +static bool __is_upscaling_needed (void) +{ + int is_wbamr = 1; + + if (vconf_get_bool(VCONF_KEY_WBAMR, &is_wbamr)) { + debug_warning("vconf_get_bool for VCONF_KEY_WBAMR failed\n"); + } + + return (is_wbamr == 0) ? true : false; +} +/* -------------------------------- BT NREC --------------------------------------------*/ +static bool __get_bt_nrec_status(void) +{ + debug_msg ("get bt nrec status.(%s)\n", g_info.bt_info.is_nrec==true ? "ON" : "OFF"); + return g_info.bt_info.is_nrec; +} + +#ifdef TIZEN_MICRO +static int __get_ag_wb_status(void) +{ + debug_msg ("get ag wb status.(%s)\n", __get_bt_bandwidth_string(g_info.bt_info.ag_wb)); + return g_info.bt_info.ag_wb; +} + +static int __get_hf_wb_status(void) +{ + debug_msg ("get hf wb status.(%s)\n", __get_bt_bandwidth_string(g_info.bt_info.hf_wb)); + return g_info.bt_info.hf_wb; +} + +static int __get_hf_connection_state(void) +{ + debug_msg ("Set HF SCO connection state(%s)", __get_hfp_connection_state_string(g_info.bt_info.hfp_conn_state)); + return g_info.bt_info.hfp_conn_state; +} + +/* ------------------------------- RIGHT HAND ------------------------------------------*/ +static bool __is_right_hand_on (void) +{ + int is_right_hand = 0; + if (vconf_get_bool(VCONF_KEY_VR_LEFTHAND_ENABLED, &is_right_hand)) { + debug_warning("vconf_get_bool for %s failed\n", VCONF_KEY_VR_LEFTHAND_ENABLED); + } + debug_msg("is_right_hand : %d",is_right_hand); + return (is_right_hand == 0) ? true : false; +} +#endif /* TIZEN_MICRO */ +#endif /* _TIZEN_PUBLIC_ */ +#ifdef TIZEN_MICRO +static void __media_pause_by_call (void) +{ + int asm_error = 0; + int asm_status = 0; + int handle = -1; + + debug_msg ("[SESSION] Media pause requested by call dbus ..."); + MMSOUND_ENTER_CRITICAL_SECTION( &_asm_mutex ) + + if (vconf_get_int(SOUND_STATUS_KEY, &asm_status)) { + debug_error(" vconf_set_int fail\n"); + } + + if ((asm_status & ~(ASM_STATUS_CALL|ASM_STATUS_NOTIFY|ASM_STATUS_ALARM|ASM_STATUS_EXCLUSIVE_RESOURCE))> 0) { + /* Do Pause for call dbus event */ + debug_warning("Change state to pause by call dbus"); + + if (!ASM_register_sound_ex (-1, &handle, ASM_EVENT_CALL, ASM_STATE_NONE, NULL, NULL, ASM_RESOURCE_NONE, &asm_error, __asm_process_message)) { + debug_warning("Call event register failed with 0x%x", asm_error); + MMSOUND_LEAVE_CRITICAL_SECTION( &_asm_mutex ) + return; + } + + if (!ASM_set_sound_state_ex(handle, ASM_EVENT_CALL, ASM_STATE_PLAYING, ASM_RESOURCE_NONE, &asm_error, __asm_process_message)) { + debug_error("Call event set sound state to playing failed with 0x%x\n", asm_error); + } + + if (!ASM_set_sound_state_ex(handle, ASM_EVENT_CALL, ASM_STATE_STOP, ASM_RESOURCE_NONE, &asm_error, __asm_process_message)) { + debug_error("Call event set sound state to stop failed with 0x%x", asm_error); + } + + if (!ASM_unregister_sound_ex(handle, ASM_EVENT_CALL, &asm_error, __asm_process_message)) { + debug_error("Call event unregister failed with 0x%x\n", asm_error); + MMSOUND_LEAVE_CRITICAL_SECTION( &_asm_mutex ) + return; + } + + } else { + debug_msg("no need to pause others"); + } + + MMSOUND_LEAVE_CRITICAL_SECTION( &_asm_mutex ) + /* End of change of session state */ + + return; +} +static void __call_status_changed(GDBusConnection *conn, + const gchar *sender_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *signal_name, + GVariant *parameters, + gpointer user_data) +{ + int value=0; + const GVariantType* value_type; + + debug_msg ("sender : %s, object : %s, interface : %s, signal : %s", + sender_name, object_path, interface_name, signal_name); + if(g_variant_is_of_type(parameters, G_VARIANT_TYPE("(i)"))) + { + g_variant_get(parameters, "(i)",&value); + debug_msg("singal[%s] = %X", signal_name, value); + if(value==MM_SOUND_CALL_STATUS_PAUSE) + { + __media_pause_by_call(); + } + } + else + { + value_type = g_variant_get_type(parameters); + debug_warning("signal type is %s", value_type); + } + +} + +void _deinit_call_status_dbus(void) +{ + debug_fenter (); + g_dbus_connection_signal_unsubscribe(conn_callstatus, sig_id_callstatus); + g_object_unref(conn_callstatus); + debug_fleave (); } +int _init_call_status_dbus(void) +{ + GError *err = NULL; + debug_fenter (); + + g_type_init(); + + conn_callstatus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err); + if (!conn_callstatus && err) { + debug_error ("g_bus_get_sync() error (%s) ", err->message); + g_error_free (err); + goto error; + } + + sig_id_callstatus = g_dbus_connection_signal_subscribe(conn_callstatus, + NULL, DBUS_CALL_STATUS_INTERFACE, DBUS_CALL_STATUS_CHANGED_SIGNAL, DBUS_CALL_STATUS_PATH, NULL, 0, + __call_status_changed, NULL, NULL); + if (sig_id_callstatus == 0) { + debug_error ("g_dbus_connection_signal_subscribe() error (%d)", sig_id_callstatus); + goto sig_error; + } + + debug_fleave (); + return 0; + +sig_error: + g_dbus_connection_signal_unsubscribe(conn_callstatus, sig_id_callstatus); + g_object_unref(conn_callstatus); + +error: + return -1; + +} +#endif /* TIZEN_MICRO */ int MMSoundMgrSessionInit(void) { LOCK_SESSION(); @@ -1289,12 +2867,17 @@ int MMSoundMgrSessionInit(void) memset (&g_info, 0, sizeof (SESSION_INFO_STRUCT)); /* FIXME: Initial status should be updated */ - _set_initial_active_device (); + __set_initial_active_device (); /* Register for headset unplug */ if (_asm_register_for_headset (&g_info.asm_handle) == false) { debug_error ("Failed to register ASM for headset\n"); } +#ifdef TIZEN_MICRO + if (_init_call_status_dbus() != 0) { + debug_error ("Registering call status signal handler failed\n"); + } +#endif debug_fleave(); diff --git a/server/mm_sound_plugin.c b/server/mm_sound_plugin.c index 9f63aa2..d330b94 100644 --- a/server/mm_sound_plugin.c +++ b/server/mm_sound_plugin.c @@ -18,7 +18,7 @@ * limitations under the License. * */ - + #include #include @@ -28,6 +28,7 @@ #include #include +#include "../include/mm_sound_common.h" #include "include/mm_sound_plugin.h" #include #include @@ -219,7 +220,16 @@ static int _MMSoundPluginGetList(const char *plugdir ,char ***list) ret = MM_ERROR_OUT_OF_STORAGE; goto free_entry; } - chdir(plugdir); + /* FIXME : need to handle error case */ + if (chdir(plugdir) != 0) { + debug_error("chdir error\n"); + if (temp) { + free (temp); + temp = NULL; + } + ret = MM_ERROR_INVALID_ARGUMENT; + goto free_entry; + } for(item_idx = items; item_idx--; ) { if(stat(entry[item_idx]->d_name, &finfo) < 0) { @@ -233,7 +243,7 @@ static int _MMSoundPluginGetList(const char *plugdir ,char ***list) } debug_msg("item %d is %s\n", item_idx, entry[item_idx]->d_name); - + if (S_ISREG(finfo.st_mode)) { temp[tn++] = __strcatdup(plugdir, entry[item_idx]->d_name); } @@ -245,7 +255,7 @@ free_entry: } free(entry); return ret; -} +} static int _MMSoundPluginDestroyList(char **list) { @@ -260,7 +270,6 @@ static int _MMSoundPluginDestroyList(char **list) static char* __strcatdup(const char *str1, const char *str2) { char *dest = NULL; - char *source = NULL; int len = 0; len = strlen(str1) + strlen(str2) + 1; dest = (char*) malloc(len*sizeof(char)); diff --git a/server/mm_sound_recovery.c b/server/mm_sound_recovery.c deleted file mode 100644 index 20f7637..0000000 --- a/server/mm_sound_recovery.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * libmm-sound - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Seungbae Shin - * - * 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/mm_sound.h" -#include "include/mm_sound_common.h" -#include "include/mm_sound_mgr_session.h" - - -int sound_system_bootup_recovery() -{ - int err=0; - char *keystr[] = {VCONF_KEY_VOLUME_TYPE_SYSTEM, VCONF_KEY_VOLUME_TYPE_NOTIFICATION, VCONF_KEY_VOLUME_TYPE_ALARM, - VCONF_KEY_VOLUME_TYPE_RINGTONE, VCONF_KEY_VOLUME_TYPE_MEDIA, VCONF_KEY_VOLUME_TYPE_CALL, - VCONF_KEY_VOLUME_TYPE_ANDROID,VCONF_KEY_VOLUME_TYPE_JAVA, VCONF_KEY_VOLUME_TYPE_MEDIA}; - int vol[AVSYS_AUDIO_VOLUME_TYPE_MAX] = {5,7,6,13,7,7,0,11,11}, i=0; -#ifdef SEPARATE_EARPHONE_VOLUME - mm_sound_device_in device_in = MM_SOUND_DEVICE_OUT_NONE; - mm_sound_device_out device_out = MM_SOUND_DEVICE_OUT_NONE; -#endif - - for (i=0; i> 8; - } else { - vol[i] = vol[i] & 0x00FF; - } -#endif - } - - err = avsys_audio_hibernation_reset(vol); - return err; -} diff --git a/server/mm_sound_server.c b/server/mm_sound_server.c index 6ec5025..40a3e3c 100644 --- a/server/mm_sound_server.c +++ b/server/mm_sound_server.c @@ -30,8 +30,19 @@ #include #include +#include #include #include + +#include +#include +#include +#include +#include + + +#include "../include/mm_sound_common.h" +#include "../include/mm_sound_utils.h" #include "include/mm_sound_thread_pool.h" #include "include/mm_sound_mgr_run.h" #include "include/mm_sound_mgr_codec.h" @@ -39,13 +50,12 @@ #include "include/mm_sound_mgr_pulse.h" #include "include/mm_sound_mgr_asm.h" #include "include/mm_sound_mgr_session.h" -#include "include/mm_sound_mgr_headset.h" -#include "include/mm_sound_mgr_dock.h" -#include "include/mm_sound_recovery.h" -#include "include/mm_sound_utils.h" -#include "include/mm_sound_common.h" - -#include +#include "include/mm_sound_mgr_device.h" +#include "include/mm_sound_mgr_device_headset.h" +#include "include/mm_sound_mgr_device_dock.h" +#include "include/mm_sound_mgr_device_hdmi.h" +#include "include/mm_sound_mgr_device_wfd.h" +#include #include @@ -58,13 +68,30 @@ #define ASM_CHECK_INTERVAL 10000 +#define MAX_PLUGIN_DIR_PATH_LEN 256 + typedef struct { - char *plugdir; + char plugdir[MAX_PLUGIN_DIR_PATH_LEN]; int startserver; int printlist; int testmode; + int poweroff; + int soundreset; } server_arg; +static char *str_errormsg[] = { + "Operation is success.", + "Handle Init Fail", + "Path Init Fail", + "Handle Fini Fail", + "Path Fini Fail", + "Handle Reset Fail", + "Path Reset Fail", + "Handle Dump Fail", + "Path Dump Fail", + "Sync Dump Fail", +}; + static int getOption(int argc, char **argv, server_arg *arg); static int usgae(int argc, char **argv); @@ -79,7 +106,7 @@ GMainLoop *g_mainloop; void* pulse_handle; -GThreadFunc event_loop_thread(gpointer data) +gpointer event_loop_thread(gpointer data) { g_mainloop = g_main_loop_new(NULL, TRUE); if(g_mainloop == NULL) { @@ -89,82 +116,116 @@ GThreadFunc event_loop_thread(gpointer data) return NULL; } -void hibernation_leave_cb() -{ - MMSoundMgrPulseHandleRegisterMonoAudio(pulse_handle); - MMSoundMgrPulseHandleRegisterBluetoothStatus (pulse_handle); - - if(sound_system_bootup_recovery()) { - debug_error("Audio reset failed\n"); - } else { - debug_msg("Audio reset success\n"); - } -} - -void wait_for_asm_ready () +static void __wait_for_asm_ready () { int retry_count = 0; int asm_ready = 0; while (!asm_ready) { - debug_log("Checking ASM ready....[%d]\n", retry_count++); + debug_msg("Checking ASM ready....[%d]\n", retry_count++); if (vconf_get_int(ASM_READY_KEY, &asm_ready)) { debug_warning("vconf_get_int for ASM_READY_KEY (%s) failed\n", ASM_READY_KEY); } usleep (ASM_CHECK_INTERVAL); } - debug_log("ASM is now ready...clear key!!!\n"); - vconf_unset (ASM_READY_KEY); + debug_msg("ASM is now ready...clear the key!!!\n"); + vconf_set_int(ASM_READY_KEY, 0); +} + +static int _handle_power_off () +{ + int handle = 0; + int asm_error = 0; + + if (ASM_register_sound (-1, &handle, ASM_EVENT_EMERGENCY, ASM_STATE_PLAYING, NULL, NULL, ASM_RESOURCE_NONE, &asm_error)) { + if (ASM_unregister_sound (handle, ASM_EVENT_EMERGENCY, &asm_error)) { + debug_log ("asm register/unregister success!!!\n"); + return 0; + } else { + debug_error ("asm unregister failed...0x%x\n", asm_error); + } + } else { + debug_error ("asm register failed...0x%x\n", asm_error); + } + + return -1; +} + +static int _handle_sound_reset () +{ + int ret = 0; + debug_warning ("not supported\n"); + return 0; +} + +static sem_t* sem_create_n_wait() +{ + sem_t* sem = NULL; + + if ((sem = sem_open ("booting-sound", O_CREAT, 0660, 0))== SEM_FAILED) { + debug_error ("error creating sem : %d", errno); + return NULL; + } + + debug_msg ("returning sem [%p]", sem); + return sem; } int main(int argc, char **argv) { + sem_t* sem = NULL; server_arg serveropt; struct sigaction action; - int ret; +#ifdef USE_HIBERNATION int heynotifd = -1; - +#endif + int volumes[VOLUME_TYPE_MAX] = {0, }; +#if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING) + int pid; +#endif action.sa_handler = _exit_handler; action.sa_flags = 0; sigemptyset(&action.sa_mask); -#if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING) - int pid; -#endif - if (getOption(argc, argv, &serveropt)) return 1; + debug_warning("sound_server [%d] init \n", getpid()); + + if (serveropt.startserver) { + if ((sem = sem_create_n_wait()) == NULL) { + debug_log("sem_create_n_wait failed..\n"); + return 0; + } + } /* Daemon process create */ if (!serveropt.testmode && serveropt.startserver) { #if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING) daemon(0,0); //chdir to ("/"), and close stdio #endif } - - signal(SIGPIPE, SIG_IGN); //ignore SIGPIPE - /* - * Set oom_adj lowest 2010.03.09 - */ - - if(sound_system_bootup_recovery()) { - debug_error("Audio reset failed\n"); - } else { - debug_msg("Audio reset success\n"); + if (serveropt.poweroff) { + if (_handle_power_off() == 0) { + debug_log("_handle_power_off success!!\n"); + } else { + debug_error("_handle_power_off failed..\n"); + } + return 0; } - heynotifd = heynoti_init(); - if(heynoti_subscribe(heynotifd, "HIBERNATION_LEAVE", hibernation_leave_cb, NULL)) { - debug_error("heynoti_subscribe failed...\n"); - } else { - debug_msg("heynoti_subscribe() success\n"); + if (serveropt.soundreset) { + if (_handle_sound_reset() == 0) { + debug_log("_handle_sound_reset success!!\n"); + } else { + debug_error("_handle_sound_reset failed..\n"); + } + return 0; } - if(heynoti_attach_handler(heynotifd)) { - debug_error("heynoti_attach_handler() failed\n"); - } else { - debug_msg("heynoti_attach_handler() success\n"); - } + /* Sound Server Starts!!!*/ + debug_warning("sound_server [%d] start \n", getpid()); + + signal(SIGPIPE, SIG_IGN); //ignore SIGPIPE #if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING) while(1) @@ -199,7 +260,6 @@ int main(int argc, char **argv) return 3; } - if (serveropt.startserver || serveropt.printlist) { MMSoundThreadPoolInit(); MMSoundMgrRunInit(serveropt.plugdir); @@ -210,24 +270,40 @@ int main(int argc, char **argv) pulse_handle = MMSoundMgrPulseInit(); MMSoundMgrASMInit(); /* Wait for ASM Ready */ - wait_for_asm_ready(); + __wait_for_asm_ready(); + debug_warning("sound_server [%d] asm ready...now, initialize devices!!!\n", getpid()); + _mm_sound_mgr_device_init(); MMSoundMgrHeadsetInit(); MMSoundMgrDockInit(); + MMSoundMgrHdmiInit(); + MMSoundMgrWfdInit(); MMSoundMgrSessionInit(); } + debug_warning("sound_server [%d] initialization complete...now, start running!!\n", getpid()); + if (serveropt.startserver) { /* Start Run types */ MMSoundMgrRunRunAll(); +#ifdef USE_HIBERNATION /* set hibernation check */ _mm_sound_check_hibernation (HIBERNATION_SOUND_CHECK_PATH); +#endif + unlink(PA_READY); // remove pa_ready file after sound-server init. + if (sem_post(sem) == -1) { + debug_error ("error sem post : %d", errno); + } else { + debug_msg ("Ready to play booting sound!!!!"); + } /* Start Ipc mgr */ MMSoundMgrIpcReady(); } + debug_warning("sound_server [%d] terminating \n", getpid()); + if (serveropt.startserver || serveropt.printlist) { MMSoundMgrRunStopAll(); if (!serveropt.testmode) @@ -237,26 +313,35 @@ int main(int argc, char **argv) MMSoundMgrRunFini(); MMSoundThreadPoolFini(); + MMSoundMgrWfdFini(); + MMSoundMgrHdmiFini(); MMSoundMgrDockFini(); MMSoundMgrHeadsetFini(); MMSoundMgrSessionFini(); _mm_sound_mgr_device_fini(); MMSoundMgrASMFini(); MMSoundMgrPulseFini(pulse_handle); - +#ifdef USE_HIBERNATION if(heynoti_unsubscribe(heynotifd, "HIBERNATION_LEAVE", NULL)) { debug_error("heynoti_unsubscribe failed..\n"); } heynoti_close(heynotifd); +#endif } + + debug_warning("sound_server [%d] exit \n", getpid()); + return 0; } static int getOption(int argc, char **argv, server_arg *arg) { int c; + char *plugin_env_dir = NULL; static struct option long_options[] = { {"start", 0, 0, 'S'}, + {"poweroff", 0, 0, 'F'}, + {"soundreset", 0, 0, 'R'}, {"list", 0, 0, 'L'}, {"help", 0, 0, 'H'}, {"plugdir", 1, 0, 'P'}, @@ -265,9 +350,12 @@ static int getOption(int argc, char **argv, server_arg *arg) }; memset(arg, 0, sizeof(server_arg)); - arg->plugdir = getenv(PLUGIN_ENV); - if (arg->plugdir == NULL) - arg->plugdir = PLUGIN_DIR; + plugin_env_dir = getenv(PLUGIN_ENV); + if (plugin_env_dir) { + MMSOUND_STRNCPY(arg->plugdir, plugin_env_dir, MAX_PLUGIN_DIR_PATH_LEN); + } else { + MMSOUND_STRNCPY(arg->plugdir, PLUGIN_DIR, MAX_PLUGIN_DIR_PATH_LEN); + } arg->testmode = 0; @@ -275,7 +363,7 @@ static int getOption(int argc, char **argv, server_arg *arg) { int opt_idx = 0; - c = getopt_long (argc, argv, "SLHRP:T", long_options, &opt_idx); + c = getopt_long (argc, argv, "SFLHRUP:Tiurd", long_options, &opt_idx); if (c == -1) break; switch (c) @@ -283,14 +371,17 @@ static int getOption(int argc, char **argv, server_arg *arg) case 'S': /* Start daemon */ arg->startserver = 1; break; + case 'F': /* Poweroff */ + arg->poweroff = 1; + break; + case 'R': /* SoundReset */ + arg->soundreset = 1; + break; case 'L': /* list of plugins */ arg->printlist = 1; break; - case 'R': - MMSoundMgrCodecInit(arg->plugdir); - break; case 'P': /* Custom plugindir */ - arg->plugdir = optarg; + MMSOUND_STRNCPY(arg->plugdir, optarg, MAX_PLUGIN_DIR_PATH_LEN); break; case 'T': /* Test mode */ arg->testmode = 1; @@ -349,9 +440,13 @@ static int usgae(int argc, char **argv) { fprintf(stderr, "Usage: %s [Options]\n", argv[0]); fprintf(stderr, "\t%-20s: start sound server.\n", "--start,-S"); + fprintf(stderr, "\t%-20s: handle poweroff\n", "--poweroff,-F"); + fprintf(stderr, "\t%-20s: handle soundreset\n", "--soundreset,-R"); + fprintf(stderr, "\t%-20s: help message.\n", "--help,-H"); +#if 0 /* currently not in use */ fprintf(stderr, "\t%-20s: print plugin list.\n", "--list,-L"); - fprintf(stderr, "\t%-20s: print this message.\n", "--help,-H"); fprintf(stderr, "\t%-20s: print this message.\n", "--plugdir,-P"); +#endif return 1; } diff --git a/server/mm_sound_thread_pool.c b/server/mm_sound_thread_pool.c index 5cac361..bd00952 100644 --- a/server/mm_sound_thread_pool.c +++ b/server/mm_sound_thread_pool.c @@ -52,7 +52,7 @@ static void __ThreadWork(gpointer data, gpointer user_data) THREAD_INFO* info = (THREAD_INFO*)data; if (info) { if (info->func) { - debug_msg ("Calling [%p] with param [%p]\n", info->func, info->param); + debug_log ("Calling [%p] with param [%p]\n", info->func, info->param); info->func (info->param); } else { debug_warning ("No func to call....\n"); @@ -60,7 +60,7 @@ static void __ThreadWork(gpointer data, gpointer user_data) /* Info was allocated by MMSoundThreadPoolRun(). The actual content of info should be freed whether inside func or outside (if handle) */ - debug_msg ("free [%p]\n", info); + debug_log ("free [%p]\n", info); free (info); info = NULL; } else { @@ -76,12 +76,12 @@ int MMSoundThreadPoolDump(int fulldump) } if (fulldump) { - debug_msg ("##### [ThreadPool] max threads=[%d], max unused=[%d], max idle time=[%d]\n", + debug_log ("##### [ThreadPool] max threads=[%d], max unused=[%d], max idle time=[%d]\n", g_thread_pool_get_max_threads (g_pool), g_thread_pool_get_max_unused_threads(), g_thread_pool_get_max_idle_time() ); } - debug_msg ("***** [ThreadPool] running=[%d], unused=[%d]\n", + debug_log ("***** [ThreadPool] running=[%d], unused=[%d]\n", g_thread_pool_get_num_threads (g_pool), g_thread_pool_get_num_unused_threads() ); @@ -113,7 +113,7 @@ int MMSoundThreadPoolInit() This dummy thread will be remained unused as soon as it started */ debug_msg ("run threads to reserve minimum thread\n"); for (i=0; ifunc = func; thread_info->param = param; - debug_msg ("alloc thread_info = %p\n", thread_info); - + debug_log ("alloc thread_info = %p\n", thread_info); + /* Add thread to queue of thread pool */ g_thread_pool_push (g_pool, thread_info, &error); if (error) { debug_error ("g_thread_pool_push failed : %s\n", error->message); g_error_free (error); + free(thread_info); return MM_ERROR_SOUND_INTERNAL; } } else { @@ -148,7 +149,7 @@ int MMSoundThreadPoolRun(void *param, void (*func)(void*)) return MM_ERROR_SOUND_INTERNAL; } - return MM_ERROR_NONE; + return MM_ERROR_NONE; } int MMSoundThreadPoolFini(void) diff --git a/server/plugin/Makefile.am b/server/plugin/Makefile.am index d25a171..fab7428 100644 --- a/server/plugin/Makefile.am +++ b/server/plugin/Makefile.am @@ -1 +1,6 @@ +if OGG_SUPPORT +SUBDIRS = wav keytone tone ogg +else SUBDIRS = wav keytone tone +endif + diff --git a/server/plugin/keytone/Makefile.am b/server/plugin/keytone/Makefile.am index 05d2f7a..6a3ff0d 100644 --- a/server/plugin/keytone/Makefile.am +++ b/server/plugin/keytone/Makefile.am @@ -1,21 +1,25 @@ lib_LTLIBRARIES = libsoundpluginkeytone.la -#libsoundpluginkeytone_la_SOURCES = mm_sound_plugin_run_keytone.c -#libsoundpluginkeytone_la_SOURCES = mm_sound_plugin_run_keytone_alsa.c -libsoundpluginkeytone_la_SOURCES = mm_sound_plugin_run_key_tone.c +libsoundpluginkeytone_la_SOURCES = mm_sound_plugin_run_key_tone.c libsoundpluginkeytone_la_CFLAGS = \ $(MMCOMMON_CFLAGS) \ + $(VCONF_CFLAGS) \ + $(GIO_CFLAGS) \ -I$(srcdir)/../../../include \ -I$(srcdir)/../../include \ - $(MMLOGSVR_CFLAGS) -DMMF_LOG_OWNER=0x020 -DMMF_DEBUG_PREFIX=\"MMF-SOUND\" + $(MMLOGSVR_CFLAGS) -DMMF_LOG_OWNER=0x002 -DMMF_DEBUG_PREFIX=\"MMF-SOUND\" libsoundpluginkeytone_la_LIBADD = $(MMCOMMON_LIBS) \ $(MMLOGSVR_LIBS) \ - $(srcdir)/../../../common/libmmfsoundcommon.la + $(VCONF_LIBS) \ + $(GIO_LIBS) \ + $(srcdir)/../../../common/libmmfsoundcommon.la -libsoundpluginkeytone_la_CFLAGS += $(AVSYSTEM_CFLAGS) -libsoundpluginkeytone_la_LIBADD += $(AVSYSTEM_LIBS) +if OGG_SUPPORT +libsoundpluginkeytone_la_CFLAGS += $(TREMOLO_CFLAGS) +libsoundpluginkeytone_la_LIBADD += $(TREMOLO_LIBS) +endif install-exec-hook: mkdir -p $(DESTDIR)$(libdir)/soundplugins diff --git a/server/plugin/keytone/mm_sound_plugin_run_key_tone.c b/server/plugin/keytone/mm_sound_plugin_run_key_tone.c index 77ea6b4..5721af0 100644 --- a/server/plugin/keytone/mm_sound_plugin_run_key_tone.c +++ b/server/plugin/keytone/mm_sound_plugin_run_key_tone.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -38,20 +39,46 @@ #include #include -#include - +#include #include "../../include/mm_sound_plugin_run.h" #include "../../include/mm_sound_plugin_codec.h" +#include "../../../include/mm_sound_utils.h" +#include "../../../include/mm_sound_common.h" +#include "../../include/mm_sound_pa_client.h" + +#ifdef OGG_SUPPORT +#include +#define OGG_DEC_BUF_SIZE 4096 +#endif + +#define OGG_FILE_SAMPLE_PLAY_DURATION (290) +#define DEFAULT_TIMEOUT_MSEC_IN_USEC (600*1000) +#define ENV_KEYTONE_TIMEOUT "KEYTONE_TIMEOUT" -#define TIMEOUT_SEC 2 #define MAX_BUFFER_SIZE 1920 #define KEYTONE_PATH "/tmp/keytone" /* Keytone pipe path */ +#define KEYTONE_PATH_TMP "/tmp/keytone_tmp" /* Keytone pipe path (it will be deprecated)*/ #define KEYTONE_GROUP 6526 /* Keytone group : assigned by security */ #define FILE_FULL_PATH 1024 /* File path lenth */ #define AUDIO_CHANNEL 1 #define AUDIO_SAMPLERATE 44100 +#define DURATION_CRITERIA 11000 /* write once or not */ + +#define SUPPORT_DBUS_KEYTONE +#ifdef SUPPORT_DBUS_KEYTONE +#include + +#include + +#define BUS_NAME "org.tizen.system.deviced" +#define OBJECT_PATH "/Org/Tizen/System/DeviceD/Key" +#define INTERFACE_NAME "org.tizen.system.deviced.Key" +#define SIGNAL_NAME "ChangeHardkey" +#define DBUS_HW_KEYTONE "/usr/share/sounds/sound-server/Tizen_HW_Touch.ogg" + +#endif /* SUPPORT_DBUS_KEYTONE */ enum { WAVE_CODE_UNKNOWN = 0, @@ -85,19 +112,24 @@ typedef struct { pthread_mutex_t sw_lock; pthread_cond_t sw_cond; - avsys_handle_t handle; + int handle; int period; - int vol_type; + int volume_config; int state; void *src; +#ifdef OGG_SUPPORT + void *ogg_dec; + unsigned char *ogg_dec_buf; + int ogg_offset; +#endif } keytone_info_t; typedef struct { char filename[FILE_FULL_PATH]; - int vol_type; -}ipc_type; + int volume_config; +} ipc_type; typedef struct { @@ -108,16 +140,181 @@ typedef struct static int (*g_thread_pool_func)(void*, void (*)(void*)) = NULL; int CreateAudioHandle(); -static int g_CreatedFlag; +static int g_CreatedFlag = 0; static int __MMSoundKeytoneParse(MMSourceType *source, mmsound_codec_info_t *info); static int _MMSoundKeytoneInit(void); static int _MMSoundKeytoneFini(void); static int _MMSoundKeytoneRender(void *param_not_used); -static unsigned int _MMSoundKeytoneTimeOut(); static keytone_info_t g_keytone; static int stop_flag = 0; -static +//#define USE_SILENT_SND +#ifdef USE_SILENT_SND +/* Per Sample X 1000 msec /Samplerate = Duration per Sample msec */ +/* 1024 Samples X 1000 / 44.1K = 23.22 msec [Duration of Zerovalue feeding time */ +/* Mono channel & 16bit format = 2byte per sample */ +#define SILENT_SND 4096 +static unsigned char g_silent_sound[SILENT_SND]; +#endif + +#define CONTROL_LATENCY +#ifdef CONTROL_LATENCY +#define LATENCY_BUF (8192*2) +#define LATENCY_CONTROL (5292*2) +static unsigned char g_latency_buf[LATENCY_BUF]; +#endif + + + +#ifdef SUPPORT_DBUS_KEYTONE +typedef struct { + char filename[FILE_FULL_PATH]; + int volume_config; +} ipc_t; + +GDBusConnection *conn; +guint sig_id; + +static int _play_keytone(const char *filename, int volume_config) +{ + int err = -1; + int fd = -1; + ipc_t data = {{0,},}; + int ret = MM_ERROR_NONE; + + debug_msg("filepath=[%s], volume_config=[0x%x]\n", filename, volume_config); + + if (!filename) + return MM_ERROR_SOUND_INVALID_FILE; + + /* Open PIPE */ + if ((fd = open(KEYTONE_PATH, O_WRONLY | O_NONBLOCK)) != -1) { + /* Set send info. */ + data.volume_config = volume_config; + MMSOUND_STRNCPY(data.filename, filename, FILE_FULL_PATH); + /* Write to PIPE */ + if ((err = write(fd, &data, sizeof(ipc_t))) < 0) { + debug_error("Fail to write data: %s\n", strerror(errno)); + ret = MM_ERROR_SOUND_INTERNAL; + } + } else { + debug_error("Fail to open pipe\n"); + ret = MM_ERROR_SOUND_FILE_NOT_FOUND; + } + + /* Close PIPE */ + if (fd != -1) + close(fd); + + return ret; +} + +static bool __is_mute_sound () +{ + int setting_sound_status = true; + int setting_touch_sound = true; + + /* 1. Check if recording is in progress */ + if (_mm_sound_is_recording()) { + debug_log ("During Recording....MUTE!!!"); + return true; + } + + /* 2. Check both SoundStatus & TouchSound vconf key for mute case */ + vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &setting_sound_status); + vconf_get_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &setting_touch_sound); + + return !(setting_sound_status & setting_touch_sound); +} + +static void on_changed_receive(GDBusConnection *conn, + const gchar *sender_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *signal_name, + GVariant *parameters, + gpointer user_data) +{ + debug_msg ("sender : %s, object : %s, interface : %s, signal : %s", + sender_name, object_path, interface_name, signal_name); + + if (__is_mute_sound ()) { + debug_log ("Skip playing keytone due to mute sound mode"); + } else { + _play_keytone (DBUS_HW_KEYTONE, VOLUME_TYPE_SYSTEM | VOLUME_GAIN_TOUCH); + } +} + +static int _init_dbus_keytone () +{ + GError *err = NULL; + + debug_fenter (); + + g_type_init(); + + conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err); + if (!conn && err) { + debug_error ("g_bus_get_sync() error (%s) ", err->message); + g_error_free (err); + goto error; + } + + sig_id = g_dbus_connection_signal_subscribe(conn, + NULL, INTERFACE_NAME, SIGNAL_NAME, OBJECT_PATH, NULL, 0, + on_changed_receive, NULL, NULL); + if (sig_id == 0) { + debug_error ("g_dbus_connection_signal_subscribe() error (%d)", sig_id); + goto sig_error; + } + + debug_fleave (); + return 0; + +sig_error: + g_dbus_connection_signal_unsubscribe(conn, sig_id); + g_object_unref(conn); + +error: + return -1; +} + +static void _deinit_dbus_keytone () +{ + debug_fenter (); + g_dbus_connection_signal_unsubscribe(conn, sig_id); + g_object_unref(conn); + debug_fleave (); +} +#endif /* SUPPORT_DBUS_KEYTONE */ + + +static MMSourceType * _mm_source_dup(MMSourceType *source) +{ + MMSourceType *dup; + if(!(dup = (MMSourceType *) malloc (sizeof (MMSourceType)))) + goto fail; + memcpy (dup, source, sizeof (MMSourceType)); + + if(!(dup->ptr = (char*)malloc (source->tot_size))) + goto fail; + memcpy (dup->ptr, source->ptr, source->tot_size); + dup->type = MM_SOURCE_MEMORY; + dup->fd = -1; + + return dup; +fail: + if (dup) { + if (dup->ptr) + free(dup->ptr); + free(dup); + } + return MM_ERROR_SOUND_INTERNAL; +} + + + +static int MMSoundPlugRunKeytoneControlRun(void) { int pre_mask; @@ -127,26 +324,35 @@ int MMSoundPlugRunKeytoneControlRun(void) int size = 0; mmsound_codec_info_t info = {0,}; MMSourceType source = {0,}; + + mmsound_codec_info_t info_cached = {0,}; + MMSourceType* source_cached = NULL; + int is_new_keytone = 0; + char previous_keytone[FILE_FULL_PATH] = { 0, }; buf_param_t buf_param = {NULL, NULL}; +#ifdef OGG_SUPPORT + int skipsize; + OGG_DEC_INFO ogg_info; +#endif + debug_enter("\n"); /* INIT IPC */ pre_mask = umask(0); - if (mknod(KEYTONE_PATH,S_IFIFO|0660,0)<0) { + if (mknod(KEYTONE_PATH_TMP,S_IFIFO|0660,0)<0) { debug_warning ("mknod failed. errno=[%d][%s]\n", errno, strerror(errno)); } umask(pre_mask); - fd = open(KEYTONE_PATH, O_RDWR); - debug_msg("after open file descriptor %d\n", fd); + fd = open(KEYTONE_PATH_TMP, O_RDWR); if (fd == -1) { debug_warning("Check ipc node %s\n", KEYTONE_PATH); return MM_ERROR_SOUND_INTERNAL; } /* change access mode so group can use keytone pipe */ - if (fchmod (fd, 0660) == -1) { + if (fchmod (fd, 0666) == -1) { debug_warning("Changing keytone access mode is failed. errno=[%d][%s]\n", errno, strerror(errno)); } @@ -161,52 +367,112 @@ int MMSoundPlugRunKeytoneControlRun(void) debug_critical("Cannot create keytone\n"); } - stop_flag = 1; + /* While loop is always on */ + stop_flag = MMSOUND_TRUE; source.ptr = NULL; - debug_msg("[%s] Trace\n", __func__); + debug_msg("Start IPC with pipe\n"); size = sizeof(ipc_type); int once= MMSOUND_TRUE; - int flag= MMSOUND_FALSE; - g_CreatedFlag = MMSOUND_FALSE; - while(stop_flag) { +#ifdef SUPPORT_DBUS_KEYTONE + _init_dbus_keytone(); +#endif /* SUPPORT_DBUS_KEYTONE */ + + while (stop_flag) { memset(&data, 0, sizeof(ipc_type)); - debug_msg("[%s] The Keytone plugin is running......\n", __func__); +#if defined(_DEBUG_VERBOS_) + debug_log("Start to read from pipe\n"); +#endif ret = read(fd, (void *)&data, size); - if(ret == -1) { - debug_error("[%s] Fail to read file\n", __func__); + if (ret == -1) { + debug_error("Fail to read file\n"); continue; } - debug_msg("[%s] The Keytone plugin is running......READ returns....\n", __func__); +#if defined(_DEBUG_VERBOS_) + debug_log("Read returns\n"); +#endif pthread_mutex_lock(&g_keytone.sw_lock); - g_keytone.vol_type = data.vol_type; - debug_log("[%s] The volume type is [%d]\n", __func__, g_keytone.vol_type); if (g_keytone.state == RENDER_STARTED) { g_keytone.state = RENDER_STOP; pthread_cond_wait(&g_keytone.sw_cond, &g_keytone.sw_lock); } - - ret = mm_source_open_file(data.filename, &source, MM_SOURCE_NOT_DRM_CONTENTS); - if (ret != MM_ERROR_NONE) { - debug_critical("Cannot open files\n"); - pthread_mutex_unlock(&g_keytone.sw_lock); - continue; + + /* Close audio handle if volume_config is changed */ + if ((g_CreatedFlag == MMSOUND_TRUE) && (g_keytone.volume_config != data.volume_config)) { + debug_msg("Close audio handle if volume config is changed previous:%x new:%x", + g_keytone.volume_config, data.volume_config); + + if(mm_sound_pa_close(g_keytone.handle) < 0) + debug_critical("mm_sound_pa_close() failed !!!!!!!!\n"); + + g_CreatedFlag = MMSOUND_FALSE; } + g_keytone.volume_config = data.volume_config; +#if defined(_DEBUG_VERBOS_) + debug_log("The volume config is [%x]\n", g_keytone.volume_config); +#endif + is_new_keytone = strcmp (data.filename, previous_keytone); + if (is_new_keytone) { + ret = mm_source_open_file(data.filename, &source, MM_SOURCE_NOT_DRM_CONTENTS); + if (ret != MM_ERROR_NONE) { + debug_critical("Cannot open files\n"); + pthread_mutex_unlock(&g_keytone.sw_lock); + continue; + } + ret = __MMSoundKeytoneParse(&source, &info); + if (ret != MM_ERROR_NONE) { + debug_critical("Fail to parse file\n"); + mm_source_close(&source); + source.ptr = NULL; + pthread_mutex_unlock(&g_keytone.sw_lock); + continue; + } - ret = __MMSoundKeytoneParse(&source, &info); - if(ret != MM_ERROR_NONE) { - debug_critical("Fail to parse file\n"); - mm_source_close(&source); - source.ptr = NULL; - pthread_mutex_unlock(&g_keytone.sw_lock); - continue; + /* Close audio handle if audio spec is changed */ + if ((g_CreatedFlag == MMSOUND_TRUE) + && ((info.channels != info_cached.channels) + || (info.samplerate!= info_cached.samplerate) + || (info.format != info_cached.format))) { + debug_msg("Close audio handle if audio channel is changed with previous:%d new:%d", info_cached.channels, info.channels); + + if(mm_sound_pa_close(g_keytone.handle) < 0) + debug_critical("mm_sound_pa_close() failed !!!!!!!!\n"); + + g_CreatedFlag = MMSOUND_FALSE; + } + + /* Cache this */ + strcpy (previous_keytone, data.filename); + memcpy (&info_cached, &info, sizeof(mmsound_codec_info_t)); + /* Free previous buffer */ + if (source_cached) { + mm_source_close(source_cached); + free (source_cached); + source_cached = NULL; + } + /* Cache again in case of new keytone path */ + source_cached = _mm_source_dup(&source); + + /* Close opened file after copy sound */ + ret = mm_source_close(&source); + if (ret != MM_ERROR_NONE) + { + debug_critical("Fail to close file\n"); + source.ptr = NULL; + pthread_mutex_unlock(&g_keytone.sw_lock); + continue; + } + } else { +#if defined(_DEBUG_VERBOS_) + debug_msg ("CONTROL :: Use Cached data : skip source open & parse!!!!!\n"); +#endif } - if(g_CreatedFlag== MMSOUND_FALSE) { + if (g_CreatedFlag== MMSOUND_FALSE) { if(MM_ERROR_NONE != CreateAudioHandle(info)) { debug_critical("Audio handle creation failed. cannot play keytone\n"); mm_source_close(&source); @@ -216,28 +482,63 @@ int MMSoundPlugRunKeytoneControlRun(void) } g_CreatedFlag = MMSOUND_TRUE; } - - buf_param.info = &info; - buf_param.source = &source; + /* Use cached value always */ + buf_param.info = &info_cached; + buf_param.source = source_cached; + +#ifdef OGG_SUPPORT + if(!is_new_keytone) { + if (buf_param.info->codec == MM_SOUND_SUPPORTED_CODEC_OGG) { + debug_msg("In case OGG codec type = %d :: SrcPtr = %x :: SrcSize =%d \n ", buf_param.info->codec,buf_param.source->ptr, buf_param.source->cur_size); + ret = OGGDEC_ResetDecode(g_keytone.ogg_dec); + if(ret != OGGDEC_SUCCESS) { + debug_warning("Fail to reset, if in case of first time, ignore it"); + } + ret = OGGDEC_InitDecode(g_keytone.ogg_dec, (unsigned char*)buf_param.source->ptr, buf_param.source->cur_size, &skipsize); + if(ret != OGGDEC_SUCCESS) { + debug_error("Fail to init ogg decoder\n"); + pthread_mutex_unlock(&g_keytone.sw_lock); + if (fd > -1) close(fd); + return MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE; + } + ret = OGGDEC_InfoDecode(g_keytone.ogg_dec, (unsigned char*)buf_param.source->ptr, &skipsize, &ogg_info); + if(ret != OGGDEC_SUCCESS) { + debug_error("Fail to get ogg info\n"); + pthread_mutex_unlock(&g_keytone.sw_lock); + if (fd > -1) close(fd); + return MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE; + } + } + } +#endif g_keytone.src = &buf_param; - if(once== MMSOUND_TRUE) { + if (once== MMSOUND_TRUE) { g_thread_pool_func(NULL, (void*)_MMSoundKeytoneRender); once= MMSOUND_FALSE; } - if(g_keytone.state == RENDER_STOPED_N_WAIT || + if (g_keytone.state == RENDER_STOPED_N_WAIT || g_keytone.state == RENDER_COND_TIMED_WAIT) { pthread_cond_signal(&g_keytone.sw_cond); } - debug_log ("[%s] set state to START, unlock \n", __func__); +#if defined(_DEBUG_VERBOS_) + debug_log ("set state to START, unlock \n"); +#endif g_keytone.state = RENDER_START; pthread_mutex_unlock(&g_keytone.sw_lock); } - if(fd > -1) + if (fd > -1) close(fd); + + if (source_cached) { + mm_source_close(source_cached); + free(source_cached); + source_cached = NULL; + } + _MMSoundKeytoneFini(); debug_leave("\n"); @@ -247,7 +548,12 @@ int MMSoundPlugRunKeytoneControlRun(void) static int MMSoundPlugRunKeytoneControlStop(void) { - stop_flag = 0; /* No impl. Don`t stop */ + stop_flag = MMSOUND_FALSE; /* No impl. Don`t stop */ + +#ifdef SUPPORT_DBUS_KEYTONE + _deinit_dbus_keytone(); +#endif /* SUPPORT_DBUS_KEYTONE */ + return MM_ERROR_NONE; } @@ -282,30 +588,45 @@ int MMSoundGetPluginType(void) static int _MMSoundKeytoneInit(void) { - debug_enter("\n"); - //g_keytone.vol_type = AVSYS_AUDIO_VOLUME_TYPE_SYSTEM; //default value. - /* Set audio FIXED param */ - - g_keytone.state = RENDER_READY; - if(pthread_mutex_init(&(g_keytone.sw_lock), NULL)) { - debug_error("pthread_mutex_init() failed [%s][%d]\n", __func__, __LINE__); + memset(&g_keytone, 0x00, sizeof(g_keytone)); + if (pthread_mutex_init(&(g_keytone.sw_lock), NULL)) { + debug_error("pthread_mutex_init() failed\n"); return MM_ERROR_SOUND_INTERNAL; } - if(pthread_cond_init(&g_keytone.sw_cond,NULL)) { - debug_error("pthread_cond_init() failed [%s][%d]\n", __func__, __LINE__); + if (pthread_cond_init(&g_keytone.sw_cond,NULL)) { + debug_error("pthread_cond_init() failed\n"); + return MM_ERROR_SOUND_INTERNAL; + } +#ifdef OGG_SUPPORT + /* Ogg decoder create */ + g_keytone.ogg_dec_buf = (unsigned char*) malloc(sizeof(unsigned char)*OGG_DEC_BUF_SIZE); + if (g_keytone.ogg_dec_buf == NULL) { + debug_error("Fail to malloc\n"); + return MM_ERROR_SOUND_NO_FREE_SPACE; + } + memset(g_keytone.ogg_dec_buf, 0, sizeof(unsigned char)*OGG_DEC_BUF_SIZE); + if(!OGGDEC_CreateDecode(&g_keytone.ogg_dec)) { + free(g_keytone.ogg_dec_buf); + debug_error("Fail to create OGG decoder\n"); return MM_ERROR_SOUND_INTERNAL; } +#endif +#ifdef USE_SILENT_SND + memset(g_silent_sound, 0, SILENT_SND); +#endif - debug_msg("init\n"); +#ifdef CONTROL_LATENCY + memset(g_latency_buf, 0, LATENCY_BUF); +#endif return MM_ERROR_NONE; } static int _MMSoundKeytoneFini(void) { - g_keytone.handle = (avsys_handle_t)-1; + g_keytone.handle = -1; if (pthread_mutex_destroy(&(g_keytone.sw_lock))) { debug_error("Fail to destroy mutex\n"); @@ -317,35 +638,54 @@ static int _MMSoundKeytoneFini(void) debug_error("Fail to destroy cond\n"); return MM_ERROR_SOUND_INTERNAL; } +#ifdef OGG_SUPPORT + if(!OGGDEC_ResetDecode(g_keytone.ogg_dec)) { + debug_error("Fail to Reset decode\n"); + return MM_ERROR_SOUND_INTERNAL; + } + if(!OGGDEC_DeleteDecode(g_keytone.ogg_dec)) { + debug_error("Fail to delete decoder\n"); + return MM_ERROR_SOUND_INTERNAL; + } + if (g_keytone.ogg_dec_buf) + free(g_keytone.ogg_dec_buf); +#endif return MM_ERROR_NONE; } int CreateAudioHandle(mmsound_codec_info_t info) { int err = MM_ERROR_NONE; - avsys_audio_param_t audio_param; - - memset(&audio_param, 0, sizeof(avsys_audio_param_t)); + int size; + int mode; + pa_sample_spec ss; + + if(info.duration < OGG_FILE_SAMPLE_PLAY_DURATION) { + mode = HANDLE_MODE_OUTPUT_LOW_LATENCY; + } else { + mode = HANDLE_MODE_OUTPUT; + } - audio_param.mode = AVSYS_AUDIO_MODE_OUTPUT_LOW_LATENCY; - audio_param.channels = info.channels;//AUDIO_CHANNEL; - audio_param.samplerate = info.samplerate;//AUDIO_SAMPLERATE; - audio_param.format = AVSYS_AUDIO_FORMAT_16BIT; - audio_param.vol_type = g_keytone.vol_type; - audio_param.priority = AVSYS_AUDIO_PRIORITY_0; + ss.rate = info.samplerate; + ss.channels = info.channels; + ss.format = PA_SAMPLE_S16LE; + mm_sound_handle_route_info route_info; + route_info.policy = HANDLE_ROUTE_POLICY_OUT_AUTO; - err = avsys_audio_open(&audio_param, &g_keytone.handle, &g_keytone.period); - if (AVSYS_FAIL(err)) { - debug_error("Fail to audio open 0x%08X\n", err); + g_keytone.handle = mm_sound_pa_open(mode, &route_info, HANDLE_PRIORITY_NORMAL, g_keytone.volume_config, &ss, NULL, &size); + if(!g_keytone.handle) { + debug_error("Fail to audio open \n"); return MM_ERROR_SOUND_INTERNAL; } - debug_log("Period size is %d bytes\n", g_keytone.period); +#if defined(_DEBUG_VERBOS_) + debug_log("Period size is %d bytes\n", g_keytone.period); +#endif //FIXME :: remove dasf buffer size - if(g_keytone.period>MAX_BUFFER_SIZE) { + if (g_keytone.period > MAX_BUFFER_SIZE) { g_keytone.period = MAX_BUFFER_SIZE; } @@ -353,107 +693,193 @@ int CreateAudioHandle(mmsound_codec_info_t info) } +static void _init_timeout_val (struct timeval* ptv) +{ + int timeout_us = DEFAULT_TIMEOUT_MSEC_IN_USEC; + char* str_timeout = NULL; + + if (ptv == NULL) + return; + + str_timeout = getenv (ENV_KEYTONE_TIMEOUT); + if (str_timeout) { + debug_log ("[%s] detected = [%s]\n", ENV_KEYTONE_TIMEOUT, str_timeout); + timeout_us = atoi (str_timeout); + } + debug_log ("Set keytone timeout as [%d] us\n", timeout_us); + + ptv->tv_sec = 0; + ptv->tv_usec = timeout_us; +} + static int _MMSoundKeytoneRender(void *param_not_used) { //static int IsAmpON = MMSOUND_FALSE; //FIXME :: this should be removed MMSourceType source = {0,}; mmsound_codec_info_t info = {0,}; - unsigned char *buf = NULL, Outbuf[MAX_BUFFER_SIZE]; + unsigned char *buf = NULL; unsigned int size=0; buf_param_t *param=NULL; +// unsigned int period_buffer, period_time = 0; + +#ifdef LATENCY_CONTROL + static int lt_cnt = 0; +#endif + struct timespec timeout; struct timeval tv; + struct timeval tv_to_add; + struct timeval tv_result; int stat; +#ifdef OGG_SUPPORT + int err, decoded_len, used_size; +#endif + /* Initialize timeout value */ + _init_timeout_val (&tv_to_add); - -// unsigned int timeout_msec = _MMSoundKeytoneTimeOut(); + /* Loop */ while(stop_flag) { pthread_mutex_lock(&g_keytone.sw_lock); if(g_keytone.state == RENDER_STOPED) { - debug_log ("[%s] set state to STOPPED_N_WAIT and do cond wait\n", __func__); +#if defined(_DEBUG_VERBOS_) + debug_log ("set state to STOPPED_N_WAIT and do cond wait\n"); +#endif g_keytone.state = RENDER_STOPED_N_WAIT; pthread_cond_wait(&g_keytone.sw_cond, &g_keytone.sw_lock); } if(g_keytone.state == RENDER_START) { - //IsAmpON = MMSOUND_TRUE; - - debug_log ("[%s] state is START\n", __func__); param = (buf_param_t *)g_keytone.src; - source = *param->source; /* Copy source */ info = *param->info; buf = source.ptr+info.doffset; - size = info.size; - if(buf==NULL) { + if(buf[0]=='\0') { size=0; debug_critical("Ooops.... Not Expected!!!!!!!!\n"); } - g_keytone.state = RENDER_STARTED; } - pthread_mutex_unlock(&g_keytone.sw_lock); - - +#ifdef USE_SILENT_SND +{ + static int use_silent_snd = 0; + use_silent_snd = 1; + if(use_silent_snd) { + /* Silent SND playback */ + mm_sound_pa_write(g_keytone.handle, g_silent_sound, SILENT_SND); + debug_msg("[Keysound] Silence sound played %d\n",SILENT_SND); + use_silent_snd = 0; + } +} +#endif while(size && stop_flag) { pthread_mutex_lock(&g_keytone.sw_lock); if (g_keytone.state == RENDER_STOP) { - debug_log ("[%s] state is STOP\n", __func__); +#ifdef CONTROL_LATENCY +#if defined(_DEBUG_VERBOS_) + debug_log ("[CONTROL_LATENCY] state is STOP %d", lt_cnt); +#endif + if(lt_cnt > 0) { + mm_sound_pa_write(g_keytone.handle, g_latency_buf, lt_cnt); + mm_sound_pa_drain(g_keytone.handle); + lt_cnt = 0; + } +#endif /* CONTROL_LATENCY */ + pthread_mutex_unlock(&g_keytone.sw_lock); break; } - pthread_mutex_unlock(&g_keytone.sw_lock); - - if(size 0) { +#ifdef CONTROL_LATENCY + memcpy(g_latency_buf+lt_cnt, g_keytone.ogg_dec_buf, decoded_len); + lt_cnt += decoded_len; + buf += used_size; #if defined(_DEBUG_VERBOS_) - debug_msg("[%s][Keysound] Last Buffer :: size=%d, period=%d\n", __func__, size, g_keytone.period); -#endif - memset(Outbuf, 0, g_keytone.period); - memcpy(Outbuf, buf, size); - avsys_audio_write(g_keytone.handle, (void *)Outbuf, g_keytone.period); - - memset(Outbuf, 0, g_keytone.period); - avsys_audio_write(g_keytone.handle, (void *)Outbuf, g_keytone.period); - avsys_audio_write(g_keytone.handle, (void *)Outbuf, g_keytone.period); - + debug_log("[CONTROL_LATENCY] DATA Ring count %d", lt_cnt); +#endif + if(lt_cnt > LATENCY_CONTROL) { + mm_sound_pa_write(g_keytone.handle, g_latency_buf, lt_cnt); +#if defined(_DEBUG_VERBOS_) + debug_log("[CONTROL_LATENCY] Write count %d", lt_cnt); +#endif + lt_cnt = 0; + } +#else + mm_sound_pa_write(g_keytone.handle, g_keytone.ogg_dec_buf, decoded_len); + buf += used_size; +#endif /* CONTROL_LATENCY */ + } else { + size = 0; + break; + } + if (err != OGGDEC_SUCCESS) { + size = 0; + debug_log("Decoding End %d", err); +#ifdef CONTROL_LATENCY + if(lt_cnt > 0) { + mm_sound_pa_write(g_keytone.handle, g_latency_buf, lt_cnt); +#if defined(_DEBUG_VERBOS_) + debug_log("[CONTROL_LATENCY] Last frame is out %d", lt_cnt); +#endif + mm_sound_pa_drain(g_keytone.handle); + lt_cnt = 0; + } +#endif /* CONTROL_LATENCY */ + break; + } +#endif /* OGG_SUPPORT */ + } else if (size < DURATION_CRITERIA) { +#if defined(_DEBUG_VERBOS_) + debug_msg("[Keysound] Last Buffer :: size=%d, period=%d\n", size, DURATION_CRITERIA); +#endif + mm_sound_pa_write(g_keytone.handle, buf, size); size = 0; } else { #if defined(_DEBUG_VERBOS_) - debug_msg("[%s][Keysound] size=%d, period=%d\n", __func__, size, g_keytone.period); + debug_msg("[Keysound] size=%d, period=%d\n", size, DURATION_CRITERIA); #endif - memcpy(Outbuf, buf, g_keytone.period); - - avsys_audio_write(g_keytone.handle, (void *)Outbuf, g_keytone.period); - size -= g_keytone.period; - buf += g_keytone.period; - + mm_sound_pa_write(g_keytone.handle, (void *)buf, DURATION_CRITERIA); + size -= DURATION_CRITERIA; + buf += DURATION_CRITERIA; } } - - mm_source_close(&source); - source.ptr = NULL; - pthread_mutex_lock(&g_keytone.sw_lock); if(g_keytone.state == RENDER_STOP ) { - debug_msg("[%s] state is STOP, do cond signal \n", __func__); +#if defined(_DEBUG_VERBOS_) + debug_log("state is STOP, do cond signal \n"); +#endif g_keytone.state = RENDER_STOPED; pthread_cond_signal(&g_keytone.sw_cond); } else { - debug_msg("[%s] state is not STOP\n", __func__); +#if defined(_DEBUG_VERBOS_) + debug_log("state is not STOP\n"); +#endif g_keytone.state = RENDER_COND_TIMED_WAIT; + + /* Set timeout : GetCurrent + Timeout => convert to timespec */ gettimeofday(&tv, NULL); - timeout.tv_sec = tv.tv_sec + TIMEOUT_SEC; - timeout.tv_nsec = tv.tv_usec; + timeradd(&tv, &tv_to_add, &tv_result); + timeout.tv_sec = tv_result.tv_sec; + timeout.tv_nsec = tv_result.tv_usec * 1000; + stat = pthread_cond_timedwait(&g_keytone.sw_cond, &g_keytone.sw_lock, &timeout); if(stat == ETIMEDOUT && g_keytone.state != RENDER_START) { - debug_msg("[%s] Do audio handle close and set state to STOPPED\n", __func__); - if(AVSYS_FAIL(avsys_audio_close(g_keytone.handle))) { - debug_critical("avsys_audio_close() failed !!!!!!!!\n"); - } + debug_log("TIMEOUT in Not START state, close Audio, set state to STOPPED\n"); + + if(mm_sound_pa_close(g_keytone.handle) < 0) + debug_critical("mm_sound_pa_close() failed !!!!!!!!\n"); g_CreatedFlag = MMSOUND_FALSE; g_keytone.state = RENDER_STOPED; @@ -500,8 +926,11 @@ static int __MMSoundKeytoneParse(MMSourceType *source, mmsound_codec_info_t *inf int datalen = -1; char *data = NULL; unsigned int tSize; - - debug_enter("\n"); + int ret; +#ifdef OGG_SUPPORT + OGG_DEC_INFO ogg_info; + int skipsize; +#endif data = MMSourceGetPtr(source); datalen = MMSourceGetCurSize(source); @@ -513,8 +942,46 @@ static int __MMSoundKeytoneParse(MMSourceType *source, mmsound_codec_info_t *inf priff = (struct __riff_chunk *) data; /* Must be checked, Just for wav or not */ - if (priff->chunkid != RIFF_CHUNK_ID ||priff->rifftype != RIFF_CHUNK_TYPE) + if (priff->chunkid != RIFF_CHUNK_ID ||priff->rifftype != RIFF_CHUNK_TYPE) { +#ifdef OGG_SUPPORT + ret = OGGDEC_ResetDecode(g_keytone.ogg_dec); + if(ret != OGGDEC_SUCCESS) { + debug_warning("Fail to reset, if in case of first time, ignore it"); + } + /* Ogg media type case */ + ret = OGGDEC_InitDecode(g_keytone.ogg_dec, (unsigned char*)data, datalen, &skipsize); + if(ret != OGGDEC_SUCCESS ) { + debug_error("Fail to init ogg decoder\n"); + return MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE; + } + info->doffset = skipsize; + + ret = OGGDEC_InfoDecode(g_keytone.ogg_dec, (unsigned char*)data, &skipsize, &ogg_info); + if(ret != OGGDEC_SUCCESS ) { + debug_error("Fail to get ogg info\n"); + return MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE; + } + ret = OGGDEC_PreparseDecode((unsigned char*)data, datalen, &ogg_info); + if (ret != OGGDEC_SUCCESS) { + debug_error("Not valid Ogg data format"); + return MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE; + } + + info->codec = MM_SOUND_SUPPORTED_CODEC_OGG; + info->channels = ogg_info.channels; + info->format = 16; + info->samplerate = ogg_info.samplerate; + info->doffset += skipsize; + info->size = datalen; + info->duration = ogg_info.duration; + debug_msg("Duration %d :: Channels %d :: Samplerate %d :: File size %d :: offset %d \n", ogg_info.duration, ogg_info.channels, ogg_info.samplerate, info->size, info->doffset); + //debug_leave("\n"); + return MM_ERROR_NONE; +#else + debug_error("Not WAVE File\n"); return MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE; +#endif + } if(priff->chunksize != datalen -8) priff->chunksize = (datalen-8); @@ -578,7 +1045,9 @@ static int __MMSoundKeytoneParse(MMSourceType *source, mmsound_codec_info_t *inf info->samplerate = pwav->samplerate; info->doffset = (tSize+8); info->size = pdata->chunkSize; +#if defined(_DEBUG_VERBOS_) debug_msg("info->size:%d\n", info->size); - debug_leave("\n"); +#endif + return MM_ERROR_NONE; } diff --git a/server/plugin/ogg/Makefile.am b/server/plugin/ogg/Makefile.am new file mode 100644 index 0000000..ea1c76b --- /dev/null +++ b/server/plugin/ogg/Makefile.am @@ -0,0 +1,21 @@ +lib_LTLIBRARIES = libsoundplugintremoloogg.la + +libsoundplugintremoloogg_la_SOURCES = \ + mm_sound_plugin_codec_ogg.c + +libsoundplugintremoloogg_la_CFLAGS = \ + $(MMCOMMON_CFLAGS) \ + $(TREMOLO_CFLAGS) \ + -I$(srcdir)/ \ + -I$(srcdir)/../../include \ + -I$(srcdir)/../../../include \ + $(MMLOGSVR_CFLAGS) -DMMF_LOG_OWNER=0x002 -DMMF_DEBUG_PREFIX=\"MMF-SOUND\" + +libsoundplugintremoloogg_la_LIBADD = $(MMCOMMON_LIBS) \ + $(MMLOGSVR_LIBS) \ + $(TREMOLO_LIBS) \ + $(srcdir)/../../../common/libmmfsoundcommon.la + +install-exec-hook: + mkdir -p $(DESTDIR)$(libdir)/soundplugins + ln -sf /usr/lib/libsoundplugintremoloogg.so $(DESTDIR)$(libdir)/soundplugins/libsoundplugintremoloogg.so diff --git a/server/plugin/ogg/mm_sound_plugin_codec_ogg.c b/server/plugin/ogg/mm_sound_plugin_codec_ogg.c new file mode 100644 index 0000000..78abc8f --- /dev/null +++ b/server/plugin/ogg/mm_sound_plugin_codec_ogg.c @@ -0,0 +1,519 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * 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 + +#include +#include +#include + +#include "../../include/mm_sound.h" +#include "../../include/mm_ipc.h" +#include "../../include/mm_sound_thread_pool.h" +#include "../../include/mm_sound_plugin_codec.h" +#include "../../../include/mm_sound_private.h" +#include "../../../include/mm_sound_pa_client.h" + +#define OGG_DEC_BUF_SIZE 4096 +#define OGG_FILE_SAMPLE_PLAY_DURATION 290 + +#define TIME_MSEC (1000) +#define SILENT_SND_MIN_VALUE (90) +#define CODEC_OGG_LOCK(LOCK) do { pthread_mutex_lock(LOCK); } while (0) +#define CODEC_OGG_UNLOCK(LOCK) do { pthread_mutex_unlock(LOCK); } while (0) + +int MMSoundPlugCodecOggStop(MMHandleType handle); + +enum { + STATE_NONE = 0, + STATE_READY, + STATE_BEGIN, + STATE_PLAY, + STATE_ENDOFDECORD, + STATE_STOP, +}; + +typedef struct { + /* thread controls */ + sem_t start_wave_signal; /* control start of pcm write thread */ + sem_t start_ogg_signal; /* control start of ogg decord thread*/ + pthread_mutex_t mutex; + + /* Codec infomations */ + void *decoder; + char* pcm_out_buf; + int offset; + int period; + int handle_route; + int gain, out, in, option; + mm_sound_device_in device_in; + mm_sound_device_out device_out; + unsigned int volume_value; + + /* Audio Infomations */ + int transper_size; /* audio open return */ + int handle; + + /* control Informations */ + int repeat_count; + int (*stop_cb)(int); + int cb_param; + int state; + MMSourceType *source; + int codec; + int NumberOfChannels; + int SamplingFrequency; + int format; + int Duration; + int BitRate; + int BufferSize; +} ogg_info_t; + +static int (*g_thread_pool_func)(void*, void (*)(void*)) = NULL; + +void _pcm_out_func(void *data) +{ + ogg_info_t *p = (ogg_info_t*) data; + int used_size; + int decoded_len; + unsigned char* ogg_buf; + unsigned int ogg_remain; + int err; + mm_sound_device_in device_in_after = MM_SOUND_DEVICE_IN_NONE; + mm_sound_device_out device_out_after = MM_SOUND_DEVICE_OUT_NONE; + + debug_enter("\n"); + + sem_wait(&p->start_wave_signal); + ogg_buf = MMSourceGetPtr(p->source); + ogg_remain = MMSourceGetCurSize(p->source); + + while (p->state == STATE_PLAY) { + err = OGGDEC_FrameDecode(p->decoder, ogg_buf+p->offset, &used_size, p->pcm_out_buf, &decoded_len); + if (decoded_len > 0) { + mm_sound_pa_write(p->handle, p->pcm_out_buf, decoded_len); + ogg_buf += used_size; + ogg_remain -= used_size; + if(err != OGGDEC_SUCCESS) { + MMSoundPlugCodecOggStop((MMHandleType)p); + debug_error("Decode done :: %d\n", err); + break; + } + } else { + MMSoundPlugCodecOggStop((MMHandleType)p); + break; + } + } + + mm_sound_pa_drain(p->handle); + mm_sound_pa_close(p->handle); + + /* + * Restore path here + */ + if (p->handle_route == MM_SOUND_HANDLE_ROUTE_SPEAKER) { + /* If current path is not same as before playing sound, restore the sound path */ + if (p->device_out != MM_SOUND_DEVICE_OUT_SPEAKER) { + mm_sound_set_sound_path_for_active_device(p->device_out, p->device_in); + mm_sound_pa_corkall(0); + } + } + if(p->handle_route == MM_SOUND_HANDLE_ROUTE_SPEAKER || p->handle_route == MM_SOUND_HANDLE_ROUTE_SPEAKER_NO_RESTORE) { + __mm_sound_unlock(); + } + /* Notice */ + /* OggDestory is called by stop_cb func */ + /* INDEED the stop_cb must be called, after end of all progress */ + if(p->stop_cb) { + p->stop_cb(p->cb_param); + } + debug_leave("\n"); +} + +int MMSoundPlugCodecOggSetThreadPool(int (*func)(void*, void (*)(void*))) +{ + debug_enter("(func : %p)\n", func); + g_thread_pool_func = func; + debug_leave("\n"); + return MM_ERROR_NONE; +} + +int* MMSoundPlugCodecOggGetSupportTypes(void) +{ + debug_enter("\n"); + static int suported[2] = {MM_SOUND_SUPPORTED_CODEC_OGG, 0}; + debug_leave("\n"); + return suported; +} + +int MMSoundPlugCodecOggParse(MMSourceType *source, mmsound_codec_info_t *info) +{ + unsigned char *ptr = NULL; + unsigned int size = 0; + int err; + OGG_DEC_INFO ogg_info; + + debug_enter("\n"); + + ptr = (unsigned char*)MMSourceGetPtr(source); + size = MMSourceGetCurSize(source); + debug_msg("[CODEC OGG] source ptr :[0x%08X] ::: source size :[0x%d]\n", ptr, size); + + err = OGGDEC_PreparseDecode(ptr, size, &ogg_info); + if (err != OGGDEC_SUCCESS) { + debug_error("Not valid Ogg data format"); + return MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE; + } + + info->format = 16; + info->channels = ogg_info.channels; + info->samplerate = ogg_info.samplerate; + info->duration = ogg_info.duration; + info->codec = MM_AUDIO_CODEC_OGG; + debug_msg("[CODEC OGG]Channels %d Samplerate %d\n", ogg_info.channels, ogg_info.samplerate); + debug_leave("\n"); + + return MM_ERROR_NONE; +} + +int MMSoundPlugCodecOggCreate(mmsound_codec_param_t *param, mmsound_codec_info_t *info, MMHandleType *handle) +{ + ogg_info_t* p = NULL; + MMSourceType *source = NULL; + OGG_DEC_INFO ogg_info; + int err, used_size, skipsize; + + mm_sound_handle_route_info route_info; + route_info.policy = HANDLE_ROUTE_POLICY_OUT_AUTO; + + pa_sample_spec ss; + int size = 0; + int mode = HANDLE_MODE_OUTPUT_LOW_LATENCY; + + debug_enter("\n"); + + if (g_thread_pool_func == NULL) { + debug_error("Need thread pool!\n"); + return MM_ERROR_SOUND_INTERNAL; + } + + source = param->source; + debug_msg("[CODEC OGG]Param source p 0x08%X\n", param->source); + + p = (ogg_info_t *) malloc(sizeof(ogg_info_t)); + if (p == NULL) { + debug_error("[CODEC OGG]Memory allocation Fail\n"); + return MM_ERROR_OUT_OF_MEMORY; + } + + memset(p, 0, sizeof(ogg_info_t)); + p->source = param->source; + p->BufferSize = MMSourceGetCurSize(source); + + pthread_mutex_init(&p->mutex, NULL); + + err = sem_init(&p->start_ogg_signal, 0, 0); + if (err == -1) { + debug_error("[CODEC OGG]Semaphore init fail\n"); + free(p); + return MM_ERROR_SOUND_INTERNAL; + } + + err = sem_init(&p->start_wave_signal, 0, 0); + if (err == -1) { + debug_error("[CODEC OGG]Semaphore init fail\n"); + sem_destroy(&p->start_ogg_signal); + free(p); + return MM_ERROR_SOUND_INTERNAL; + } + + err = OGGDEC_CreateDecode(&p->decoder); + if (err != OGGDEC_SUCCESS || p->decoder == NULL) { + debug_error("[CODEC OGG]Fail to Create ogg decoder\n"); + sem_destroy(&p->start_ogg_signal); + sem_destroy(&p->start_wave_signal); + free(p); + return MM_ERROR_SOUND_INTERNAL; + } + p->pcm_out_buf = (char *)malloc(sizeof(char)*OGG_DEC_BUF_SIZE); + if (p->pcm_out_buf == NULL) { + debug_error("[CODEC OGG]Memory allocation fail\n"); + sem_destroy(&p->start_ogg_signal); + sem_destroy(&p->start_wave_signal); + OGGDEC_ResetDecode(p->decoder); + OGGDEC_DeleteDecode(p->decoder); + free(p); + return MM_ERROR_SOUND_NO_FREE_SPACE; + } + err = OGGDEC_InitDecode(p->decoder, (unsigned char*)p->source->ptr, p->BufferSize, &skipsize); + if (err != OGGDEC_SUCCESS || p->decoder == NULL) { + debug_error("Fail to init ogg decoder\n"); + sem_destroy(&p->start_ogg_signal); + sem_destroy(&p->start_wave_signal); + OGGDEC_ResetDecode(p->decoder); + OGGDEC_DeleteDecode(p->decoder); + free(p->pcm_out_buf); + free(p); + return MM_ERROR_SOUND_INTERNAL; + } + p->offset = skipsize; + + err = OGGDEC_InfoDecode(p->decoder, p->source->ptr+p->offset, &used_size, &ogg_info); + if (err != OGGDEC_SUCCESS || p->decoder == NULL) + { + debug_error("[CODEC OGG]Fail to get ogg info\n"); + sem_destroy(&p->start_ogg_signal); + sem_destroy(&p->start_wave_signal); + OGGDEC_ResetDecode(p->decoder); + OGGDEC_DeleteDecode(p->decoder); + free(p->pcm_out_buf); + free(p); + return MM_ERROR_SOUND_INTERNAL; + } + p->offset += used_size; + p->Duration = info->duration; + p->format = info->format = 16; + info->channels = ogg_info.channels; + info->samplerate = ogg_info.samplerate; + + /* Temporal code for debug */ + /* + debug_msg("([CODEC OGG]handle %x)\n", p); + debug_msg("[CODEC OGG]Type %s\n", info->codec == MM_AUDIO_CODEC_OGG ? "OGG" : "Unknown"); + debug_msg("[CODEC OGG]channels : %d\n", info->channels); + debug_msg("[CODEC OGG]format : %d\n", info->format); + debug_msg("[CODEC OGG]samplerate : %d\n", info->samplerate); + debug_msg("[CODEC OGG]doffset : %d\n", info->doffset); + debug_msg("[CODEC OGG]priority : %d\n", param->priority); + debug_msg("[CODEC OGG]repeat : %d\n", param->repeat_count); + debug_msg("[CODEC OGG]volume : %d\n", param->volume); + debug_msg("[CODEC OGG]callback : %08x\n", param->stop_cb); + */ + debug_msg("Audio duration [%d]", info->duration); + p->repeat_count = param ->repeat_count; + p->stop_cb = param->stop_cb; + p->cb_param = param->param; + + if(info->duration < OGG_FILE_SAMPLE_PLAY_DURATION) { + mode = HANDLE_MODE_OUTPUT_LOW_LATENCY; + } else { + mode = HANDLE_MODE_OUTPUT; + } + + if(param->handle_route == MM_SOUND_HANDLE_ROUTE_USING_CURRENT) /* normal, solo */ + route_info.policy = HANDLE_ROUTE_POLICY_OUT_AUTO; + else /* loud solo */ + route_info.policy = HANDLE_ROUTE_POLICY_OUT_HANDSET; + + p->handle_route = param->handle_route; + + switch(info->format) + { + case 8: + ss.format = PA_SAMPLE_U8; + break; + case 16: + ss.format = PA_SAMPLE_S16LE; + break; + default: + ss.format = PA_SAMPLE_S16LE; + break; + } + ss.channels = info->channels; + ss.rate = info->samplerate; + + debug_msg("[CODEC OGG] PARAM mode:[%d] priority:[%d] policy:[%d] channels:[%d] samplerate:[%d] format:[%d] volume type:[%x]\n", + mode,-1, route_info.policy, ss.channels, ss.rate, ss.format, param->volume_config); + + /* + * set path here + */ + switch(p->handle_route) + { + case MM_SOUND_HANDLE_ROUTE_SPEAKER: + case MM_SOUND_HANDLE_ROUTE_SPEAKER_NO_RESTORE: + debug_msg("[CODEC OGG] Save backup path\n"); + __mm_sound_lock(); + mm_sound_get_audio_path(&p->device_in, &p->device_out); + /* if current out is not speaker, then force set path to speaker */ + if (p->device_out != MM_SOUND_DEVICE_OUT_SPEAKER) { + debug_msg("[CODEC OGG] current out is not SPEAKER, set path to SPEAKER now!!!\n"); + mm_sound_pa_corkall(1); + mm_sound_set_sound_path_for_active_device(MM_SOUND_DEVICE_OUT_SPEAKER, MM_SOUND_DEVICE_IN_NONE); + } + break; + case MM_SOUND_HANDLE_ROUTE_USING_CURRENT: + default: + break; + } + p->handle = mm_sound_pa_open(HANDLE_MODE_OUTPUT_LOW_LATENCY, &route_info, 0, param->volume_config, &ss, NULL, &size); + if(!p->handle) { + debug_error("[CODEC OGG] Can not open audio handle\n"); + if (p->handle_route == MM_SOUND_HANDLE_ROUTE_SPEAKER || p->handle_route == MM_SOUND_HANDLE_ROUTE_SPEAKER_NO_RESTORE) { + __mm_sound_unlock(); + } + + sem_destroy(&p->start_ogg_signal); + sem_destroy(&p->start_wave_signal); + OGGDEC_ResetDecode(p->decoder); + OGGDEC_DeleteDecode(p->decoder); + free(p->pcm_out_buf); + free(p); + return MM_ERROR_SOUND_INTERNAL; + } + + pthread_mutex_lock(&p->mutex); + p->state = STATE_READY; + pthread_mutex_unlock(&p->mutex); + *handle = p; + + err = g_thread_pool_func(p, _pcm_out_func); + if (err) { + if (p->handle_route == MM_SOUND_HANDLE_ROUTE_SPEAKER || p->handle_route == MM_SOUND_HANDLE_ROUTE_SPEAKER_NO_RESTORE) { + __mm_sound_unlock(); + } + sem_destroy(&p->start_ogg_signal); + sem_destroy(&p->start_wave_signal); + OGGDEC_ResetDecode(p->decoder); + OGGDEC_DeleteDecode(p->decoder); + free(p->pcm_out_buf); + free(p); + debug_error("[CODEC OGG]pthread_create() fail in pcm thread\n"); + return MM_ERROR_SOUND_INTERNAL; + } + + debug_leave("\n"); + return MM_ERROR_NONE; +} + +int MMSoundPlugCodecOggPlay(MMHandleType handle) +{ + ogg_info_t *p = (ogg_info_t *) handle; + debug_enter("(handle %x)\n", handle); + + if (p->BufferSize <= 0) { + debug_error("[CODEC OGG]End of file\n"); + return MM_ERROR_END_OF_FILE; + } + pthread_mutex_lock(&p->mutex); + p->state = STATE_PLAY; + pthread_mutex_unlock(&p->mutex); + sem_post(&p->start_wave_signal); + + debug_leave("\n"); + return MM_ERROR_NONE; +} + +int MMSoundPlugCodecOggStop(MMHandleType handle) +{ + ogg_info_t *p = (ogg_info_t *) handle; + debug_enter("(handle %x)\n", handle); + pthread_mutex_lock(&p->mutex); + p->state = STATE_STOP; + pthread_mutex_unlock(&p->mutex); + debug_leave("\n"); + + return MM_ERROR_NONE; +} + +int MMSoundPlugCodecOggDestroy(MMHandleType handle) +{ + ogg_info_t *p = (ogg_info_t*) handle; + int err; + + debug_enter("(handle %x)\n", handle); + + if (!p) { + debug_critical("Confirm the hadle (is NULL)\n"); + err = MM_ERROR_SOUND_INTERNAL; + return err; + } + + if(p->source) { + mm_source_close(p->source); + free(p->source); p->source = NULL; + } + + err = OGGDEC_ResetDecode(p->decoder); + if (err != OGGDEC_SUCCESS) { + debug_error("[CODEC OGG]Codec Reset fail\n"); + err = MM_ERROR_SOUND_INTERNAL; + } + + err = OGGDEC_DeleteDecode(p->decoder); + if (err != OGGDEC_SUCCESS) { + debug_error("[CODEC OGG]Delete Decode fail\n"); + err = MM_ERROR_SOUND_INTERNAL; + } + + sem_destroy(&p->start_wave_signal); + sem_destroy(&p->start_ogg_signal); + + if(p->pcm_out_buf) { + free(p->pcm_out_buf); + p->pcm_out_buf = NULL; + } + + if (p) { + free (p); + p = NULL; + } + + debug_leave("\n"); + return err; +} + +EXPORT_API +int MMSoundGetPluginType(void) +{ + debug_enter("\n"); + debug_leave("\n"); + return MM_SOUND_PLUGIN_TYPE_CODEC; +} + +EXPORT_API +int MMSoundPlugCodecGetInterface(mmsound_codec_interface_t *intf) +{ + debug_enter("\n"); + if (!intf) { + debug_critical("Confirm the codec interface struct (is NULL)\n"); + return MM_ERROR_SOUND_INTERNAL; + } + + intf->GetSupportTypes = MMSoundPlugCodecOggGetSupportTypes; + intf->Parse = MMSoundPlugCodecOggParse; + intf->Create = MMSoundPlugCodecOggCreate; + intf->Destroy = MMSoundPlugCodecOggDestroy; + intf->Play = MMSoundPlugCodecOggPlay; + intf->Stop = MMSoundPlugCodecOggStop; + intf->SetThreadPool = MMSoundPlugCodecOggSetThreadPool; + + debug_leave("\n"); + return MM_ERROR_NONE; +} diff --git a/server/plugin/tone/Makefile.am b/server/plugin/tone/Makefile.am index b061bdd..022bc49 100644 --- a/server/plugin/tone/Makefile.am +++ b/server/plugin/tone/Makefile.am @@ -6,15 +6,12 @@ libsoundplugintone_la_CFLAGS = \ $(MMCOMMON_CFLAGS) \ -I$(srcdir)/../../../../common/include \ -I$(srcdir)/../../../include \ - $(MMLOGSVR_CFLAGS) -DMMF_LOG_OWNER=0x020 -DMMF_DEBUG_PREFIX=\"MMF-SOUND\" + $(MMLOGSVR_CFLAGS) -DMMF_LOG_OWNER=0x002 -DMMF_DEBUG_PREFIX=\"MMF-SOUND\" libsoundplugintone_la_LIBADD = \ $(MMCOMMON_LIBS) \ $(MMLOGSVR_LIBS) -libsoundplugintone_la_CFLAGS += $(AVSYSTEM_CFLAGS) -libsoundplugintone_la_LIBADD += $(AVSYSTEM_LIBS) - install-exec-hook: mkdir -p $(DESTDIR)$(libdir)/soundplugins ln -sf /usr/lib/libsoundplugintone.so $(DESTDIR)$(libdir)/soundplugins/libsoundplugintone.so diff --git a/server/plugin/tone/mm_sound_plugin_codec_tone.c b/server/plugin/tone/mm_sound_plugin_codec_tone.c index 4a90cdb..468bd74 100644 --- a/server/plugin/tone/mm_sound_plugin_codec_tone.c +++ b/server/plugin/tone/mm_sound_plugin_codec_tone.c @@ -27,8 +27,6 @@ #include #include -#include - #include "../../include/mm_sound_thread_pool.h" #include "../../include/mm_sound_plugin_codec.h" #include @@ -42,6 +40,10 @@ #include #include #include + +#include +#include "../../../include/mm_sound_pa_client.h" + #ifndef M_PI #define M_PI 3.14159265358979323846 #endif @@ -72,18 +74,20 @@ typedef enum { CONTROL_PLAYING, } control_e; +#if 0 typedef struct { pthread_mutex_t syncker; pthread_cond_t cond; int state; } tone_control_t; +#endif typedef struct { /* AMR Buffer */ int size; /* sizeof hole amr data */ /* Audio Infomations */ - avsys_handle_t audio_handle; + int handle; /* control Informations */ int repeat_count; @@ -112,13 +116,13 @@ typedef struct st_tone float low_frequency; float middle_frequency; float high_frequency; - int playingTime; - int loopCnt; - int loopIndx; + int playingTime; + int loopCnt; + int loopIndx; } TONE; - static const int TONE_SEGMENT[][MM_SOUND_TONE_NUM] = - { +static const int TONE_SEGMENT[][MM_SOUND_TONE_NUM] = +{ {941, 1336, 0, -1, 0, 0, -1, -1, -1, -1, 0, 0},// 0 key: 1336Hz, 941Hz @@ -171,7 +175,7 @@ typedef struct st_tone -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Dial tone: CEPT: 425Hz, continuous {350, 440, 0, -1, 0, 0, - -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Dial tone: ANSI (IS-95): 350Hz+440Hz, continuous\ + -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Dial tone: ANSI (IS-95): 350Hz+440Hz, continuous {400, 0, 0, -1, 0, 0, -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Dial tone: JAPAN: 400Hz, continuous @@ -190,14 +194,14 @@ typedef struct st_tone {425, 0, 0, 200, 0, 0, 0, 0, 0, 200, 0, 0, - -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Congestion: CEPT, JAPAN: 425Hz, 200ms ON, 200ms OFF + -1, -1, -1, -1, 1, 0}, //Call supervisory tone, Congestion: CEPT, JAPAN: 425Hz, 200ms ON, 200ms OFF {480, 620, 0, 250, 0, 0, 0, 0, 0, 250, 0, 0, -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Congestion: ANSI (IS-95): 480Hz+620Hz, 250ms ON, 250ms OFF... {425, 0, 0, 200, 0, 0, - -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Radio path acknowlegment : CEPT, ANSI: 425Hz, 200ms ON + -1, -1, -1, -1, 1, 0}, //Call supervisory tone, Radio path acknowlegment : CEPT, ANSI: 425Hz, 200ms ON {400, 0, 0, 1000, 0, 0, 0, 0, 0, 2000, 0, 0, @@ -234,26 +238,26 @@ typedef struct st_tone -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Ring Tone: ANSI (IS-95): 440Hz + 480Hz, 2s ON, 4s OFF... {400, 1200, 0, 35, 0, 0, - -1, -1, -1, -1, 0, 0}, // General beep: 400Hz+1200Hz, 35ms ON + -1, -1, -1, -1, 1, 0}, // General beep: 400Hz+1200Hz, 35ms ON {1200, 0, 0, 100, 0, 0, 0, 0, 0, 100, 0, 0, -1, -1, -1, -1, 2, 0}, //Proprietary tone, positive acknowlegement: 1200Hz, 100ms ON, 100ms OFF 2 bursts {300, 400, 500, 400, 0, 0, - -1, -1, -1, -1, 0, 0}, //Proprietary tone, negative acknowlegement: 300Hz+400Hz+500Hz, 400ms ON + -1, -1, -1, -1, 1, 0}, //Proprietary tone, negative acknowlegement: 300Hz+400Hz+500Hz, 400ms ON {400, 1200, 0, 200, 0, 0, - -1, -1, -1, -1, 0, 0}, //Proprietary tone, prompt tone: 400Hz+1200Hz, 200ms ON + -1, -1, -1, -1, 1, 0}, //Proprietary tone, prompt tone: 400Hz+1200Hz, 200ms ON {400, 1200, 0, 35, 0, 0, 0, 0, 0, 200, 0, 0, 400, 1200, 0, 35, 0, 0, - -1, -1, -1, -1, 0, 0}, //Proprietary tone, general double beep: twice 400Hz+1200Hz, 35ms ON, 200ms OFF, 35ms ON + -1, -1, -1, -1, 1, 0}, //Proprietary tone, general double beep: twice 400Hz+1200Hz, 35ms ON, 200ms OFF, 35ms ON {440, 0, 0, 250, 0, 0, 620, 0, 0, 250, 0, 0, - -1, -1, -1, -1, 0, 0}, //Call supervisory tone (IS-95), intercept tone: alternating 440 Hz and 620 Hz tones, each on for 250 ms + -1, -1, -1, -1, 1, 0}, //Call supervisory tone (IS-95), intercept tone: alternating 440 Hz and 620 Hz tones, each on for 250 ms {440, 0, 0, 250, 0, 0, 620, 0, 0, 250, 0, 0, @@ -284,7 +288,7 @@ typedef struct st_tone {440, 0, 0, 250, 0, 0, 620, 0, 0, 250, 0, 0, - -1, -1, -1, -1, 0, 0 }, //CDMA Abbr Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON + -1, -1, -1, -1, 1, 0 }, //CDMA Abbr Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON {480, 620, 0, 250, 0, 0, 0, 0, 0, 250, 0, 0, @@ -304,10 +308,10 @@ typedef struct st_tone {660, 1000, 0, 500, 0, 0, 0, 0, 0, 100, 0, 0, - -1, -1, -1, -1, 0, 0}, //CDMA answer tone: silent tone - defintion Frequency 0, 0ms ON, 0ms OFF + -1, -1, -1, -1, 1, 0}, //CDMA answer tone: silent tone - defintion Frequency 0, 0ms ON, 0ms OFF {440, 0, 0, 300, 0, 0, - -1, -1, -1, -1, 0, 0}, //CDMA Network Callwaiting tone: 440Hz 300ms ON + -1, -1, -1, -1, 1, 0}, //CDMA Network Callwaiting tone: 440Hz 300ms ON {480, 0, 0, 100, 0, 0, 0, 0, 0, 100, 0, 0, @@ -318,7 +322,7 @@ typedef struct st_tone 2090, 0, 0, 32, 0, 0, 2556, 0, 0, 48, 0, 0, 0, 0, 0, 4000, 0, 0, - -1, -1, -1, -1, 0, 0}, //ISDN Call Signal Normal tone: {2091Hz 32ms ON, 2556 64ms ON} 20 times, 2091 32ms ON, 2556 48ms ON, 4s OFF + -1, -1, -1, -1, 1, 0}, //ISDN Call Signal Normal tone: {2091Hz 32ms ON, 2556 64ms ON} 20 times, 2091 32ms ON, 2556 48ms ON, 4s OFF {2091, 0, 0, 32, 0, 0, 2556, 0, 0, 64, 7, 0, @@ -328,7 +332,7 @@ typedef struct st_tone 2556, 0, 0, 64, 7, 4, 2091, 0, 0, 32, 0, 0, 0, 0, 0, 4000, 0, 0, - -1, -1, -1, -1, 0, 0}, //ISDN Call Signal Intergroup tone: {2091Hz 32ms ON, 2556 64ms ON} 8 times, 2091Hz 32ms ON, 400ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} 8times, 2091Hz 32ms ON, 4s OFF. + -1, -1, -1, -1, 1, 0}, //ISDN Call Signal Intergroup tone: {2091Hz 32ms ON, 2556 64ms ON} 8 times, 2091Hz 32ms ON, 400ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} 8times, 2091Hz 32ms ON, 4s OFF {2091, 0, 0, 32, 0, 0, 2556, 0, 0, 64, 3, 0, @@ -338,24 +342,24 @@ typedef struct st_tone 2556, 0, 0, 64, 3, 4, 2091, 0, 0, 32, 0, 0, 0, 0, 0, 200, 0, 0, - -1, -1, -1, -1, 0, 0},//ISDN Call Signal SP PRI tone:{2091Hz 32ms ON, 2556 64ms ON} 4 times 2091Hz 16ms ON, 200ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} 4 times, 2091Hz 16ms ON, 200ms OFF + -1, -1, -1, -1, 1, 0},//ISDN Call Signal SP PRI tone:{2091Hz 32ms ON, 2556 64ms ON} 4 times 2091Hz 16ms ON, 200ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} 4 times, 2091Hz 16ms ON, 200ms OFF {0, 0, 0, -1, 0, 0, - -1, -1, -1, -1, 0, 0}, //ISDN Call sign PAT3 tone: silent tone + -1, -1, -1, -1, 1, 0}, //ISDN Call sign PAT3 tone: silent tone {2091, 0, 0, 32, 0, 0, 2556, 0, 0, 64, 4, 0, 2091, 0, 0, 20, 0, 0, - -1, -1, -1, -1, 0, 0}, //ISDN Ping Ring tone: {2091Hz 32ms ON, 2556Hz 64ms ON} 5 times 2091Hz 20ms ON + -1, -1, -1, -1, 1, 0}, //ISDN Ping Ring tone: {2091Hz 32ms ON, 2556Hz 64ms ON} 5 times 2091Hz 20ms ON {0, 0, 0, -1, 0, 0, - -1, -1, -1, -1, 0, 0}, //ISDN Pat5 tone: silent tone + -1, -1, -1, -1, 1, 0}, //ISDN Pat5 tone: silent tone {0, 0, 0, -1, 0, 0, - -1, -1, -1, -1, 0, 0}, //ISDN Pat6 tone: silent tone + -1, -1, -1, -1, 1, 0}, //ISDN Pat6 tone: silent tone {0, 0, 0, -1, 0, 0, - -1, -1, -1, -1, 0, 0}, //ISDN Pat7 tone: silent tone + -1, -1, -1, -1, 1, 0}, //ISDN Pat7 tone: silent tone {3700, 0, 0, 25, 0, 0, 4000, 0, 0, 25, 39, 0, @@ -453,7 +457,7 @@ typedef struct st_tone 3700, 0, 0, 25, 0, 0, 4000, 0, 0, 25, 9, 6, 0, 0, 0, 3000, 0, 0, - -1, -1, -1, -1, 0, 0}, //CDMA HIGH SLS tone: {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 3000ms OFF, REPEAT + -1, -1, -1, -1, 0, 0}, //CDMA HIGH SLS tone: {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 3000ms OFF, REPEAT.... {2600, 0, 0, 25, 0, 0, 2900, 0, 0, 25, 9, 0, @@ -464,7 +468,7 @@ typedef struct st_tone 2600, 0, 0, 25, 0, 0, 2900, 0, 0, 25, 9, 6, 0, 0, 0, 3000, 0, 0, - -1, -1, -1, -1, 0, 0}, //CDMA MED SLS tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 3000ms OFF, REPEAT + -1, -1, -1, -1, 0, 0}, //CDMA MED SLS tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 3000ms OFF, REPEAT.... {1300, 0, 0, 25, 0, 0, 1450, 0, 0, 25, 9, 0, @@ -475,7 +479,7 @@ typedef struct st_tone 1300, 0, 0, 25, 0, 0, 1450, 0, 0, 25, 9, 6, 0, 0, 0, 3000, 0, 0, - -1, -1, -1, -1, 0, 0}, //CDMA LOW SLS tone: {1300Hz 25ms, 1450Hz 25ms} 10 times, 500ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, 500ms OFF, {1300Hz 25ms, 1450Hz 25ms} 10 times, 3000ms OFF, REPEAT// + -1, -1, -1, -1, 0, 0}, //CDMA LOW SLS tone: {1300Hz 25ms, 1450Hz 25ms} 10 times, 500ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, 500ms OFF, {1300Hz 25ms, 1450Hz 25ms} 10 times, 3000ms OFF, REPEAT.... {3700, 0, 0, 25, 0, 0, 4000, 0, 0, 25, 9, 0, @@ -653,7 +657,7 @@ typedef struct st_tone 740, 0, 0, 62, 0, 0, 622, 0, 0, 62, 0, 0, 1109, 0, 0, 62, 0, 0, - -1, -1, -1, -1, 0, 0}, //CDMA Alert Network Lite tone: 1109Hz 62ms ON, 784Hz 62ms ON, 740Hz 62ms ON 622Hz 62ms ON, 1109Hz 62ms ON + -1, -1, -1, -1, 1, 0}, //CDMA Alert Network Lite tone: 1109Hz 62ms ON, 784Hz 62ms ON, 740Hz 62ms ON 622Hz 62ms ON, 1109Hz 62ms ON {1245, 0, 0, 62, 0, 0, 659, 0, 0, 62, 0, 0, @@ -662,17 +666,17 @@ typedef struct st_tone 1245, 0, 0, 62, 0, 0, 659, 0, 0, 62, 0, 0, 1245, 0, 0, 62, 0, 0, - -1, -1, -1, -1, 0, 0},//CDMA Alert Auto Redial tone: {1245Hz 62ms ON, 659Hz 62ms ON} 3 times, 1245 62ms ON// + -1, -1, -1, -1, 1, 0},//CDMA Alert Auto Redial tone: {1245Hz 62ms ON, 659Hz 62ms ON} 3 times, 1245 62ms ON// {1150, 770, 0, 400, 0, 0, - -1, -1, -1, -1, 0, 0}, //CDMA One Min Beep tone: 1150Hz+770Hz 400ms ON// + -1, -1, -1, -1, 1, 0}, //CDMA One Min Beep tone: 1150Hz+770Hz 400ms ON// {941, 1477, 0, 120, 0, 0, - -1, -1, -1, -1, 0, 0}, //CDMA KEYPAD Volume key lite tone: 941Hz+1477Hz 120ms ON + -1, -1, -1, -1, 1, 0}, //CDMA KEYPAD Volume key lite tone: 941Hz+1477Hz 120ms ON {587, 0, 0, 375, 0, 0, 1175, 0, 0, 125, 0, 0, - -1, -1, -1, -1, 0, 0}, //CDMA PRESSHOLDKEY LITE tone: 587Hz 375ms ON, 1175Hz 125ms ON + -1, -1, -1, -1, 1, 0}, //CDMA PRESSHOLDKEY LITE tone: 587Hz 375ms ON, 1175Hz 125ms ON {587, 0, 0, 62, 0, 0, 784, 0, 0, 62, 0, 0, @@ -682,7 +686,7 @@ typedef struct st_tone 784, 0, 0, 62, 0, 0, 831, 0, 0, 62, 0, 0, 784, 0, 0, 62, 0, 0, - -1, -1, -1, -1, 0, 0}, //CDMA ALERT INCALL LITE tone: 587Hz 62ms, 784 62ms, 831Hz 62ms, 784Hz 62ms, 1109 62ms, 784Hz 62ms, 831Hz 62ms, 784Hz 62ms + -1, -1, -1, -1, 1, 0}, //CDMA ALERT INCALL LITE tone: 587Hz 62ms, 784 62ms, 831Hz 62ms, 784Hz 62ms, 1109 62ms, 784Hz 62ms, 831Hz 62ms, 784Hz 62ms {941, 0, 0, 125, 0, 0, 0, 0, 0, 10, 0, 0, @@ -699,29 +703,42 @@ typedef struct st_tone {1047, 0, 0, 125, 0, 0, 370, 0, 0, 125, 0, 0, - -1, -1, -1, -1, 0, 0}, //CDMA SOFT ERROR LITE tone: 1047Hz 125ms ON, 370Hz 125ms + -1, -1, -1, -1, 1, 0}, //CDMA SOFT ERROR LITE tone: 1047Hz 125ms ON, 370Hz 125ms {1480, 0, 0, 125, 0, 0, 1397, 0, 0, 125, 0, 0, 784, 0, 0, 125, 0, 0, - -1, -1, -1, -1, 0, 0}, //CDMA CALLDROP LITE tone: 1480Hz 125ms, 1397Hz 125ms, 784Hz 125ms// + -1, -1, -1, -1, 1, 0}, //CDMA CALLDROP LITE tone: 1480Hz 125ms, 1397Hz 125ms, 784Hz 125ms// {425, 0, 0, 125, 0, 0, 0, 0, 0, 125, 0, 0, - -1, -1, -1, -1, 0, 0},//CDMA_NETWORK_BUSY_ONE_SHOT tone: 425Hz 500ms ON, 500ms OFF. + -1, -1, -1, -1, 1, 0},//CDMA_NETWORK_BUSY_ONE_SHOT tone: 425Hz 500ms ON, 500ms OFF {1150, 770, 0, 400, 0, 0, - -1, -1, -1, -1, 0, 0}, //CDMA_ABBR_ALERT tone: 1150Hz+770Hz 400ms ON + -1, -1, -1, -1, 1, 0}, //CDMA_ABBR_ALERT tone: 1150Hz+770Hz 400ms ON {0, 0, 0, -1, 0, 0, - -1, -1, -1, -1, 0, 0}, //CDMA_SIGNAL_OFF - silent tone - }; + -1, -1, -1, -1, 1, 0}, //CDMA_SIGNAL_OFF - silent tone + + {100, 0, 0, -1, 0, 0, + -1, -1, -1, -1, 0, 0}, //100Hz continuous + {200, 0, 0, -1, 0, 0, + -1, -1, -1, -1, 0, 0}, //200Hz continuous + + {300, 0, 0, -1, 0, 0, + -1, -1, -1, -1, 0, 0}, //300Hz continuous +}; + +#if 0 static tone_control_t g_control; -static int (*g_thread_pool_func)(void*, void (*)(void*)) = NULL; +#endif +static int (*g_thread_pool_func)(void*, void (*)(void*)) = NULL; +#if 0 static int _MMSoundToneInit(void); static int _MMSoundToneFini(void); +#endif static void _running_tone(void *param); @@ -744,10 +761,13 @@ int MMSoundPlugCodecToneParse(MMSourceType *source, mmsound_codec_info_t *info) int MMSoundPlugCodecToneCreate(mmsound_codec_param_t *param, mmsound_codec_info_t *info, MMHandleType *handle) { - avsys_audio_param_t audio_param; tone_info_t *toneInfo; + pa_sample_spec ss; + mm_sound_handle_route_info route_info; - int result = AVSYS_STATE_SUCCESS; + int size; + + int result = MM_ERROR_NONE; debug_enter("\n"); @@ -761,29 +781,21 @@ int MMSoundPlugCodecToneCreate(mmsound_codec_param_t *param, mmsound_codec_info_ toneInfo->state = STATE_READY; - /* set audio param */ - memset (&audio_param, 0, sizeof(avsys_audio_param_t)); - - /* Set sound player parameter */ - audio_param.samplerate = SAMPLERATE; - audio_param.channels = CHANNELS; - audio_param.format = AVSYS_AUDIO_FORMAT_16BIT; - audio_param.mode = AVSYS_AUDIO_MODE_OUTPUT; - audio_param.vol_type = param->volume_table; - audio_param.priority = AVSYS_AUDIO_PRIORITY_0; - + ss.rate = SAMPLERATE; + ss.channels = CHANNELS; + ss.format = PA_SAMPLE_S16LE; + route_info.policy = HANDLE_ROUTE_POLICY_OUT_AUTO; - result = avsys_audio_open(&audio_param, &toneInfo->audio_handle, &toneInfo->size); - if(AVSYS_FAIL(result)) { + toneInfo->handle = mm_sound_pa_open(HANDLE_MODE_OUTPUT, &route_info, HANDLE_PRIORITY_NORMAL, param->volume_config, &ss, NULL, &size); + if (!toneInfo->handle) { debug_error("Device Open Error 0x%x\n", result); goto Error; } - debug_log("Create audio_handle is %d\n", toneInfo->audio_handle); - + debug_log("Create audio_handle is %lu\n", toneInfo->handle); debug_msg("tone : %d\n", param->tone); debug_msg("repeat : %d\n", param->repeat_count); - debug_msg("volume table : %d\n", param->volume_table); + debug_msg("volume config : %x\n", param->volume_config); debug_msg("callback : %p\n", param->stop_cb); debug_msg("pid : %d\n", param->pid); @@ -801,16 +813,17 @@ int MMSoundPlugCodecToneCreate(mmsound_codec_param_t *param, mmsound_codec_info_ goto Error; } - *handle = toneInfo; + *handle = (MMHandleType)toneInfo; debug_leave("\n"); return MM_ERROR_NONE; Error: if(toneInfo) { - if(toneInfo->audio_handle) - avsys_audio_close(toneInfo->audio_handle); - + if(toneInfo->handle) { + if(MM_ERROR_NONE != mm_sound_pa_close(toneInfo->handle)) + debug_error("mm_sound_pa_close() fail. handle(%lu)\n", toneInfo->handle); + } free(toneInfo); } @@ -852,18 +865,27 @@ int MMSoundPlugCodecTonePlay(MMHandleType handle) } static char* -_create_tone (double *sample, TONE _TONE, double volume, int *toneSize) +_create_tone(double *sample, TONE _TONE, double volume, int *toneSize, gboolean is_cycle_ended) { short *pbuf; double i = 0; double amplitude, f1, f2, f3; - double volume_factor; int quota= 0; - int DEFAULT_PACKET_INTERVAL = 10; - float low_frequency = _TONE.low_frequency; - float middle_frequency = _TONE.middle_frequency; - float high_frequency = _TONE.high_frequency; + float low_frequency; + float middle_frequency; + float high_frequency; int sample_size = 0; + char* buffer; + + if(is_cycle_ended) { + low_frequency = 0; + middle_frequency = 0; + high_frequency = 0; + } else { + low_frequency = _TONE.low_frequency; + middle_frequency = _TONE.middle_frequency; + high_frequency = _TONE.high_frequency; + } if(sample == NULL) { debug_error("Sample buffer is not allocated\n"); @@ -879,9 +901,10 @@ _create_tone (double *sample, TONE _TONE, double volume, int *toneSize) *toneSize = ((*toneSize+1)>>1)<<1; sample_size = (*toneSize) / (SAMPLE_SIZE / 8); - debug_log("_TONE.playing_time: %d toneSize: %d\n", _TONE.playingTime, *toneSize); - char* buffer = g_malloc (*toneSize); + debug_log("%0.f, %0.f, %0.f _TONE.playing_time: %d toneSize: %d\n", + low_frequency, middle_frequency, high_frequency, _TONE.playingTime, *toneSize); + buffer = g_malloc (*toneSize); if(buffer == NULL) { debug_error("Buffer is not allocated\n"); return NULL; @@ -981,13 +1004,13 @@ _mm_get_CurIndex(TONE _TONE, int *CurArrayPlayCnt, int *CurIndex) } else { (*CurIndex)++; } - debug_log("CurIndex: %d, CurArrayPlayCnt :%d", *CurIndex, *CurArrayPlayCnt); + debug_log("[%d] CurIndex: %d", *CurArrayPlayCnt, *CurIndex); return ret; } static void _running_tone(void *param) { - int result = AVSYS_STATE_SUCCESS; + int result = MM_ERROR_NONE; char *ptoneBuf = NULL; char filename[100]; @@ -1007,6 +1030,7 @@ static void _running_tone(void *param) int waveRestPlayTime = 0; int CurIndex = 0; int CurArrayPlayCnt = 0; + gboolean is_cycle_ended = FALSE; debug_enter("\n"); double sample = 0; @@ -1033,16 +1057,26 @@ static void _running_tone(void *param) debug_error("_mm_get_waveCnt_PlayingTime return value error\n"); goto exit; } + + if(_mm_get_CurIndex(_TONE, &CurArrayPlayCnt, &CurIndex) != MM_ERROR_NONE) { + debug_error("_mm_get_CurIndex return value error\n"); + goto exit; + } + debug_log ("Predefined Tone[%d] Total Play time (ms) : %d, _TONE.playing_time: %d _numWave = %d low_frequency: %0.f, middle_frequency: %0.f, high_frequency: %0.f\n", CurIndex, toneTime, _TONE.playingTime, numWave, _TONE.low_frequency, _TONE.middle_frequency, _TONE.high_frequency); + if (_TONE.low_frequency == -1) { /* skip frequency which's value is -1*/ + if((_TONE.loopCnt > 0) && (CurArrayPlayCnt == _TONE.loopCnt)) { + is_cycle_ended = TRUE; + debug_log("[is_cycle_ended]"); + } CurIndex = _TONE.loopIndx; continue; } /* Write pcm data */ - for(CurWaveIndex = 0; CurWaveIndex < numWave+1; CurWaveIndex++) { if(CurWaveIndex == numWave ) { /* play the last tone set*/ playingTime = waveRestPlayTime; @@ -1059,13 +1093,13 @@ static void _running_tone(void *param) playingTime = toneTime - prePlayingTime; } - ptoneBuf = _create_tone (&sample, _TONE, toneInfo->volume, &toneSize); + ptoneBuf = _create_tone(&sample, _TONE, toneInfo->volume, &toneSize, is_cycle_ended); if(ptoneBuf == NULL) { debug_error("Tone Buffer is not allocated\n"); goto exit; } debug_log ("[TONE] Play.....%dth %dms\n", CurWaveIndex, playingTime); - avsys_audio_write(toneInfo->audio_handle, ptoneBuf, ((toneSize * playingTime /duration + 1)>>1)<<1); + mm_sound_pa_write(toneInfo->handle, ptoneBuf, ((toneSize * playingTime /duration + 1)>>1)<<1); prePlayingTime += playingTime; debug_log ("previous_sum: %d\n", prePlayingTime); g_free (ptoneBuf); @@ -1073,32 +1107,27 @@ static void _running_tone(void *param) if(prePlayingTime == toneTime || toneInfo->state != STATE_PLAY) { debug_log ("Finished.....on Total Playing Time : %d _TONE.playing_time: %d\n", prePlayingTime, _TONE.playingTime); - avsys_audio_drain(toneInfo->audio_handle); + mm_sound_pa_drain(toneInfo->handle); debug_log ("Finished.....quit loop\n"); goto exit; } + debug_log ("[%d] CurIndex: %d previous_sum: %d\n", CurArrayPlayCnt, CurIndex, prePlayingTime); } - if(_mm_get_CurIndex(_TONE, &CurArrayPlayCnt, &CurIndex) != MM_ERROR_NONE) { - debug_error("_mm_get_CurIndex return value error\n"); - goto exit; - } - - debug_log ("CurIndex: %d previous_sum: %d CurArrayPlayCnt: %d\n", CurIndex, prePlayingTime, CurArrayPlayCnt); } exit : - result = avsys_audio_close(toneInfo->audio_handle); - if(AVSYS_FAIL(result)) { - debug_error("Device Close Error 0x%x\n", result); - } + if(MM_ERROR_NONE != mm_sound_pa_close(toneInfo->handle)) + debug_error("mm_sound_pa_close() fail. handle(%lu)\n", toneInfo->handle); +#if 0 pthread_mutex_destroy(&g_control.syncker); +#endif debug_msg("Play end\n"); - toneInfo->state = STATE_STOP; + toneInfo->state = STATE_NONE; if (toneInfo->stop_cb) - toneInfo->stop_cb(toneInfo->cb_param); + toneInfo->stop_cb(toneInfo->cb_param); debug_leave("\n"); } @@ -1111,6 +1140,11 @@ int MMSoundPlugCodecToneStop(MMHandleType handle) debug_enter("(handle %x)\n", handle); toneInfo->state = STATE_STOP; debug_msg("sent stop signal\n"); + + while(toneInfo->state != STATE_NONE) { + usleep(30000); + } + debug_leave("\n"); return MM_ERROR_NONE; @@ -1125,6 +1159,7 @@ int MMSoundPlugCodecToneSetThreadPool(int (*func)(void*, void (*)(void*))) return MM_ERROR_NONE; } +#if 0 static int _MMSoundToneInit(void) { memset(&g_control, 0, sizeof(tone_control_t)); @@ -1137,6 +1172,7 @@ static int _MMSoundToneFini(void) pthread_mutex_destroy(&g_control.syncker); return MM_ERROR_NONE; } +#endif EXPORT_API int MMSoundGetPluginType(void) diff --git a/server/plugin/wav/Makefile.am b/server/plugin/wav/Makefile.am index 7031ace..b2a7110 100644 --- a/server/plugin/wav/Makefile.am +++ b/server/plugin/wav/Makefile.am @@ -6,15 +6,12 @@ libsoundpluginwave_la_CFLAGS = \ $(MMCOMMON_CFLAGS) \ -I$(srcdir)/../../../include \ -I$(srcdir)/../../include \ - $(MMLOGSVR_CFLAGS) -DMMF_LOG_OWNER=0x020 -DMMF_DEBUG_PREFIX=\"MMF-SOUND\" + $(MMLOGSVR_CFLAGS) -DMMF_LOG_OWNER=0x002 -DMMF_DEBUG_PREFIX=\"MMF-SOUND\" libsoundpluginwave_la_LIBADD = $(MMCOMMON_LIBS) \ $(MMLOGSVR_LIBS) \ $(srcdir)/../../../common/libmmfsoundcommon.la -libsoundpluginwave_la_CFLAGS += $(AVSYSTEM_CFLAGS) -libsoundpluginwave_la_LIBADD += $(AVSYSTEM_LIBS) - install-exec-hook: mkdir -p $(DESTDIR)$(libdir)/soundplugins ln -sf /usr/lib/libsoundpluginwave.so $(DESTDIR)$(libdir)/soundplugins/libsoundpluginwave.so diff --git a/server/plugin/wav/mm_sound_plugin_codec_wave.c b/server/plugin/wav/mm_sound_plugin_codec_wave.c index 50f908b..93175d8 100644 --- a/server/plugin/wav/mm_sound_plugin_codec_wave.c +++ b/server/plugin/wav/mm_sound_plugin_codec_wave.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include "../../include/mm_sound.h" #include "../../include/mm_ipc.h" @@ -39,6 +39,7 @@ #define SAMPLE_COUNT 128 +#define WAV_FILE_SAMPLE_PLAY_DURATION 350 /*Unit: ms*/ enum { WAVE_CODE_UNKNOWN = 0, WAVE_CODE_PCM = 1, @@ -57,6 +58,9 @@ enum { #define FMT_CHUNK_ID ((unsigned long) MAKE_FOURCC('f', 'm', 't', ' ')) #define DATA_CHUNK_ID ((unsigned long) MAKE_FOURCC('d', 'a', 't', 'a')) +#define CODEC_WAVE_LOCK(LOCK) do { pthread_mutex_lock(LOCK); } while (0) +#define CODEC_WAVE_UNLOCK(LOCK) do { pthread_mutex_unlock(LOCK); } while (0) + enum { STATE_NONE = 0, STATE_READY, @@ -70,7 +74,7 @@ typedef struct char *ptr_current; int size; int transper_size; - avsys_handle_t audio_handle; + int handle; int period; int tone; int keytone; @@ -79,9 +83,17 @@ typedef struct int cb_param; int state; pthread_mutex_t mutex; + pthread_mutex_t *codec_wave_mutex; + int mode; + int volume_config; + int channels; + int samplerate; + int format; + int handle_route; + int priority; MMSourceType *source; char buffer[48000 / 1000 * SAMPLE_COUNT * 2 *2];//segmentation fault when above 22.05KHz stereo - int handle_route; + int gain, out, in, option; } wave_info_t; static void _runing(void *param); @@ -149,14 +161,14 @@ int MMSoundPlugCodecWaveParse(MMSourceType *source, mmsound_codec_info_t *info) debug_msg("[CODEC WAV] source size :[0x%08X]\n", datalen); priff = (struct __riff_chunk *) data; - + /* Must be checked, Just for wav or not */ if (priff->chunkid != RIFF_CHUNK_ID ||priff->rifftype != RIFF_CHUNK_TYPE) return MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE; - + if(priff->chunksize != datalen -8) priff->chunksize = (datalen-8); - + if (priff->chunkid != RIFF_CHUNK_ID ||priff->chunksize != datalen -8 ||priff->rifftype != RIFF_CHUNK_TYPE) { debug_msg("[CODEC WAV] This contents is not RIFF file\n"); debug_msg("[CODEC WAV] cunkid : %ld, chunksize : %ld, rifftype : 0x%lx\n", priff->chunkid, priff->chunksize, priff->rifftype); @@ -169,7 +181,7 @@ int MMSoundPlugCodecWaveParse(MMSourceType *source, mmsound_codec_info_t *info) tSize = sizeof(struct __riff_chunk); pdata = (struct __data_chunk*)(data+tSize); - + while (pdata->chunkid != FMT_CHUNK_ID && tSize < datalen) { tSize += (pdata->chunkSize+8); @@ -203,16 +215,17 @@ int MMSoundPlugCodecWaveParse(MMSourceType *source, mmsound_codec_info_t *info) return MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE; } else { pdata = (struct __data_chunk*)(data+tSize); - } + } } - + info->codec = MM_SOUND_SUPPORTED_CODEC_WAVE; info->channels = pwav->channels; info->format = pwav->bitspersample; info->samplerate = pwav->samplerate; info->doffset = (tSize+8); info->size = pdata->chunkSize; - debug_msg("info->size:%d\n", info->size); + info->duration = ((info->size)*1000)/pwav->avgbytepersec; + debug_msg("info->size:%d info->duration: %d\n", info->size, info->duration); debug_leave("\n"); return MM_ERROR_NONE; @@ -222,32 +235,17 @@ int MMSoundPlugCodecWaveParse(MMSourceType *source, mmsound_codec_info_t *info) int MMSoundPlugCodecWaveCreate(mmsound_codec_param_t *param, mmsound_codec_info_t *info, MMHandleType *handle) { - int ret = MM_ERROR_NONE; wave_info_t* p = NULL; - - avsys_audio_param_t audio_param; - - static avsys_handle_t keytone_handle = (avsys_handle_t)-1; MMSourceType *source; - static int keytone_period = 0; +#ifdef DEBUG_DETAIL debug_enter("\n"); - debug_msg("[CODEC WAV] Local keytone_period : %d\n", keytone_period); - debug_msg("[CODEC WAV] Local keytone_handle : %d\n", (int)keytone_handle); - - debug_msg("[CODEC WAV] Type %s\n", info->codec == MM_SOUND_SUPPORTED_CODEC_WAVE ? "PCM Wave" : "Unknown"); - debug_msg("[CODEC WAV] channels : %d\n", info->channels); - debug_msg("[CODEC WAV] format : %d\n", info->format); - debug_msg("[CODEC WAV] samplerate : %d\n", info->samplerate); - debug_msg("[CODEC WAV] doffset : %d\n", info->doffset); - - debug_msg("[CODEC WAV] priority : %d\n", param->priority); - debug_msg("[CODEC WAV] repeat : %d\n", param->repeat_count); - debug_msg("[CODEC WAV] volume type : %d\n", param->volume); - debug_msg("[CODEC WAV] callback : %p\n", param->stop_cb); - debug_msg("[CODEC WAV] Keytonemode : %08x\n", param->keytone); - debug_msg("[CODEC WAV] handle route : %d\n", param->handle_route); +#endif + debug_msg("period[%d] type[%s] ch[%d] format[%d] rate[%d] doffset[%d] priority[%d] repeat[%d] volume[%d] callback[%p] keytone[%08x] route[%d]\n", + keytone_period, (info->codec == MM_SOUND_SUPPORTED_CODEC_WAVE) ? "Wave" : "Unknown", + info->channels, info->format, info->samplerate, info->doffset, param->priority, param->repeat_count, + param->volume, param->stop_cb, param->keytone, param->handle_route); source = param->source; @@ -264,7 +262,7 @@ int MMSoundPlugCodecWaveCreate(mmsound_codec_param_t *param, mmsound_codec_info_ } memset(p, 0, sizeof(wave_info_t)); - p->audio_handle = -1; + p->handle = 0; p->ptr_current = MMSourceGetPtr(source) + info->doffset; @@ -276,66 +274,56 @@ int MMSoundPlugCodecWaveCreate(mmsound_codec_param_t *param, mmsound_codec_info_ p->stop_cb = param->stop_cb; p->cb_param = param->param; p->source = source; + p->codec_wave_mutex = param->codec_wave_mutex; // pthread_mutex_init(&p->mutex, NULL); debug_msg("[CODEC WAV] transper_size : %d\n", p->transper_size); debug_msg("[CODEC WAV] size : %d\n", p->size); + if(info->duration < WAV_FILE_SAMPLE_PLAY_DURATION) { + p->mode = HANDLE_MODE_OUTPUT_LOW_LATENCY; + } else { + p->mode = HANDLE_MODE_OUTPUT; + } + + p->priority = param->priority; + p->volume_config = param->volume_config; + p->channels = info->channels; + p->samplerate = info->samplerate; - /* audio param setting */ - memset (&audio_param, 0, sizeof(avsys_audio_param_t)); - audio_param.mode = AVSYS_AUDIO_MODE_OUTPUT; - audio_param.priority = param->priority; - audio_param.vol_type = param->volume_table; - audio_param.channels = info->channels; - audio_param.samplerate = info->samplerate; if(param->handle_route == MM_SOUND_HANDLE_ROUTE_USING_CURRENT) /* normal, solo */ - audio_param.handle_route = AVSYS_AUDIO_HANDLE_ROUTE_FOLLOWING_POLICY; + p->handle_route = HANDLE_ROUTE_POLICY_OUT_AUTO; else /* loud solo */ - audio_param.handle_route = AVSYS_AUDIO_HANDLE_ROUTE_HANDSET_ONLY; - p->handle_route = param->handle_route; + p->handle_route = HANDLE_ROUTE_POLICY_OUT_HANDSET; switch(info->format) { case 8: - audio_param.format = AVSYS_AUDIO_FORMAT_8BIT; + p->format = PA_SAMPLE_U8; break; case 16: - audio_param.format = AVSYS_AUDIO_FORMAT_16BIT; + p->format = PA_SAMPLE_S16LE; break; default: - audio_param.format = AVSYS_AUDIO_FORMAT_16BIT; + p->format = PA_SAMPLE_S16LE; break; } - debug_msg("[CODEC WAV] PARAM mode : [%d]\n", audio_param.mode); - debug_msg("[CODEC WAV] PARAM priority: [%d]\n", audio_param.priority); - debug_msg("[CODEC WAV] PARAM channels : [%d]\n", audio_param.channels); - debug_msg("[CODEC WAV] PARAM samplerate : [%d]\n", audio_param.samplerate); - debug_msg("[CODEC WAV] PARAM format : [%d]\n", audio_param.format); - debug_msg("[CODEC WAV] PARAM volume type : [%d]\n", audio_param.vol_type); - - ret = avsys_audio_open(&audio_param, &p->audio_handle, &p->period); - if (ret != MM_ERROR_NONE) - debug_critical("[CODEC WAV] Can not open audio handle\n"); - - - - if (p->audio_handle == (avsys_handle_t)-1) { - debug_critical("[CODEC WAV] audio_handle is not created !! \n"); - if (p) - free(p); - return MM_ERROR_SOUND_INTERNAL; - } - + debug_msg("[CODEC WAV] PARAM mode : [%d]\n", p->mode); + debug_msg("[CODEC WAV] PARAM channels : [%d]\n", p->channels); + debug_msg("[CODEC WAV] PARAM samplerate : [%d]\n", p->samplerate); + debug_msg("[CODEC WAV] PARAM format : [%d]\n", p->format); + debug_msg("[CODEC WAV] PARAM volume type : [%x]\n", p->volume_config); p->state = STATE_READY; g_thread_pool_func(p, _runing); debug_msg("[CODEC WAV] Thread pool start\n"); - *handle = p; + *handle = (MMHandleType)p; +#ifdef DEBUG_DETAIL debug_leave("\n"); +#endif return MM_ERROR_NONE; } @@ -357,9 +345,7 @@ int MMSoundPlugCodecWavePlay(MMHandleType handle) debug_leave("\n"); return MM_ERROR_NONE; - } - - +} static void _runing(void *param) { @@ -367,15 +353,79 @@ static void _runing(void *param) int nread = 0; char *org_cur = NULL; int org_size = 0; - int stop_size; char *dummy = NULL; int ret; + unsigned int volume_value = 0; + int size; - int gain, out, in, option; - int gain_after, out_after, in_after, option_after; + pa_sample_spec ss; + mm_sound_handle_route_info route_info; + mm_sound_device_in device_in_before = MM_SOUND_DEVICE_IN_NONE; + mm_sound_device_in device_in_after = MM_SOUND_DEVICE_IN_NONE; + mm_sound_device_out device_out_before = MM_SOUND_DEVICE_OUT_NONE; + mm_sound_device_out device_out_after = MM_SOUND_DEVICE_OUT_NONE; + + if (p == NULL) { + debug_error("[CODEC WAV] param is null\n"); + return; + } debug_enter("[CODEC WAV] (Slot ID %d)\n", p->cb_param); + CODEC_WAVE_LOCK(p->codec_wave_mutex); + + /* + * set path here + */ + switch(p->handle_route) + { + case MM_SOUND_HANDLE_ROUTE_SPEAKER: + case MM_SOUND_HANDLE_ROUTE_SPEAKER_NO_RESTORE: + debug_msg("[CODEC WAV] Save backup path\n"); + __mm_sound_lock(); + + /* get route info from pulseaudio */ + /* MMSoundMgrPulseGetActiveDevice(&p->in, &p->out); */ + mm_sound_get_audio_path(&device_in_before, &device_out_before); + /* if current out is not speaker, then force set path to speaker */ + if (device_out_before != MM_SOUND_DEVICE_OUT_SPEAKER) { + debug_msg("[CODEC WAV] current out is not SPEAKER, set path to SPEAKER now!!!\n"); + mm_sound_pa_corkall(1); + mm_sound_set_sound_path_for_active_device(MM_SOUND_DEVICE_OUT_SPEAKER, MM_SOUND_DEVICE_IN_NONE); + } + + /* set route info */ + route_info.device_in = MM_SOUND_DEVICE_IN_NONE; + route_info.device_out = MM_SOUND_DEVICE_OUT_SPEAKER; + route_info.policy = HANDLE_ROUTE_POLICY_OUT_HANDSET; + /* MMSoundMgrPulseSetActiveDevice(route_info_device_in, route_info.device_out); */ + break; + case MM_SOUND_HANDLE_ROUTE_USING_CURRENT: + default: + break; + } + + ss.rate = p->samplerate; + ss.channels = p->channels; + ss.format = p->format; + p->period = pa_sample_size(&ss) * ((ss.rate * 25) / 1000); + p->handle = mm_sound_pa_open(p->mode, &route_info, p->priority, p->volume_config, &ss, NULL, &size); + if(!p->handle) { + debug_critical("[CODEC WAV] Can not open audio handle\n"); + CODEC_WAVE_UNLOCK(p->codec_wave_mutex); + if (p->handle_route == MM_SOUND_HANDLE_ROUTE_SPEAKER || p->handle_route == MM_SOUND_HANDLE_ROUTE_SPEAKER_NO_RESTORE) { + __mm_sound_unlock(); + } + return; + } + + if (p->handle == 0) { + debug_critical("[CODEC WAV] audio_handle is not created !! \n"); + CODEC_WAVE_UNLOCK(p->codec_wave_mutex); + free(p); + p = NULL; + return; + } /* Set the thread schedule */ org_cur = p->ptr_current; @@ -384,35 +434,20 @@ static void _runing(void *param) dummy = malloc(p->period); if(!dummy) { debug_error("[CODEC WAV] not enough memory"); + CODEC_WAVE_UNLOCK(p->codec_wave_mutex); + if (p->handle_route == MM_SOUND_HANDLE_ROUTE_SPEAKER || p->handle_route == MM_SOUND_HANDLE_ROUTE_SPEAKER_NO_RESTORE) { + __mm_sound_unlock(); + } return; } memset(dummy, 0, p->period); p->transper_size = p->period; - stop_size = org_size > p->period ? org_size : p->period; + /* stop_size = org_size > p->period ? org_size : p->period; */ debug_msg("[CODEC WAV] Wait start signal\n"); - while(p->state == STATE_READY) + while(p->state == STATE_READY) { usleep(4); - - /* - * set path here - */ - switch(p->handle_route) - { - case MM_SOUND_HANDLE_ROUTE_SPEAKER: - debug_msg("[CODEC WAV] Save backup path\n"); - avsys_audio_get_path_ex(&gain, &out, &in, &option); - - /* if current out is not speaker, then force set path to speaker */ - if (out != AVSYS_AUDIO_PATH_EX_SPK) { - debug_msg("[CODEC WAV] current out is not SPEAKER, set path to SPEAKER now!!!\n"); - avsys_audio_set_path_ex(AVSYS_AUDIO_GAIN_EX_AUDIOPLAYER, AVSYS_AUDIO_PATH_EX_SPK, AVSYS_AUDIO_PATH_EX_NONE, AVSYS_AUDIO_PATH_OPTION_NONE); - } - break; - case MM_SOUND_HANDLE_ROUTE_USING_CURRENT: - default: - break; } debug_msg("[CODEC WAV] Recv start signal\n"); @@ -431,7 +466,7 @@ static void _runing(void *param) if (p->size >= p->transper_size) { nread = p->transper_size; memcpy(p->buffer, p->ptr_current, nread); - avsys_audio_write(p->audio_handle, p->buffer, nread); + mm_sound_pa_write(p->handle, p->buffer, nread); p->ptr_current += nread; p->size -= nread; debug_msg("[CODEC WAV] Playing, nRead_data : %d Size : %d \n", nread, p->size); @@ -439,10 +474,8 @@ static void _runing(void *param) /* Write remain size */ nread = p->size; memcpy(p->buffer, p->ptr_current, nread); - avsys_audio_write(p->audio_handle, p->buffer, nread); - avsys_audio_write(p->audio_handle, dummy, (p->transper_size-nread)); - //avsys_audio_drain(p->audio_handle); - //debug_error("Drain is called\n"); + mm_sound_pa_write(p->handle, p->buffer, nread); + mm_sound_pa_write(p->handle, dummy, (p->transper_size-nread)); p->ptr_current += nread; p->size = 0; } @@ -454,45 +487,40 @@ static void _runing(void *param) debug_msg("[CODEC WAV] End playing\n"); p->state = STATE_STOP; - if (p->audio_handle == -1) { + if (p->handle == 0) { usleep(200000); debug_warning("[CODEC WAV] audio already unrealize !!\n"); } else { - //usleep(75000); + /* usleep(75000); */ + if(MM_ERROR_NONE != mm_sound_pa_drain(p->handle)) + debug_error("mm_sound_pa_drain() failed\n"); - if(AVSYS_FAIL(avsys_audio_drain(p->audio_handle))) - { - debug_error("avsys_audio_drain() failed\n"); + if(MM_ERROR_NONE != mm_sound_pa_close(p->handle)) { + debug_error("[CODEC WAV] Can not close audio handle\n"); + } else { + p->handle = 0; } - /* * Restore path here */ if (p->handle_route == MM_SOUND_HANDLE_ROUTE_SPEAKER) { - avsys_audio_get_path_ex(&gain_after, &out_after, &in_after, &option_after); - /* If current path is not same as before playing sound, restore the sound path */ - if (gain_after != gain || out_after != out || in_after != in || option_after != option) { - - debug_msg("[CODEC WAV] Restore path to previous one\n"); - ret = avsys_audio_set_path_ex(gain, out, in, option); - if(AVSYS_FAIL(ret)) { - debug_error("[CODEC WAV] Can not restore sound path\n"); - } + if (device_out_before != MM_SOUND_DEVICE_OUT_SPEAKER) { + mm_sound_set_sound_path_for_active_device(device_out_before, device_in_before); + mm_sound_pa_corkall(0); } } - - ret = avsys_audio_close(p->audio_handle); - if (AVSYS_FAIL(ret)) { - debug_critical("[CODEC WAV] Can not close audio handle\n"); + if (p->handle_route == MM_SOUND_HANDLE_ROUTE_SPEAKER || p->handle_route == MM_SOUND_HANDLE_ROUTE_SPEAKER_NO_RESTORE) { + __mm_sound_unlock(); } - } - p->audio_handle = -1; + CODEC_WAVE_UNLOCK(p->codec_wave_mutex); + + p->handle = 0; p->state = STATE_NONE; - free(dummy); + free(dummy); dummy = NULL; if (p->stop_cb) { debug_msg("[CODEC WAV] Play is finished, Now start callback\n"); @@ -505,8 +533,9 @@ static void _runing(void *param) int MMSoundPlugCodecWaveStop(MMHandleType handle) { wave_info_t *p = (wave_info_t*) handle; + if (!p) { - debug_error("The handle is NULL\n"); + debug_error("The handle is null\n"); return MM_ERROR_SOUND_INTERNAL; } debug_msg("[CODEC WAV] Current state is state %d\n", p->state); @@ -521,17 +550,17 @@ int MMSoundPlugCodecWaveDestroy(MMHandleType handle) { wave_info_t *p = (wave_info_t*) handle; - if(!p) { - debug_warning("Can not destroy handle :: handle is null\n"); + if (!p) { + debug_warning("Can not destroy handle :: handle is invalid"); return MM_ERROR_SOUND_INVALID_POINTER; } if(p->source) { mm_source_close(p->source); - free(p->source); + free(p->source); p->source = NULL; } - free(p); + free(p); p = NULL; return MM_ERROR_NONE; } diff --git a/server/sounds/Tizen_HW_Touch.ogg b/server/sounds/Tizen_HW_Touch.ogg new file mode 100644 index 0000000..acab434 Binary files /dev/null and b/server/sounds/Tizen_HW_Touch.ogg differ diff --git a/server/sounds/dock.ogg b/server/sounds/dock.ogg new file mode 100644 index 0000000..fed42e5 Binary files /dev/null and b/server/sounds/dock.ogg differ diff --git a/server/sounds/undock.ogg b/server/sounds/undock.ogg new file mode 100644 index 0000000..5cb2f2c Binary files /dev/null and b/server/sounds/undock.ogg differ diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index 570a14d..adb2202 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -4,7 +4,6 @@ mm_sound_testsuite_SOURCES = mm_sound_testsuite_simple.c mm_sound_testsuite_CFLAGS = $(MMCOMMON_CFLAGS) \ -I$(srcdir)/../include \ - $(AVSYSTEM_CFLAGS) \ $(ALSA_CFLAGS) \ $(VCONF_CFLAGS) \ $(AUDIOSESSIONMGR_CFLAGS) \ @@ -12,10 +11,9 @@ mm_sound_testsuite_CFLAGS = $(MMCOMMON_CFLAGS) \ mm_sound_testsuite_DEPENDENCIES = $(srcdir)/../.libs/libmmfsound.la \ $(srcdir)/../.libs/libmmfkeysound.la - +mm_sound_testsuite_CFLAGS += -fPIC -pie mm_sound_testsuite_LDADD = $(MMCOMMON_LIBS) \ $(MMSESSION_LIBS) \ - $(AVSYSTEM_LIBS) \ $(VCONF_LIBS) \ $(AUDIOSESSIONMGR_LIBS) \ $(srcdir)/../.libs/libmmfsound.la \ diff --git a/testsuite/mm_sound_testsuite_simple.c b/testsuite/mm_sound_testsuite_simple.c index 8d24e3f..3cd81ec 100644 --- a/testsuite/mm_sound_testsuite_simple.c +++ b/testsuite/mm_sound_testsuite_simple.c @@ -24,12 +24,14 @@ #include #define debug_log(msg, args...) fprintf(stderr, msg, ##args) -#define avsys_info(msg, args...) fprintf(stderr, msg, ##args) +#define debug_error(msg, args...) fprintf(stderr, msg, ##args) #define MAX_STRING_LEN 256 #define MAX_PATH_LEN 1024 #define MIN_TONE_PLAY_TIME 300 #include "../include/mm_sound.h" +#include "../include/mm_sound_common.h" #include "../include/mm_sound_private.h" +#include "../include/mm_sound_pa_client.h" #include @@ -43,7 +45,8 @@ #include #include -#define POWERON_FILE "/usr/share/keysound/poweron.wav" +#define POWERON_FILE "/usr/share/feedback/sound/operation/power_on.wav" +#define KEYTONE_FILE "/opt/usr/share/settings/Previews/touch.wav" // For testsuite status @@ -72,21 +75,89 @@ gboolean timeout_menu_display(void *data); gboolean timeout_quit_program(void *data); gboolean input (GIOChannel *channel); +static char* __get_playback_device_str (mm_sound_device_out out); +static char* __get_capture_device_str (mm_sound_device_in in); +static char* __get_route_str (mm_sound_route route); +static int __mm_sound_foreach_available_route_cb (mm_sound_route route, void *user_data); +static void __mm_sound_available_route_changed_cb (mm_sound_route route, bool available, void *user_data); +static void __mm_sound_active_device_changed_cb (mm_sound_device_in device_in, mm_sound_device_out device_out, void *user_data); -void mycallback(void *data) +void mycallback(void *data, int id) { char *str = (char*)data; if(data != NULL) - debug_log("mycallback called (user data:%s)\n", str); + debug_log("mycallback called (user data:%s ,id:%d)\n", str, id); else debug_log("mycallback called (no user data)\n"); } volatile char test_callback_done; -void test_callback(void *data) +void test_callback(void *data, int id) { debug_log("test_callback is called\n"); test_callback_done = 1; } +void device_connected_cb (MMSoundDevice_t device_h, bool is_connected, void *user_data) +{ + int ret = 0; + int type = 0; + int io_direction = 0; + int state = 0; + int id = 0; + char *name = NULL; + debug_log("*** device_connected_cb is called, device_h[0x%x], is_connected[%d], user_date[0x%x]\n", device_h, is_connected, user_data); + ret = mm_sound_get_device_type(device_h, &type); + if (ret) { + debug_error("failed to mm_sound_get_device_type()\n"); + } + ret = mm_sound_get_device_io_direction(device_h, &io_direction); + if (ret) { + debug_error("failed to mm_sound_get_device_io_direction()\n"); + } + ret = mm_sound_get_device_state(device_h, &state); + if (ret) { + debug_error("failed to mm_sound_get_device_state()\n"); + } + ret = mm_sound_get_device_id(device_h, &id); + if (ret) { + debug_error("failed to mm_sound_get_device_id()\n"); + } + ret = mm_sound_get_device_name(device_h, &name); + if (ret) { + debug_error("failed to mm_sound_get_device_name()\n"); + } + debug_log("*** --- type[%d], id[%d], io_direction[%d], state[%d], name[%s]\n", type, id, io_direction, state, name); +} +void device_info_changed_cb (MMSoundDevice_t device_h, int changed_info_type, void *user_data) +{ + int ret = 0; + int type = 0; + int io_direction = 0; + int state = 0; + int id = 0; + char *name = NULL; + debug_log("*** device_info_changed_cb is called, device_h[0x%x], changed_info_type[%d], user_date[0x%x]\n", device_h, changed_info_type, user_data); + ret = mm_sound_get_device_type(device_h, &type); + if (ret) { + debug_error("failed to mm_sound_get_device_type()\n"); + } + ret = mm_sound_get_device_io_direction(device_h, &io_direction); + if (ret) { + debug_error("failed to mm_sound_get_device_io_direction()\n"); + } + ret = mm_sound_get_device_state(device_h, &state); + if (ret) { + debug_error("failed to mm_sound_get_device_state()\n"); + } + ret = mm_sound_get_device_id(device_h, &id); + if (ret) { + debug_error("failed to mm_sound_get_device_id()\n"); + } + ret = mm_sound_get_device_name(device_h, &name); + if (ret) { + debug_error("failed to mm_sound_get_device_name()\n"); + } + debug_log("*** --- type[%d], id[%d], io_direction[%d], state[%d], name[%s]\n", type, id, io_direction, state, name); +} void quit_program() { g_main_loop_quit(g_loop); @@ -99,10 +170,10 @@ static void displaymenu() g_print(" Sound Path APIs\n"); g_print("==================================================================\n"); g_print("1. Play speaker \t"); - g_print("2. Play headset \t"); - g_print("3. Play auto \n"); + g_print("2. Play headset \n"); + g_print("3. (blank) \n"); g_print("4. Rec. with mic \t"); - g_print("5. Rec. auto \t"); + g_print("5. (blank) \t"); g_print("6. Call receiver \n"); g_print("7. Call end \t"); g_print("8. VT call speaker \t"); @@ -126,22 +197,40 @@ static void displaymenu() g_print("r : Get system \t"); g_print("t : Inc. system \t"); g_print("y : Dec. system \n"); + g_print("g : Get voice \t"); + g_print("h : Inc. voice \t"); + g_print("j : Dec. voice \n"); + g_print("B : Set audio balance\n"); + g_print("M : Set mute all\n"); g_print("==================================================================\n"); g_print(" Audio route APIs\n"); g_print("==================================================================\n"); - g_print("u : Ignore a2dp \t"); - g_print("i : Default \t"); - g_print("o : Get Route \n"); - g_print("O : Get Playing device\t"); - g_print("p : Is BT Avail \n"); + g_print("u : Foreach Available Routes \t"); + g_print("i : Get Active Devices \n"); + g_print("o : Add Available Routes Callback \t"); + g_print("O : Remove Available Routes Callback \n"); + g_print("p : Add Active Route Callback\t"); + g_print("P : Remove Active Route Callback \n"); + g_print("{ : Get BT A2DP Status\n"); + g_print("} : Set Active Route\n"); g_print("==================================================================\n"); g_print(" Session Test\n"); g_print("==================================================================\n"); g_print("z : Call start \t"); g_print("Z : VideoCall start \t"); - g_print("v : Call/VideoCall end \t"); + g_print("N : Notification start \n"); + g_print("n : VOIP start \t"); + g_print("v : Session end \t"); g_print("V : Current Status \n"); g_print("==================================================================\n"); + g_print(" Audio device APIs\n"); + g_print("==================================================================\n"); + g_print("L : Get current list of connected devices \n"); + g_print("C : Add device connected callback \t"); + g_print("D : Remove device connected callback \n"); + g_print("Q : Add device info. changed callback \t"); + g_print("W : Remove device info. changed callback \n"); + g_print("==================================================================\n"); g_print("d : Input Directory \t"); g_print("f : Input File name \t"); g_print("x : Exit Program \n"); @@ -187,29 +276,96 @@ gboolean input (GIOChannel *channel) static void input_filename(char *filename) { - strncpy(g_file_name, filename, sizeof(g_file_name)-1); + MMSOUND_STRNCPY(g_file_name, filename, MAX_STRING_LEN); g_print("\nThe input filename is '%s' \n\n",g_file_name); } static void input_dirname(char *dirname) { - strncpy(g_dir_name, dirname, sizeof(g_dir_name)-1); + MMSOUND_STRNCPY(g_dir_name, dirname, MAX_PATH_LEN); g_print("\nThe input directory is '%s' \n\n",g_dir_name); } +static char* __get_playback_device_str (mm_sound_device_out out) +{ + switch (out) { + case MM_SOUND_DEVICE_OUT_SPEAKER: return "SPEAKER"; + case MM_SOUND_DEVICE_OUT_RECEIVER: return "RECEIVER"; + case MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY: return "HEADSET"; + case MM_SOUND_DEVICE_OUT_BT_SCO: return "BTSCO"; + case MM_SOUND_DEVICE_OUT_BT_A2DP: return "BTA2DP"; + case MM_SOUND_DEVICE_OUT_DOCK: return "DOCK"; + case MM_SOUND_DEVICE_OUT_HDMI: return "HDMI"; + case MM_SOUND_DEVICE_OUT_MIRRORING: return "MIRRORING"; + case MM_SOUND_DEVICE_OUT_USB_AUDIO: return "USB"; + case MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK: return "MULTIMEDIA_DOCK"; + default: return NULL; + } +} + +static char* __get_capture_device_str (mm_sound_device_in in) +{ + switch (in) { + case MM_SOUND_DEVICE_IN_MIC: return "MAINMIC"; + case MM_SOUND_DEVICE_IN_WIRED_ACCESSORY: return "HEADSET"; + case MM_SOUND_DEVICE_IN_BT_SCO: return "BTMIC"; + default: return NULL; + } +} + +static char* __get_route_str (mm_sound_route route) +{ + switch (route) { + case MM_SOUND_ROUTE_OUT_SPEAKER: return "OUT_SPEAKER"; + case MM_SOUND_ROUTE_OUT_RECEIVER: return "OUT_RECEIVER"; + case MM_SOUND_ROUTE_OUT_WIRED_ACCESSORY: return "OUT_WIRED_ACCESSORY"; + case MM_SOUND_ROUTE_OUT_BLUETOOTH_A2DP: return "OUT_BLUETOOTH_A2DP"; + case MM_SOUND_ROUTE_OUT_DOCK: return "OUT_DOCK"; + case MM_SOUND_ROUTE_OUT_HDMI: return "OUT_HDMI"; + case MM_SOUND_ROUTE_OUT_MIRRORING: return "OUT_MIRRORING"; + case MM_SOUND_ROUTE_OUT_USB_AUDIO: return "OUT_USB"; + case MM_SOUND_ROUTE_OUT_MULTIMEDIA_DOCK: return "OUT_MULTIMEDIA_DOCK"; + case MM_SOUND_ROUTE_IN_MIC: return "IN_MIC"; + case MM_SOUND_ROUTE_IN_WIRED_ACCESSORY: return "IN_WIRED_ACCESSORY"; + case MM_SOUND_ROUTE_IN_MIC_OUT_RECEIVER: return "IN_MIC_OUT_RECEIVER"; + case MM_SOUND_ROUTE_IN_MIC_OUT_SPEAKER: return "IN_MIC_OUT_SPEAKER"; + case MM_SOUND_ROUTE_IN_MIC_OUT_HEADPHONE: return "IN_MIC_OUT_HEADPHONE"; + case MM_SOUND_ROUTE_INOUT_HEADSET: return "INOUT_HEADSET"; + case MM_SOUND_ROUTE_INOUT_BLUETOOTH: return "INOUT_BLUETOOTH"; + default: return NULL; + } +} + +static int __mm_sound_foreach_available_route_cb (mm_sound_route route, void *user_data) +{ + g_print ("[%s] route = [0x%08x][%s]\n", __func__, route, __get_route_str(route)); + return true; +} + +static void __mm_sound_available_route_changed_cb (mm_sound_route route, bool available, void *user_data) +{ + g_print ("[%s] route = [%d][0x%08x][%s]\n", __func__, available, route, __get_route_str(route)); +} + +static void __mm_sound_active_device_changed_cb (mm_sound_device_in device_in, mm_sound_device_out device_out, void *user_data) +{ + g_print ("[%s] in[0x%08x][%s], out[0x%08x][%s]\n", __func__, + device_in, __get_capture_device_str(device_in), device_out, __get_playback_device_str(device_out)); +} + static void interpret (char *cmd) { int ret=0; static int handle = -1; - MMSoundParamType soundparam = {0,}; + MMSoundPlayParam soundparam = {0,}; switch (g_menu_state) { case CURRENT_STATUS_MAINMENU: if(strncmp(cmd, "k", 1) == 0) { - ret = mm_sound_play_keysound(POWERON_FILE, 8); + ret = mm_sound_play_keysound(KEYTONE_FILE, 8); if(ret < 0) debug_log("keysound play failed with 0x%x\n", ret); } @@ -319,6 +475,116 @@ static void interpret (char *cmd) } } } + else if(strncmp(cmd, "g", 1) == 0) + {//get voice volume + unsigned int value = 100; + ret = mm_sound_volume_get_value(VOLUME_TYPE_VOICE, &value); + if(ret < 0) { + debug_log("mm_sound_volume_get_value 0x%x\n", ret); + } + else{ + g_print("*** VOICE VOLUME : %u ***\n", value); + g_volume_value = value; + } + } + else if(strncmp(cmd, "h", 1) == 0) + {//set voice volume up + unsigned int value = 100; + ret = mm_sound_volume_get_value(VOLUME_TYPE_VOICE, &value); + if(ret < 0) { + debug_log("mm_sound_volume_get_value 0x%x\n", ret); + } + else { + debug_log("Loaded voice volume is %d\n", value); + int step; + value++; + mm_sound_volume_get_step(VOLUME_TYPE_VOICE, &step); + if(value >= step) { + value = step-1; + } + ret = mm_sound_volume_set_value(VOLUME_TYPE_VOICE, value); + if(ret < 0) { + debug_log("mm_sound_volume_set_value 0x%x\n", ret); + }else { + g_print("Current Voice volume is %d\n", value); + } + } + } + else if(strncmp(cmd, "j", 1) == 0) + {//set voice volume down + unsigned int value = 100; + ret = mm_sound_volume_get_value(VOLUME_TYPE_VOICE, &value); + if(ret < 0) { + debug_log("mm_sound_volume_get_value 0x%x\n", ret); + } + else { + if(value != 0) { + value--; + } + + ret = mm_sound_volume_set_value(VOLUME_TYPE_VOICE, value); + if(ret < 0) { + debug_log("mm_sound_volume_set_value 0x%x\n", ret); + }else { + g_print("Current Voice volume is %d\n", value); + } + } + } + + else if(strncmp(cmd, "B", 1) == 0) + { + int ret = 0; + char input_string[128]; + float balance; + + fflush(stdin); + ret = mm_sound_volume_get_balance(&balance); + if (ret == MM_ERROR_NONE) { + g_print ("### mm_sound_volume_get_balance Success, balance=%f\n", balance); + } else { + g_print ("### mm_sound_volume_get_balance Error = %x\n", ret); + } + g_print("> Enter new audio balance (current is %f) : ", balance); + if (fgets(input_string, sizeof(input_string)-1, stdin) == NULL) { + g_print ("### fgets return NULL\n"); + } + + balance = atof (input_string); + ret = mm_sound_volume_set_balance(balance); + if (ret == MM_ERROR_NONE) { + g_print ("### mm_sound_volume_set_balance(%f) Success\n", balance); + } else { + g_print ("### mm_sound_volume_set_balance(%f) Error = %x\n", balance, ret); + } + } + + else if(strncmp(cmd, "M", 1) == 0) + { + int ret = 0; + char input_string[128]; + int muteall; + + fflush(stdin); + ret = mm_sound_get_muteall(&muteall); + if (ret == MM_ERROR_NONE) { + g_print ("### mm_sound_get_muteall Success, muteall=%d\n", muteall); + } else { + g_print ("### mm_sound_get_muteall Error = %x\n", ret); + } + g_print("> Enter new muteall state (current is %d) : ", muteall); + if (fgets(input_string, sizeof(input_string)-1, stdin) == NULL) { + g_print ("### fgets return NULL\n"); + } + + muteall = atoi (input_string); + ret = mm_sound_set_muteall(muteall); + if (ret == MM_ERROR_NONE) { + g_print ("### mm_sound_set_muteall(%d) Success\n", muteall); + } else { + g_print ("### mm_sound_set_muteall(%d) Error = %x\n", muteall, ret); + } + } + else if(strncmp(cmd, "a", 1) == 0) { debug_log("volume is %d type, %d\n", g_volume_type, g_volume_value); @@ -341,12 +607,15 @@ static void interpret (char *cmd) int tonetime=0; double volume=1.0; int volume_type = -1; + bool enable_session = 0; MMSoundTone_t tone = MM_SOUND_TONE_DTMF_0; while(num != 'q') { fflush(stdin); - g_print("enter number(0~H exit:q), volume type(0~7), volume(0.0~1.0), time(ms):\t "); - fgets(input_string, sizeof(input_string)-1, stdin); + g_print("enter number(0~H exit:q), volume type(0~7), volume(0.0~1.0), time(ms), enable_session(0:unable , 1:enable):\t "); + if (fgets(input_string, sizeof(input_string)-1, stdin) == NULL) { + g_print ("### fgets return NULL\n"); + } tok = strtok(input_string, " "); if(!tok) continue; if(tok[0] == 'q') { @@ -424,9 +693,9 @@ static void interpret (char *cmd) else if(num == 'x') { tone =MM_SOUND_TONE_CDMA_ALERT_CALL_GUARD; } else if(num == 'y') { tone =MM_SOUND_TONE_CDMA_SOFT_ERROR_LITE; } else if(num == 'z') { tone =MM_SOUND_TONE_CDMA_CALLDROP_LITE; } - else if(num == '{') { tone =MM_SOUND_TONE_CDMA_NETWORK_BUSY_ONE_SHOT; } - else if(num == '}') { tone =MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING; } - else if(num == '~') { tone =MM_SOUND_TONE_CDMA_SIGNAL_OFF; } + else if(num == '{') { tone =MM_SOUND_TONE_LOW_FRE; } + else if(num == '}') { tone =MM_SOUND_TONE_MED_FRE; } + else if(num == '~') { tone =MM_SOUND_TONE_HIGH_FRE; } tok = strtok(NULL, " "); if(tok) volume_type = (double)atoi(tok); @@ -443,8 +712,11 @@ static void interpret (char *cmd) tonetime = MIN_TONE_PLAY_TIME; } - debug_log("volume type: %d\t volume is %f\t tonetime: %d \n", volume_type, volume, tonetime); - ret = mm_sound_play_tone(tone, volume_type, volume, tonetime, &handle); + tok = strtok(NULL, " "); + if(tok) enable_session = (bool)atof(tok); + + debug_log("volume type: %d\t volume is %f\t tonetime: %d\t enable_session %d \n", volume_type, volume, tonetime, enable_session); + ret = mm_sound_play_tone_ex(tone, volume_type, volume, tonetime, &handle, enable_session); if(ret<0) debug_log ("[magpie] Play DTMF sound cannot be played ! %d\n", handle); } @@ -474,7 +746,9 @@ static void interpret (char *cmd) snprintf(fullpath, sizeof(fullpath)-1,"%s/%s", g_dir_name, entry->d_name); debug_log("Try %s\n", fullpath); - lstat(fullpath, &file_stat); + if (lstat(fullpath, &file_stat) == -1) + continue; + if(S_ISREG(file_stat.st_mode)) { test_callback_done = 0 ; @@ -528,7 +802,7 @@ static void interpret (char *cmd) soundparam.mem_ptr = NULL; soundparam.mem_size = 0; soundparam.filename = g_file_name; - soundparam.volume_table = g_volume_type; + soundparam.volume_config = g_volume_type; if ((mm_sound_play_sound_ex (&soundparam, &handle))<0) debug_log ("Play EX sound cannot be played !\n"); @@ -548,100 +822,194 @@ static void interpret (char *cmd) } else if (strncmp (cmd, "1",1) == 0) { //ap to spk - if (mm_sound_set_path (MM_SOUND_GAIN_KEYTONE, MM_SOUND_PATH_SPK, MM_SOUND_PATH_NONE, MM_SOUND_PATH_OPTION_NONE)<0) - debug_log ("Fail to set sound path !!!\n"); - g_print("Set path for speaker playback\n"); + g_print("Not supported - Set path for speaker playback\n"); } else if (strncmp (cmd, "2",1) == 0) { //ap to headset - if (mm_sound_set_path(MM_SOUND_GAIN_KEYTONE, MM_SOUND_PATH_HEADSET, MM_SOUND_PATH_NONE, MM_SOUND_PATH_OPTION_NONE)<0) - debug_log ("Fail to set sound path !!!\n"); - g_print("Set path for headset playback\n"); + g_print("Not supported - Set path for headset playback\n"); } else if (strncmp (cmd, "3",1) == 0) { - //dual out + } else if (strncmp (cmd, "4",1) == 0) { //recording - if (mm_sound_set_path(MM_SOUND_GAIN_VOICEREC, MM_SOUND_PATH_NONE, MM_SOUND_PATH_MIC, MM_SOUND_PATH_OPTION_NONE)<0) - debug_log ("Fail to set sound path !!!\n"); - g_print("Set path for recording with main mic\n"); + g_print("Not supported - Set path for recording with main mic\n"); } else if (strncmp (cmd, "5",1) == 0) { - //record release + } else if (strncmp (cmd, "6",1) == 0) { //voice call - if (mm_sound_set_path(MM_SOUND_GAIN_VOICECALL, MM_SOUND_PATH_RECV, MM_SOUND_PATH_MIC, MM_SOUND_PATH_OPTION_NONE)<0) - debug_log ("Fail to set sound path !!!\n"); - g_print("Set path for voicecall\n"); + g_print("Not supported - Set path for voicecall\n"); } else if (strncmp (cmd, "7",1) == 0) { //voicecall release - if (mm_sound_set_path(MM_SOUND_GAIN_VOICECALL, MM_SOUND_PATH_NONE, MM_SOUND_PATH_NONE, MM_SOUND_PATH_OPTION_NONE)<0) - debug_log ("Fail to set sound path !!!\n"); - g_print("release path for voicecall\n"); + g_print("Not supported - release path for voicecall\n"); } else if (strncmp (cmd, "8",1) == 0) { //voice call - if (mm_sound_set_path(MM_SOUND_GAIN_VIDEOCALL, MM_SOUND_PATH_SPK, MM_SOUND_PATH_MIC, MM_SOUND_PATH_OPTION_NONE)<0) - debug_log ("Fail to set sound path !!!\n"); - g_print("Set path for VT call\n"); + g_print("Not supported - Set path for VT call\n"); } else if (strncmp (cmd, "9",1) == 0) { //voicecall release - if (mm_sound_set_path(MM_SOUND_GAIN_VIDEOCALL, MM_SOUND_PATH_NONE, MM_SOUND_PATH_NONE, MM_SOUND_PATH_OPTION_NONE)<0) - debug_log ("[magpie] Fail to set sound path !!!\n"); - g_print("release path for VT call\n"); + g_print("Not supported - release path for VT call\n"); } - else if (strncmp(cmd, "o", 1) == 0) { - char *str_route[SYSTEM_AUDIO_ROUTE_POLICY_MAX] = { - "DEFAULT","IGN_A2DP","HANDSET" - }; - system_audio_route_t route; - int ret = mm_sound_route_get_system_policy(&route); - g_print ("### Current Audio Route = [%s], mm_sound_get_audio_route () returns [%d]\n", str_route[route], ret); - } - else if (strncmp(cmd, "O", 1) == 0) { - char *str_dev[SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_MAX] = { -#if defined(_REVIEW_API_UPDATE_001) - "None","Handset(Speaker)","Bluetooth", "earphone" -#else - "None","Handset","Bluetooth" + /* -------------------------- Route Test : Starts -------------------------- */ +#if 0 + g_print("==================================================================\n"); + g_print(" Audio route APIs\n"); + g_print("==================================================================\n"); + g_print("u : Foreach Available Routes \t"); + g_print("i : Get Active Devices \n"); + g_print("o : Add Available Routes Callback \t"); + g_print("O : Remove Available Routes Callback \n"); + g_print("p : Add Active Route Callback\t"); + g_print("P : Remove Active Route Callback \n"); + g_print("{ : Get BT A2DP Status\n"); #endif - }; - system_audio_route_device_t dev = 0; - int ret = mm_sound_route_get_playing_device(&dev); - g_print ("### Current Audio Device = [%s], mm_sound_route_get_playing_device () returns [%d]\n", str_dev[dev], ret); - } else if (strncmp(cmd, "u", 1) == 0) { - g_print ("### Set Audio Route to Ignore a2dp, mm_sound_route_set_system_policy () returns [%d]\n", - mm_sound_route_set_system_policy(SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP)); + int ret = 0; + ret = mm_sound_foreach_available_route_cb(__mm_sound_foreach_available_route_cb, NULL); + if (ret == MM_ERROR_NONE) { + g_print ("### mm_sound_foreach_available_route_cb() Success\n\n"); + } else { + g_print ("### mm_sound_foreach_available_route_cb() Error : errno [%x]\n\n", ret); + } } - else if (strncmp(cmd, "i", 1) == 0) { - g_print ("### Set Audio Route to Default, mm_sound_route_set_system_policy () returns [%d]\n", - mm_sound_route_set_system_policy(SYSTEM_AUDIO_ROUTE_POLICY_DEFAULT)); + int ret = 0; + mm_sound_device_in in = MM_SOUND_DEVICE_IN_NONE; + mm_sound_device_out out = MM_SOUND_DEVICE_OUT_NONE; + ret = mm_sound_get_active_device(&in, &out); + if (ret == MM_ERROR_NONE) { + g_print ("### mm_sound_get_active_device() Success : in[0x%08x][%s], out[0x%08x][%s]\n\n", + in, __get_capture_device_str(in), out, __get_playback_device_str(out)); + } else { + g_print ("### mm_sound_get_active_device() Error : errno [%x]\n\n", ret); + } + } + else if (strncmp(cmd, "o", 1) == 0) { + int ret = 0; + ret = mm_sound_add_available_route_changed_callback(__mm_sound_available_route_changed_cb, NULL); + if (ret == MM_ERROR_NONE) { + g_print ("### mm_sound_add_available_route_changed_callback() Success\n\n"); + } else { + g_print ("### mm_sound_add_available_route_changed_callback() Error : errno [%x]\n\n", ret); + } + } + else if (strncmp(cmd, "O", 1) == 0) { + int ret = 0; + ret = mm_sound_remove_available_route_changed_callback(); + if (ret == MM_ERROR_NONE) { + g_print ("### mm_sound_remove_available_route_changed_callback() Success\n\n"); + } else { + g_print ("### mm_sound_remove_available_route_changed_callback() Error : errno [%x]\n\n", ret); + } } - else if (strncmp(cmd, "p", 1) == 0) { - int ret; - int connected = 0; + int ret = 0; + ret = mm_sound_add_active_device_changed_callback("null", __mm_sound_active_device_changed_cb, NULL); + if (ret == MM_ERROR_NONE) { + g_print ("### mm_sound_add_active_device_changed_callback() Success\n\n"); + } else { + g_print ("### mm_sound_add_active_device_changed_callback() Error : errno [%x]\n\n", ret); + } + } + else if (strncmp(cmd, "P", 1) == 0) { + int ret = 0; + ret = mm_sound_remove_active_device_changed_callback("null"); + if (ret == MM_ERROR_NONE) { + g_print ("### mm_sound_remove_active_device_changed_callback() Success\n\n"); + } else { + g_print ("### mm_sound_remove_active_device_changed_callback() Error : errno [%x]\n\n", ret); + } + } + else if (strncmp(cmd, "{", 1) == 0) { + int ret = 0; + bool connected = 0; char* bt_name = NULL; - ret = mm_sound_route_get_a2dp_status (&connected, &bt_name); + ret = mm_sound_route_get_a2dp_status (&connected, &bt_name); if (ret == MM_ERROR_NONE) { - g_print ("### Is Bluetooth A2DP On Success : connected=[%d] name=[%s]\n", connected, bt_name); + g_print ("### mm_sound_route_get_a2dp_status() Success : connected=[%d] name=[%s]\n", connected, bt_name); if (bt_name) free (bt_name); } else { - g_print ("### Is Bluetooth A2DP On Error : errno [%d]\n", ret); + g_print ("### mm_sound_route_get_a2dp_status() Error : errno [%x]\n", ret); } } + else if(strncmp(cmd, "}", 1) == 0) + { + int ret = 0; + char input_string[128]; + mm_sound_route route = MM_SOUND_ROUTE_OUT_SPEAKER; + char num; + char need_broadcast; + + fflush(stdin); + g_print ("1. MM_SOUND_ROUTE_OUT_SPEAKER\n"); + g_print ("2. MM_SOUND_ROUTE_OUT_RECEIVER\n"); + g_print ("3. MM_SOUND_ROUTE_OUT_WIRED_ACCESSORY\n"); + g_print ("4. MM_SOUND_ROUTE_OUT_BLUETOOTH_A2DP\n"); + g_print ("5. MM_SOUND_ROUTE_OUT_DOCK\n"); + g_print ("6. MM_SOUND_ROUTE_OUT_HDMI\n"); + g_print ("7. MM_SOUND_ROUTE_OUT_MIRRORING\n"); + g_print ("8. MM_SOUND_ROUTE_OUT_USB_AUDIO\n"); + g_print ("9. MM_SOUND_ROUTE_OUT_MULTIMEDIA_DOCK\n"); + g_print ("0. MM_SOUND_ROUTE_IN_MIC\n"); + g_print ("a. MM_SOUND_ROUTE_IN_WIRED_ACCESSORY\n"); + g_print ("b. MM_SOUND_ROUTE_IN_MIC_OUT_RECEIVER\n"); + g_print ("c. MM_SOUND_ROUTE_IN_MIC_OUT_SPEAKER\n"); + g_print ("d. MM_SOUND_ROUTE_IN_MIC_OUT_HEADPHONE\n"); + g_print ("e. MM_SOUND_ROUTE_INOUT_HEADSET\n"); + g_print ("f. MM_SOUND_ROUTE_INOUT_BLUETOOTH\n"); + g_print("> select route number and select is need broadcast(1 need , 0 no need): (eg . 1 1)"); + + if (fgets(input_string, sizeof(input_string)-1, stdin)) { + g_print ("### fgets return NULL\n"); + } + num = input_string[0]; + need_broadcast = input_string[2]; + + if(num == '1') { route = MM_SOUND_ROUTE_OUT_SPEAKER; } + else if(num == '2') { route = MM_SOUND_ROUTE_OUT_RECEIVER; } + else if(num == '3') { route = MM_SOUND_ROUTE_OUT_WIRED_ACCESSORY; } + else if(num == '4') { route = MM_SOUND_ROUTE_OUT_BLUETOOTH_A2DP; } + else if(num == '5') { route = MM_SOUND_ROUTE_OUT_DOCK; } + else if(num == '6') { route = MM_SOUND_ROUTE_OUT_HDMI; } + else if(num == '7') { route = MM_SOUND_ROUTE_OUT_MIRRORING; } + else if(num == '8') { route = MM_SOUND_ROUTE_OUT_USB_AUDIO; } + else if(num == '9') { route = MM_SOUND_ROUTE_OUT_MULTIMEDIA_DOCK; } + else if(num == '0') { route = MM_SOUND_ROUTE_IN_MIC; } + else if(num == 'a') { route = MM_SOUND_ROUTE_IN_WIRED_ACCESSORY; } + else if(num == 'b') { route = MM_SOUND_ROUTE_IN_MIC_OUT_RECEIVER; } + else if(num == 'c') { route = MM_SOUND_ROUTE_IN_MIC_OUT_SPEAKER; } + else if(num == 'd') { route = MM_SOUND_ROUTE_IN_MIC_OUT_HEADPHONE; } + else if(num == 'e') { route = MM_SOUND_ROUTE_INOUT_HEADSET; } + else if(num == 'f') { route = MM_SOUND_ROUTE_INOUT_BLUETOOTH; } + + if (need_broadcast == '1') { + ret = mm_sound_set_active_route(route); + if (ret == MM_ERROR_NONE) { + g_print ("### mm_sound_set_active_route(%s) Success\n\n", __get_route_str (route)); + } else { + g_print ("### mm_sound_set_active_route(%s) Error : errno [%x]\n\n", __get_route_str (route), ret); + } + + } else { + ret = mm_sound_set_active_route_without_broadcast(route); + if (ret == MM_ERROR_NONE) { + g_print ("### mm_sound_set_active_route_without_broadcast(%s) Success\n\n", __get_route_str (route)); + } else { + g_print ("### mm_sound_set_active_route_without_broadcast(%s) Error : errno [%x]\n\n", __get_route_str (route), ret); + } + } + } + else if(strncmp(cmd, "z", 1) ==0) { if(MM_ERROR_NONE != mm_session_init(MM_SESSION_TYPE_CALL)) { @@ -654,6 +1022,18 @@ static void interpret (char *cmd) g_print("VideoCall session init failed\n"); } } + else if(strncmp(cmd, "N", 1) ==0) { + if(MM_ERROR_NONE != mm_session_init(MM_SESSION_TYPE_NOTIFY)) + { + g_print("Notify session init failed\n"); + } + } + else if(strncmp(cmd, "n", 1) ==0) { + if(MM_ERROR_NONE != mm_session_init(MM_SESSION_TYPE_VOIP)) + { + g_print("VOIP session init failed\n"); + } + } else if(strncmp(cmd, "v", 1) ==0) { if(MM_ERROR_NONE != mm_session_finish()) { @@ -668,39 +1048,18 @@ static void interpret (char *cmd) } else { - if(value == ASM_STATUS_NONE || (value == ASM_STATUS_NONE & ASM_STATUS_MONITOR)) + if(value == ASM_STATUS_NONE || value == ASM_STATUS_MONITOR) { g_print("No Session Instance\n"); } - if(value & ASM_STATUS_SHARE_MMPLAYER) { - g_print("SHARE - PLAYER\n"); - } - if(value & ASM_STATUS_EXCLUSIVE_MMPLAYER) { - g_print("EXCLUSIVE - PLAYER\n"); - } - if(value & ASM_STATUS_SHARE_MMSOUND) { - g_print("SHARE - SOUND\n"); - } - if(value & ASM_STATUS_EXCLUSIVE_MMSOUND) { - g_print("EXCLUSIVE - SOUND\n"); - } - if(value & ASM_STATUS_SHARE_MMCAMCORDER) { - g_print("SHARE - CAMCORDER\n"); - } - if(value & ASM_STATUS_EXCLUSIVE_MMCAMCORDER) { - g_print("EXCLUSIVE - CAMCORDER\n"); + if(value & ASM_STATUS_MEDIA_MMPLAYER) { + g_print("MEDIA - PLAYER\n"); } - if(value & ASM_STATUS_SHARE_OPENAL) { - g_print("SHARE - OPENAL\n"); + if(value & ASM_STATUS_MEDIA_MMSOUND) { + g_print("MEDIA - SOUND\n"); } - if(value & ASM_STATUS_EXCLUSIVE_OPENAL) { - g_print("EXCLUSIVE - OPENAL\n"); - } - if(value & ASM_STATUS_SHARE_AVSYSTEM) { - g_print("SHARE - AVSYSTEM\n"); - } - if(value & ASM_STATUS_EXCLUSIVE_AVSYSTEM) { - g_print("EXCLUSIVE - AVSYSTEM\n"); + if(value & ASM_STATUS_MEDIA_OPENAL) { + g_print("MEDIA - OPENAL\n"); } if(value & ASM_STATUS_NOTIFY) { g_print("NOTIFY\n"); @@ -714,10 +1073,224 @@ static void interpret (char *cmd) if(value & ASM_STATUS_VIDEOCALL) { g_print("VIDEOCALL\n"); } + if(value & ASM_STATUS_VOIP) { + g_print("VOIP\n"); + } } } - // End of sound & avsystem interpret + else if(strncmp(cmd, "L", 1) ==0) { + int ret = 0; + mm_sound_device_flags_e flags = MM_SOUND_DEVICE_ALL_FLAG; + MMSoundDeviceList_t device_list; + int type = 0; + int io_direction = 0; + int state = 0; + int id = 0; + char *name = NULL; + MMSoundDevice_t device_h = NULL; + int dret = MM_ERROR_NONE; + + ret = mm_sound_get_current_device_list(flags, &device_list); + if (ret) { + g_print("failed to mm_sound_get_current_device_list(), ret[0x%x]\n", ret); + } else { + g_print("device_list[0x%x], device_h[0x%x]\n", device_list, device_h); + do { + dret = mm_sound_get_next_device (device_list, &device_h); + if (dret) { + debug_error("failed to mm_sound_get_next_device(), dret[0x%x]\n", dret); + } else { + ret = mm_sound_get_device_type(device_h, &type); + if (ret) { + debug_error("failed to mm_sound_get_device_type()\n"); + } + ret = mm_sound_get_device_io_direction(device_h, &io_direction); + if (ret) { + debug_error("failed to mm_sound_get_device_io_direction()\n"); + } + ret = mm_sound_get_device_state(device_h, &state); + if (ret) { + debug_error("failed to mm_sound_get_device_state()\n"); + } + ret = mm_sound_get_device_id(device_h, &id); + if (ret) { + debug_error("failed to mm_sound_get_device_id()\n"); + } + ret = mm_sound_get_device_name(device_h, &name); + if (ret) { + debug_error("failed to mm_sound_get_device_name()\n"); + } + debug_log("*** --- [NEXT DEVICE] type[%d], id[%d], io_direction[%d], state[%d], name[%s]\n", type, id, io_direction, state, name); + } + } while (dret == MM_ERROR_NONE); + do { + dret = MM_ERROR_NONE; + dret = mm_sound_get_prev_device (device_list, &device_h); + if (dret) { + debug_error("failed to mm_sound_get_prev_device(), dret[0x%x]\n", dret); + } else { + ret = mm_sound_get_device_type(device_h, &type); + if (ret) { + debug_error("failed to mm_sound_get_device_type()\n"); + } + ret = mm_sound_get_device_io_direction(device_h, &io_direction); + if (ret) { + debug_error("failed to mm_sound_get_device_io_direction()\n"); + } + ret = mm_sound_get_device_state(device_h, &state); + if (ret) { + debug_error("failed to mm_sound_get_device_state()\n"); + } + ret = mm_sound_get_device_id(device_h, &id); + if (ret) { + debug_error("failed to mm_sound_get_device_id()\n"); + } + ret = mm_sound_get_device_name(device_h, &name); + if (ret) { + debug_error("failed to mm_sound_get_device_name()\n"); + } + debug_log("*** --- [PREV DEVICE] type[%d], id[%d], io_direction[%d], state[%d], name[%s]\n", type, id, io_direction, state, name); + } + } while (dret == MM_ERROR_NONE); + } + } + + else if(strncmp(cmd, "C", 1) ==0) { + int ret = 0; + char input_string[128]; + mm_sound_device_flags_e device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG; + mm_sound_device_flags_e device_flag_2 = MM_SOUND_DEVICE_ALL_FLAG; + mm_sound_device_flags_e device_flag_3 = MM_SOUND_DEVICE_ALL_FLAG; + + char flag_1, flag_2, flag_3; + + fflush(stdin); + g_print ("1. IO_DIRECTION_IN_FLAG\n"); + g_print ("2. IO_DIRECTION_OUT_FLAG\n"); + g_print ("3. IO_DIRECTION_BOTH_FLAG\n"); + g_print ("4. TYPE_INTERNAL_FLAG\n"); + g_print ("5. TYPE_EXTERNAL_FLAG\n"); + g_print ("6. STATE_DEACTIVATED_FLAG\n"); + g_print ("7. STATE_ACTIVATED_FLAG\n"); + g_print ("8. ALL_FLAG\n"); + g_print("> select flag numbers (total 3): (eg. 2 5 7)"); + + if (fgets(input_string, sizeof(input_string)-1, stdin)) { + g_print ("### fgets return NULL\n"); + } + flag_1 = input_string[0]; + flag_2 = input_string[2]; + flag_3 = input_string[4]; + + if(flag_1 == '1') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; } + else if(flag_1 == '2') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; } + else if(flag_1 == '3') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; } + else if(flag_1 == '4') { device_flag_1 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; } + else if(flag_1 == '5') { device_flag_1 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; } + else if(flag_1 == '6') { device_flag_1 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; } + else if(flag_1 == '7') { device_flag_1 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; } + else if(flag_1 == '8') { device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG; } + if(flag_2 == '1') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; } + else if(flag_2 == '2') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; } + else if(flag_2 == '3') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; } + else if(flag_2 == '4') { device_flag_2 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; } + else if(flag_2 == '5') { device_flag_2 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; } + else if(flag_2 == '6') { device_flag_2 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; } + else if(flag_2 == '7') { device_flag_2 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; } + else if(flag_2 == '8') { device_flag_2 = MM_SOUND_DEVICE_ALL_FLAG; } + if(flag_3 == '1') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; } + else if(flag_3 == '2') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; } + else if(flag_3 == '3') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; } + else if(flag_3 == '4') { device_flag_3 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; } + else if(flag_3 == '5') { device_flag_3 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; } + else if(flag_3 == '6') { device_flag_3 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; } + else if(flag_3 == '7') { device_flag_3 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; } + else if(flag_3 == '8') { device_flag_3 = MM_SOUND_DEVICE_ALL_FLAG; } + + ret = mm_sound_add_device_connected_callback(device_flag_1|device_flag_2|device_flag_3, device_connected_cb, NULL); + if (ret) { + g_print("failed to mm_sound_add_device_connected_callback(), ret[0x%x]\n", ret); + } else { + g_print("device_flags[0x%x], callback fun[0x%x]\n", device_flag_1|device_flag_2|device_flag_3, device_connected_cb); + } + } + + else if(strncmp(cmd, "D", 1) ==0) { + int ret = 0; + ret = mm_sound_remove_device_connected_callback(); + if (ret) { + g_print("failed to mm_sound_remove_device_connected_callback(), ret[0x%x]\n", ret); + } + } + + else if(strncmp(cmd, "Q", 1) ==0) { + int ret = 0; + char input_string[128]; + mm_sound_device_flags_e device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG; + mm_sound_device_flags_e device_flag_2 = MM_SOUND_DEVICE_ALL_FLAG; + mm_sound_device_flags_e device_flag_3 = MM_SOUND_DEVICE_ALL_FLAG; + + char flag_1, flag_2, flag_3; + + fflush(stdin); + g_print ("1. IO_DIRECTION_IN_FLAG\n"); + g_print ("2. IO_DIRECTION_OUT_FLAG\n"); + g_print ("3. IO_DIRECTION_BOTH_FLAG\n"); + g_print ("4. TYPE_INTERNAL_FLAG\n"); + g_print ("5. TYPE_EXTERNAL_FLAG\n"); + g_print ("6. STATE_DEACTIVATED_FLAG\n"); + g_print ("7. STATE_ACTIVATED_FLAG\n"); + g_print ("8. ALL_FLAG\n"); + g_print("> select flag numbers (total 3): (eg. 2 5 7)"); + + if (fgets(input_string, sizeof(input_string)-1, stdin)) { + g_print ("### fgets return NULL\n"); + } + flag_1 = input_string[0]; + flag_2 = input_string[2]; + flag_3 = input_string[4]; + + if(flag_1 == '1') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; } + else if(flag_1 == '2') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; } + else if(flag_1 == '3') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; } + else if(flag_1 == '4') { device_flag_1 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; } + else if(flag_1 == '5') { device_flag_1 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; } + else if(flag_1 == '6') { device_flag_1 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; } + else if(flag_1 == '7') { device_flag_1 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; } + else if(flag_1 == '8') { device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG; } + if(flag_2 == '1') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; } + else if(flag_2 == '2') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; } + else if(flag_2 == '3') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; } + else if(flag_2 == '4') { device_flag_2 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; } + else if(flag_2 == '5') { device_flag_2 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; } + else if(flag_2 == '6') { device_flag_2 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; } + else if(flag_2 == '7') { device_flag_2 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; } + else if(flag_2 == '8') { device_flag_2 = MM_SOUND_DEVICE_ALL_FLAG; } + if(flag_3 == '1') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; } + else if(flag_3 == '2') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; } + else if(flag_3 == '3') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; } + else if(flag_3 == '4') { device_flag_3 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; } + else if(flag_3 == '5') { device_flag_3 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; } + else if(flag_3 == '6') { device_flag_3 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; } + else if(flag_3 == '7') { device_flag_3 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; } + else if(flag_3 == '8') { device_flag_3 = MM_SOUND_DEVICE_ALL_FLAG; } + + ret = mm_sound_add_device_information_changed_callback(device_flag_1|device_flag_2|device_flag_3, device_info_changed_cb, NULL); + if (ret) { + g_print("failed to mm_sound_add_device_information_changed_callback(), ret[0x%x]\n", ret); + } else { + g_print("device_flags[0x%x], callback fun[0x%x]\n", device_flag_1|device_flag_2|device_flag_3, device_info_changed_cb); + } + } + + else if(strncmp(cmd, "W", 1) ==0) { + int ret = 0; + ret = mm_sound_remove_device_information_changed_callback(); + if (ret) { + g_print("failed to mm_sound_remove_device_information_changed_callback(), ret[0x%x]\n", ret); + } + } else if (strncmp(cmd, "x", 1) == 0) { quit_program(); } @@ -735,18 +1308,22 @@ static void interpret (char *cmd) case CURRENT_STATUS_POSITION: break; } - g_timeout_add(100, timeout_menu_display, 0); + //g_timeout_add(100, timeout_menu_display, 0); } -void volume_change_callback(void* data) +void volume_change_callback(volume_type_t type, unsigned int volume, void *user_data) { - volume_type_t* type = (volume_type_t*) data; - - g_volume_type = *type; - mm_sound_volume_get_value(g_volume_type, &g_volume_value); - g_print("Volume Callback Runs :::: MEDIA VALUME %d\n", g_volume_value); + if (type == VOLUME_TYPE_MEDIA) + g_print("Volume Callback Runs :::: MEDIA VALUME %d\n", volume); } +void muteall_change_callback(void* data) +{ + int muteall; + + mm_sound_get_muteall(&muteall); + g_print("Muteall Callback Runs :::: muteall value = %d\n", muteall); +} void audio_route_policy_changed_callback(void* data, system_audio_route_t policy) { @@ -767,14 +1344,23 @@ void audio_route_policy_changed_callback(void* data, system_audio_route_t policy int main(int argc, char *argv[]) { + int ret = 0; stdin_channel = g_io_channel_unix_new(0); g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)input, NULL); g_loop = g_main_loop_new (NULL, 1); g_print("callback function addr :: %p\n", volume_change_callback); g_volume_type = VOLUME_TYPE_MEDIA; - mm_sound_volume_get_value(g_volume_type, &g_volume_value); - mm_sound_volume_add_callback(g_volume_type, volume_change_callback, (void*) &g_volume_type); + ret = mm_sound_volume_get_value(g_volume_type, &g_volume_value); + if(ret < 0) { + g_print("mm_sound_volume_get_value 0x%x\n", ret); + } + + MMSOUND_STRNCPY(g_file_name, POWERON_FILE, MAX_STRING_LEN); + g_print("\nThe input filename is '%s' \n\n",g_file_name); + + mm_sound_add_volume_changed_callback(volume_change_callback, (void*) &g_volume_type); + mm_sound_muteall_add_callback(muteall_change_callback); displaymenu(); g_main_loop_run (g_loop); -- cgit v1.2.3