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

pa_stream* pa_stream_new_with_proplist ( pa_context c,
const char *  name,
const pa_sample_spec ss,
const pa_channel_map map,
pa_proplist *  p 
)

Create a new, unconnected stream with the specified name and sample type, and specify the the initial stream property list.

Since:
0.9.11
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
p  The initial property list

Definition at line 83 of file stream.c.

References pa_sample_spec::channels, pa_channel_map::channels, pa_sample_spec::format, PA_CHANNEL_MAP_DEFAULT, PA_ERR_FORKED, PA_ERR_INVALID, PA_ERR_NOTSUPPORTED, PA_INVALID_INDEX, PA_SAMPLE_S24_32BE, PA_SAMPLE_S24_32LE, PA_SAMPLE_S24BE, PA_SAMPLE_S24LE, PA_SAMPLE_S32BE, PA_SAMPLE_S32LE, PA_STREAM_NODIRECTION, PA_STREAM_UNCONNECTED, PA_USEC_PER_MSEC, 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, !pa_detect_fork(), PA_ERR_FORKED);
    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_S32BE), PA_ERR_NOTSUPPORTED);
    PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15 || (ss->format != PA_SAMPLE_S24LE && ss->format != PA_SAMPLE_S24BE), PA_ERR_NOTSUPPORTED);
    PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15 || (ss->format != PA_SAMPLE_S24_32LE && ss->format != PA_SAMPLE_S24_32BE), PA_ERR_NOTSUPPORTED);
    PA_CHECK_VALIDITY_RETURN_NULL(c, !map || (pa_channel_map_valid(map) && map->channels == ss->channels), PA_ERR_INVALID);
    PA_CHECK_VALIDITY_RETURN_NULL(c, name || (p && pa_proplist_contains(p, PA_PROP_MEDIA_NAME)), 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->direction = PA_STREAM_NODIRECTION;
    s->state = PA_STREAM_UNCONNECTED;
    s->flags = 0;

    s->sample_spec = *ss;
    s->channel_map = *map;

    s->direct_on_input = PA_INVALID_INDEX;

    s->proplist = p ? pa_proplist_copy(p) : pa_proplist_new();
    if (name)
        pa_proplist_sets(s->proplist, PA_PROP_MEDIA_NAME, name);

    s->channel = 0;
    s->channel_valid = FALSE;
    s->syncid = c->csyncid++;
    s->stream_index = PA_INVALID_INDEX;

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

    /* We initialize der target length here, so that if the user
     * passes no explicit buffering metrics the default is similar to
     * what older PA versions provided. */

    s->buffer_attr.maxlength = (uint32_t) -1;
    s->buffer_attr.tlength = (uint32_t) pa_usec_to_bytes(250*PA_USEC_PER_MSEC, ss); /* 250ms of buffering */
    s->buffer_attr.minreq = (uint32_t) -1;
    s->buffer_attr.prebuf = (uint32_t) -1;
    s->buffer_attr.fragsize = (uint32_t) -1;

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

    s->write_memblock = NULL;
    s->write_data = NULL;

    pa_memchunk_reset(&s->peek_memchunk);
    s->peek_data = NULL;
    s->record_memblockq = NULL;

    memset(&s->timing_info, 0, sizeof(s->timing_info));
    s->timing_info_valid = FALSE;

    s->previous_time = 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->auto_timing_update_event = NULL;
    s->auto_timing_update_requested = FALSE;
    s->auto_timing_interval_usec = AUTO_TIMING_INTERVAL_START_USEC;

    reset_callbacks(s);

    s->smoother = NULL;

    /* 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