From 6878fd2cde1481c0fb9c0bf81f5666a68f1a779b Mon Sep 17 00:00:00 2001 From: zenglifeng Date: Sun, 5 Jun 2022 18:42:27 +0800 Subject: [PATCH] Porting the third-party library alsa-lib, add head file Signed-off-by: zenglifeng --- BUILD.gn | 17 +-- include/alsa | 1 + include/asoundlib.h | 58 ++++++++ include/config.h | 235 +++++++++++++++++++++++++++++++++ include/version.h | 8 +- src/control/ctl_symbols_list.c | 23 ++++ src/pcm/pcm_symbols_list.c | 47 +++++++ 7 files changed, 369 insertions(+), 20 deletions(-) create mode 120000 include/alsa create mode 100644 include/asoundlib.h create mode 100644 include/config.h create mode 100644 src/control/ctl_symbols_list.c create mode 100644 src/pcm/pcm_symbols_list.c diff --git a/BUILD.gn b/BUILD.gn index a61d5312..46228b9a 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -38,6 +38,7 @@ config("alsa_lib_config") { "-Wno-tautological-constant-out-of-range-compare", "-Wno-implicit-fallthrough", "-Wno-error", + "-D_GNU_SOURCE", "-DHAVE_CONFIG_H", ] @@ -163,25 +164,9 @@ ohos_source_set("alsa_lib_dynamic") { "{target_gen_dir}/include/", ] - deps = [ ":gen_config_header" ] - configs = [ ":alsa_lib_config" ] } -action("gen_config_header") { - script = "//third_party/alsa-lib/ohos_build_config.sh" - - args = [ rebase_path("//third_party/alsa-lib", root_build_dir) ] - - outputs = [ - "${target_gen_dir}/include/config.h", - "${target_gen_dir}/include/asoundlib.h", - "${target_gen_dir}/src/control/ctl_symbols_list.c", - "${target_gen_dir}/src/pcm/pcm_symbols_list.c", - "${target_gen_dir}/include/alsa", - ] -} - ohos_shared_library("libasound") { deps = [ ":alsa_lib_dynamic", diff --git a/include/alsa b/include/alsa new file mode 120000 index 00000000..945c9b46 --- /dev/null +++ b/include/alsa @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/include/asoundlib.h b/include/asoundlib.h new file mode 100644 index 00000000..cb2c5838 --- /dev/null +++ b/include/asoundlib.h @@ -0,0 +1,58 @@ +/* + * ALSA lib header file include/asoundlib.h + * Copyright (c) 2022 Huawei Device Co., Ltd. + * + * 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 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 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 __ASOUNDLIB_H +#define __ASOUNDLIB_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __GNUC__ +#define __inline__ inline +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif /* __ASOUNDLIB_H */ diff --git a/include/config.h b/include/config.h new file mode 100644 index 00000000..25dc05c3 --- /dev/null +++ b/include/config.h @@ -0,0 +1,235 @@ +/* + * ALSA lib header file include/config.h + * Copyright (c) 2022 Huawei Device Co., Ltd. + * + * 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 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 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 __ALSA_CONFIG_H +#define __ALSA_CONFIG_H + +/* Directory with aload* device files */ +#define ALOAD_DEVICE_DIRECTORY "/dev/" + +/* directory containing ALSA configuration database */ +#define ALSA_CONFIG_DIR "/system/etc/audio/alsa/share" + +/* Enable assert at error message handler */ +/* #undef ALSA_DEBUG_ASSERT */ + +/* Directory with ALSA device files */ +#define ALSA_DEVICE_DIRECTORY "/dev/snd/" + +/* directory containing ALSA add-on modules */ +#define ALSA_PLUGIN_DIR "/system/lib" + +/* Build hwdep component */ +#define BUILD_HWDEP "1" + +/* Build mixer component */ +#define BUILD_MIXER "1" + +/* Build PCM component */ +#define BUILD_PCM "1" + +/* Build PCM adpcm plugin */ +#define BUILD_PCM_PLUGIN_ADPCM "1" + +/* Build PCM alaw plugin */ +#define BUILD_PCM_PLUGIN_ALAW "1" + +/* Build PCM lfloat plugin */ +#define BUILD_PCM_PLUGIN_LFLOAT "1" + +/* Build PCM mmap-emul plugin */ +#define BUILD_PCM_PLUGIN_MMAP_EMUL "1" + +/* Build PCM mulaw plugin */ +#define BUILD_PCM_PLUGIN_MULAW "1" + +/* Build PCM rate plugin */ +#define BUILD_PCM_PLUGIN_RATE "1" + +/* Build PCM route plugin */ +#define BUILD_PCM_PLUGIN_ROUTE "1" + +/* Build raw MIDI component */ +#define BUILD_RAWMIDI "1" + +/* Build sequencer component */ +#define BUILD_SEQ "1" + +/* Build DSP Topology component */ +#define BUILD_TOPOLOGY "1" + +/* Build UCM component */ +#define BUILD_UCM "1" + +/* Have clock gettime */ +#define HAVE_CLOCK_GETTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `eaccess' function. */ +#define HAVE_EACCESS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ENDIAN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Have libdl */ +#define HAVE_LIBDL 1 + +/* Have libpthread */ +#define HAVE_LIBPTHREAD 1 + +/* Define to 1 if you have the `resmgr' library (-lresmgr). */ +/* #undef HAVE_LIBRESMGR */ + +/* Have librt */ +#define HAVE_LIBRT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* MMX technology is enabled */ +/* #undef HAVE_MMX */ + +/* Define if your pthreads implementation have PTHREAD_MUTEX_RECURSIVE */ +#define HAVE_PTHREAD_MUTEX_RECURSIVE /**/ + +/* Avoid calculation in float */ +/* #undef HAVE_SOFT_FLOAT */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_ENDIAN_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SHM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `uselocale' function. */ +#define HAVE_USELOCALE 1 + +/* Enable use of wordexp */ +/* #undef HAVE_WORDEXP */ + +/* Define to 1 if compiler supports __thread */ +#define HAVE___THREAD 1 + +/* Lockless dmix as default */ +/* #undef LOCKLESS_DMIX_DEFAULT */ + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* No assert debug */ +/* #undef NDEBUG */ + +/* Name of package */ +#define PACKAGE "alsa-lib" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "alsa-lib" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "alsa-lib 1.2.6" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "alsa-lib" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.2.6" + +/* Max number of cards */ +#define SND_MAX_CARDS 32 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Support /dev/aload* access for auto-loading */ +#define SUPPORT_ALOAD "1" + +/* Support resmgr with alsa-lib */ +/* #undef SUPPORT_RESMGR */ + +/* Disable thread-safe API functions */ +#define THREAD_SAFE_API "1" + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* directory to put tmp socket files */ +#define TMPDIR "/tmp" + +/* sound library version string */ +#define VERSION "1.2.6" + +/* compiled with versioned symbols */ +#define VERSIONED_SYMBOLS + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Toolchain Symbol Prefix */ +#define __SYMBOL_PREFIX "" + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +#endif /* __ALSA_CONFIG_H */ diff --git a/include/version.h b/include/version.h index a59e1554..b0db9197 100644 --- a/include/version.h +++ b/include/version.h @@ -1,6 +1,6 @@ /* * ALSA lib header file include/version.h - * Copyright (c) 2022 by Allen Riemann Free Software Foundation, Inc. + * Copyright (c) 2022 Huawei Device Co., Ltd. * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -18,8 +18,8 @@ * */ -#ifndef __VERSION_H -#define __VERSION_H +#ifndef __ALSA_VERSION_H +#define __ALSA_VERSION_H #define SND_LIB_MAJOR 1 /**< major number of library version */ #define SND_LIB_MINOR 2 /**< minor number of library version */ @@ -31,4 +31,4 @@ /** library version (string) */ #define SND_LIB_VERSION_STR "1.2.6" -#endif /* __VERSION_H */ +#endif /* __ALSA_VERSION_H */ diff --git a/src/control/ctl_symbols_list.c b/src/control/ctl_symbols_list.c new file mode 100644 index 00000000..ea17749d --- /dev/null +++ b/src/control/ctl_symbols_list.c @@ -0,0 +1,23 @@ +/* + * ALSA lib C file ctl_symbols_list.c + * Copyright (c) 2022 Huawei Device Co., Ltd. + * + * 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 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 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 + * + */ + +&_snd_module_control_remap, +&_snd_module_control_shm, +&_snd_module_control_ext, diff --git a/src/pcm/pcm_symbols_list.c b/src/pcm/pcm_symbols_list.c new file mode 100644 index 00000000..389a4e6a --- /dev/null +++ b/src/pcm/pcm_symbols_list.c @@ -0,0 +1,47 @@ +/* + * ALSA lib C file pcm_symbols_list.c + * Copyright (c) 2022 Huawei Device Co., Ltd. + * + * 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 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 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 + * + */ + +&_snd_module_pcm_copy, +&_snd_module_pcm_linear, +&_snd_module_pcm_route, +&_snd_module_pcm_mulaw, +&_snd_module_pcm_alaw, +&_snd_module_pcm_adpcm, +&_snd_module_pcm_rate, +&_snd_module_pcm_plug, +&_snd_module_pcm_multi, +&_snd_module_pcm_shm, +&_snd_module_pcm_file, +&_snd_module_pcm_null, +&_snd_module_pcm_empty, +&_snd_module_pcm_share, +&_snd_module_pcm_meter, +&_snd_module_pcm_hooks, +&_snd_module_pcm_lfloat, +&_snd_module_pcm_ladspa, +&_snd_module_pcm_dmix, +&_snd_module_pcm_dshare, +&_snd_module_pcm_dsnoop, +&_snd_module_pcm_asym, +&_snd_module_pcm_iec958, +&_snd_module_pcm_softvol, +&_snd_module_pcm_extplug, +&_snd_module_pcm_ioplug, +&_snd_module_pcm_mmap_emul, -- Gitee