~ubuntu-branches/ubuntu/intrepid/alsa-lib/intrepid

« back to all changes in this revision

Viewing changes to debian/patches/fix_mmap_with_multi_plug.patch

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2008-03-11 23:31:24 UTC
  • Revision ID: james.westby@ubuntu.com-20080311233124-f1yvj5o7162murun
Tags: 1.0.15-3ubuntu4
* Backport fixes from hg tip (no API/ABI changes):
  - fix_sem_deadlock_in_dmix.patch (LP: #190059),
  - fix_const_casts.patch,
  - fix_ioplug.patch,
  - fix_control_range.patch,
  - dont_use_hackish_callback_in_rate_plugin.patch,
  - fix_cpu_hog_in_rate_plug.patch,
  - fix_mmap_with_multi_plug.patch,
  - fix_wrong_return_values_in_direct_plug.patch,
  - fix_timestamp_in_status_pcm_direct_plug.patch,
  - fix_configs_error_handling.patch,
  - fix_not_updated_bit_set.patch,
  - fix_device_assignment.patch,
  - fix_missing_aliases.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Index: alsa-lib-1.0.15/src/pcm/pcm_multi.c
 
2
===================================================================
 
3
--- alsa-lib-1.0.15.orig/src/pcm/pcm_multi.c    2008-03-11 22:41:11.000000000 -0400
 
4
+++ alsa-lib-1.0.15/src/pcm/pcm_multi.c 2008-03-11 22:41:29.000000000 -0400
 
5
@@ -690,13 +690,44 @@
 
6
        return size;
 
7
 }
 
8
 
 
9
-static int snd_pcm_multi_mmap(snd_pcm_t *pcm ATTRIBUTE_UNUSED)
 
10
+static int snd_pcm_multi_munmap(snd_pcm_t *pcm)
 
11
 {
 
12
+       free(pcm->mmap_channels);
 
13
+       free(pcm->running_areas);
 
14
+       pcm->mmap_channels = NULL;
 
15
+       pcm->running_areas = NULL;
 
16
        return 0;
 
17
 }
 
18
 
 
19
-static int snd_pcm_multi_munmap(snd_pcm_t *pcm ATTRIBUTE_UNUSED)
 
20
+static int snd_pcm_multi_mmap(snd_pcm_t *pcm)
 
21
 {
 
22
+       snd_pcm_multi_t *multi = pcm->private_data;
 
23
+       unsigned int c;
 
24
+
 
25
+       pcm->mmap_channels = calloc(pcm->channels,
 
26
+                                   sizeof(pcm->mmap_channels[0]));
 
27
+       pcm->running_areas = calloc(pcm->channels,
 
28
+                                   sizeof(pcm->running_areas[0]));
 
29
+       if (!pcm->mmap_channels || !pcm->running_areas) {
 
30
+               snd_pcm_multi_munmap(pcm);
 
31
+               return -ENOMEM;
 
32
+       }
 
33
+
 
34
+       /* Copy the slave mmapped buffer data */
 
35
+       for (c = 0; c < pcm->channels; c++) {
 
36
+               snd_pcm_multi_channel_t *chan = &multi->channels[c];
 
37
+               snd_pcm_t *slave;
 
38
+               if (chan->slave_idx < 0) {
 
39
+                       snd_pcm_multi_munmap(pcm);
 
40
+                       return -ENXIO;
 
41
+               }
 
42
+               slave = multi->slaves[chan->slave_idx].pcm;
 
43
+               pcm->mmap_channels[c] =
 
44
+                       slave->mmap_channels[chan->slave_channel];
 
45
+               pcm->mmap_channels[c].channel = c;
 
46
+               pcm->running_areas[c] =
 
47
+                       slave->running_areas[chan->slave_channel];
 
48
+       }
 
49
        return 0;
 
50
 }
 
51
 
 
52
@@ -850,6 +881,7 @@
 
53
                return err;
 
54
        }
 
55
        pcm->mmap_rw = 1;
 
56
+       pcm->mmap_shadow = 1; /* has own mmap method */
 
57
        pcm->ops = &snd_pcm_multi_ops;
 
58
        pcm->fast_ops = &snd_pcm_multi_fast_ops;
 
59
        pcm->private_data = multi;