From 3bf75f9b90c981f18f27a0d35a44f488ab68c8ea Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 27 Mar 2006 16:40:49 +0200 Subject: [ALSA] Clean up PCM codes (take 2) - Clean up initialization and destruction of substream instance Now snd_pcm_open_substream() alone does most initialization jobs. Add pcm_release callback for cleaning up at snd_pcm_release_substream() - Tidy up PCM oss code Signed-off-by: Takashi Iwai --- sound/core/pcm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sound/core/pcm.c') diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 1e9878fed37f..5d7eb123b999 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -777,8 +777,9 @@ static void snd_pcm_tick_timer_func(unsigned long data) snd_pcm_tick_elapsed(substream); } -int snd_pcm_open_substream(struct snd_pcm *pcm, int stream, - struct snd_pcm_substream **rsubstream) +int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream, + struct file *file, + struct snd_pcm_substream **rsubstream) { struct snd_pcm_str * pstr; struct snd_pcm_substream *substream; @@ -793,7 +794,7 @@ int snd_pcm_open_substream(struct snd_pcm *pcm, int stream, *rsubstream = NULL; snd_assert(pcm != NULL, return -ENXIO); pstr = &pcm->streams[stream]; - if (pstr->substream == NULL) + if (pstr->substream == NULL || pstr->substream_count == 0) return -ENODEV; card = pcm->card; @@ -807,8 +808,6 @@ int snd_pcm_open_substream(struct snd_pcm *pcm, int stream, } up_read(&card->controls_rwsem); - if (pstr->substream_count == 0) - return -ENODEV; switch (stream) { case SNDRV_PCM_STREAM_PLAYBACK: if (pcm->info_flags & SNDRV_PCM_INFO_HALF_DUPLEX) { @@ -874,12 +873,13 @@ int snd_pcm_open_substream(struct snd_pcm *pcm, int stream, substream->runtime = runtime; substream->private_data = pcm->private_data; + substream->ffile = file; pstr->substream_opened++; *rsubstream = substream; return 0; } -void snd_pcm_release_substream(struct snd_pcm_substream *substream) +void snd_pcm_detach_substream(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime; substream->file = NULL; -- cgit v1.2.3-59-g8ed1b