sound: pcm: record a substream's owner process
authorClemens Ladisch <clemens@ladisch.de>
Tue, 10 Nov 2009 09:13:30 +0000 (10:13 +0100)
committerTakashi Iwai <tiwai@suse.de>
Tue, 10 Nov 2009 15:32:20 +0000 (16:32 +0100)
Record the pid of the task that opened a PCM substream. For sound
cards with hardware mixing, this allows determining which process
is associated with a specific substream's volume control.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/sound/pcm.h
sound/core/pcm.c

index de6d981..c83a4a7 100644 (file)
@@ -348,6 +348,8 @@ struct snd_pcm_group {              /* keep linked substreams */
        int count;
 };
 
+struct pid;
+
 struct snd_pcm_substream {
        struct snd_pcm *pcm;
        struct snd_pcm_str *pstr;
@@ -379,6 +381,7 @@ struct snd_pcm_substream {
        atomic_t mmap_count;
        unsigned int f_flags;
        void (*pcm_release)(struct snd_pcm_substream *);
+       struct pid *pid;
 #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
        /* -- OSS things -- */
        struct snd_pcm_oss_substream oss;
index 8e2c783..6884ae0 100644 (file)
@@ -435,6 +435,7 @@ static void snd_pcm_substream_proc_status_read(struct snd_info_entry *entry,
                return;
        }
        snd_iprintf(buffer, "state: %s\n", snd_pcm_state_name(status.state));
+       snd_iprintf(buffer, "owner_pid   : %d\n", pid_vnr(substream->pid));
        snd_iprintf(buffer, "trigger_time: %ld.%09ld\n",
                status.trigger_tstamp.tv_sec, status.trigger_tstamp.tv_nsec);
        snd_iprintf(buffer, "tstamp      : %ld.%09ld\n",
@@ -900,6 +901,7 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
        substream->private_data = pcm->private_data;
        substream->ref_count = 1;
        substream->f_flags = file->f_flags;
+       substream->pid = get_pid(task_pid(current));
        pstr->substream_opened++;
        *rsubstream = substream;
        return 0;
@@ -921,6 +923,8 @@ void snd_pcm_detach_substream(struct snd_pcm_substream *substream)
        kfree(runtime->hw_constraints.rules);
        kfree(runtime);
        substream->runtime = NULL;
+       put_pid(substream->pid);
+       substream->pid = NULL;
        substream->pstr->substream_opened--;
 }