mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
stream: add flush and drain command
This commit is contained in:
parent
754782f302
commit
9dba8f3a36
3 changed files with 41 additions and 5 deletions
|
|
@ -233,10 +233,10 @@ static inline void
|
||||||
spa_graph_node_add(struct spa_graph *graph,
|
spa_graph_node_add(struct spa_graph *graph,
|
||||||
struct spa_graph_node *node)
|
struct spa_graph_node *node)
|
||||||
{
|
{
|
||||||
|
spa_debug("node %p add to graph %p", node, graph);
|
||||||
node->graph = graph;
|
node->graph = graph;
|
||||||
spa_list_append(&graph->nodes, &node->link);
|
spa_list_append(&graph->nodes, &node->link);
|
||||||
spa_graph_link_add(node, graph->state, &node->graph_link);
|
spa_graph_link_add(node, graph->state, &node->graph_link);
|
||||||
spa_debug("node %p add to graph %p", node, graph);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void spa_graph_node_remove(struct spa_graph_node *node)
|
static inline void spa_graph_node_remove(struct spa_graph_node *node)
|
||||||
|
|
|
||||||
|
|
@ -1223,3 +1223,32 @@ int pw_stream_queue_buffer(struct pw_stream *stream, struct pw_buffer *buffer)
|
||||||
|
|
||||||
return call_trigger(impl);
|
return call_trigger(impl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
do_flush(struct spa_loop *loop,
|
||||||
|
bool async, uint32_t seq, const void *data, size_t size, void *user_data)
|
||||||
|
{
|
||||||
|
struct stream *impl = user_data;
|
||||||
|
struct buffer *b;
|
||||||
|
|
||||||
|
pw_log_trace("stream %p: flush", impl);
|
||||||
|
do {
|
||||||
|
b = pop_queue(impl, &impl->queued);
|
||||||
|
if (b != NULL)
|
||||||
|
push_queue(impl, &impl->dequeued, b);
|
||||||
|
}
|
||||||
|
while (b);
|
||||||
|
|
||||||
|
impl->time.queued = impl->queued.outcount = impl->dequeued.incount =
|
||||||
|
impl->dequeued.outcount = impl->queued.incount;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int pw_stream_flush(struct pw_stream *stream, bool drain)
|
||||||
|
{
|
||||||
|
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
|
||||||
|
pw_loop_invoke(impl->core->data_loop,
|
||||||
|
do_flush, 1, NULL, 0, true, impl);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,8 @@ struct pw_buffer {
|
||||||
* returned in the time info. */
|
* returned in the time info. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Events for a stream */
|
/** Events for a stream. These events are always called from the mainloop
|
||||||
|
* unless explicitly documented otherwise. */
|
||||||
struct pw_stream_events {
|
struct pw_stream_events {
|
||||||
#define PW_VERSION_STREAM_EVENTS 0
|
#define PW_VERSION_STREAM_EVENTS 0
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
|
|
@ -197,6 +198,9 @@ struct pw_stream_events {
|
||||||
* mainloop but can also be called directly from the realtime data
|
* mainloop but can also be called directly from the realtime data
|
||||||
* thread if the user is prepared to deal with this. */
|
* thread if the user is prepared to deal with this. */
|
||||||
void (*process) (void *data);
|
void (*process) (void *data);
|
||||||
|
|
||||||
|
/** The stream is drained */
|
||||||
|
void (*drained) (void *data);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Convert a stream state to a readable string \memberof pw_stream */
|
/** Convert a stream state to a readable string \memberof pw_stream */
|
||||||
|
|
@ -307,9 +311,6 @@ int pw_stream_set_control(struct pw_stream *stream, const char *name, float valu
|
||||||
/** Get a control value */
|
/** Get a control value */
|
||||||
int pw_stream_get_control(struct pw_stream *stream, const char *name, float *value);
|
int pw_stream_get_control(struct pw_stream *stream, const char *name, float *value);
|
||||||
|
|
||||||
/** Activate or deactivate the stream \memberof pw_stream */
|
|
||||||
int pw_stream_set_active(struct pw_stream *stream, bool active);
|
|
||||||
|
|
||||||
/** A time structure \memberof pw_stream */
|
/** A time structure \memberof pw_stream */
|
||||||
struct pw_time {
|
struct pw_time {
|
||||||
int64_t now; /**< the monotonic time */
|
int64_t now; /**< the monotonic time */
|
||||||
|
|
@ -333,6 +334,12 @@ struct pw_buffer *pw_stream_dequeue_buffer(struct pw_stream *stream);
|
||||||
/** Submit a buffer for playback or recycle a buffer for capture. */
|
/** Submit a buffer for playback or recycle a buffer for capture. */
|
||||||
int pw_stream_queue_buffer(struct pw_stream *stream, struct pw_buffer *buffer);
|
int pw_stream_queue_buffer(struct pw_stream *stream, struct pw_buffer *buffer);
|
||||||
|
|
||||||
|
/** Activate or deactivate the stream \memberof pw_stream */
|
||||||
|
int pw_stream_set_active(struct pw_stream *stream, bool active);
|
||||||
|
|
||||||
|
/** Flush a stream. When \a drain is true, the drained callback will
|
||||||
|
* be called when all data is played or recorded */
|
||||||
|
int pw_stream_flush(struct pw_stream *stream, bool drain);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue