mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-16 08:56:45 -05:00
bluez5: protect against NULL transport
The transport can be destroyed at any time, make sure we don't crash when it does.
This commit is contained in:
parent
4c80656a7b
commit
c4cf5e6629
4 changed files with 49 additions and 30 deletions
|
|
@ -361,6 +361,8 @@ static int send_buffer(struct impl *this)
|
|||
struct rtp_header *header;
|
||||
struct rtp_payload *payload;
|
||||
|
||||
spa_return_val_if_fail(this->transport, -EIO);
|
||||
|
||||
header = (struct rtp_header *)this->buffer;
|
||||
payload = (struct rtp_payload *)(this->buffer + sizeof(struct rtp_header));
|
||||
memset(this->buffer, 0, sizeof(struct rtp_header)+sizeof(struct rtp_payload));
|
||||
|
|
@ -487,6 +489,8 @@ static int set_bitpool(struct impl *this, int bitpool)
|
|||
{
|
||||
struct port *port = &this->port;
|
||||
|
||||
spa_return_val_if_fail(this->transport, -EIO);
|
||||
|
||||
if (bitpool < this->min_bitpool)
|
||||
bitpool = this->min_bitpool;
|
||||
if (bitpool > this->max_bitpool)
|
||||
|
|
@ -715,7 +719,11 @@ static void a2dp_on_timeout(struct spa_source *source)
|
|||
static int init_sbc(struct impl *this)
|
||||
{
|
||||
struct spa_bt_transport *transport = this->transport;
|
||||
a2dp_sbc_t *conf = transport->configuration;
|
||||
a2dp_sbc_t *conf;
|
||||
|
||||
spa_return_val_if_fail(transport, -EIO);
|
||||
|
||||
conf = transport->configuration;
|
||||
|
||||
sbc_init(&this->sbc, 0);
|
||||
this->sbc.endian = SBC_LE;
|
||||
|
|
@ -797,6 +805,8 @@ static int do_start(struct impl *this)
|
|||
if (this->started)
|
||||
return 0;
|
||||
|
||||
spa_return_val_if_fail(this->transport, -EIO);
|
||||
|
||||
this->following = is_following(this);
|
||||
|
||||
spa_log_debug(this->log, NAME " %p: start following:%d", this, this->following);
|
||||
|
|
@ -1039,6 +1049,8 @@ impl_node_port_enum_params(void *object, int seq,
|
|||
case SPA_PARAM_EnumFormat:
|
||||
if (result.index > 0)
|
||||
return 0;
|
||||
if (this->transport == NULL)
|
||||
return -EIO;
|
||||
|
||||
switch (this->transport->codec) {
|
||||
case A2DP_CODEC_SBC:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue