From 39280c6f22a61d40b29b453ab114cc2e004ac89b Mon Sep 17 00:00:00 2001 From: zenglifeng Date: Wed, 18 May 2022 11:17:05 +0800 Subject: [PATCH] Porting the third-party library alsa-lib Signed-off-by: zenglifeng --- BUILD.gn | 201 ++++++++++++ include/version.h | 34 ++ ohos_build_config.sh | 26 ++ src/conf/BUILD.gn | 721 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 982 insertions(+) create mode 100644 BUILD.gn create mode 100644 include/version.h create mode 100755 ohos_build_config.sh create mode 100644 src/conf/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 00000000..a61d5312 --- /dev/null +++ b/BUILD.gn @@ -0,0 +1,201 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# 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. + +import("//build/ohos.gni") + +config("alsa_lib_config") { + cflags = [ + "-Wno-sign-compare", + "-Wno-implicit-function-declaration", + "-Wno-parentheses", + "-Wno-string-conversion", + "-Wno-string-plus-int", + "-Wno-asm-operand-widths", + "-Wno-pointer-sign", + "-Wno-deprecated-declarations", + "-Wno-implicit-int", + "-Wno-switch", + "-Wno-incompatible-pointer-types-discards-qualifiers", + "-Wno-int-conversion", + "-Wno-absolute-value", + "-Wno-unused-function", + "-Wno-unused-label", + "-Wno-unused-const-variable", + "-Wno-visibility", + "-Wno-incompatible-pointer-types", + "-Wno-sometimes-uninitialized", + "-Wno-format", + "-Wno-tautological-constant-out-of-range-compare", + "-Wno-implicit-fallthrough", + "-Wno-error", + "-DHAVE_CONFIG_H", + ] + + if (use_musl) { + cflags += [ "-Wno-bool-operation" ] + } +} + +ohos_source_set("alsa_lib_dynamic") { + sources = [ + "//third_party/alsa-lib/src/async.c", + "//third_party/alsa-lib/src/conf.c", + "//third_party/alsa-lib/src/confeval.c", + "//third_party/alsa-lib/src/confmisc.c", + "//third_party/alsa-lib/src/control/cards.c", + "//third_party/alsa-lib/src/control/control.c", + "//third_party/alsa-lib/src/control/control_empty.c", + "//third_party/alsa-lib/src/control/control_ext.c", + "//third_party/alsa-lib/src/control/control_hw.c", + "//third_party/alsa-lib/src/control/control_plugin.c", + "//third_party/alsa-lib/src/control/control_remap.c", + "//third_party/alsa-lib/src/control/control_shm.c", + "//third_party/alsa-lib/src/control/control_symbols.c", + "//third_party/alsa-lib/src/control/ctlparse.c", + "//third_party/alsa-lib/src/control/hcontrol.c", + "//third_party/alsa-lib/src/control/namehint.c", + "//third_party/alsa-lib/src/control/setup.c", + "//third_party/alsa-lib/src/control/tlv.c", + "//third_party/alsa-lib/src/dlmisc.c", + "//third_party/alsa-lib/src/error.c", + "//third_party/alsa-lib/src/hwdep/hwdep.c", + "//third_party/alsa-lib/src/hwdep/hwdep_hw.c", + "//third_party/alsa-lib/src/hwdep/hwdep_symbols.c", + "//third_party/alsa-lib/src/input.c", + "//third_party/alsa-lib/src/mixer/bag.c", + "//third_party/alsa-lib/src/mixer/mixer.c", + "//third_party/alsa-lib/src/mixer/simple.c", + "//third_party/alsa-lib/src/mixer/simple_abst.c", + "//third_party/alsa-lib/src/mixer/simple_none.c", + "//third_party/alsa-lib/src/names.c", + "//third_party/alsa-lib/src/output.c", + "//third_party/alsa-lib/src/pcm/interval.c", + "//third_party/alsa-lib/src/pcm/mask.c", + "//third_party/alsa-lib/src/pcm/pcm.c", + "//third_party/alsa-lib/src/pcm/pcm_adpcm.c", + "//third_party/alsa-lib/src/pcm/pcm_alaw.c", + "//third_party/alsa-lib/src/pcm/pcm_asym.c", + "//third_party/alsa-lib/src/pcm/pcm_copy.c", + "//third_party/alsa-lib/src/pcm/pcm_direct.c", + "//third_party/alsa-lib/src/pcm/pcm_dmix.c", + "//third_party/alsa-lib/src/pcm/pcm_dshare.c", + "//third_party/alsa-lib/src/pcm/pcm_dsnoop.c", + "//third_party/alsa-lib/src/pcm/pcm_empty.c", + "//third_party/alsa-lib/src/pcm/pcm_extplug.c", + "//third_party/alsa-lib/src/pcm/pcm_file.c", + "//third_party/alsa-lib/src/pcm/pcm_generic.c", + "//third_party/alsa-lib/src/pcm/pcm_hooks.c", + "//third_party/alsa-lib/src/pcm/pcm_hw.c", + "//third_party/alsa-lib/src/pcm/pcm_iec958.c", + "//third_party/alsa-lib/src/pcm/pcm_ioplug.c", + "//third_party/alsa-lib/src/pcm/pcm_ladspa.c", + "//third_party/alsa-lib/src/pcm/pcm_lfloat.c", + "//third_party/alsa-lib/src/pcm/pcm_linear.c", + "//third_party/alsa-lib/src/pcm/pcm_meter.c", + "//third_party/alsa-lib/src/pcm/pcm_misc.c", + "//third_party/alsa-lib/src/pcm/pcm_mmap.c", + "//third_party/alsa-lib/src/pcm/pcm_mmap_emul.c", + "//third_party/alsa-lib/src/pcm/pcm_mulaw.c", + "//third_party/alsa-lib/src/pcm/pcm_multi.c", + "//third_party/alsa-lib/src/pcm/pcm_null.c", + "//third_party/alsa-lib/src/pcm/pcm_params.c", + "//third_party/alsa-lib/src/pcm/pcm_plug.c", + "//third_party/alsa-lib/src/pcm/pcm_plugin.c", + "//third_party/alsa-lib/src/pcm/pcm_rate.c", + "//third_party/alsa-lib/src/pcm/pcm_rate_linear.c", + "//third_party/alsa-lib/src/pcm/pcm_route.c", + "//third_party/alsa-lib/src/pcm/pcm_share.c", + "//third_party/alsa-lib/src/pcm/pcm_shm.c", + "//third_party/alsa-lib/src/pcm/pcm_simple.c", + "//third_party/alsa-lib/src/pcm/pcm_softvol.c", + "//third_party/alsa-lib/src/pcm/pcm_symbols.c", + "//third_party/alsa-lib/src/rawmidi/rawmidi.c", + "//third_party/alsa-lib/src/rawmidi/rawmidi_hw.c", + "//third_party/alsa-lib/src/rawmidi/rawmidi_symbols.c", + "//third_party/alsa-lib/src/rawmidi/rawmidi_virt.c", + "//third_party/alsa-lib/src/seq/seq.c", + "//third_party/alsa-lib/src/seq/seq_event.c", + "//third_party/alsa-lib/src/seq/seq_hw.c", + "//third_party/alsa-lib/src/seq/seq_midi_event.c", + "//third_party/alsa-lib/src/seq/seq_old.c", + "//third_party/alsa-lib/src/seq/seq_symbols.c", + "//third_party/alsa-lib/src/seq/seqmid.c", + "//third_party/alsa-lib/src/shmarea.c", + "//third_party/alsa-lib/src/socket.c", + "//third_party/alsa-lib/src/timer/timer.c", + "//third_party/alsa-lib/src/timer/timer_hw.c", + "//third_party/alsa-lib/src/timer/timer_query.c", + "//third_party/alsa-lib/src/timer/timer_query_hw.c", + "//third_party/alsa-lib/src/timer/timer_symbols.c", + "//third_party/alsa-lib/src/ucm/main.c", + "//third_party/alsa-lib/src/ucm/parser.c", + "//third_party/alsa-lib/src/ucm/ucm_cond.c", + "//third_party/alsa-lib/src/ucm/ucm_exec.c", + "//third_party/alsa-lib/src/ucm/ucm_include.c", + "//third_party/alsa-lib/src/ucm/ucm_regex.c", + "//third_party/alsa-lib/src/ucm/ucm_subs.c", + "//third_party/alsa-lib/src/ucm/utils.c", + "//third_party/alsa-lib/src/userfile.c", + ] + + include_dirs = [ + "//third_party/alsa-lib/include", + "//third_party/alsa-lib/include/sound", + "//third_party/alsa-lib/include/uapi", + "//third_party/alsa-lib/src/pcm", + "//third_party/alsa-lib/src/ucm", + "//third_party/alsa-lib/src/mixer", + "//third_party/alsa-lib/src/seq", + "//third_party/alsa-lib/src/hwdep", + "//third_party/alsa-lib/src/rawmidi", + "//third_party/alsa-lib/src/control", + "//third_party/alsa-lib/src/timer", + "{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", + + # conf files + "src/conf:alsa-lib-prebuilt-all", + ] + license_file = "./COPYING" + output_extension = "so" + install_images = [ + "system", + "updater", + ] + install_enable = true + part_name = "audio_device_driver" + subsystem_name = "hdf" +} diff --git a/include/version.h b/include/version.h new file mode 100644 index 00000000..a59e1554 --- /dev/null +++ b/include/version.h @@ -0,0 +1,34 @@ +/* + * ALSA lib header file include/version.h + * Copyright (c) 2022 by Allen Riemann Free Software Foundation, Inc. + * + * 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 __VERSION_H +#define __VERSION_H + +#define SND_LIB_MAJOR 1 /**< major number of library version */ +#define SND_LIB_MINOR 2 /**< minor number of library version */ +#define SND_LIB_SUBMINOR 6 /**< subminor number of library version */ +#define SND_LIB_EXTRAVER 1000000 /**< extra version number, used mainly for betas */ +/** library version */ +#define SND_LIB_VER(maj, min, sub) (((maj)<<16)|((min)<<8)|(sub)) +#define SND_LIB_VERSION SND_LIB_VER(SND_LIB_MAJOR, SND_LIB_MINOR, SND_LIB_SUBMINOR) +/** library version (string) */ +#define SND_LIB_VERSION_STR "1.2.6" + +#endif /* __VERSION_H */ diff --git a/ohos_build_config.sh b/ohos_build_config.sh new file mode 100755 index 00000000..b2091b7c --- /dev/null +++ b/ohos_build_config.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# Allen Riemann +set -e + +ALSA_LIB_PATH=$1 +modules= +alisp= +prefix= +libdir="/lib" +configdir="/etc/audio/alsa/share" +args="--disable-aload --prefix=$prefix --libdir=$libdir --with-configdir=$configdir" + +export LC_ALL=C +cd ${ALSA_LIB_PATH} +touch ltconfig +libtoolize --force --copy --automake +aclocal $ACLOCAL_FLAGS +autoheader +automake --foreign --copy --add-missing +touch depcomp # seems to be missing for old automake +autoconf +echo "./configure $args" +${ALSA_LIB_PATH}/configure $args || exit 1 +cd - +cat <