diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-11-14 08:38:28 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-11-14 08:38:28 -0500 |
commit | 0c3c35e148dbc03106038dd25816fb9f3a084d86 (patch) | |
tree | 8b8cc6a027353a0f242f61362b35b0942da61b83 /sound/core | |
parent | 50d40f187f9182ee8caa1b83f80a0e11e2226baa (diff) | |
parent | 5e08fe570c2dbabb5015c37049eb9a451e55c890 (diff) |
Merge branch 'fix/misc' into topic/misc
Diffstat (limited to 'sound/core')
-rw-r--r-- | sound/core/rawmidi.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index c0adc14c91f0..70d6f25ba526 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c | |||
@@ -248,7 +248,8 @@ static int assign_substream(struct snd_rawmidi *rmidi, int subdevice, | |||
248 | list_for_each_entry(substream, &s->substreams, list) { | 248 | list_for_each_entry(substream, &s->substreams, list) { |
249 | if (substream->opened) { | 249 | if (substream->opened) { |
250 | if (stream == SNDRV_RAWMIDI_STREAM_INPUT || | 250 | if (stream == SNDRV_RAWMIDI_STREAM_INPUT || |
251 | !(mode & SNDRV_RAWMIDI_LFLG_APPEND)) | 251 | !(mode & SNDRV_RAWMIDI_LFLG_APPEND) || |
252 | !substream->append) | ||
252 | continue; | 253 | continue; |
253 | } | 254 | } |
254 | if (subdevice < 0 || subdevice == substream->number) { | 255 | if (subdevice < 0 || subdevice == substream->number) { |
@@ -266,17 +267,21 @@ static int open_substream(struct snd_rawmidi *rmidi, | |||
266 | { | 267 | { |
267 | int err; | 268 | int err; |
268 | 269 | ||
269 | err = snd_rawmidi_runtime_create(substream); | 270 | if (substream->use_count == 0) { |
270 | if (err < 0) | 271 | err = snd_rawmidi_runtime_create(substream); |
271 | return err; | 272 | if (err < 0) |
272 | err = substream->ops->open(substream); | 273 | return err; |
273 | if (err < 0) | 274 | err = substream->ops->open(substream); |
274 | return err; | 275 | if (err < 0) { |
275 | substream->opened = 1; | 276 | snd_rawmidi_runtime_free(substream); |
276 | if (substream->use_count++ == 0) | 277 | return err; |
278 | } | ||
279 | substream->opened = 1; | ||
277 | substream->active_sensing = 0; | 280 | substream->active_sensing = 0; |
278 | if (mode & SNDRV_RAWMIDI_LFLG_APPEND) | 281 | if (mode & SNDRV_RAWMIDI_LFLG_APPEND) |
279 | substream->append = 1; | 282 | substream->append = 1; |
283 | } | ||
284 | substream->use_count++; | ||
280 | rmidi->streams[substream->stream].substream_opened++; | 285 | rmidi->streams[substream->stream].substream_opened++; |
281 | return 0; | 286 | return 0; |
282 | } | 287 | } |
@@ -297,27 +302,27 @@ static int rawmidi_open_priv(struct snd_rawmidi *rmidi, int subdevice, int mode, | |||
297 | SNDRV_RAWMIDI_STREAM_INPUT, | 302 | SNDRV_RAWMIDI_STREAM_INPUT, |
298 | mode, &sinput); | 303 | mode, &sinput); |
299 | if (err < 0) | 304 | if (err < 0) |
300 | goto __error; | 305 | return err; |
301 | } | 306 | } |
302 | if (mode & SNDRV_RAWMIDI_LFLG_OUTPUT) { | 307 | if (mode & SNDRV_RAWMIDI_LFLG_OUTPUT) { |
303 | err = assign_substream(rmidi, subdevice, | 308 | err = assign_substream(rmidi, subdevice, |
304 | SNDRV_RAWMIDI_STREAM_OUTPUT, | 309 | SNDRV_RAWMIDI_STREAM_OUTPUT, |
305 | mode, &soutput); | 310 | mode, &soutput); |
306 | if (err < 0) | 311 | if (err < 0) |
307 | goto __error; | 312 | return err; |
308 | } | 313 | } |
309 | 314 | ||
310 | if (sinput) { | 315 | if (sinput) { |
311 | err = open_substream(rmidi, sinput, mode); | 316 | err = open_substream(rmidi, sinput, mode); |
312 | if (err < 0) | 317 | if (err < 0) |
313 | goto __error; | 318 | return err; |
314 | } | 319 | } |
315 | if (soutput) { | 320 | if (soutput) { |
316 | err = open_substream(rmidi, soutput, mode); | 321 | err = open_substream(rmidi, soutput, mode); |
317 | if (err < 0) { | 322 | if (err < 0) { |
318 | if (sinput) | 323 | if (sinput) |
319 | close_substream(rmidi, sinput, 0); | 324 | close_substream(rmidi, sinput, 0); |
320 | goto __error; | 325 | return err; |
321 | } | 326 | } |
322 | } | 327 | } |
323 | 328 | ||
@@ -325,13 +330,6 @@ static int rawmidi_open_priv(struct snd_rawmidi *rmidi, int subdevice, int mode, | |||
325 | rfile->input = sinput; | 330 | rfile->input = sinput; |
326 | rfile->output = soutput; | 331 | rfile->output = soutput; |
327 | return 0; | 332 | return 0; |
328 | |||
329 | __error: | ||
330 | if (sinput && sinput->runtime) | ||
331 | snd_rawmidi_runtime_free(sinput); | ||
332 | if (soutput && soutput->runtime) | ||
333 | snd_rawmidi_runtime_free(soutput); | ||
334 | return err; | ||
335 | } | 333 | } |
336 | 334 | ||
337 | /* called from sound/core/seq/seq_midi.c */ | 335 | /* called from sound/core/seq/seq_midi.c */ |