aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2013-11-26 09:02:44 +0100
committerTakashi Iwai <tiwai@suse.de>2013-11-26 09:02:44 +0100
commit0f9ab27ec5627283e7b343cada0026efc626f55d (patch)
treeaa43752ef839b6e3d3139d643941a1c9ddf54a61
parent6f8996f655eacbd8355984332d24bc8fe5b2d27e (diff)
downloadhda-emu-0f9ab27ec5627283e7b343cada0026efc626f55d.tar.gz
Do proper error handling at PCM test
When something wrong happens during PCM operation, properly close and manage refcounts instead of just powering down and returning.
-rw-r--r--hda-emu.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/hda-emu.c b/hda-emu.c
index 45b9fda..7a262ec 100644
--- a/hda-emu.c
+++ b/hda-emu.c
@@ -767,8 +767,7 @@ void hda_test_pcm(int id, int op, int subid,
err = hinfo->ops.open(hinfo, _codec, substream);
if (err < 0) {
hda_log(HDA_LOG_INFO, "Open error = %d\n", err);
- snd_hda_power_down(_codec);
- return;
+ goto powerdown;
}
hda_log(HDA_LOG_INFO, "Available PCM parameters:\n");
@@ -794,8 +793,7 @@ void hda_test_pcm(int id, int op, int subid,
channels > runtime->hw.channels_max) {
hda_log(HDA_LOG_ERR, "Channels count (%d) not available for %s\n",
channels, (dir ? "capture" : "playback"));
- snd_hda_power_down(_codec);
- return;
+ goto closing;
}
hda_log(HDA_LOG_INFO, "Prepare PCM, rate=%d, channels=%d, "
"format=%d bits\n",
@@ -807,10 +805,9 @@ void hda_test_pcm(int id, int op, int subid,
, ctls
#endif
);
- if (!format_val) {
- snd_hda_power_down(_codec);
- return;
- }
+ if (!format_val)
+ goto closing;
+
hda_log(HDA_LOG_INFO, "PCM format_val = 0x%x\n", format_val);
#ifdef HAVE_COMMON_PREPARE
err = snd_hda_codec_prepare(_codec, hinfo, subid + 1,
@@ -827,9 +824,17 @@ void hda_test_pcm(int id, int op, int subid,
#else
hinfo->ops.cleanup(hinfo, _codec, substream);
#endif
+ }
+
+ closing:
+ if (op != PCM_TEST_START) {
substream->ref_count = 0;
hda_log(HDA_LOG_INFO, "Close PCM\n");
hinfo->ops.close(hinfo, _codec, substream);
+ }
+
+ powerdown:
+ if (op != PCM_TEST_START) {
snd_hda_power_down(_codec);
#ifdef HAVE_HDA_ATTACH_PCM