[pulseaudio-commits] r1733 - in /branches/lennart/src: modules/ pulsecore/
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Thu Aug 30 15:57:54 PDT 2007
Author: lennart
Date: Fri Aug 31 00:57:53 2007
New Revision: 1733
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1733&root=3Dpulseaudio&vi=
ew=3Drev
Log:
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 t=
hat 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 ar=
e 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 st=
ates 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 stream=
s 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 return=
ed by pa_sink_render() doesn't matter
Modified:
branches/lennart/src/modules/module-alsa-sink.c
branches/lennart/src/modules/module-alsa-source.c
branches/lennart/src/modules/module-null-sink.c
branches/lennart/src/modules/module-oss.c
branches/lennart/src/modules/module-pipe-sink.c
branches/lennart/src/modules/module-pipe-source.c
branches/lennart/src/modules/module-rescue-streams.c
branches/lennart/src/modules/module-sine.c
branches/lennart/src/modules/module-suspend-on-idle.c
branches/lennart/src/pulsecore/cli-text.c
branches/lennart/src/pulsecore/core.c
branches/lennart/src/pulsecore/core.h
branches/lennart/src/pulsecore/play-memblockq.c
branches/lennart/src/pulsecore/play-memchunk.c
branches/lennart/src/pulsecore/protocol-esound.c
branches/lennart/src/pulsecore/protocol-native.c
branches/lennart/src/pulsecore/protocol-simple.c
branches/lennart/src/pulsecore/sink-input.c
branches/lennart/src/pulsecore/sink-input.h
branches/lennart/src/pulsecore/sink.c
branches/lennart/src/pulsecore/sink.h
branches/lennart/src/pulsecore/sound-file-stream.c
branches/lennart/src/pulsecore/source-output.c
branches/lennart/src/pulsecore/source-output.h
branches/lennart/src/pulsecore/source.c
branches/lennart/src/pulsecore/source.h
Modified: branches/lennart/src/modules/module-alsa-sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/mo=
dule-alsa-sink.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Ddi=
ff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/modules/module-alsa-sink.c (original)
+++ branches/lennart/src/modules/module-alsa-sink.c Fri Aug 31 00:57:53 2007
@@ -347,7 +347,7 @@
u->alsa_rtpoll_item =3D NULL;
}
=
- pa_log_debug("Device suspended...");
+ pa_log_info("Device suspended...");
=
return 0;
}
@@ -361,7 +361,7 @@
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 =3D snd_pcm_open(&u->pcm_handle, u->device_name, SND_PCM_STRE=
AM_PLAYBACK, SND_PCM_NONBLOCK)) < 0) {
@@ -406,7 +406,7 @@
=
u->first =3D 1;
=
- pa_log_debug("Resumed successfully...");
+ pa_log_info("Resumed successfully...");
=
return 0;
=
@@ -457,7 +457,8 @@
=
break;
=
- case PA_SINK_DISCONNECTED:
+ case PA_SINK_UNLINKED:
+ case PA_SINK_INIT:
;
}
=
@@ -607,13 +608,7 @@
goto fail;
=
for (;;) {
- pa_msgobject *object;
- int code;
- void *data;
- pa_memchunk chunk;
- int64_t offset;
-
-/* pa_log("loop"); */
+ int ret;
=
/* Render some data and write it to the dsp */
if (PA_SINK_OPENED(u->sink->thread_info.state)) {
@@ -635,28 +630,25 @@
}
}
=
-/* pa_log("loop2"); */
+ /* Now give the sink inputs some to time to process their data */
+ if ((ret =3D pa_sink_process_inputs(u->sink)) < 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, &off=
set, &chunk, 0) =3D=3D 0) {
- int ret;
-
- if (!object && code =3D=3D PA_MESSAGE_SHUTDOWN) {
- pa_asyncmsgq_done(u->thread_mq.inq, 0);
- goto finish;
- }
-
- ret =3D pa_asyncmsgq_dispatch(object, code, data, offset, &chu=
nk);
- pa_asyncmsgq_done(u->thread_mq.inq, ret);
+ if ((ret =3D 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_SINK_OPENED(u->sink->thread_info.state)) {
struct pollfd *pollfd;
unsigned short revents =3D 0;
@@ -680,9 +672,7 @@
=
goto fail;
}
-/* pa_log("got alsa event"); */
- }
- =
+ }
}
=
fail:
@@ -828,6 +818,7 @@
=
pa_sink_set_module(u->sink, m);
pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
+ pa_sink_set_rtpoll(u->sink, u->rtpoll);
pa_sink_set_description(u->sink, t =3D pa_sprintf_malloc(
"ALSA PCM on %s (%s)%s",
dev,
@@ -835,7 +826,7 @@
use_mmap ? " via DMA" : ""));
pa_xfree(t);
=
- u->sink->is_hardware =3D 1;
+ u->sink->flags =3D PA_SINK_HARDWARE|PA_SINK_CAN_SUSPEND|PA_SINK_HW_VOL=
UME_CTRL|PA_SINK_LATENCY;
=
u->frame_size =3D frame_size;
u->fragment_size =3D frag_size =3D period_size * frame_size;
@@ -894,6 +885,8 @@
if (u->sink->get_mute)
u->sink->get_mute(u->sink);
=
+ pa_sink_put(u->sink);
+ =
pa_modargs_free(ma);
=
return 0;
@@ -917,7 +910,7 @@
return;
=
if (u->sink)
- pa_sink_disconnect(u->sink);
+ pa_sink_unlink(u->sink);
=
if (u->thread) {
pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NUL=
L, 0, NULL);
Modified: branches/lennart/src/modules/module-alsa-source.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/mo=
dule-alsa-source.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3D=
diff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/modules/module-alsa-source.c (original)
+++ branches/lennart/src/modules/module-alsa-source.c Fri Aug 31 00:57:53 2=
007
@@ -328,7 +328,7 @@
u->alsa_rtpoll_item =3D NULL;
}
=
- pa_log_debug("Device suspended...");
+ pa_log_info("Device suspended...");
=
return 0;
}
@@ -342,7 +342,7 @@
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 =3D snd_pcm_open(&u->pcm_handle, u->device_name, SND_PCM_STRE=
AM_CAPTURE, SND_PCM_NONBLOCK)) < 0) {
@@ -387,7 +387,7 @@
=
/* FIXME: We need to reload the volume somehow */
=
- pa_log_debug("Resumed successfully...");
+ pa_log_info("Resumed successfully...");
=
return 0;
=
@@ -438,7 +438,8 @@
=
break;
=
- case PA_SOURCE_DISCONNECTED:
+ case PA_SOURCE_UNLINKED:
+ case PA_SOURCE_INIT:
;
}
=
@@ -590,15 +591,9 @@
snd_pcm_start(u->pcm_handle);
=
for (;;) {
- pa_msgobject *object;
- int code;
- void *data;
- int64_t offset;
- pa_memchunk chunk;
-
-/* pa_log("loop"); */
- =
- /* Render some data and write it to the dsp */
+ int ret;
+
+ /* 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 @@
}
}
=
-/* pa_log("loop2"); */
+ /* Now give the source outputs some to time to process their data =
*/
+ if ((ret =3D 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, &off=
set, &chunk, 0) =3D=3D 0) {
- int ret;
-
-/* pa_log("processing msg"); */
-
- if (!object && code =3D=3D PA_MESSAGE_SHUTDOWN) {
- pa_asyncmsgq_done(u->thread_mq.inq, 0);
- goto finish;
- }
-
- ret =3D pa_asyncmsgq_dispatch(object, code, data, offset, &chu=
nk);
- pa_asyncmsgq_done(u->thread_mq.inq, ret);
+ if ((ret =3D 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 =3D 0;
@@ -657,7 +648,6 @@
=
goto fail;
}
-/* pa_log("got alsa event"); */
}
}
=
@@ -802,6 +792,7 @@
=
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 =3D pa_sprintf_malloc(
"ALSA PCM on %s (%s)%s",
dev,
@@ -809,7 +800,7 @@
use_mmap ? " via DMA" : ""));
pa_xfree(t);
=
- u->source->is_hardware =3D 1;
+ u->source->flags =3D PA_SOURCE_HARDWARE|PA_SOURCE_CAN_SUSPEND|PA_SOURC=
E_LATENCY|PA_SOURCE_HW_VOLUME_CTRL;
=
u->frame_size =3D frame_size;
u->fragment_size =3D frag_size =3D period_size * frame_size;
@@ -863,6 +854,8 @@
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 @@
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, NUL=
L, 0, NULL);
Modified: branches/lennart/src/modules/module-null-sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/mo=
dule-null-sink.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Ddi=
ff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/modules/module-null-sink.c (original)
+++ branches/lennart/src/modules/module-null-sink.c Fri Aug 31 00:57:53 2007
@@ -128,11 +128,7 @@
pa_rtclock_get(&u->timestamp);
=
for (;;) {
- pa_msgobject *object;
- int code;
- void *data;
- pa_memchunk chunk;
- int64_t offset;
+ int ret;
=
/* Render some data and drop it immediately */
if (u->sink->thread_info.state =3D=3D PA_SINK_RUNNING) {
@@ -141,30 +137,25 @@
pa_rtclock_get(&now);
=
if (pa_timespec_cmp(&u->timestamp, &now) <=3D 0) {
-
- pa_sink_render(u->sink, u->block_size, &chunk);
- pa_memblock_unref(chunk.memblock);
-
- pa_timespec_add(&u->timestamp, pa_bytes_to_usec(chunk.leng=
th, &u->sink->sample_spec));
+ pa_sink_skip(u->sink, u->block_size);
+ pa_timespec_add(&u->timestamp, pa_bytes_to_usec(u->block_s=
ize, &u->sink->sample_spec));
}
=
pa_rtpoll_set_timer_absolute(u->rtpoll, &u->timestamp);
} else
pa_rtpoll_set_timer_disabled(u->rtpoll);
=
+ /* Now give the sink inputs some to time to process their data */
+ if ((ret =3D pa_sink_process_inputs(u->sink)) < 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, &off=
set, &chunk, 0) =3D=3D 0) {
- int ret;
-
- if (!object && code =3D=3D PA_MESSAGE_SHUTDOWN) {
- pa_asyncmsgq_done(u->thread_mq.inq, 0);
- goto finish;
- }
-
- ret =3D pa_asyncmsgq_dispatch(object, code, data, offset, &chu=
nk);
- pa_asyncmsgq_done(u->thread_mq.inq, ret);
+ if ((ret =3D 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) {
@@ -217,9 +208,11 @@
=
u->sink->parent.process_msg =3D sink_process_msg;
u->sink->userdata =3D u;
+ u->sink->flags =3D PA_SINK_LATENCY;
=
pa_sink_set_module(u->sink, m);
pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
+ pa_sink_set_rtpoll(u->sink, u->rtpoll);
pa_sink_set_description(u->sink, pa_modargs_get_value(ma, "description=
", "NULL sink"));
=
u->block_size =3D pa_bytes_per_second(&ss) / 20; /* 50 ms */
@@ -231,6 +224,8 @@
goto fail;
}
=
+ pa_sink_put(u->sink);
+ =
pa_modargs_free(ma);
=
return 0;
@@ -253,7 +248,7 @@
return;
=
if (u->sink)
- pa_sink_disconnect(u->sink);
+ pa_sink_unlink(u->sink);
=
if (u->thread) {
pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NUL=
L, 0, NULL);
Modified: branches/lennart/src/modules/module-oss.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/mo=
dule-oss.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/modules/module-oss.c (original)
+++ branches/lennart/src/modules/module-oss.c Fri Aug 31 00:57:53 2007
@@ -443,7 +443,7 @@
pa_assert(u);
pa_assert(u->fd >=3D 0);
=
- pa_log_debug("Suspending...");
+ pa_log_info("Suspending...");
=
if (u->out_mmap_memblocks) {
unsigned i;
@@ -483,7 +483,7 @@
u->rtpoll_item =3D NULL;
}
=
- pa_log_debug("Device suspended...");
+ pa_log_info("Device suspended...");
=
return 0;
}
@@ -501,7 +501,7 @@
=
m =3D u->mode;
=
- pa_log_debug("Trying resume...");
+ pa_log_info("Trying resume...");
=
if ((u->fd =3D pa_oss_open(u->device_name, &m, NULL)) < 0) {
pa_log_warn("Resume failed, device busy (%s)", pa_cstrerror(errno)=
);
@@ -582,7 +582,7 @@
pollfd->events =3D 0;
pollfd->revents =3D 0;
=
- pa_log_debug("Resumed successfully...");
+ pa_log_info("Resumed successfully...");
=
return 0;
=
@@ -651,7 +651,8 @@
=
break;
=
- case PA_SINK_DISCONNECTED:
+ case PA_SINK_UNLINKED:
+ case PA_SINK_INIT:
;
}
=
@@ -748,7 +749,8 @@
}
break;
=
- case PA_SOURCE_DISCONNECTED:
+ case PA_SOURCE_UNLINKED:
+ case PA_SOURCE_INIT:
;
=
}
@@ -807,20 +809,15 @@
trigger(u, 0);
=
for (;;) {
- pa_msgobject *object;
- int code;
- void *data;
- pa_memchunk chunk;
- int64_t offset;
+ int ret;
=
/* pa_log("loop"); */
=
/* Render some data and write it to the dsp */
=
- if (u->sink && u->sink->thread_info.state !=3D PA_SINK_DISCONNECTE=
D && u->fd >=3D 0 && (revents & POLLOUT)) {
+ if (u->sink && u->sink->thread_info.state !=3D PA_SINK_UNLINKED &&=
u->fd >=3D 0 && (revents & POLLOUT)) {
=
if (u->use_mmap) {
- int ret;
=
if ((ret =3D mmap_write(u)) < 0)
goto fail;
@@ -908,10 +905,9 @@
=
/* Try to read some data and pass it on to the source driver */
=
- if (u->source && u->source->thread_info.state !=3D PA_SOURCE_DISCO=
NNECTED && u->fd >=3D 0 && ((revents & POLLIN))) {
+ if (u->source && u->source->thread_info.state !=3D PA_SOURCE_UNLIN=
KED && u->fd >=3D 0 && ((revents & POLLIN))) {
=
if (u->use_mmap) {
- int ret;
=
if ((ret =3D mmap_read(u)) < 0)
goto fail;
@@ -995,21 +991,23 @@
=
/* pa_log("loop2"); */
=
+ /* Now give the sink inputs some to time to process their data */
+ if ((ret =3D pa_sink_process_inputs(u->sink)) < 0)
+ goto fail;
+ if (ret > 0)
+ continue;
+
+ /* Now give the source outputs some to time to process their data =
*/
+ if ((ret =3D 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, &off=
set, &chunk, 0) =3D=3D 0) {
- int ret;
-
-/* pa_log("processing msg"); */
-
- if (!object && code =3D=3D PA_MESSAGE_SHUTDOWN) {
- pa_asyncmsgq_done(u->thread_mq.inq, 0);
- goto finish;
- }
-
- ret =3D pa_asyncmsgq_dispatch(object, code, data, offset, &chu=
nk);
- pa_asyncmsgq_done(u->thread_mq.inq, ret);
+ if ((ret =3D pa_thread_mq_process(&u->thread_mq) < 0))
+ goto finish;
+ if (ret > 0)
continue;
- } =
=
if (u->fd >=3D 0) {
struct pollfd *pollfd;
@@ -1019,7 +1017,6 @@
((u->source && PA_SOURCE_OPENED(u->source->thread_info.sta=
te)) ? POLLIN : 0) |
((u->sink && PA_SINK_OPENED(u->sink->thread_info.state)) ?=
POLLOUT : 0);
}
-
=
/* Hmm, nothing to do. Let's sleep */
if (pa_rtpoll_run(u->rtpoll) < 0) {
@@ -1212,6 +1209,7 @@
=
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 =3D pa_sprintf_malloc(
"OSS PCM on %s%s%s%s%s",
dev,
@@ -1220,7 +1218,7 @@
hwdesc[0] ? ")" : "",
use_mmap ? " via DMA" : ""));
pa_xfree(t);
- u->source->is_hardware =3D 1;
+ u->source->flags =3D PA_SOURCE_HARDWARE|PA_SOURCE_CAN_SUSPEND|PA_S=
OURCE_LATENCY|PA_SOURCE_HW_VOLUME_CTRL;
u->source->refresh_volume =3D 1;
=
if (use_mmap)
@@ -1266,6 +1264,7 @@
=
pa_sink_set_module(u->sink, m);
pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
+ pa_sink_set_rtpoll(u->sink, u->rtpoll);
pa_sink_set_description(u->sink, t =3D pa_sprintf_malloc(
"OSS PCM on %s%s%s%s%s",
dev,
@@ -1274,7 +1273,7 @@
hwdesc[0] ? ")" : "",
use_mmap ? " via DMA" : ""));
pa_xfree(t);
- u->sink->is_hardware =3D 1;
+ u->sink->flags =3D PA_SINK_HARDWARE|PA_SINK_CAN_SUSPEND|PA_SINK_LA=
TENCY|PA_SINK_HW_VOLUME_CTRL;
u->sink->refresh_volume =3D 1;
=
if (use_mmap)
@@ -1298,6 +1297,11 @@
if (u->sink)
pa_asyncmsgq_post(u->thread_mq.inq, PA_MSGOBJECT(u->sink), PA_SINK=
_MESSAGE_GET_VOLUME, &u->sink->volume, 0, NULL, NULL);
=
+ if (u->sink)
+ pa_sink_put(u->sink);
+ if (u->source)
+ pa_source_put(u->source);
+ =
pa_modargs_free(ma);
=
return 0;
@@ -1324,10 +1328,10 @@
return;
=
if (u->sink)
- pa_sink_disconnect(u->sink);
+ pa_sink_unlink(u->sink);
=
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, NUL=
L, 0, NULL);
Modified: branches/lennart/src/modules/module-pipe-sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/mo=
dule-pipe-sink.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Ddi=
ff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/modules/module-pipe-sink.c (original)
+++ branches/lennart/src/modules/module-pipe-sink.c Fri Aug 31 00:57:53 2007
@@ -124,17 +124,12 @@
pa_rtpoll_install(u->rtpoll);
=
for (;;) {
- pa_msgobject *object;
- int code;
- void *data;
- pa_memchunk chunk;
- int64_t offset;
+ int ret;
struct pollfd *pollfd;
=
+ pollfd =3D pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
+
/* Render some data and write it to the fifo */
-
- pollfd =3D pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
- =
if (u->sink->thread_info.state =3D=3D PA_SINK_RUNNING && pollfd->r=
events) {
ssize_t l;
void *p;
@@ -173,19 +168,17 @@
}
}
=
+ /* Now give the sink inputs some to time to process their data */
+ if ((ret =3D pa_sink_process_inputs(u->sink)) < 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, &off=
set, &chunk, 0) =3D=3D 0) {
- int ret;
-
- if (!object && code =3D=3D PA_MESSAGE_SHUTDOWN) {
- pa_asyncmsgq_done(u->thread_mq.inq, 0);
- goto finish;
- }
-
- ret =3D pa_asyncmsgq_dispatch(object, code, data, offset, &chu=
nk);
- pa_asyncmsgq_done(u->thread_mq.inq, ret);
+ if ((ret =3D pa_thread_mq_process(&u->thread_mq) < 0))
+ goto finish;
+ if (ret > 0)
continue;
- }
=
/* Hmm, nothing to do. Let's sleep */
pollfd->events =3D u->sink->thread_info.state =3D=3D PA_SINK_RUNNI=
NG ? POLLOUT : 0;
@@ -271,9 +264,11 @@
=
u->sink->parent.process_msg =3D sink_process_msg;
u->sink->userdata =3D u;
+ u->sink->flags =3D PA_SINK_LATENCY;
=
pa_sink_set_module(u->sink, m);
pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
+ pa_sink_set_rtpoll(u->sink, u->rtpoll);
pa_sink_set_description(u->sink, t =3D pa_sprintf_malloc("Unix FIFO si=
nk '%s'", u->filename));
pa_xfree(t);
=
@@ -281,11 +276,13 @@
pollfd =3D pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
pollfd->fd =3D u->fd;
pollfd->events =3D pollfd->revents =3D 0;
- =
+
if (!(u->thread =3D pa_thread_new(thread_func, u))) {
pa_log("Failed to create thread.");
goto fail;
}
+
+ pa_sink_put(u->sink);
=
pa_modargs_free(ma);
=
@@ -309,7 +306,7 @@
return;
=
if (u->sink)
- pa_sink_disconnect(u->sink);
+ pa_sink_unlink(u->sink);
=
if (u->thread) {
pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NUL=
L, 0, NULL);
Modified: branches/lennart/src/modules/module-pipe-source.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/mo=
dule-pipe-source.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3D=
diff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/modules/module-pipe-source.c (original)
+++ branches/lennart/src/modules/module-pipe-source.c Fri Aug 31 00:57:53 2=
007
@@ -45,6 +45,7 @@
#include <pulsecore/log.h>
#include <pulsecore/thread.h>
#include <pulsecore/thread-mq.h>
+#include <pulsecore/rtpoll.h>
=
#include "module-pipe-source-symdef.h"
=
@@ -66,13 +67,17 @@
pa_core *core;
pa_module *module;
pa_source *source;
+
pa_thread *thread;
pa_thread_mq thread_mq;
- =
+ pa_rtpoll *rtpoll;
+
char *filename;
int fd;
=
pa_memchunk memchunk;
+
+ pa_rtpoll_item *rtpoll_item;
};
=
static const char* const valid_modargs[] =3D {
@@ -86,14 +91,7 @@
};
=
static void thread_func(void *userdata) {
- enum {
- POLLFD_ASYNCQ,
- POLLFD_FIFO,
- POLLFD_MAX,
- };
- =
struct userdata *u =3D userdata;
- struct pollfd pollfd[POLLFD_MAX];
int read_type =3D 0;
=
pa_assert(u);
@@ -101,40 +99,18 @@
pa_log_debug("Thread starting up");
=
pa_thread_mq_install(&u->thread_mq);
-
- memset(&pollfd, 0, sizeof(pollfd));
- =
- pollfd[POLLFD_ASYNCQ].fd =3D pa_asyncmsgq_get_fd(u->thread_mq.inq);
- pollfd[POLLFD_ASYNCQ].events =3D POLLIN;
- pollfd[POLLFD_FIFO].fd =3D u->fd;
-
+ pa_rtpoll_install(u->rtpoll);
+ =
for (;;) {
- pa_msgobject *object;
- int code;
- void *data;
- pa_memchunk chunk;
- int r;
- int64_t offset;
-
- /* Check whether there is a message for us to process */
- if (pa_asyncmsgq_get(u->thread_mq.inq, &object, &code, &data, &off=
set, &chunk, 0) =3D=3D 0) {
- int ret;
-
- if (!object && code =3D=3D PA_MESSAGE_SHUTDOWN) {
- pa_asyncmsgq_done(u->thread_mq.inq, 0);
- goto finish;
- }
-
- ret =3D pa_asyncmsgq_dispatch(object, code, data, offset, &chu=
nk);
- pa_asyncmsgq_done(u->thread_mq.inq, ret);
- continue;
- }
-
+ int ret;
+ struct pollfd *pollfd;
+
+ pollfd =3D pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
+ =
/* Try to read some data and pass it on to the source driver */
-
- if (u->source->thread_info.state =3D=3D PA_SOURCE_RUNNING && pollf=
d[POLLFD_FIFO].revents) {
+ if (u->source->thread_info.state =3D=3D PA_SOURCE_RUNNING && pollf=
d->revents) {
+ ssize_t l;
void *p;
- ssize_t l;
=
if (!u->memchunk.memblock) {
u->memchunk.memblock =3D pa_memblock_new(u->core->mempool,=
PIPE_BUF);
@@ -169,38 +145,35 @@
pa_memchunk_reset(&u->memchunk);
}
=
- pollfd[POLLFD_FIFO].revents =3D 0;
- continue;
+ pollfd->revents =3D 0;
}
}
=
- pollfd[POLLFD_FIFO].events =3D u->source->thread_info.state =3D=3D=
PA_SOURCE_RUNNING ? POLLIN : 0;
+ /* Now give the source outputs some to time to process their data =
*/
+ if ((ret =3D pa_source_process_outputs(u->source)) < 0)
+ goto fail;
+ if (ret > 0)
+ continue;
+
+ /* Check whether there is a message for us to process */
+ if ((ret =3D pa_thread_mq_process(&u->thread_mq) < 0))
+ goto finish;
+ if (ret > 0)
+ continue;
=
/* Hmm, nothing to do. Let's sleep */
-
- if (pa_asyncmsgq_before_poll(u->thread_mq.inq) < 0)
- continue;
-
-/* pa_log("polling for %i", pollfd[POLLFD_FIFO].events); */
- r =3D poll(pollfd, POLLFD_MAX, -1);
-/* pa_log("polling got %i (r=3D%i) %i", r > 0 ? pollfd[POLLFD_FIFO=
].revents : 0, r, r > 0 ? pollfd[POLLFD_ASYNCQ].revents: 0); */
-
- pa_asyncmsgq_after_poll(u->thread_mq.inq);
-
- if (r < 0) {
- if (errno =3D=3D EINTR)
- continue;
-
+ pollfd->events =3D u->source->thread_info.state =3D=3D PA_SOURCE_R=
UNNING ? POLLIN : 0;
+
+ if (pa_rtpoll_run(u->rtpoll) < 0) {
pa_log("poll() failed: %s", pa_cstrerror(errno));
goto fail;
}
=
- if (pollfd[POLLFD_FIFO].revents & ~POLLIN) {
+ pollfd =3D pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
+ if (pollfd->revents & ~POLLIN) {
pa_log("FIFO shutdown.");
goto fail;
}
-
- pa_assert((pollfd[POLLFD_ASYNCQ].revents & ~POLLIN) =3D=3D 0);
}
=
fail:
@@ -220,6 +193,7 @@
pa_channel_map map;
pa_modargs *ma;
char *t;
+ struct pollfd *pollfd;
=
pa_assert(m);
=
@@ -240,6 +214,8 @@
m->userdata =3D u;
pa_memchunk_reset(&u->memchunk);
pa_thread_mq_init(&u->thread_mq, m->core->mainloop);
+ u->rtpoll =3D pa_rtpoll_new();
+ pa_rtpoll_item_new_asyncmsgq(u->rtpoll, u->thread_mq.inq);
=
u->filename =3D pa_xstrdup(pa_modargs_get_value(ma, "file", DEFAULT_FI=
LE_NAME));
=
@@ -268,16 +244,25 @@
}
=
u->source->userdata =3D u;
+ u->source->flags =3D 0;
=
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 =3D pa_sprintf_malloc("Unix FIF=
O source '%s'", u->filename));
pa_xfree(t);
=
+ u->rtpoll_item =3D pa_rtpoll_item_new(u->rtpoll, 1);
+ pollfd =3D pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
+ pollfd->fd =3D u->fd;
+ pollfd->events =3D pollfd->revents =3D 0;
+ =
if (!(u->thread =3D pa_thread_new(thread_func, u))) {
pa_log("Failed to create thread.");
goto fail;
}
+
+ pa_source_put(u->source);
=
pa_modargs_free(ma);
=
@@ -301,7 +286,7 @@
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, NUL=
L, 0, NULL);
@@ -316,6 +301,12 @@
if (u->memchunk.memblock)
pa_memblock_unref(u->memchunk.memblock);
=
+ if (u->rtpoll_item)
+ pa_rtpoll_item_free(u->rtpoll_item);
+ =
+ if (u->rtpoll)
+ pa_rtpoll_free(u->rtpoll);
+ =
if (u->filename) {
unlink(u->filename);
pa_xfree(u->filename);
Modified: branches/lennart/src/modules/module-rescue-streams.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/mo=
dule-rescue-streams.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=
=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/modules/module-rescue-streams.c (original)
+++ branches/lennart/src/modules/module-rescue-streams.c Fri Aug 31 00:57:5=
3 2007
@@ -138,8 +138,8 @@
}
=
m->userdata =3D u =3D pa_xnew(struct userdata, 1);
- u->sink_slot =3D pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_DIS=
CONNECT], (pa_hook_cb_t) sink_hook_callback, NULL);
- u->source_slot =3D pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE=
_DISCONNECT], (pa_hook_cb_t) source_hook_callback, NULL);
+ u->sink_slot =3D pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_UNL=
INK], (pa_hook_cb_t) sink_hook_callback, NULL);
+ u->source_slot =3D pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE=
_UNLINK], (pa_hook_cb_t) source_hook_callback, NULL);
=
pa_modargs_free(ma);
return 0;
Modified: branches/lennart/src/modules/module-sine.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/mo=
dule-sine.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/modules/module-sine.c (original)
+++ branches/lennart/src/modules/module-sine.c Fri Aug 31 00:57:53 2007
@@ -98,7 +98,7 @@
u =3D i->userdata;
pa_assert(u);
=
- pa_sink_input_disconnect(u->sink_input);
+ pa_sink_input_unlink(u->sink_input);
pa_sink_input_unref(u->sink_input);
u->sink_input =3D NULL;
=
@@ -195,7 +195,7 @@
return;
=
if (u->sink_input) {
- pa_sink_input_disconnect(u->sink_input);
+ pa_sink_input_unlink(u->sink_input);
pa_sink_input_unref(u->sink_input);
}
=
Modified: branches/lennart/src/modules/module-suspend-on-idle.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/mo=
dule-suspend-on-idle.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&vie=
w=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/modules/module-suspend-on-idle.c (original)
+++ branches/lennart/src/modules/module-suspend-on-idle.c Fri Aug 31 00:57:=
53 2007
@@ -53,16 +53,16 @@
pa_hook_slot
*sink_new_slot,
*source_new_slot,
- *sink_disconnect_slot,
- *source_disconnect_slot,
+ *sink_unlink_slot,
+ *source_unlink_slot,
*sink_state_changed_slot,
*source_state_changed_slot;
=
pa_hook_slot
*sink_input_new_slot,
*source_output_new_slot,
- *sink_input_disconnect_slot,
- *source_output_disconnect_slot,
+ *sink_input_unlink_slot,
+ *source_output_unlink_slot,
*sink_input_move_slot,
*source_output_move_slot,
*sink_input_move_post_slot,
@@ -139,8 +139,8 @@
pa_sink_input_assert_ref(s);
pa_assert(u);
=
- pa_assert_se((d =3D pa_hashmap_get(u->device_infos, s->sink)));
- resume(d);
+ if ((d =3D pa_hashmap_get(u->device_infos, s->sink)))
+ resume(d);
=
return PA_HOOK_OK;
}
@@ -152,35 +152,35 @@
pa_source_output_assert_ref(s);
pa_assert(u);
=
- pa_assert_se((d =3D pa_hashmap_get(u->device_infos, s->source)));
- resume(d);
- =
- return PA_HOOK_OK;
-}
-
-static pa_hook_result_t sink_input_disconnect_hook_cb(pa_core *c, pa_sink_=
input *s, struct userdata *u) {
+ if ((d =3D pa_hashmap_get(u->device_infos, s->source)))
+ resume(d);
+ =
+ return PA_HOOK_OK;
+}
+
+static pa_hook_result_t sink_input_unlink_hook_cb(pa_core *c, pa_sink_inpu=
t *s, struct userdata *u) {
pa_assert(c);
pa_sink_input_assert_ref(s);
pa_assert(u);
=
if (pa_sink_used_by(s->sink) <=3D 0) {
struct device_info *d;
- pa_assert_se((d =3D pa_hashmap_get(u->device_infos, s->sink)));
- restart(d);
- }
- =
- return PA_HOOK_OK;
-}
-
-static pa_hook_result_t source_output_disconnect_hook_cb(pa_core *c, pa_so=
urce_output *s, struct userdata *u) {
+ if ((d =3D pa_hashmap_get(u->device_infos, s->sink)))
+ restart(d);
+ }
+ =
+ return PA_HOOK_OK;
+}
+
+static pa_hook_result_t source_output_unlink_hook_cb(pa_core *c, pa_source=
_output *s, struct userdata *u) {
pa_assert(c);
pa_source_output_assert_ref(s);
pa_assert(u);
=
if (pa_source_used_by(s->source) <=3D 0) {
struct device_info *d;
- pa_assert_se((d =3D pa_hashmap_get(u->device_infos, s->source)));
- restart(d);
+ if ((d =3D pa_hashmap_get(u->device_infos, s->source)))
+ restart(d);
}
=
return PA_HOOK_OK;
@@ -193,8 +193,8 @@
=
if (pa_sink_used_by(s->sink) <=3D 1) {
struct device_info *d;
- pa_assert_se((d =3D pa_hashmap_get(u->device_infos, s->sink)));
- restart(d);
+ if ((d =3D pa_hashmap_get(u->device_infos, s->sink)))
+ restart(d);
}
=
return PA_HOOK_OK;
@@ -206,8 +206,8 @@
pa_sink_input_assert_ref(s);
pa_assert(u);
=
- pa_assert_se((d =3D pa_hashmap_get(u->device_infos, s->sink)));
- resume(d);
+ if ((d =3D pa_hashmap_get(u->device_infos, s->sink)))
+ resume(d);
=
return PA_HOOK_OK;
}
@@ -219,8 +219,9 @@
=
if (pa_source_used_by(s->source) <=3D 1) {
struct device_info *d;
- pa_assert_se((d =3D pa_hashmap_get(u->device_infos, s->source)));
- restart(d);
+
+ if ((d =3D pa_hashmap_get(u->device_infos, s->source)))
+ restart(d);
}
=
return PA_HOOK_OK;
@@ -232,24 +233,36 @@
pa_source_output_assert_ref(s);
pa_assert(u);
=
- pa_assert_se((d =3D pa_hashmap_get(u->device_infos, s->source)));
- resume(d);
+ if ((d =3D pa_hashmap_get(u->device_infos, s->source)))
+ resume(d);
=
return PA_HOOK_OK;
}
=
static pa_hook_result_t device_new_hook_cb(pa_core *c, pa_object *o, struc=
t userdata *u) {
struct device_info *d;
+ pa_source *source;
+ pa_sink *sink;
=
pa_assert(c);
pa_object_assert_ref(o);
pa_assert(u);
+
+ source =3D pa_source_isinstance(o) ? PA_SOURCE(o) : NULL;
+ sink =3D pa_sink_isinstance(o) ? PA_SINK(o) : NULL;
+
+ pa_assert(source || sink);
+ =
+ if (source && !(source->flags & PA_SOURCE_CAN_SUSPEND))
+ return PA_HOOK_OK;
+
+ if (sink && !(sink->flags & PA_SINK_CAN_SUSPEND))
+ return PA_HOOK_OK;
=
d =3D pa_xnew(struct device_info, 1);
d->userdata =3D u;
- d->source =3D pa_source_isinstance(o) ? pa_source_ref(PA_SOURCE(o)) : =
NULL;
- d->sink =3D pa_sink_isinstance(o) ? pa_sink_ref(PA_SINK(o)) : NULL;
- pa_assert(d->source || d->sink);
+ d->source =3D source ? pa_source_ref(source) : NULL;
+ d->sink =3D sink ? pa_sink_ref(sink) : NULL;
d->time_event =3D c->mainloop->time_new(c->mainloop, NULL, timeout_cb,=
d);
pa_hashmap_put(u->device_infos, o, d);
=
@@ -273,15 +286,15 @@
pa_xfree(d);
}
=
-static pa_hook_result_t device_disconnect_hook_cb(pa_core *c, pa_object *o=
, struct userdata *u) {
+static pa_hook_result_t device_unlink_hook_cb(pa_core *c, pa_object *o, st=
ruct userdata *u) {
struct device_info *d;
=
pa_assert(c);
pa_object_assert_ref(o);
pa_assert(u);
=
- pa_assert_se((d =3D pa_hashmap_remove(u->device_infos, o)));
- device_info_free(d);
+ if ((d =3D pa_hashmap_remove(u->device_infos, o)))
+ device_info_free(d);
=
return PA_HOOK_OK;
}
@@ -353,15 +366,15 @@
=
u->sink_new_slot =3D pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK=
_NEW_POST], (pa_hook_cb_t) device_new_hook_cb, u);
u->source_new_slot =3D pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SO=
URCE_NEW_POST], (pa_hook_cb_t) device_new_hook_cb, u);
- u->sink_disconnect_slot =3D pa_hook_connect(&m->core->hooks[PA_CORE_HO=
OK_SINK_DISCONNECT_POST], (pa_hook_cb_t) device_disconnect_hook_cb, u);
- u->source_disconnect_slot =3D pa_hook_connect(&m->core->hooks[PA_CORE_=
HOOK_SOURCE_DISCONNECT_POST], (pa_hook_cb_t) device_disconnect_hook_cb, u);
+ u->sink_unlink_slot =3D pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_S=
INK_UNLINK_POST], (pa_hook_cb_t) device_unlink_hook_cb, u);
+ u->source_unlink_slot =3D pa_hook_connect(&m->core->hooks[PA_CORE_HOOK=
_SOURCE_UNLINK_POST], (pa_hook_cb_t) device_unlink_hook_cb, u);
u->sink_state_changed_slot =3D pa_hook_connect(&m->core->hooks[PA_CORE=
_HOOK_SINK_STATE_CHANGED], (pa_hook_cb_t) device_state_changed_hook_cb, u);
u->source_state_changed_slot =3D pa_hook_connect(&m->core->hooks[PA_CO=
RE_HOOK_SOURCE_STATE_CHANGED], (pa_hook_cb_t) device_state_changed_hook_cb,=
u);
=
u->sink_input_new_slot =3D pa_hook_connect(&m->core->hooks[PA_CORE_HOO=
K_SINK_INPUT_PUT], (pa_hook_cb_t) sink_input_new_hook_cb, u);
u->source_output_new_slot =3D pa_hook_connect(&m->core->hooks[PA_CORE_=
HOOK_SOURCE_OUTPUT_PUT], (pa_hook_cb_t) source_output_new_hook_cb, u);
- u->sink_input_disconnect_slot =3D pa_hook_connect(&m->core->hooks[PA_C=
ORE_HOOK_SINK_INPUT_DISCONNECT_POST], (pa_hook_cb_t) sink_input_disconnect_=
hook_cb, u);
- u->source_output_disconnect_slot =3D pa_hook_connect(&m->core->hooks[P=
A_CORE_HOOK_SOURCE_OUTPUT_DISCONNECT_POST], (pa_hook_cb_t) source_output_di=
sconnect_hook_cb, u);
+ u->sink_input_unlink_slot =3D pa_hook_connect(&m->core->hooks[PA_CORE_=
HOOK_SINK_INPUT_UNLINK_POST], (pa_hook_cb_t) sink_input_unlink_hook_cb, u);
+ u->source_output_unlink_slot =3D pa_hook_connect(&m->core->hooks[PA_CO=
RE_HOOK_SOURCE_OUTPUT_UNLINK_POST], (pa_hook_cb_t) source_output_unlink_hoo=
k_cb, u);
u->sink_input_move_slot =3D pa_hook_connect(&m->core->hooks[PA_CORE_HO=
OK_SINK_INPUT_MOVE], (pa_hook_cb_t) sink_input_move_hook_cb, u);
u->source_output_move_slot =3D pa_hook_connect(&m->core->hooks[PA_CORE=
_HOOK_SOURCE_OUTPUT_MOVE], (pa_hook_cb_t) source_output_move_hook_cb, u);
u->sink_input_move_post_slot =3D pa_hook_connect(&m->core->hooks[PA_CO=
RE_HOOK_SINK_INPUT_MOVE_POST], (pa_hook_cb_t) sink_input_move_post_hook_cb,=
u);
@@ -392,22 +405,22 @@
=
if (u->sink_new_slot)
pa_hook_slot_free(u->sink_new_slot);
- if (u->sink_disconnect_slot)
- pa_hook_slot_free(u->sink_disconnect_slot);
+ if (u->sink_unlink_slot)
+ pa_hook_slot_free(u->sink_unlink_slot);
if (u->sink_state_changed_slot)
pa_hook_slot_free(u->sink_state_changed_slot);
=
if (u->source_new_slot)
pa_hook_slot_free(u->source_new_slot);
- if (u->source_disconnect_slot)
- pa_hook_slot_free(u->source_disconnect_slot);
+ if (u->source_unlink_slot)
+ pa_hook_slot_free(u->source_unlink_slot);
if (u->source_state_changed_slot)
pa_hook_slot_free(u->source_state_changed_slot);
=
if (u->sink_input_new_slot)
pa_hook_slot_free(u->sink_input_new_slot);
- if (u->sink_input_disconnect_slot)
- pa_hook_slot_free(u->sink_input_disconnect_slot);
+ if (u->sink_input_unlink_slot)
+ pa_hook_slot_free(u->sink_input_unlink_slot);
if (u->sink_input_move_slot)
pa_hook_slot_free(u->sink_input_move_slot);
if (u->sink_input_move_post_slot)
@@ -415,8 +428,8 @@
=
if (u->source_output_new_slot)
pa_hook_slot_free(u->source_output_new_slot);
- if (u->source_output_disconnect_slot)
- pa_hook_slot_free(u->source_output_disconnect_slot);
+ if (u->source_output_unlink_slot)
+ pa_hook_slot_free(u->source_output_unlink_slot);
if (u->source_output_move_slot)
pa_hook_slot_free(u->source_output_move_slot);
if (u->source_output_move_post_slot)
Modified: branches/lennart/src/pulsecore/cli-text.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
cli-text.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/cli-text.c (original)
+++ branches/lennart/src/pulsecore/cli-text.c Fri Aug 31 00:57:53 2007
@@ -97,7 +97,7 @@
[PA_SINK_RUNNING] =3D "RUNNING",
[PA_SINK_SUSPENDED] =3D "SUSPENDED",
[PA_SINK_IDLE] =3D "IDLE",
- [PA_SINK_DISCONNECTED] =3D "DISCONNECTED"
+ [PA_SINK_UNLINKED] =3D "UNLINKED"
};
assert(c);
=
@@ -114,7 +114,7 @@
" %c index: %u\n"
"\tname: <%s>\n"
"\tdriver: <%s>\n"
- "\tis hardware: <%i>\n"
+ "\tflags: %s%s%s%s\n"
"\tstate: %s\n"
"\tvolume: <%s>\n"
"\tmute: <%i>\n"
@@ -127,7 +127,10 @@
sink->index,
sink->name,
sink->driver,
- !!sink->is_hardware,
+ sink->flags & PA_SINK_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
+ sink->flags & PA_SINK_LATENCY ? "LATENCY " : "",
+ sink->flags & PA_SINK_HARDWARE ? "HARDWARE " : "",
+ sink->flags & PA_SINK_CAN_SUSPEND ? "CAN_SUSPEND " : "",
state_table[pa_sink_get_state(sink)],
pa_cvolume_snprint(cv, sizeof(cv), pa_sink_get_volume(sink)),
!!pa_sink_get_mute(sink),
@@ -154,7 +157,7 @@
[PA_SOURCE_RUNNING] =3D "RUNNING",
[PA_SOURCE_SUSPENDED] =3D "SUSPENDED",
[PA_SOURCE_IDLE] =3D "IDLE",
- [PA_SOURCE_DISCONNECTED] =3D "DISCONNECTED"
+ [PA_SOURCE_UNLINKED] =3D "UNLINKED"
};
assert(c);
=
@@ -172,7 +175,7 @@
" %c index: %u\n"
"\tname: <%s>\n"
"\tdriver: <%s>\n"
- "\tis hardware: <%i>\n"
+ "\tflags: %s%s%s%s\n"
"\tstate: %s\n"
"\tvolume: <%s>\n"
"\tmute: <%u>\n"
@@ -184,7 +187,10 @@
source->index,
source->name,
source->driver,
- !!source->is_hardware,
+ source->flags & PA_SOURCE_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " :=
"",
+ source->flags & PA_SOURCE_LATENCY ? "LATENCY " : "",
+ source->flags & PA_SOURCE_HARDWARE ? "HARDWARE " : "",
+ source->flags & PA_SOURCE_CAN_SUSPEND ? "CAN_SUSPEND " : "",
state_table[pa_source_get_state(source)],
pa_cvolume_snprint(cv, sizeof(cv), pa_source_get_volume(source=
)),
!!pa_source_get_mute(source),
@@ -212,7 +218,7 @@
static const char* const state_table[] =3D {
[PA_SOURCE_OUTPUT_RUNNING] =3D "RUNNING",
[PA_SOURCE_OUTPUT_CORKED] =3D "CORKED",
- [PA_SOURCE_OUTPUT_DISCONNECTED] =3D "DISCONNECTED"
+ [PA_SOURCE_OUTPUT_UNLINKED] =3D "UNLINKED"
};
assert(c);
=
@@ -231,6 +237,7 @@
" index: %u\n"
"\tname: '%s'\n"
"\tdriver: <%s>\n"
+ "\tflags: %s%s\n"
"\tstate: %s\n"
"\tsource: <%u> '%s'\n"
"\tlatency: <%0.0f usec>\n"
@@ -240,6 +247,8 @@
o->index,
o->name,
o->driver,
+ o->flags & PA_SOURCE_OUTPUT_VARIABLE_RATE ? "VARIABLE_RATE " :=
"",
+ o->flags & PA_SOURCE_OUTPUT_DONT_MOVE ? "DONT_MOVE " : "",
state_table[pa_source_output_get_state(o)],
o->source->index, o->source->name,
(double) pa_source_output_get_latency(o),
@@ -263,7 +272,7 @@
[PA_SINK_INPUT_RUNNING] =3D "RUNNING",
[PA_SINK_INPUT_DRAINED] =3D "DRAINED",
[PA_SINK_INPUT_CORKED] =3D "CORKED",
- [PA_SINK_INPUT_DISCONNECTED] =3D "DISCONNECTED"
+ [PA_SINK_INPUT_UNLINKED] =3D "UNLINKED"
};
=
assert(c);
@@ -282,6 +291,7 @@
" index: %u\n"
"\tname: <%s>\n"
"\tdriver: <%s>\n"
+ "\tflags: %s%s\n"
"\tstate: %s\n"
"\tsink: <%u> '%s'\n"
"\tvolume: <%s>\n"
@@ -293,6 +303,8 @@
i->index,
i->name,
i->driver,
+ i->flags & PA_SINK_INPUT_VARIABLE_RATE ? "VARIABLE_RATE " : "",
+ i->flags & PA_SINK_INPUT_DONT_MOVE ? "DONT_MOVE " : "",
state_table[pa_sink_input_get_state(i)],
i->sink->index, i->sink->name,
pa_cvolume_snprint(cv, sizeof(cv), pa_sink_input_get_volume(i)=
),
Modified: branches/lennart/src/pulsecore/core.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
core.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/core.c (original)
+++ branches/lennart/src/pulsecore/core.c Fri Aug 31 00:57:53 2007
@@ -133,7 +133,7 @@
c->module_idle_time =3D 20;
c->scache_idle_time =3D 20;
=
- c->resample_method =3D PA_RESAMPLER_SRC_SINC_FASTEST;
+ c->resample_method =3D PA_RESAMPLER_SPEEX_FLOAT_BASE;
=
c->is_system_instance =3D 0;
c->disallow_module_loading =3D 0;
Modified: branches/lennart/src/pulsecore/core.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
core.h?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/core.h (original)
+++ branches/lennart/src/pulsecore/core.h Fri Aug 31 00:57:53 2007
@@ -44,23 +44,23 @@
=
typedef enum pa_core_hook {
PA_CORE_HOOK_SINK_NEW_POST,
- PA_CORE_HOOK_SINK_DISCONNECT,
- PA_CORE_HOOK_SINK_DISCONNECT_POST,
+ PA_CORE_HOOK_SINK_UNLINK,
+ PA_CORE_HOOK_SINK_UNLINK_POST,
PA_CORE_HOOK_SINK_STATE_CHANGED,
PA_CORE_HOOK_SOURCE_NEW_POST,
- PA_CORE_HOOK_SOURCE_DISCONNECT,
- PA_CORE_HOOK_SOURCE_DISCONNECT_POST,
+ PA_CORE_HOOK_SOURCE_UNLINK,
+ PA_CORE_HOOK_SOURCE_UNLINK_POST,
PA_CORE_HOOK_SOURCE_STATE_CHANGED,
PA_CORE_HOOK_SINK_INPUT_NEW,
PA_CORE_HOOK_SINK_INPUT_PUT,
- PA_CORE_HOOK_SINK_INPUT_DISCONNECT,
- PA_CORE_HOOK_SINK_INPUT_DISCONNECT_POST,
+ PA_CORE_HOOK_SINK_INPUT_UNLINK,
+ PA_CORE_HOOK_SINK_INPUT_UNLINK_POST,
PA_CORE_HOOK_SINK_INPUT_MOVE,
PA_CORE_HOOK_SINK_INPUT_MOVE_POST,
PA_CORE_HOOK_SOURCE_OUTPUT_NEW,
PA_CORE_HOOK_SOURCE_OUTPUT_PUT,
- PA_CORE_HOOK_SOURCE_OUTPUT_DISCONNECT,
- PA_CORE_HOOK_SOURCE_OUTPUT_DISCONNECT_POST,
+ PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK,
+ PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK_POST,
PA_CORE_HOOK_SOURCE_OUTPUT_MOVE,
PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_POST,
PA_CORE_HOOK_MAX
Modified: branches/lennart/src/pulsecore/play-memblockq.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
play-memblockq.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Ddi=
ff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/play-memblockq.c (original)
+++ branches/lennart/src/pulsecore/play-memblockq.c Fri Aug 31 00:57:53 2007
@@ -58,7 +58,7 @@
if (!u->sink_input)
return;
=
- pa_sink_input_disconnect(u->sink_input);
+ pa_sink_input_unlink(u->sink_input);
=
pa_sink_input_unref(u->sink_input);
u->sink_input =3D NULL;
Modified: branches/lennart/src/pulsecore/play-memchunk.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
play-memchunk.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/play-memchunk.c (original)
+++ branches/lennart/src/pulsecore/play-memchunk.c Fri Aug 31 00:57:53 2007
@@ -58,7 +58,7 @@
if (!u->sink_input)
return;
=
- pa_sink_input_disconnect(u->sink_input);
+ pa_sink_input_unlink(u->sink_input);
=
pa_sink_input_unref(u->sink_input);
u->sink_input =3D NULL;
Modified: branches/lennart/src/pulsecore/protocol-esound.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
protocol-esound.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Dd=
iff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/protocol-esound.c (original)
+++ branches/lennart/src/pulsecore/protocol-esound.c Fri Aug 31 00:57:53 20=
07
@@ -212,13 +212,13 @@
return;
=
if (c->sink_input) {
- pa_sink_input_disconnect(c->sink_input);
+ pa_sink_input_unlink(c->sink_input);
pa_sink_input_unref(c->sink_input);
c->sink_input =3D NULL;
}
=
if (c->source_output) {
- pa_source_output_disconnect(c->source_output);
+ pa_source_output_unlink(c->source_output);
pa_source_output_unref(c->source_output);
c->source_output =3D NULL;
}
Modified: branches/lennart/src/pulsecore/protocol-native.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
protocol-native.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Dd=
iff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/protocol-native.c (original)
+++ branches/lennart/src/pulsecore/protocol-native.c Fri Aug 31 00:57:53 20=
07
@@ -387,7 +387,7 @@
return;
=
if (s->source_output) {
- pa_source_output_disconnect(s->source_output);
+ pa_source_output_unlink(s->source_output);
pa_source_output_unref(s->source_output);
s->source_output =3D NULL;
}
@@ -460,11 +460,10 @@
data.source =3D source;
data.driver =3D __FILE__;
data.name =3D name;
- data.start_corked =3D corked;
pa_source_output_new_data_set_sample_spec(&data, ss);
pa_source_output_new_data_set_channel_map(&data, map);
=
- if (!(source_output =3D pa_source_output_new(c->protocol->core, &data,=
0)))
+ if (!(source_output =3D pa_source_output_new(c->protocol->core, &data,=
corked ? PA_SOURCE_OUTPUT_START_CORKED : 0)))
return NULL;
=
s =3D pa_msgobject_new(record_stream);
@@ -504,7 +503,7 @@
return;
=
if (s->sink_input) {
- pa_sink_input_disconnect(s->sink_input);
+ pa_sink_input_unlink(s->sink_input);
pa_sink_input_unref(s->sink_input);
s->sink_input =3D NULL;
}
@@ -653,10 +652,9 @@
pa_sink_input_new_data_set_volume(&data, volume);
data.module =3D c->protocol->module;
data.client =3D c->client;
- data.start_corked =3D corked;
data.sync_base =3D ssync ? ssync->sink_input : NULL;
=
- if (!(sink_input =3D pa_sink_input_new(c->protocol->core, &data, 0)))
+ if (!(sink_input =3D pa_sink_input_new(c->protocol->core, &data, corke=
d ? PA_SINK_INPUT_START_CORKED : 0)))
return NULL;
=
s =3D pa_msgobject_new(playback_stream);
@@ -1729,10 +1727,7 @@
PA_TAG_STRING, sink->monitor_source ? sink->monitor_source->name :=
NULL,
PA_TAG_USEC, pa_sink_get_latency(sink),
PA_TAG_STRING, sink->driver,
- PA_TAG_U32,
- (sink->get_volume ? PA_SINK_HW_VOLUME_CTRL : 0) | /* FIXME */
- (sink->get_latency ? PA_SINK_LATENCY : 0) | /* FIXME */ =
- (sink->is_hardware ? PA_SINK_HARDWARE : 0),
+ PA_TAG_U32, sink->flags,
PA_TAG_INVALID);
}
=
@@ -1754,10 +1749,7 @@
PA_TAG_STRING, source->monitor_of ? source->monitor_of->name : NUL=
L,
PA_TAG_USEC, pa_source_get_latency(source),
PA_TAG_STRING, source->driver,
- PA_TAG_U32,
- (source->get_volume ? PA_SOURCE_HW_VOLUME_CTRL : 0) | /* FIXME=
*/
- (source->get_latency ? PA_SOURCE_LATENCY : 0) | /* FI=
XME */
- (source->is_hardware ? PA_SOURCE_HARDWARE : 0),
+ PA_TAG_U32, source->flags,
PA_TAG_INVALID);
}
=
Modified: branches/lennart/src/pulsecore/protocol-simple.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
protocol-simple.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Dd=
iff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/protocol-simple.c (original)
+++ branches/lennart/src/pulsecore/protocol-simple.c Fri Aug 31 00:57:53 20=
07
@@ -110,13 +110,13 @@
return;
=
if (c->sink_input) {
- pa_sink_input_disconnect(c->sink_input);
+ pa_sink_input_unlink(c->sink_input);
pa_sink_input_unref(c->sink_input);
c->sink_input =3D NULL;
}
=
if (c->source_output) {
- pa_source_output_disconnect(c->source_output);
+ pa_source_output_unlink(c->source_output);
pa_source_output_unref(c->source_output);
c->source_output =3D NULL;
}
Modified: branches/lennart/src/pulsecore/sink-input.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
sink-input.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/sink-input.c (original)
+++ branches/lennart/src/pulsecore/sink-input.c Fri Aug 31 00:57:53 2007
@@ -108,7 +108,7 @@
data->sink =3D pa_namereg_get(core, NULL, PA_NAMEREG_SINK, 1);
=
pa_return_null_if_fail(data->sink);
- pa_return_null_if_fail(pa_sink_get_state(data->sink) !=3D PA_SINK_DISC=
ONNECTED);
+ pa_return_null_if_fail(pa_sink_get_state(data->sink) !=3D PA_SINK_UNLI=
NKED);
pa_return_null_if_fail(!data->sync_base || (data->sync_base->sink =3D=
=3D data->sink && pa_sink_input_get_state(data->sync_base) =3D=3D PA_SINK_I=
NPUT_CORKED));
=
if (!data->sample_spec_is_set)
@@ -167,7 +167,7 @@
i->parent.process_msg =3D pa_sink_input_process_msg;
=
i->core =3D core;
- i->state =3D data->start_corked ? PA_SINK_INPUT_CORKED : PA_SINK_INPUT=
_RUNNING;
+ i->state =3D PA_SINK_INPUT_INIT;
i->flags =3D flags;
i->name =3D pa_xstrdup(data->name);
i->driver =3D pa_xstrdup(data->driver);
@@ -194,9 +194,12 @@
=
i->peek =3D NULL;
i->drop =3D NULL;
+ i->process =3D NULL;
i->kill =3D NULL;
i->get_latency =3D NULL;
- i->underrun =3D NULL;
+ i->attach =3D NULL;
+ i->detach =3D NULL;
+ i->suspend =3D NULL;
i->userdata =3D NULL;
=
i->thread_info.state =3D i->state;
@@ -245,11 +248,11 @@
return 0;
}
=
-void pa_sink_input_disconnect(pa_sink_input *i) {
+void pa_sink_input_unlink(pa_sink_input *i) {
pa_assert(i);
- pa_return_if_fail(i->state !=3D PA_SINK_INPUT_DISCONNECTED);
-
- pa_hook_fire(&i->sink->core->hooks[PA_CORE_HOOK_SINK_INPUT_DISCONNECT]=
, i);
+ pa_assert(PA_SINK_INPUT_LINKED(i->state));
+
+ pa_hook_fire(&i->sink->core->hooks[PA_CORE_HOOK_SINK_INPUT_UNLINK], i);
=
if (i->sync_prev)
i->sync_prev->sync_next =3D i->sync_next;
@@ -264,16 +267,19 @@
=
pa_subscription_post(i->sink->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|P=
A_SUBSCRIPTION_EVENT_REMOVE, i->index);
=
- sink_input_set_state(i, PA_SINK_INPUT_DISCONNECTED);
+ sink_input_set_state(i, PA_SINK_INPUT_UNLINKED);
pa_sink_update_status(i->sink);
=
i->peek =3D NULL;
i->drop =3D NULL;
+ i->process =3D NULL;
i->kill =3D NULL;
i->get_latency =3D NULL;
- i->underrun =3D NULL;
-
- pa_hook_fire(&i->sink->core->hooks[PA_CORE_HOOK_SINK_INPUT_DISCONNECT_=
POST], i);
+ i->attach =3D NULL;
+ i->detach =3D NULL;
+ i->suspend =3D NULL;
+
+ pa_hook_fire(&i->sink->core->hooks[PA_CORE_HOOK_SINK_INPUT_UNLINK_POST=
], i);
i->sink =3D NULL;
pa_sink_input_unref(i);
}
@@ -284,8 +290,8 @@
pa_assert(i);
pa_assert(pa_sink_input_refcnt(i) =3D=3D 0);
=
- if (i->state !=3D PA_SINK_INPUT_DISCONNECTED)
- pa_sink_input_disconnect(i);
+ if (PA_SINK_INPUT_LINKED(i->state))
+ pa_sink_input_unlink(i);
=
pa_log_info("Freeing output %u \"%s\"", i->index, i->name);
=
@@ -306,6 +312,11 @@
void pa_sink_input_put(pa_sink_input *i) {
pa_sink_input_assert_ref(i);
=
+ pa_assert(i->state =3D=3D PA_SINK_INPUT_INIT);
+ pa_assert(i->peek);
+ pa_assert(i->drop);
+
+ i->thread_info.state =3D i->state =3D i->flags & PA_SINK_INPUT_START_C=
ORKED ? PA_SINK_INPUT_CORKED : PA_SINK_INPUT_RUNNING;
i->thread_info.volume =3D i->volume;
i->thread_info.muted =3D i->muted;
=
@@ -314,10 +325,15 @@
=
pa_subscription_post(i->sink->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|P=
A_SUBSCRIPTION_EVENT_NEW, i->index);
pa_hook_fire(&i->sink->core->hooks[PA_CORE_HOOK_SINK_INPUT_PUT], i);
+
+ /* Please note that if you change something here, you have to
+ change something in pa_sink_input_move() with the ghost stream
+ registration too. */
}
=
void pa_sink_input_kill(pa_sink_input*i) {
pa_sink_input_assert_ref(i);
+ pa_assert(PA_SINK_INPUT_LINKED(i->state));
=
if (i->kill)
i->kill(i);
@@ -327,6 +343,7 @@
pa_usec_t r =3D 0;
=
pa_sink_input_assert_ref(i);
+ pa_assert(PA_SINK_INPUT_LINKED(i->state));
=
if (pa_asyncmsgq_send(i->sink->asyncmsgq, PA_MSGOBJECT(i), PA_SINK_INP=
UT_MESSAGE_GET_LATENCY, &r, 0, NULL) < 0)
r =3D 0;
@@ -344,10 +361,11 @@
int volume_is_norm;
=
pa_sink_input_assert_ref(i);
+ pa_assert(PA_SINK_INPUT_LINKED(i->thread_info.state));
pa_assert(chunk);
pa_assert(volume);
=
- if (!i->peek || !i->drop || i->thread_info.state =3D=3D PA_SINK_INPUT_=
DISCONNECTED || i->thread_info.state =3D=3D PA_SINK_INPUT_CORKED)
+ if (!i->peek || !i->drop || i->thread_info.state =3D=3D PA_SINK_INPUT_=
UNLINKED || i->thread_info.state =3D=3D PA_SINK_INPUT_CORKED)
goto finish;
=
pa_assert(i->thread_info.state =3D=3D PA_SINK_INPUT_RUNNING || i->thre=
ad_info.state =3D=3D PA_SINK_INPUT_DRAINED);
@@ -420,9 +438,6 @@
=
finish:
=
- if (ret < 0 && !pa_atomic_load(&i->thread_info.drained) && i->underrun)
- i->underrun(i);
-
if (ret >=3D 0)
pa_atomic_store(&i->thread_info.drained, 0);
else if (ret < 0)
@@ -448,13 +463,18 @@
/* Called from thread context */
void pa_sink_input_drop(pa_sink_input *i, size_t length) {
pa_sink_input_assert_ref(i);
+ pa_assert(PA_SINK_INPUT_LINKED(i->thread_info.state));
pa_assert(length > 0);
=
if (i->thread_info.move_silence > 0) {
=
- pa_assert(i->thread_info.move_silence >=3D length);
-
- i->thread_info.move_silence -=3D length;
+ if (i->thread_info.move_silence >=3D length) {
+ i->thread_info.move_silence -=3D length;
+ length =3D 0;
+ } else {
+ length -=3D i->thread_info.move_silence;
+ i->thread_info.move_silence =3D 0;
+ }
=
if (i->thread_info.move_silence <=3D 0) {
pa_assert(i->thread_info.silence_memblock);
@@ -462,7 +482,8 @@
i->thread_info.silence_memblock =3D NULL;
}
=
- return;
+ if (length <=3D 0)
+ return;
}
=
if (i->thread_info.resampled_chunk.memblock) {
@@ -531,6 +552,7 @@
=
void pa_sink_input_set_volume(pa_sink_input *i, const pa_cvolume *volume) {
pa_sink_input_assert_ref(i);
+ pa_assert(PA_SINK_INPUT_LINKED(i->state));
=
if (pa_cvolume_equal(&i->volume, volume))
return;
@@ -543,6 +565,7 @@
=
const pa_cvolume *pa_sink_input_get_volume(pa_sink_input *i) {
pa_sink_input_assert_ref(i);
+ pa_assert(PA_SINK_INPUT_LINKED(i->state));
=
return &i->volume;
}
@@ -550,6 +573,7 @@
void pa_sink_input_set_mute(pa_sink_input *i, int mute) {
pa_assert(i);
pa_sink_input_assert_ref(i);
+ pa_assert(PA_SINK_INPUT_LINKED(i->state));
=
if (!i->muted =3D=3D !mute)
return;
@@ -562,18 +586,21 @@
=
int pa_sink_input_get_mute(pa_sink_input *i) {
pa_sink_input_assert_ref(i);
+ pa_assert(PA_SINK_INPUT_LINKED(i->state));
=
return !!i->muted;
}
=
void pa_sink_input_cork(pa_sink_input *i, int b) {
pa_sink_input_assert_ref(i);
+ pa_assert(PA_SINK_INPUT_LINKED(i->state));
=
sink_input_set_state(i, b ? PA_SINK_INPUT_CORKED : PA_SINK_INPUT_RUNNI=
NG);
}
=
int pa_sink_input_set_rate(pa_sink_input *i, uint32_t rate) {
pa_sink_input_assert_ref(i);
+ pa_assert(PA_SINK_INPUT_LINKED(i->state));
pa_return_val_if_fail(i->thread_info.resampler, -1);
=
if (i->sample_spec.rate =3D=3D rate)
@@ -615,12 +642,16 @@
pa_sink_input_move_info info;
=
pa_sink_input_assert_ref(i);
+ pa_assert(PA_SINK_INPUT_LINKED(i->state));
pa_sink_assert_ref(dest);
=
origin =3D i->sink;
=
if (dest =3D=3D origin)
return 0;
+
+ if (i->flags & PA_SINK_INPUT_DONT_MOVE)
+ return -1;
=
if (i->sync_next || i->sync_prev) {
pa_log_warn("Moving synchronised streams not supported.");
@@ -714,6 +745,10 @@
=
if (info.ghost_sink_input) {
/* Basically, do what pa_sink_input_put() does ...*/
+ info.ghost_sink_input->thread_info.state =3D info.ghost_sink_input=
->state =3D PA_SINK_INPUT_RUNNING;
+ info.ghost_sink_input->thread_info.volume =3D info.ghost_sink_inpu=
t->volume;
+ info.ghost_sink_input->thread_info.muted =3D info.ghost_sink_input=
->muted;
+ =
pa_subscription_post(i->sink->core, PA_SUBSCRIPTION_EVENT_SINK_INP=
UT|PA_SUBSCRIPTION_EVENT_NEW, info.ghost_sink_input->index);
pa_hook_fire(&i->sink->core->hooks[PA_CORE_HOOK_SINK_INPUT_PUT], i=
nfo.ghost_sink_input);
pa_sink_input_unref(info.ghost_sink_input);
@@ -774,6 +809,7 @@
pa_sink_input *i =3D PA_SINK_INPUT(o);
=
pa_sink_input_assert_ref(i);
+ pa_assert(PA_SINK_INPUT_LINKED(i->thread_info.state));
=
switch (code) {
case PA_SINK_INPUT_MESSAGE_SET_VOLUME:
@@ -841,3 +877,4 @@
=
return i->state;
}
+
Modified: branches/lennart/src/pulsecore/sink-input.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
sink-input.h?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/sink-input.h (original)
+++ branches/lennart/src/pulsecore/sink-input.h Fri Aug 31 00:57:53 2007
@@ -39,14 +39,21 @@
#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 the=
re 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 =3D=3D PA_SINK_INPUT_DRAINED || x =3D=3D PA_SINK_INPUT_RUNNIN=
G || x =3D=3D PA_SINK_INPUT_CORKED;
+}
=
typedef enum pa_sink_input_flags {
PA_SINK_INPUT_VARIABLE_RATE =3D 1,
+ PA_SINK_INPUT_DONT_MOVE =3D 2,
+ PA_SINK_INPUT_START_CORKED =3D 4
} pa_sink_input_flags_t;
=
struct pa_sink_input {
@@ -75,11 +82,42 @@
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 @@
=
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_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);
=
Modified: branches/lennart/src/pulsecore/sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
sink.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/sink.c (original)
+++ branches/lennart/src/pulsecore/sink.c Fri Aug 31 00:57:53 2007
@@ -92,7 +92,8 @@
s->parent.process_msg =3D pa_sink_process_msg;
=
s->core =3D core;
- s->state =3D PA_SINK_IDLE;
+ s->state =3D PA_SINK_INIT;
+ s->flags =3D 0;
s->name =3D pa_xstrdup(name);
s->description =3D NULL;
s->driver =3D pa_xstrdup(driver);
@@ -106,8 +107,6 @@
pa_cvolume_reset(&s->volume, spec->channels);
s->muted =3D 0;
s->refresh_volume =3D s->refresh_mute =3D 0;
-
- s->is_hardware =3D 0;
=
s->get_latency =3D NULL;
s->set_volume =3D NULL;
@@ -118,6 +117,7 @@
s->userdata =3D NULL;
=
s->asyncmsgq =3D NULL;
+ s->rtpoll =3D NULL;
s->silence =3D NULL;
=
r =3D pa_idxset_put(core->sinks, s, &s->index);
@@ -145,11 +145,22 @@
s->thread_info.soft_muted =3D s->muted;
s->thread_info.state =3D s->state;
=
- pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIPTIO=
N_EVENT_NEW, s->index);
-
- pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_NEW_POST], s);
-
return s;
+}
+
+void pa_sink_put(pa_sink* s) {
+ pa_sink_assert_ref(s);
+
+ pa_assert(s->state =3D=3D PA_SINK_INIT);
+ pa_assert(s->asyncmsgq);
+ pa_assert(s->rtpoll);
+
+ s->thread_info.state =3D s->state =3D PA_SINK_IDLE;
+ =
+ pa_source_put(s->monitor_source);
+
+ pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIP=
TION_EVENT_NEW, s->index);
+ pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_NEW_POST], s);
}
=
static int sink_set_state(pa_sink *s, pa_sink_state_t state) {
@@ -160,6 +171,21 @@
if (s->state =3D=3D state)
return 0;
=
+ if (state =3D=3D PA_SINK_SUSPENDED && !(s->flags & PA_SINK_CAN_SUSPEND=
))
+ return -1;
+
+ if ((s->state =3D=3D PA_SINK_SUSPENDED && PA_SINK_OPENED(state)) ||
+ (PA_SINK_OPENED(s->state) && state =3D=3D PA_SINK_SUSPENDED)) {
+ pa_sink_input *i;
+ uint32_t idx;
+ =
+ /* We're suspending or resuming, tell everyone about it */
+ =
+ for (i =3D PA_SINK_INPUT(pa_idxset_first(s->inputs, &idx)); i; i =
=3D PA_SINK_INPUT(pa_idxset_next(s->inputs, &idx)))
+ if (i->suspend)
+ i->suspend(i, state =3D=3D PA_SINK_SUSPENDED);
+ }
+ =
if (s->set_state)
if ((ret =3D s->set_state(s, state)) < 0)
return -1;
@@ -168,18 +194,19 @@
return -1;
=
s->state =3D state;
- =
- pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_STATE_CHANGED], s);
+
+ if (state !=3D PA_SINK_UNLINKED) /* if we enter UNLINKED state pa_sink=
_unlink() will fire the apropriate events */
+ pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_STATE_CHANGED], s);
return 0;
}
=
-void pa_sink_disconnect(pa_sink* s) {
+void pa_sink_unlink(pa_sink* s) {
pa_sink_input *i, *j =3D NULL;
=
pa_assert(s);
- pa_return_if_fail(s->state !=3D PA_SINK_DISCONNECTED);
-
- pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_DISCONNECT], s);
+ pa_assert(PA_SINK_LINKED(s->state));
+
+ pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_UNLINK], s);
=
pa_namereg_unregister(s->core, s->name);
pa_idxset_remove_by_data(s->core->sinks, s, NULL);
@@ -191,9 +218,9 @@
}
=
if (s->monitor_source)
- pa_source_disconnect(s->monitor_source);
-
- sink_set_state(s, PA_SINK_DISCONNECTED);
+ pa_source_unlink(s->monitor_source);
+
+ sink_set_state(s, PA_SINK_UNLINKED);
=
s->get_latency =3D NULL;
s->get_volume =3D NULL;
@@ -204,7 +231,7 @@
=
pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIP=
TION_EVENT_REMOVE, s->index);
=
- pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_DISCONNECT_POST], s);
+ pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_UNLINK_POST], s);
}
=
static void sink_free(pa_object *o) {
@@ -214,8 +241,8 @@
pa_assert(s);
pa_assert(pa_sink_refcnt(s) =3D=3D 0);
=
- if (s->state !=3D PA_SINK_DISCONNECTED)
- pa_sink_disconnect(s);
+ if (PA_SINK_LINKED(s->state))
+ pa_sink_unlink(s);
=
pa_log_info("Freeing sink %u \"%s\"", s->index, s->name);
=
@@ -250,8 +277,18 @@
pa_source_set_asyncmsgq(s->monitor_source, q);
}
=
+void pa_sink_set_rtpoll(pa_sink *s, pa_rtpoll *p) {
+ pa_sink_assert_ref(s);
+ pa_assert(p);
+
+ s->rtpoll =3D p;
+ if (s->monitor_source)
+ pa_source_set_rtpoll(s->monitor_source, p);
+}
+
int pa_sink_update_status(pa_sink*s) {
pa_sink_assert_ref(s);
+ pa_assert(PA_SINK_LINKED(s->state));
=
if (s->state =3D=3D PA_SINK_SUSPENDED)
return 0;
@@ -261,6 +298,7 @@
=
int pa_sink_suspend(pa_sink *s, int suspend) {
pa_sink_assert_ref(s);
+ pa_assert(PA_SINK_LINKED(s->state));
=
if (suspend)
return sink_set_state(s, PA_SINK_SUSPENDED);
@@ -270,6 +308,7 @@
=
void pa_sink_ping(pa_sink *s) {
pa_sink_assert_ref(s);
+ pa_assert(PA_SINK_LINKED(s->state));
=
pa_asyncmsgq_post(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_PING,=
NULL, 0, NULL, NULL);
}
@@ -364,6 +403,7 @@
unsigned n;
=
pa_sink_assert_ref(s);
+ pa_assert(PA_SINK_OPENED(s->thread_info.state));
pa_assert(length);
pa_assert(result);
=
@@ -429,6 +469,7 @@
unsigned n;
=
pa_sink_assert_ref(s);
+ pa_assert(PA_SINK_OPENED(s->thread_info.state));
pa_assert(target);
pa_assert(target->memblock);
pa_assert(target->length);
@@ -494,6 +535,7 @@
size_t l, d;
=
pa_sink_assert_ref(s);
+ pa_assert(PA_SINK_OPENED(s->thread_info.state));
pa_assert(target);
pa_assert(target->memblock);
pa_assert(target->length);
@@ -518,6 +560,7 @@
=
void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) {
pa_sink_assert_ref(s);
+ pa_assert(PA_SINK_OPENED(s->thread_info.state));
pa_assert(length);
pa_assert(result);
=
@@ -529,10 +572,46 @@
pa_sink_render_into_full(s, result);
}
=
+void pa_sink_skip(pa_sink *s, size_t length) {
+ pa_sink_input *i;
+ void *state =3D NULL;
+
+ pa_sink_assert_ref(s);
+ pa_assert(PA_SINK_OPENED(s->thread_info.state));
+ pa_assert(length > 0);
+ =
+ if (pa_source_used_by(s->monitor_source)) {
+ pa_memchunk chunk;
+ =
+ /* If something is connected to our monitor source, we have to
+ * pass valid data to it */
+
+ while (length > 0) {
+ pa_sink_render(s, length, &chunk);
+ pa_memblock_unref(chunk.memblock);
+
+ pa_assert(chunk.length <=3D length);
+ length -=3D chunk.length;
+ }
+ =
+ } else {
+ /* Ok, noone cares about the rendered data, so let's not even rend=
er it */
+
+ while ((i =3D pa_hashmap_iterate(s->thread_info.inputs, &state, NU=
LL))) {
+ pa_sink_input_assert_ref(i);
+ pa_sink_input_drop(i, length);
+ }
+ }
+}
+
pa_usec_t pa_sink_get_latency(pa_sink *s) {
pa_usec_t usec =3D 0;
=
pa_sink_assert_ref(s);
+ pa_assert(PA_SINK_LINKED(s->state));
+
+ if (!PA_SINK_OPENED(s->state))
+ return 0;
=
if (s->get_latency)
return s->get_latency(s);
@@ -547,6 +626,7 @@
int changed;
=
pa_sink_assert_ref(s);
+ pa_assert(PA_SINK_LINKED(s->state));
pa_assert(volume);
=
changed =3D !pa_cvolume_equal(volume, &s->volume);
@@ -566,6 +646,7 @@
struct pa_cvolume old_volume;
=
pa_sink_assert_ref(s);
+ pa_assert(PA_SINK_LINKED(s->state));
=
old_volume =3D s->volume;
=
@@ -585,6 +666,7 @@
int changed;
=
pa_sink_assert_ref(s);
+ pa_assert(PA_SINK_LINKED(s->state));
=
changed =3D s->muted !=3D mute;
s->muted =3D mute;
@@ -603,6 +685,7 @@
int old_muted;
=
pa_sink_assert_ref(s);
+ pa_assert(PA_SINK_LINKED(s->state));
=
old_muted =3D s->muted;
=
@@ -659,6 +742,7 @@
unsigned ret;
=
pa_sink_assert_ref(s);
+ pa_assert(PA_SINK_LINKED(s->state));
=
ret =3D pa_idxset_size(s->inputs);
=
@@ -671,6 +755,7 @@
int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t=
offset, pa_memchunk *chunk) {
pa_sink *s =3D PA_SINK(o);
pa_sink_assert_ref(s);
+ pa_assert(PA_SINK_LINKED(s->thread_info.state));
=
switch ((pa_sink_message_t) code) {
=
@@ -694,13 +779,19 @@
i->thread_info.sync_next->thread_info.sync_prev =3D i;
}
=
+ if (i->attach)
+ i->attach(i);
+
return 0;
}
=
case PA_SINK_MESSAGE_REMOVE_INPUT: {
pa_sink_input *i =3D PA_SINK_INPUT(userdata);
=
- /* Since the caller sleeps in pa_sink_input_disconnect(),
+ if (i->detach)
+ i->detach(i);
+ =
+ /* Since the caller sleeps in pa_sink_input_unlink(),
* we can safely access data outside of thread_info even
* though it is mutable */
=
@@ -833,3 +924,21 @@
=
return ret;
}
+
+int pa_sink_process_inputs(pa_sink *s) {
+ pa_sink_input *i;
+ void *state =3D NULL;
+ int r;
+ =
+ pa_sink_assert_ref(s);
+
+ if (!PA_SINK_LINKED(s->thread_info.state))
+ return 0;
+ =
+ while ((i =3D PA_SINK_INPUT(pa_hashmap_iterate(s->thread_info.inputs, =
&state, NULL))))
+ if (i->process)
+ if ((r =3D i->process(i)))
+ return r;
+
+ return 0;
+}
Modified: branches/lennart/src/pulsecore/sink.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
sink.h?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/sink.h (original)
+++ branches/lennart/src/pulsecore/sink.h Fri Aug 31 00:57:53 2007
@@ -40,15 +40,25 @@
#include <pulsecore/module.h>
#include <pulsecore/refcnt.h>
#include <pulsecore/msgobject.h>
+#include <pulsecore/rtpoll.h>
=
#define PA_MAX_INPUTS_PER_SINK 32
=
typedef enum pa_sink_state {
+ PA_SINK_INIT,
PA_SINK_RUNNING,
PA_SINK_SUSPENDED,
PA_SINK_IDLE,
- PA_SINK_DISCONNECTED
+ PA_SINK_UNLINKED
} pa_sink_state_t;
+
+static inline int PA_SINK_OPENED(pa_sink_state_t x) {
+ return x =3D=3D PA_SINK_RUNNING || x =3D=3D PA_SINK_IDLE;
+}
+
+static inline int PA_SINK_LINKED(pa_sink_state_t x) {
+ return x =3D=3D PA_SINK_RUNNING || x =3D=3D PA_SINK_IDLE || x =3D=3D P=
A_SINK_SUSPENDED;
+}
=
struct pa_sink {
pa_msgobject parent;
@@ -56,10 +66,10 @@
uint32_t index;
pa_core *core;
pa_sink_state_t state;
+ pa_sink_flags_t flags;
=
char *name;
char *description, *driver; /* may be NULL */
- int is_hardware;
=
pa_module *module; /* may be NULL */
=
@@ -67,21 +77,22 @@
pa_channel_map channel_map;
=
pa_idxset *inputs;
- pa_source *monitor_source; /* may be NULL */
+ pa_source *monitor_source; =
=
pa_cvolume volume;
int muted;
int refresh_volume;
int refresh_mute;
=
- int (*set_state)(pa_sink *s, pa_sink_state_t state);
- int (*set_volume)(pa_sink *s); /* dito */
- int (*get_volume)(pa_sink *s); /* dito */
- int (*get_mute)(pa_sink *s); /* dito */
- int (*set_mute)(pa_sink *s); /* dito */
+ int (*set_state)(pa_sink *s, pa_sink_state_t state); /* may be NULL */
+ int (*set_volume)(pa_sink *s); /* dito */
+ int (*get_volume)(pa_sink *s); /* dito */
+ int (*get_mute)(pa_sink *s); /* dito */
+ int (*set_mute)(pa_sink *s); /* dito */
pa_usec_t (*get_latency)(pa_sink *s); /* dito */
=
pa_asyncmsgq *asyncmsgq;
+ pa_rtpoll *rtpoll;
=
/* Contains copies of the above data so that the real-time worker
* thread can work without access locking */
@@ -114,7 +125,7 @@
PA_SINK_MESSAGE_MAX
} pa_sink_message_t;
=
-/* To be used exclusively by the sink driver */
+/* To be called exclusively by the sink driver, from main context */
=
pa_sink* pa_sink_new(
pa_core *core,
@@ -124,18 +135,21 @@
const pa_sample_spec *spec,
const pa_channel_map *map);
=
-void pa_sink_disconnect(pa_sink* s);
+void pa_sink_put(pa_sink *s);
+void pa_sink_unlink(pa_sink* s);
=
void pa_sink_set_module(pa_sink *sink, pa_module *m);
void pa_sink_set_description(pa_sink *s, const char *description);
void pa_sink_set_asyncmsgq(pa_sink *s, pa_asyncmsgq *q);
+void pa_sink_set_rtpoll(pa_sink *s, pa_rtpoll *p);
=
-/* Usable by everyone */
+/* May be called by everyone, from main context */
=
pa_usec_t pa_sink_get_latency(pa_sink *s);
=
int pa_sink_update_status(pa_sink*s);
int pa_sink_suspend(pa_sink *s, int suspend);
+int pa_sink_suspend_all(pa_core *c, int suspend);
=
/* Sends a ping message to the sink thread, to make it wake up and
* check for data to process even if there is no real message is
@@ -150,19 +164,17 @@
unsigned pa_sink_used_by(pa_sink *s);
#define pa_sink_get_state(s) ((s)->state)
=
-/* To be used exclusively by the sink driver thread */
+/* To be called exclusively by the sink driver, from IO context */
=
void pa_sink_render(pa_sink*s, size_t length, pa_memchunk *result);
void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result);
void pa_sink_render_into(pa_sink*s, pa_memchunk *target);
void pa_sink_render_into_full(pa_sink *s, pa_memchunk *target);
=
+void pa_sink_skip(pa_sink *s, size_t length);
+
+int pa_sink_process_inputs(pa_sink *s);
+
int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t=
offset, pa_memchunk *chunk);
=
-static inline int PA_SINK_OPENED(pa_sink_state_t x) {
- return x =3D=3D PA_SINK_RUNNING || x =3D=3D PA_SINK_IDLE;
-}
-
-int pa_sink_suspend_all(pa_core *c, int suspend);
-
#endif
Modified: branches/lennart/src/pulsecore/sound-file-stream.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
sound-file-stream.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=
=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/sound-file-stream.c (original)
+++ branches/lennart/src/pulsecore/sound-file-stream.c Fri Aug 31 00:57:53 =
2007
@@ -69,7 +69,7 @@
if (!u->sink_input)
return;
=
- pa_sink_input_disconnect(u->sink_input);
+ pa_sink_input_unlink(u->sink_input);
=
pa_sink_input_unref(u->sink_input);
u->sink_input =3D NULL;
Modified: branches/lennart/src/pulsecore/source-output.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
source-output.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/source-output.c (original)
+++ branches/lennart/src/pulsecore/source-output.c Fri Aug 31 00:57:53 2007
@@ -86,7 +86,7 @@
data->source =3D pa_namereg_get(core, NULL, PA_NAMEREG_SOURCE, 1);
=
pa_return_null_if_fail(data->source);
- pa_return_null_if_fail(pa_source_get_state(data->source) !=3D PA_SOURC=
E_DISCONNECTED);
+ pa_return_null_if_fail(pa_source_get_state(data->source) !=3D PA_SOURC=
E_UNLINKED);
=
if (!data->sample_spec_is_set)
data->sample_spec =3D data->source->sample_spec;
@@ -135,7 +135,7 @@
o->parent.process_msg =3D pa_source_output_process_msg;
=
o->core =3D core;
- o->state =3D data->start_corked ? PA_SOURCE_OUTPUT_CORKED : PA_SOURCE_=
OUTPUT_RUNNING;
+ o->state =3D PA_SOURCE_OUTPUT_INIT;
o->flags =3D flags;
o->name =3D pa_xstrdup(data->name);
o->driver =3D pa_xstrdup(data->driver);
@@ -148,8 +148,12 @@
o->channel_map =3D data->channel_map;
=
o->push =3D NULL;
+ o->process =3D NULL;
o->kill =3D NULL;
o->get_latency =3D NULL;
+ o->detach =3D NULL;
+ o->attach =3D NULL;
+ o->suspend =3D NULL;
o->userdata =3D NULL;
=
o->thread_info.state =3D o->state;
@@ -183,11 +187,11 @@
return 0;
}
=
-void pa_source_output_disconnect(pa_source_output*o) {
+void pa_source_output_unlink(pa_source_output*o) {
pa_assert(o);
- pa_return_if_fail(o->state !=3D PA_SOURCE_OUTPUT_DISCONNECTED);
-
- pa_hook_fire(&o->source->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_DISCON=
NECT], o);
+ pa_assert(PA_SOURCE_OUTPUT_LINKED(o->state));
+
+ pa_hook_fire(&o->source->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK=
], o);
=
pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o->source), PA_SO=
URCE_MESSAGE_REMOVE_OUTPUT, o, 0, NULL);
=
@@ -196,14 +200,18 @@
=
pa_subscription_post(o->source->core, PA_SUBSCRIPTION_EVENT_SOURCE_OUT=
PUT|PA_SUBSCRIPTION_EVENT_REMOVE, o->index);
=
- source_output_set_state(o, PA_SOURCE_OUTPUT_DISCONNECTED);
+ source_output_set_state(o, PA_SOURCE_OUTPUT_UNLINKED);
pa_source_update_status(o->source);
=
o->push =3D NULL;
+ o->process =3D NULL;
o->kill =3D NULL;
o->get_latency =3D NULL;
-
- pa_hook_fire(&o->source->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_DISCON=
NECT_POST], o);
+ o->attach =3D NULL;
+ o->detach =3D NULL;
+ o->suspend =3D NULL;
+
+ pa_hook_fire(&o->source->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK=
_POST], o);
=
o->source =3D NULL;
pa_source_output_unref(o);
@@ -214,8 +222,8 @@
=
pa_assert(pa_source_output_refcnt(o) =3D=3D 0);
=
- if (o->state !=3D PA_SOURCE_OUTPUT_DISCONNECTED)
- pa_source_output_disconnect(o);
+ if (PA_SOURCE_LINKED(o->state))
+ pa_source_output_unlink(o);
=
pa_log_info("Freeing output %u \"%s\"", o->index, o->name);
=
@@ -230,6 +238,11 @@
void pa_source_output_put(pa_source_output *o) {
pa_source_output_assert_ref(o);
=
+ pa_assert(o->state =3D=3D PA_SOURCE_OUTPUT_INIT);
+ pa_assert(o->push);
+
+ o->thread_info.state =3D o->state =3D o->flags & PA_SOURCE_OUTPUT_STAR=
T_CORKED ? PA_SOURCE_OUTPUT_CORKED : PA_SOURCE_OUTPUT_RUNNING;
+
pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o->source), PA_SO=
URCE_MESSAGE_ADD_OUTPUT, o, 0, NULL);
pa_source_update_status(o->source);
=
@@ -240,7 +253,8 @@
=
void pa_source_output_kill(pa_source_output*o) {
pa_source_output_assert_ref(o);
-
+ pa_assert(PA_SOURCE_OUTPUT_LINKED(o->state));
+ =
if (o->kill)
o->kill(o);
}
@@ -249,6 +263,7 @@
pa_usec_t r =3D 0;
=
pa_source_output_assert_ref(o);
+ pa_assert(PA_SOURCE_OUTPUT_LINKED(o->state));
=
if (pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o), PA_SOURCE=
_OUTPUT_MESSAGE_GET_LATENCY, &r, 0, NULL) < 0)
r =3D 0;
@@ -264,10 +279,11 @@
pa_memchunk rchunk;
=
pa_source_output_assert_ref(o);
+ pa_assert(PA_SOURCE_OUTPUT_LINKED(o->thread_info.state));
pa_assert(chunk);
pa_assert(chunk->length);
=
- if (!o->push || o->state =3D=3D PA_SOURCE_OUTPUT_DISCONNECTED || o->st=
ate =3D=3D PA_SOURCE_OUTPUT_CORKED)
+ if (!o->push || o->state =3D=3D PA_SOURCE_OUTPUT_UNLINKED || o->state =
=3D=3D PA_SOURCE_OUTPUT_CORKED)
return;
=
pa_assert(o->state =3D=3D PA_SOURCE_OUTPUT_RUNNING);
@@ -288,12 +304,14 @@
=
void pa_source_output_cork(pa_source_output *o, int b) {
pa_source_output_assert_ref(o);
+ pa_assert(PA_SOURCE_OUTPUT_LINKED(o->state));
=
source_output_set_state(o, b ? PA_SOURCE_OUTPUT_CORKED : PA_SOURCE_OUT=
PUT_RUNNING);
}
=
int pa_source_output_set_rate(pa_source_output *o, uint32_t rate) {
pa_source_output_assert_ref(o);
+ pa_assert(PA_SOURCE_OUTPUT_LINKED(o->state));
pa_return_val_if_fail(o->thread_info.resampler, -1);
=
if (o->sample_spec.rate =3D=3D rate)
@@ -333,12 +351,16 @@
pa_resampler *new_resampler =3D NULL;
=
pa_source_output_assert_ref(o);
+ pa_assert(PA_SOURCE_OUTPUT_LINKED(o->state));
pa_source_assert_ref(dest);
=
origin =3D o->source;
=
if (dest =3D=3D origin)
return 0;
+
+ if (o->flags & PA_SOURCE_OUTPUT_DONT_MOVE)
+ return -1;
=
if (pa_idxset_size(dest->outputs) >=3D PA_MAX_OUTPUTS_PER_SOURCE) {
pa_log_warn("Failed to move source output: too many outputs per so=
urce.");
@@ -405,6 +427,7 @@
pa_source_output *o =3D PA_SOURCE_OUTPUT(mo);
=
pa_source_output_assert_ref(o);
+ pa_assert(PA_SOURCE_OUTPUT_LINKED(o->thread_info.state));
=
switch (code) {
=
Modified: branches/lennart/src/pulsecore/source-output.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
source-output.h?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/source-output.h (original)
+++ branches/lennart/src/pulsecore/source-output.h Fri Aug 31 00:57:53 2007
@@ -36,13 +36,20 @@
#include <pulsecore/client.h>
=
typedef enum pa_source_output_state {
+ PA_SOURCE_OUTPUT_INIT,
PA_SOURCE_OUTPUT_RUNNING,
PA_SOURCE_OUTPUT_CORKED,
- PA_SOURCE_OUTPUT_DISCONNECTED
+ PA_SOURCE_OUTPUT_UNLINKED
} pa_source_output_state_t;
=
+static inline int PA_SOURCE_OUTPUT_LINKED(pa_source_output_state_t x) {
+ return x =3D=3D PA_SOURCE_OUTPUT_RUNNING || x =3D=3D PA_SOURCE_OUTPUT_=
CORKED;
+}
+
typedef enum pa_source_output_flags {
- PA_SOURCE_OUTPUT_VARIABLE_RATE =3D 1
+ PA_SOURCE_OUTPUT_VARIABLE_RATE =3D 1,
+ PA_SOURCE_OUTPUT_DONT_MOVE =3D 2,
+ PA_SOURCE_OUTPUT_START_CORKED =3D 4
} pa_source_output_flags_t;
=
struct pa_source_output {
@@ -62,8 +69,37 @@
pa_sample_spec sample_spec;
pa_channel_map channel_map;
=
+ /* Pushes a new memchunk into the output. Called from IO thread
+ * context. */
void (*push)(pa_source_output *o, const pa_memchunk *chunk);
+
+ /* 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_source_output *o); /* may be NULL */
+
+ /* If non-NULL this function is called when the output is first
+ * connected to a source. Called from IO thread context */
+ void (*attach) (pa_source_output *o); /* may be NULL */ =
+
+ /* If non-NULL this function is called when the output is
+ * disconnected from its source. Called from IO thread context */
+ void (*detach) (pa_source_output *o); /* may be NULL */ =
+ =
+ /* If non-NULL called whenever the the source this output is attached
+ * to suspends or resumes. Called from main context */
+ void (*suspend) (pa_source_output *o, int b); /* may be NULL */
+
+ /* Supposed to unlink and destroy this stream. Called from main
+ * context. */
void (*kill)(pa_source_output* o); /* may be NULL */
+
+ /* Return the current latency (i.e. length of bufferd audio) of
+ this stream. Called from main context. If NULL a
+ PA_SOURCE_OUTPUT_MESSAGE_GET_LATENCY message is sent to the IO
+ thread instead. */
pa_usec_t (*get_latency) (pa_source_output *o); /* may be NULL */
=
pa_resample_method_t resample_method;
@@ -102,8 +138,6 @@
int channel_map_is_set;
=
pa_resample_method_t resample_method;
-
- int start_corked;
} pa_source_output_new_data;
=
pa_source_output_new_data* pa_source_output_new_data_init(pa_source_output=
_new_data *data);
@@ -119,7 +153,7 @@
pa_source_output_flags_t flags);
=
void pa_source_output_put(pa_source_output *o);
-void pa_source_output_disconnect(pa_source_output*o);
+void pa_source_output_unlink(pa_source_output*o);
=
void pa_source_output_set_name(pa_source_output *i, const char *name);
=
Modified: branches/lennart/src/pulsecore/source.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
source.c?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/source.c (original)
+++ branches/lennart/src/pulsecore/source.c Fri Aug 31 00:57:53 2007
@@ -84,7 +84,8 @@
s->parent.process_msg =3D pa_source_process_msg;
=
s->core =3D core;
- s->state =3D PA_SOURCE_IDLE;
+ s->state =3D PA_SOURCE_INIT;
+ s->flags =3D 0;
s->name =3D pa_xstrdup(name);
s->description =3D NULL;
s->driver =3D pa_xstrdup(driver);
@@ -99,8 +100,6 @@
pa_cvolume_reset(&s->volume, spec->channels);
s->muted =3D 0;
s->refresh_volume =3D s->refresh_muted =3D 0;
-
- s->is_hardware =3D 0;
=
s->get_latency =3D NULL;
s->set_volume =3D NULL;
@@ -111,6 +110,7 @@
s->userdata =3D NULL;
=
s->asyncmsgq =3D NULL;
+ s->rtpoll =3D NULL;
=
r =3D pa_idxset_put(core->sources, s, &s->index);
assert(s->index !=3D PA_IDXSET_INVALID && r >=3D 0);
@@ -123,11 +123,20 @@
s->thread_info.soft_muted =3D s->muted;
s->thread_info.state =3D s->state;
=
- pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_SOURCE | PA_SUBSCRIPT=
ION_EVENT_NEW, s->index);
-
- pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_NEW_POST], s);
- =
return s;
+}
+
+void pa_source_put(pa_source *s) {
+ pa_source_assert_ref(s);
+
+ pa_assert(s->state =3D=3D PA_SINK_INIT);
+ pa_assert(s->rtpoll);
+ pa_assert(s->asyncmsgq);
+
+ s->thread_info.state =3D s->state =3D PA_SOURCE_IDLE;
+
+ pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE | PA_SUBSCR=
IPTION_EVENT_NEW, s->index);
+ pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_NEW_POST], s);
}
=
static int source_set_state(pa_source *s, pa_source_state_t state) {
@@ -137,6 +146,21 @@
=
if (s->state =3D=3D state)
return 0;
+
+ if (state =3D=3D PA_SOURCE_SUSPENDED && !(s->flags & PA_SOURCE_CAN_SUS=
PEND))
+ return -1;
+ =
+ if ((s->state =3D=3D PA_SOURCE_SUSPENDED && PA_SOURCE_OPENED(state)) ||
+ (PA_SOURCE_OPENED(s->state) && state =3D=3D PA_SOURCE_SUSPENDED)) {
+ pa_source_output *o;
+ uint32_t idx;
+ =
+ /* We're suspending or resuming, tell everyone about it */
+ =
+ for (o =3D PA_SOURCE_OUTPUT(pa_idxset_first(s->outputs, &idx)); o;=
o =3D PA_SOURCE_OUTPUT(pa_idxset_next(s->outputs, &idx)))
+ if (o->suspend)
+ o->suspend(o, state =3D=3D PA_SINK_SUSPENDED);
+ }
=
if (s->set_state)
if ((ret =3D s->set_state(s, state)) < 0)
@@ -146,17 +170,19 @@
return -1;
=
s->state =3D state;
- pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_STATE_CHANGED], s);
+
+ if (state !=3D PA_SOURCE_UNLINKED) /* if we enter UNLINKED state pa_so=
urce_unlink() will fire the apropriate events */
+ pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_STATE_CHANGED], s=
);
return 0;
}
=
-void pa_source_disconnect(pa_source *s) {
+void pa_source_unlink(pa_source *s) {
pa_source_output *o, *j =3D NULL;
=
pa_assert(s);
- pa_return_if_fail(s->state !=3D PA_SOURCE_DISCONNECTED);
-
- pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_DISCONNECT], s); =
+ pa_assert(PA_SOURCE_LINKED(s->state));
+
+ pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_UNLINK], s); =
=
pa_namereg_unregister(s->core, s->name);
pa_idxset_remove_by_data(s->core->sources, s, NULL);
@@ -167,7 +193,7 @@
j =3D o;
}
=
- source_set_state(s, PA_SOURCE_DISCONNECTED);
+ source_set_state(s, PA_SOURCE_UNLINKED);
=
s->get_latency =3D NULL;
s->get_volume =3D NULL;
@@ -178,7 +204,7 @@
=
pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE | PA_SUBSCR=
IPTION_EVENT_REMOVE, s->index);
=
- pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_DISCONNECT_POST], s);=
=
+ pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_UNLINK_POST], s); =
}
=
static void source_free(pa_object *o) {
@@ -188,8 +214,8 @@
pa_assert(s);
pa_assert(pa_source_refcnt(s) =3D=3D 0);
=
- if (s->state !=3D PA_SOURCE_DISCONNECTED)
- pa_source_disconnect(s);
+ if (PA_SOURCE_LINKED(s->state))
+ pa_source_unlink(s);
=
pa_log_info("Freeing source %u \"%s\"", s->index, s->name);
=
@@ -208,6 +234,7 @@
=
int pa_source_update_status(pa_source*s) {
pa_source_assert_ref(s);
+ pa_assert(PA_SOURCE_LINKED(s->state));
=
if (s->state =3D=3D PA_SOURCE_SUSPENDED)
return 0;
@@ -217,6 +244,7 @@
=
int pa_source_suspend(pa_source *s, int suspend) {
pa_source_assert_ref(s);
+ pa_assert(PA_SOURCE_LINKED(s->state));
=
if (suspend)
return source_set_state(s, PA_SOURCE_SUSPENDED);
@@ -226,6 +254,7 @@
=
void pa_source_ping(pa_source *s) {
pa_source_assert_ref(s);
+ pa_assert(PA_SOURCE_LINKED(s->state));
=
pa_asyncmsgq_post(s->asyncmsgq, PA_MSGOBJECT(s), PA_SOURCE_MESSAGE_PIN=
G, NULL, 0, NULL, NULL);
}
@@ -235,6 +264,7 @@
void *state =3D NULL;
=
pa_source_assert_ref(s);
+ pa_assert(PA_SOURCE_OPENED(s->thread_info.state));
pa_assert(chunk);
=
if (s->thread_info.state !=3D PA_SOURCE_RUNNING)
@@ -267,6 +297,10 @@
pa_usec_t usec;
=
pa_source_assert_ref(s);
+ pa_assert(PA_SOURCE_LINKED(s->state));
+
+ if (!PA_SOURCE_OPENED(s->state))
+ return 0;
=
if (s->get_latency)
return s->get_latency(s);
@@ -281,6 +315,7 @@
int changed;
=
pa_source_assert_ref(s);
+ pa_assert(PA_SOURCE_LINKED(s->state));
pa_assert(volume);
=
changed =3D !pa_cvolume_equal(volume, &s->volume);
@@ -298,7 +333,9 @@
=
const pa_cvolume *pa_source_get_volume(pa_source *s) {
pa_cvolume old_volume;
- pa_source_assert_ref(s);
+
+ pa_source_assert_ref(s);
+ pa_assert(PA_SOURCE_LINKED(s->state));
=
old_volume =3D s->volume;
=
@@ -318,6 +355,7 @@
int changed;
=
pa_source_assert_ref(s);
+ pa_assert(PA_SOURCE_LINKED(s->state));
=
changed =3D s->muted !=3D mute;
s->muted =3D mute;
@@ -336,6 +374,7 @@
int old_muted;
=
pa_source_assert_ref(s);
+ pa_assert(PA_SOURCE_LINKED(s->state));
=
old_muted =3D s->muted;
=
@@ -384,8 +423,16 @@
s->asyncmsgq =3D q;
}
=
+void pa_source_set_rtpoll(pa_source *s, pa_rtpoll *p) {
+ pa_source_assert_ref(s);
+ pa_assert(p);
+
+ s->rtpoll =3D p;
+}
+
unsigned pa_source_used_by(pa_source *s) {
pa_source_assert_ref(s);
+ pa_assert(PA_SOURCE_LINKED(s->state));
=
return pa_idxset_size(s->outputs);
}
@@ -393,19 +440,28 @@
int pa_source_process_msg(pa_msgobject *object, int code, void *userdata, =
int64_t offset, pa_memchunk *chunk) {
pa_source *s =3D PA_SOURCE(object);
pa_source_assert_ref(s);
+ pa_assert(PA_SOURCE_LINKED(s->thread_info.state));
=
switch ((pa_source_message_t) code) {
case PA_SOURCE_MESSAGE_ADD_OUTPUT: {
pa_source_output *o =3D PA_SOURCE_OUTPUT(userdata);
pa_hashmap_put(s->thread_info.outputs, PA_UINT32_TO_PTR(o->ind=
ex), pa_source_output_ref(o));
+
+ if (o->attach)
+ o->attach(o);
+ =
return 0;
}
=
case PA_SOURCE_MESSAGE_REMOVE_OUTPUT: {
pa_source_output *o =3D PA_SOURCE_OUTPUT(userdata);
+
+ if (o->detach)
+ o->detach(o);
+
if (pa_hashmap_remove(s->thread_info.outputs, PA_UINT32_TO_PTR=
(o->index)))
pa_source_output_unref(o);
- =
+
return 0;
}
=
@@ -452,3 +508,21 @@
=
return ret;
}
+
+int pa_source_process_outputs(pa_source *s) {
+ pa_source_output *o;
+ void *state =3D NULL;
+ int r;
+ =
+ pa_source_assert_ref(s);
+
+ if (!PA_SOURCE_LINKED(s->state))
+ return 0;
+ =
+ while ((o =3D pa_hashmap_iterate(s->thread_info.outputs, &state, NULL)=
))
+ if (o->process)
+ if ((r =3D o->process(o)))
+ return r;
+
+ return 0;
+}
Modified: branches/lennart/src/pulsecore/source.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
source.h?rev=3D1733&root=3Dpulseaudio&r1=3D1732&r2=3D1733&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/source.h (original)
+++ branches/lennart/src/pulsecore/source.h Fri Aug 31 00:57:53 2007
@@ -42,15 +42,25 @@
#include <pulsecore/module.h>
#include <pulsecore/asyncmsgq.h>
#include <pulsecore/msgobject.h>
+#include <pulsecore/rtpoll.h>
=
#define PA_MAX_OUTPUTS_PER_SOURCE 32
=
typedef enum pa_source_state {
+ PA_SOURCE_INIT,
PA_SOURCE_RUNNING,
PA_SOURCE_SUSPENDED,
PA_SOURCE_IDLE,
- PA_SOURCE_DISCONNECTED
+ PA_SOURCE_UNLINKED
} pa_source_state_t;
+
+static inline int PA_SOURCE_OPENED(pa_source_state_t x) {
+ return x =3D=3D PA_SOURCE_RUNNING || x =3D=3D PA_SOURCE_IDLE;
+}
+
+static inline int PA_SOURCE_LINKED(pa_source_state_t x) {
+ return x =3D=3D PA_SOURCE_RUNNING || x =3D=3D PA_SOURCE_IDLE || x =3D=
=3D PA_SOURCE_SUSPENDED;
+}
=
struct pa_source {
pa_msgobject parent;
@@ -58,10 +68,10 @@
uint32_t index;
pa_core *core;
pa_source_state_t state;
+ pa_source_flags_t flags;
=
char *name;
char *description, *driver; /* may be NULL */
- int is_hardware;
=
pa_module *module; /* may be NULL */
=
@@ -76,7 +86,7 @@
int refresh_volume;
int refresh_muted;
=
- int (*set_state)(pa_source*source, pa_source_state_t state); =
/* may be NULL */
+ int (*set_state)(pa_source*source, pa_source_state_t state); /* may be=
NULL */
int (*set_volume)(pa_source *s); /* dito */
int (*get_volume)(pa_source *s); /* dito */
int (*set_mute)(pa_source *s); /* dito */
@@ -84,7 +94,10 @@
pa_usec_t (*get_latency)(pa_source *s); /* dito */
=
pa_asyncmsgq *asyncmsgq;
+ pa_rtpoll *rtpoll;
=
+ /* Contains copies of the above data so that the real-time worker
+ * thread can work without access locking */
struct {
pa_source_state_t state;
pa_hashmap *outputs;
@@ -111,7 +124,7 @@
PA_SOURCE_MESSAGE_MAX
} pa_source_message_t;
=
-/* To be used exclusively by the source driver */
+/* To be called exclusively by the source driver, from main context */
=
pa_source* pa_source_new(
pa_core *core,
@@ -121,18 +134,22 @@
const pa_sample_spec *spec,
const pa_channel_map *map);
=
-void pa_source_disconnect(pa_source *s);
+void pa_source_put(pa_source *s);
+void pa_source_unlink(pa_source *s);
=
void pa_source_set_module(pa_source *s, pa_module *m);
void pa_source_set_description(pa_source *s, const char *description);
void pa_source_set_asyncmsgq(pa_source *s, pa_asyncmsgq *q);
+void pa_source_set_rtpoll(pa_source *s, pa_rtpoll *p);
=
-/* Callable by everyone */
+/* May be called by everyone, from main context */
=
pa_usec_t pa_source_get_latency(pa_source *s);
=
int pa_source_update_status(pa_source*s);
int pa_source_suspend(pa_source *s, int suspend);
+int pa_source_suspend_all(pa_core *c, int suspend);
+
void pa_source_ping(pa_source *s);
=
void pa_source_set_volume(pa_source *source, const pa_cvolume *volume);
@@ -143,15 +160,12 @@
unsigned pa_source_used_by(pa_source *s);
#define pa_source_get_state(s) ((pa_source_state_t) (s)->state)
=
-/* To be used exclusively by the source driver thread */
+/* To be called exclusively by the source driver, from IO context */
=
void pa_source_post(pa_source*s, const pa_memchunk *b);
+
+int pa_source_process_outputs(pa_source *o);
+
int pa_source_process_msg(pa_msgobject *o, int code, void *userdata, int64=
_t, pa_memchunk *chunk);
=
-static inline int PA_SOURCE_OPENED(pa_source_state_t x) {
- return x =3D=3D PA_SOURCE_RUNNING || x =3D=3D PA_SOURCE_IDLE;
-}
-
-int pa_source_suspend_all(pa_core *c, int suspend);
-
#endif
More information about the pulseaudio-commits
mailing list