[pulseaudio-commits] r1957 - in /branches/lennart/src/pulsecore: iochannel.c iochannel.h pstream.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Sat Oct 27 06:00:00 PDT 2007
Author: lennart
Date: Sat Oct 27 14:59:59 2007
New Revision: 1957
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1957&root=pulseaudio&view=rev
Log:
modernize pa_iochannel a bit, add pa_iochannel_get_send_fd()
Modified:
branches/lennart/src/pulsecore/iochannel.c
branches/lennart/src/pulsecore/iochannel.h
branches/lennart/src/pulsecore/pstream.c
Modified: branches/lennart/src/pulsecore/iochannel.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/iochannel.c?rev=1957&root=pulseaudio&r1=1956&r2=1957&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/iochannel.c (original)
+++ branches/lennart/src/pulsecore/iochannel.c Sat Oct 27 14:59:59 2007
@@ -58,11 +58,11 @@
pa_iochannel_cb_t callback;
void*userdata;
- int readable;
- int writable;
- int hungup;
-
- int no_close;
+ pa_bool_t readable;
+ pa_bool_t writable;
+ pa_bool_t hungup;
+
+ pa_bool_t no_close;
pa_io_event* input_event, *output_event;
};
@@ -90,7 +90,7 @@
static void callback(pa_mainloop_api* m, pa_io_event *e, int fd, pa_io_event_flags_t f, void *userdata) {
pa_iochannel *io = userdata;
- int changed = 0;
+ pa_bool_t changed = FALSE;
pa_assert(m);
pa_assert(e);
@@ -98,19 +98,19 @@
pa_assert(userdata);
if ((f & (PA_IO_EVENT_HANGUP|PA_IO_EVENT_ERROR)) && !io->hungup) {
- io->hungup = 1;
- changed = 1;
+ io->hungup = TRUE;
+ changed = TRUE;
}
if ((f & PA_IO_EVENT_INPUT) && !io->readable) {
- io->readable = 1;
- changed = 1;
+ io->readable = TRUE;
+ changed = TRUE;
pa_assert(e == io->input_event);
}
if ((f & PA_IO_EVENT_OUTPUT) && !io->writable) {
- io->writable = 1;
- changed = 1;
+ io->writable = TRUE;
+ changed = TRUE;
pa_assert(e == io->output_event);
}
@@ -136,10 +136,10 @@
io->userdata = NULL;
io->callback = NULL;
- io->readable = 0;
- io->writable = 0;
- io->hungup = 0;
- io->no_close = 0;
+ io->readable = FALSE;
+ io->writable = FALSE;
+ io->hungup = FALSE;
+ io->no_close = FALSE;
io->input_event = io->output_event = NULL;
@@ -182,19 +182,19 @@
pa_xfree(io);
}
-int pa_iochannel_is_readable(pa_iochannel*io) {
+pa_bool_t pa_iochannel_is_readable(pa_iochannel*io) {
pa_assert(io);
return io->readable || io->hungup;
}
-int pa_iochannel_is_writable(pa_iochannel*io) {
+pa_bool_t pa_iochannel_is_writable(pa_iochannel*io) {
pa_assert(io);
return io->writable && !io->hungup;
}
-int pa_iochannel_is_hungup(pa_iochannel*io) {
+pa_bool_t pa_iochannel_is_hungup(pa_iochannel*io) {
pa_assert(io);
return io->hungup;
@@ -208,9 +208,8 @@
pa_assert(l);
pa_assert(io->ofd >= 0);
- r = pa_write(io->ofd, data, l, &io->ofd_type);
- if (r >= 0) {
- io->writable = 0;
+ if ((r = pa_write(io->ofd, data, l, &io->ofd_type)) >= 0) {
+ io->writable = FALSE;
enable_mainloop_sources(io);
}
@@ -224,9 +223,8 @@
pa_assert(data);
pa_assert(io->ifd >= 0);
- r = pa_read(io->ifd, data, l, &io->ifd_type);
- if (r >= 0) {
- io->readable = 0;
+ if ((r = pa_read(io->ifd, data, l, &io->ifd_type)) >= 0) {
+ io->readable = FALSE;
enable_mainloop_sources(io);
}
@@ -235,7 +233,7 @@
#ifdef HAVE_CREDS
-int pa_iochannel_creds_supported(pa_iochannel *io) {
+pa_bool_t pa_iochannel_creds_supported(pa_iochannel *io) {
struct sockaddr_un sa;
socklen_t l;
@@ -309,14 +307,14 @@
mh.msg_flags = 0;
if ((r = sendmsg(io->ofd, &mh, MSG_NOSIGNAL)) >= 0) {
- io->writable = 0;
+ io->writable = FALSE;
enable_mainloop_sources(io);
}
return r;
}
-ssize_t pa_iochannel_read_with_creds(pa_iochannel*io, void*data, size_t l, pa_creds *creds, int *creds_valid) {
+ssize_t pa_iochannel_read_with_creds(pa_iochannel*io, void*data, size_t l, pa_creds *creds, pa_bool_t *creds_valid) {
ssize_t r;
struct msghdr mh;
struct iovec iov;
@@ -358,12 +356,12 @@
creds->gid = u.gid;
creds->uid = u.uid;
- *creds_valid = 1;
+ *creds_valid = TRUE;
break;
}
}
- io->readable = 0;
+ io->readable = FALSE;
enable_mainloop_sources(io);
}
@@ -379,10 +377,10 @@
io->userdata = userdata;
}
-void pa_iochannel_set_noclose(pa_iochannel*io, int b) {
- pa_assert(io);
-
- io->no_close = b;
+void pa_iochannel_set_noclose(pa_iochannel*io, pa_bool_t b) {
+ pa_assert(io);
+
+ io->no_close = !!b;
}
void pa_iochannel_socket_peer_to_string(pa_iochannel*io, char*s, size_t l) {
@@ -416,3 +414,9 @@
return io->ifd;
}
+
+int pa_iochannel_get_send_fd(pa_iochannel *io) {
+ pa_assert(io);
+
+ return io->ofd;
+}
Modified: branches/lennart/src/pulsecore/iochannel.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/iochannel.h?rev=1957&root=pulseaudio&r1=1956&r2=1957&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/iochannel.h (original)
+++ branches/lennart/src/pulsecore/iochannel.h Sat Oct 27 14:59:59 2007
@@ -33,6 +33,7 @@
#include <pulse/mainloop-api.h>
#include <pulsecore/creds.h>
+#include <pulsecore/macro.h>
/* A wrapper around UNIX file descriptors for attaching them to the a
main event loop. Everytime new data may be read or be written to
@@ -58,20 +59,20 @@
ssize_t pa_iochannel_read(pa_iochannel*io, void*data, size_t l);
#ifdef HAVE_CREDS
-int pa_iochannel_creds_supported(pa_iochannel *io);
+pa_bool_t pa_iochannel_creds_supported(pa_iochannel *io);
int pa_iochannel_creds_enable(pa_iochannel *io);
ssize_t pa_iochannel_write_with_creds(pa_iochannel*io, const void*data, size_t l, const pa_creds *ucred);
-ssize_t pa_iochannel_read_with_creds(pa_iochannel*io, void*data, size_t l, pa_creds *ucred, int *creds_valid);
+ssize_t pa_iochannel_read_with_creds(pa_iochannel*io, void*data, size_t l, pa_creds *ucred, pa_bool_t *creds_valid);
#endif
-int pa_iochannel_is_readable(pa_iochannel*io);
-int pa_iochannel_is_writable(pa_iochannel*io);
-int pa_iochannel_is_hungup(pa_iochannel*io);
+pa_bool_t pa_iochannel_is_readable(pa_iochannel*io);
+pa_bool_t pa_iochannel_is_writable(pa_iochannel*io);
+pa_bool_t pa_iochannel_is_hungup(pa_iochannel*io);
/* Don't close the file descirptors when the io channel is freed. By
* default the file descriptors are closed. */
-void pa_iochannel_set_noclose(pa_iochannel*io, int b);
+void pa_iochannel_set_noclose(pa_iochannel*io, pa_bool_t b);
/* Set the callback function that is called whenever data becomes available for read or write */
typedef void (*pa_iochannel_cb_t)(pa_iochannel*io, void *userdata);
@@ -87,5 +88,6 @@
pa_mainloop_api* pa_iochannel_get_mainloop_api(pa_iochannel *io);
int pa_iochannel_get_recv_fd(pa_iochannel *io);
+int pa_iochannel_get_send_fd(pa_iochannel *io);
#endif
Modified: branches/lennart/src/pulsecore/pstream.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/pstream.c?rev=1957&root=pulseaudio&r1=1956&r2=1957&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/pstream.c (original)
+++ branches/lennart/src/pulsecore/pstream.c Sat Oct 27 14:59:59 2007
@@ -217,12 +217,12 @@
static void defer_callback(pa_mainloop_api *m, pa_defer_event *e, void*userdata) {
pa_pstream *p = userdata;
-
+
pa_assert(p);
pa_assert(PA_REFCNT_VALUE(p) > 0);
pa_assert(p->defer_event == e);
pa_assert(p->mainloop == m);
-
+
do_something(p);
}
@@ -244,7 +244,7 @@
p->mainloop = m;
p->defer_event = m->defer_new(m, defer_callback, p);
m->defer_enable(p->defer_event, 0);
-
+
p->send_queue = pa_queue_new();
p->write.current = NULL;
@@ -266,7 +266,7 @@
p->revoke_callback_userdata = NULL;
p->release_callback = NULL;
p->release_callback_userdata = NULL;
-
+
p->mempool = pool;
p->use_shm = 0;
@@ -335,7 +335,7 @@
if (!(i = pa_flist_pop(PA_STATIC_FLIST_GET(items))))
i = pa_xnew(struct item_info, 1);
-
+
i->type = PA_PSTREAM_ITEM_PACKET;
i->packet = pa_packet_ref(packet);
@@ -365,7 +365,7 @@
length = chunk->length;
bsm = pa_mempool_block_size_max(p->mempool);
-
+
while (length > 0) {
struct item_info *i;
size_t n;
@@ -662,7 +662,7 @@
#ifdef HAVE_CREDS
{
- int b = 0;
+ pa_bool_t b = 0;
if ((r = pa_iochannel_read_with_creds(p->io, d, l, &p->read_creds, &b)) <= 0)
goto fail;
@@ -970,7 +970,7 @@
if (p->dead)
return;
-
+
p->dead = 1;
if (p->import) {
@@ -991,7 +991,7 @@
if (p->defer_event) {
p->mainloop->defer_free(p->defer_event);
p->defer_event = NULL;
- }
+ }
p->die_callback = NULL;
p->drain_callback = NULL;
More information about the pulseaudio-commits
mailing list