~diwic/ubuntu/lucid/pulseaudio/bugfixes

« back to all changes in this revision

Viewing changes to src/utils/pasuspender.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2008-11-04 15:46:00 UTC
  • mfrom: (1.2.1 upstream) (1.1.6 lenny)
  • Revision ID: james.westby@ubuntu.com-20081104154600-hlzknpcazaam0nxm
Tags: 0.9.13-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Don't build against, and create jack package. Jack is not in main.
  - Remove --disable-per-user-esound-socket from configure flags, as we still
    want per user esound sockets.
  - Remove stop links from rc0 and rc6.
  - Change default resample algorithm and bubffer size.
  - Add alsa configuration files to route alsa applications via pulseaudio.
  - Move libasound2-plugins from Recommends to Depends.
* debian/pulseaudio.preinst: When upgrading from intrepid, remove
  /etc/X11/Xsession.d/70pulseaudio, as this was used to minimize a race
  condition when starting GNOME in intrepid. This race should not exist in
  jaunty once libcanberra is built to use pulseaudio as a backend.
* Do not spawn a pulseaudio server if clients fail to find a running server.
* Remove explicit version dependency for libspeex-dev to allow the package
  to be built for now.
* Regenerate autotools files to work with Ubuntu's newer libtool/libltdl.
* debian/control: libpulsecore5 -> libpulsecore8 to match the library
  soname.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: pasuspender.c 2028 2007-11-07 13:52:07Z lennart $ */
2
 
 
3
1
/***
4
2
  This file is part of PulseAudio.
5
3
 
37
35
#include <stdlib.h>
38
36
#include <limits.h>
39
37
#include <getopt.h>
40
 
 
41
 
#include <sndfile.h>
 
38
#include <locale.h>
42
39
 
43
40
#ifdef __linux__
44
41
#include <sys/prctl.h>
45
42
#endif
46
43
 
 
44
#include <pulse/i18n.h>
47
45
#include <pulse/pulseaudio.h>
48
46
#include <pulsecore/macro.h>
49
47
 
50
 
#if PA_API_VERSION < 10
51
 
#error Invalid PulseAudio API version
52
 
#endif
53
 
 
54
48
#define BUFSIZE 1024
55
49
 
56
50
static pa_context *context = NULL;
84
78
 
85
79
    if ((child_pid = fork()) < 0) {
86
80
 
87
 
        fprintf(stderr, "fork(): %s\n", strerror(errno));
 
81
        fprintf(stderr, _("fork(): %s\n"), strerror(errno));
88
82
        quit(1);
89
83
 
90
84
    } else if (child_pid == 0) {
95
89
#endif
96
90
 
97
91
        if (execvp(child_argv[0], child_argv) < 0)
98
 
            fprintf(stderr, "execvp(): %s\n", strerror(errno));
 
92
            fprintf(stderr, _("execvp(): %s\n"), strerror(errno));
99
93
 
100
94
        _exit(1);
101
95
 
112
106
    n++;
113
107
 
114
108
    if (!success) {
115
 
        fprintf(stderr, "Failure to suspend: %s\n", pa_strerror(pa_context_errno(c)));
 
109
        fprintf(stderr, _("Failure to suspend: %s\n"), pa_strerror(pa_context_errno(c)));
116
110
        quit(1);
117
111
        return;
118
112
    }
127
121
    n++;
128
122
 
129
123
    if (!success) {
130
 
        fprintf(stderr, "Failure to resume: %s\n", pa_strerror(pa_context_errno(c)));
 
124
        fprintf(stderr, _("Failure to resume: %s\n"), pa_strerror(pa_context_errno(c)));
131
125
        quit(1);
132
126
        return;
133
127
    }
150
144
                pa_operation_unref(pa_context_suspend_sink_by_index(c, PA_INVALID_INDEX, 1, suspend_complete, NULL));
151
145
                pa_operation_unref(pa_context_suspend_source_by_index(c, PA_INVALID_INDEX, 1, suspend_complete, NULL));
152
146
            } else {
153
 
                fprintf(stderr, "WARNING: Sound server is not local, not suspending.\n");
 
147
                fprintf(stderr, _("WARNING: Sound server is not local, not suspending.\n"));
154
148
                start_child();
155
149
            }
156
150
 
162
156
 
163
157
        case PA_CONTEXT_FAILED:
164
158
        default:
165
 
            fprintf(stderr, "Connection failure: %s\n", pa_strerror(pa_context_errno(c)));
 
159
            fprintf(stderr, _("Connection failure: %s\n"), pa_strerror(pa_context_errno(c)));
166
160
 
167
161
            pa_context_unref(context);
168
162
            context = NULL;
179
173
}
180
174
 
181
175
static void sigint_callback(pa_mainloop_api *m, pa_signal_event *e, int sig, void *userdata) {
182
 
    fprintf(stderr, "Got SIGINT, exiting.\n");
 
176
    fprintf(stderr, _("Got SIGINT, exiting.\n"));
183
177
    quit(0);
184
178
}
185
179
 
197
191
    if (WIFEXITED(status))
198
192
        child_ret = WEXITSTATUS(status);
199
193
    else if (WIFSIGNALED(status)) {
200
 
        fprintf(stderr, "WARNING: Child process terminated by signal %u\n", WTERMSIG(status));
 
194
        fprintf(stderr, _("WARNING: Child process terminated by signal %u\n"), WTERMSIG(status));
201
195
        child_ret = 1;
202
196
    }
203
197
 
215
209
 
216
210
static void help(const char *argv0) {
217
211
 
218
 
    printf("%s [options] ... \n\n"
 
212
    printf(_("%s [options] ... \n\n"
219
213
           "  -h, --help                            Show this help\n"
220
214
           "      --version                         Show version\n"
221
 
           "  -s, --server=SERVER                   The name of the server to connect to\n\n",
 
215
           "  -s, --server=SERVER                   The name of the server to connect to\n\n"),
222
216
           argv0);
223
217
}
224
218
 
238
232
        {NULL,          0, NULL, 0}
239
233
    };
240
234
 
 
235
    setlocale(LC_ALL, "");
 
236
    bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR);
 
237
 
241
238
    if (!(bn = strrchr(argv[0], '/')))
242
239
        bn = argv[0];
243
240
    else
251
248
                goto quit;
252
249
 
253
250
            case ARG_VERSION:
254
 
                printf("pasuspender "PACKAGE_VERSION"\nCompiled with libpulse %s\nLinked with libpulse %s\n", pa_get_headers_version(), pa_get_library_version());
 
251
                printf(_("pasuspender %s\n"
 
252
                         "Compiled with libpulse %s\n"
 
253
                         "Linked with libpulse %s\n"),
 
254
                       PACKAGE_VERSION,
 
255
                       pa_get_headers_version(),
 
256
                       pa_get_library_version());
255
257
                ret = 0;
256
258
                goto quit;
257
259
 
275
277
    }
276
278
 
277
279
    if (!(m = pa_mainloop_new())) {
278
 
        fprintf(stderr, "pa_mainloop_new() failed.\n");
 
280
        fprintf(stderr, _("pa_mainloop_new() failed.\n"));
279
281
        goto quit;
280
282
    }
281
283
 
288
290
#endif
289
291
 
290
292
    if (!(context = pa_context_new(mainloop_api, bn))) {
291
 
        fprintf(stderr, "pa_context_new() failed.\n");
 
293
        fprintf(stderr, _("pa_context_new() failed.\n"));
292
294
        goto quit;
293
295
    }
294
296
 
296
298
    pa_context_connect(context, server, PA_CONTEXT_NOAUTOSPAWN, NULL);
297
299
 
298
300
    if (pa_mainloop_run(m, &ret) < 0) {
299
 
        fprintf(stderr, "pa_mainloop_run() failed.\n");
 
301
        fprintf(stderr, _("pa_mainloop_run() failed.\n"));
300
302
        goto quit;
301
303
    }
302
304