diff options
author | Takashi Iwai <tiwai@suse.de> | 2013-11-26 09:02:44 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-11-26 09:02:44 +0100 |
commit | 0f9ab27ec5627283e7b343cada0026efc626f55d (patch) | |
tree | aa43752ef839b6e3d3139d643941a1c9ddf54a61 | |
parent | 6f8996f655eacbd8355984332d24bc8fe5b2d27e (diff) | |
download | hda-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.c | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -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 |