OSDN Git Service
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>