diff options
Diffstat (limited to 'sound/core/pcm.c')
-rw-r--r-- | sound/core/pcm.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 8e980aa678d0..89c7485519cb 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c | |||
@@ -31,13 +31,17 @@ | |||
31 | #include <sound/control.h> | 31 | #include <sound/control.h> |
32 | #include <sound/info.h> | 32 | #include <sound/info.h> |
33 | 33 | ||
34 | #include "pcm_local.h" | ||
35 | |||
34 | MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, Abramo Bagnara <abramo@alsa-project.org>"); | 36 | MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, Abramo Bagnara <abramo@alsa-project.org>"); |
35 | MODULE_DESCRIPTION("Midlevel PCM code for ALSA."); | 37 | MODULE_DESCRIPTION("Midlevel PCM code for ALSA."); |
36 | MODULE_LICENSE("GPL"); | 38 | MODULE_LICENSE("GPL"); |
37 | 39 | ||
38 | static LIST_HEAD(snd_pcm_devices); | 40 | static LIST_HEAD(snd_pcm_devices); |
39 | static LIST_HEAD(snd_pcm_notify_list); | ||
40 | static DEFINE_MUTEX(register_mutex); | 41 | static DEFINE_MUTEX(register_mutex); |
42 | #if IS_ENABLED(CONFIG_SND_PCM_OSS) | ||
43 | static LIST_HEAD(snd_pcm_notify_list); | ||
44 | #endif | ||
41 | 45 | ||
42 | static int snd_pcm_free(struct snd_pcm *pcm); | 46 | static int snd_pcm_free(struct snd_pcm *pcm); |
43 | static int snd_pcm_dev_free(struct snd_device *device); | 47 | static int snd_pcm_dev_free(struct snd_device *device); |
@@ -884,16 +888,23 @@ static void snd_pcm_free_stream(struct snd_pcm_str * pstr) | |||
884 | put_device(&pstr->dev); | 888 | put_device(&pstr->dev); |
885 | } | 889 | } |
886 | 890 | ||
891 | #if IS_ENABLED(CONFIG_SND_PCM_OSS) | ||
892 | #define pcm_call_notify(pcm, call) \ | ||
893 | do { \ | ||
894 | struct snd_pcm_notify *_notify; \ | ||
895 | list_for_each_entry(_notify, &snd_pcm_notify_list, list) \ | ||
896 | _notify->call(pcm); \ | ||
897 | } while (0) | ||
898 | #else | ||
899 | #define pcm_call_notify(pcm, call) do {} while (0) | ||
900 | #endif | ||
901 | |||
887 | static int snd_pcm_free(struct snd_pcm *pcm) | 902 | static int snd_pcm_free(struct snd_pcm *pcm) |
888 | { | 903 | { |
889 | struct snd_pcm_notify *notify; | ||
890 | |||
891 | if (!pcm) | 904 | if (!pcm) |
892 | return 0; | 905 | return 0; |
893 | if (!pcm->internal) { | 906 | if (!pcm->internal) |
894 | list_for_each_entry(notify, &snd_pcm_notify_list, list) | 907 | pcm_call_notify(pcm, n_unregister); |
895 | notify->n_unregister(pcm); | ||
896 | } | ||
897 | if (pcm->private_free) | 908 | if (pcm->private_free) |
898 | pcm->private_free(pcm); | 909 | pcm->private_free(pcm); |
899 | snd_pcm_lib_preallocate_free_for_all(pcm); | 910 | snd_pcm_lib_preallocate_free_for_all(pcm); |
@@ -1056,7 +1067,7 @@ static struct attribute *pcm_dev_attrs[] = { | |||
1056 | NULL | 1067 | NULL |
1057 | }; | 1068 | }; |
1058 | 1069 | ||
1059 | static struct attribute_group pcm_dev_attr_group = { | 1070 | static const struct attribute_group pcm_dev_attr_group = { |
1060 | .attrs = pcm_dev_attrs, | 1071 | .attrs = pcm_dev_attrs, |
1061 | }; | 1072 | }; |
1062 | 1073 | ||
@@ -1069,7 +1080,6 @@ static int snd_pcm_dev_register(struct snd_device *device) | |||
1069 | { | 1080 | { |
1070 | int cidx, err; | 1081 | int cidx, err; |
1071 | struct snd_pcm_substream *substream; | 1082 | struct snd_pcm_substream *substream; |
1072 | struct snd_pcm_notify *notify; | ||
1073 | struct snd_pcm *pcm; | 1083 | struct snd_pcm *pcm; |
1074 | 1084 | ||
1075 | if (snd_BUG_ON(!device || !device->device_data)) | 1085 | if (snd_BUG_ON(!device || !device->device_data)) |
@@ -1107,8 +1117,7 @@ static int snd_pcm_dev_register(struct snd_device *device) | |||
1107 | snd_pcm_timer_init(substream); | 1117 | snd_pcm_timer_init(substream); |
1108 | } | 1118 | } |
1109 | 1119 | ||
1110 | list_for_each_entry(notify, &snd_pcm_notify_list, list) | 1120 | pcm_call_notify(pcm, n_register); |
1111 | notify->n_register(pcm); | ||
1112 | 1121 | ||
1113 | unlock: | 1122 | unlock: |
1114 | mutex_unlock(®ister_mutex); | 1123 | mutex_unlock(®ister_mutex); |
@@ -1118,7 +1127,6 @@ static int snd_pcm_dev_register(struct snd_device *device) | |||
1118 | static int snd_pcm_dev_disconnect(struct snd_device *device) | 1127 | static int snd_pcm_dev_disconnect(struct snd_device *device) |
1119 | { | 1128 | { |
1120 | struct snd_pcm *pcm = device->device_data; | 1129 | struct snd_pcm *pcm = device->device_data; |
1121 | struct snd_pcm_notify *notify; | ||
1122 | struct snd_pcm_substream *substream; | 1130 | struct snd_pcm_substream *substream; |
1123 | int cidx; | 1131 | int cidx; |
1124 | 1132 | ||
@@ -1138,8 +1146,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device) | |||
1138 | } | 1146 | } |
1139 | } | 1147 | } |
1140 | if (!pcm->internal) { | 1148 | if (!pcm->internal) { |
1141 | list_for_each_entry(notify, &snd_pcm_notify_list, list) | 1149 | pcm_call_notify(pcm, n_disconnect); |
1142 | notify->n_disconnect(pcm); | ||
1143 | } | 1150 | } |
1144 | for (cidx = 0; cidx < 2; cidx++) { | 1151 | for (cidx = 0; cidx < 2; cidx++) { |
1145 | if (!pcm->internal) | 1152 | if (!pcm->internal) |
@@ -1151,6 +1158,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device) | |||
1151 | return 0; | 1158 | return 0; |
1152 | } | 1159 | } |
1153 | 1160 | ||
1161 | #if IS_ENABLED(CONFIG_SND_PCM_OSS) | ||
1154 | /** | 1162 | /** |
1155 | * snd_pcm_notify - Add/remove the notify list | 1163 | * snd_pcm_notify - Add/remove the notify list |
1156 | * @notify: PCM notify list | 1164 | * @notify: PCM notify list |
@@ -1183,6 +1191,7 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree) | |||
1183 | return 0; | 1191 | return 0; |
1184 | } | 1192 | } |
1185 | EXPORT_SYMBOL(snd_pcm_notify); | 1193 | EXPORT_SYMBOL(snd_pcm_notify); |
1194 | #endif /* CONFIG_SND_PCM_OSS */ | ||
1186 | 1195 | ||
1187 | #ifdef CONFIG_SND_PROC_FS | 1196 | #ifdef CONFIG_SND_PROC_FS |
1188 | /* | 1197 | /* |