aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/pcm.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2006-03-27 09:40:49 -0500
committerJaroslav Kysela <perex@suse.cz>2006-03-31 10:58:59 -0500
commit3bf75f9b90c981f18f27a0d35a44f488ab68c8ea (patch)
tree9284c90f09ce38fc3bb2ebc46624ddf3db09b526 /sound/core/pcm.c
parentbf1bbb5a49eec51c30d341606885507b501b37e8 (diff)
[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 <tiwai@suse.de>
Diffstat (limited to 'sound/core/pcm.c')
-rw-r--r--sound/core/pcm.c12
1 files changed, 6 insertions, 6 deletions
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)
777 snd_pcm_tick_elapsed(substream); 777 snd_pcm_tick_elapsed(substream);
778} 778}
779 779
780int snd_pcm_open_substream(struct snd_pcm *pcm, int stream, 780int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
781 struct snd_pcm_substream **rsubstream) 781 struct file *file,
782 struct snd_pcm_substream **rsubstream)
782{ 783{
783 struct snd_pcm_str * pstr; 784 struct snd_pcm_str * pstr;
784 struct snd_pcm_substream *substream; 785 struct snd_pcm_substream *substream;
@@ -793,7 +794,7 @@ int snd_pcm_open_substream(struct snd_pcm *pcm, int stream,
793 *rsubstream = NULL; 794 *rsubstream = NULL;
794 snd_assert(pcm != NULL, return -ENXIO); 795 snd_assert(pcm != NULL, return -ENXIO);
795 pstr = &pcm->streams[stream]; 796 pstr = &pcm->streams[stream];
796 if (pstr->substream == NULL) 797 if (pstr->substream == NULL || pstr->substream_count == 0)
797 return -ENODEV; 798 return -ENODEV;
798 799
799 card = pcm->card; 800 card = pcm->card;
@@ -807,8 +808,6 @@ int snd_pcm_open_substream(struct snd_pcm *pcm, int stream,
807 } 808 }
808 up_read(&card->controls_rwsem); 809 up_read(&card->controls_rwsem);
809 810
810 if (pstr->substream_count == 0)
811 return -ENODEV;
812 switch (stream) { 811 switch (stream) {
813 case SNDRV_PCM_STREAM_PLAYBACK: 812 case SNDRV_PCM_STREAM_PLAYBACK:
814 if (pcm->info_flags & SNDRV_PCM_INFO_HALF_DUPLEX) { 813 if (pcm->info_flags & SNDRV_PCM_INFO_HALF_DUPLEX) {
@@ -874,12 +873,13 @@ int snd_pcm_open_substream(struct snd_pcm *pcm, int stream,
874 873
875 substream->runtime = runtime; 874 substream->runtime = runtime;
876 substream->private_data = pcm->private_data; 875 substream->private_data = pcm->private_data;
876 substream->ffile = file;
877 pstr->substream_opened++; 877 pstr->substream_opened++;
878 *rsubstream = substream; 878 *rsubstream = substream;
879 return 0; 879 return 0;
880} 880}
881 881
882void snd_pcm_release_substream(struct snd_pcm_substream *substream) 882void snd_pcm_detach_substream(struct snd_pcm_substream *substream)
883{ 883{
884 struct snd_pcm_runtime *runtime; 884 struct snd_pcm_runtime *runtime;
885 substream->file = NULL; 885 substream->file = NULL;