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

           Branch data     Line data    Source code
       1                 :            : /***
       2                 :            :   This file is part of PulseAudio.
       3                 :            : 
       4                 :            :   Copyright 2004-2006 Lennart Poettering
       5                 :            : 
       6                 :            :   PulseAudio is free software; you can redistribute it and/or modify
       7                 :            :   it under the terms of the GNU Lesser General Public License as published
       8                 :            :   by the Free Software Foundation; either version 2.1 of the License,
       9                 :            :   or (at your option) any later version.
      10                 :            : 
      11                 :            :   PulseAudio is distributed in the hope that it will be useful, but
      12                 :            :   WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 :            :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
      14                 :            :   General Public License for more details.
      15                 :            : 
      16                 :            :   You should have received a copy of the GNU Lesser General Public License
      17                 :            :   along with PulseAudio; if not, write to the Free Software
      18                 :            :   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
      19                 :            :   USA.
      20                 :            : ***/
      21                 :            : 
      22                 :            : #ifdef HAVE_CONFIG_H
      23                 :            : #include <config.h>
      24                 :            : #endif
      25                 :            : 
      26                 :            : #include <stdlib.h>
      27                 :            : #include <stdio.h>
      28                 :            : 
      29                 :            : #include <pulse/utf8.h>
      30                 :            : #include <pulse/fork-detect.h>
      31                 :            : 
      32                 :            : #include <pulsecore/pstream-util.h>
      33                 :            : #include <pulsecore/macro.h>
      34                 :            : #include <pulsecore/proplist-util.h>
      35                 :            : 
      36                 :            : #include "internal.h"
      37                 :            : #include "scache.h"
      38                 :            : 
      39                 :          0 : int pa_stream_connect_upload(pa_stream *s, size_t length) {
      40                 :            :     pa_tagstruct *t;
      41                 :            :     uint32_t tag;
      42                 :            :     const char *name;
      43                 :            : 
      44         [ #  # ]:          0 :     pa_assert(s);
      45         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(s) >= 1);
      46                 :            : 
      47         [ #  # ]:          0 :     PA_CHECK_VALIDITY(s->context, !pa_detect_fork(), PA_ERR_FORKED);
      48         [ #  # ]:          0 :     PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_UNCONNECTED, PA_ERR_BADSTATE);
      49         [ #  # ]:          0 :     PA_CHECK_VALIDITY(s->context, length > 0, PA_ERR_INVALID);
      50         [ #  # ]:          0 :     PA_CHECK_VALIDITY(s->context, length == (size_t) (uint32_t) length, PA_ERR_INVALID);
      51         [ #  # ]:          0 :     PA_CHECK_VALIDITY(s->context, s->context->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
      52                 :            : 
      53         [ #  # ]:          0 :     if (!(name = pa_proplist_gets(s->proplist, PA_PROP_EVENT_ID)))
      54                 :          0 :         name = pa_proplist_gets(s->proplist, PA_PROP_MEDIA_NAME);
      55                 :            : 
      56 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY(s->context, name && *name && pa_utf8_valid(name), PA_ERR_INVALID);
                 [ #  # ]
      57                 :            : 
      58                 :          0 :     pa_stream_ref(s);
      59                 :            : 
      60                 :          0 :     s->direction = PA_STREAM_UPLOAD;
      61                 :          0 :     s->flags = 0;
      62                 :            : 
      63                 :          0 :     t = pa_tagstruct_command(s->context, PA_COMMAND_CREATE_UPLOAD_STREAM, &tag);
      64                 :            : 
      65                 :          0 :     pa_tagstruct_puts(t, name);
      66                 :          0 :     pa_tagstruct_put_sample_spec(t, &s->sample_spec);
      67                 :          0 :     pa_tagstruct_put_channel_map(t, &s->channel_map);
      68                 :          0 :     pa_tagstruct_putu32(t, (uint32_t) length);
      69                 :            : 
      70         [ #  # ]:          0 :     if (s->context->version >= 13)
      71                 :          0 :         pa_tagstruct_put_proplist(t, s->proplist);
      72                 :            : 
      73                 :          0 :     pa_pstream_send_tagstruct(s->context->pstream, t);
      74                 :          0 :     pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, pa_create_stream_callback, s, NULL);
      75                 :            : 
      76                 :          0 :     pa_stream_set_state(s, PA_STREAM_CREATING);
      77                 :            : 
      78                 :          0 :     pa_stream_unref(s);
      79                 :          0 :     return 0;
      80                 :            : }
      81                 :            : 
      82                 :          0 : int pa_stream_finish_upload(pa_stream *s) {
      83                 :            :     pa_tagstruct *t;
      84                 :            :     uint32_t tag;
      85                 :            : 
      86         [ #  # ]:          0 :     pa_assert(s);
      87         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(s) >= 1);
      88                 :            : 
      89         [ #  # ]:          0 :     PA_CHECK_VALIDITY(s->context, !pa_detect_fork(), PA_ERR_FORKED);
      90         [ #  # ]:          0 :     PA_CHECK_VALIDITY(s->context, s->channel_valid, PA_ERR_BADSTATE);
      91         [ #  # ]:          0 :     PA_CHECK_VALIDITY(s->context, s->context->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
      92                 :            : 
      93                 :          0 :     pa_stream_ref(s);
      94                 :            : 
      95                 :          0 :     t = pa_tagstruct_command(s->context, PA_COMMAND_FINISH_UPLOAD_STREAM, &tag);
      96                 :          0 :     pa_tagstruct_putu32(t, s->channel);
      97                 :          0 :     pa_pstream_send_tagstruct(s->context->pstream, t);
      98                 :          0 :     pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, pa_stream_disconnect_callback, s, NULL);
      99                 :            : 
     100                 :          0 :     pa_stream_unref(s);
     101                 :          0 :     return 0;
     102                 :            : }
     103                 :            : 
     104                 :          0 : static void play_sample_ack_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
     105                 :          0 :     pa_operation *o = userdata;
     106                 :          0 :     int success = 1;
     107                 :          0 :     uint32_t idx = PA_INVALID_INDEX;
     108                 :            : 
     109         [ #  # ]:          0 :     pa_assert(pd);
     110         [ #  # ]:          0 :     pa_assert(o);
     111         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(o) >= 1);
     112                 :            : 
     113         [ #  # ]:          0 :     if (!o->context)
     114                 :            :         goto finish;
     115                 :            : 
     116         [ #  # ]:          0 :     if (command != PA_COMMAND_REPLY) {
     117         [ #  # ]:          0 :         if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
     118                 :            :             goto finish;
     119                 :            : 
     120                 :            :         success = 0;
     121         [ #  # ]:          0 :     } else if ((o->context->version >= 13 && pa_tagstruct_getu32(t, &idx) < 0) ||
           [ #  #  #  # ]
     122                 :          0 :                !pa_tagstruct_eof(t)) {
     123                 :          0 :         pa_context_fail(o->context, PA_ERR_PROTOCOL);
     124                 :          0 :         goto finish;
     125 [ #  # ][ #  # ]:          0 :     } else if (o->context->version >= 13 && idx == PA_INVALID_INDEX)
     126                 :          0 :         success = 0;
     127                 :            : 
     128         [ #  # ]:          0 :     if (o->callback) {
     129                 :          0 :         pa_context_success_cb_t cb = (pa_context_success_cb_t) o->callback;
     130                 :          0 :         cb(o->context, success, o->userdata);
     131                 :            :     }
     132                 :            : 
     133                 :            : finish:
     134                 :          0 :     pa_operation_done(o);
     135                 :          0 :     pa_operation_unref(o);
     136                 :          0 : }
     137                 :            : 
     138                 :          0 : static void play_sample_with_proplist_ack_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
     139                 :          0 :     pa_operation *o = userdata;
     140                 :            :     uint32_t idx;
     141                 :            : 
     142         [ #  # ]:          0 :     pa_assert(pd);
     143         [ #  # ]:          0 :     pa_assert(o);
     144         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(o) >= 1);
     145                 :            : 
     146         [ #  # ]:          0 :     if (!o->context)
     147                 :            :         goto finish;
     148                 :            : 
     149         [ #  # ]:          0 :     if (command != PA_COMMAND_REPLY) {
     150         [ #  # ]:          0 :         if (pa_context_handle_error(o->context, command, t, FALSE) < 0)
     151                 :            :             goto finish;
     152                 :            : 
     153                 :          0 :         idx = PA_INVALID_INDEX;
     154   [ #  #  #  # ]:          0 :     } else if (pa_tagstruct_getu32(t, &idx) < 0 ||
     155                 :          0 :                !pa_tagstruct_eof(t)) {
     156                 :          0 :         pa_context_fail(o->context, PA_ERR_PROTOCOL);
     157                 :          0 :         goto finish;
     158                 :            :     }
     159                 :            : 
     160         [ #  # ]:          0 :     if (o->callback) {
     161                 :          0 :         pa_context_play_sample_cb_t cb = (pa_context_play_sample_cb_t) o->callback;
     162                 :          0 :         cb(o->context, idx, o->userdata);
     163                 :            :     }
     164                 :            : 
     165                 :            : finish:
     166                 :          0 :     pa_operation_done(o);
     167                 :          0 :     pa_operation_unref(o);
     168                 :          0 : }
     169                 :            : 
     170                 :            : 
     171                 :          0 : pa_operation *pa_context_play_sample(pa_context *c, const char *name, const char *dev, pa_volume_t volume, pa_context_success_cb_t cb, void *userdata) {
     172                 :            :     pa_operation *o;
     173                 :            :     pa_tagstruct *t;
     174                 :            :     uint32_t tag;
     175                 :            : 
     176         [ #  # ]:          0 :     pa_assert(c);
     177         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
     178                 :            : 
     179         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     180         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     181 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
     182 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !dev || *dev, PA_ERR_INVALID);
     183                 :            : 
     184                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
     185                 :            : 
     186         [ #  # ]:          0 :     if (!dev)
     187                 :          0 :         dev = c->conf->default_sink;
     188                 :            : 
     189                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_PLAY_SAMPLE, &tag);
     190                 :          0 :     pa_tagstruct_putu32(t, PA_INVALID_INDEX);
     191                 :          0 :     pa_tagstruct_puts(t, dev);
     192                 :            : 
     193 [ #  # ][ #  # ]:          0 :     if (!PA_VOLUME_IS_VALID(volume) && c->version < 15)
     194                 :          0 :         volume = PA_VOLUME_NORM;
     195                 :            : 
     196                 :          0 :     pa_tagstruct_putu32(t, volume);
     197                 :          0 :     pa_tagstruct_puts(t, name);
     198                 :            : 
     199         [ #  # ]:          0 :     if (c->version >= 13) {
     200                 :          0 :         pa_proplist *p = pa_proplist_new();
     201                 :          0 :         pa_tagstruct_put_proplist(t, p);
     202                 :          0 :         pa_proplist_free(p);
     203                 :            :     }
     204                 :            : 
     205                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
     206                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, play_sample_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
     207                 :            : 
     208                 :          0 :     return o;
     209                 :            : }
     210                 :            : 
     211                 :          0 : pa_operation *pa_context_play_sample_with_proplist(pa_context *c, const char *name, const char *dev, pa_volume_t volume, pa_proplist *p, pa_context_play_sample_cb_t cb, void *userdata) {
     212                 :            :     pa_operation *o;
     213                 :            :     pa_tagstruct *t;
     214                 :            :     uint32_t tag;
     215                 :            : 
     216         [ #  # ]:          0 :     pa_assert(c);
     217         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
     218                 :            : 
     219         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     220         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     221 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
     222 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !dev || *dev, PA_ERR_INVALID);
     223         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 13, PA_ERR_NOTSUPPORTED);
     224                 :            : 
     225                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
     226                 :            : 
     227         [ #  # ]:          0 :     if (!dev)
     228                 :          0 :         dev = c->conf->default_sink;
     229                 :            : 
     230                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_PLAY_SAMPLE, &tag);
     231                 :          0 :     pa_tagstruct_putu32(t, PA_INVALID_INDEX);
     232                 :          0 :     pa_tagstruct_puts(t, dev);
     233                 :            : 
     234 [ #  # ][ #  # ]:          0 :     if (!PA_VOLUME_IS_VALID(volume) && c->version < 15)
     235                 :          0 :         volume = PA_VOLUME_NORM;
     236                 :            : 
     237                 :          0 :     pa_tagstruct_putu32(t, volume);
     238                 :          0 :     pa_tagstruct_puts(t, name);
     239                 :            : 
     240         [ #  # ]:          0 :     if (p)
     241                 :          0 :         pa_tagstruct_put_proplist(t, p);
     242                 :            :     else {
     243                 :          0 :         p = pa_proplist_new();
     244                 :          0 :         pa_tagstruct_put_proplist(t, p);
     245                 :          0 :         pa_proplist_free(p);
     246                 :            :     }
     247                 :            : 
     248                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
     249                 :          0 :     pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, play_sample_with_proplist_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
     250                 :            : 
     251                 :          0 :     return o;
     252                 :            : }
     253                 :            : 
     254                 :          0 : pa_operation* pa_context_remove_sample(pa_context *c, const char *name, pa_context_success_cb_t cb, void *userdata) {
     255                 :            :     pa_operation *o;
     256                 :            :     pa_tagstruct *t;
     257                 :            :     uint32_t tag;
     258                 :            : 
     259         [ #  # ]:          0 :     pa_assert(c);
     260         [ #  # ]:          0 :     pa_assert(PA_REFCNT_VALUE(c) >= 1);
     261                 :            : 
     262         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     263         [ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     264 [ #  # ][ #  # ]:          0 :     PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
     265                 :            : 
     266                 :          0 :     o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
     267                 :            : 
     268                 :          0 :     t = pa_tagstruct_command(c, PA_COMMAND_REMOVE_SAMPLE, &tag);
     269                 :          0 :     pa_tagstruct_puts(t, name);
     270                 :            : 
     271                 :          0 :     pa_pstream_send_tagstruct(c->pstream, t);
     272                 :          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);
     273                 :            : 
     274                 :          0 :     return o;
     275                 :            : }

Generated by: LCOV version 1.9