mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
improve states
This commit is contained in:
parent
e92e1acec4
commit
fd5f0d96f3
5 changed files with 21 additions and 14 deletions
|
|
@ -45,8 +45,6 @@ typedef struct _PinosLinkInfo PinosLinkInfo;
|
||||||
* @PINOS_NODE_STATE_CREATING: the node is being created
|
* @PINOS_NODE_STATE_CREATING: the node is being created
|
||||||
* @PINOS_NODE_STATE_SUSPENDED: the node is suspended, the device might
|
* @PINOS_NODE_STATE_SUSPENDED: the node is suspended, the device might
|
||||||
* be closed
|
* be closed
|
||||||
* @PINOS_NODE_STATE_INITIALIZING: the node is initializing, the device is
|
|
||||||
* being opened and the capabilities are queried
|
|
||||||
* @PINOS_NODE_STATE_IDLE: the node is running but there is no active
|
* @PINOS_NODE_STATE_IDLE: the node is running but there is no active
|
||||||
* port
|
* port
|
||||||
* @PINOS_NODE_STATE_RUNNING: the node is running
|
* @PINOS_NODE_STATE_RUNNING: the node is running
|
||||||
|
|
|
||||||
|
|
@ -924,22 +924,24 @@ do_link_remove_done (SpaLoop *loop,
|
||||||
spa_list_remove (&this->input_link);
|
spa_list_remove (&this->input_link);
|
||||||
this->input->node->n_used_input_links--;
|
this->input->node->n_used_input_links--;
|
||||||
|
|
||||||
|
clear_port_buffers (this, this->input);
|
||||||
|
|
||||||
if (this->input->node->n_used_input_links == 0 &&
|
if (this->input->node->n_used_input_links == 0 &&
|
||||||
this->input->node->n_used_output_links == 0)
|
this->input->node->n_used_output_links == 0)
|
||||||
pinos_node_set_state (this->input->node, PINOS_NODE_STATE_IDLE);
|
pinos_node_set_state (this->input->node, PINOS_NODE_STATE_IDLE);
|
||||||
|
|
||||||
clear_port_buffers (this, this->input);
|
|
||||||
this->input = NULL;
|
this->input = NULL;
|
||||||
}
|
}
|
||||||
if (this->output) {
|
if (this->output) {
|
||||||
spa_list_remove (&this->output_link);
|
spa_list_remove (&this->output_link);
|
||||||
this->output->node->n_used_output_links--;
|
this->output->node->n_used_output_links--;
|
||||||
|
|
||||||
|
clear_port_buffers (this, this->output);
|
||||||
|
|
||||||
if (this->output->node->n_used_input_links == 0 &&
|
if (this->output->node->n_used_input_links == 0 &&
|
||||||
this->output->node->n_used_output_links == 0)
|
this->output->node->n_used_output_links == 0)
|
||||||
pinos_node_set_state (this->output->node, PINOS_NODE_STATE_IDLE);
|
pinos_node_set_state (this->output->node, PINOS_NODE_STATE_IDLE);
|
||||||
|
|
||||||
clear_port_buffers (this, this->output);
|
|
||||||
this->output = NULL;
|
this->output = NULL;
|
||||||
}
|
}
|
||||||
if (--impl->refcount == 0)
|
if (--impl->refcount == 0)
|
||||||
|
|
|
||||||
|
|
@ -162,8 +162,10 @@ pause_node (PinosNode *this)
|
||||||
SpaResult res;
|
SpaResult res;
|
||||||
SpaNodeCommand cmd;
|
SpaNodeCommand cmd;
|
||||||
|
|
||||||
pinos_log_debug ("node %p: pause node", this);
|
if (this->node->state <= SPA_NODE_STATE_PAUSED)
|
||||||
|
return SPA_RESULT_OK;
|
||||||
|
|
||||||
|
pinos_log_debug ("node %p: pause node", this);
|
||||||
cmd.type = SPA_NODE_COMMAND_PAUSE;
|
cmd.type = SPA_NODE_COMMAND_PAUSE;
|
||||||
cmd.size = sizeof (cmd);
|
cmd.size = sizeof (cmd);
|
||||||
if ((res = spa_node_send_command (this->node, &cmd)) < 0)
|
if ((res = spa_node_send_command (this->node, &cmd)) < 0)
|
||||||
|
|
@ -179,7 +181,6 @@ start_node (PinosNode *this)
|
||||||
SpaNodeCommand cmd;
|
SpaNodeCommand cmd;
|
||||||
|
|
||||||
pinos_log_debug ("node %p: start node", this);
|
pinos_log_debug ("node %p: start node", this);
|
||||||
|
|
||||||
cmd.type = SPA_NODE_COMMAND_START;
|
cmd.type = SPA_NODE_COMMAND_START;
|
||||||
cmd.size = sizeof (cmd);
|
cmd.size = sizeof (cmd);
|
||||||
if ((res = spa_node_send_command (this->node, &cmd)) < 0)
|
if ((res = spa_node_send_command (this->node, &cmd)) < 0)
|
||||||
|
|
|
||||||
|
|
@ -243,11 +243,6 @@ do_remove_link_done (SpaLoop *loop,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node->n_used_output_links == 0 &&
|
|
||||||
node->n_used_input_links == 0) {
|
|
||||||
pinos_node_update_state (node, PINOS_NODE_STATE_IDLE, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!port->allocated) {
|
if (!port->allocated) {
|
||||||
pinos_log_debug ("port %p: clear buffers on port", port);
|
pinos_log_debug ("port %p: clear buffers on port", port);
|
||||||
spa_node_port_use_buffers (port->node->node,
|
spa_node_port_use_buffers (port->node->node,
|
||||||
|
|
@ -258,6 +253,11 @@ do_remove_link_done (SpaLoop *loop,
|
||||||
port->n_buffers = 0;
|
port->n_buffers = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (node->n_used_output_links == 0 &&
|
||||||
|
node->n_used_input_links == 0) {
|
||||||
|
pinos_node_update_state (node, PINOS_NODE_STATE_IDLE, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
return SPA_RESULT_OK;
|
return SPA_RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -166,16 +166,22 @@ spa_alsa_set_format (SpaALSAState *state, SpaFormatAudio *fmt, SpaPortFormatFlag
|
||||||
state->frame_size = info->channels * 2;
|
state->frame_size = info->channels * 2;
|
||||||
|
|
||||||
period_size = props->period_size;
|
period_size = props->period_size;
|
||||||
CHECK (snd_pcm_hw_params_set_period_size_near (hndl, params, &period_size, &dir), "set_period_size");
|
periods = props->periods;
|
||||||
|
|
||||||
|
spa_log_info (state->log, "trying period frames %zd and periods %u", period_size, periods);
|
||||||
|
|
||||||
|
dir = 0;
|
||||||
|
CHECK (snd_pcm_hw_params_set_period_size_near (hndl, params, &period_size, &dir), "set_period_size_near");
|
||||||
state->period_frames = period_size;
|
state->period_frames = period_size;
|
||||||
|
|
||||||
periods = props->periods;
|
dir = 0;
|
||||||
CHECK (snd_pcm_hw_params_set_periods_near (hndl, params, &periods, &dir), "set_periods_near");
|
CHECK (snd_pcm_hw_params_set_periods_near (hndl, params, &periods, &dir), "set_periods_near");
|
||||||
state->buffer_frames = periods * state->period_frames;
|
state->buffer_frames = periods * state->period_frames;
|
||||||
|
|
||||||
CHECK (snd_pcm_hw_params_set_buffer_size (hndl, params, state->buffer_frames), "set_buffer_size");
|
CHECK (snd_pcm_hw_params_set_buffer_size (hndl, params, state->buffer_frames), "set_buffer_size");
|
||||||
|
|
||||||
spa_log_info (state->log, "buffer frames %zd, period frames %zd", state->buffer_frames, state->period_frames);
|
spa_log_info (state->log, "buffer frames %zd, period frames %zd, periods %u",
|
||||||
|
state->buffer_frames, state->period_frames, periods);
|
||||||
|
|
||||||
/* write the parameters to device */
|
/* write the parameters to device */
|
||||||
CHECK (snd_pcm_hw_params (hndl, params), "set_hw_params");
|
CHECK (snd_pcm_hw_params (hndl, params), "set_hw_params");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue