spa: add and use spa_overflow macros

This commit is contained in:
Wim Taymans 2026-04-24 15:54:15 +02:00
parent 84f8230a47
commit 0f8d5c6e57
16 changed files with 149 additions and 50 deletions

View file

@ -39,6 +39,7 @@
#include <bluetooth/bluetooth.h>
#include <spa/utils/defs.h>
#include <spa/utils/overflow.h>
#include <spa/support/log.h>
#include "rate-control.h"
@ -107,9 +108,12 @@ static inline int spa_bt_decode_buffer_init(struct spa_bt_decode_buffer *this, s
this->frame_size = frame_size;
this->rate = rate;
this->log = log;
this->buffer_reserve = this->frame_size * reserve;
this->buffer_size = this->frame_size * quantum_limit * 2;
this->buffer_size += this->buffer_reserve;
if (spa_overflow_mul(this->frame_size, reserve, &this->buffer_reserve))
return -ENOMEM;
if (spa_overflow_mul(this->frame_size, quantum_limit, &this->buffer_size) ||
spa_overflow_mul(this->buffer_size, 2u, &this->buffer_size) ||
spa_overflow_add(this->buffer_size, this->buffer_reserve, &this->buffer_size))
return -ENOMEM;
this->corr = 1.0;
this->prev_match_rate = 1.0;
this->target = 0;