filter: add event to notify command

All commands send to the filter are emited in the command event.
This commit is contained in:
Wim Taymans 2021-10-19 15:27:14 +02:00
parent dfa3f631ec
commit 34609389e3
3 changed files with 8 additions and 3 deletions

View file

@ -506,6 +506,7 @@ static int impl_send_command(void *object, const struct spa_command *command)
switch (SPA_NODE_COMMAND_ID(command)) { switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Suspend: case SPA_NODE_COMMAND_Suspend:
case SPA_NODE_COMMAND_Flush:
case SPA_NODE_COMMAND_Pause: case SPA_NODE_COMMAND_Pause:
pw_loop_invoke(impl->context->main_loop, pw_loop_invoke(impl->context->main_loop,
NULL, 0, NULL, 0, false, impl); NULL, 0, NULL, 0, false, impl);
@ -521,10 +522,9 @@ static int impl_send_command(void *object, const struct spa_command *command)
} }
break; break;
default: default:
pw_log_warn("%p: unhandled node command %d", filter,
SPA_NODE_COMMAND_ID(command));
break; break;
} }
pw_filter_emit_command(filter, command);
return 0; return 0;
} }

View file

@ -76,7 +76,7 @@ struct pw_buffer {
/** Events for a filter. These events are always called from the mainloop /** Events for a filter. These events are always called from the mainloop
* unless explicitly documented otherwise. */ * unless explicitly documented otherwise. */
struct pw_filter_events { struct pw_filter_events {
#define PW_VERSION_FILTER_EVENTS 0 #define PW_VERSION_FILTER_EVENTS 1
uint32_t version; uint32_t version;
void (*destroy) (void *data); void (*destroy) (void *data);
@ -103,6 +103,9 @@ struct pw_filter_events {
/** The filter is drained */ /** The filter is drained */
void (*drained) (void *data); void (*drained) (void *data);
/** A command notify, Since 0.3.39:1 */
void (*command) (void *data, const struct spa_command *command);
}; };
/** Convert a filter state to a readable string */ /** Convert a filter state to a readable string */

View file

@ -1003,6 +1003,7 @@ struct pw_core {
#define pw_stream_emit_process(s) pw_stream_emit(s, process, 0) #define pw_stream_emit_process(s) pw_stream_emit(s, process, 0)
#define pw_stream_emit_drained(s) pw_stream_emit(s, drained,0) #define pw_stream_emit_drained(s) pw_stream_emit(s, drained,0)
#define pw_stream_emit_control_info(s,i,c) pw_stream_emit(s, control_info, 0, i, c) #define pw_stream_emit_control_info(s,i,c) pw_stream_emit(s, control_info, 0, i, c)
#define pw_stream_emit_command(s,c) pw_stream_emit(s, command,1,c)
struct pw_stream { struct pw_stream {
@ -1038,6 +1039,7 @@ struct pw_stream {
#define pw_filter_emit_remove_buffer(s,p,b) pw_filter_emit(s, remove_buffer, 0, p, b) #define pw_filter_emit_remove_buffer(s,p,b) pw_filter_emit(s, remove_buffer, 0, p, b)
#define pw_filter_emit_process(s,p) pw_filter_emit(s, process, 0, p) #define pw_filter_emit_process(s,p) pw_filter_emit(s, process, 0, p)
#define pw_filter_emit_drained(s) pw_filter_emit(s, drained, 0) #define pw_filter_emit_drained(s) pw_filter_emit(s, drained, 0)
#define pw_filter_emit_command(s,c) pw_filter_emit(s, command, 1, c)
struct pw_filter { struct pw_filter {