mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
alsa-compress-offload-sink: Fix format renegotation
The have_format flag was not being properly processed, leading to incorrect behavior when the format param was enumerated.
This commit is contained in:
parent
de2d7a583b
commit
d20fc2a8ec
1 changed files with 22 additions and 8 deletions
|
|
@ -510,6 +510,8 @@ static void device_close(struct impl *this)
|
||||||
this->device_context = NULL;
|
this->device_context = NULL;
|
||||||
this->device_started = false;
|
this->device_started = false;
|
||||||
this->device_is_paused = false;
|
this->device_is_paused = false;
|
||||||
|
|
||||||
|
this->have_format = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int device_start(struct impl *this)
|
static int device_start(struct impl *this)
|
||||||
|
|
@ -919,11 +921,6 @@ static int do_start(struct impl *this)
|
||||||
if (this->started)
|
if (this->started)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!this->have_format)
|
|
||||||
return -EIO;
|
|
||||||
if (this->n_buffers == 0)
|
|
||||||
return -EIO;
|
|
||||||
|
|
||||||
this->following = is_following(this);
|
this->following = is_following(this);
|
||||||
spa_log_debug(this->log, "%p: starting output; starting as follower: %d",
|
spa_log_debug(this->log, "%p: starting output; starting as follower: %d",
|
||||||
this, this->following);
|
this, this->following);
|
||||||
|
|
@ -1357,8 +1354,14 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SPA_NODE_COMMAND_Start:
|
case SPA_NODE_COMMAND_Start:
|
||||||
|
if (!this->have_format)
|
||||||
|
return -EIO;
|
||||||
|
if (this->n_buffers == 0)
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
if (SPA_UNLIKELY((res = do_start(this)) < 0))
|
if (SPA_UNLIKELY((res = do_start(this)) < 0))
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SPA_NODE_COMMAND_Suspend:
|
case SPA_NODE_COMMAND_Suspend:
|
||||||
|
|
@ -1403,6 +1406,12 @@ static int port_enum_formats(struct impl *this, int seq, uint32_t start, uint32_
|
||||||
"device opened: %d have configured format: %d device started: %d",
|
"device opened: %d have configured format: %d device started: %d",
|
||||||
this, device_opened, this->have_format, device_started);
|
this, device_opened, this->have_format, device_started);
|
||||||
|
|
||||||
|
if (!this->started && this->have_format) {
|
||||||
|
spa_log_debug(this->log, "%p: closing device to reset configured format", this);
|
||||||
|
device_close(this);
|
||||||
|
device_opened = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!device_opened) {
|
if (!device_opened) {
|
||||||
if ((res = device_open(this)) < 0)
|
if ((res = device_open(this)) < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
@ -1487,11 +1496,18 @@ next:
|
||||||
return port_enum_formats(this, seq, start, num, filter, &b);
|
return port_enum_formats(this, seq, start, num, filter, &b);
|
||||||
|
|
||||||
case SPA_PARAM_Format:
|
case SPA_PARAM_Format:
|
||||||
if (!this->have_format)
|
if (!this->have_format) {
|
||||||
|
spa_log_debug(this->log, "%p: attempted to enumerate current "
|
||||||
|
"format, but no current audio info set", this);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
if (result.index > 0)
|
if (result.index > 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
spa_log_debug(this->log, "%p: current audio info is set; "
|
||||||
|
"enumerating currently set format", this);
|
||||||
|
|
||||||
param = spa_format_audio_build(&b, id, &this->current_audio_info);
|
param = spa_format_audio_build(&b, id, &this->current_audio_info);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -1557,8 +1573,6 @@ static int port_set_format(void *object,
|
||||||
spa_log_debug(this->log, "%p: clearing format and closing device", this);
|
spa_log_debug(this->log, "%p: clearing format and closing device", this);
|
||||||
device_close(this);
|
device_close(this);
|
||||||
clear_buffers(this);
|
clear_buffers(this);
|
||||||
|
|
||||||
this->have_format = false;
|
|
||||||
} else {
|
} else {
|
||||||
struct spa_audio_info info = { 0 };
|
struct spa_audio_info info = { 0 };
|
||||||
uint32_t rate;
|
uint32_t rate;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue