filter: remove some unused code

Add some SPA_LIKELY
This commit is contained in:
Wim Taymans 2023-05-05 21:33:28 +02:00
parent 4b5b94303e
commit f5a10cb734

View file

@ -46,8 +46,6 @@ struct buffer {
struct queue { struct queue {
uint32_t ids[MAX_BUFFERS]; uint32_t ids[MAX_BUFFERS];
struct spa_ringbuffer ring; struct spa_ringbuffer ring;
uint64_t incount;
uint64_t outcount;
}; };
struct data { struct data {
@ -327,7 +325,6 @@ static inline int push_queue(struct port *port, struct queue *queue, struct buff
return -EINVAL; return -EINVAL;
SPA_FLAG_SET(buffer->flags, BUFFER_FLAG_QUEUED); SPA_FLAG_SET(buffer->flags, BUFFER_FLAG_QUEUED);
queue->incount += buffer->this.size;
spa_ringbuffer_get_write_index(&queue->ring, &index); spa_ringbuffer_get_write_index(&queue->ring, &index);
queue->ids[index & MASK_BUFFERS] = buffer->id; queue->ids[index & MASK_BUFFERS] = buffer->id;
@ -350,7 +347,6 @@ static inline struct buffer *pop_queue(struct port *port, struct queue *queue)
spa_ringbuffer_read_update(&queue->ring, index + 1); spa_ringbuffer_read_update(&queue->ring, index + 1);
buffer = &port->buffers[id]; buffer = &port->buffers[id];
queue->outcount += buffer->this.size;
SPA_FLAG_CLEAR(buffer->flags, BUFFER_FLAG_QUEUED); SPA_FLAG_CLEAR(buffer->flags, BUFFER_FLAG_QUEUED);
return buffer; return buffer;
@ -359,7 +355,6 @@ static inline struct buffer *pop_queue(struct port *port, struct queue *queue)
static inline void clear_queue(struct port *port, struct queue *queue) static inline void clear_queue(struct port *port, struct queue *queue)
{ {
spa_ringbuffer_init(&queue->ring); spa_ringbuffer_init(&queue->ring);
queue->incount = queue->outcount;
} }
static bool filter_set_state(struct pw_filter *filter, enum pw_filter_state state, const char *error) static bool filter_set_state(struct pw_filter *filter, enum pw_filter_state state, const char *error)
@ -1929,13 +1924,13 @@ struct pw_buffer *pw_filter_dequeue_buffer(void *port_data)
struct buffer *b; struct buffer *b;
int res; int res;
if ((b = pop_queue(p, &p->dequeued)) == NULL) { if (SPA_UNLIKELY((b = pop_queue(p, &p->dequeued)) == NULL)) {
res = -errno; res = -errno;
pw_log_trace("%p: no more buffers: %m", impl); pw_log_debug("%p: no more buffers: %m", impl);
errno = -res; errno = -res;
return NULL; return NULL;
} }
pw_log_trace("%p: dequeue buffer %d", impl, b->id); pw_log_trace_fp("%p: dequeue buffer %d", impl, b->id);
return &b->this; return &b->this;
} }
@ -1944,15 +1939,9 @@ SPA_EXPORT
int pw_filter_queue_buffer(void *port_data, struct pw_buffer *buffer) int pw_filter_queue_buffer(void *port_data, struct pw_buffer *buffer)
{ {
struct port *p = SPA_CONTAINER_OF(port_data, struct port, user_data); struct port *p = SPA_CONTAINER_OF(port_data, struct port, user_data);
struct filter *impl = p->filter;
struct buffer *b = SPA_CONTAINER_OF(buffer, struct buffer, this); struct buffer *b = SPA_CONTAINER_OF(buffer, struct buffer, this);
int res; pw_log_trace_fp("%p: queue buffer %d", impl, b->id);
return push_queue(p, &p->queued, b);
pw_log_trace("%p: queue buffer %d", impl, b->id);
if ((res = push_queue(p, &p->queued, b)) < 0)
return res;
return res;
} }
SPA_EXPORT SPA_EXPORT
@ -1962,7 +1951,7 @@ void *pw_filter_get_dsp_buffer(void *port_data, uint32_t n_samples)
struct pw_buffer *buf; struct pw_buffer *buf;
struct spa_data *d; struct spa_data *d;
if ((buf = pw_filter_dequeue_buffer(port_data)) == NULL) if (SPA_UNLIKELY((buf = pw_filter_dequeue_buffer(port_data)) == NULL))
return NULL; return NULL;
d = &buf->buffer->datas[0]; d = &buf->buffer->datas[0];
@ -1973,7 +1962,6 @@ void *pw_filter_get_dsp_buffer(void *port_data, uint32_t n_samples)
d->chunk->stride = sizeof(float); d->chunk->stride = sizeof(float);
d->chunk->flags = 0; d->chunk->flags = 0;
} }
pw_filter_queue_buffer(port_data, buf); pw_filter_queue_buffer(port_data, buf);
return d->data; return d->data;
@ -1994,10 +1982,6 @@ do_flush(struct spa_loop *loop,
push_queue(impl, &impl->dequeued, b); push_queue(impl, &impl->dequeued, b);
} }
while (b); while (b);
impl->time.queued = impl->queued.outcount = impl->dequeued.incount =
impl->dequeued.outcount = impl->queued.incount;
#endif #endif
return 0; return 0;
} }