Add support for ALSA compressed offload

See
https://docs.kernel.org/sound/designs/compress-offload.html
https://github.com/alsa-project/tinycompress
This commit is contained in:
Sanchayan Maity 2022-09-20 15:13:16 +05:30 committed by Wim Taymans
parent f3914e494c
commit 6a034cc398
7 changed files with 1212 additions and 2 deletions

View file

@ -266,6 +266,15 @@ if not readline_dep.found()
readline_dep = cc.find_library('readline', required : get_option('readline'))
endif
need_avcodec = get_option('ffmpeg').enabled() or get_option('pw-cat').enabled()
avcodec_dep = dependency('libavcodec', required: need_avcodec)
avformat_dep = dependency('libavformat', required: get_option('pw-cat'))
summary({'Libav for pw-cat': avcodec_dep.found() and avformat_dep.found()}, bool_yn: true, section: 'Support for ALSA Compress-Offload API')
tinycompress_dep = cc.find_library('tinycompress', has_headers: ['tinycompress/tinycompress.h' ], required: get_option('compressed-offload'))
summary({'Compressed offload sink': tinycompress_dep.found()}, bool_yn: true, section: 'Support for ALSA Compress-Offload API')
compressed_offload_enabled = avcodec_dep.found() and avformat_dep.found() and tinycompress_dep.found()
cdata.set('HAVE_COMPRESSED_OFFLOAD', compressed_offload_enabled)
summary({'readline (for pw-cli)': readline_dep.found()}, bool_yn: true, section: 'Misc dependencies')
cdata.set('HAVE_READLINE', readline_dep.found())
ncurses_dep = dependency('ncursesw', required : false)

View file

@ -273,3 +273,7 @@ option('gsettings',
description: 'Enable code that depends on gsettings',
type: 'feature',
value: 'auto')
option('compressed-offload',
description: 'Enable compressed offload support',
type: 'feature',
value: 'auto')

View file

@ -0,0 +1,39 @@
/* Simple Plugin API
*
* Copyright © 2021 Wim Taymans
* © 2022 Asymptotic Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef SPA_AUDIO_COMPRESSED_H
#define SPA_AUDIO_COMPRESSED_H
#include <spa/param/audio/aac.h>
#include <spa/param/audio/alac.h>
#include <spa/param/audio/amr.h>
#include <spa/param/audio/ape.h>
#include <spa/param/audio/flac.h>
#include <spa/param/audio/mp3.h>
#include <spa/param/audio/ra.h>
#include <spa/param/audio/vorbis.h>
#include <spa/param/audio/wma.h>
#endif /* SPA_AUDIO_COMPRESSED_H */

View file

@ -74,7 +74,6 @@ if get_option('spa-plugins').allowed()
summary({'ModemManager': mm_dep.found()}, bool_yn: true, section: 'Bluetooth backends')
endif
endif
avcodec_dep = dependency('libavcodec', required: get_option('ffmpeg'))
jack_dep = dependency('jack', version : '>= 1.9.10', required: get_option('jack'))
summary({'JACK2': jack_dep.found()}, bool_yn: true, section: 'Backend')
vulkan_dep = dependency('vulkan', disabler : true, version : '>= 1.1.69', required: get_option('vulkan'))

File diff suppressed because it is too large Load diff

View file

@ -22,6 +22,8 @@
* DEALINGS IN THE SOFTWARE.
*/
#include "config.h"
#include <errno.h>
#include <spa/support/plugin.h>
@ -33,6 +35,9 @@ extern const struct spa_handle_factory spa_alsa_udev_factory;
extern const struct spa_handle_factory spa_alsa_device_factory;
extern const struct spa_handle_factory spa_alsa_seq_bridge_factory;
extern const struct spa_handle_factory spa_alsa_acp_device_factory;
#ifdef HAVE_COMPRESSED_OFFLOAD
extern const struct spa_handle_factory spa_alsa_compressed_sink_factory;
#endif
struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.alsa");
struct spa_log_topic *alsa_log_topic = &log_topic;
@ -62,6 +67,11 @@ int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t
case 5:
*factory = &spa_alsa_acp_device_factory;
break;
#ifdef HAVE_COMPRESSED_OFFLOAD
case 6:
*factory = &spa_alsa_compressed_sink_factory;
break;
#endif
default:
return 0;
}

View file

@ -1,6 +1,8 @@
subdir('acp')
subdir('mixer')
spa_alsa_dependencies = [ spa_dep, alsa_dep, libudev_dep, mathlib, epoll_shim_dep, libinotify_dep ]
spa_alsa_sources = ['alsa.c',
'alsa.h',
'alsa-udev.c',
@ -12,12 +14,17 @@ spa_alsa_sources = ['alsa.c',
'alsa-seq-bridge.c',
'alsa-seq.c']
if tinycompress_dep.found()
spa_alsa_sources += [ 'alsa-compressed-sink.c' ]
spa_alsa_dependencies += tinycompress_dep
endif
spa_alsa = shared_library(
'spa-alsa',
[ spa_alsa_sources ],
c_args : acp_c_args,
include_directories : [configinc],
dependencies : [ spa_dep, alsa_dep, libudev_dep, mathlib, epoll_shim_dep, libinotify_dep ],
dependencies : spa_alsa_dependencies,
link_with : [ acp_lib ],
install : true,
install_dir : spa_plugindir / 'alsa'