spa: remove unnecessary indirection for some spa_log_topics

This results in shorter machine code since it removes one
pointer load and a NULL check.
This commit is contained in:
Barnabás Pőcze 2023-10-06 12:41:55 +02:00 committed by Wim Taymans
parent d2b5b53c08
commit 8256a2d5a6
13 changed files with 39 additions and 35 deletions

View file

@ -9,6 +9,8 @@
#include <spa/support/plugin.h>
#include <spa/support/log.h>
#include "alsa.h"
extern const struct spa_handle_factory spa_alsa_source_factory;
extern const struct spa_handle_factory spa_alsa_sink_factory;
extern const struct spa_handle_factory spa_alsa_udev_factory;
@ -20,8 +22,7 @@ extern const struct spa_handle_factory spa_alsa_compress_offload_sink_factory;
extern const struct spa_handle_factory spa_alsa_compress_offload_device_factory;
#endif
struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.alsa");
struct spa_log_topic *alsa_log_topic = &log_topic;
struct spa_log_topic alsa_log_topic = SPA_LOG_TOPIC(0, "spa.alsa");
SPA_EXPORT
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)

View file

@ -8,12 +8,12 @@
#include <spa/support/log.h>
#undef SPA_LOG_TOPIC_DEFAULT
#define SPA_LOG_TOPIC_DEFAULT alsa_log_topic
extern struct spa_log_topic *alsa_log_topic;
#define SPA_LOG_TOPIC_DEFAULT &alsa_log_topic
extern struct spa_log_topic alsa_log_topic;
static inline void alsa_log_topic_init(struct spa_log *log)
{
spa_log_topic_init(log, alsa_log_topic);
spa_log_topic_init(log, &alsa_log_topic);
}
#endif /* SPA_ALSA_H */

View file

@ -26,8 +26,8 @@
#include <spa/debug/log.h>
#undef SPA_LOG_TOPIC_DEFAULT
#define SPA_LOG_TOPIC_DEFAULT log_topic
static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.audioadapter");
#define SPA_LOG_TOPIC_DEFAULT &log_topic
static struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.audioadapter");
#define DEFAULT_ALIGN 16
@ -1755,7 +1755,7 @@ impl_init(const struct spa_handle_factory *factory,
this = (struct impl *) handle;
this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
spa_log_topic_init(this->log, log_topic);
spa_log_topic_init(this->log, &log_topic);
this->cpu = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_CPU);

View file

@ -36,8 +36,8 @@
#include "wavfile.h"
#undef SPA_LOG_TOPIC_DEFAULT
#define SPA_LOG_TOPIC_DEFAULT log_topic
static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.audioconvert");
#define SPA_LOG_TOPIC_DEFAULT &log_topic
static struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.audioconvert");
#define DEFAULT_RATE 48000
#define DEFAULT_CHANNELS 2
@ -3354,7 +3354,7 @@ impl_init(const struct spa_handle_factory *factory,
this = (struct impl *) handle;
this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
spa_log_topic_init(this->log, log_topic);
spa_log_topic_init(this->log, &log_topic);
this->cpu = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_CPU);
if (this->cpu) {

View file

@ -23,8 +23,8 @@
#include "mix-ops.h"
#undef SPA_LOG_TOPIC_DEFAULT
#define SPA_LOG_TOPIC_DEFAULT log_topic
static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.audiomixer");
#define SPA_LOG_TOPIC_DEFAULT &log_topic
static struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.audiomixer");
#define DEFAULT_RATE 48000
#define DEFAULT_CHANNELS 2
@ -918,7 +918,7 @@ impl_init(const struct spa_handle_factory *factory,
this = (struct impl *) handle;
this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
spa_log_topic_init(this->log, log_topic);
spa_log_topic_init(this->log, &log_topic);
this->data_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DataLoop);
if (this->data_loop == NULL) {

View file

@ -23,8 +23,8 @@
#include "mix-ops.h"
#undef SPA_LOG_TOPIC_DEFAULT
#define SPA_LOG_TOPIC_DEFAULT log_topic
static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.mixer-dsp");
#define SPA_LOG_TOPIC_DEFAULT &log_topic
static struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.mixer-dsp");
#define MAX_BUFFERS 64
#define MAX_PORTS 512
@ -855,7 +855,7 @@ impl_init(const struct spa_handle_factory *factory,
this = (struct impl *) handle;
this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
spa_log_topic_init(this->log, log_topic);
spa_log_topic_init(this->log, &log_topic);
this->data_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DataLoop);
if (this->data_loop == NULL) {

View file

@ -7,11 +7,12 @@
#include <spa/support/plugin.h>
#include <spa/support/log.h>
#include "avb.h"
extern const struct spa_handle_factory spa_avb_sink_factory;
extern const struct spa_handle_factory spa_avb_source_factory;
struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.avb");
struct spa_log_topic *avb_log_topic = &log_topic;
struct spa_log_topic avb_log_topic = SPA_LOG_TOPIC(0, "spa.avb");
SPA_EXPORT
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)

View file

@ -8,12 +8,12 @@
#include <spa/support/log.h>
#undef SPA_LOG_TOPIC_DEFAULT
#define SPA_LOG_TOPIC_DEFAULT avb_log_topic
extern struct spa_log_topic *avb_log_topic;
#define SPA_LOG_TOPIC_DEFAULT &avb_log_topic
extern struct spa_log_topic avb_log_topic;
static inline void avb_log_topic_init(struct spa_log *log)
{
spa_log_topic_init(log, avb_log_topic);
spa_log_topic_init(log, &avb_log_topic);
}
#endif /* SPA_AVB_H */

View file

@ -9,8 +9,7 @@
#include "libcamera.h"
struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.libcamera");
struct spa_log_topic *libcamera_log_topic = &log_topic;
struct spa_log_topic libcamera_log_topic = SPA_LOG_TOPIC(0, "spa.libcamera");
SPA_EXPORT
int spa_handle_factory_enum(const struct spa_handle_factory **factory,

View file

@ -18,12 +18,12 @@ extern const struct spa_handle_factory spa_libcamera_manager_factory;
extern const struct spa_handle_factory spa_libcamera_device_factory;
#undef SPA_LOG_TOPIC_DEFAULT
#define SPA_LOG_TOPIC_DEFAULT libcamera_log_topic
extern struct spa_log_topic *libcamera_log_topic;
#define SPA_LOG_TOPIC_DEFAULT &libcamera_log_topic
extern struct spa_log_topic libcamera_log_topic;
static inline void libcamera_log_topic_init(struct spa_log *log)
{
spa_log_topic_init(log, libcamera_log_topic);
spa_log_topic_init(log, &libcamera_log_topic);
}
#ifdef __cplusplus

View file

@ -7,12 +7,13 @@
#include <spa/support/plugin.h>
#include <spa/support/log.h>
#include "v4l2.h"
extern const struct spa_handle_factory spa_v4l2_source_factory;
extern const struct spa_handle_factory spa_v4l2_udev_factory;
extern const struct spa_handle_factory spa_v4l2_device_factory;
struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.v4l2");
struct spa_log_topic *v4l2_log_topic = &log_topic;
struct spa_log_topic v4l2_log_topic = SPA_LOG_TOPIC(0, "spa.v4l2");
SPA_EXPORT
int spa_handle_factory_enum(const struct spa_handle_factory **factory,

View file

@ -4,15 +4,17 @@
#include <errno.h>
#include <linux/videodev2.h>
#include <spa/support/log.h>
#undef SPA_LOG_TOPIC_DEFAULT
#define SPA_LOG_TOPIC_DEFAULT v4l2_log_topic
extern struct spa_log_topic *v4l2_log_topic;
#define SPA_LOG_TOPIC_DEFAULT &v4l2_log_topic
extern struct spa_log_topic v4l2_log_topic;
static inline void v4l2_log_topic_init(struct spa_log *log)
{
spa_log_topic_init(log, v4l2_log_topic);
spa_log_topic_init(log, &v4l2_log_topic);
}
struct spa_v4l2_device {

View file

@ -25,8 +25,8 @@
#include <spa/debug/log.h>
#undef SPA_LOG_TOPIC_DEFAULT
#define SPA_LOG_TOPIC_DEFAULT log_topic
static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.videoadapter");
#define SPA_LOG_TOPIC_DEFAULT &log_topic
static struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.videoadapter");
#define DEFAULT_ALIGN 16
@ -1554,7 +1554,7 @@ impl_init(const struct spa_handle_factory *factory,
this = (struct impl *) handle;
this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
spa_log_topic_init(this->log, log_topic);
spa_log_topic_init(this->log, &log_topic);
this->cpu = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_CPU);