Logo Search packages:      
Sourcecode: pulseaudio version File versions

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 
)

Play a sample from the sample cache to the specified device. If the latter is NULL use the default sink. Returns an operation object

Parameters:
c  Context
name  Name of the sample to play
dev  Sink to play this sample on
volume  Volume to play this sample with. Starting with 0.9.15 you may pass here (pa_volume_t) -1 which will leave the decision about the volume to the server side which is a good idea.
cb  Call this function after successfully starting playback, or NULL
userdata  Userdata to pass to the callback

Definition at line 169 of file scache.c.

References PA_CONTEXT_READY, PA_ERR_BADSTATE, PA_ERR_INVALID, PA_INVALID_INDEX, PA_VOLUME_NORM, and pa_volume_t.

                                                                                                                                                       {
    pa_operation *o;
    pa_tagstruct *t;
    uint32_t tag;

    pa_assert(c);
    pa_assert(PA_REFCNT_VALUE(c) >= 1);

    PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
    PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
    PA_CHECK_VALIDITY_RETURN_NULL(c, !dev || *dev, PA_ERR_INVALID);

    o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);

    if (!dev)
        dev = c->conf->default_sink;

    t = pa_tagstruct_command(c, PA_COMMAND_PLAY_SAMPLE, &tag);
    pa_tagstruct_putu32(t, PA_INVALID_INDEX);
    pa_tagstruct_puts(t, dev);

    if (volume == (pa_volume_t) -1 && c->version < 15)
        volume = PA_VOLUME_NORM;

    pa_tagstruct_putu32(t, volume);
    pa_tagstruct_puts(t, name);

    if (c->version >= 13) {
        pa_proplist *p = pa_proplist_new();
        pa_tagstruct_put_proplist(t, p);
        pa_proplist_free(p);
    }

    pa_pstream_send_tagstruct(c->pstream, t);
    pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, play_sample_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);

    return o;
}


Generated by  Doxygen 1.6.0   Back to index