mirror of https://github.com/thesofproject/sof.git
ipc4: (cosmetic) convert several if-else chains to switch-case
Where applicable, switch-case provides better readability than chained if-else, replace several such cases. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
parent
4a438b962b
commit
54455d592f
|
@ -250,50 +250,48 @@ static int set_pipeline_state(uint32_t id, uint32_t cmd, bool *delayed, uint32_t
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case SOF_IPC4_PIPELINE_STATE_RUNNING:
|
case SOF_IPC4_PIPELINE_STATE_RUNNING:
|
||||||
/* nothing to do if the pipeline is already running */
|
|
||||||
if (status == COMP_STATE_ACTIVE)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (status != COMP_STATE_PAUSED && status != COMP_STATE_READY) {
|
|
||||||
tr_err(&ipc_tr, "ipc: current status %d", status);
|
|
||||||
return IPC4_INVALID_REQUEST;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* init params when pipeline is complete or reset */
|
/* init params when pipeline is complete or reset */
|
||||||
if (status == COMP_STATE_READY) {
|
switch (status) {
|
||||||
|
case COMP_STATE_ACTIVE:
|
||||||
|
/* nothing to do if the pipeline is already running */
|
||||||
|
return 0;
|
||||||
|
case COMP_STATE_READY:
|
||||||
cmd = COMP_TRIGGER_PRE_START;
|
cmd = COMP_TRIGGER_PRE_START;
|
||||||
|
|
||||||
ret = ipc4_pcm_params(host);
|
ret = ipc4_pcm_params(host);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return IPC4_INVALID_REQUEST;
|
return IPC4_INVALID_REQUEST;
|
||||||
} else {
|
break;
|
||||||
|
case COMP_STATE_PAUSED:
|
||||||
cmd = COMP_TRIGGER_PRE_RELEASE;
|
cmd = COMP_TRIGGER_PRE_RELEASE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
tr_err(&ipc_tr, "ipc: current status %d", status);
|
||||||
|
return IPC4_INVALID_REQUEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case SOF_IPC4_PIPELINE_STATE_RESET:
|
case SOF_IPC4_PIPELINE_STATE_RESET:
|
||||||
if (status == COMP_STATE_INIT) {
|
switch (status) {
|
||||||
|
case COMP_STATE_INIT:
|
||||||
ret = ipc_pipeline_complete(ipc, id);
|
ret = ipc_pipeline_complete(ipc, id);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
ret = IPC4_INVALID_REQUEST;
|
ret = IPC4_INVALID_REQUEST;
|
||||||
|
|
||||||
*ppl_status = COMP_STATE_READY;
|
*ppl_status = COMP_STATE_READY;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
case COMP_STATE_READY:
|
||||||
|
|
||||||
/* initialized -> pause -> reset */
|
/* initialized -> pause -> reset */
|
||||||
if (status == COMP_STATE_READY)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
case COMP_STATE_ACTIVE:
|
||||||
if (status == COMP_STATE_ACTIVE || status == COMP_STATE_PAUSED) {
|
case COMP_STATE_PAUSED:
|
||||||
ret = pipeline_trigger(host->cd->pipeline, host->cd, COMP_TRIGGER_STOP);
|
ret = pipeline_trigger(host->cd->pipeline, host->cd, COMP_TRIGGER_STOP);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
tr_err(&ipc_tr, "ipc: comp %d trigger 0x%x failed %d",
|
tr_err(&ipc_tr, "ipc: comp %d trigger 0x%x failed %d",
|
||||||
id, cmd, ret);
|
id, cmd, ret);
|
||||||
return IPC4_PIPELINE_STATE_NOT_SET;
|
return IPC4_PIPELINE_STATE_NOT_SET;
|
||||||
} else if (ret == PPL_STATUS_SCHEDULED) {
|
|
||||||
*delayed = true;
|
|
||||||
}
|
}
|
||||||
|
if (ret == PPL_STATUS_SCHEDULED)
|
||||||
|
*delayed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -309,18 +307,19 @@ static int set_pipeline_state(uint32_t id, uint32_t cmd, bool *delayed, uint32_t
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
case SOF_IPC4_PIPELINE_STATE_PAUSED:
|
case SOF_IPC4_PIPELINE_STATE_PAUSED:
|
||||||
if (status == COMP_STATE_INIT) {
|
switch (status) {
|
||||||
|
case COMP_STATE_INIT:
|
||||||
ret = ipc_pipeline_complete(ipc, id);
|
ret = ipc_pipeline_complete(ipc, id);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
ret = IPC4_INVALID_REQUEST;
|
ret = IPC4_INVALID_REQUEST;
|
||||||
|
|
||||||
*ppl_status = COMP_STATE_READY;
|
*ppl_status = COMP_STATE_READY;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
case COMP_STATE_READY:
|
||||||
|
case COMP_STATE_PAUSED:
|
||||||
/* return if pipeline is not active yet or if it is already paused */
|
/* return if pipeline is not active yet or if it is already paused */
|
||||||
if (status == COMP_STATE_READY || status == COMP_STATE_PAUSED)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
cmd = COMP_TRIGGER_PAUSE;
|
cmd = COMP_TRIGGER_PAUSE;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue