]> code.delx.au - pulseaudio/blobdiff - polyp/pactl.c
Merge Pierre's changes
[pulseaudio] / polyp / pactl.c
index 2a466b39c3cc0a2e5f3ad399f3f17023d07bfa9b..725b5460a730e816c30ef432d9aa2ae90ba02031 100644 (file)
@@ -4,7 +4,7 @@
   This file is part of polypaudio.
  
   polypaudio is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published
+  it under the terms of the GNU Lesser General Public License as published
   by the Free Software Foundation; either version 2 of the License,
   or (at your option) any later version.
  
@@ -13,7 +13,7 @@
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   General Public License for more details.
  
-  You should have received a copy of the GNU General Public License
+  You should have received a copy of the GNU Lesser General Public License
   along with polypaudio; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 #include <polyp/mainloop-signal.h>
 #include <polyp/sample.h>
 
+#if PA_API_VERSION != 8
+#error Invalid Polypaudio API version
+#endif
+
 #define BUFSIZE 1024
 
 static struct pa_context *context = NULL;
@@ -130,20 +134,22 @@ static void get_server_info_callback(struct pa_context *c, const struct pa_serve
            "Server Version: %s\n"
            "Default Sample Specification: %s\n"
            "Default Sink: %s\n"
-           "Default Source: %s\n",
+           "Default Source: %s\n"
+           "Cookie: %08x\n",
            i->user_name,
            i->host_name,
            i->server_name,
            i->server_version,
            s,
            i->default_sink_name,
-           i->default_source_name);
+           i->default_source_name,
+           i->cookie);
 
     complete_action();
 }
 
 static void get_sink_info_callback(struct pa_context *c, const struct pa_sink_info *i, int is_last, void *userdata) {
-    char s[PA_SAMPLE_SPEC_SNPRINT_MAX];
+    char s[PA_SAMPLE_SPEC_SNPRINT_MAX], tid[5];
 
     if (is_last < 0) {
         fprintf(stderr, "Failed to get sink information: %s\n", pa_strerror(pa_context_errno(c)));
@@ -166,6 +172,7 @@ static void get_sink_info_callback(struct pa_context *c, const struct pa_sink_in
     
     printf("*** Sink #%u ***\n"
            "Name: %s\n"
+           "Type: %s\n"
            "Description: %s\n"
            "Sample Specification: %s\n"
            "Owner Module: %u\n"
@@ -174,16 +181,18 @@ static void get_sink_info_callback(struct pa_context *c, const struct pa_sink_in
            "Latency: %0.0f usec\n",
            i->index,
            i->name,
+           pa_typeid_to_string(i->_typeid, tid, sizeof(tid)),
            i->description,
            s,
            i->owner_module,
            i->volume, pa_volume_to_dB(i->volume),
            i->monitor_source,
            (double) i->latency);
+
 }
 
 static void get_source_info_callback(struct pa_context *c, const struct pa_source_info *i, int is_last, void *userdata) {
-    char s[PA_SAMPLE_SPEC_SNPRINT_MAX], t[32];
+    char s[PA_SAMPLE_SPEC_SNPRINT_MAX], t[32], tid[5];
 
     if (is_last < 0) {
         fprintf(stderr, "Failed to get source information: %s\n", pa_strerror(pa_context_errno(c)));
@@ -208,18 +217,21 @@ static void get_source_info_callback(struct pa_context *c, const struct pa_sourc
     
     printf("*** Source #%u ***\n"
            "Name: %s\n"
+           "Type: %s\n"
            "Description: %s\n"
            "Sample Specification: %s\n"
            "Owner Module: %u\n"
            "Monitor of Sink: %s\n"
            "Latency: %0.0f usec\n",
            i->index,
+           pa_typeid_to_string(i->_typeid, tid, sizeof(tid)),
            i->name,
            i->description,
            s,
            i->owner_module,
            i->monitor_of_sink != PA_INVALID_INDEX ? t : "no",
            (double) i->latency);
+    
 }
 
 static void get_module_info_callback(struct pa_context *c, const struct pa_module_info *i, int is_last, void *userdata) {
@@ -257,7 +269,7 @@ static void get_module_info_callback(struct pa_context *c, const struct pa_modul
 }
 
 static void get_client_info_callback(struct pa_context *c, const struct pa_client_info *i, int is_last, void *userdata) {
-    char t[32];
+    char t[32], tid[5];
 
     if (is_last < 0) {
         fprintf(stderr, "Failed to get client information: %s\n", pa_strerror(pa_context_errno(c)));
@@ -280,16 +292,16 @@ static void get_client_info_callback(struct pa_context *c, const struct pa_clien
     
     printf("*** Client #%u ***\n"
            "Name: %s\n"
-           "Owner Module: %s\n"
-           "Protocol Name: %s\n",
+           "Type: %s\n"
+           "Owner Module: %s\n",
            i->index,
            i->name,
-           i->owner_module != PA_INVALID_INDEX ? t : "n/a",
-           i->protocol_name);
+           pa_typeid_to_string(i->_typeid, tid, sizeof(tid)),
+           i->owner_module != PA_INVALID_INDEX ? t : "n/a");
 }
 
 static void get_sink_input_info_callback(struct pa_context *c, const struct pa_sink_input_info *i, int is_last, void *userdata) {
-    char t[32], k[32], s[PA_SAMPLE_SPEC_SNPRINT_MAX];
+    char t[32], k[32], s[PA_SAMPLE_SPEC_SNPRINT_MAX], tid[5];
 
     if (is_last < 0) {
         fprintf(stderr, "Failed to get sink input information: %s\n", pa_strerror(pa_context_errno(c)));
@@ -314,26 +326,31 @@ static void get_sink_input_info_callback(struct pa_context *c, const struct pa_s
     
     printf("*** Sink Input #%u ***\n"
            "Name: %s\n"
+           "Type: %s\n"
            "Owner Module: %s\n"
            "Client: %s\n"
            "Sink: %u\n"
            "Sample Specification: %s\n"
            "Volume: 0x%03x (%0.2f dB)\n"
            "Buffer Latency: %0.0f usec\n"
-           "Sink Latency: %0.0f usec\n",
+           "Sink Latency: %0.0f usec\n"
+           "Resample method: %s\n",
            i->index,
            i->name,
+           pa_typeid_to_string(i->_typeid, tid, sizeof(tid)),
            i->owner_module != PA_INVALID_INDEX ? t : "n/a",
            i->client != PA_INVALID_INDEX ? k : "n/a",
            i->sink,
            s,
            i->volume, pa_volume_to_dB(i->volume),
            (double) i->buffer_usec,
-           (double) i->sink_usec);
+           (double) i->sink_usec,
+           i->resample_method ? i->resample_method : "n/a");
 }
 
+
 static void get_source_output_info_callback(struct pa_context *c, const struct pa_source_output_info *i, int is_last, void *userdata) {
-    char t[32], k[32], s[PA_SAMPLE_SPEC_SNPRINT_MAX];
+    char t[32], k[32], s[PA_SAMPLE_SPEC_SNPRINT_MAX], tid[5];
 
     if (is_last < 0) {
         fprintf(stderr, "Failed to get source output information: %s\n", pa_strerror(pa_context_errno(c)));
@@ -358,20 +375,24 @@ static void get_source_output_info_callback(struct pa_context *c, const struct p
     
     printf("*** Source Output #%u ***\n"
            "Name: %s\n"
+           "Type: %s\n"
            "Owner Module: %s\n"
            "Client: %s\n"
            "Source: %u\n"
            "Sample Specification: %s\n"
            "Buffer Latency: %0.0f usec\n"
-           "Source Latency: %0.0f usec\n",
+           "Source Latency: %0.0f usec\n"
+           "Resample method: %s\n",
            i->index,
            i->name,
+           pa_typeid_to_string(i->_typeid, tid, sizeof(tid)),
            i->owner_module != PA_INVALID_INDEX ? t : "n/a",
            i->client != PA_INVALID_INDEX ? k : "n/a",
            i->source,
            s,
            (double) i->buffer_usec,
-           (double) i->source_usec);
+           (double) i->source_usec,
+           i->resample_method ? i->resample_method : "n/a");
 }
 
 static void get_sample_info_callback(struct pa_context *c, const struct pa_sample_info *i, int is_last, void *userdata) {
@@ -433,11 +454,12 @@ static void get_autoload_info_callback(struct pa_context *c, const struct pa_aut
         printf("\n");
     nl = 1;
 
-    printf("*** Autoload Entry ***\n"
+    printf("*** Autoload Entry #%u ***\n"
            "Name: %s\n"
            "Type: %s\n"
            "Module: %s\n"
            "Argument: %s\n",
+           i->index,
            i->name,
            i->type == PA_AUTOLOAD_SINK ? "sink" : "source",
            i->module,
@@ -717,7 +739,9 @@ int main(int argc, char *argv[]) {
     r = pa_signal_init(mainloop_api);
     assert(r == 0);
     pa_signal_new(SIGINT, exit_signal_callback, NULL);
+#ifdef SIGPIPE
     signal(SIGPIPE, SIG_IGN);
+#endif
     
     if (!(context = pa_context_new(mainloop_api, client_name))) {
         fprintf(stderr, "pa_context_new() failed.\n");