aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2009-11-10 04:13:30 -0500
committerTakashi Iwai <tiwai@suse.de>2009-11-10 10:32:20 -0500
commite7373b702f6eab35f315e016a4159860a7a4d686 (patch)
tree01e2401935c57f80f6b78d1906128f006655b432
parent91d12c485b8949cce6c13ab641147c5bc86ce8b9 (diff)
sound: pcm: record a substream's owner process
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>
-rw-r--r--include/sound/pcm.h3
-rw-r--r--sound/core/pcm.c4
2 files changed, 7 insertions, 0 deletions
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index de6d981de5d6..c83a4a79f16b 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -348,6 +348,8 @@ struct snd_pcm_group { /* keep linked substreams */
348 int count; 348 int count;
349}; 349};
350 350
351struct pid;
352
351struct snd_pcm_substream { 353struct snd_pcm_substream {
352 struct snd_pcm *pcm; 354 struct snd_pcm *pcm;
353 struct snd_pcm_str *pstr; 355 struct snd_pcm_str *pstr;
@@ -379,6 +381,7 @@ struct snd_pcm_substream {
379 atomic_t mmap_count; 381 atomic_t mmap_count;
380 unsigned int f_flags; 382 unsigned int f_flags;
381 void (*pcm_release)(struct snd_pcm_substream *); 383 void (*pcm_release)(struct snd_pcm_substream *);
384 struct pid *pid;
382#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) 385#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
383 /* -- OSS things -- */ 386 /* -- OSS things -- */
384 struct snd_pcm_oss_substream oss; 387 struct snd_pcm_oss_substream oss;
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 8e2c7833614c..6884ae031f6f 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -435,6 +435,7 @@ static void snd_pcm_substream_proc_status_read(struct snd_info_entry *entry,
435 return; 435 return;
436 } 436 }
437 snd_iprintf(buffer, "state: %s\n", snd_pcm_state_name(status.state)); 437 snd_iprintf(buffer, "state: %s\n", snd_pcm_state_name(status.state));
438 snd_iprintf(buffer, "owner_pid : %d\n", pid_vnr(substream->pid));
438 snd_iprintf(buffer, "trigger_time: %ld.%09ld\n", 439 snd_iprintf(buffer, "trigger_time: %ld.%09ld\n",
439 status.trigger_tstamp.tv_sec, status.trigger_tstamp.tv_nsec); 440 status.trigger_tstamp.tv_sec, status.trigger_tstamp.tv_nsec);
440 snd_iprintf(buffer, "tstamp : %ld.%09ld\n", 441 snd_iprintf(buffer, "tstamp : %ld.%09ld\n",
@@ -900,6 +901,7 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
900 substream->private_data = pcm->private_data; 901 substream->private_data = pcm->private_data;
901 substream->ref_count = 1; 902 substream->ref_count = 1;
902 substream->f_flags = file->f_flags; 903 substream->f_flags = file->f_flags;
904 substream->pid = get_pid(task_pid(current));
903 pstr->substream_opened++; 905 pstr->substream_opened++;
904 *rsubstream = substream; 906 *rsubstream = substream;
905 return 0; 907 return 0;
@@ -921,6 +923,8 @@ void snd_pcm_detach_substream(struct snd_pcm_substream *substream)
921 kfree(runtime->hw_constraints.rules); 923 kfree(runtime->hw_constraints.rules);
922 kfree(runtime); 924 kfree(runtime);
923 substream->runtime = NULL; 925 substream->runtime = NULL;
926 put_pid(substream->pid);
927 substream->pid = NULL;
924 substream->pstr->substream_opened--; 928 substream->pstr->substream_opened--;
925} 929}
926 930