Lots of assorted minor cleanups and fixes:

* s/disconnect/unlink/ at many places where it makes sense
* make "start_corked" a normal pa_sink_input/pa_source_output flag instead of a seperate boolean variable
* add generic process() function to pa_sink_input/pa_source_output vtable that can be used by streams to do some arbitrary processing in each rt loop iteration even the sink/source is suspended
* add detach()/attach() functions to pa_sink_input/pa_source_output vtable that are called when ever the rtpoll object of the event thread changes
* add suspend() functions to pa_sink_input/pa_source_output vtable which are called whenever the sink/source they are attached to suspends/resumes
* add PA_SINK_INIT/PA_SOURCE_INIT/PA_SINK_INPUT_INIT/PA_SINK_OUTPUT_INIT states to state machines which is active between _new() and _put()
* seperate _put() from _new() for pa_sink/pa_source
* add PA_SOURCE_OUTPUT_DONT_MOVE/PA_SINK_INPUT_DONT_MOVE flags
* make the pa_rtpoll object a property of pa_sink/pa_source to allow streams attached to them make use of it
* fix skipping over move_silence
* update module-pipe-source to make use of pa_rtpoll
* add pa_sink_skip() as optimization in cases where the actualy data returned by pa_sink_render() doesn't matter


git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1733 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2007-08-30 22:57:53 +00:00
parent b552541dd1
commit 4d623f0d44
26 changed files with 708 additions and 378 deletions

View file

@ -39,14 +39,21 @@ typedef struct pa_sink_input pa_sink_input;
#include <pulsecore/core.h>
typedef enum pa_sink_input_state {
PA_SINK_INPUT_INIT, /*< The stream is not active yet, because pa_sink_put() has not been called yet */
PA_SINK_INPUT_DRAINED, /*< The stream stopped playing because there was no data to play */
PA_SINK_INPUT_RUNNING, /*< The stream is alive and kicking */
PA_SINK_INPUT_CORKED, /*< The stream was corked on user request */
PA_SINK_INPUT_DISCONNECTED /*< The stream is dead */
PA_SINK_INPUT_UNLINKED /*< The stream is dead */
} pa_sink_input_state_t;
static inline int PA_SINK_INPUT_LINKED(pa_sink_input_state_t x) {
return x == PA_SINK_INPUT_DRAINED || x == PA_SINK_INPUT_RUNNING || x == PA_SINK_INPUT_CORKED;
}
typedef enum pa_sink_input_flags {
PA_SINK_INPUT_VARIABLE_RATE = 1,
PA_SINK_INPUT_DONT_MOVE = 2,
PA_SINK_INPUT_START_CORKED = 4
} pa_sink_input_flags_t;
struct pa_sink_input {
@ -75,11 +82,42 @@ struct pa_sink_input {
pa_cvolume volume;
int muted;
/* Returns the chunk of audio data (but doesn't drop it
* yet!). Returns -1 on failure. Called from IO thread context. */
int (*peek) (pa_sink_input *i, pa_memchunk *chunk);
/* Drops the specified number of bytes, usually called right after
* peek(), but not necessarily. Called from IO thread context. */
void (*drop) (pa_sink_input *i, size_t length);
/* If non-NULL this function is called in each IO event loop and
* can be used to do additional processing even when the device is
* suspended and peek() is never called. Should return 1 when
* "some work" has been done and the IO event loop should be
* reiterated immediately. Called from IO thread context. */
int (*process) (pa_sink_input *i); /* may be NULL */
/* If non-NULL this function is called when the input is first
* connected to a sink. Called from IO thread context */
void (*attach) (pa_sink_input *i); /* may be NULL */
/* If non-NULL this function is called when the output is
* disconnected from its sink. Called from IO thread context */
void (*detach) (pa_sink_input *i); /* may be NULL */
/* If non-NULL called whenever the the sink this input is attached
* to suspends or resumes. Called from main context */
void (*suspend) (pa_sink_input *i, int b); /* may be NULL */
/* Supposed to unlink and destroy this stream. Called from main
* context. */
void (*kill) (pa_sink_input *i); /* may be NULL */
/* Return the current latency (i.e. length of bufferd audio) of
this stream. Called from main context. If NULL a
PA_SINK_INPUT_MESSAGE_GET_LATENCY message is sent to the IO thread
instead. */
pa_usec_t (*get_latency) (pa_sink_input *i); /* may be NULL */
void (*underrun) (pa_sink_input *i); /* may be NULL */
pa_resample_method_t resample_method;
@ -138,7 +176,6 @@ typedef struct pa_sink_input_new_data {
pa_resample_method_t resample_method;
int start_corked;
pa_sink_input *sync_base;
} pa_sink_input_new_data;
@ -156,7 +193,7 @@ pa_sink_input* pa_sink_input_new(
pa_sink_input_flags_t flags);
void pa_sink_input_put(pa_sink_input *i);
void pa_sink_input_disconnect(pa_sink_input* i);
void pa_sink_input_unlink(pa_sink_input* i);
void pa_sink_input_set_name(pa_sink_input *i, const char *name);