#include <stdio.h>
#include <errno.h>
#include <math.h>
#include <signal.h>
#define M_PI_M2 ( M_PI + M_PI )
#define DEFAULT_RATE 44100
#define DEFAULT_FREQ 440
#define DEFAULT_VOLUME 0.7
struct data;
struct port {
struct data *data;
double accumulator;
};
struct data {
struct port *out_port;
};
{
struct data *data = userdata;
float *out;
struct port *out_port = data->out_port;
if (out == NULL)
return;
for (i = 0; i < n_samples; i++) {
out_port->accumulator += M_PI_M2 * DEFAULT_FREQ / DEFAULT_RATE;
if (out_port->accumulator >= M_PI_M2)
out_port->accumulator -= M_PI_M2;
*out++ = sin(out_port->accumulator) * DEFAULT_VOLUME;
}
}
.process = on_process,
};
static void do_quit(void *userdata, int signal_number)
{
struct data *data = userdata;
}
int main(int argc, char *argv[])
{
struct data data = { 0, };
"audio-dsp-src",
NULL),
&filter_events,
&data);
sizeof(struct port),
NULL),
NULL, 0);
NULL, 0) < 0) {
fprintf(stderr, "can't connect\n");
return -1;
}
return 0;
}
int pw_filter_connect(struct pw_filter *filter, enum pw_filter_flags flags, const struct spa_pod **params, uint32_t n_params)
Connect a filter for processing.
Definition filter.c:1590
void * pw_filter_add_port(struct pw_filter *filter, enum pw_direction direction, enum pw_filter_port_flags flags, size_t port_data_size, struct pw_properties *props, const struct spa_pod **params, uint32_t n_params)
add a port to the filter, returns user data of port_data_size.
Definition filter.c:1820
#define PW_VERSION_FILTER_EVENTS
Definition filter.h:66
void pw_filter_destroy(struct pw_filter *filter)
Destroy a filter
Definition filter.c:1427
void * pw_filter_get_dsp_buffer(void *port_data, uint32_t n_samples)
Get a data pointer to the buffer data.
Definition filter.c:2025
struct pw_filter * pw_filter_new_simple(struct pw_loop *loop, const char *name, struct pw_properties *props, const struct pw_filter_events *events, void *data)
Definition filter.c:1323
@ PW_FILTER_FLAG_RT_PROCESS
call process from the realtime thread
Definition filter.h:108
@ PW_FILTER_PORT_FLAG_MAP_BUFFERS
mmap the buffers except DmaBuf that is not explicitly marked as mappable.
Definition filter.h:129
#define PW_KEY_PORT_NAME
port name
Definition keys.h:282
#define PW_KEY_MEDIA_TYPE
Media.
Definition keys.h:438
#define PW_KEY_NODE_AUTOCONNECT
node wants to be automatically connected to a compatible node
Definition keys.h:207
#define PW_KEY_MEDIA_ROLE
Role: Movie, Music, Camera, Screen, Communication, Game, Notification, DSP, Production,...
Definition keys.h:444
#define PW_KEY_MEDIA_CATEGORY
Media Category: Playback, Capture, Duplex, Monitor, Manager.
Definition keys.h:441
#define PW_KEY_FORMAT_DSP
format related properties
Definition keys.h:479
#define PW_KEY_MEDIA_CLASS
class Ex: "Video/Source"
Definition keys.h:449
#define pw_log_trace(...)
Definition log.h:182
#define pw_loop_add_signal(l,...)
Definition loop.h:65
int pw_main_loop_quit(struct pw_main_loop *loop)
Quit a main loop.
Definition main-loop.c:106
void pw_main_loop_destroy(struct pw_main_loop *loop)
Destroy a loop.
Definition main-loop.c:71
int pw_main_loop_run(struct pw_main_loop *loop)
Run a main loop.
Definition main-loop.c:120
struct pw_main_loop * pw_main_loop_new(const struct spa_dict *props)
Create a new main loop.
Definition main-loop.c:61
struct pw_loop * pw_main_loop_get_loop(struct pw_main_loop *loop)
Get the loop implementation.
Definition main-loop.c:94
void pw_init(int *argc, char **argv[])
Initialize PipeWire.
Definition pipewire.c:489
void pw_deinit(void)
Deinitialize PipeWire.
Definition pipewire.c:601
#define PW_DIRECTION_OUTPUT
Definition port.h:50
struct pw_properties * pw_properties_new(const char *key,...)
Make a new properties object.
Definition properties.c:85
Events for a filter.
Definition filter.h:64
uint64_t duration
Duration of current cycle, in samples @ rate.
Definition io.h:151
The position information adds extra meaning to the raw clock times.
Definition io.h:307
struct spa_io_clock clock
clock position of driver, always valid and read only
Definition io.h:308