OSDN Git Service

pcm: Return the consistent error code for unexpected PCM states
authorTakashi Iwai <tiwai@suse.de>
Wed, 17 Jan 2018 14:57:20 +0000 (15:57 +0100)
committerTakashi Iwai <tiwai@suse.de>
Thu, 18 Jan 2018 09:11:59 +0000 (10:11 +0100)
commit6e555781259281e31f8b5dc518a317511d67bbd8
treed8854e68e985174b0fb46397cea9ddbdf77044f9
parent60ed28999a272e1a3d737a9eeee0719b98efd447
pcm: Return the consistent error code for unexpected PCM states

Some PCM functions have the sanity check of the expected PCM states,
and most of them return -EBADFD if the current state doesn't match.
This is bad for some programs like aplay that expect the function
returning a proper code corresponding to the state, e.g. -ESTRPIPE for
the suspend.

This patch is an attempt to address such inconsistencies.  The sanity
checker bad_pcm_state() now returns the error code instead of bool, so
that the caller can pass the returned code as is.  And it calls a new
helper, pcm_state_to_error(), for obtaining the error code to certain
known PCM error state.

While we're at it, use the new pcm_state_to_error() for simplifying
the existing code to retrieve the error code, too.

Tested-by: Mirza Krak <mirza.krak@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/pcm/pcm.c