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
38 #include <pulse/pulseaudio.h>
39 #include <pulsecore/core-util.h>
41 #if PA_API_VERSION < 10
42 #error Invalid PulseAudio API version
47 static pa_context
*context
= NULL
;
48 static pa_mainloop_api
*mainloop_api
= NULL
;
50 static char *device
= NULL
, *sample_name
= NULL
, *sink_name
= NULL
, *source_name
= NULL
, *module_name
= NULL
, *module_args
= NULL
;
51 static uint32_t sink_input_idx
= PA_INVALID_INDEX
, source_output_idx
= PA_INVALID_INDEX
;
52 static uint32_t module_index
;
55 static SNDFILE
*sndfile
= NULL
;
56 static pa_stream
*sample_stream
= NULL
;
57 static pa_sample_spec sample_spec
;
58 static size_t sample_length
= 0;
60 static int actions
= 1;
80 static void quit(int ret
) {
82 mainloop_api
->quit(mainloop_api
, ret
);
86 static void context_drain_complete(pa_context
*c
, void *userdata
) {
87 pa_context_disconnect(c
);
90 static void drain(void) {
92 if (!(o
= pa_context_drain(context
, context_drain_complete
, NULL
)))
93 pa_context_disconnect(context
);
95 pa_operation_unref(o
);
99 static void complete_action(void) {
106 static void stat_callback(pa_context
*c
, const pa_stat_info
*i
, void *userdata
) {
109 fprintf(stderr
, "Failed to get statistics: %s\n", pa_strerror(pa_context_errno(c
)));
114 pa_bytes_snprint(s
, sizeof(s
), i
->memblock_total_size
);
115 printf("Currently in use: %u blocks containing %s bytes total.\n", i
->memblock_total
, s
);
117 pa_bytes_snprint(s
, sizeof(s
), i
->memblock_allocated_size
);
118 printf("Allocated during whole lifetime: %u blocks containing %s bytes total.\n", i
->memblock_allocated
, s
);
120 pa_bytes_snprint(s
, sizeof(s
), i
->scache_size
);
121 printf("Sample cache size: %s\n", s
);
126 static void get_server_info_callback(pa_context
*c
, const pa_server_info
*i
, void *useerdata
) {
127 char s
[PA_SAMPLE_SPEC_SNPRINT_MAX
];
130 fprintf(stderr
, "Failed to get server information: %s\n", pa_strerror(pa_context_errno(c
)));
135 pa_sample_spec_snprint(s
, sizeof(s
), &i
->sample_spec
);
137 printf("User name: %s\n"
140 "Server Version: %s\n"
141 "Default Sample Specification: %s\n"
143 "Default Source: %s\n"
150 i
->default_sink_name
,
151 i
->default_source_name
,
157 static void get_sink_info_callback(pa_context
*c
, const pa_sink_info
*i
, int is_last
, void *userdata
) {
158 char s
[PA_SAMPLE_SPEC_SNPRINT_MAX
], cv
[PA_CVOLUME_SNPRINT_MAX
], cm
[PA_CHANNEL_MAP_SNPRINT_MAX
];
162 fprintf(stderr
, "Failed to get sink information: %s\n", pa_strerror(pa_context_errno(c
)));
178 printf("*** Sink #%u ***\n"
181 "Sample Specification: %s\n"
185 "Monitor Source: %s\n"
186 "Latency: %0.0f usec, configured %0.0f usec\n"
187 "Flags: %s%s%s%s%s%s\n"
191 pa_strnull(i
->driver
),
192 pa_sample_spec_snprint(s
, sizeof(s
), &i
->sample_spec
),
193 pa_channel_map_snprint(cm
, sizeof(cm
), &i
->channel_map
),
195 i
->mute
? "muted" : pa_cvolume_snprint(cv
, sizeof(cv
), &i
->volume
),
196 pa_strnull(i
->monitor_source_name
),
197 (double) i
->latency
, (double) i
->configured_latency
,
198 i
->flags
& PA_SINK_HARDWARE
? "HARDWARE " : "",
199 i
->flags
& PA_SINK_NETWORK
? "NETWORK " : "",
200 i
->flags
& PA_SINK_HW_MUTE_CTRL
? "HW_MUTE_CTRL " : "",
201 i
->flags
& PA_SINK_HW_VOLUME_CTRL
? "HW_VOLUME_CTRL " : "",
202 i
->flags
& PA_SINK_DECIBEL_VOLUME
? "DECIBEL_VOLUME " : "",
203 i
->flags
& PA_SINK_LATENCY
? "LATENCY " : "",
204 pl
= pa_proplist_to_string(i
->proplist
));
209 static void get_source_info_callback(pa_context
*c
, const pa_source_info
*i
, int is_last
, void *userdata
) {
210 char s
[PA_SAMPLE_SPEC_SNPRINT_MAX
], cv
[PA_CVOLUME_SNPRINT_MAX
], cm
[PA_CHANNEL_MAP_SNPRINT_MAX
];
214 fprintf(stderr
, "Failed to get source information: %s\n", pa_strerror(pa_context_errno(c
)));
230 printf("*** Source #%u ***\n"
233 "Sample Specification: %s\n"
237 "Monitor of Sink: %s\n"
238 "Latency: %0.0f usec, configured %0.0f usec\n"
239 "Flags: %s%s%s%s%s%s\n"
243 pa_strnull(i
->driver
),
244 pa_sample_spec_snprint(s
, sizeof(s
), &i
->sample_spec
),
245 pa_channel_map_snprint(cm
, sizeof(cm
), &i
->channel_map
),
247 i
->mute
? "muted" : pa_cvolume_snprint(cv
, sizeof(cv
), &i
->volume
),
248 i
->monitor_of_sink_name
? i
->monitor_of_sink_name
: "n/a",
249 (double) i
->latency
, (double) i
->configured_latency
,
250 i
->flags
& PA_SOURCE_HARDWARE
? "HARDWARE " : "",
251 i
->flags
& PA_SOURCE_NETWORK
? "NETWORK " : "",
252 i
->flags
& PA_SOURCE_HW_MUTE_CTRL
? "HW_MUTE_CTRL " : "",
253 i
->flags
& PA_SOURCE_HW_VOLUME_CTRL
? "HW_VOLUME_CTRL " : "",
254 i
->flags
& PA_SOURCE_DECIBEL_VOLUME
? "DECIBEL_VOLUME " : "",
255 i
->flags
& PA_SOURCE_LATENCY
? "LATENCY " : "",
256 pl
= pa_proplist_to_string(i
->proplist
));
261 static void get_module_info_callback(pa_context
*c
, const pa_module_info
*i
, int is_last
, void *userdata
) {
265 fprintf(stderr
, "Failed to get module information: %s\n", pa_strerror(pa_context_errno(c
)));
281 snprintf(t
, sizeof(t
), "%u", i
->n_used
);
283 printf("*** Module #%u ***\n"
286 "Usage counter: %s\n"
290 i
->argument
? i
->argument
: "",
291 i
->n_used
!= PA_INVALID_INDEX
? t
: "n/a",
292 pa_yes_no(i
->auto_unload
));
295 static void get_client_info_callback(pa_context
*c
, const pa_client_info
*i
, int is_last
, void *userdata
) {
300 fprintf(stderr
, "Failed to get client information: %s\n", pa_strerror(pa_context_errno(c
)));
316 snprintf(t
, sizeof(t
), "%u", i
->owner_module
);
318 printf("*** Client #%u ***\n"
323 pa_strnull(i
->driver
),
324 i
->owner_module
!= PA_INVALID_INDEX
? t
: "n/a",
325 pl
= pa_proplist_to_string(i
->proplist
));
330 static void get_sink_input_info_callback(pa_context
*c
, const pa_sink_input_info
*i
, int is_last
, void *userdata
) {
331 char t
[32], k
[32], s
[PA_SAMPLE_SPEC_SNPRINT_MAX
], cv
[PA_CVOLUME_SNPRINT_MAX
], cm
[PA_CHANNEL_MAP_SNPRINT_MAX
];
335 fprintf(stderr
, "Failed to get sink input information: %s\n", pa_strerror(pa_context_errno(c
)));
351 snprintf(t
, sizeof(t
), "%u", i
->owner_module
);
352 snprintf(k
, sizeof(k
), "%u", i
->client
);
354 printf("*** Sink Input #%u ***\n"
359 "Sample Specification: %s\n"
362 "Buffer Latency: %0.0f usec\n"
363 "Sink Latency: %0.0f usec\n"
364 "Resample method: %s\n"
367 pa_strnull(i
->driver
),
368 i
->owner_module
!= PA_INVALID_INDEX
? t
: "n/a",
369 i
->client
!= PA_INVALID_INDEX
? k
: "n/a",
371 pa_sample_spec_snprint(s
, sizeof(s
), &i
->sample_spec
),
372 pa_channel_map_snprint(cm
, sizeof(cm
), &i
->channel_map
),
373 i
->mute
? "muted" : pa_cvolume_snprint(cv
, sizeof(cv
), &i
->volume
),
374 (double) i
->buffer_usec
,
375 (double) i
->sink_usec
,
376 i
->resample_method
? i
->resample_method
: "n/a",
377 pl
= pa_proplist_to_string(i
->proplist
));
382 static void get_source_output_info_callback(pa_context
*c
, const pa_source_output_info
*i
, int is_last
, void *userdata
) {
383 char t
[32], k
[32], s
[PA_SAMPLE_SPEC_SNPRINT_MAX
], cm
[PA_CHANNEL_MAP_SNPRINT_MAX
];
387 fprintf(stderr
, "Failed to get source output information: %s\n", pa_strerror(pa_context_errno(c
)));
404 snprintf(t
, sizeof(t
), "%u", i
->owner_module
);
405 snprintf(k
, sizeof(k
), "%u", i
->client
);
407 printf("*** Source Output #%u ***\n"
412 "Sample Specification: %s\n"
414 "Buffer Latency: %0.0f usec\n"
415 "Source Latency: %0.0f usec\n"
416 "Resample method: %s\n"
419 pa_strnull(i
->driver
),
420 i
->owner_module
!= PA_INVALID_INDEX
? t
: "n/a",
421 i
->client
!= PA_INVALID_INDEX
? k
: "n/a",
423 pa_sample_spec_snprint(s
, sizeof(s
), &i
->sample_spec
),
424 pa_channel_map_snprint(cm
, sizeof(cm
), &i
->channel_map
),
425 (double) i
->buffer_usec
,
426 (double) i
->source_usec
,
427 i
->resample_method
? i
->resample_method
: "n/a",
428 pl
= pa_proplist_to_string(i
->proplist
));
433 static void get_sample_info_callback(pa_context
*c
, const pa_sample_info
*i
, int is_last
, void *userdata
) {
434 char t
[32], s
[PA_SAMPLE_SPEC_SNPRINT_MAX
], cv
[PA_CVOLUME_SNPRINT_MAX
], cm
[PA_CHANNEL_MAP_SNPRINT_MAX
];
438 fprintf(stderr
, "Failed to get sample information: %s\n", pa_strerror(pa_context_errno(c
)));
455 pa_bytes_snprint(t
, sizeof(t
), i
->bytes
);
457 printf("*** Sample #%u ***\n"
460 "Sample Specification: %s\n"
469 pa_cvolume_snprint(cv
, sizeof(cv
), &i
->volume
),
470 pa_sample_spec_valid(&i
->sample_spec
) ? pa_sample_spec_snprint(s
, sizeof(s
), &i
->sample_spec
) : "n/a",
471 pa_sample_spec_valid(&i
->sample_spec
) ? pa_channel_map_snprint(cm
, sizeof(cm
), &i
->channel_map
) : "n/a",
472 (double) i
->duration
/1000000,
475 i
->filename
? i
->filename
: "n/a",
476 pl
= pa_proplist_to_string(i
->proplist
));
481 static void get_autoload_info_callback(pa_context
*c
, const pa_autoload_info
*i
, int is_last
, void *userdata
) {
483 fprintf(stderr
, "Failed to get autoload information: %s\n", pa_strerror(pa_context_errno(c
)));
499 printf("*** Autoload Entry #%u ***\n"
506 i
->type
== PA_AUTOLOAD_SINK
? "sink" : "source",
508 i
->argument
? i
->argument
: "");
511 static void simple_callback(pa_context
*c
, int success
, void *userdata
) {
513 fprintf(stderr
, "Failure: %s\n", pa_strerror(pa_context_errno(c
)));
521 static void index_callback(pa_context
*c
, uint32_t idx
, void *userdata
) {
522 if (idx
== PA_INVALID_INDEX
) {
523 fprintf(stderr
, "Failure: %s\n", pa_strerror(pa_context_errno(c
)));
533 static void stream_state_callback(pa_stream
*s
, void *userdata
) {
536 switch (pa_stream_get_state(s
)) {
537 case PA_STREAM_CREATING
:
538 case PA_STREAM_READY
:
541 case PA_STREAM_TERMINATED
:
545 case PA_STREAM_FAILED
:
547 fprintf(stderr
, "Failed to upload sample: %s\n", pa_strerror(pa_context_errno(pa_stream_get_context(s
))));
552 static void stream_write_callback(pa_stream
*s
, size_t length
, void *userdata
) {
555 assert(s
&& length
&& sndfile
);
557 d
= pa_xmalloc(length
);
559 assert(sample_length
>= length
);
560 l
= length
/pa_frame_size(&sample_spec
);
562 if ((sf_readf_float(sndfile
, d
, l
)) != l
) {
564 fprintf(stderr
, "Premature end of file\n");
568 pa_stream_write(s
, d
, length
, pa_xfree
, 0, PA_SEEK_RELATIVE
);
570 sample_length
-= length
;
572 if (sample_length
<= 0) {
573 pa_stream_set_write_callback(sample_stream
, NULL
, NULL
);
574 pa_stream_finish_upload(sample_stream
);
578 static void context_state_callback(pa_context
*c
, void *userdata
) {
580 switch (pa_context_get_state(c
)) {
581 case PA_CONTEXT_CONNECTING
:
582 case PA_CONTEXT_AUTHORIZING
:
583 case PA_CONTEXT_SETTING_NAME
:
586 case PA_CONTEXT_READY
:
590 pa_operation_unref(pa_context_stat(c
, stat_callback
, NULL
));
591 pa_operation_unref(pa_context_get_server_info(c
, get_server_info_callback
, NULL
));
595 pa_operation_unref(pa_context_play_sample(c
, sample_name
, device
, PA_VOLUME_NORM
, simple_callback
, NULL
));
599 pa_operation_unref(pa_context_remove_sample(c
, sample_name
, simple_callback
, NULL
));
603 sample_stream
= pa_stream_new(c
, sample_name
, &sample_spec
, NULL
);
604 assert(sample_stream
);
606 pa_stream_set_state_callback(sample_stream
, stream_state_callback
, NULL
);
607 pa_stream_set_write_callback(sample_stream
, stream_write_callback
, NULL
);
608 pa_stream_connect_upload(sample_stream
, sample_length
);
612 pa_operation_unref(pa_context_exit_daemon(c
, NULL
, NULL
));
617 pa_operation_unref(pa_context_get_module_info_list(c
, get_module_info_callback
, NULL
));
618 pa_operation_unref(pa_context_get_sink_info_list(c
, get_sink_info_callback
, NULL
));
619 pa_operation_unref(pa_context_get_source_info_list(c
, get_source_info_callback
, NULL
));
620 pa_operation_unref(pa_context_get_sink_input_info_list(c
, get_sink_input_info_callback
, NULL
));
621 pa_operation_unref(pa_context_get_source_output_info_list(c
, get_source_output_info_callback
, NULL
));
622 pa_operation_unref(pa_context_get_client_info_list(c
, get_client_info_callback
, NULL
));
623 pa_operation_unref(pa_context_get_sample_info_list(c
, get_sample_info_callback
, NULL
));
624 pa_operation_unref(pa_context_get_autoload_info_list(c
, get_autoload_info_callback
, NULL
));
627 case MOVE_SINK_INPUT
:
628 pa_operation_unref(pa_context_move_sink_input_by_name(c
, sink_input_idx
, sink_name
, simple_callback
, NULL
));
631 case MOVE_SOURCE_OUTPUT
:
632 pa_operation_unref(pa_context_move_source_output_by_name(c
, source_output_idx
, source_name
, simple_callback
, NULL
));
636 pa_operation_unref(pa_context_load_module(c
, module_name
, module_args
, index_callback
, NULL
));
640 pa_operation_unref(pa_context_unload_module(c
, module_index
, simple_callback
, NULL
));
645 pa_operation_unref(pa_context_suspend_sink_by_name(c
, sink_name
, suspend
, simple_callback
, NULL
));
647 pa_operation_unref(pa_context_suspend_sink_by_index(c
, PA_INVALID_INDEX
, suspend
, simple_callback
, NULL
));
652 pa_operation_unref(pa_context_suspend_source_by_name(c
, source_name
, suspend
, simple_callback
, NULL
));
654 pa_operation_unref(pa_context_suspend_source_by_index(c
, PA_INVALID_INDEX
, suspend
, simple_callback
, NULL
));
662 case PA_CONTEXT_TERMINATED
:
666 case PA_CONTEXT_FAILED
:
668 fprintf(stderr
, "Connection failure: %s\n", pa_strerror(pa_context_errno(c
)));
673 static void exit_signal_callback(pa_mainloop_api
*m
, pa_signal_event
*e
, int sig
, void *userdata
) {
674 fprintf(stderr
, "Got SIGINT, exiting.\n");
678 static void help(const char *argv0
) {
680 printf("%s [options] stat\n"
681 "%s [options] list\n"
682 "%s [options] exit\n"
683 "%s [options] upload-sample FILENAME [NAME]\n"
684 "%s [options] play-sample NAME [SINK]\n"
685 "%s [options] remove-sample NAME\n"
686 "%s [options] move-sink-input ID SINK\n"
687 "%s [options] move-source-output ID SOURCE\n"
688 "%s [options] load-module NAME [ARGS ...]\n"
689 "%s [options] unload-module ID\n"
690 "%s [options] suspend-sink [SINK] 1|0\n"
691 "%s [options] suspend-source [SOURCE] 1|0\n\n"
692 " -h, --help Show this help\n"
693 " --version Show version\n\n"
694 " -s, --server=SERVER The name of the server to connect to\n"
695 " -n, --client-name=NAME How to call this client on the server\n",
696 argv0
, argv0
, argv0
, argv0
, argv0
, argv0
, argv0
, argv0
, argv0
, argv0
, argv0
, argv0
);
699 enum { ARG_VERSION
= 256 };
701 int main(int argc
, char *argv
[]) {
702 pa_mainloop
* m
= NULL
;
705 char *server
= NULL
, *client_name
= NULL
, *bn
;
707 static const struct option long_options
[] = {
708 {"server", 1, NULL
, 's'},
709 {"client-name", 1, NULL
, 'n'},
710 {"version", 0, NULL
, ARG_VERSION
},
711 {"help", 0, NULL
, 'h'},
715 if (!(bn
= strrchr(argv
[0], '/')))
720 while ((c
= getopt_long(argc
, argv
, "s:n:h", long_options
, NULL
)) != -1) {
728 printf("pactl "PACKAGE_VERSION
"\nCompiled with libpulse %s\nLinked with libpulse %s\n", pa_get_headers_version(), pa_get_library_version());
734 server
= pa_xstrdup(optarg
);
738 pa_xfree(client_name
);
739 client_name
= pa_xstrdup(optarg
);
748 client_name
= pa_xstrdup(bn
);
751 if (!strcmp(argv
[optind
], "stat"))
753 else if (!strcmp(argv
[optind
], "exit"))
755 else if (!strcmp(argv
[optind
], "list"))
757 else if (!strcmp(argv
[optind
], "upload-sample")) {
758 struct SF_INFO sfinfo
;
759 action
= UPLOAD_SAMPLE
;
761 if (optind
+1 >= argc
) {
762 fprintf(stderr
, "Please specify a sample file to load\n");
767 sample_name
= pa_xstrdup(argv
[optind
+2]);
769 char *f
= strrchr(argv
[optind
+1], '/');
779 sample_name
= pa_xstrdup(tmp
);
782 memset(&sfinfo
, 0, sizeof(sfinfo
));
783 if (!(sndfile
= sf_open(argv
[optind
+1], SFM_READ
, &sfinfo
))) {
784 fprintf(stderr
, "Failed to open sound file.\n");
788 sample_spec
.format
= PA_SAMPLE_FLOAT32
;
789 sample_spec
.rate
= sfinfo
.samplerate
;
790 sample_spec
.channels
= sfinfo
.channels
;
792 sample_length
= sfinfo
.frames
*pa_frame_size(&sample_spec
);
793 } else if (!strcmp(argv
[optind
], "play-sample")) {
794 action
= PLAY_SAMPLE
;
795 if (argc
!= optind
+2 && argc
!= optind
+3) {
796 fprintf(stderr
, "You have to specify a sample name to play\n");
800 sample_name
= pa_xstrdup(argv
[optind
+1]);
803 device
= pa_xstrdup(argv
[optind
+2]);
805 } else if (!strcmp(argv
[optind
], "remove-sample")) {
806 action
= REMOVE_SAMPLE
;
807 if (argc
!= optind
+2) {
808 fprintf(stderr
, "You have to specify a sample name to remove\n");
812 sample_name
= pa_xstrdup(argv
[optind
+1]);
813 } else if (!strcmp(argv
[optind
], "move-sink-input")) {
814 action
= MOVE_SINK_INPUT
;
815 if (argc
!= optind
+3) {
816 fprintf(stderr
, "You have to specify a sink input index and a sink\n");
820 sink_input_idx
= atoi(argv
[optind
+1]);
821 sink_name
= pa_xstrdup(argv
[optind
+2]);
822 } else if (!strcmp(argv
[optind
], "move-source-output")) {
823 action
= MOVE_SOURCE_OUTPUT
;
824 if (argc
!= optind
+3) {
825 fprintf(stderr
, "You have to specify a source output index and a source\n");
829 source_output_idx
= atoi(argv
[optind
+1]);
830 source_name
= pa_xstrdup(argv
[optind
+2]);
831 } else if (!strcmp(argv
[optind
], "load-module")) {
836 action
= LOAD_MODULE
;
838 if (argc
<= optind
+1) {
839 fprintf(stderr
, "You have to specify a module name and arguments.\n");
843 module_name
= argv
[optind
+1];
845 for (i
= optind
+2; i
< argc
; i
++)
846 n
+= strlen(argv
[i
])+1;
849 p
= module_args
= pa_xnew0(char, n
);
851 for (i
= optind
+2; i
< argc
; i
++)
852 p
+= sprintf(p
, "%s%s", p
== module_args
? "" : " ", argv
[i
]);
855 } else if (!strcmp(argv
[optind
], "unload-module")) {
856 action
= UNLOAD_MODULE
;
858 if (argc
!= optind
+2) {
859 fprintf(stderr
, "You have to specify a module index\n");
863 module_index
= atoi(argv
[optind
+1]);
865 } else if (!strcmp(argv
[optind
], "suspend-sink")) {
866 action
= SUSPEND_SINK
;
868 if (argc
> optind
+3 || optind
+1 >= argc
) {
869 fprintf(stderr
, "You may not specify more than one sink. You have to specify at least one boolean value.\n");
873 suspend
= pa_parse_boolean(argv
[argc
-1]);
876 sink_name
= pa_xstrdup(argv
[optind
+1]);
878 } else if (!strcmp(argv
[optind
], "suspend-source")) {
879 action
= SUSPEND_SOURCE
;
881 if (argc
> optind
+3 || optind
+1 >= argc
) {
882 fprintf(stderr
, "You may not specify more than one source. You have to specify at least one boolean value.\n");
886 suspend
= pa_parse_boolean(argv
[argc
-1]);
889 source_name
= pa_xstrdup(argv
[optind
+1]);
890 } else if (!strcmp(argv
[optind
], "help")) {
897 if (action
== NONE
) {
898 fprintf(stderr
, "No valid command specified.\n");
902 if (!(m
= pa_mainloop_new())) {
903 fprintf(stderr
, "pa_mainloop_new() failed.\n");
907 mainloop_api
= pa_mainloop_get_api(m
);
909 r
= pa_signal_init(mainloop_api
);
911 pa_signal_new(SIGINT
, exit_signal_callback
, NULL
);
913 signal(SIGPIPE
, SIG_IGN
);
916 if (!(context
= pa_context_new(mainloop_api
, client_name
))) {
917 fprintf(stderr
, "pa_context_new() failed.\n");
921 pa_context_set_state_callback(context
, context_state_callback
, NULL
);
922 pa_context_connect(context
, server
, 0, NULL
);
924 if (pa_mainloop_run(m
, &ret
) < 0) {
925 fprintf(stderr
, "pa_mainloop_run() failed.\n");
931 pa_stream_unref(sample_stream
);
934 pa_context_unref(context
);
946 pa_xfree(sample_name
);
948 pa_xfree(source_name
);
949 pa_xfree(module_args
);
950 pa_xfree(client_name
);