From 49dae17dfb38adedbfd397dc2b3c619fc4e90327 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 5 Oct 2016 17:43:11 +0200 Subject: [PATCH] Add logger Add logger interface Make it possible to pass extra interfaces to the element at init time, such as a logger. --- pinos/modules/spa/spa-alsa-monitor.c | 4 +- pinos/modules/spa/spa-audiotestsrc.c | 2 +- pinos/modules/spa/spa-v4l2-monitor.c | 4 +- pinos/modules/spa/spa-videotestsrc.c | 2 +- pinos/server/client-node.c | 2 +- pinos/server/rt-loop.c | 2 +- spa/include/spa/log.h | 150 ++++++++++++++++++++++++ spa/include/spa/meson.build | 1 + spa/include/spa/plugin.h | 22 +++- spa/plugins/alsa/alsa-monitor.c | 4 +- spa/plugins/alsa/alsa-sink.c | 4 +- spa/plugins/alsa/alsa-source.c | 4 +- spa/plugins/audiomixer/audiomixer.c | 4 +- spa/plugins/audiotestsrc/audiotestsrc.c | 4 +- spa/plugins/ffmpeg/ffmpeg.c | 8 +- spa/plugins/remote/proxy.c | 4 +- spa/plugins/v4l2/v4l2-monitor.c | 4 +- spa/plugins/v4l2/v4l2-source.c | 8 +- spa/plugins/v4l2/v4l2-utils.c | 45 +++---- spa/plugins/videotestsrc/videotestsrc.c | 4 +- spa/plugins/volume/volume.c | 4 +- spa/plugins/xv/xv-sink.c | 4 +- spa/tests/test-mixer.c | 2 +- spa/tests/test-v4l2.c | 2 +- spa/tools/spa-inspect.c | 2 +- spa/tools/spa-monitor.c | 2 +- 26 files changed, 251 insertions(+), 47 deletions(-) create mode 100644 spa/include/spa/log.h diff --git a/pinos/modules/spa/spa-alsa-monitor.c b/pinos/modules/spa/spa-alsa-monitor.c index e11f9cfc0..d661b0fb8 100644 --- a/pinos/modules/spa/spa-alsa-monitor.c +++ b/pinos/modules/spa/spa-alsa-monitor.c @@ -88,7 +88,7 @@ make_handle (SpaHandle **handle, const char *lib, const char *name, const SpaDic continue; *handle = g_malloc0 (factory->size); - if ((res = spa_handle_factory_init (factory, *handle, info)) < 0) { + if ((res = spa_handle_factory_init (factory, *handle, info, NULL, 0)) < 0) { g_error ("can't make factory instance: %d", res); return res; } @@ -110,7 +110,7 @@ add_item (PinosSpaALSAMonitor *this, SpaMonitorItem *item) g_debug ("alsa-monitor %p: add: \"%s\" (%s)", this, item->name, item->id); handle = calloc (1, item->factory->size); - if ((res = spa_handle_factory_init (item->factory, handle, item->info)) < 0) { + if ((res = spa_handle_factory_init (item->factory, handle, item->info, NULL, 0)) < 0) { g_error ("can't make factory instance: %d", res); return; } diff --git a/pinos/modules/spa/spa-audiotestsrc.c b/pinos/modules/spa/spa-audiotestsrc.c index 83d0cb16b..edce8fe47 100644 --- a/pinos/modules/spa/spa-audiotestsrc.c +++ b/pinos/modules/spa/spa-audiotestsrc.c @@ -69,7 +69,7 @@ make_node (SpaNode **node, const char *lib, const char *name) continue; handle = calloc (1, factory->size); - if ((res = spa_handle_factory_init (factory, handle, NULL)) < 0) { + if ((res = spa_handle_factory_init (factory, handle, NULL, NULL, 0)) < 0) { g_error ("can't make factory instance: %d", res); return res; } diff --git a/pinos/modules/spa/spa-v4l2-monitor.c b/pinos/modules/spa/spa-v4l2-monitor.c index b9281da87..51b60a9a3 100644 --- a/pinos/modules/spa/spa-v4l2-monitor.c +++ b/pinos/modules/spa/spa-v4l2-monitor.c @@ -88,7 +88,7 @@ make_handle (SpaHandle **handle, const char *lib, const char *name, const SpaDic continue; *handle = g_malloc0 (factory->size); - if ((res = spa_handle_factory_init (factory, *handle, info)) < 0) { + if ((res = spa_handle_factory_init (factory, *handle, info, NULL, 0)) < 0) { g_error ("can't make factory instance: %d", res); return res; } @@ -110,7 +110,7 @@ add_item (PinosSpaV4l2Monitor *this, SpaMonitorItem *item) g_debug ("v4l2-monitor %p: add: \"%s\" (%s)", this, item->name, item->id); handle = calloc (1, item->factory->size); - if ((res = spa_handle_factory_init (item->factory, handle, item->info)) < 0) { + if ((res = spa_handle_factory_init (item->factory, handle, item->info, NULL, 0)) < 0) { g_error ("can't make factory instance: %d", res); return; } diff --git a/pinos/modules/spa/spa-videotestsrc.c b/pinos/modules/spa/spa-videotestsrc.c index 538fc0f90..6c270943a 100644 --- a/pinos/modules/spa/spa-videotestsrc.c +++ b/pinos/modules/spa/spa-videotestsrc.c @@ -68,7 +68,7 @@ make_node (SpaNode **node, const char *lib, const char *name) continue; handle = calloc (1, factory->size); - if ((res = factory->init (factory, handle, NULL)) < 0) { + if ((res = factory->init (factory, handle, NULL, NULL, 0)) < 0) { g_error ("can't make factory instance: %d", res); return res; } diff --git a/pinos/server/client-node.c b/pinos/server/client-node.c index c67e558fd..81040db17 100644 --- a/pinos/server/client-node.c +++ b/pinos/server/client-node.c @@ -257,7 +257,7 @@ make_node (SpaNode **node, const char *lib, const char *name) continue; handle = calloc (1, factory->size); - if ((res = factory->init (factory, handle, NULL)) < 0) { + if ((res = factory->init (factory, handle, NULL, NULL, 0)) < 0) { g_error ("can't make factory instance: %d", res); return res; } diff --git a/pinos/server/rt-loop.c b/pinos/server/rt-loop.c index 2e9a3ee83..e1f18ba34 100644 --- a/pinos/server/rt-loop.c +++ b/pinos/server/rt-loop.c @@ -138,7 +138,7 @@ loop (void *user_data) for (i = 0; i < priv->n_poll; i++) { SpaPollItem *p = &priv->poll[i]; - if (p->enabled && p->after_cb) { + if (p->enabled && p->after_cb && (p->n_fds == 0 || priv->fds[priv->idx[i]].revents != 0)) { ndata.fds = &priv->fds[priv->idx[i]]; ndata.n_fds = p->n_fds; ndata.user_data = p->user_data; diff --git a/spa/include/spa/log.h b/spa/include/spa/log.h new file mode 100644 index 000000000..5dc5573a1 --- /dev/null +++ b/spa/include/spa/log.h @@ -0,0 +1,150 @@ +/* Simple Plugin API + * Copyright (C) 2016 Wim Taymans + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __SPA_LOG_H__ +#define __SPA_LOG_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _SpaLog SpaLog; + +#include + +#include +#include + +#define SPA_INTERFACE_ID_LOG 3 +#define SPA_INTERFACE_ID_LOG_NAME "Log interface" +#define SPA_INTERFACE_ID_LOG_DESCRIPTION "Log interface" + +typedef enum +{ + SPA_LOG_LEVEL_NONE = 0, + SPA_LOG_LEVEL_ERROR, + SPA_LOG_LEVEL_WARN, + SPA_LOG_LEVEL_INFO, + SPA_LOG_LEVEL_DEBUG, + SPA_LOG_LEVEL_TRACE, +} SpaLogLevel; + +/** + * SpaLog: + * + * The Log interface + */ +struct _SpaLog { + /* pointer to the handle owning this interface */ + SpaHandle *handle; + /* the total size of this log. This can be used to expand this + * structure in the future */ + size_t size; + /** + * SpaLog::info + * + * Extra information about the log + */ + const SpaDict *info; + + /** + * SpaLog::level + * + * Logging level, everything above this level is not logged + */ + SpaLogLevel level; + + /** + * SpaLog::log + * @log: a #SpaLog + * @level: a #SpaLogLevel + * @file: the file name + * @line: the line number + * @func: the function name + * @fmt: printf style format + * @...: format arguments + * + * Log a message with the given log level. + */ + void (*log) (SpaLog *log, + SpaLogLevel level, + const char *file, + int line, + const char *func, + const char *fmt, ...); + + /** + * SpaLog::logv + * @log: a #SpaLog + * @level: a #SpaLogLevel + * @file: the file name + * @line: the line number + * @func: the function name + * @fmt: printf style format + * @args: format arguments + * + * Log a message with the given log level. + */ + void (*logv) (SpaLog *log, + SpaLogLevel level, + const char *file, + int line, + const char *func, + const char *fmt, + va_list args); +}; + +#if __STDC_VERSION__ >= 199901L + +#define spa_log_log(l,lev,...) \ + if ((l) && (l)->level > lev) \ + (l)->log((l),lev,__VA_ARGS__) + +#define spa_log_error(l,...) spa_log_log(l,SPA_LOG_LEVEL_ERROR,__FILE__,__LINE__,__func__,__VA_ARGS__) +#define spa_log_warn(l,...) spa_log_log(l,SPA_LOG_LEVEL_WARN,__FILE__,__LINE__,__func__,__VA_ARGS__) +#define spa_log_info(l,...) spa_log_log(l,SPA_LOG_LEVEL_INFO,__FILE__,__LINE__,__func__,__VA_ARGS__) +#define spa_log_debug(l,...) spa_log_log(l,SPA_LOG_LEVEL_DEBUG,__FILE__,__LINE__,__func__,__VA_ARGS__) +#define spa_log_trace(l,...) spa_log_log(l,SPA_LOG_LEVEL_TRACE,__FILE__,__LINE__,__func__,__VA_ARGS__) + +#else + +#define SPA_LOG_FUNC(name,lev) \ +static inline void spa_log_##name (SpaLog *l, const char *format, ...) \ +{ \ + if ((l) && (l)->level > lev) { \ + va_list varargs; \ + va_start (varargs, format); \ + (l)->logv((l),lev,__FILE__,__LINE__,__func__,format,varargs); \ + va_end (varargs); \ + } \ +} + +SPA_LOG_FUNC(error, SPA_LOG_LEVEL_ERROR) +SPA_LOG_FUNC(warn, SPA_LOG_LEVEL_WARN) +SPA_LOG_FUNC(info, SPA_LOG_LEVEL_INFO) +SPA_LOG_FUNC(debug, SPA_LOG_LEVEL_DEBUG) +SPA_LOG_FUNC(trace, SPA_LOG_LEVEL_TRACE) + +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* __SPA_LOG_H__ */ diff --git a/spa/include/spa/meson.build b/spa/include/spa/meson.build index 73f217b89..822a846bf 100644 --- a/spa/include/spa/meson.build +++ b/spa/include/spa/meson.build @@ -6,6 +6,7 @@ spa_headers = [ 'defs.h', 'dict.h', 'format.h', + 'log.h', 'monitor.h', 'node-command.h', 'node-event.h', diff --git a/spa/include/spa/plugin.h b/spa/include/spa/plugin.h index 51c0a619f..a4d3142a8 100644 --- a/spa/include/spa/plugin.h +++ b/spa/include/spa/plugin.h @@ -78,6 +78,19 @@ typedef struct { const char *description; } SpaInterfaceInfo; +/** + * SpaInterface: + * @interface_id: the id of the interface + * @interface: an interface instance + * + * An interface instance that is usually passed to the init() function of + * a factory to provide extra API such as logging. + */ +typedef struct { + uint32_t interface_id; + void *interface; +} SpaInterface; + struct _SpaHandleFactory { /** * SpaHandleFactory::name @@ -104,17 +117,24 @@ struct _SpaHandleFactory { * @handle: a pointer to memory * @info: extra handle specific information, usually obtained * from a #SpaMonitor. This can be used to configure the handle. + * @platform: platform interfaces + * @n_platform: number of elements in @platform * * Initialize an instance of this factory. The caller should allocate * memory at least SpaHandleFactory::size bytes and pass this as @handle. * + * @platform can optionally contain extra interfaces that the plugin can + * use such as a logger. + * * Returns: #SPA_RESULT_OK on success * #SPA_RESULT_NOT_IMPLEMENTED when an instance can't be made * #SPA_RESULT_INVALID_ARGUMENTS when factory or handle are %NULL */ SpaResult (*init) (const SpaHandleFactory *factory, SpaHandle *handle, - const SpaDict *info); + const SpaDict *info, + const SpaInterface **platform, + unsigned int n_platform); /** * SpaHandle::enum_interface_info: diff --git a/spa/plugins/alsa/alsa-monitor.c b/spa/plugins/alsa/alsa-monitor.c index b6b3657be..6f85f9fc5 100644 --- a/spa/plugins/alsa/alsa-monitor.c +++ b/spa/plugins/alsa/alsa-monitor.c @@ -379,7 +379,9 @@ alsa_monitor_clear (SpaHandle *handle) static SpaResult alsa_monitor_init (const SpaHandleFactory *factory, SpaHandle *handle, - const SpaDict *info) + const SpaDict *info, + const SpaInterface **platform, + unsigned int n_platform) { SpaALSAMonitor *this; diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c index 48f2ebebe..8e07d7d42 100644 --- a/spa/plugins/alsa/alsa-sink.c +++ b/spa/plugins/alsa/alsa-sink.c @@ -598,7 +598,9 @@ alsa_sink_clear (SpaHandle *handle) static SpaResult alsa_sink_init (const SpaHandleFactory *factory, SpaHandle *handle, - const SpaDict *info) + const SpaDict *info, + const SpaInterface **platform, + unsigned int n_platform) { SpaALSASink *this; diff --git a/spa/plugins/alsa/alsa-source.c b/spa/plugins/alsa/alsa-source.c index 6955ca9bb..8f3fa90ab 100644 --- a/spa/plugins/alsa/alsa-source.c +++ b/spa/plugins/alsa/alsa-source.c @@ -751,7 +751,9 @@ alsa_source_clear (SpaHandle *handle) static SpaResult alsa_source_init (const SpaHandleFactory *factory, SpaHandle *handle, - const SpaDict *info) + const SpaDict *info, + const SpaInterface **platform, + unsigned int n_platform) { SpaALSASource *this; unsigned int i; diff --git a/spa/plugins/audiomixer/audiomixer.c b/spa/plugins/audiomixer/audiomixer.c index 5d33fb76c..441c76edd 100644 --- a/spa/plugins/audiomixer/audiomixer.c +++ b/spa/plugins/audiomixer/audiomixer.c @@ -779,7 +779,9 @@ spa_audiomixer_clear (SpaHandle *handle) static SpaResult spa_audiomixer_init (const SpaHandleFactory *factory, SpaHandle *handle, - const SpaDict *info) + const SpaDict *info, + const SpaInterface **platform, + unsigned int n_platform) { SpaAudioMixer *this; diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c index 3dc65dcf4..357cc2f71 100644 --- a/spa/plugins/audiotestsrc/audiotestsrc.c +++ b/spa/plugins/audiotestsrc/audiotestsrc.c @@ -988,7 +988,9 @@ audiotestsrc_clear (SpaHandle *handle) static SpaResult audiotestsrc_init (const SpaHandleFactory *factory, SpaHandle *handle, - const SpaDict *info) + const SpaDict *info, + const SpaInterface **platform, + unsigned int n_platform) { SpaAudioTestSrc *this; diff --git a/spa/plugins/ffmpeg/ffmpeg.c b/spa/plugins/ffmpeg/ffmpeg.c index ec87d5fb5..4d6ddbb5e 100644 --- a/spa/plugins/ffmpeg/ffmpeg.c +++ b/spa/plugins/ffmpeg/ffmpeg.c @@ -31,7 +31,9 @@ SpaResult spa_ffmpeg_enc_init (SpaHandle *handle); static SpaResult ffmpeg_dec_init (const SpaHandleFactory *factory, SpaHandle *handle, - const SpaDict *info) + const SpaDict *info, + const SpaInterface **platform, + unsigned int n_platform) { if (factory == NULL || handle == NULL) return SPA_RESULT_INVALID_ARGUMENTS; @@ -42,7 +44,9 @@ ffmpeg_dec_init (const SpaHandleFactory *factory, static SpaResult ffmpeg_enc_init (const SpaHandleFactory *factory, SpaHandle *handle, - const SpaDict *info) + const SpaDict *info, + const SpaInterface **platform, + unsigned int n_platform) { if (factory == NULL || handle == NULL) return SPA_RESULT_INVALID_ARGUMENTS; diff --git a/spa/plugins/remote/proxy.c b/spa/plugins/remote/proxy.c index 68fa03ffe..aaaa5b426 100644 --- a/spa/plugins/remote/proxy.c +++ b/spa/plugins/remote/proxy.c @@ -1347,7 +1347,9 @@ proxy_clear (SpaHandle *handle) static SpaResult proxy_init (const SpaHandleFactory *factory, SpaHandle *handle, - const SpaDict *info) + const SpaDict *info, + const SpaInterface **platform, + unsigned int n_platform) { SpaProxy *this; diff --git a/spa/plugins/v4l2/v4l2-monitor.c b/spa/plugins/v4l2/v4l2-monitor.c index e6faf0280..3061dfd46 100644 --- a/spa/plugins/v4l2/v4l2-monitor.c +++ b/spa/plugins/v4l2/v4l2-monitor.c @@ -350,7 +350,9 @@ v4l2_monitor_clear (SpaHandle *handle) static SpaResult v4l2_monitor_init (const SpaHandleFactory *factory, SpaHandle *handle, - const SpaDict *info) + const SpaDict *info, + const SpaInterface **platform, + unsigned int n_platform) { SpaV4l2Monitor *this; diff --git a/spa/plugins/v4l2/v4l2-source.c b/spa/plugins/v4l2/v4l2-source.c index ac75ba801..143b365e0 100644 --- a/spa/plugins/v4l2/v4l2-source.c +++ b/spa/plugins/v4l2/v4l2-source.c @@ -28,6 +28,7 @@ #include #include #include +#include typedef struct _SpaV4l2Source SpaV4l2Source; @@ -111,6 +112,8 @@ typedef struct { SpaAllocParamMetaEnable param_meta; SpaPortStatus status; + SpaLog *log; + int64_t last_ticks; int64_t last_monotonic; } SpaV4l2State; @@ -827,7 +830,9 @@ v4l2_source_clear (SpaHandle *handle) static SpaResult v4l2_source_init (const SpaHandleFactory *factory, SpaHandle *handle, - const SpaDict *info) + const SpaDict *info, + const SpaInterface **platform, + unsigned int n_platform) { SpaV4l2Source *this; unsigned int i; @@ -849,6 +854,7 @@ v4l2_source_init (const SpaHandleFactory *factory, SPA_QUEUE_INIT (&this->state[0].ready); + this->state[0].log = NULL; this->state[0].info.flags = SPA_PORT_INFO_FLAG_LIVE; this->state[0].status.flags = SPA_PORT_STATUS_FLAG_NONE; diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c index 976ec0ca5..45fdf7cc3 100644 --- a/spa/plugins/v4l2/v4l2-utils.c +++ b/spa/plugins/v4l2/v4l2-utils.c @@ -32,27 +32,27 @@ spa_v4l2_open (SpaV4l2Source *this) return 0; if (props->props.unset_mask & 1) { - fprintf(stderr, "v4l2: Device property not set\n"); + spa_log_error (state->log, "v4l2: Device property not set\n"); return -1; } - fprintf (stderr, "v4l2: Playback device is '%s'\n", props->device); + spa_log_info (state->log, "v4l2: Playback device is '%s'\n", props->device); if (stat (props->device, &st) < 0) { - fprintf(stderr, "v4l2: Cannot identify '%s': %d, %s\n", + spa_log_error (state->log, "v4l2: Cannot identify '%s': %d, %s\n", props->device, errno, strerror (errno)); return -1; } if (!S_ISCHR (st.st_mode)) { - fprintf(stderr, "v4l2: %s is no device\n", props->device); + spa_log_error (state->log, "v4l2: %s is no device\n", props->device); return -1; } state->fd = open (props->device, O_RDWR | O_NONBLOCK, 0); if (state->fd == -1) { - fprintf (stderr, "v4l2: Cannot open '%s': %d, %s\n", + spa_log_error (state->log, "v4l2: Cannot open '%s': %d, %s\n", props->device, errno, strerror (errno)); return -1; } @@ -63,7 +63,7 @@ spa_v4l2_open (SpaV4l2Source *this) } if ((state->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) { - fprintf (stderr, "v4l2: %s is no video capture device\n", props->device); + spa_log_error (state->log, "v4l2: %s is no video capture device\n", props->device); return -1; } state->opened = true; @@ -103,7 +103,7 @@ spa_v4l2_clear_buffers (SpaV4l2Source *this) b = &state->buffers[i]; if (b->outstanding) { - fprintf (stderr, "v4l2: queueing outstanding buffer %p\n", b); + spa_log_info (state->log, "v4l2: queueing outstanding buffer %p\n", b); spa_v4l2_buffer_recycle (this, i); } if (b->allocated) { @@ -139,7 +139,7 @@ spa_v4l2_close (SpaV4l2Source *this) if (state->n_buffers > 0) return 0; - fprintf (stderr, "v4l2: close\n"); + spa_log_info (state->log, "v4l2: close\n"); if (close(state->fd)) perror ("close"); @@ -749,7 +749,7 @@ spa_v4l2_set_format (SpaV4l2Source *this, V4l2Format *f, bool try_only) f->format, 0); if (info == NULL) { - fprintf (stderr, "v4l2: unknown media type %d %d %d\n", f->fmt.media_type, + spa_log_error (state->log, "v4l2: unknown media type %d %d %d\n", f->fmt.media_type, f->fmt.media_subtype, f->format); return -1; } @@ -761,7 +761,7 @@ spa_v4l2_set_format (SpaV4l2Source *this, V4l2Format *f, bool try_only) streamparm.parm.capture.timeperframe.numerator = f->framerate.denom; streamparm.parm.capture.timeperframe.denominator = f->framerate.num; - fprintf (stderr, "v4l2: set %08x %dx%d %d/%d\n", fmt.fmt.pix.pixelformat, + spa_log_info (state->log, "v4l2: set %08x %dx%d %d/%d\n", fmt.fmt.pix.pixelformat, fmt.fmt.pix.width, fmt.fmt.pix.height, streamparm.parm.capture.timeperframe.numerator, streamparm.parm.capture.timeperframe.denominator); @@ -781,7 +781,7 @@ spa_v4l2_set_format (SpaV4l2Source *this, V4l2Format *f, bool try_only) if (xioctl (state->fd, VIDIOC_S_PARM, &streamparm) < 0) perror ("VIDIOC_S_PARM"); - fprintf (stderr, "v4l2: got %08x %dx%d %d/%d\n", fmt.fmt.pix.pixelformat, + spa_log_info (state->log, "v4l2: got %08x %dx%d %d/%d\n", fmt.fmt.pix.pixelformat, fmt.fmt.pix.width, fmt.fmt.pix.height, streamparm.parm.capture.timeperframe.numerator, streamparm.parm.capture.timeperframe.denominator); @@ -882,6 +882,9 @@ v4l2_on_fd_events (SpaPollNotifyData *data) if (data->fds[0].revents & POLLERR) return -1; + if (!(data->fds[0].revents & POLLIN)) + return 0; + if (mmap_read (this) < 0) return 0; @@ -912,7 +915,7 @@ spa_v4l2_use_buffers (SpaV4l2Source *this, SpaBuffer **buffers, uint32_t n_buffe state->memtype = V4L2_MEMORY_DMABUF; break; default: - fprintf (stderr, "v4l2: can't use buffers\n"); + spa_log_error (state->log, "v4l2: can't use buffers\n"); return SPA_RESULT_ERROR; } } @@ -926,9 +929,9 @@ spa_v4l2_use_buffers (SpaV4l2Source *this, SpaBuffer **buffers, uint32_t n_buffe perror ("VIDIOC_REQBUFS"); return SPA_RESULT_ERROR; } - fprintf (stderr, "v4l2: got %d buffers\n", reqbuf.count); + spa_log_info (state->log, "v4l2: got %d buffers\n", reqbuf.count); if (reqbuf.count < 2) { - fprintf (stderr, "v4l2: can't allocate enough buffers\n"); + spa_log_error (state->log, "v4l2: can't allocate enough buffers\n"); return SPA_RESULT_ERROR; } @@ -941,10 +944,10 @@ spa_v4l2_use_buffers (SpaV4l2Source *this, SpaBuffer **buffers, uint32_t n_buffe b->allocated = false; b->h = spa_buffer_find_meta (b->outbuf, SPA_META_TYPE_HEADER); - fprintf (stderr, "v4l2: import buffer %p\n", buffers[i]); + spa_log_info (state->log, "v4l2: import buffer %p\n", buffers[i]); if (buffers[i]->n_datas < 1) { - fprintf (stderr, "v4l2: invalid memory on buffer %p\n", buffers[i]); + spa_log_error (state->log, "v4l2: invalid memory on buffer %p\n", buffers[i]); continue; } d = buffers[i]->datas; @@ -957,7 +960,7 @@ spa_v4l2_use_buffers (SpaV4l2Source *this, SpaBuffer **buffers, uint32_t n_buffe case SPA_DATA_TYPE_MEMPTR: case SPA_DATA_TYPE_MEMFD: if (d[0].data == NULL) { - fprintf (stderr, "v4l2: need mmaped memory\n"); + spa_log_error (state->log, "v4l2: need mmaped memory\n"); continue; } b->v4l2_buffer.m.userptr = (unsigned long) SPA_MEMBER (d[0].data, d[0].offset, void *); @@ -999,22 +1002,22 @@ mmap_init (SpaV4l2Source *this, return SPA_RESULT_ERROR; } - fprintf (stderr, "v4l2: got %d buffers\n", reqbuf.count); + spa_log_info (state->log, "v4l2: got %d buffers\n", reqbuf.count); *n_buffers = reqbuf.count; if (reqbuf.count < 2) { - fprintf (stderr, "v4l2: can't allocate enough buffers\n"); + spa_log_error (state->log, "v4l2: can't allocate enough buffers\n"); return SPA_RESULT_ERROR; } if (state->export_buf) - fprintf (stderr, "v4l2: using EXPBUF\n"); + spa_log_info (state->log, "v4l2: using EXPBUF\n"); for (i = 0; i < reqbuf.count; i++) { V4l2Buffer *b; SpaData *d; if (buffers[i]->n_datas < 1) { - fprintf (stderr, "v4l2: invalid buffer data\n"); + spa_log_error (state->log, "v4l2: invalid buffer data\n"); return SPA_RESULT_ERROR; } diff --git a/spa/plugins/videotestsrc/videotestsrc.c b/spa/plugins/videotestsrc/videotestsrc.c index b59334358..456d0e8de 100644 --- a/spa/plugins/videotestsrc/videotestsrc.c +++ b/spa/plugins/videotestsrc/videotestsrc.c @@ -936,7 +936,9 @@ videotestsrc_clear (SpaHandle *handle) static SpaResult videotestsrc_init (const SpaHandleFactory *factory, SpaHandle *handle, - const SpaDict *info) + const SpaDict *info, + const SpaInterface **platform, + unsigned int n_platform) { SpaVideoTestSrc *this; diff --git a/spa/plugins/volume/volume.c b/spa/plugins/volume/volume.c index 7116cd6cc..142cedaf9 100644 --- a/spa/plugins/volume/volume.c +++ b/spa/plugins/volume/volume.c @@ -676,7 +676,9 @@ volume_clear (SpaHandle *handle) static SpaResult volume_init (const SpaHandleFactory *factory, SpaHandle *handle, - const SpaDict *info) + const SpaDict *info, + const SpaInterface **platform, + unsigned int n_platform) { SpaVolume *this; diff --git a/spa/plugins/xv/xv-sink.c b/spa/plugins/xv/xv-sink.c index bd25deef1..af6cc0580 100644 --- a/spa/plugins/xv/xv-sink.c +++ b/spa/plugins/xv/xv-sink.c @@ -557,7 +557,9 @@ xv_sink_clear (SpaHandle *handle) static SpaResult xv_sink_init (const SpaHandleFactory *factory, SpaHandle *handle, - const SpaDict *info) + const SpaDict *info, + const SpaInterface **platform, + unsigned int n_platform) { SpaXvSink *this; diff --git a/spa/tests/test-mixer.c b/spa/tests/test-mixer.c index d4506a82a..5ae8fe374 100644 --- a/spa/tests/test-mixer.c +++ b/spa/tests/test-mixer.c @@ -74,7 +74,7 @@ make_node (SpaNode **node, const char *lib, const char *name) continue; handle = calloc (1, factory->size); - if ((res = spa_handle_factory_init (factory, handle, NULL)) < 0) { + if ((res = spa_handle_factory_init (factory, handle, NULL, NULL, 0)) < 0) { printf ("can't make factory instance: %d\n", res); return res; } diff --git a/spa/tests/test-v4l2.c b/spa/tests/test-v4l2.c index 67eb12461..5230176e1 100644 --- a/spa/tests/test-v4l2.c +++ b/spa/tests/test-v4l2.c @@ -94,7 +94,7 @@ make_node (SpaNode **node, const char *lib, const char *name) continue; handle = calloc (1, factory->size); - if ((res = spa_handle_factory_init (factory, handle, NULL)) < 0) { + if ((res = spa_handle_factory_init (factory, handle, NULL, NULL, 0)) < 0) { printf ("can't make factory instance: %d\n", res); return res; } diff --git a/spa/tools/spa-inspect.c b/spa/tools/spa-inspect.c index c657a540b..d5a8d6d96 100644 --- a/spa/tools/spa-inspect.c +++ b/spa/tools/spa-inspect.c @@ -101,7 +101,7 @@ inspect_factory (const SpaHandleFactory *factory) printf (" none\n"); handle = calloc (1, factory->size); - if ((res = spa_handle_factory_init (factory, handle, NULL)) < 0) { + if ((res = spa_handle_factory_init (factory, handle, NULL, NULL, 0)) < 0) { printf ("can't make factory instance: %d\n", res); return; } diff --git a/spa/tools/spa-monitor.c b/spa/tools/spa-monitor.c index 47dabf3bc..19c9d4cd3 100644 --- a/spa/tools/spa-monitor.c +++ b/spa/tools/spa-monitor.c @@ -211,7 +211,7 @@ main (int argc, char *argv[]) void *interface; handle = calloc (1, factory->size); - if ((res = spa_handle_factory_init (factory, handle, NULL)) < 0) { + if ((res = spa_handle_factory_init (factory, handle, NULL, NULL, 0)) < 0) { printf ("can't make factory instance: %d\n", res); continue; }