[PATCH 3/7] ALSA: pcm: avoid mmap of control data if .update_appl_ptr is implemented

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ramesh Babu <ramesh.babu@xxxxxxxxx>

In case of mmap, by default alsa-lib mmaps both control & status data.

If driver subscribes for .appl_ptr_update, driver needs to get
notification whenever appl ptr changes. So with control & status mmaped,
driver won't get appl ptr notifications.

In alsa-lib IOCTL_SYNC_PTR can be forced using  sync_ptr_ioctl flag in
conf But this makes driver behavior dependent on a flag in the conf.

This patch conditionally checks for .appl_ptr_update and returns error
when user land asks for mmaping control & status data, thus forcing user
to issue IOCTL_SYNC_PTR.

One drawback with this approach is, if .appl_ptr_update is subscribed by
driver, the user space looses flexibility to mmap the control & status
data.

Signed-off-by: Ramesh Babu <ramesh.babu@xxxxxxxxx>
Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@xxxxxxxxx>
---
 sound/core/pcm_native.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index c56d4ed..1965d83 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3535,10 +3535,22 @@ static int snd_pcm_mmap(struct file *file, struct vm_area_struct *area)
 	case SNDRV_PCM_MMAP_OFFSET_STATUS:
 		if (pcm_file->no_compat_mmap)
 			return -ENXIO;
+		/*
+		 * we want to force sync pointer,
+		 * if driver implements appl_ptr_update
+		 */
+		if (substream->ops->appl_ptr_update)
+			return -ENXIO;
 		return snd_pcm_mmap_status(substream, file, area);
 	case SNDRV_PCM_MMAP_OFFSET_CONTROL:
 		if (pcm_file->no_compat_mmap)
 			return -ENXIO;
+		/*
+		 * we want to force sync pointer,
+		 * if driver implements appl_ptr_update
+		 */
+		if (substream->ops->appl_ptr_update)
+			return -ENXIO;
 		return snd_pcm_mmap_control(substream, file, area);
 	default:
 		return snd_pcm_mmap_data(substream, file, area);
-- 
1.9.1

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux