2 This file is part of PulseAudio.
4 Copyright 2004-2006 Lennart Poettering
6 PulseAudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 2 of the License,
9 or (at your option) any later version.
11 PulseAudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with PulseAudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
39 #include <pulse/i18n.h>
40 #include <pulse/pulseaudio.h>
41 #include <pulsecore/core-util.h>
45 static pa_context
*context
= NULL
;
46 static pa_mainloop_api
*mainloop_api
= NULL
;
48 static char *device
= NULL
, *sample_name
= NULL
, *sink_name
= NULL
, *source_name
= NULL
, *module_name
= NULL
, *module_args
= NULL
;
49 static uint32_t sink_input_idx
= PA_INVALID_INDEX
, source_output_idx
= PA_INVALID_INDEX
;
50 static uint32_t module_index
;
53 static SNDFILE
*sndfile
= NULL
;
54 static pa_stream
*sample_stream
= NULL
;
55 static pa_sample_spec sample_spec
;
56 static size_t sample_length
= 0;
58 static int actions
= 1;
78 static void quit(int ret
) {
80 mainloop_api
->quit(mainloop_api
, ret
);
84 static void context_drain_complete(pa_context
*c
, void *userdata
) {
85 pa_context_disconnect(c
);
88 static void drain(void) {
90 if (!(o
= pa_context_drain(context
, context_drain_complete
, NULL
)))
91 pa_context_disconnect(context
);
93 pa_operation_unref(o
);
97 static void complete_action(void) {
104 static void stat_callback(pa_context
*c
, const pa_stat_info
*i
, void *userdata
) {
107 fprintf(stderr
, _("Failed to get statistics: %s\n"), pa_strerror(pa_context_errno(c
)));
112 pa_bytes_snprint(s
, sizeof(s
), i
->memblock_total_size
);
113 printf(_("Currently in use: %u blocks containing %s bytes total.\n"), i
->memblock_total
, s
);
115 pa_bytes_snprint(s
, sizeof(s
), i
->memblock_allocated_size
);
116 printf(_("Allocated during whole lifetime: %u blocks containing %s bytes total.\n"), i
->memblock_allocated
, s
);
118 pa_bytes_snprint(s
, sizeof(s
), i
->scache_size
);
119 printf(_("Sample cache size: %s\n"), s
);
124 static void get_server_info_callback(pa_context
*c
, const pa_server_info
*i
, void *useerdata
) {
125 char s
[PA_SAMPLE_SPEC_SNPRINT_MAX
];
128 fprintf(stderr
, _("Failed to get server information: %s\n"), pa_strerror(pa_context_errno(c
)));
133 pa_sample_spec_snprint(s
, sizeof(s
), &i
->sample_spec
);
135 printf(_("User name: %s\n"
138 "Server Version: %s\n"
139 "Default Sample Specification: %s\n"
141 "Default Source: %s\n"
148 i
->default_sink_name
,
149 i
->default_source_name
,
155 static void get_sink_info_callback(pa_context
*c
, const pa_sink_info
*i
, int is_last
, void *userdata
) {
156 char s
[PA_SAMPLE_SPEC_SNPRINT_MAX
], cv
[PA_CVOLUME_SNPRINT_MAX
], cm
[PA_CHANNEL_MAP_SNPRINT_MAX
];
160 fprintf(stderr
, _("Failed to get sink information: %s\n"), pa_strerror(pa_context_errno(c
)));
176 printf(_("*** Sink #%u ***\n"
179 "Sample Specification: %s\n"
183 "Monitor Source: %s\n"
184 "Latency: %0.0f usec, configured %0.0f usec\n"
185 "Flags: %s%s%s%s%s%s\n"
189 pa_strnull(i
->driver
),
190 pa_sample_spec_snprint(s
, sizeof(s
), &i
->sample_spec
),
191 pa_channel_map_snprint(cm
, sizeof(cm
), &i
->channel_map
),
193 i
->mute
? _("muted") : pa_cvolume_snprint(cv
, sizeof(cv
), &i
->volume
),
194 pa_strnull(i
->monitor_source_name
),
195 (double) i
->latency
, (double) i
->configured_latency
,
196 i
->flags
& PA_SINK_HARDWARE
? "HARDWARE " : "",
197 i
->flags
& PA_SINK_NETWORK
? "NETWORK " : "",
198 i
->flags
& PA_SINK_HW_MUTE_CTRL
? "HW_MUTE_CTRL " : "",
199 i
->flags
& PA_SINK_HW_VOLUME_CTRL
? "HW_VOLUME_CTRL " : "",
200 i
->flags
& PA_SINK_DECIBEL_VOLUME
? "DECIBEL_VOLUME " : "",
201 i
->flags
& PA_SINK_LATENCY
? "LATENCY " : "",
202 pl
= pa_proplist_to_string(i
->proplist
));
207 static void get_source_info_callback(pa_context
*c
, const pa_source_info
*i
, int is_last
, void *userdata
) {
208 char s
[PA_SAMPLE_SPEC_SNPRINT_MAX
], cv
[PA_CVOLUME_SNPRINT_MAX
], cm
[PA_CHANNEL_MAP_SNPRINT_MAX
];
212 fprintf(stderr
, _("Failed to get source information: %s\n"), pa_strerror(pa_context_errno(c
)));
228 printf(_("*** Source #%u ***\n"
231 "Sample Specification: %s\n"
235 "Monitor of Sink: %s\n"
236 "Latency: %0.0f usec, configured %0.0f usec\n"
237 "Flags: %s%s%s%s%s%s\n"
241 pa_strnull(i
->driver
),
242 pa_sample_spec_snprint(s
, sizeof(s
), &i
->sample_spec
),
243 pa_channel_map_snprint(cm
, sizeof(cm
), &i
->channel_map
),
245 i
->mute
? "muted" : pa_cvolume_snprint(cv
, sizeof(cv
), &i
->volume
),
246 i
->monitor_of_sink_name
? i
->monitor_of_sink_name
: _("n/a"),
247 (double) i
->latency
, (double) i
->configured_latency
,
248 i
->flags
& PA_SOURCE_HARDWARE
? "HARDWARE " : "",
249 i
->flags
& PA_SOURCE_NETWORK
? "NETWORK " : "",
250 i
->flags
& PA_SOURCE_HW_MUTE_CTRL
? "HW_MUTE_CTRL " : "",
251 i
->flags
& PA_SOURCE_HW_VOLUME_CTRL
? "HW_VOLUME_CTRL " : "",
252 i
->flags
& PA_SOURCE_DECIBEL_VOLUME
? "DECIBEL_VOLUME " : "",
253 i
->flags
& PA_SOURCE_LATENCY
? "LATENCY " : "",
254 pl
= pa_proplist_to_string(i
->proplist
));
259 static void get_module_info_callback(pa_context
*c
, const pa_module_info
*i
, int is_last
, void *userdata
) {
263 fprintf(stderr
, _("Failed to get module information: %s\n"), pa_strerror(pa_context_errno(c
)));
279 snprintf(t
, sizeof(t
), "%u", i
->n_used
);
281 printf(_("*** Module #%u ***\n"
284 "Usage counter: %s\n"
285 "Auto unload: %s\n"),
288 i
->argument
? i
->argument
: "",
289 i
->n_used
!= PA_INVALID_INDEX
? t
: _("n/a"),
290 pa_yes_no(i
->auto_unload
));
293 static void get_client_info_callback(pa_context
*c
, const pa_client_info
*i
, int is_last
, void *userdata
) {
298 fprintf(stderr
, _("Failed to get client information: %s\n"), pa_strerror(pa_context_errno(c
)));
314 snprintf(t
, sizeof(t
), "%u", i
->owner_module
);
316 printf(_("*** Client #%u ***\n"
321 pa_strnull(i
->driver
),
322 i
->owner_module
!= PA_INVALID_INDEX
? t
: _("n/a"),
323 pl
= pa_proplist_to_string(i
->proplist
));
328 static void get_sink_input_info_callback(pa_context
*c
, const pa_sink_input_info
*i
, int is_last
, void *userdata
) {
329 char t
[32], k
[32], s
[PA_SAMPLE_SPEC_SNPRINT_MAX
], cv
[PA_CVOLUME_SNPRINT_MAX
], cm
[PA_CHANNEL_MAP_SNPRINT_MAX
];
333 fprintf(stderr
, _("Failed to get sink input information: %s\n"), pa_strerror(pa_context_errno(c
)));
349 snprintf(t
, sizeof(t
), "%u", i
->owner_module
);
350 snprintf(k
, sizeof(k
), "%u", i
->client
);
352 printf(_("*** Sink Input #%u ***\n"
357 "Sample Specification: %s\n"
360 "Buffer Latency: %0.0f usec\n"
361 "Sink Latency: %0.0f usec\n"
362 "Resample method: %s\n"
365 pa_strnull(i
->driver
),
366 i
->owner_module
!= PA_INVALID_INDEX
? t
: _("n/a"),
367 i
->client
!= PA_INVALID_INDEX
? k
: _("n/a"),
369 pa_sample_spec_snprint(s
, sizeof(s
), &i
->sample_spec
),
370 pa_channel_map_snprint(cm
, sizeof(cm
), &i
->channel_map
),
371 i
->mute
? _("muted") : pa_cvolume_snprint(cv
, sizeof(cv
), &i
->volume
),
372 (double) i
->buffer_usec
,
373 (double) i
->sink_usec
,
374 i
->resample_method
? i
->resample_method
: _("n/a"),
375 pl
= pa_proplist_to_string(i
->proplist
));
380 static void get_source_output_info_callback(pa_context
*c
, const pa_source_output_info
*i
, int is_last
, void *userdata
) {
381 char t
[32], k
[32], s
[PA_SAMPLE_SPEC_SNPRINT_MAX
], cm
[PA_CHANNEL_MAP_SNPRINT_MAX
];
385 fprintf(stderr
, _("Failed to get source output information: %s\n"), pa_strerror(pa_context_errno(c
)));
402 snprintf(t
, sizeof(t
), "%u", i
->owner_module
);
403 snprintf(k
, sizeof(k
), "%u", i
->client
);
405 printf(_("*** Source Output #%u ***\n"
410 "Sample Specification: %s\n"
412 "Buffer Latency: %0.0f usec\n"
413 "Source Latency: %0.0f usec\n"
414 "Resample method: %s\n"
417 pa_strnull(i
->driver
),
418 i
->owner_module
!= PA_INVALID_INDEX
? t
: _("n/a"),
419 i
->client
!= PA_INVALID_INDEX
? k
: _("n/a"),
421 pa_sample_spec_snprint(s
, sizeof(s
), &i
->sample_spec
),
422 pa_channel_map_snprint(cm
, sizeof(cm
), &i
->channel_map
),
423 (double) i
->buffer_usec
,
424 (double) i
->source_usec
,
425 i
->resample_method
? i
->resample_method
: _("n/a"),
426 pl
= pa_proplist_to_string(i
->proplist
));
431 static void get_sample_info_callback(pa_context
*c
, const pa_sample_info
*i
, int is_last
, void *userdata
) {
432 char t
[32], s
[PA_SAMPLE_SPEC_SNPRINT_MAX
], cv
[PA_CVOLUME_SNPRINT_MAX
], cm
[PA_CHANNEL_MAP_SNPRINT_MAX
];
436 fprintf(stderr
, _("Failed to get sample information: %s\n"), pa_strerror(pa_context_errno(c
)));
453 pa_bytes_snprint(t
, sizeof(t
), i
->bytes
);
455 printf(_("*** Sample #%u ***\n"
458 "Sample Specification: %s\n"
467 pa_cvolume_snprint(cv
, sizeof(cv
), &i
->volume
),
468 pa_sample_spec_valid(&i
->sample_spec
) ? pa_sample_spec_snprint(s
, sizeof(s
), &i
->sample_spec
) : _("n/a"),
469 pa_sample_spec_valid(&i
->sample_spec
) ? pa_channel_map_snprint(cm
, sizeof(cm
), &i
->channel_map
) : _("n/a"),
470 (double) i
->duration
/1000000,
473 i
->filename
? i
->filename
: _("n/a"),
474 pl
= pa_proplist_to_string(i
->proplist
));
479 static void simple_callback(pa_context
*c
, int success
, void *userdata
) {
481 fprintf(stderr
, _("Failure: %s\n"), pa_strerror(pa_context_errno(c
)));
489 static void index_callback(pa_context
*c
, uint32_t idx
, void *userdata
) {
490 if (idx
== PA_INVALID_INDEX
) {
491 fprintf(stderr
, _("Failure: %s\n"), pa_strerror(pa_context_errno(c
)));
501 static void stream_state_callback(pa_stream
*s
, void *userdata
) {
504 switch (pa_stream_get_state(s
)) {
505 case PA_STREAM_CREATING
:
506 case PA_STREAM_READY
:
509 case PA_STREAM_TERMINATED
:
513 case PA_STREAM_FAILED
:
515 fprintf(stderr
, _("Failed to upload sample: %s\n"), pa_strerror(pa_context_errno(pa_stream_get_context(s
))));
520 static void stream_write_callback(pa_stream
*s
, size_t length
, void *userdata
) {
523 assert(s
&& length
&& sndfile
);
525 d
= pa_xmalloc(length
);
527 assert(sample_length
>= length
);
528 l
= (sf_count_t
) (length
/pa_frame_size(&sample_spec
));
530 if ((sf_readf_float(sndfile
, d
, l
)) != l
) {
532 fprintf(stderr
, _("Premature end of file\n"));
536 pa_stream_write(s
, d
, length
, pa_xfree
, 0, PA_SEEK_RELATIVE
);
538 sample_length
-= length
;
540 if (sample_length
<= 0) {
541 pa_stream_set_write_callback(sample_stream
, NULL
, NULL
);
542 pa_stream_finish_upload(sample_stream
);
546 static void context_state_callback(pa_context
*c
, void *userdata
) {
548 switch (pa_context_get_state(c
)) {
549 case PA_CONTEXT_CONNECTING
:
550 case PA_CONTEXT_AUTHORIZING
:
551 case PA_CONTEXT_SETTING_NAME
:
554 case PA_CONTEXT_READY
:
558 pa_operation_unref(pa_context_stat(c
, stat_callback
, NULL
));
559 pa_operation_unref(pa_context_get_server_info(c
, get_server_info_callback
, NULL
));
563 pa_operation_unref(pa_context_play_sample(c
, sample_name
, device
, PA_VOLUME_NORM
, simple_callback
, NULL
));
567 pa_operation_unref(pa_context_remove_sample(c
, sample_name
, simple_callback
, NULL
));
571 sample_stream
= pa_stream_new(c
, sample_name
, &sample_spec
, NULL
);
572 assert(sample_stream
);
574 pa_stream_set_state_callback(sample_stream
, stream_state_callback
, NULL
);
575 pa_stream_set_write_callback(sample_stream
, stream_write_callback
, NULL
);
576 pa_stream_connect_upload(sample_stream
, sample_length
);
580 pa_operation_unref(pa_context_exit_daemon(c
, simple_callback
, NULL
));
585 pa_operation_unref(pa_context_get_module_info_list(c
, get_module_info_callback
, NULL
));
586 pa_operation_unref(pa_context_get_sink_info_list(c
, get_sink_info_callback
, NULL
));
587 pa_operation_unref(pa_context_get_source_info_list(c
, get_source_info_callback
, NULL
));
588 pa_operation_unref(pa_context_get_sink_input_info_list(c
, get_sink_input_info_callback
, NULL
));
589 pa_operation_unref(pa_context_get_source_output_info_list(c
, get_source_output_info_callback
, NULL
));
590 pa_operation_unref(pa_context_get_client_info_list(c
, get_client_info_callback
, NULL
));
591 pa_operation_unref(pa_context_get_sample_info_list(c
, get_sample_info_callback
, NULL
));
594 case MOVE_SINK_INPUT
:
595 pa_operation_unref(pa_context_move_sink_input_by_name(c
, sink_input_idx
, sink_name
, simple_callback
, NULL
));
598 case MOVE_SOURCE_OUTPUT
:
599 pa_operation_unref(pa_context_move_source_output_by_name(c
, source_output_idx
, source_name
, simple_callback
, NULL
));
603 pa_operation_unref(pa_context_load_module(c
, module_name
, module_args
, index_callback
, NULL
));
607 pa_operation_unref(pa_context_unload_module(c
, module_index
, simple_callback
, NULL
));
612 pa_operation_unref(pa_context_suspend_sink_by_name(c
, sink_name
, suspend
, simple_callback
, NULL
));
614 pa_operation_unref(pa_context_suspend_sink_by_index(c
, PA_INVALID_INDEX
, suspend
, simple_callback
, NULL
));
619 pa_operation_unref(pa_context_suspend_source_by_name(c
, source_name
, suspend
, simple_callback
, NULL
));
621 pa_operation_unref(pa_context_suspend_source_by_index(c
, PA_INVALID_INDEX
, suspend
, simple_callback
, NULL
));
629 case PA_CONTEXT_TERMINATED
:
633 case PA_CONTEXT_FAILED
:
635 fprintf(stderr
, _("Connection failure: %s\n"), pa_strerror(pa_context_errno(c
)));
640 static void exit_signal_callback(pa_mainloop_api
*m
, pa_signal_event
*e
, int sig
, void *userdata
) {
641 fprintf(stderr
, _("Got SIGINT, exiting.\n"));
645 static void help(const char *argv0
) {
647 printf(_("%s [options] stat\n"
648 "%s [options] list\n"
649 "%s [options] exit\n"
650 "%s [options] upload-sample FILENAME [NAME]\n"
651 "%s [options] play-sample NAME [SINK]\n"
652 "%s [options] remove-sample NAME\n"
653 "%s [options] move-sink-input ID SINK\n"
654 "%s [options] move-source-output ID SOURCE\n"
655 "%s [options] load-module NAME [ARGS ...]\n"
656 "%s [options] unload-module ID\n"
657 "%s [options] suspend-sink [SINK] 1|0\n"
658 "%s [options] suspend-source [SOURCE] 1|0\n\n"
659 " -h, --help Show this help\n"
660 " --version Show version\n\n"
661 " -s, --server=SERVER The name of the server to connect to\n"
662 " -n, --client-name=NAME How to call this client on the server\n"),
663 argv0
, argv0
, argv0
, argv0
, argv0
, argv0
, argv0
, argv0
, argv0
, argv0
, argv0
, argv0
);
666 enum { ARG_VERSION
= 256 };
668 int main(int argc
, char *argv
[]) {
669 pa_mainloop
* m
= NULL
;
672 char *server
= NULL
, *client_name
= NULL
, *bn
;
674 static const struct option long_options
[] = {
675 {"server", 1, NULL
, 's'},
676 {"client-name", 1, NULL
, 'n'},
677 {"version", 0, NULL
, ARG_VERSION
},
678 {"help", 0, NULL
, 'h'},
682 setlocale(LC_ALL
, "");
683 bindtextdomain(GETTEXT_PACKAGE
, PULSE_LOCALEDIR
);
685 if (!(bn
= strrchr(argv
[0], '/')))
690 while ((c
= getopt_long(argc
, argv
, "s:n:h", long_options
, NULL
)) != -1) {
698 printf(_("pactl %s\n"
699 "Compiled with libpulse %s\n"
700 "Linked with libpulse %s\n"),
702 pa_get_headers_version(),
703 pa_get_library_version());
709 server
= pa_xstrdup(optarg
);
713 pa_xfree(client_name
);
714 client_name
= pa_xstrdup(optarg
);
723 client_name
= pa_xstrdup(bn
);
726 if (!strcmp(argv
[optind
], "stat"))
728 else if (!strcmp(argv
[optind
], "exit"))
730 else if (!strcmp(argv
[optind
], "list"))
732 else if (!strcmp(argv
[optind
], "upload-sample")) {
733 struct SF_INFO sfinfo
;
734 action
= UPLOAD_SAMPLE
;
736 if (optind
+1 >= argc
) {
737 fprintf(stderr
, _("Please specify a sample file to load\n"));
742 sample_name
= pa_xstrdup(argv
[optind
+2]);
744 char *f
= strrchr(argv
[optind
+1], '/');
754 sample_name
= pa_xstrdup(tmp
);
757 memset(&sfinfo
, 0, sizeof(sfinfo
));
758 if (!(sndfile
= sf_open(argv
[optind
+1], SFM_READ
, &sfinfo
))) {
759 fprintf(stderr
, _("Failed to open sound file.\n"));
763 sample_spec
.format
= PA_SAMPLE_FLOAT32
;
764 sample_spec
.rate
= (uint32_t) sfinfo
.samplerate
;
765 sample_spec
.channels
= (uint8_t) sfinfo
.channels
;
767 sample_length
= (size_t)sfinfo
.frames
*pa_frame_size(&sample_spec
);
768 } else if (!strcmp(argv
[optind
], "play-sample")) {
769 action
= PLAY_SAMPLE
;
770 if (argc
!= optind
+2 && argc
!= optind
+3) {
771 fprintf(stderr
, _("You have to specify a sample name to play\n"));
775 sample_name
= pa_xstrdup(argv
[optind
+1]);
778 device
= pa_xstrdup(argv
[optind
+2]);
780 } else if (!strcmp(argv
[optind
], "remove-sample")) {
781 action
= REMOVE_SAMPLE
;
782 if (argc
!= optind
+2) {
783 fprintf(stderr
, _("You have to specify a sample name to remove\n"));
787 sample_name
= pa_xstrdup(argv
[optind
+1]);
788 } else if (!strcmp(argv
[optind
], "move-sink-input")) {
789 action
= MOVE_SINK_INPUT
;
790 if (argc
!= optind
+3) {
791 fprintf(stderr
, _("You have to specify a sink input index and a sink\n"));
795 sink_input_idx
= (uint32_t) atoi(argv
[optind
+1]);
796 sink_name
= pa_xstrdup(argv
[optind
+2]);
797 } else if (!strcmp(argv
[optind
], "move-source-output")) {
798 action
= MOVE_SOURCE_OUTPUT
;
799 if (argc
!= optind
+3) {
800 fprintf(stderr
, _("You have to specify a source output index and a source\n"));
804 source_output_idx
= (uint32_t) atoi(argv
[optind
+1]);
805 source_name
= pa_xstrdup(argv
[optind
+2]);
806 } else if (!strcmp(argv
[optind
], "load-module")) {
811 action
= LOAD_MODULE
;
813 if (argc
<= optind
+1) {
814 fprintf(stderr
, _("You have to specify a module name and arguments.\n"));
818 module_name
= argv
[optind
+1];
820 for (i
= optind
+2; i
< argc
; i
++)
821 n
+= strlen(argv
[i
])+1;
824 p
= module_args
= pa_xmalloc(n
);
826 for (i
= optind
+2; i
< argc
; i
++)
827 p
+= sprintf(p
, "%s%s", p
== module_args
? "" : " ", argv
[i
]);
830 } else if (!strcmp(argv
[optind
], "unload-module")) {
831 action
= UNLOAD_MODULE
;
833 if (argc
!= optind
+2) {
834 fprintf(stderr
, _("You have to specify a module index\n"));
838 module_index
= (uint32_t) atoi(argv
[optind
+1]);
840 } else if (!strcmp(argv
[optind
], "suspend-sink")) {
841 action
= SUSPEND_SINK
;
843 if (argc
> optind
+3 || optind
+1 >= argc
) {
844 fprintf(stderr
, _("You may not specify more than one sink. You have to specify at least one boolean value.\n"));
848 suspend
= pa_parse_boolean(argv
[argc
-1]);
851 sink_name
= pa_xstrdup(argv
[optind
+1]);
853 } else if (!strcmp(argv
[optind
], "suspend-source")) {
854 action
= SUSPEND_SOURCE
;
856 if (argc
> optind
+3 || optind
+1 >= argc
) {
857 fprintf(stderr
, _("You may not specify more than one source. You have to specify at least one boolean value.\n"));
861 suspend
= pa_parse_boolean(argv
[argc
-1]);
864 source_name
= pa_xstrdup(argv
[optind
+1]);
865 } else if (!strcmp(argv
[optind
], "help")) {
872 if (action
== NONE
) {
873 fprintf(stderr
, _("No valid command specified.\n"));
877 if (!(m
= pa_mainloop_new())) {
878 fprintf(stderr
, _("pa_mainloop_new() failed.\n"));
882 mainloop_api
= pa_mainloop_get_api(m
);
884 r
= pa_signal_init(mainloop_api
);
886 pa_signal_new(SIGINT
, exit_signal_callback
, NULL
);
888 signal(SIGPIPE
, SIG_IGN
);
891 if (!(context
= pa_context_new(mainloop_api
, client_name
))) {
892 fprintf(stderr
, _("pa_context_new() failed.\n"));
896 pa_context_set_state_callback(context
, context_state_callback
, NULL
);
897 pa_context_connect(context
, server
, 0, NULL
);
899 if (pa_mainloop_run(m
, &ret
) < 0) {
900 fprintf(stderr
, _("pa_mainloop_run() failed.\n"));
906 pa_stream_unref(sample_stream
);
909 pa_context_unref(context
);
921 pa_xfree(sample_name
);
923 pa_xfree(source_name
);
924 pa_xfree(module_args
);
925 pa_xfree(client_name
);