~ubuntu-branches/ubuntu/gutsy/pulseaudio/gutsy-updates

« back to all changes in this revision

Viewing changes to debian/patches/06_pulseaudio-0.9.5-suspend.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2007-05-25 01:32:39 UTC
  • Revision ID: james.westby@ubuntu.com-20070525013239-4cipvgiz2cnle3mq
Tags: 0.9.5-7ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/control:
    + Add lsb-base (>= 3) to pulseaudio's dependencies,
    + Adhere to DebianMaintainerField policy,
  - debian/patches/:
    + Add 10_fix_DoS_vulns.dpatch (pA ticket 67) and
      11_disallow_excessively_high_sampling_rates.dpatch,
    + Drop 06_fix_suspend.dpatch in favour of
      06_pulseaudio-0.9.5-suspend.dpatch,
    + Retain 07_fix_esdcompat_bashism.dpatch and
      09_fix_esd_max_samplesize.dpatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh /usr/share/dpatch/dpatch-run
 
2
## 06_pulseaudio-0.9.5-suspend.dpatch.dpatch by <ranma+debianbts@tdiedrich.de>
 
3
##
 
4
## All lines beginning with `## DP:' are a description of the patch.
 
5
## DP: Handle -ESTRPIPE correctly. Allows pulseaudio to survive suspend 
 
6
## DP: operations on ALSA devices (e.g. s2disk).
 
7
 
 
8
@DPATCH@
 
9
 
 
10
diff -Naru pulseaudio-0.9.5-orig/src/modules/module-alsa-sink.c pulseaudio-0.9.5/src/modules/module-alsa-sink.c
 
11
--- pulseaudio-0.9.5-orig/src/modules/module-alsa-sink.c        2006-08-18 23:38:48.000000000 +0200
 
12
+++ pulseaudio-0.9.5/src/modules/module-alsa-sink.c     2007-01-13 21:01:07.000000000 +0100
 
13
@@ -138,6 +138,23 @@
 
14
     return ret;
 
15
 }
 
16
 
 
17
+static int suspend_recovery(struct userdata *u) {
 
18
+    int ret;
 
19
+    assert(u);
 
20
+
 
21
+    pa_log_info("*** ALSA-SUSPEND (playback) ***");
 
22
+    
 
23
+    if ((ret = snd_pcm_prepare(u->pcm_handle)) < 0) {
 
24
+        pa_log("snd_pcm_prepare() failed: %s", snd_strerror(-ret));
 
25
+
 
26
+        clear_up(u);
 
27
+        pa_module_unload_request(u->module);
 
28
+        return -1;
 
29
+    }
 
30
+
 
31
+    return ret;
 
32
+}
 
33
+
 
34
 static void do_write(struct userdata *u) {
 
35
     assert(u);
 
36
 
 
37
@@ -169,6 +186,13 @@
 
38
                 continue;
 
39
             }
 
40
 
 
41
+            if (frames == -ESTRPIPE) {
 
42
+                if (suspend_recovery(u) < 0)
 
43
+                    return;
 
44
+                
 
45
+                continue;
 
46
+            }
 
47
+
 
48
             pa_log("snd_pcm_writei() failed: %s", snd_strerror(-frames));
 
49
 
 
50
             clear_up(u);
 
51
@@ -200,6 +224,10 @@
 
52
         if (xrun_recovery(u) < 0)
 
53
             return;
 
54
 
 
55
+    if (snd_pcm_state(u->pcm_handle) == SND_PCM_STATE_SUSPENDED)
 
56
+        if (suspend_recovery(u) < 0)
 
57
+            return;
 
58
+
 
59
     do_write(u);
 
60
 }
 
61