示例#1
0
static void push_a_copy(const char *s, struct list_of_strings *list) {
    if ( list->size < list->n_strings + 2 ) { // including terminating NULL
        list->size = list->size == 0 ? 2 : list->size * 2;
        list->strings = _mbx_xrealloc(list->strings, list->size*sizeof(char *));
    }
    list->strings[list->n_strings++] = _mbx_xstrdup(s);
    list->strings[list->n_strings] = NULL;
}
示例#2
0
/* Initialize a new _mbx_out. This is a helper function for _mbx_out_new() */
static void malloc_and_init(_mbx_out *out_p,
        const char *name, const char *dev_name, _mbx_out_cb cb,
        void *output_cb_userdata)
{
    *out_p = _mbx_xmalloc(sizeof(struct _mbx_out));
    bzero(*out_p, sizeof(struct _mbx_out));
    (*out_p)->state = _MBX_OUT_INITIALIZING;
    (*out_p)->output_cb_userdata = output_cb_userdata;
    (*out_p)->name = _mbx_xstrdup(name);
    (*out_p)->dev_name = _mbx_xstrdup(dev_name);
    /* TODO: The sample spec is hard coded. It should be determined depending
     * on the capabilities of the sound card. */
    (*out_p)->sample_spec.rate = MBX_SAMPLE_RATE;
    (*out_p)->sample_spec.channels = 2; /* stereo */
    (*out_p)->sample_spec.format = PA_SAMPLE_S16LE;
    /* an invalid sample spec would be a programming error */
    assert(pa_sample_spec_valid(&(*out_p)->sample_spec));
    (*out_p)->cb = cb;
}