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

@ -328,7 +328,7 @@ static int suspend(struct userdata *u) {
u->alsa_rtpoll_item = NULL;
}
pa_log_debug("Device suspended...");
pa_log_info("Device suspended...");
return 0;
}
@ -342,7 +342,7 @@ static int unsuspend(struct userdata *u) {
pa_assert(u);
pa_assert(!u->pcm_handle);
pa_log_debug("Trying resume...");
pa_log_info("Trying resume...");
snd_config_update_free_global();
if ((err = snd_pcm_open(&u->pcm_handle, u->device_name, SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK)) < 0) {
@ -387,7 +387,7 @@ static int unsuspend(struct userdata *u) {
/* FIXME: We need to reload the volume somehow */
pa_log_debug("Resumed successfully...");
pa_log_info("Resumed successfully...");
return 0;
@ -438,7 +438,8 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
break;
case PA_SOURCE_DISCONNECTED:
case PA_SOURCE_UNLINKED:
case PA_SOURCE_INIT:
;
}
@ -590,15 +591,9 @@ static void thread_func(void *userdata) {
snd_pcm_start(u->pcm_handle);
for (;;) {
pa_msgobject *object;
int code;
void *data;
int64_t offset;
pa_memchunk chunk;
int ret;
/* pa_log("loop"); */
/* Render some data and write it to the dsp */
/* Read some data and pass it to the sources */
if (PA_SOURCE_OPENED(u->source->thread_info.state)) {
if (u->use_mmap) {
@ -611,29 +606,25 @@ static void thread_func(void *userdata) {
}
}
/* pa_log("loop2"); */
/* Now give the source outputs some to time to process their data */
if ((ret = pa_source_process_outputs(u->source)) < 0)
goto fail;
if (ret > 0)
continue;
/* Check whether there is a message for us to process */
if (pa_asyncmsgq_get(u->thread_mq.inq, &object, &code, &data, &offset, &chunk, 0) == 0) {
int ret;
/* pa_log("processing msg"); */
if (!object && code == PA_MESSAGE_SHUTDOWN) {
pa_asyncmsgq_done(u->thread_mq.inq, 0);
goto finish;
}
ret = pa_asyncmsgq_dispatch(object, code, data, offset, &chunk);
pa_asyncmsgq_done(u->thread_mq.inq, ret);
if ((ret = pa_thread_mq_process(&u->thread_mq) < 0))
goto finish;
if (ret > 0)
continue;
}
/* Hmm, nothing to do. Let's sleep */
if (pa_rtpoll_run(u->rtpoll) < 0) {
pa_log("poll() failed: %s", pa_cstrerror(errno));
goto fail;
}
/* Tell ALSA about this and process its response */
if (PA_SOURCE_OPENED(u->source->thread_info.state)) {
struct pollfd *pollfd;
unsigned short revents = 0;
@ -657,7 +648,6 @@ static void thread_func(void *userdata) {
goto fail;
}
/* pa_log("got alsa event"); */
}
}
@ -802,6 +792,7 @@ int pa__init(pa_module*m) {
pa_source_set_module(u->source, m);
pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);
pa_source_set_rtpoll(u->source, u->rtpoll);
pa_source_set_description(u->source, t = pa_sprintf_malloc(
"ALSA PCM on %s (%s)%s",
dev,
@ -809,7 +800,7 @@ int pa__init(pa_module*m) {
use_mmap ? " via DMA" : ""));
pa_xfree(t);
u->source->is_hardware = 1;
u->source->flags = PA_SOURCE_HARDWARE|PA_SOURCE_CAN_SUSPEND|PA_SOURCE_LATENCY|PA_SOURCE_HW_VOLUME_CTRL;
u->frame_size = frame_size;
u->fragment_size = frag_size = period_size * frame_size;
@ -863,6 +854,8 @@ int pa__init(pa_module*m) {
if (u->source->get_mute)
u->source->get_mute(u->source);
pa_source_put(u->source);
pa_modargs_free(ma);
return 0;
@ -886,7 +879,7 @@ void pa__done(pa_module*m) {
return;
if (u->source)
pa_source_disconnect(u->source);
pa_source_unlink(u->source);
if (u->thread) {
pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NULL, 0, NULL);