LCOV - code coverage report
Current view: top level - pulse - introspect.c (source / functions) Hit Total Coverage
Test: lcov.out Lines: 0 1216 0.0 %
Date: 2012-07-17 Functions: 0 74 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1214 0.0 %

           Branch data     Line data    Source code
       1                 :            : /***
       2                 :            :   This file is part of PulseAudio.
       3                 :            : 
       4                 :            :   Copyright 2004-2006 Lennart Poettering
       5                 :            :   Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
       6                 :            : 
       7                 :            :   PulseAudio is free software; you can redistribute it and/or modify
       8                 :            :   it under the terms of the GNU Lesser General Public License as published
       9                 :            :   by the Free Software Foundation; either version 2.1 of the License,
      10                 :            :   or (at your option) any later version.
      11                 :            : 
      12                 :            :   PulseAudio is distributed in the hope that it will be useful, but
      13                 :            :   WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :            :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
      15                 :            :   General Public License for more details.
      16                 :            : 
      17                 :            :   You should have received a copy of the GNU Lesser General Public License
      18                 :            :   along with PulseAudio; if not, write to the Free Software
      19                 :            :   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
      20                 :            :   USA.
      21                 :            : ***/
      22                 :            : 
      23                 :            : #ifdef HAVE_CONFIG_H
      24                 :            : #include <config.h>
      25                 :            : #endif
      26                 :            : 
      27                 :            : #include <pulse/context.h>
      28                 :            : #include <pulse/xmalloc.h>
      29                 :            : #include <pulse/fork-detect.h>
      30                 :            : 
      31                 :            : #include <pulsecore/macro.h>
      32                 :            : #include <pulsecore/core-util.h>
      33                 :            : #include <pulsecore/pstream-util.h>
      34                 :            : 
      35                 :            : #include "internal.h"
      36                 :            : #include "introspect.h"
      37                 :            : 
      38                 :            : /*** Statistics ***/
      39                 :            : 
      40                 :          0 : static void context_stat_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
      41                 :          0 :     pa_operation *o = userdata;
      42                 :          0 :     pa_stat_info i, *p = &i;
      43                 :            : 
      44         [ #  # ]:          0 :     pa_assert(pd);
      45         [ #  # ]:          0 :     pa_assert(o);
      46         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(o) >= 1);
      47                 :            : 
      48                 :            :     pa_zero(i);
      49                 :            : 
      50         [ #  # ]:          0 :     if (!o->context)
      51                 :            :         goto finish;
      52                 :            : 
      53         [ #  # ]:          0 :     if (command != PA_COMMAND_REPLY) {
      54         [ #  # ]:          0 :         if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
      55                 :            :             goto finish;
      56                 :            : 
      57                 :            :         p = NULL;
      58   [ #  #  #  # ]:          0 :     } else if (pa_tagstruct_getu32(t, &i.memblock_total) < 0 ||
      59         [ #  # ]:          0 :                pa_tagstruct_getu32(t, &i.memblock_total_size) < 0 ||
      60         [ #  # ]:          0 :                pa_tagstruct_getu32(t, &i.memblock_allocated) < 0 ||
      61         [ #  # ]:          0 :                pa_tagstruct_getu32(t, &i.memblock_allocated_size) < 0 ||
      62         [ #  # ]:          0 :                pa_tagstruct_getu32(t, &i.scache_size) < 0 ||
      63                 :          0 :                !pa_tagstruct_eof(t)) {
      64                 :          0 :         pa_context_fail(o->context, PA_ERR_PROTOCOL);
      65                 :          0 :         goto finish;
      66                 :            :     }
      67                 :            : 
      68         [ #  # ]:          0 :     if (o->callback) {
      69                 :          0 :         pa_stat_info_cb_t cb = (pa_stat_info_cb_t) o->callback;
      70                 :          0 :         cb(o->context, p, o->userdata);
      71                 :            :     }
      72                 :            : 
      73                 :            : finish:
      74                 :          0 :     pa_operation_done(o);
      75                 :          0 :     pa_operation_unref(o);
      76                 :          0 : }
      77                 :            : 
      78                 :          0 : pa_operation* pa_context_stat(pa_context *c, pa_stat_info_cb_t cb, void *userdata) {
      79                 :          0 :     return pa_context_send_simple_command(c, PA_COMMAND_STAT, context_stat_callback, (pa_operation_cb_t) cb, userdata);
      80                 :            : }
      81                 :            : 
      82                 :            : /*** Server Info ***/
      83                 :            : 
      84                 :          0 : static void context_get_server_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
      85                 :          0 :     pa_operation *o = userdata;
      86                 :          0 :     pa_server_info i, *p = &i;
      87                 :            : 
      88         [ #  # ]:          0 :     pa_assert(pd);
      89         [ #  # ]:          0 :     pa_assert(o);
      90         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(o) >= 1);
      91                 :            : 
      92                 :            :     pa_zero(i);
      93                 :            : 
      94         [ #  # ]:          0 :     if (!o->context)
      95                 :            :         goto finish;
      96                 :            : 
      97         [ #  # ]:          0 :     if (command != PA_COMMAND_REPLY) {
      98         [ #  # ]:          0 :         if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
      99                 :            :             goto finish;
     100                 :            : 
     101                 :            :         p = NULL;
     102   [ #  #  #  # ]:          0 :     } else if (pa_tagstruct_gets(t, &i.server_name) < 0 ||
     103         [ #  # ]:          0 :                pa_tagstruct_gets(t, &i.server_version) < 0 ||
     104         [ #  # ]:          0 :                pa_tagstruct_gets(t, &i.user_name) < 0 ||
     105         [ #  # ]:          0 :                pa_tagstruct_gets(t, &i.host_name) < 0 ||
     106         [ #  # ]:          0 :                pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 ||
     107         [ #  # ]:          0 :                pa_tagstruct_gets(t, &i.default_sink_name) < 0 ||
     108         [ #  # ]:          0 :                pa_tagstruct_gets(t, &i.default_source_name) < 0 ||
     109         [ #  # ]:          0 :                pa_tagstruct_getu32(t, &i.cookie) < 0 ||
     110         [ #  # ]:          0 :                (o->context->version >= 15 &&
     111         [ #  # ]:          0 :                 pa_tagstruct_get_channel_map(t, &i.channel_map) < 0) ||
     112                 :          0 :                !pa_tagstruct_eof(t)) {
     113                 :            : 
     114                 :          0 :         pa_context_fail(o->context, PA_ERR_PROTOCOL);
     115                 :          0 :         goto finish;
     116                 :            :     }
     117                 :            : 
     118 [ #  # ][ #  # ]:          0 :     if (p && o->context->version < 15)
     119                 :          0 :         pa_channel_map_init_extend(&i.channel_map, i.sample_spec.channels, PA_CHANNEL_MAP_DEFAULT);
     120                 :            : 
     121         [ #  # ]:          0 :     if (o->callback) {
     122                 :          0 :         pa_server_info_cb_t cb = (pa_server_info_cb_t) o->callback;
     123                 :          0 :         cb(o->context, p, o->userdata);
     124                 :            :     }
     125                 :            : 
     126                 :            : finish:
     127                 :          0 :     pa_operation_done(o);
     128                 :          0 :     pa_operation_unref(o);
     129                 :          0 : }
     130                 :            : 
     131                 :          0 : pa_operation* pa_context_get_server_info(pa_context *c, pa_server_info_cb_t cb, void *userdata) {
     132                 :          0 :     return pa_context_send_simple_command(c, PA_COMMAND_GET_SERVER_INFO, context_get_server_info_callback, (pa_operation_cb_t) cb, userdata);
     133                 :            : }
     134                 :            : 
     135                 :            : /*** Sink Info ***/
     136                 :            : 
     137                 :          0 : static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
     138                 :          0 :     pa_operation *o = userdata;
     139                 :          0 :     int eol = 1;
     140                 :            :     pa_sink_info i;
     141                 :            :     uint32_t j;
     142                 :            : 
     143         [ #  # ]:          0 :     pa_assert(pd);
     144         [ #  # ]:          0 :     pa_assert(o);
     145         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(o) >= 1);
     146                 :            : 
     147                 :            :     /* For safety in case someone use fail: outside the while loop below */
     148                 :            :     pa_zero(i);
     149                 :            : 
     150         [ #  # ]:          0 :     if (!o->context)
     151                 :            :         goto finish;
     152                 :            : 
     153         [ #  # ]:          0 :     if (command != PA_COMMAND_REPLY) {
     154         [ #  # ]:          0 :         if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
     155                 :            :             goto finish;
     156                 :            : 
     157                 :            :         eol = -1;
     158                 :            :     } else {
     159                 :            : 
     160         [ #  # ]:          0 :         while (!pa_tagstruct_eof(t)) {
     161                 :            :             pa_bool_t mute;
     162                 :            :             uint32_t flags;
     163                 :            :             uint32_t state;
     164                 :          0 :             const char *ap = NULL;
     165                 :            : 
     166                 :            :             pa_zero(i);
     167                 :          0 :             i.proplist = pa_proplist_new();
     168                 :          0 :             i.base_volume = PA_VOLUME_NORM;
     169                 :          0 :             i.n_volume_steps = PA_VOLUME_NORM+1;
     170                 :          0 :             mute = FALSE;
     171                 :          0 :             state = PA_SINK_INVALID_STATE;
     172                 :          0 :             i.card = PA_INVALID_INDEX;
     173                 :            : 
     174   [ #  #  #  # ]:          0 :             if (pa_tagstruct_getu32(t, &i.index) < 0 ||
     175         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.name) < 0 ||
     176         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.description) < 0 ||
     177         [ #  # ]:          0 :                 pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 ||
     178         [ #  # ]:          0 :                 pa_tagstruct_get_channel_map(t, &i.channel_map) < 0 ||
     179         [ #  # ]:          0 :                 pa_tagstruct_getu32(t, &i.owner_module) < 0 ||
     180         [ #  # ]:          0 :                 pa_tagstruct_get_cvolume(t, &i.volume) < 0 ||
     181         [ #  # ]:          0 :                 pa_tagstruct_get_boolean(t, &mute) < 0 ||
     182         [ #  # ]:          0 :                 pa_tagstruct_getu32(t, &i.monitor_source) < 0 ||
     183         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.monitor_source_name) < 0 ||
     184         [ #  # ]:          0 :                 pa_tagstruct_get_usec(t, &i.latency) < 0 ||
     185         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.driver) < 0 ||
     186         [ #  # ]:          0 :                 pa_tagstruct_getu32(t, &flags) < 0 ||
     187         [ #  # ]:          0 :                 (o->context->version >= 13 &&
     188         [ #  # ]:          0 :                  (pa_tagstruct_get_proplist(t, i.proplist) < 0 ||
     189         [ #  # ]:          0 :                   pa_tagstruct_get_usec(t, &i.configured_latency) < 0)) ||
     190         [ #  # ]:          0 :                 (o->context->version >= 15 &&
     191         [ #  # ]:          0 :                  (pa_tagstruct_get_volume(t, &i.base_volume) < 0 ||
     192         [ #  # ]:          0 :                   pa_tagstruct_getu32(t, &state) < 0 ||
     193         [ #  # ]:          0 :                   pa_tagstruct_getu32(t, &i.n_volume_steps) < 0 ||
     194         [ #  # ]:          0 :                   pa_tagstruct_getu32(t, &i.card) < 0)) ||
     195         [ #  # ]:          0 :                 (o->context->version >= 16 &&
     196                 :          0 :                  (pa_tagstruct_getu32(t, &i.n_ports)))) {
     197                 :            : 
     198                 :            :                 goto fail;
     199                 :            :             }
     200                 :            : 
     201         [ #  # ]:          0 :             if (o->context->version >= 16) {
     202         [ #  # ]:          0 :                 if (i.n_ports > 0) {
     203                 :          0 :                     i.ports = pa_xnew(pa_sink_port_info*, i.n_ports+1);
     204                 :          0 :                     i.ports[0] = pa_xnew(pa_sink_port_info, i.n_ports);
     205                 :            : 
     206         [ #  # ]:          0 :                     for (j = 0; j < i.n_ports; j++) {
     207                 :          0 :                         i.ports[j] = &i.ports[0][j];
     208                 :            : 
     209   [ #  #  #  # ]:          0 :                         if (pa_tagstruct_gets(t, &i.ports[j]->name) < 0 ||
     210         [ #  # ]:          0 :                             pa_tagstruct_gets(t, &i.ports[j]->description) < 0 ||
     211                 :          0 :                             pa_tagstruct_getu32(t, &i.ports[j]->priority) < 0) {
     212                 :            : 
     213                 :            :                             goto fail;
     214                 :            :                         }
     215                 :            : 
     216                 :          0 :                         i.ports[j]->available = PA_PORT_AVAILABLE_UNKNOWN;
     217         [ #  # ]:          0 :                         if (o->context->version >= 24) {
     218                 :            :                             uint32_t av;
     219 [ #  # ][ #  # ]:          0 :                             if (pa_tagstruct_getu32(t, &av) < 0 || av > PA_PORT_AVAILABLE_YES)
     220                 :            :                                 goto fail;
     221                 :          0 :                             i.ports[j]->available = av;
     222                 :            :                         }
     223                 :            :                     }
     224                 :            : 
     225                 :          0 :                     i.ports[j] = NULL;
     226                 :            :                 }
     227                 :            : 
     228         [ #  # ]:          0 :                 if (pa_tagstruct_gets(t, &ap) < 0)
     229                 :            :                     goto fail;
     230                 :            : 
     231         [ #  # ]:          0 :                 if (ap) {
     232         [ #  # ]:          0 :                     for (j = 0; j < i.n_ports; j++)
     233         [ #  # ]:          0 :                         if (pa_streq(i.ports[j]->name, ap)) {
     234                 :          0 :                             i.active_port = i.ports[j];
     235                 :          0 :                             break;
     236                 :            :                         }
     237                 :            :                 }
     238                 :            :             }
     239                 :            : 
     240         [ #  # ]:          0 :             if (o->context->version >= 21) {
     241                 :            :                 uint8_t n_formats;
     242 [ #  # ][ #  # ]:          0 :                 if (pa_tagstruct_getu8(t, &n_formats) < 0 || n_formats < 1)
     243                 :            :                     goto fail;
     244                 :            : 
     245                 :          0 :                 i.formats = pa_xnew0(pa_format_info*, n_formats);
     246                 :            : 
     247         [ #  # ]:          0 :                 for (j = 0; j < n_formats; j++) {
     248                 :          0 :                     i.n_formats++;
     249                 :          0 :                     i.formats[j] = pa_format_info_new();
     250                 :            : 
     251         [ #  # ]:          0 :                     if (pa_tagstruct_get_format_info(t, i.formats[j]) < 0)
     252                 :            :                         goto fail;
     253                 :            :                 }
     254                 :            :             }
     255                 :            : 
     256                 :          0 :             i.mute = (int) mute;
     257                 :          0 :             i.flags = (pa_sink_flags_t) flags;
     258                 :          0 :             i.state = (pa_sink_state_t) state;
     259                 :            : 
     260         [ #  # ]:          0 :             if (o->callback) {
     261                 :          0 :                 pa_sink_info_cb_t cb = (pa_sink_info_cb_t) o->callback;
     262                 :          0 :                 cb(o->context, &i, 0, o->userdata);
     263                 :            :             }
     264                 :            : 
     265         [ #  # ]:          0 :             if (i.formats) {
     266         [ #  # ]:          0 :                 for (j = 0; j < i.n_formats; j++)
     267                 :          0 :                     pa_format_info_free(i.formats[j]);
     268                 :          0 :                 pa_xfree(i.formats);
     269                 :            :             }
     270         [ #  # ]:          0 :             if (i.ports) {
     271                 :          0 :                 pa_xfree(i.ports[0]);
     272                 :          0 :                 pa_xfree(i.ports);
     273                 :            :             }
     274                 :          0 :             pa_proplist_free(i.proplist);
     275                 :            :         }
     276                 :            :     }
     277                 :            : 
     278         [ #  # ]:          0 :     if (o->callback) {
     279                 :          0 :         pa_sink_info_cb_t cb = (pa_sink_info_cb_t) o->callback;
     280                 :          0 :         cb(o->context, NULL, eol, o->userdata);
     281                 :            :     }
     282                 :            : 
     283                 :            : finish:
     284                 :          0 :     pa_operation_done(o);
     285                 :          0 :     pa_operation_unref(o);
     286                 :          0 :     return;
     287                 :            : 
     288                 :            : fail:
     289         [ #  # ]:          0 :     pa_assert(i.proplist);
     290                 :            : 
     291                 :          0 :     pa_context_fail(o->context, PA_ERR_PROTOCOL);
     292                 :            : 
     293         [ #  # ]:          0 :     if (i.formats) {
     294         [ #  # ]:          0 :         for (j = 0; j < i.n_formats; j++)
     295                 :          0 :             pa_format_info_free(i.formats[j]);
     296                 :          0 :         pa_xfree(i.formats);
     297                 :            :     }
     298         [ #  # ]:          0 :     if (i.ports) {
     299                 :          0 :         pa_xfree(i.ports[0]);
     300                 :          0 :         pa_xfree(i.ports);
     301                 :            :     }
     302                 :          0 :     pa_proplist_free(i.proplist);
     303                 :            : 
     304                 :          0 :     goto finish;
     305                 :            : }
     306                 :            : 
     307                 :          0 : pa_operation* pa_context_get_sink_info_list(pa_context *c, pa_sink_info_cb_t cb, void *userdata) {
     308                 :          0 :     return pa_context_send_simple_command(c, PA_COMMAND_GET_SINK_INFO_LIST, context_get_sink_info_callback, (pa_operation_cb_t) cb, userdata);
     309                 :            : }
     310                 :            : 
     311                 :          0 : pa_operation* pa_context_get_sink_info_by_index(pa_context *c, uint32_t idx, pa_sink_info_cb_t cb, void *userdata) {
     312                 :            :     pa_tagstruct *t;
     313                 :            :     pa_operation *o;
     314                 :            :     uint32_t tag;
     315                 :            : 
     316         [ #  # ]:          0 :     pa_assert(c);
     317         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
     318         [ #  # ]:          0 :     pa_assert(cb);
     319                 :            : 
     320         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     321         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     322                 :            : 
     323                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
     324                 :            : 
     325                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_GET_SINK_INFO, &tag);
     326                 :          0 :     pa_tagstruct_putu32(t, idx);
     327                 :          0 :     pa_tagstruct_puts(t, NULL);
     328                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
     329                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_sink_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
     330                 :            : 
     331                 :          0 :     return o;
     332                 :            : }
     333                 :            : 
     334                 :          0 : pa_operation* pa_context_get_sink_info_by_name(pa_context *c, const char *name, pa_sink_info_cb_t cb, void *userdata) {
     335                 :            :     pa_tagstruct *t;
     336                 :            :     pa_operation *o;
     337                 :            :     uint32_t tag;
     338                 :            : 
     339         [ #  # ]:          0 :     pa_assert(c);
     340         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
     341         [ #  # ]:          0 :     pa_assert(cb);
     342                 :            : 
     343         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     344         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     345 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
     346                 :            : 
     347                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
     348                 :            : 
     349                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_GET_SINK_INFO, &tag);
     350                 :          0 :     pa_tagstruct_putu32(t, PA_INVALID_INDEX);
     351                 :          0 :     pa_tagstruct_puts(t, name);
     352                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
     353                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_sink_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
     354                 :            : 
     355                 :          0 :     return o;
     356                 :            : }
     357                 :            : 
     358                 :          0 : pa_operation* pa_context_set_sink_port_by_index(pa_context *c, uint32_t idx, const char*port, pa_context_success_cb_t cb, void *userdata) {
     359                 :            :     pa_operation *o;
     360                 :            :     pa_tagstruct *t;
     361                 :            :     uint32_t tag;
     362                 :            : 
     363         [ #  # ]:          0 :     pa_assert(c);
     364         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
     365                 :            : 
     366         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     367         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     368         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
     369         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 16, PA_ERR_NOTSUPPORTED);
     370                 :            : 
     371                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
     372                 :            : 
     373                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_PORT, &tag);
     374                 :          0 :     pa_tagstruct_putu32(t, idx);
     375                 :          0 :     pa_tagstruct_puts(t, NULL);
     376                 :          0 :     pa_tagstruct_puts(t, port);
     377                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
     378                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
     379                 :            : 
     380                 :          0 :     return o;
     381                 :            : }
     382                 :            : 
     383                 :          0 : pa_operation* pa_context_set_sink_port_by_name(pa_context *c, const char *name, const char*port, pa_context_success_cb_t cb, void *userdata) {
     384                 :            :     pa_operation *o;
     385                 :            :     pa_tagstruct *t;
     386                 :            :     uint32_t tag;
     387                 :            : 
     388         [ #  # ]:          0 :     pa_assert(c);
     389         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
     390                 :            : 
     391         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     392         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     393 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
     394         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 16, PA_ERR_NOTSUPPORTED);
     395                 :            : 
     396                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
     397                 :            : 
     398                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_PORT, &tag);
     399                 :          0 :     pa_tagstruct_putu32(t, PA_INVALID_INDEX);
     400                 :          0 :     pa_tagstruct_puts(t, name);
     401                 :          0 :     pa_tagstruct_puts(t, port);
     402                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
     403                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
     404                 :            : 
     405                 :          0 :     return o;
     406                 :            : }
     407                 :            : 
     408                 :            : /*** Source info ***/
     409                 :            : 
     410                 :          0 : static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
     411                 :          0 :     pa_operation *o = userdata;
     412                 :          0 :     int eol = 1;
     413                 :            :     pa_source_info i;
     414                 :            :     uint32_t j;
     415                 :            : 
     416         [ #  # ]:          0 :     pa_assert(pd);
     417         [ #  # ]:          0 :     pa_assert(o);
     418         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(o) >= 1);
     419                 :            : 
     420                 :            :     /* For safety in case someone use fail: outside the while loop below */
     421                 :            :     pa_zero(i);
     422                 :            : 
     423         [ #  # ]:          0 :     if (!o->context)
     424                 :            :         goto finish;
     425                 :            : 
     426         [ #  # ]:          0 :     if (command != PA_COMMAND_REPLY) {
     427         [ #  # ]:          0 :         if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
     428                 :            :             goto finish;
     429                 :            : 
     430                 :            :         eol = -1;
     431                 :            :     } else {
     432                 :            : 
     433         [ #  # ]:          0 :         while (!pa_tagstruct_eof(t)) {
     434                 :            :             pa_bool_t mute;
     435                 :            :             uint32_t flags;
     436                 :            :             uint32_t state;
     437                 :            :             const char *ap;
     438                 :            : 
     439                 :            :             pa_zero(i);
     440                 :          0 :             i.proplist = pa_proplist_new();
     441                 :          0 :             i.base_volume = PA_VOLUME_NORM;
     442                 :          0 :             i.n_volume_steps = PA_VOLUME_NORM+1;
     443                 :          0 :             mute = FALSE;
     444                 :          0 :             state = PA_SOURCE_INVALID_STATE;
     445                 :          0 :             i.card = PA_INVALID_INDEX;
     446                 :            : 
     447   [ #  #  #  # ]:          0 :             if (pa_tagstruct_getu32(t, &i.index) < 0 ||
     448         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.name) < 0 ||
     449         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.description) < 0 ||
     450         [ #  # ]:          0 :                 pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 ||
     451         [ #  # ]:          0 :                 pa_tagstruct_get_channel_map(t, &i.channel_map) < 0 ||
     452         [ #  # ]:          0 :                 pa_tagstruct_getu32(t, &i.owner_module) < 0 ||
     453         [ #  # ]:          0 :                 pa_tagstruct_get_cvolume(t, &i.volume) < 0 ||
     454         [ #  # ]:          0 :                 pa_tagstruct_get_boolean(t, &mute) < 0 ||
     455         [ #  # ]:          0 :                 pa_tagstruct_getu32(t, &i.monitor_of_sink) < 0 ||
     456         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.monitor_of_sink_name) < 0 ||
     457         [ #  # ]:          0 :                 pa_tagstruct_get_usec(t, &i.latency) < 0 ||
     458         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.driver) < 0 ||
     459         [ #  # ]:          0 :                 pa_tagstruct_getu32(t, &flags) < 0 ||
     460         [ #  # ]:          0 :                 (o->context->version >= 13 &&
     461         [ #  # ]:          0 :                  (pa_tagstruct_get_proplist(t, i.proplist) < 0 ||
     462         [ #  # ]:          0 :                   pa_tagstruct_get_usec(t, &i.configured_latency) < 0)) ||
     463         [ #  # ]:          0 :                 (o->context->version >= 15 &&
     464         [ #  # ]:          0 :                  (pa_tagstruct_get_volume(t, &i.base_volume) < 0 ||
     465         [ #  # ]:          0 :                   pa_tagstruct_getu32(t, &state) < 0 ||
     466         [ #  # ]:          0 :                   pa_tagstruct_getu32(t, &i.n_volume_steps) < 0 ||
     467         [ #  # ]:          0 :                   pa_tagstruct_getu32(t, &i.card) < 0)) ||
     468         [ #  # ]:          0 :                 (o->context->version >= 16 &&
     469                 :          0 :                  (pa_tagstruct_getu32(t, &i.n_ports)))) {
     470                 :            : 
     471                 :            :                 goto fail;
     472                 :            :             }
     473                 :            : 
     474         [ #  # ]:          0 :             if (o->context->version >= 16) {
     475         [ #  # ]:          0 :                 if (i.n_ports > 0) {
     476                 :          0 :                     i.ports = pa_xnew(pa_source_port_info*, i.n_ports+1);
     477                 :          0 :                     i.ports[0] = pa_xnew(pa_source_port_info, i.n_ports);
     478                 :            : 
     479         [ #  # ]:          0 :                     for (j = 0; j < i.n_ports; j++) {
     480                 :          0 :                         i.ports[j] = &i.ports[0][j];
     481                 :            : 
     482   [ #  #  #  # ]:          0 :                         if (pa_tagstruct_gets(t, &i.ports[j]->name) < 0 ||
     483         [ #  # ]:          0 :                             pa_tagstruct_gets(t, &i.ports[j]->description) < 0 ||
     484                 :          0 :                             pa_tagstruct_getu32(t, &i.ports[j]->priority) < 0) {
     485                 :            : 
     486                 :            :                             goto fail;
     487                 :            :                         }
     488                 :            : 
     489                 :          0 :                         i.ports[j]->available = PA_PORT_AVAILABLE_UNKNOWN;
     490         [ #  # ]:          0 :                         if (o->context->version >= 24) {
     491                 :            :                             uint32_t av;
     492 [ #  # ][ #  # ]:          0 :                             if (pa_tagstruct_getu32(t, &av) < 0 || av > PA_PORT_AVAILABLE_YES)
     493                 :            :                                 goto fail;
     494                 :          0 :                             i.ports[j]->available = av;
     495                 :            :                         }
     496                 :            :                     }
     497                 :            : 
     498                 :          0 :                     i.ports[j] = NULL;
     499                 :            :                 }
     500                 :            : 
     501         [ #  # ]:          0 :                 if (pa_tagstruct_gets(t, &ap) < 0)
     502                 :            :                     goto fail;
     503                 :            : 
     504         [ #  # ]:          0 :                 if (ap) {
     505         [ #  # ]:          0 :                     for (j = 0; j < i.n_ports; j++)
     506         [ #  # ]:          0 :                         if (pa_streq(i.ports[j]->name, ap)) {
     507                 :          0 :                             i.active_port = i.ports[j];
     508                 :          0 :                             break;
     509                 :            :                         }
     510                 :            :                 }
     511                 :            :             }
     512                 :            : 
     513         [ #  # ]:          0 :             if (o->context->version >= 22) {
     514                 :            :                 uint8_t n_formats;
     515 [ #  # ][ #  # ]:          0 :                 if (pa_tagstruct_getu8(t, &n_formats) < 0 || n_formats < 1)
     516                 :            :                     goto fail;
     517                 :            : 
     518                 :          0 :                 i.formats = pa_xnew0(pa_format_info*, n_formats);
     519                 :            : 
     520         [ #  # ]:          0 :                 for (j = 0; j < n_formats; j++) {
     521                 :          0 :                     i.n_formats++;
     522                 :          0 :                     i.formats[j] = pa_format_info_new();
     523                 :            : 
     524         [ #  # ]:          0 :                     if (pa_tagstruct_get_format_info(t, i.formats[j]) < 0)
     525                 :            :                         goto fail;
     526                 :            :                 }
     527                 :            :             }
     528                 :            : 
     529                 :          0 :             i.mute = (int) mute;
     530                 :          0 :             i.flags = (pa_source_flags_t) flags;
     531                 :          0 :             i.state = (pa_source_state_t) state;
     532                 :            : 
     533         [ #  # ]:          0 :             if (o->callback) {
     534                 :          0 :                 pa_source_info_cb_t cb = (pa_source_info_cb_t) o->callback;
     535                 :          0 :                 cb(o->context, &i, 0, o->userdata);
     536                 :            :             }
     537                 :            : 
     538         [ #  # ]:          0 :             if (i.formats) {
     539         [ #  # ]:          0 :                 for (j = 0; j < i.n_formats; j++)
     540                 :          0 :                     pa_format_info_free(i.formats[j]);
     541                 :          0 :                 pa_xfree(i.formats);
     542                 :            :             }
     543         [ #  # ]:          0 :             if (i.ports) {
     544                 :          0 :                 pa_xfree(i.ports[0]);
     545                 :          0 :                 pa_xfree(i.ports);
     546                 :            :             }
     547                 :          0 :             pa_proplist_free(i.proplist);
     548                 :            :         }
     549                 :            :     }
     550                 :            : 
     551         [ #  # ]:          0 :     if (o->callback) {
     552                 :          0 :         pa_source_info_cb_t cb = (pa_source_info_cb_t) o->callback;
     553                 :          0 :         cb(o->context, NULL, eol, o->userdata);
     554                 :            :     }
     555                 :            : 
     556                 :            : finish:
     557                 :          0 :     pa_operation_done(o);
     558                 :          0 :     pa_operation_unref(o);
     559                 :          0 :     return;
     560                 :            : 
     561                 :            : fail:
     562         [ #  # ]:          0 :     pa_assert(i.proplist);
     563                 :            : 
     564                 :          0 :     pa_context_fail(o->context, PA_ERR_PROTOCOL);
     565                 :            : 
     566         [ #  # ]:          0 :     if (i.formats) {
     567         [ #  # ]:          0 :         for (j = 0; j < i.n_formats; j++)
     568                 :          0 :             pa_format_info_free(i.formats[j]);
     569                 :          0 :         pa_xfree(i.formats);
     570                 :            :     }
     571         [ #  # ]:          0 :     if (i.ports) {
     572                 :          0 :         pa_xfree(i.ports[0]);
     573                 :          0 :         pa_xfree(i.ports);
     574                 :            :     }
     575                 :          0 :     pa_proplist_free(i.proplist);
     576                 :            : 
     577                 :          0 :     goto finish;
     578                 :            : }
     579                 :            : 
     580                 :          0 : pa_operation* pa_context_get_source_info_list(pa_context *c, pa_source_info_cb_t cb, void *userdata) {
     581                 :          0 :     return pa_context_send_simple_command(c, PA_COMMAND_GET_SOURCE_INFO_LIST, context_get_source_info_callback, (pa_operation_cb_t) cb, userdata);
     582                 :            : }
     583                 :            : 
     584                 :          0 : pa_operation* pa_context_get_source_info_by_index(pa_context *c, uint32_t idx, pa_source_info_cb_t cb, void *userdata) {
     585                 :            :     pa_tagstruct *t;
     586                 :            :     pa_operation *o;
     587                 :            :     uint32_t tag;
     588                 :            : 
     589         [ #  # ]:          0 :     pa_assert(c);
     590         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
     591         [ #  # ]:          0 :     pa_assert(cb);
     592                 :            : 
     593         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     594         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     595                 :            : 
     596                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
     597                 :            : 
     598                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_GET_SOURCE_INFO, &tag);
     599                 :          0 :     pa_tagstruct_putu32(t, idx);
     600                 :          0 :     pa_tagstruct_puts(t, NULL);
     601                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
     602                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_source_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
     603                 :            : 
     604                 :          0 :     return o;
     605                 :            : }
     606                 :            : 
     607                 :          0 : pa_operation* pa_context_get_source_info_by_name(pa_context *c, const char *name, pa_source_info_cb_t cb, void *userdata) {
     608                 :            :     pa_tagstruct *t;
     609                 :            :     pa_operation *o;
     610                 :            :     uint32_t tag;
     611                 :            : 
     612         [ #  # ]:          0 :     pa_assert(c);
     613         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
     614         [ #  # ]:          0 :     pa_assert(cb);
     615                 :            : 
     616         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     617         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     618 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
     619                 :            : 
     620                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
     621                 :            : 
     622                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_GET_SOURCE_INFO, &tag);
     623                 :          0 :     pa_tagstruct_putu32(t, PA_INVALID_INDEX);
     624                 :          0 :     pa_tagstruct_puts(t, name);
     625                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
     626                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_source_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
     627                 :            : 
     628                 :          0 :     return o;
     629                 :            : }
     630                 :            : 
     631                 :          0 : pa_operation* pa_context_set_source_port_by_index(pa_context *c, uint32_t idx, const char*port, pa_context_success_cb_t cb, void *userdata) {
     632                 :            :     pa_operation *o;
     633                 :            :     pa_tagstruct *t;
     634                 :            :     uint32_t tag;
     635                 :            : 
     636         [ #  # ]:          0 :     pa_assert(c);
     637         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
     638                 :            : 
     639         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     640         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     641         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
     642         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 16, PA_ERR_NOTSUPPORTED);
     643                 :            : 
     644                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
     645                 :            : 
     646                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_PORT, &tag);
     647                 :          0 :     pa_tagstruct_putu32(t, idx);
     648                 :          0 :     pa_tagstruct_puts(t, NULL);
     649                 :          0 :     pa_tagstruct_puts(t, port);
     650                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
     651                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
     652                 :            : 
     653                 :          0 :     return o;
     654                 :            : }
     655                 :            : 
     656                 :          0 : pa_operation* pa_context_set_source_port_by_name(pa_context *c, const char *name, const char*port, pa_context_success_cb_t cb, void *userdata) {
     657                 :            :     pa_operation *o;
     658                 :            :     pa_tagstruct *t;
     659                 :            :     uint32_t tag;
     660                 :            : 
     661         [ #  # ]:          0 :     pa_assert(c);
     662         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
     663                 :            : 
     664         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     665         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     666 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
     667         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 16, PA_ERR_NOTSUPPORTED);
     668                 :            : 
     669                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
     670                 :            : 
     671                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_PORT, &tag);
     672                 :          0 :     pa_tagstruct_putu32(t, PA_INVALID_INDEX);
     673                 :          0 :     pa_tagstruct_puts(t, name);
     674                 :          0 :     pa_tagstruct_puts(t, port);
     675                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
     676                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
     677                 :            : 
     678                 :          0 :     return o;
     679                 :            : }
     680                 :            : 
     681                 :            : /*** Client info ***/
     682                 :            : 
     683                 :          0 : static void context_get_client_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
     684                 :          0 :     pa_operation *o = userdata;
     685                 :          0 :     int eol = 1;
     686                 :            : 
     687         [ #  # ]:          0 :     pa_assert(pd);
     688         [ #  # ]:          0 :     pa_assert(o);
     689         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(o) >= 1);
     690                 :            : 
     691         [ #  # ]:          0 :     if (!o->context)
     692                 :            :         goto finish;
     693                 :            : 
     694         [ #  # ]:          0 :     if (command != PA_COMMAND_REPLY) {
     695         [ #  # ]:          0 :         if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
     696                 :            :             goto finish;
     697                 :            : 
     698                 :            :         eol = -1;
     699                 :            :     } else {
     700                 :            : 
     701         [ #  # ]:          0 :         while (!pa_tagstruct_eof(t)) {
     702                 :            :             pa_client_info i;
     703                 :            : 
     704                 :            :             pa_zero(i);
     705                 :          0 :             i.proplist = pa_proplist_new();
     706                 :            : 
     707   [ #  #  #  # ]:          0 :             if (pa_tagstruct_getu32(t, &i.index) < 0 ||
     708         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.name) < 0 ||
     709         [ #  # ]:          0 :                 pa_tagstruct_getu32(t, &i.owner_module) < 0 ||
     710         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.driver) < 0 ||
     711         [ #  # ]:          0 :                 (o->context->version >= 13 && pa_tagstruct_get_proplist(t, i.proplist) < 0)) {
     712                 :            : 
     713                 :          0 :                 pa_context_fail(o->context, PA_ERR_PROTOCOL);
     714                 :          0 :                 pa_proplist_free(i.proplist);
     715                 :          0 :                 goto finish;
     716                 :            :             }
     717                 :            : 
     718         [ #  # ]:          0 :             if (o->callback) {
     719                 :          0 :                 pa_client_info_cb_t cb = (pa_client_info_cb_t) o->callback;
     720                 :          0 :                 cb(o->context, &i, 0, o->userdata);
     721                 :            :             }
     722                 :            : 
     723                 :          0 :             pa_proplist_free(i.proplist);
     724                 :            :         }
     725                 :            :     }
     726                 :            : 
     727         [ #  # ]:          0 :     if (o->callback) {
     728                 :          0 :         pa_client_info_cb_t cb = (pa_client_info_cb_t) o->callback;
     729                 :          0 :         cb(o->context, NULL, eol, o->userdata);
     730                 :            :     }
     731                 :            : 
     732                 :            : finish:
     733                 :          0 :     pa_operation_done(o);
     734                 :          0 :     pa_operation_unref(o);
     735                 :          0 : }
     736                 :            : 
     737                 :          0 : pa_operation* pa_context_get_client_info(pa_context *c, uint32_t idx, pa_client_info_cb_t cb, void *userdata) {
     738                 :            :     pa_tagstruct *t;
     739                 :            :     pa_operation *o;
     740                 :            :     uint32_t tag;
     741                 :            : 
     742         [ #  # ]:          0 :     pa_assert(c);
     743         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
     744         [ #  # ]:          0 :     pa_assert(cb);
     745                 :            : 
     746         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     747         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     748         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
     749                 :            : 
     750                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
     751                 :            : 
     752                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_GET_CLIENT_INFO, &tag);
     753                 :          0 :     pa_tagstruct_putu32(t, idx);
     754                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
     755                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_client_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
     756                 :            : 
     757                 :          0 :     return o;
     758                 :            : }
     759                 :            : 
     760                 :          0 : pa_operation* pa_context_get_client_info_list(pa_context *c, pa_client_info_cb_t cb, void *userdata) {
     761                 :          0 :     return pa_context_send_simple_command(c, PA_COMMAND_GET_CLIENT_INFO_LIST, context_get_client_info_callback, (pa_operation_cb_t) cb, userdata);
     762                 :            : }
     763                 :            : 
     764                 :            : /*** Card info ***/
     765                 :            : 
     766                 :          0 : static void card_info_free(pa_card_info* i) {
     767         [ #  # ]:          0 :     if (i->proplist)
     768                 :          0 :         pa_proplist_free(i->proplist);
     769                 :            : 
     770                 :          0 :     pa_xfree(i->profiles);
     771                 :            : 
     772         [ #  # ]:          0 :     if (i->ports) {
     773                 :            :         uint32_t j;
     774                 :            : 
     775         [ #  # ]:          0 :         for (j = 0; j < i->n_ports; j++) {
     776         [ #  # ]:          0 :             if (i->ports[j]) {
     777         [ #  # ]:          0 :                 if (i->ports[j]->profiles)
     778                 :          0 :                     pa_xfree(i->ports[j]->profiles);
     779         [ #  # ]:          0 :                 if (i->ports[j]->proplist)
     780                 :          0 :                     pa_proplist_free(i->ports[j]->proplist);
     781                 :            :             }
     782                 :            :         }
     783                 :            : 
     784                 :          0 :         pa_xfree(i->ports[0]);
     785                 :          0 :         pa_xfree(i->ports);
     786                 :            :     }
     787                 :          0 : }
     788                 :            : 
     789                 :          0 : static int fill_card_port_info(pa_context *context, pa_tagstruct* t, pa_card_info* i) {
     790                 :            :     uint32_t j, k, l;
     791                 :            : 
     792         [ #  # ]:          0 :     if (pa_tagstruct_getu32(t, &i->n_ports) < 0)
     793                 :            :         return -PA_ERR_PROTOCOL;
     794                 :            : 
     795         [ #  # ]:          0 :     if (i->n_ports == 0) {
     796                 :          0 :         i->ports = NULL;
     797                 :          0 :         return 0;
     798                 :            :     }
     799                 :            : 
     800                 :          0 :     i->ports = pa_xnew0(pa_card_port_info*, i->n_ports+1);
     801                 :          0 :     i->ports[0] = pa_xnew0(pa_card_port_info, i->n_ports);
     802                 :            : 
     803         [ #  # ]:          0 :     for (j = 0; j < i->n_ports; j++) {
     804                 :            :         uint8_t direction;
     805                 :            :         uint32_t available;
     806                 :          0 :         pa_card_port_info* port = i->ports[j] = &i->ports[0][j];
     807                 :            : 
     808                 :          0 :         port->proplist = pa_proplist_new();
     809                 :            : 
     810   [ #  #  #  # ]:          0 :         if (pa_tagstruct_gets(t, &port->name) < 0 ||
     811         [ #  # ]:          0 :             pa_tagstruct_gets(t, &port->description) < 0 ||
     812         [ #  # ]:          0 :             pa_tagstruct_getu32(t, &port->priority) < 0 ||
     813         [ #  # ]:          0 :             pa_tagstruct_getu32(t, &available) < 0 ||
     814         [ #  # ]:          0 :             pa_tagstruct_getu8(t, &direction) < 0 ||
     815         [ #  # ]:          0 :             pa_tagstruct_get_proplist(t, port->proplist) < 0 ||
     816                 :          0 :             pa_tagstruct_getu32(t, &port->n_profiles) < 0) {
     817                 :            : 
     818                 :            :             return -PA_ERR_PROTOCOL;
     819                 :            :         }
     820                 :            : 
     821 [ #  # ][ #  # ]:          0 :         if (available > PA_PORT_AVAILABLE_YES ||
     822                 :          0 :             direction > PA_DIRECTION_OUTPUT + PA_DIRECTION_INPUT) {
     823                 :            : 
     824                 :            :             return -PA_ERR_PROTOCOL;
     825                 :            :         }
     826                 :            : 
     827                 :          0 :         port->direction = direction;
     828                 :          0 :         port->available = available;
     829                 :            : 
     830         [ #  # ]:          0 :         if (port->n_profiles > 0) {
     831                 :          0 :             port->profiles = pa_xnew0(pa_card_profile_info*, i->n_profiles+1);
     832                 :            : 
     833         [ #  # ]:          0 :             for (k = 0; k < port->n_profiles; k++) {
     834                 :            :                 const char* profilename;
     835                 :            : 
     836         [ #  # ]:          0 :                 if (pa_tagstruct_gets(t, &profilename) < 0)
     837                 :            :                     return -PA_ERR_PROTOCOL;
     838                 :            : 
     839         [ #  # ]:          0 :                 for (l = 0; l < i->n_profiles; l++) {
     840         [ #  # ]:          0 :                     if (pa_streq(i->profiles[l].name, profilename)) {
     841                 :          0 :                         port->profiles[k] = &i->profiles[l];
     842                 :          0 :                         break;
     843                 :            :                     }
     844                 :            :                 }
     845                 :            : 
     846         [ #  # ]:          0 :                 if (l >= i->n_profiles)
     847                 :            :                     return -PA_ERR_PROTOCOL;
     848                 :            :             }
     849                 :            :         }
     850         [ #  # ]:          0 :         if (context->version >= 27) {
     851         [ #  # ]:          0 :             if (pa_tagstruct_gets64(t, &port->latency_offset) < 0)
     852                 :            :                 return -PA_ERR_PROTOCOL;
     853                 :            :         } else
     854                 :          0 :             port->latency_offset = 0;
     855                 :            :     }
     856                 :            : 
     857                 :            :     return 0;
     858                 :            : }
     859                 :            : 
     860                 :          0 : static void context_get_card_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
     861                 :          0 :     pa_operation *o = userdata;
     862                 :          0 :     int eol = 1;
     863                 :            :     pa_card_info i;
     864                 :            : 
     865         [ #  # ]:          0 :     pa_assert(pd);
     866         [ #  # ]:          0 :     pa_assert(o);
     867         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(o) >= 1);
     868                 :            : 
     869         [ #  # ]:          0 :     if (!o->context)
     870                 :            :         goto finish;
     871                 :            : 
     872         [ #  # ]:          0 :     if (command != PA_COMMAND_REPLY) {
     873         [ #  # ]:          0 :         if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
     874                 :            :             goto finish;
     875                 :            : 
     876                 :            :         eol = -1;
     877                 :            :     } else {
     878                 :            : 
     879         [ #  # ]:          0 :         while (!pa_tagstruct_eof(t)) {
     880                 :            :             uint32_t j;
     881                 :            :             const char*ap;
     882                 :            : 
     883                 :            :             pa_zero(i);
     884                 :            : 
     885   [ #  #  #  # ]:          0 :             if (pa_tagstruct_getu32(t, &i.index) < 0 ||
     886         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.name) < 0 ||
     887         [ #  # ]:          0 :                 pa_tagstruct_getu32(t, &i.owner_module) < 0 ||
     888         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.driver) < 0 ||
     889                 :          0 :                 pa_tagstruct_getu32(t, &i.n_profiles) < 0) {
     890                 :            : 
     891                 :          0 :                 pa_context_fail(o->context, PA_ERR_PROTOCOL);
     892                 :          0 :                 card_info_free(&i);
     893                 :          0 :                 goto finish;
     894                 :            :             }
     895                 :            : 
     896         [ #  # ]:          0 :             if (i.n_profiles > 0) {
     897                 :          0 :                 i.profiles = pa_xnew0(pa_card_profile_info, i.n_profiles+1);
     898                 :            : 
     899         [ #  # ]:          0 :                 for (j = 0; j < i.n_profiles; j++) {
     900                 :            : 
     901   [ #  #  #  # ]:          0 :                     if (pa_tagstruct_gets(t, &i.profiles[j].name) < 0 ||
     902         [ #  # ]:          0 :                         pa_tagstruct_gets(t, &i.profiles[j].description) < 0 ||
     903         [ #  # ]:          0 :                         pa_tagstruct_getu32(t, &i.profiles[j].n_sinks) < 0 ||
     904         [ #  # ]:          0 :                         pa_tagstruct_getu32(t, &i.profiles[j].n_sources) < 0 ||
     905                 :          0 :                         pa_tagstruct_getu32(t, &i.profiles[j].priority) < 0) {
     906                 :            : 
     907                 :          0 :                         pa_context_fail(o->context, PA_ERR_PROTOCOL);
     908                 :          0 :                         card_info_free(&i);
     909                 :          0 :                         goto finish;
     910                 :            :                     }
     911                 :            :                 }
     912                 :            : 
     913                 :            :                 /* Terminate with an extra NULL entry, just to make sure */
     914                 :          0 :                 i.profiles[j].name = NULL;
     915                 :          0 :                 i.profiles[j].description = NULL;
     916                 :            :             }
     917                 :            : 
     918                 :          0 :             i.proplist = pa_proplist_new();
     919                 :            : 
     920   [ #  #  #  # ]:          0 :             if (pa_tagstruct_gets(t, &ap) < 0 ||
     921                 :          0 :                 pa_tagstruct_get_proplist(t, i.proplist) < 0) {
     922                 :            : 
     923                 :          0 :                 pa_context_fail(o->context, PA_ERR_PROTOCOL);
     924                 :          0 :                 card_info_free(&i);
     925                 :          0 :                 goto finish;
     926                 :            :             }
     927                 :            : 
     928         [ #  # ]:          0 :             if (ap) {
     929         [ #  # ]:          0 :                 for (j = 0; j < i.n_profiles; j++)
     930         [ #  # ]:          0 :                     if (pa_streq(i.profiles[j].name, ap)) {
     931                 :          0 :                         i.active_profile = &i.profiles[j];
     932                 :          0 :                         break;
     933                 :            :                     }
     934                 :            :             }
     935                 :            : 
     936         [ #  # ]:          0 :             if (o->context->version >= 26) {
     937         [ #  # ]:          0 :                 if (fill_card_port_info(o->context, t, &i) < 0) {
     938                 :          0 :                     pa_context_fail(o->context, PA_ERR_PROTOCOL);
     939                 :          0 :                     card_info_free(&i);
     940                 :          0 :                     goto finish;
     941                 :            :                 }
     942                 :            :             }
     943                 :            : 
     944         [ #  # ]:          0 :             if (o->callback) {
     945                 :          0 :                 pa_card_info_cb_t cb = (pa_card_info_cb_t) o->callback;
     946                 :          0 :                 cb(o->context, &i, 0, o->userdata);
     947                 :            :             }
     948                 :            : 
     949                 :          0 :             card_info_free(&i);
     950                 :            :         }
     951                 :            :     }
     952                 :            : 
     953         [ #  # ]:          0 :     if (o->callback) {
     954                 :          0 :         pa_card_info_cb_t cb = (pa_card_info_cb_t) o->callback;
     955                 :          0 :         cb(o->context, NULL, eol, o->userdata);
     956                 :            :     }
     957                 :            : 
     958                 :            : finish:
     959                 :          0 :     pa_operation_done(o);
     960                 :          0 :     pa_operation_unref(o);
     961                 :          0 : }
     962                 :            : 
     963                 :          0 : pa_operation* pa_context_get_card_info_by_index(pa_context *c, uint32_t idx, pa_card_info_cb_t cb, void *userdata) {
     964                 :            :     pa_tagstruct *t;
     965                 :            :     pa_operation *o;
     966                 :            :     uint32_t tag;
     967                 :            : 
     968         [ #  # ]:          0 :     pa_assert(c);
     969         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
     970         [ #  # ]:          0 :     pa_assert(cb);
     971                 :            : 
     972         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     973         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     974         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
     975         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED);
     976                 :            : 
     977                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
     978                 :            : 
     979                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_GET_CARD_INFO, &tag);
     980                 :          0 :     pa_tagstruct_putu32(t, idx);
     981                 :          0 :     pa_tagstruct_puts(t, NULL);
     982                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
     983                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_card_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
     984                 :            : 
     985                 :          0 :     return o;
     986                 :            : }
     987                 :            : 
     988                 :          0 : pa_operation* pa_context_get_card_info_by_name(pa_context *c, const char*name, pa_card_info_cb_t cb, void *userdata) {
     989                 :            :     pa_tagstruct *t;
     990                 :            :     pa_operation *o;
     991                 :            :     uint32_t tag;
     992                 :            : 
     993         [ #  # ]:          0 :     pa_assert(c);
     994         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
     995         [ #  # ]:          0 :     pa_assert(cb);
     996                 :            : 
     997         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     998         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     999 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
    1000         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED);
    1001                 :            : 
    1002                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1003                 :            : 
    1004                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_GET_CARD_INFO, &tag);
    1005                 :          0 :     pa_tagstruct_putu32(t, PA_INVALID_INDEX);
    1006                 :          0 :     pa_tagstruct_puts(t, name);
    1007                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1008                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_card_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1009                 :            : 
    1010                 :          0 :     return o;
    1011                 :            : }
    1012                 :            : 
    1013                 :          0 : pa_operation* pa_context_get_card_info_list(pa_context *c, pa_card_info_cb_t cb, void *userdata) {
    1014         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED);
    1015                 :            : 
    1016                 :          0 :     return pa_context_send_simple_command(c, PA_COMMAND_GET_CARD_INFO_LIST, context_get_card_info_callback, (pa_operation_cb_t) cb, userdata);
    1017                 :            : }
    1018                 :            : 
    1019                 :          0 : pa_operation* pa_context_set_card_profile_by_index(pa_context *c, uint32_t idx, const char*profile, pa_context_success_cb_t cb, void *userdata) {
    1020                 :            :     pa_operation *o;
    1021                 :            :     pa_tagstruct *t;
    1022                 :            :     uint32_t tag;
    1023                 :            : 
    1024         [ #  # ]:          0 :     pa_assert(c);
    1025         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1026                 :            : 
    1027         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1028         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1029         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
    1030         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED);
    1031                 :            : 
    1032                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1033                 :            : 
    1034                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_CARD_PROFILE, &tag);
    1035                 :          0 :     pa_tagstruct_putu32(t, idx);
    1036                 :          0 :     pa_tagstruct_puts(t, NULL);
    1037                 :          0 :     pa_tagstruct_puts(t, profile);
    1038                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1039                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1040                 :            : 
    1041                 :          0 :     return o;
    1042                 :            : }
    1043                 :            : 
    1044                 :          0 : pa_operation* pa_context_set_card_profile_by_name(pa_context *c, const char *name, const char*profile, pa_context_success_cb_t cb, void *userdata) {
    1045                 :            :     pa_operation *o;
    1046                 :            :     pa_tagstruct *t;
    1047                 :            :     uint32_t tag;
    1048                 :            : 
    1049         [ #  # ]:          0 :     pa_assert(c);
    1050         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1051                 :            : 
    1052         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1053         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1054 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
    1055         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED);
    1056                 :            : 
    1057                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1058                 :            : 
    1059                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_CARD_PROFILE, &tag);
    1060                 :          0 :     pa_tagstruct_putu32(t, PA_INVALID_INDEX);
    1061                 :          0 :     pa_tagstruct_puts(t, name);
    1062                 :          0 :     pa_tagstruct_puts(t, profile);
    1063                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1064                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1065                 :            : 
    1066                 :          0 :     return o;
    1067                 :            : }
    1068                 :            : 
    1069                 :            : /*** Module info ***/
    1070                 :            : 
    1071                 :          0 : static void context_get_module_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
    1072                 :          0 :     pa_operation *o = userdata;
    1073                 :          0 :     int eol = 1;
    1074                 :            : 
    1075         [ #  # ]:          0 :     pa_assert(pd);
    1076         [ #  # ]:          0 :     pa_assert(o);
    1077         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(o) >= 1);
    1078                 :            : 
    1079         [ #  # ]:          0 :     if (!o->context)
    1080                 :            :         goto finish;
    1081                 :            : 
    1082         [ #  # ]:          0 :     if (command != PA_COMMAND_REPLY) {
    1083         [ #  # ]:          0 :         if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
    1084                 :            :             goto finish;
    1085                 :            : 
    1086                 :            :         eol = -1;
    1087                 :            :     } else {
    1088                 :            : 
    1089         [ #  # ]:          0 :         while (!pa_tagstruct_eof(t)) {
    1090                 :            :             pa_module_info i;
    1091                 :          0 :             pa_bool_t auto_unload = FALSE;
    1092                 :            : 
    1093                 :            :             pa_zero(i);
    1094                 :          0 :             i.proplist = pa_proplist_new();
    1095                 :            : 
    1096   [ #  #  #  # ]:          0 :             if (pa_tagstruct_getu32(t, &i.index) < 0 ||
    1097         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.name) < 0 ||
    1098         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.argument) < 0 ||
    1099         [ #  # ]:          0 :                 pa_tagstruct_getu32(t, &i.n_used) < 0 ||
    1100 [ #  # ][ #  # ]:          0 :                 (o->context->version < 15 && pa_tagstruct_get_boolean(t, &auto_unload) < 0) ||
    1101         [ #  # ]:          0 :                 (o->context->version >= 15 && pa_tagstruct_get_proplist(t, i.proplist) < 0)) {
    1102                 :          0 :                 pa_context_fail(o->context, PA_ERR_PROTOCOL);
    1103                 :          0 :                 goto finish;
    1104                 :            :             }
    1105                 :            : 
    1106                 :          0 :             i.auto_unload = (int) auto_unload;
    1107                 :            : 
    1108         [ #  # ]:          0 :             if (o->callback) {
    1109                 :          0 :                 pa_module_info_cb_t cb = (pa_module_info_cb_t) o->callback;
    1110                 :          0 :                 cb(o->context, &i, 0, o->userdata);
    1111                 :            :             }
    1112                 :            : 
    1113                 :          0 :             pa_proplist_free(i.proplist);
    1114                 :            :         }
    1115                 :            :     }
    1116                 :            : 
    1117         [ #  # ]:          0 :     if (o->callback) {
    1118                 :          0 :         pa_module_info_cb_t cb = (pa_module_info_cb_t) o->callback;
    1119                 :          0 :         cb(o->context, NULL, eol, o->userdata);
    1120                 :            :     }
    1121                 :            : 
    1122                 :            : finish:
    1123                 :          0 :     pa_operation_done(o);
    1124                 :          0 :     pa_operation_unref(o);
    1125                 :          0 : }
    1126                 :            : 
    1127                 :          0 : pa_operation* pa_context_get_module_info(pa_context *c, uint32_t idx, pa_module_info_cb_t cb, void *userdata) {
    1128                 :            :     pa_tagstruct *t;
    1129                 :            :     pa_operation *o;
    1130                 :            :     uint32_t tag;
    1131                 :            : 
    1132         [ #  # ]:          0 :     pa_assert(c);
    1133         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1134         [ #  # ]:          0 :     pa_assert(cb);
    1135                 :            : 
    1136         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1137         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1138         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
    1139                 :            : 
    1140                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1141                 :            : 
    1142                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_GET_MODULE_INFO, &tag);
    1143                 :          0 :     pa_tagstruct_putu32(t, idx);
    1144                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1145                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_module_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1146                 :            : 
    1147                 :          0 :     return o;
    1148                 :            : }
    1149                 :            : 
    1150                 :          0 : pa_operation* pa_context_get_module_info_list(pa_context *c, pa_module_info_cb_t cb, void *userdata) {
    1151                 :          0 :     return pa_context_send_simple_command(c, PA_COMMAND_GET_MODULE_INFO_LIST, context_get_module_info_callback, (pa_operation_cb_t) cb, userdata);
    1152                 :            : }
    1153                 :            : 
    1154                 :            : /*** Sink input info ***/
    1155                 :            : 
    1156                 :          0 : static void context_get_sink_input_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
    1157                 :          0 :     pa_operation *o = userdata;
    1158                 :          0 :     int eol = 1;
    1159                 :            : 
    1160         [ #  # ]:          0 :     pa_assert(pd);
    1161         [ #  # ]:          0 :     pa_assert(o);
    1162         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(o) >= 1);
    1163                 :            : 
    1164         [ #  # ]:          0 :     if (!o->context)
    1165                 :            :         goto finish;
    1166                 :            : 
    1167         [ #  # ]:          0 :     if (command != PA_COMMAND_REPLY) {
    1168         [ #  # ]:          0 :         if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
    1169                 :            :             goto finish;
    1170                 :            : 
    1171                 :            :         eol = -1;
    1172                 :            :     } else {
    1173                 :            : 
    1174         [ #  # ]:          0 :         while (!pa_tagstruct_eof(t)) {
    1175                 :            :             pa_sink_input_info i;
    1176                 :          0 :             pa_bool_t mute = FALSE, corked = FALSE, has_volume = FALSE, volume_writable = TRUE;
    1177                 :            : 
    1178                 :            :             pa_zero(i);
    1179                 :          0 :             i.proplist = pa_proplist_new();
    1180                 :          0 :             i.format = pa_format_info_new();
    1181                 :            : 
    1182   [ #  #  #  # ]:          0 :             if (pa_tagstruct_getu32(t, &i.index) < 0 ||
    1183         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.name) < 0 ||
    1184         [ #  # ]:          0 :                 pa_tagstruct_getu32(t, &i.owner_module) < 0 ||
    1185         [ #  # ]:          0 :                 pa_tagstruct_getu32(t, &i.client) < 0 ||
    1186         [ #  # ]:          0 :                 pa_tagstruct_getu32(t, &i.sink) < 0 ||
    1187         [ #  # ]:          0 :                 pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 ||
    1188         [ #  # ]:          0 :                 pa_tagstruct_get_channel_map(t, &i.channel_map) < 0 ||
    1189         [ #  # ]:          0 :                 pa_tagstruct_get_cvolume(t, &i.volume) < 0 ||
    1190         [ #  # ]:          0 :                 pa_tagstruct_get_usec(t, &i.buffer_usec) < 0 ||
    1191         [ #  # ]:          0 :                 pa_tagstruct_get_usec(t, &i.sink_usec) < 0 ||
    1192         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.resample_method) < 0 ||
    1193         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.driver) < 0 ||
    1194 [ #  # ][ #  # ]:          0 :                 (o->context->version >= 11 && pa_tagstruct_get_boolean(t, &mute) < 0) ||
    1195 [ #  # ][ #  # ]:          0 :                 (o->context->version >= 13 && pa_tagstruct_get_proplist(t, i.proplist) < 0) ||
    1196 [ #  # ][ #  # ]:          0 :                 (o->context->version >= 19 && pa_tagstruct_get_boolean(t, &corked) < 0) ||
    1197   [ #  #  #  # ]:          0 :                 (o->context->version >= 20 && (pa_tagstruct_get_boolean(t, &has_volume) < 0 ||
    1198         [ #  # ]:          0 :                                                pa_tagstruct_get_boolean(t, &volume_writable) < 0)) ||
    1199         [ #  # ]:          0 :                 (o->context->version >= 21 && pa_tagstruct_get_format_info(t, i.format) < 0)) {
    1200                 :            : 
    1201                 :          0 :                 pa_context_fail(o->context, PA_ERR_PROTOCOL);
    1202                 :          0 :                 pa_proplist_free(i.proplist);
    1203                 :          0 :                 pa_format_info_free(i.format);
    1204                 :          0 :                 goto finish;
    1205                 :            :             }
    1206                 :            : 
    1207                 :          0 :             i.mute = (int) mute;
    1208                 :          0 :             i.corked = (int) corked;
    1209                 :          0 :             i.has_volume = (int) has_volume;
    1210                 :          0 :             i.volume_writable = (int) volume_writable;
    1211                 :            : 
    1212         [ #  # ]:          0 :             if (o->callback) {
    1213                 :          0 :                 pa_sink_input_info_cb_t cb = (pa_sink_input_info_cb_t) o->callback;
    1214                 :          0 :                 cb(o->context, &i, 0, o->userdata);
    1215                 :            :             }
    1216                 :            : 
    1217                 :          0 :             pa_proplist_free(i.proplist);
    1218                 :          0 :             pa_format_info_free(i.format);
    1219                 :            :         }
    1220                 :            :     }
    1221                 :            : 
    1222         [ #  # ]:          0 :     if (o->callback) {
    1223                 :          0 :         pa_sink_input_info_cb_t cb = (pa_sink_input_info_cb_t) o->callback;
    1224                 :          0 :         cb(o->context, NULL, eol, o->userdata);
    1225                 :            :     }
    1226                 :            : 
    1227                 :            : finish:
    1228                 :          0 :     pa_operation_done(o);
    1229                 :          0 :     pa_operation_unref(o);
    1230                 :          0 : }
    1231                 :            : 
    1232                 :          0 : pa_operation* pa_context_get_sink_input_info(pa_context *c, uint32_t idx, pa_sink_input_info_cb_t cb, void *userdata) {
    1233                 :            :     pa_tagstruct *t;
    1234                 :            :     pa_operation *o;
    1235                 :            :     uint32_t tag;
    1236                 :            : 
    1237         [ #  # ]:          0 :     pa_assert(c);
    1238         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1239         [ #  # ]:          0 :     pa_assert(cb);
    1240                 :            : 
    1241         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1242         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1243         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
    1244                 :            : 
    1245                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1246                 :            : 
    1247                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_GET_SINK_INPUT_INFO, &tag);
    1248                 :          0 :     pa_tagstruct_putu32(t, idx);
    1249                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1250                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_sink_input_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1251                 :            : 
    1252                 :          0 :     return o;
    1253                 :            : }
    1254                 :            : 
    1255                 :          0 : pa_operation* pa_context_get_sink_input_info_list(pa_context *c, void (*cb)(pa_context *c, const pa_sink_input_info*i, int is_last, void *userdata), void *userdata) {
    1256                 :          0 :     return pa_context_send_simple_command(c, PA_COMMAND_GET_SINK_INPUT_INFO_LIST, context_get_sink_input_info_callback, (pa_operation_cb_t) cb, userdata);
    1257                 :            : }
    1258                 :            : 
    1259                 :            : /*** Source output info ***/
    1260                 :            : 
    1261                 :          0 : static void context_get_source_output_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
    1262                 :          0 :     pa_operation *o = userdata;
    1263                 :          0 :     int eol = 1;
    1264                 :            : 
    1265         [ #  # ]:          0 :     pa_assert(pd);
    1266         [ #  # ]:          0 :     pa_assert(o);
    1267         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(o) >= 1);
    1268                 :            : 
    1269         [ #  # ]:          0 :     if (!o->context)
    1270                 :            :         goto finish;
    1271                 :            : 
    1272         [ #  # ]:          0 :     if (command != PA_COMMAND_REPLY) {
    1273         [ #  # ]:          0 :         if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
    1274                 :            :             goto finish;
    1275                 :            : 
    1276                 :            :         eol = -1;
    1277                 :            :     } else {
    1278                 :            : 
    1279         [ #  # ]:          0 :         while (!pa_tagstruct_eof(t)) {
    1280                 :            :             pa_source_output_info i;
    1281                 :          0 :             pa_bool_t mute = FALSE, corked = FALSE, has_volume = FALSE, volume_writable = TRUE;
    1282                 :            : 
    1283                 :            :             pa_zero(i);
    1284                 :          0 :             i.proplist = pa_proplist_new();
    1285                 :          0 :             i.format = pa_format_info_new();
    1286                 :            : 
    1287   [ #  #  #  # ]:          0 :             if (pa_tagstruct_getu32(t, &i.index) < 0 ||
    1288         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.name) < 0 ||
    1289         [ #  # ]:          0 :                 pa_tagstruct_getu32(t, &i.owner_module) < 0 ||
    1290         [ #  # ]:          0 :                 pa_tagstruct_getu32(t, &i.client) < 0 ||
    1291         [ #  # ]:          0 :                 pa_tagstruct_getu32(t, &i.source) < 0 ||
    1292         [ #  # ]:          0 :                 pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 ||
    1293         [ #  # ]:          0 :                 pa_tagstruct_get_channel_map(t, &i.channel_map) < 0 ||
    1294         [ #  # ]:          0 :                 pa_tagstruct_get_usec(t, &i.buffer_usec) < 0 ||
    1295         [ #  # ]:          0 :                 pa_tagstruct_get_usec(t, &i.source_usec) < 0 ||
    1296         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.resample_method) < 0 ||
    1297         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.driver) < 0 ||
    1298 [ #  # ][ #  # ]:          0 :                 (o->context->version >= 13 && pa_tagstruct_get_proplist(t, i.proplist) < 0) ||
    1299 [ #  # ][ #  # ]:          0 :                 (o->context->version >= 19 && pa_tagstruct_get_boolean(t, &corked) < 0) ||
    1300   [ #  #  #  # ]:          0 :                 (o->context->version >= 22 && (pa_tagstruct_get_cvolume(t, &i.volume) < 0 ||
    1301         [ #  # ]:          0 :                                                pa_tagstruct_get_boolean(t, &mute) < 0 ||
    1302         [ #  # ]:          0 :                                                pa_tagstruct_get_boolean(t, &has_volume) < 0 ||
    1303         [ #  # ]:          0 :                                                pa_tagstruct_get_boolean(t, &volume_writable) < 0 ||
    1304                 :          0 :                                                pa_tagstruct_get_format_info(t, i.format) < 0))) {
    1305                 :            : 
    1306                 :          0 :                 pa_context_fail(o->context, PA_ERR_PROTOCOL);
    1307                 :          0 :                 pa_proplist_free(i.proplist);
    1308                 :          0 :                 pa_format_info_free(i.format);
    1309                 :          0 :                 goto finish;
    1310                 :            :             }
    1311                 :            : 
    1312                 :          0 :             i.mute = (int) mute;
    1313                 :          0 :             i.corked = (int) corked;
    1314                 :          0 :             i.has_volume = (int) has_volume;
    1315                 :          0 :             i.volume_writable = (int) volume_writable;
    1316                 :            : 
    1317         [ #  # ]:          0 :             if (o->callback) {
    1318                 :          0 :                 pa_source_output_info_cb_t cb = (pa_source_output_info_cb_t) o->callback;
    1319                 :          0 :                 cb(o->context, &i, 0, o->userdata);
    1320                 :            :             }
    1321                 :            : 
    1322                 :          0 :             pa_proplist_free(i.proplist);
    1323                 :          0 :             pa_format_info_free(i.format);
    1324                 :            :         }
    1325                 :            :     }
    1326                 :            : 
    1327         [ #  # ]:          0 :     if (o->callback) {
    1328                 :          0 :         pa_source_output_info_cb_t cb = (pa_source_output_info_cb_t) o->callback;
    1329                 :          0 :         cb(o->context, NULL, eol, o->userdata);
    1330                 :            :     }
    1331                 :            : 
    1332                 :            : finish:
    1333                 :          0 :     pa_operation_done(o);
    1334                 :          0 :     pa_operation_unref(o);
    1335                 :          0 : }
    1336                 :            : 
    1337                 :          0 : pa_operation* pa_context_get_source_output_info(pa_context *c, uint32_t idx, pa_source_output_info_cb_t cb, void *userdata) {
    1338                 :            :     pa_tagstruct *t;
    1339                 :            :     pa_operation *o;
    1340                 :            :     uint32_t tag;
    1341                 :            : 
    1342         [ #  # ]:          0 :     pa_assert(c);
    1343         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1344         [ #  # ]:          0 :     pa_assert(cb);
    1345                 :            : 
    1346         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1347         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1348         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
    1349                 :            : 
    1350                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1351                 :            : 
    1352                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_GET_SOURCE_OUTPUT_INFO, &tag);
    1353                 :          0 :     pa_tagstruct_putu32(t, idx);
    1354                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1355                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_source_output_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1356                 :            : 
    1357                 :          0 :     return o;
    1358                 :            : }
    1359                 :            : 
    1360                 :          0 : pa_operation* pa_context_get_source_output_info_list(pa_context *c,  pa_source_output_info_cb_t cb, void *userdata) {
    1361                 :          0 :     return pa_context_send_simple_command(c, PA_COMMAND_GET_SOURCE_OUTPUT_INFO_LIST, context_get_source_output_info_callback, (pa_operation_cb_t) cb, userdata);
    1362                 :            : }
    1363                 :            : 
    1364                 :            : /*** Volume manipulation ***/
    1365                 :            : 
    1366                 :          0 : pa_operation* pa_context_set_sink_volume_by_index(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata) {
    1367                 :            :     pa_operation *o;
    1368                 :            :     pa_tagstruct *t;
    1369                 :            :     uint32_t tag;
    1370                 :            : 
    1371         [ #  # ]:          0 :     pa_assert(c);
    1372         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1373         [ #  # ]:          0 :     pa_assert(volume);
    1374                 :            : 
    1375         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1376         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1377         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
    1378                 :            : 
    1379                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1380                 :            : 
    1381                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_VOLUME, &tag);
    1382                 :          0 :     pa_tagstruct_putu32(t, idx);
    1383                 :          0 :     pa_tagstruct_puts(t, NULL);
    1384                 :          0 :     pa_tagstruct_put_cvolume(t, volume);
    1385                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1386                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1387                 :            : 
    1388                 :          0 :     return o;
    1389                 :            : }
    1390                 :            : 
    1391                 :          0 : pa_operation* pa_context_set_sink_volume_by_name(pa_context *c, const char *name, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata) {
    1392                 :            :     pa_operation *o;
    1393                 :            :     pa_tagstruct *t;
    1394                 :            :     uint32_t tag;
    1395                 :            : 
    1396         [ #  # ]:          0 :     pa_assert(c);
    1397         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1398         [ #  # ]:          0 :     pa_assert(name);
    1399         [ #  # ]:          0 :     pa_assert(volume);
    1400                 :            : 
    1401         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1402         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1403         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
    1404 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
    1405                 :            : 
    1406                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1407                 :            : 
    1408                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_VOLUME, &tag);
    1409                 :          0 :     pa_tagstruct_putu32(t, PA_INVALID_INDEX);
    1410                 :          0 :     pa_tagstruct_puts(t, name);
    1411                 :          0 :     pa_tagstruct_put_cvolume(t, volume);
    1412                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1413                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1414                 :            : 
    1415                 :          0 :     return o;
    1416                 :            : }
    1417                 :            : 
    1418                 :          0 : pa_operation* pa_context_set_sink_mute_by_index(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata) {
    1419                 :            :     pa_operation *o;
    1420                 :            :     pa_tagstruct *t;
    1421                 :            :     uint32_t tag;
    1422                 :            : 
    1423         [ #  # ]:          0 :     pa_assert(c);
    1424         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1425                 :            : 
    1426         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1427         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1428                 :            : 
    1429                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1430                 :            : 
    1431                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_MUTE, &tag);
    1432                 :          0 :     pa_tagstruct_putu32(t, idx);
    1433                 :          0 :     pa_tagstruct_puts(t, NULL);
    1434                 :          0 :     pa_tagstruct_put_boolean(t, mute);
    1435                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1436                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1437                 :            : 
    1438                 :          0 :     return o;
    1439                 :            : }
    1440                 :            : 
    1441                 :          0 : pa_operation* pa_context_set_sink_mute_by_name(pa_context *c, const char *name, int mute, pa_context_success_cb_t cb, void *userdata) {
    1442                 :            :     pa_operation *o;
    1443                 :            :     pa_tagstruct *t;
    1444                 :            :     uint32_t tag;
    1445                 :            : 
    1446         [ #  # ]:          0 :     pa_assert(c);
    1447         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1448         [ #  # ]:          0 :     pa_assert(name);
    1449                 :            : 
    1450         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1451         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1452 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
    1453                 :            : 
    1454                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1455                 :            : 
    1456                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_MUTE, &tag);
    1457                 :          0 :     pa_tagstruct_putu32(t, PA_INVALID_INDEX);
    1458                 :          0 :     pa_tagstruct_puts(t, name);
    1459                 :          0 :     pa_tagstruct_put_boolean(t, mute);
    1460                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1461                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1462                 :            : 
    1463                 :          0 :     return o;
    1464                 :            : }
    1465                 :            : 
    1466                 :          0 : pa_operation* pa_context_set_sink_input_volume(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata) {
    1467                 :            :     pa_operation *o;
    1468                 :            :     pa_tagstruct *t;
    1469                 :            :     uint32_t tag;
    1470                 :            : 
    1471         [ #  # ]:          0 :     pa_assert(c);
    1472         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1473         [ #  # ]:          0 :     pa_assert(volume);
    1474                 :            : 
    1475         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1476         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1477         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
    1478         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
    1479                 :            : 
    1480                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1481                 :            : 
    1482                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_INPUT_VOLUME, &tag);
    1483                 :          0 :     pa_tagstruct_putu32(t, idx);
    1484                 :          0 :     pa_tagstruct_put_cvolume(t, volume);
    1485                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1486                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1487                 :            : 
    1488                 :          0 :     return o;
    1489                 :            : }
    1490                 :            : 
    1491                 :          0 : pa_operation* pa_context_set_sink_input_mute(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata) {
    1492                 :            :     pa_operation *o;
    1493                 :            :     pa_tagstruct *t;
    1494                 :            :     uint32_t tag;
    1495                 :            : 
    1496         [ #  # ]:          0 :     pa_assert(c);
    1497         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1498                 :            : 
    1499         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1500         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1501         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
    1502         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED);
    1503                 :            : 
    1504                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1505                 :            : 
    1506                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_INPUT_MUTE, &tag);
    1507                 :          0 :     pa_tagstruct_putu32(t, idx);
    1508                 :          0 :     pa_tagstruct_put_boolean(t, mute);
    1509                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1510                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1511                 :            : 
    1512                 :          0 :     return o;
    1513                 :            : }
    1514                 :            : 
    1515                 :          0 : pa_operation* pa_context_set_source_volume_by_index(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata) {
    1516                 :            :     pa_operation *o;
    1517                 :            :     pa_tagstruct *t;
    1518                 :            :     uint32_t tag;
    1519                 :            : 
    1520         [ #  # ]:          0 :     pa_assert(c);
    1521         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1522         [ #  # ]:          0 :     pa_assert(volume);
    1523                 :            : 
    1524         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1525         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1526         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
    1527                 :            : 
    1528                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1529                 :            : 
    1530                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_VOLUME, &tag);
    1531                 :          0 :     pa_tagstruct_putu32(t, idx);
    1532                 :          0 :     pa_tagstruct_puts(t, NULL);
    1533                 :          0 :     pa_tagstruct_put_cvolume(t, volume);
    1534                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1535                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1536                 :            : 
    1537                 :          0 :     return o;
    1538                 :            : }
    1539                 :            : 
    1540                 :          0 : pa_operation* pa_context_set_source_volume_by_name(pa_context *c, const char *name, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata) {
    1541                 :            :     pa_operation *o;
    1542                 :            :     pa_tagstruct *t;
    1543                 :            :     uint32_t tag;
    1544                 :            : 
    1545         [ #  # ]:          0 :     pa_assert(c);
    1546         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1547         [ #  # ]:          0 :     pa_assert(name);
    1548         [ #  # ]:          0 :     pa_assert(volume);
    1549                 :            : 
    1550         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1551         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1552         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
    1553 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
    1554                 :            : 
    1555                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1556                 :            : 
    1557                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_VOLUME, &tag);
    1558                 :          0 :     pa_tagstruct_putu32(t, PA_INVALID_INDEX);
    1559                 :          0 :     pa_tagstruct_puts(t, name);
    1560                 :          0 :     pa_tagstruct_put_cvolume(t, volume);
    1561                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1562                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1563                 :            : 
    1564                 :          0 :     return o;
    1565                 :            : }
    1566                 :            : 
    1567                 :          0 : pa_operation* pa_context_set_source_mute_by_index(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata) {
    1568                 :            :     pa_operation *o;
    1569                 :            :     pa_tagstruct *t;
    1570                 :            :     uint32_t tag;
    1571                 :            : 
    1572         [ #  # ]:          0 :     pa_assert(c);
    1573         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1574                 :            : 
    1575         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1576         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1577                 :            : 
    1578                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1579                 :            : 
    1580                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_MUTE, &tag);
    1581                 :          0 :     pa_tagstruct_putu32(t, idx);
    1582                 :          0 :     pa_tagstruct_puts(t, NULL);
    1583                 :          0 :     pa_tagstruct_put_boolean(t, mute);
    1584                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1585                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1586                 :            : 
    1587                 :          0 :     return o;
    1588                 :            : }
    1589                 :            : 
    1590                 :          0 : pa_operation* pa_context_set_source_mute_by_name(pa_context *c, const char *name, int mute, pa_context_success_cb_t cb, void *userdata) {
    1591                 :            :     pa_operation *o;
    1592                 :            :     pa_tagstruct *t;
    1593                 :            :     uint32_t tag;
    1594                 :            : 
    1595         [ #  # ]:          0 :     pa_assert(c);
    1596         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1597         [ #  # ]:          0 :     pa_assert(name);
    1598                 :            : 
    1599         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1600         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1601 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
    1602                 :            : 
    1603                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1604                 :            : 
    1605                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_MUTE, &tag);
    1606                 :          0 :     pa_tagstruct_putu32(t, PA_INVALID_INDEX);
    1607                 :          0 :     pa_tagstruct_puts(t, name);
    1608                 :          0 :     pa_tagstruct_put_boolean(t, mute);
    1609                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1610                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1611                 :            : 
    1612                 :          0 :     return o;
    1613                 :            : }
    1614                 :            : 
    1615                 :          0 : pa_operation* pa_context_set_source_output_volume(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata) {
    1616                 :            :     pa_operation *o;
    1617                 :            :     pa_tagstruct *t;
    1618                 :            :     uint32_t tag;
    1619                 :            : 
    1620         [ #  # ]:          0 :     pa_assert(c);
    1621         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1622         [ #  # ]:          0 :     pa_assert(volume);
    1623                 :            : 
    1624         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1625         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1626         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
    1627         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 22, PA_ERR_NOTSUPPORTED);
    1628         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
    1629                 :            : 
    1630                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1631                 :            : 
    1632                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_OUTPUT_VOLUME, &tag);
    1633                 :          0 :     pa_tagstruct_putu32(t, idx);
    1634                 :          0 :     pa_tagstruct_put_cvolume(t, volume);
    1635                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1636                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1637                 :            : 
    1638                 :          0 :     return o;
    1639                 :            : }
    1640                 :            : 
    1641                 :          0 : pa_operation* pa_context_set_source_output_mute(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata) {
    1642                 :            :     pa_operation *o;
    1643                 :            :     pa_tagstruct *t;
    1644                 :            :     uint32_t tag;
    1645                 :            : 
    1646         [ #  # ]:          0 :     pa_assert(c);
    1647         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1648                 :            : 
    1649         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1650         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1651         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
    1652         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 22, PA_ERR_NOTSUPPORTED);
    1653                 :            : 
    1654                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1655                 :            : 
    1656                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_OUTPUT_MUTE, &tag);
    1657                 :          0 :     pa_tagstruct_putu32(t, idx);
    1658                 :          0 :     pa_tagstruct_put_boolean(t, mute);
    1659                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1660                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1661                 :            : 
    1662                 :          0 :     return o;
    1663                 :            : }
    1664                 :            : 
    1665                 :            : /** Sample Cache **/
    1666                 :            : 
    1667                 :          0 : static void context_get_sample_info_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
    1668                 :          0 :     pa_operation *o = userdata;
    1669                 :          0 :     int eol = 1;
    1670                 :            : 
    1671         [ #  # ]:          0 :     pa_assert(pd);
    1672         [ #  # ]:          0 :     pa_assert(o);
    1673         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(o) >= 1);
    1674                 :            : 
    1675         [ #  # ]:          0 :     if (!o->context)
    1676                 :            :         goto finish;
    1677                 :            : 
    1678         [ #  # ]:          0 :     if (command != PA_COMMAND_REPLY) {
    1679         [ #  # ]:          0 :         if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
    1680                 :            :             goto finish;
    1681                 :            : 
    1682                 :            :         eol = -1;
    1683                 :            :     } else {
    1684                 :            : 
    1685         [ #  # ]:          0 :         while (!pa_tagstruct_eof(t)) {
    1686                 :            :             pa_sample_info i;
    1687                 :          0 :             pa_bool_t lazy = FALSE;
    1688                 :            : 
    1689                 :            :             pa_zero(i);
    1690                 :          0 :             i.proplist = pa_proplist_new();
    1691                 :            : 
    1692   [ #  #  #  # ]:          0 :             if (pa_tagstruct_getu32(t, &i.index) < 0 ||
    1693         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.name) < 0 ||
    1694         [ #  # ]:          0 :                 pa_tagstruct_get_cvolume(t, &i.volume) < 0 ||
    1695         [ #  # ]:          0 :                 pa_tagstruct_get_usec(t, &i.duration) < 0 ||
    1696         [ #  # ]:          0 :                 pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 ||
    1697         [ #  # ]:          0 :                 pa_tagstruct_get_channel_map(t, &i.channel_map) < 0 ||
    1698         [ #  # ]:          0 :                 pa_tagstruct_getu32(t, &i.bytes) < 0 ||
    1699         [ #  # ]:          0 :                 pa_tagstruct_get_boolean(t, &lazy) < 0 ||
    1700         [ #  # ]:          0 :                 pa_tagstruct_gets(t, &i.filename) < 0 ||
    1701         [ #  # ]:          0 :                 (o->context->version >= 13 && pa_tagstruct_get_proplist(t, i.proplist) < 0)) {
    1702                 :            : 
    1703                 :          0 :                 pa_context_fail(o->context, PA_ERR_PROTOCOL);
    1704                 :          0 :                 goto finish;
    1705                 :            :             }
    1706                 :            : 
    1707                 :          0 :             i.lazy = (int) lazy;
    1708                 :            : 
    1709         [ #  # ]:          0 :             if (o->callback) {
    1710                 :          0 :                 pa_sample_info_cb_t cb = (pa_sample_info_cb_t) o->callback;
    1711                 :          0 :                 cb(o->context, &i, 0, o->userdata);
    1712                 :            :             }
    1713                 :            : 
    1714                 :          0 :             pa_proplist_free(i.proplist);
    1715                 :            :         }
    1716                 :            :     }
    1717                 :            : 
    1718         [ #  # ]:          0 :     if (o->callback) {
    1719                 :          0 :         pa_sample_info_cb_t cb = (pa_sample_info_cb_t) o->callback;
    1720                 :          0 :         cb(o->context, NULL, eol, o->userdata);
    1721                 :            :     }
    1722                 :            : 
    1723                 :            : finish:
    1724                 :          0 :     pa_operation_done(o);
    1725                 :          0 :     pa_operation_unref(o);
    1726                 :          0 : }
    1727                 :            : 
    1728                 :          0 : pa_operation* pa_context_get_sample_info_by_name(pa_context *c, const char *name, pa_sample_info_cb_t cb, void *userdata) {
    1729                 :            :     pa_tagstruct *t;
    1730                 :            :     pa_operation *o;
    1731                 :            :     uint32_t tag;
    1732                 :            : 
    1733         [ #  # ]:          0 :     pa_assert(c);
    1734         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1735         [ #  # ]:          0 :     pa_assert(cb);
    1736                 :            : 
    1737         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1738         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1739 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
    1740                 :            : 
    1741                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1742                 :            : 
    1743                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_GET_SAMPLE_INFO, &tag);
    1744                 :          0 :     pa_tagstruct_putu32(t, PA_INVALID_INDEX);
    1745                 :          0 :     pa_tagstruct_puts(t, name);
    1746                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1747                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_sample_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1748                 :            : 
    1749                 :          0 :     return o;
    1750                 :            : }
    1751                 :            : 
    1752                 :          0 : pa_operation* pa_context_get_sample_info_by_index(pa_context *c, uint32_t idx, pa_sample_info_cb_t cb, void *userdata) {
    1753                 :            :     pa_tagstruct *t;
    1754                 :            :     pa_operation *o;
    1755                 :            :     uint32_t tag;
    1756                 :            : 
    1757         [ #  # ]:          0 :     pa_assert(c);
    1758         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1759         [ #  # ]:          0 :     pa_assert(cb);
    1760                 :            : 
    1761         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1762         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1763         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
    1764                 :            : 
    1765                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1766                 :            : 
    1767                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_GET_SAMPLE_INFO, &tag);
    1768                 :          0 :     pa_tagstruct_putu32(t, idx);
    1769                 :          0 :     pa_tagstruct_puts(t, NULL);
    1770                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1771                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_sample_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1772                 :            : 
    1773                 :          0 :     return o;
    1774                 :            : }
    1775                 :            : 
    1776                 :          0 : pa_operation* pa_context_get_sample_info_list(pa_context *c, pa_sample_info_cb_t cb, void *userdata) {
    1777                 :          0 :     return pa_context_send_simple_command(c, PA_COMMAND_GET_SAMPLE_INFO_LIST, context_get_sample_info_callback, (pa_operation_cb_t) cb, userdata);
    1778                 :            : }
    1779                 :            : 
    1780                 :          0 : static pa_operation* command_kill(pa_context *c, uint32_t command, uint32_t idx, pa_context_success_cb_t cb, void *userdata) {
    1781                 :            :     pa_operation *o;
    1782                 :            :     pa_tagstruct *t;
    1783                 :            :     uint32_t tag;
    1784                 :            : 
    1785         [ #  # ]:          0 :     pa_assert(c);
    1786         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1787                 :            : 
    1788         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1789         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1790         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
    1791                 :            : 
    1792                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1793                 :            : 
    1794                 :          0 :     t = pa_tagstruct_command(c, command, &tag);
    1795                 :          0 :     pa_tagstruct_putu32(t, idx);
    1796                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1797                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1798                 :            : 
    1799                 :          0 :     return o;
    1800                 :            : }
    1801                 :            : 
    1802                 :          0 : pa_operation* pa_context_kill_client(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata) {
    1803                 :          0 :     return command_kill(c, PA_COMMAND_KILL_CLIENT, idx, cb, userdata);
    1804                 :            : }
    1805                 :            : 
    1806                 :          0 : pa_operation* pa_context_kill_sink_input(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata) {
    1807                 :          0 :     return command_kill(c, PA_COMMAND_KILL_SINK_INPUT, idx, cb, userdata);
    1808                 :            : }
    1809                 :            : 
    1810                 :          0 : pa_operation* pa_context_kill_source_output(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata) {
    1811                 :          0 :     return command_kill(c, PA_COMMAND_KILL_SOURCE_OUTPUT, idx, cb, userdata);
    1812                 :            : }
    1813                 :            : 
    1814                 :          0 : static void context_index_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
    1815                 :          0 :     pa_operation *o = userdata;
    1816                 :            :     uint32_t idx;
    1817                 :            : 
    1818         [ #  # ]:          0 :     pa_assert(pd);
    1819         [ #  # ]:          0 :     pa_assert(o);
    1820         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(o) >= 1);
    1821                 :            : 
    1822         [ #  # ]:          0 :     if (!o->context)
    1823                 :            :         goto finish;
    1824                 :            : 
    1825         [ #  # ]:          0 :     if (command != PA_COMMAND_REPLY) {
    1826         [ #  # ]:          0 :         if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
    1827                 :            :             goto finish;
    1828                 :            : 
    1829                 :          0 :         idx = PA_INVALID_INDEX;
    1830   [ #  #  #  # ]:          0 :     } else if (pa_tagstruct_getu32(t, &idx) ||
    1831                 :          0 :                !pa_tagstruct_eof(t)) {
    1832                 :          0 :         pa_context_fail(o->context, PA_ERR_PROTOCOL);
    1833                 :          0 :         goto finish;
    1834                 :            :     }
    1835                 :            : 
    1836         [ #  # ]:          0 :     if (o->callback) {
    1837                 :          0 :         pa_context_index_cb_t cb = (pa_context_index_cb_t) o->callback;
    1838                 :          0 :         cb(o->context, idx, o->userdata);
    1839                 :            :     }
    1840                 :            : 
    1841                 :            : 
    1842                 :            : finish:
    1843                 :          0 :     pa_operation_done(o);
    1844                 :          0 :     pa_operation_unref(o);
    1845                 :          0 : }
    1846                 :            : 
    1847                 :          0 : pa_operation* pa_context_load_module(pa_context *c, const char*name, const char *argument, pa_context_index_cb_t cb, void *userdata) {
    1848                 :            :     pa_operation *o;
    1849                 :            :     pa_tagstruct *t;
    1850                 :            :     uint32_t tag;
    1851                 :            : 
    1852         [ #  # ]:          0 :     pa_assert(c);
    1853         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1854                 :            : 
    1855         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1856         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1857 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
    1858                 :            : 
    1859                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1860                 :            : 
    1861                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_LOAD_MODULE, &tag);
    1862                 :          0 :     pa_tagstruct_puts(t, name);
    1863                 :          0 :     pa_tagstruct_puts(t, argument);
    1864                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1865                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_index_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1866                 :            : 
    1867                 :          0 :     return o;
    1868                 :            : }
    1869                 :            : 
    1870                 :          0 : pa_operation* pa_context_unload_module(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata) {
    1871                 :          0 :     return command_kill(c, PA_COMMAND_UNLOAD_MODULE, idx, cb, userdata);
    1872                 :            : }
    1873                 :            : 
    1874                 :          0 : pa_operation* pa_context_set_port_latency_offset(pa_context *c, const char *card_name, const char *port_name, int64_t offset, pa_context_success_cb_t cb, void *userdata) {
    1875                 :            :     pa_operation *o;
    1876                 :            :     pa_tagstruct *t;
    1877                 :            :     uint32_t tag;
    1878                 :            : 
    1879         [ #  # ]:          0 :     pa_assert(c);
    1880         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1881                 :            : 
    1882         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1883         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1884 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, card_name && *card_name, PA_ERR_INVALID);
    1885 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, port_name && *port_name, PA_ERR_INVALID);
    1886         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 27, PA_ERR_NOTSUPPORTED);
    1887                 :            : 
    1888                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1889                 :            : 
    1890                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SET_PORT_LATENCY_OFFSET, &tag);
    1891                 :          0 :     pa_tagstruct_putu32(t, PA_INVALID_INDEX);
    1892                 :          0 :     pa_tagstruct_puts(t, card_name);
    1893                 :          0 :     pa_tagstruct_puts(t, port_name);
    1894                 :          0 :     pa_tagstruct_puts64(t, offset);
    1895                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1896                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1897                 :            : 
    1898                 :          0 :     return o;
    1899                 :            : }
    1900                 :            : 
    1901                 :            : /*** Autoload stuff ***/
    1902                 :            : 
    1903                 :            : PA_WARN_REFERENCE(pa_context_get_autoload_info_by_name, "Module auto-loading no longer supported.");
    1904                 :            : 
    1905                 :          0 : pa_operation* pa_context_get_autoload_info_by_name(pa_context *c, const char *name, pa_autoload_type_t type, pa_autoload_info_cb_t cb, void *userdata) {
    1906                 :            : 
    1907         [ #  # ]:          0 :     pa_assert(c);
    1908         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1909                 :            : 
    1910                 :          0 :     PA_FAIL_RETURN_NULL(c, PA_ERR_OBSOLETE);
    1911                 :            : }
    1912                 :            : 
    1913                 :            : PA_WARN_REFERENCE(pa_context_get_autoload_info_by_index, "Module auto-loading no longer supported.");
    1914                 :            : 
    1915                 :          0 : pa_operation* pa_context_get_autoload_info_by_index(pa_context *c, uint32_t idx, pa_autoload_info_cb_t cb, void *userdata) {
    1916         [ #  # ]:          0 :     pa_assert(c);
    1917         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1918                 :            : 
    1919                 :          0 :     PA_FAIL_RETURN_NULL(c, PA_ERR_OBSOLETE);
    1920                 :            : }
    1921                 :            : 
    1922                 :            : PA_WARN_REFERENCE(pa_context_get_autoload_info_list, "Module auto-loading no longer supported.");
    1923                 :            : 
    1924                 :          0 : pa_operation* pa_context_get_autoload_info_list(pa_context *c, pa_autoload_info_cb_t cb, void *userdata) {
    1925         [ #  # ]:          0 :     pa_assert(c);
    1926         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1927                 :            : 
    1928                 :          0 :     PA_FAIL_RETURN_NULL(c, PA_ERR_OBSOLETE);
    1929                 :            : }
    1930                 :            : 
    1931                 :            : PA_WARN_REFERENCE(pa_context_add_autoload, "Module auto-loading no longer supported.");
    1932                 :            : 
    1933                 :          0 : pa_operation* pa_context_add_autoload(pa_context *c, const char *name, pa_autoload_type_t type, const char *module, const char*argument, pa_context_index_cb_t cb, void* userdata) {
    1934         [ #  # ]:          0 :     pa_assert(c);
    1935         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1936                 :            : 
    1937                 :          0 :     PA_FAIL_RETURN_NULL(c, PA_ERR_OBSOLETE);
    1938                 :            : }
    1939                 :            : 
    1940                 :            : PA_WARN_REFERENCE(pa_context_remove_autoload_by_name, "Module auto-loading no longer supported.");
    1941                 :            : 
    1942                 :          0 : pa_operation* pa_context_remove_autoload_by_name(pa_context *c, const char *name, pa_autoload_type_t type, pa_context_success_cb_t cb, void* userdata) {
    1943         [ #  # ]:          0 :     pa_assert(c);
    1944         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1945                 :            : 
    1946                 :          0 :     PA_FAIL_RETURN_NULL(c, PA_ERR_OBSOLETE);
    1947                 :            : }
    1948                 :            : 
    1949                 :            : PA_WARN_REFERENCE(pa_context_remove_autoload_by_index, "Module auto-loading no longer supported.");
    1950                 :            : 
    1951                 :          0 : pa_operation* pa_context_remove_autoload_by_index(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void* userdata) {
    1952         [ #  # ]:          0 :     pa_assert(c);
    1953         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1954                 :            : 
    1955                 :          0 :     PA_FAIL_RETURN_NULL(c, PA_ERR_OBSOLETE);
    1956                 :            : }
    1957                 :            : 
    1958                 :          0 : pa_operation* pa_context_move_sink_input_by_name(pa_context *c, uint32_t idx, const char *sink_name, pa_context_success_cb_t cb, void* userdata) {
    1959                 :            :     pa_operation *o;
    1960                 :            :     pa_tagstruct *t;
    1961                 :            :     uint32_t tag;
    1962                 :            : 
    1963         [ #  # ]:          0 :     pa_assert(c);
    1964         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1965                 :            : 
    1966         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1967         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1968         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 10, PA_ERR_NOTSUPPORTED);
    1969         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
    1970 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, sink_name && *sink_name, PA_ERR_INVALID);
    1971                 :            : 
    1972                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1973                 :            : 
    1974                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_MOVE_SINK_INPUT, &tag);
    1975                 :          0 :     pa_tagstruct_putu32(t, idx);
    1976                 :          0 :     pa_tagstruct_putu32(t, PA_INVALID_INDEX);
    1977                 :          0 :     pa_tagstruct_puts(t, sink_name);
    1978                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    1979                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    1980                 :            : 
    1981                 :          0 :     return o;
    1982                 :            : }
    1983                 :            : 
    1984                 :          0 : pa_operation* pa_context_move_sink_input_by_index(pa_context *c, uint32_t idx, uint32_t sink_idx, pa_context_success_cb_t cb, void* userdata) {
    1985                 :            :     pa_operation *o;
    1986                 :            :     pa_tagstruct *t;
    1987                 :            :     uint32_t tag;
    1988                 :            : 
    1989         [ #  # ]:          0 :     pa_assert(c);
    1990         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    1991                 :            : 
    1992         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    1993         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    1994         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 10, PA_ERR_NOTSUPPORTED);
    1995         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
    1996         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, sink_idx != PA_INVALID_INDEX, PA_ERR_INVALID);
    1997                 :            : 
    1998                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    1999                 :            : 
    2000                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_MOVE_SINK_INPUT, &tag);
    2001                 :          0 :     pa_tagstruct_putu32(t, idx);
    2002                 :          0 :     pa_tagstruct_putu32(t, sink_idx);
    2003                 :          0 :     pa_tagstruct_puts(t, NULL);
    2004                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    2005                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    2006                 :            : 
    2007                 :          0 :     return o;
    2008                 :            : }
    2009                 :            : 
    2010                 :          0 : pa_operation* pa_context_move_source_output_by_name(pa_context *c, uint32_t idx, const char *source_name, pa_context_success_cb_t cb, void* userdata) {
    2011                 :            :     pa_operation *o;
    2012                 :            :     pa_tagstruct *t;
    2013                 :            :     uint32_t tag;
    2014                 :            : 
    2015         [ #  # ]:          0 :     pa_assert(c);
    2016         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    2017                 :            : 
    2018         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    2019         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    2020         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 10, PA_ERR_NOTSUPPORTED);
    2021         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
    2022 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, source_name && *source_name, PA_ERR_INVALID);
    2023                 :            : 
    2024                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    2025                 :            : 
    2026                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_MOVE_SOURCE_OUTPUT, &tag);
    2027                 :          0 :     pa_tagstruct_putu32(t, idx);
    2028                 :          0 :     pa_tagstruct_putu32(t, PA_INVALID_INDEX);
    2029                 :          0 :     pa_tagstruct_puts(t, source_name);
    2030                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    2031                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    2032                 :            : 
    2033                 :          0 :     return o;
    2034                 :            : }
    2035                 :            : 
    2036                 :          0 : pa_operation* pa_context_move_source_output_by_index(pa_context *c, uint32_t idx, uint32_t source_idx, pa_context_success_cb_t cb, void* userdata) {
    2037                 :            :     pa_operation *o;
    2038                 :            :     pa_tagstruct *t;
    2039                 :            :     uint32_t tag;
    2040                 :            : 
    2041         [ #  # ]:          0 :     pa_assert(c);
    2042         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    2043                 :            : 
    2044         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    2045         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    2046         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 10, PA_ERR_NOTSUPPORTED);
    2047         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
    2048         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, source_idx != PA_INVALID_INDEX, PA_ERR_INVALID);
    2049                 :            : 
    2050                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    2051                 :            : 
    2052                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_MOVE_SOURCE_OUTPUT, &tag);
    2053                 :          0 :     pa_tagstruct_putu32(t, idx);
    2054                 :          0 :     pa_tagstruct_putu32(t, source_idx);
    2055                 :          0 :     pa_tagstruct_puts(t, NULL);
    2056                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    2057                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    2058                 :            : 
    2059                 :          0 :     return o;
    2060                 :            : }
    2061                 :            : 
    2062                 :          0 : pa_operation* pa_context_suspend_sink_by_name(pa_context *c, const char *sink_name, int suspend, pa_context_success_cb_t cb, void* userdata) {
    2063                 :            :     pa_operation *o;
    2064                 :            :     pa_tagstruct *t;
    2065                 :            :     uint32_t tag;
    2066                 :            : 
    2067         [ #  # ]:          0 :     pa_assert(c);
    2068         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    2069                 :            : 
    2070         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    2071         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    2072         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED);
    2073 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !sink_name || *sink_name, PA_ERR_INVALID);
    2074                 :            : 
    2075                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    2076                 :            : 
    2077                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SUSPEND_SINK, &tag);
    2078                 :          0 :     pa_tagstruct_putu32(t, PA_INVALID_INDEX);
    2079                 :          0 :     pa_tagstruct_puts(t, sink_name);
    2080                 :          0 :     pa_tagstruct_put_boolean(t, suspend);
    2081                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    2082                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    2083                 :            : 
    2084                 :          0 :     return o;
    2085                 :            : }
    2086                 :            : 
    2087                 :          0 : pa_operation* pa_context_suspend_sink_by_index(pa_context *c, uint32_t idx, int suspend, pa_context_success_cb_t cb, void* userdata) {
    2088                 :            :     pa_operation *o;
    2089                 :            :     pa_tagstruct *t;
    2090                 :            :     uint32_t tag;
    2091                 :            : 
    2092         [ #  # ]:          0 :     pa_assert(c);
    2093         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    2094                 :            : 
    2095         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    2096         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    2097         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED);
    2098                 :            : 
    2099                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    2100                 :            : 
    2101                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SUSPEND_SINK, &tag);
    2102                 :          0 :     pa_tagstruct_putu32(t, idx);
    2103         [ #  # ]:          0 :     pa_tagstruct_puts(t, idx == PA_INVALID_INDEX ? "" : NULL);
    2104                 :          0 :     pa_tagstruct_put_boolean(t, suspend);
    2105                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    2106                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    2107                 :            : 
    2108                 :          0 :     return o;
    2109                 :            : }
    2110                 :            : 
    2111                 :          0 : pa_operation* pa_context_suspend_source_by_name(pa_context *c, const char *source_name, int suspend, pa_context_success_cb_t cb, void* userdata) {
    2112                 :            :     pa_operation *o;
    2113                 :            :     pa_tagstruct *t;
    2114                 :            :     uint32_t tag;
    2115                 :            : 
    2116         [ #  # ]:          0 :     pa_assert(c);
    2117         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    2118                 :            : 
    2119         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    2120         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    2121         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED);
    2122 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !source_name || *source_name, PA_ERR_INVALID);
    2123                 :            : 
    2124                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    2125                 :            : 
    2126                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SUSPEND_SOURCE, &tag);
    2127                 :          0 :     pa_tagstruct_putu32(t, PA_INVALID_INDEX);
    2128                 :          0 :     pa_tagstruct_puts(t, source_name);
    2129                 :          0 :     pa_tagstruct_put_boolean(t, suspend);
    2130                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    2131                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    2132                 :            : 
    2133                 :          0 :     return o;
    2134                 :            : }
    2135                 :            : 
    2136                 :          0 : pa_operation* pa_context_suspend_source_by_index(pa_context *c, uint32_t idx, int suspend, pa_context_success_cb_t cb, void* userdata) {
    2137                 :            :     pa_operation *o;
    2138                 :            :     pa_tagstruct *t;
    2139                 :            :     uint32_t tag;
    2140                 :            : 
    2141         [ #  # ]:          0 :     pa_assert(c);
    2142         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
    2143                 :            : 
    2144         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
    2145         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    2146         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED);
    2147                 :            : 
    2148                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
    2149                 :            : 
    2150                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_SUSPEND_SOURCE, &tag);
    2151                 :          0 :     pa_tagstruct_putu32(t, idx);
    2152         [ #  # ]:          0 :     pa_tagstruct_puts(t, idx == PA_INVALID_INDEX ? "" : NULL);
    2153                 :          0 :     pa_tagstruct_put_boolean(t, suspend);
    2154                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
    2155                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
    2156                 :            : 
    2157                 :          0 :     return o;
    2158                 :            : }

Generated by: LCOV version 1.9