Rename "compressed-offload to "Compress-Offload" in the code

This commit is contained in:
Carlos Rafael Giani 2022-11-23 15:55:00 +01:00 committed by Wim Taymans
parent 55a79fd16a
commit e9a2c6aa34
7 changed files with 41 additions and 38 deletions

View file

@ -270,10 +270,10 @@ need_avcodec = get_option('ffmpeg').enabled() or get_option('pw-cat').enabled()
avcodec_dep = dependency('libavcodec', required: need_avcodec) avcodec_dep = dependency('libavcodec', required: need_avcodec)
avformat_dep = dependency('libavformat', required: get_option('pw-cat')) 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') 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')) tinycompress_dep = cc.find_library('tinycompress', has_headers: ['tinycompress/tinycompress.h' ], required: get_option('compress-offload'))
summary({'Compressed offload sink': tinycompress_dep.found()}, bool_yn: true, section: 'Support for ALSA Compress-Offload API') summary({'Compress-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() compress_offload_enabled = avcodec_dep.found() and avformat_dep.found() and tinycompress_dep.found()
cdata.set('HAVE_COMPRESSED_OFFLOAD', compressed_offload_enabled) cdata.set('HAVE_ALSA_COMPRESS_OFFLOAD', compress_offload_enabled)
summary({'readline (for pw-cli)': readline_dep.found()}, bool_yn: true, section: 'Misc dependencies') summary({'readline (for pw-cli)': readline_dep.found()}, bool_yn: true, section: 'Misc dependencies')
cdata.set('HAVE_READLINE', readline_dep.found()) cdata.set('HAVE_READLINE', readline_dep.found())

View file

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

View file

@ -110,6 +110,8 @@ extern "C" {
#define SPA_NAME_API_ALSA_SEQ_BRIDGE "api.alsa.seq.bridge" /**< an alsa Node interface for #define SPA_NAME_API_ALSA_SEQ_BRIDGE "api.alsa.seq.bridge" /**< an alsa Node interface for
* bridging midi ports */ * bridging midi ports */
#define SPA_NAME_API_ALSA_ACP_DEVICE "api.alsa.acp.device" /**< an alsa ACP Device interface */ #define SPA_NAME_API_ALSA_ACP_DEVICE "api.alsa.acp.device" /**< an alsa ACP Device interface */
#define SPA_NAME_API_ALSA_COMPRESS_OFFLOAD_SINK "api.alsa.compress.offload.sink" /**< an alsa Node interface for
* compressed audio */
/** keys for bluez5 factory names */ /** keys for bluez5 factory names */
#define SPA_NAME_API_BLUEZ5_ENUM_DBUS "api.bluez5.enum.dbus" /**< a dbus Device interface */ #define SPA_NAME_API_BLUEZ5_ENUM_DBUS "api.bluez5.enum.dbus" /**< a dbus Device interface */

View file

@ -1,4 +1,4 @@
/* Spa /* Spa ALSA Compress-Offload sink
* *
* Copyright © 2022 Wim Taymans * Copyright © 2022 Wim Taymans
* © 2022 Asymptotic Inc. * © 2022 Asymptotic Inc.
@ -38,6 +38,7 @@
#include <spa/utils/list.h> #include <spa/utils/list.h>
#include <spa/utils/keys.h> #include <spa/utils/keys.h>
#include <spa/utils/json.h> #include <spa/utils/json.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h> #include <spa/utils/string.h>
#include <spa/utils/result.h> #include <spa/utils/result.h>
#include <spa/node/node.h> #include <spa/node/node.h>
@ -52,16 +53,16 @@
#include <spa/pod/filter.h> #include <spa/pod/filter.h>
#include <spa/control/control.h> #include <spa/control/control.h>
//#include <libavcodec/codec_id.h>
#include <sound/compress_params.h> #include <sound/compress_params.h>
#include <tinycompress/tinycompress.h> #include <tinycompress/tinycompress.h>
/* /*
* This creates a Pipewire sink node which uses the tinycompress user space * This creates a Pipewire sink node which uses the tinycompress user space
* library to use the ALSA compressed APIs for writing compressed data like * library to use the ALSA Compress-Offload API for writing compressed data
* MP3, FLAC etc. to an ALSA compressed device. * like MP3, FLAC etc. to an DSP that can handle such data directly.
* *
* These show up differently under /dev/snd like comprCxDx. * These show up under /dev/snd like comprCxDx, as opposed to regular
* ALSA PCM devices.
* *
* root@dragonboard-845c:~# ls /dev/snd * root@dragonboard-845c:~# ls /dev/snd
* by-path comprC0D3 controlC0 pcmC0D0c pcmC0D0p pcmC0D1c pcmC0D1p pcmC0D2c pcmC0D2p timer * by-path comprC0D3 controlC0 pcmC0D0c pcmC0D0p pcmC0D1c pcmC0D1p pcmC0D2c pcmC0D2p timer
@ -71,8 +72,8 @@
* context.objects = [ * context.objects = [
* { factory = spa-node-factory * { factory = spa-node-factory
* args = { * args = {
* factory.name = api.alsa.compressed.sink * factory.name = api.alsa.compress.offload.sink
* node.name = Compressed-Sink * node.name = Compress-Offload-Sink
* media.class = "Audio/Sink" * media.class = "Audio/Sink"
* api.alsa.path = "hw:0,3" * api.alsa.path = "hw:0,3"
* } * }
@ -88,7 +89,7 @@
* *
*/ */
#define NAME "compressed-audio-sink" #define NAME "compress-offload-audio-sink"
#define DEFAULT_CHANNELS 2 #define DEFAULT_CHANNELS 2
#define DEFAULT_RATE 44100 #define DEFAULT_RATE 44100
#define MAX_BUFFERS 4 #define MAX_BUFFERS 4
@ -675,7 +676,7 @@ compress_setup(struct impl *this, struct spa_audio_info *info, uint32_t *out_rat
case SPA_MEDIA_SUBTYPE_wma: case SPA_MEDIA_SUBTYPE_wma:
codec->id = SND_AUDIOCODEC_WMA; codec->id = SND_AUDIOCODEC_WMA;
/* /*
* WMA does not work with compressed offload if codec profile * WMA does not work with Compress-Offload if codec profile
* is not set. * is not set.
*/ */
switch (info->info.wma.profile) { switch (info->info.wma.profile) {
@ -1070,7 +1071,7 @@ impl_init(const struct spa_handle_factory *factory,
if ((str[0] == 'h') || (str[1] == 'w') || (str[2] == ':')) { if ((str[0] == 'h') || (str[1] == 'w') || (str[2] == ':')) {
snprintf(this->props.device, sizeof(this->props.device), "%s", str); snprintf(this->props.device, sizeof(this->props.device), "%s", str);
} else { } else {
spa_log_error(this->log, NAME " %p: Invalid compressed hw %s", this, str); spa_log_error(this->log, NAME " %p: Invalid Compress-Offload hw %s", this, str);
return -EINVAL; return -EINVAL;
} }
} else { } else {
@ -1093,7 +1094,7 @@ impl_init(const struct spa_handle_factory *factory,
this->codecs_supported[i] = codec_info[i].codec_id; this->codecs_supported[i] = codec_info[i].codec_id;
} }
spa_log_info(this->log, NAME " %p: Initialized compressed sink %s", spa_log_info(this->log, NAME " %p: Initialized Compress-Offload sink %s",
this, this->props.device); this, this->props.device);
return 0; return 0;
@ -1126,15 +1127,15 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
static const struct spa_dict_item info_items[] = { static const struct spa_dict_item info_items[] = {
{ SPA_KEY_FACTORY_AUTHOR, "Sanchayan Maity <sanchayan@asymptotic.io>" }, { SPA_KEY_FACTORY_AUTHOR, "Sanchayan Maity <sanchayan@asymptotic.io>" },
{ SPA_KEY_FACTORY_DESCRIPTION, "Consume compressed audio" }, { SPA_KEY_FACTORY_DESCRIPTION, "Play compressed audio (like MP3 or AAC) with the ALSA Compress-Offload API" },
{ SPA_KEY_FACTORY_USAGE, "["SPA_KEY_API_ALSA_PATH"=<path>]" }, { SPA_KEY_FACTORY_USAGE, "["SPA_KEY_API_ALSA_PATH"=<path>]" },
}; };
static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items); static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items);
const struct spa_handle_factory spa_alsa_compressed_sink_factory = { const struct spa_handle_factory spa_alsa_compress_offload_sink_factory = {
SPA_VERSION_HANDLE_FACTORY, SPA_VERSION_HANDLE_FACTORY,
"api.alsa.compressed.sink", SPA_NAME_API_ALSA_COMPRESS_OFFLOAD_SINK,
&info, &info,
impl_get_size, impl_get_size,
impl_init, impl_init,

View file

@ -35,8 +35,8 @@ 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_device_factory;
extern const struct spa_handle_factory spa_alsa_seq_bridge_factory; extern const struct spa_handle_factory spa_alsa_seq_bridge_factory;
extern const struct spa_handle_factory spa_alsa_acp_device_factory; extern const struct spa_handle_factory spa_alsa_acp_device_factory;
#ifdef HAVE_COMPRESSED_OFFLOAD #ifdef HAVE_ALSA_COMPRESS_OFFLOAD
extern const struct spa_handle_factory spa_alsa_compressed_sink_factory; extern const struct spa_handle_factory spa_alsa_compress_offload_sink_factory;
#endif #endif
struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.alsa"); struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.alsa");
@ -67,9 +67,9 @@ int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t
case 5: case 5:
*factory = &spa_alsa_acp_device_factory; *factory = &spa_alsa_acp_device_factory;
break; break;
#ifdef HAVE_COMPRESSED_OFFLOAD #ifdef HAVE_ALSA_COMPRESS_OFFLOAD
case 6: case 6:
*factory = &spa_alsa_compressed_sink_factory; *factory = &spa_alsa_compress_offload_sink_factory;
break; break;
#endif #endif
default: default:

View file

@ -15,7 +15,7 @@ spa_alsa_sources = ['alsa.c',
'alsa-seq.c'] 'alsa-seq.c']
if tinycompress_dep.found() if tinycompress_dep.found()
spa_alsa_sources += [ 'alsa-compressed-sink.c' ] spa_alsa_sources += [ 'alsa-compress-offload-sink.c' ]
spa_alsa_dependencies += tinycompress_dep spa_alsa_dependencies += tinycompress_dep
endif endif

View file

@ -53,7 +53,7 @@
#include "config.h" #include "config.h"
#ifdef HAVE_COMPRESSED_OFFLOAD #ifdef HAVE_ALSA_COMPRESS_OFFLOAD
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
#endif #endif
@ -115,7 +115,7 @@ struct data {
#define TYPE_PCM 0 #define TYPE_PCM 0
#define TYPE_MIDI 1 #define TYPE_MIDI 1
#define TYPE_DSD 2 #define TYPE_DSD 2
#ifdef HAVE_COMPRESSED_OFFLOAD #ifdef HAVE_ALSA_COMPRESS_OFFLOAD
#define TYPE_ENCODED 3 #define TYPE_ENCODED 3
#endif #endif
int data_type; int data_type;
@ -162,7 +162,7 @@ struct data {
struct dsf_layout layout; struct dsf_layout layout;
} dsf; } dsf;
#ifdef HAVE_COMPRESSED_OFFLOAD #ifdef HAVE_ALSA_COMPRESS_OFFLOAD
FILE *encoded_file; FILE *encoded_file;
AVFormatContext *fmt_context; AVFormatContext *fmt_context;
AVStream *astream; AVStream *astream;
@ -251,7 +251,7 @@ static int sf_playback_fill_f64(struct data *d, void *dest, unsigned int n_frame
return (int)rn; return (int)rn;
} }
#ifdef HAVE_COMPRESSED_OFFLOAD #ifdef HAVE_ALSA_COMPRESS_OFFLOAD
static int encoded_playback_fill(struct data *d, void *dest, unsigned int n_frames) static int encoded_playback_fill(struct data *d, void *dest, unsigned int n_frames)
{ {
int ret, size = 0; int ret, size = 0;
@ -394,7 +394,7 @@ playback_fill_fn(uint32_t fmt)
if (sizeof(double) != 8) if (sizeof(double) != 8)
return NULL; return NULL;
return sf_playback_fill_f64; return sf_playback_fill_f64;
#ifdef HAVE_COMPRESSED_OFFLOAD #ifdef HAVE_ALSA_COMPRESS_OFFLOAD
case SPA_AUDIO_FORMAT_ENCODED: case SPA_AUDIO_FORMAT_ENCODED:
return encoded_playback_fill; return encoded_playback_fill;
#endif #endif
@ -786,7 +786,7 @@ static void on_process(void *userdata)
n_frames = d->maxsize / data->stride; n_frames = d->maxsize / data->stride;
n_frames = SPA_MIN(n_frames, (int)b->requested); n_frames = SPA_MIN(n_frames, (int)b->requested);
#ifdef HAVE_COMPRESSED_OFFLOAD #ifdef HAVE_ALSA_COMPRESS_OFFLOAD
n_fill_frames = data->fill(data, p, n_frames); n_fill_frames = data->fill(data, p, n_frames);
if (n_fill_frames > 0 || n_frames == 0) { if (n_fill_frames > 0 || n_frames == 0) {
@ -983,7 +983,7 @@ static void show_usage(const char *name, bool is_error)
" -r, --record Recording mode\n" " -r, --record Recording mode\n"
" -m, --midi Midi mode\n" " -m, --midi Midi mode\n"
" -d, --dsd DSD mode\n" " -d, --dsd DSD mode\n"
#ifdef HAVE_COMPRESSED_OFFLOAD #ifdef HAVE_ALSA_COMPRESS_OFFLOAD
" -o, --encoded Encoded mode\n" " -o, --encoded Encoded mode\n"
#endif #endif
"\n"), fp); "\n"), fp);
@ -1273,7 +1273,7 @@ static void format_from_filename(SF_INFO *info, const char *filename)
info->format = (info->format & ~SF_FORMAT_SUBMASK) | SF_FORMAT_VORBIS; info->format = (info->format & ~SF_FORMAT_SUBMASK) | SF_FORMAT_VORBIS;
} }
#ifdef HAVE_COMPRESSED_OFFLOAD #ifdef HAVE_ALSA_COMPRESS_OFFLOAD
static int setup_encodedfile(struct data *data) static int setup_encodedfile(struct data *data)
{ {
int ret; int ret;
@ -1575,7 +1575,7 @@ int main(int argc, char *argv[])
goto error_no_props; goto error_no_props;
} }
#ifdef HAVE_COMPRESSED_OFFLOAD #ifdef HAVE_ALSA_COMPRESS_OFFLOAD
while ((c = getopt_long(argc, argv, "hvprmdoR:q:P:", long_options, NULL)) != -1) { while ((c = getopt_long(argc, argv, "hvprmdoR:q:P:", long_options, NULL)) != -1) {
#else #else
while ((c = getopt_long(argc, argv, "hvprmdR:q:P:", long_options, NULL)) != -1) { while ((c = getopt_long(argc, argv, "hvprmdR:q:P:", long_options, NULL)) != -1) {
@ -1616,7 +1616,7 @@ int main(int argc, char *argv[])
data.data_type = TYPE_DSD; data.data_type = TYPE_DSD;
break; break;
#ifdef HAVE_COMPRESSED_OFFLOAD #ifdef HAVE_ALSA_COMPRESS_OFFLOAD
case 'o': case 'o':
data.data_type = TYPE_ENCODED; data.data_type = TYPE_ENCODED;
break; break;
@ -1793,7 +1793,7 @@ int main(int argc, char *argv[])
case TYPE_DSD: case TYPE_DSD:
ret = setup_dsffile(&data); ret = setup_dsffile(&data);
break; break;
#ifdef HAVE_COMPRESSED_OFFLOAD #ifdef HAVE_ALSA_COMPRESS_OFFLOAD
case TYPE_ENCODED: case TYPE_ENCODED:
ret = setup_encodedfile(&data); ret = setup_encodedfile(&data);
break; break;
@ -1816,7 +1816,7 @@ int main(int argc, char *argv[])
ret = setup_properties(&data); ret = setup_properties(&data);
switch (data.data_type) { switch (data.data_type) {
#ifdef HAVE_COMPRESSED_OFFLOAD #ifdef HAVE_ALSA_COMPRESS_OFFLOAD
case TYPE_ENCODED: case TYPE_ENCODED:
{ {
struct spa_audio_info info; struct spa_audio_info info;
@ -1924,7 +1924,7 @@ int main(int argc, char *argv[])
/* and wait while we let things run */ /* and wait while we let things run */
pw_main_loop_run(data.loop); pw_main_loop_run(data.loop);
#ifdef HAVE_COMPRESSED_OFFLOAD #ifdef HAVE_ALSA_COMPRESS_OFFLOAD
if (data.encoded_file) if (data.encoded_file)
fclose(data.encoded_file); fclose(data.encoded_file);
#endif #endif