Commit 7584af10 authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Takashi Iwai

sound: rawmidi: record a substream's owner process

Record the pid of the task that opened a RawMIDI substream.
Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent e7373b70
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
struct snd_rawmidi; struct snd_rawmidi;
struct snd_rawmidi_substream; struct snd_rawmidi_substream;
struct snd_seq_port_info; struct snd_seq_port_info;
struct pid;
struct snd_rawmidi_ops { struct snd_rawmidi_ops {
int (*open) (struct snd_rawmidi_substream * substream); int (*open) (struct snd_rawmidi_substream * substream);
...@@ -97,6 +98,7 @@ struct snd_rawmidi_substream { ...@@ -97,6 +98,7 @@ struct snd_rawmidi_substream {
struct snd_rawmidi_str *pstr; struct snd_rawmidi_str *pstr;
char name[32]; char name[32];
struct snd_rawmidi_runtime *runtime; struct snd_rawmidi_runtime *runtime;
struct pid *pid;
/* hardware layer */ /* hardware layer */
struct snd_rawmidi_ops *ops; struct snd_rawmidi_ops *ops;
}; };
......
...@@ -278,6 +278,7 @@ static int open_substream(struct snd_rawmidi *rmidi, ...@@ -278,6 +278,7 @@ static int open_substream(struct snd_rawmidi *rmidi,
substream->active_sensing = 0; substream->active_sensing = 0;
if (mode & SNDRV_RAWMIDI_LFLG_APPEND) if (mode & SNDRV_RAWMIDI_LFLG_APPEND)
substream->append = 1; substream->append = 1;
substream->pid = get_pid(task_pid(current));
rmidi->streams[substream->stream].substream_opened++; rmidi->streams[substream->stream].substream_opened++;
} }
substream->use_count++; substream->use_count++;
...@@ -488,6 +489,8 @@ static void close_substream(struct snd_rawmidi *rmidi, ...@@ -488,6 +489,8 @@ static void close_substream(struct snd_rawmidi *rmidi,
snd_rawmidi_runtime_free(substream); snd_rawmidi_runtime_free(substream);
substream->opened = 0; substream->opened = 0;
substream->append = 0; substream->append = 0;
put_pid(substream->pid);
substream->pid = NULL;
rmidi->streams[substream->stream].substream_opened--; rmidi->streams[substream->stream].substream_opened--;
} }
...@@ -1336,6 +1339,9 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry, ...@@ -1336,6 +1339,9 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
substream->number, substream->number,
(unsigned long) substream->bytes); (unsigned long) substream->bytes);
if (substream->opened) { if (substream->opened) {
snd_iprintf(buffer,
" Owner PID : %d\n",
pid_vnr(substream->pid));
runtime = substream->runtime; runtime = substream->runtime;
snd_iprintf(buffer, snd_iprintf(buffer,
" Mode : %s\n" " Mode : %s\n"
...@@ -1357,6 +1363,9 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry, ...@@ -1357,6 +1363,9 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
substream->number, substream->number,
(unsigned long) substream->bytes); (unsigned long) substream->bytes);
if (substream->opened) { if (substream->opened) {
snd_iprintf(buffer,
" Owner PID : %d\n",
pid_vnr(substream->pid));
runtime = substream->runtime; runtime = substream->runtime;
snd_iprintf(buffer, snd_iprintf(buffer,
" Buffer size : %lu\n" " Buffer size : %lu\n"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment