mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
Add logger
Add logger interface Make it possible to pass extra interfaces to the element at init time, such as a logger.
This commit is contained in:
parent
e90c53e48d
commit
49dae17dfb
26 changed files with 251 additions and 47 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include <spa/video/format.h>
|
||||
#include <spa/debug.h>
|
||||
#include <spa/queue.h>
|
||||
#include <spa/log.h>
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue