mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
Add flags to set_format
Use flags to control the behaviour of set_format Move poll into separate file
This commit is contained in:
parent
b9320c67c2
commit
96df59274c
11 changed files with 146 additions and 97 deletions
|
|
@ -27,6 +27,7 @@ extern "C" {
|
|||
typedef struct _SpaEvent SpaEvent;
|
||||
|
||||
#include <spa/defs.h>
|
||||
#include <spa/poll.h>
|
||||
|
||||
/**
|
||||
* SpaEventType:
|
||||
|
|
@ -35,10 +36,11 @@ typedef struct _SpaEvent SpaEvent;
|
|||
* @SPA_EVENT_TYPE_STOPPED: emited when the STOP command completes
|
||||
* @SPA_EVENT_TYPE_CAN_PULL_OUTPUT: emited when an async node has output that can be pulled
|
||||
* @SPA_EVENT_TYPE_CAN_PUSH_INPUT: emited when more data can be pushed to an async node
|
||||
* @SPA_EVENT_TYPE_PULL_INPUT: emited when data needs to be provided on an input
|
||||
* @SPA_EVENT_TYPE_PULL_INPUT: emited when data needs to be provided on an input. data points to
|
||||
* buffer to fill.
|
||||
* @SPA_EVENT_TYPE_ALLOC_OUTPUT: emited when an output buffer needs to be allocated
|
||||
* @SPA_EVENT_TYPE_ADD_POLL: emited when a pollfd should be added
|
||||
* @SPA_EVENT_TYPE_REMOVE_POLL: emited when a pollfd should be removed
|
||||
* @SPA_EVENT_TYPE_ADD_POLL: emited when a pollfd should be added. data points to #SpaPollItem
|
||||
* @SPA_EVENT_TYPE_REMOVE_POLL: emited when a pollfd should be removed. data points to #SpaPollItem
|
||||
* @SPA_EVENT_TYPE_DRAINED: emited when DRAIN command completed
|
||||
* @SPA_EVENT_TYPE_MARKER: emited when MARK command completed
|
||||
* @SPA_EVENT_TYPE_ERROR: emited when error occured
|
||||
|
|
@ -69,55 +71,6 @@ struct _SpaEvent {
|
|||
size_t size;
|
||||
};
|
||||
|
||||
/**
|
||||
* SpaPollFd:
|
||||
* @fd: a file descriptor
|
||||
* @events: events to watch
|
||||
* @revents: events after poll
|
||||
*/
|
||||
typedef struct {
|
||||
int fd;
|
||||
short events;
|
||||
short revents;
|
||||
} SpaPollFd;
|
||||
|
||||
|
||||
/**
|
||||
* SpaPollNotifyData:
|
||||
* @user_data: user data
|
||||
* @fds: array of file descriptors
|
||||
* @n_fds: number of elements in @fds
|
||||
* @now: the current time
|
||||
* @timeout: the next desired wakeup time relative to @now
|
||||
*
|
||||
* Data passed to #SpaPollNotify.
|
||||
*/
|
||||
typedef struct {
|
||||
void *user_data;
|
||||
SpaPollFd *fds;
|
||||
unsigned int n_fds;
|
||||
uint64_t now;
|
||||
uint64_t timeout;
|
||||
} SpaPollNotifyData;
|
||||
|
||||
typedef int (*SpaPollNotify) (SpaPollNotifyData *data);
|
||||
|
||||
/**
|
||||
* SpaPollItem:
|
||||
* @fds: array of file descriptors to watch
|
||||
* @n_fds: number of elements in @fds
|
||||
* @callback: callback called when there was activity on any of @fds
|
||||
* @user_data: user data
|
||||
*/
|
||||
typedef struct {
|
||||
SpaPollFd *fds;
|
||||
unsigned int n_fds;
|
||||
SpaPollNotify idle_cb;
|
||||
SpaPollNotify before_cb;
|
||||
SpaPollNotify after_cb;
|
||||
void *user_data;
|
||||
} SpaPollItem;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -35,6 +35,21 @@ typedef struct _SpaNode SpaNode;
|
|||
#include <spa/command.h>
|
||||
#include <spa/format.h>
|
||||
|
||||
/**
|
||||
* SpaPortFormatFlags:
|
||||
* @SPA_PORT_FORMAT_FLAG_NONE: no flags
|
||||
* @SPA_PORT_FORMAT_FLAG_TEST_ONLY: just check if the format is accepted
|
||||
* @SPA_PORT_FORMAT_FLAG_FIXATE: fixate the non-optional unset fields
|
||||
* @SPA_PORT_FORMAT_FLAG_NEAREST: allow set fields to be rounded to the
|
||||
* nearest allowed field value.
|
||||
*/
|
||||
typedef enum {
|
||||
SPA_PORT_FORMAT_FLAG_NONE = 0,
|
||||
SPA_PORT_FORMAT_FLAG_TEST_ONLY = (1 << 0),
|
||||
SPA_PORT_FORMAT_FLAG_FIXATE = (1 << 1),
|
||||
SPA_PORT_FORMAT_FLAG_NEAREST = (1 << 2),
|
||||
} SpaPortFormatFlags;
|
||||
|
||||
/**
|
||||
* SpaInputFlags:
|
||||
* @SPA_INPUT_FLAG_NONE: no flag
|
||||
|
|
@ -267,7 +282,7 @@ struct _SpaNode {
|
|||
* SpaNode::port_set_format:
|
||||
* @handle: a #SpaHandle
|
||||
* @port_id: the port to configure
|
||||
* @test_only: only check if the format is accepted
|
||||
* @flags: flags
|
||||
* @format: a #SpaFormat with the format
|
||||
*
|
||||
* Set a format on @port_id of @node.
|
||||
|
|
@ -283,10 +298,10 @@ struct _SpaNode {
|
|||
* #SPA_RESULT_WRONG_PROPERTY_TYPE when the type or size of a property
|
||||
* is not correct.
|
||||
*/
|
||||
SpaResult (*port_set_format) (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
bool test_only,
|
||||
const SpaFormat *format);
|
||||
SpaResult (*port_set_format) (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
SpaPortFormatFlags flags,
|
||||
const SpaFormat *format);
|
||||
/**
|
||||
* SpaNode::port_get_format:
|
||||
* @handle: a #SpaHandle
|
||||
|
|
|
|||
83
spa/include/spa/poll.h
Normal file
83
spa/include/spa/poll.h
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/* Simple Plugin API
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* 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_POLL_H__
|
||||
#define __SPA_POLL_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _SpaEvent SpaEvent;
|
||||
|
||||
#include <spa/defs.h>
|
||||
|
||||
/**
|
||||
* SpaPollFd:
|
||||
* @fd: a file descriptor
|
||||
* @events: events to watch
|
||||
* @revents: events after poll
|
||||
*/
|
||||
typedef struct {
|
||||
int fd;
|
||||
short events;
|
||||
short revents;
|
||||
} SpaPollFd;
|
||||
|
||||
/**
|
||||
* SpaPollNotifyData:
|
||||
* @user_data: user data
|
||||
* @fds: array of file descriptors
|
||||
* @n_fds: number of elements in @fds
|
||||
* @now: the current time
|
||||
* @timeout: the next desired wakeup time relative to @now
|
||||
*
|
||||
* Data passed to #SpaPollNotify.
|
||||
*/
|
||||
typedef struct {
|
||||
void *user_data;
|
||||
SpaPollFd *fds;
|
||||
unsigned int n_fds;
|
||||
uint64_t now;
|
||||
uint64_t timeout;
|
||||
} SpaPollNotifyData;
|
||||
|
||||
typedef int (*SpaPollNotify) (SpaPollNotifyData *data);
|
||||
|
||||
/**
|
||||
* SpaPollItem:
|
||||
* @fds: array of file descriptors to watch
|
||||
* @n_fds: number of elements in @fds
|
||||
* @callback: callback called when there was activity on any of @fds
|
||||
* @user_data: user data
|
||||
*/
|
||||
typedef struct {
|
||||
SpaPollFd *fds;
|
||||
unsigned int n_fds;
|
||||
SpaPollNotify idle_cb;
|
||||
SpaPollNotify before_cb;
|
||||
SpaPollNotify after_cb;
|
||||
void *user_data;
|
||||
} SpaPollItem;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_POLL_H__ */
|
||||
|
|
@ -365,10 +365,10 @@ spa_alsa_sink_node_port_enum_formats (SpaHandle *handle,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_port_set_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
bool test_only,
|
||||
const SpaFormat *format)
|
||||
spa_alsa_sink_node_port_set_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
SpaPortFormatFlags flags,
|
||||
const SpaFormat *format)
|
||||
{
|
||||
SpaALSASink *this = (SpaALSASink *) handle;
|
||||
SpaResult res;
|
||||
|
|
@ -387,8 +387,6 @@ spa_alsa_sink_node_port_set_format (SpaHandle *handle,
|
|||
if ((res = spa_audio_raw_format_parse (format, &this->current_format)) < 0)
|
||||
return res;
|
||||
|
||||
printf ("format %d\n", this->current_format.info.rate);
|
||||
|
||||
this->have_format = true;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
|
|||
|
|
@ -330,10 +330,10 @@ spa_audiomixer_node_port_enum_formats (SpaHandle *handle,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiomixer_node_port_set_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
bool test_only,
|
||||
const SpaFormat *format)
|
||||
spa_audiomixer_node_port_set_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
SpaPortFormatFlags flags,
|
||||
const SpaFormat *format)
|
||||
{
|
||||
SpaAudioMixer *this = (SpaAudioMixer *) handle;
|
||||
SpaResult res;
|
||||
|
|
|
|||
|
|
@ -307,10 +307,10 @@ spa_audiotestsrc_node_port_enum_formats (SpaHandle *handle,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiotestsrc_node_port_set_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
bool test_only,
|
||||
const SpaFormat *format)
|
||||
spa_audiotestsrc_node_port_set_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
SpaPortFormatFlags flags,
|
||||
const SpaFormat *format)
|
||||
{
|
||||
SpaAudioTestSrc *this = (SpaAudioTestSrc *) handle;
|
||||
SpaResult res;
|
||||
|
|
|
|||
|
|
@ -278,10 +278,10 @@ spa_ffmpeg_dec_node_port_enum_formats (SpaHandle *handle,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_ffmpeg_dec_node_port_set_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
bool test_only,
|
||||
const SpaFormat *format)
|
||||
spa_ffmpeg_dec_node_port_set_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
SpaPortFormatFlags flags,
|
||||
const SpaFormat *format)
|
||||
{
|
||||
SpaFFMpegDec *this = (SpaFFMpegDec *) handle;
|
||||
SpaFFMpegState *state;
|
||||
|
|
@ -315,7 +315,7 @@ spa_ffmpeg_dec_node_port_set_format (SpaHandle *handle,
|
|||
} else
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
if (!test_only) {
|
||||
if (!(flags & SPA_PORT_FORMAT_FLAG_TEST_ONLY)) {
|
||||
memcpy (tf, f, fs);
|
||||
state->current_format = tf;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -278,10 +278,10 @@ spa_ffmpeg_enc_node_port_enum_formats (SpaHandle *handle,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_ffmpeg_enc_node_port_set_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
bool test_only,
|
||||
const SpaFormat *format)
|
||||
spa_ffmpeg_enc_node_port_set_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
SpaPortFormatFlags flags,
|
||||
const SpaFormat *format)
|
||||
{
|
||||
SpaFFMpegEnc *this = (SpaFFMpegEnc *) handle;
|
||||
SpaFFMpegState *state;
|
||||
|
|
@ -315,7 +315,7 @@ spa_ffmpeg_enc_node_port_set_format (SpaHandle *handle,
|
|||
} else
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
if (!test_only) {
|
||||
if (!(flags & SPA_PORT_FORMAT_FLAG_TEST_ONLY)) {
|
||||
memcpy (tf, f, fs);
|
||||
state->current_format = tf;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -331,10 +331,10 @@ spa_v4l2_source_node_port_enum_formats (SpaHandle *handle,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_v4l2_source_node_port_set_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
bool test_only,
|
||||
const SpaFormat *format)
|
||||
spa_v4l2_source_node_port_set_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
SpaPortFormatFlags flags,
|
||||
const SpaFormat *format)
|
||||
{
|
||||
SpaV4l2Source *this = (SpaV4l2Source *) handle;
|
||||
SpaV4l2State *state;
|
||||
|
|
@ -368,10 +368,10 @@ spa_v4l2_source_node_port_set_format (SpaHandle *handle,
|
|||
} else
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
if (spa_v4l2_set_format (this, f, test_only) < 0)
|
||||
if (spa_v4l2_set_format (this, f, flags & SPA_PORT_FORMAT_FLAG_TEST_ONLY) < 0)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
if (!test_only) {
|
||||
if (!(flags & SPA_PORT_FORMAT_FLAG_TEST_ONLY)) {
|
||||
memcpy (tf, f, fs);
|
||||
state->current_format = tf;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -288,10 +288,10 @@ spa_volume_node_port_enum_formats (SpaHandle *handle,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_volume_node_port_set_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
bool test_only,
|
||||
const SpaFormat *format)
|
||||
spa_volume_node_port_set_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
SpaPortFormatFlags flags,
|
||||
const SpaFormat *format)
|
||||
{
|
||||
SpaVolume *this = (SpaVolume *) handle;
|
||||
SpaResult res;
|
||||
|
|
|
|||
|
|
@ -317,10 +317,10 @@ spa_xv_sink_node_port_enum_formats (SpaHandle *handle,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_port_set_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
bool test_only,
|
||||
const SpaFormat *format)
|
||||
spa_xv_sink_node_port_set_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
SpaPortFormatFlags flags,
|
||||
const SpaFormat *format)
|
||||
{
|
||||
SpaXvSink *this = (SpaXvSink *) handle;
|
||||
SpaResult res;
|
||||
|
|
@ -351,10 +351,10 @@ spa_xv_sink_node_port_set_format (SpaHandle *handle,
|
|||
} else
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
if (spa_xv_set_format (this, f, test_only) < 0)
|
||||
if (spa_xv_set_format (this, f, flags & SPA_PORT_FORMAT_FLAG_TEST_ONLY) < 0)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
if (!test_only) {
|
||||
if (!(flags & SPA_PORT_FORMAT_FLAG_TEST_ONLY)) {
|
||||
memcpy (tf, f, fs);
|
||||
this->current_format = tf;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue