Logo Search packages:      
Sourcecode: pulseaudio version File versions  Download package

pa_stream* pa_stream_new ( pa_context c,
const char *  name,
const pa_sample_spec ss,
const pa_channel_map map 
)

Create a new, unconnected stream with the specified name and sample type

Parameters:
c  The context to create this stream in
name  A name for this stream
ss  The desired sample format
map  The desired channel map, or NULL for default

Definition at line 46 of file stream.c.

References pa_sample_spec::channels, pa_channel_map::channels, pa_sample_spec::format, PA_CHANNEL_MAP_DEFAULT, PA_ERR_INVALID, PA_ERR_NOTSUPPORTED, PA_INVALID_INDEX, PA_SAMPLE_S32LE, PA_SAMPLE_S32NE, PA_STREAM_NODIRECTION, PA_STREAM_UNCONNECTED, and pa_xnew.

                                                                                                               {
    pa_stream *s;
    int i;
    pa_channel_map tmap;

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

    PA_CHECK_VALIDITY_RETURN_NULL(c, ss && pa_sample_spec_valid(ss), PA_ERR_INVALID);
    PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 12 || (ss->format != PA_SAMPLE_S32LE || ss->format != PA_SAMPLE_S32NE), PA_ERR_NOTSUPPORTED);
    PA_CHECK_VALIDITY_RETURN_NULL(c, !map || (pa_channel_map_valid(map) && map->channels == ss->channels), PA_ERR_INVALID);

    if (!map)
        PA_CHECK_VALIDITY_RETURN_NULL(c, map = pa_channel_map_init_auto(&tmap, ss->channels, PA_CHANNEL_MAP_DEFAULT), PA_ERR_INVALID);

    s = pa_xnew(pa_stream, 1);
    PA_REFCNT_INIT(s);
    s->context = c;
    s->mainloop = c->mainloop;

    s->buffer_attr_not_ready = s->timing_info_not_ready = FALSE;

    s->read_callback = NULL;
    s->read_userdata = NULL;
    s->write_callback = NULL;
    s->write_userdata = NULL;
    s->state_callback = NULL;
    s->state_userdata = NULL;
    s->overflow_callback = NULL;
    s->overflow_userdata = NULL;
    s->underflow_callback = NULL;
    s->underflow_userdata = NULL;
    s->latency_update_callback = NULL;
    s->latency_update_userdata = NULL;
    s->moved_callback = NULL;
    s->moved_userdata = NULL;
    s->suspended_callback = NULL;
    s->suspended_userdata = NULL;

    s->direction = PA_STREAM_NODIRECTION;
    s->name = pa_xstrdup(name);
    s->sample_spec = *ss;
    s->channel_map = *map;
    s->flags = 0;

    s->channel = 0;
    s->channel_valid = 0;
    s->syncid = c->csyncid++;
    s->stream_index = PA_INVALID_INDEX;
    s->requested_bytes = 0;
    s->state = PA_STREAM_UNCONNECTED;

    s->manual_buffer_attr = FALSE;
    memset(&s->buffer_attr, 0, sizeof(s->buffer_attr));

    s->device_index = PA_INVALID_INDEX;
    s->device_name = NULL;
    s->suspended = FALSE;

    s->peek_memchunk.index = 0;
    s->peek_memchunk.length = 0;
    s->peek_memchunk.memblock = NULL;
    s->peek_data = NULL;

    s->record_memblockq = NULL;

    s->previous_time = 0;
    s->timing_info_valid = 0;
    s->read_index_not_before = 0;
    s->write_index_not_before = 0;

    for (i = 0; i < PA_MAX_WRITE_INDEX_CORRECTIONS; i++)
        s->write_index_corrections[i].valid = 0;
    s->current_write_index_correction = 0;

    s->corked = 0;

    s->cached_time_valid = 0;

    s->auto_timing_update_event = NULL;
    s->auto_timing_update_requested = 0;

    /* Refcounting is strictly one-way: from the "bigger" to the "smaller" object. */
    PA_LLIST_PREPEND(pa_stream, c->streams, s);
    pa_stream_ref(s);

    return s;
}


Generated by  Doxygen 1.6.0   Back to index