fix a bad memory access pulsecore/client.c

git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@2527 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2008-06-13 21:56:19 +00:00
parent 7bae1baa3e
commit b27cc1d426
14 changed files with 220 additions and 33 deletions

View file

@ -106,6 +106,8 @@ struct pa_stream {
pa_context *context;
pa_mainloop_api *mainloop;
uint32_t direct_on_input;
pa_stream_direction_t direction;
pa_stream_state_t state;
pa_stream_flags_t flags;

View file

@ -107,6 +107,8 @@ pa_stream *pa_stream_new_with_proplist(
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);
@ -838,6 +840,7 @@ static int create_stream(
pa_assert(direction == PA_STREAM_PLAYBACK || direction == PA_STREAM_RECORD);
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_UNCONNECTED, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY(s->context, s->direct_on_input == PA_INVALID_INDEX || direction == PA_STREAM_RECORD, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY(s->context, !(flags & ~(PA_STREAM_START_CORKED|
PA_STREAM_INTERPOLATE_TIMING|
PA_STREAM_NOT_MONOTONOUS|
@ -954,6 +957,9 @@ static int create_stream(
PA_TAG_BOOLEAN, flags & PA_STREAM_ADJUST_LATENCY,
PA_TAG_PROPLIST, s->proplist,
PA_TAG_INVALID);
if (s->direction == PA_STREAM_RECORD)
pa_tagstruct_putu32(t, s->direct_on_input);
}
pa_pstream_send_tagstruct(s->context->pstream, t);
@ -2227,3 +2233,26 @@ pa_operation *pa_stream_proplist_remove(pa_stream *s, const char *const keys[],
return o;
}
int pa_stream_set_monitor_stream(pa_stream *s, uint32_t sink_input_idx) {
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
PA_CHECK_VALIDITY(s->context, sink_input_idx != PA_INVALID_INDEX, PA_ERR_INVALID);
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_UNCONNECTED, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY(s->context, s->context->version >= 13, PA_ERR_NOTSUPPORTED);
s->direct_on_input = sink_input_idx;
return 0;
}
uint32_t pa_stream_get_monitor_stream(pa_stream *s) {
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->direct_on_input != PA_INVALID_INDEX, PA_ERR_BADSTATE, PA_INVALID_INDEX);
PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->context->version >= 13, PA_ERR_NOTSUPPORTED, PA_INVALID_INDEX);
return s->direct_on_input;
}

View file

@ -527,14 +527,14 @@ const pa_buffer_attr* pa_stream_get_buffer_attr(pa_stream *s);
* server is at least PulseAudio 0.9.8. \since 0.9.8 */
pa_operation *pa_stream_set_buffer_attr(pa_stream *s, const pa_buffer_attr *attr, pa_stream_success_cb_t cb, void *userdata);
/* Change the stream sampling rate during playback. You need to pass
/** Change the stream sampling rate during playback. You need to pass
* PA_STREAM_VARIABLE_RATE in the flags parameter of
* pa_stream_connect() if you plan to use this function. Only valid
* after the stream has been connected successfully and if the server
* is at least PulseAudio 0.9.8. \since 0.9.8 */
pa_operation *pa_stream_update_sample_rate(pa_stream *s, uint32_t rate, pa_stream_success_cb_t cb, void *userdata);
/* Update the property list of the sink input/source output of this
/** Update the property list of the sink input/source output of this
* stream, adding new entries. Please note that it is highly
* recommended to set as much properties initially via
* pa_stream_new_with_proplist() as possible instead a posteriori with
@ -542,10 +542,20 @@ pa_operation *pa_stream_update_sample_rate(pa_stream *s, uint32_t rate, pa_strea
* this stream to the right device. \since 0.9.11 */
pa_operation *pa_stream_proplist_update(pa_stream *s, pa_update_mode_t mode, pa_proplist *p, pa_stream_success_cb_t cb, void *userdata);
/* Update the property list of the sink input/source output of this
/** Update the property list of the sink input/source output of this
* stream, remove entries. \since 0.9.11 */
pa_operation *pa_stream_proplist_remove(pa_stream *s, const char *const keys[], pa_stream_success_cb_t cb, void *userdata);
/** For record streams connected to a monitor source: monitor only a
* very specific sink input of the sink. Thus function needs to be
* called before pa_stream_connect_record() is called. \since
* 0.9.11 */
int pa_stream_set_monitor_stream(pa_stream *s, uint32_t sink_input_idx);
/** Return what has been set with pa_stream_set_monitor_stream()
* ebfore. \since 0.9.11 */
uint32_t pa_stream_get_monitor_stream(pa_stream *s);
PA_C_DECL_END
#endif