This file is part of polypaudio.
polypaudio is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2 of the License,
- or (at your option) any later version.
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
polypaudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with polypaudio; if not, write to the Free Software
+ You should have received a copy of the GNU Lesser General Public
+ License along with polypaudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
***/
static void enable_mainloop_sources(struct pa_iochannel *io) {
assert(io);
- if (io->input_event == io->output_event) {
+ if (io->input_event == io->output_event && io->input_event) {
enum pa_io_event_flags f = PA_IO_EVENT_NULL;
assert(io->input_event);
if ((f & (PA_IO_EVENT_HANGUP|PA_IO_EVENT_ERROR)) && !io->hungup) {
io->hungup = 1;
changed = 1;
- }
-
- if ((f & PA_IO_EVENT_INPUT) && !io->readable) {
- io->readable = 1;
- changed = 1;
- assert(e == io->input_event);
- }
-
- if ((f & PA_IO_EVENT_OUTPUT) && !io->writable) {
- io->writable = 1;
- changed = 1;
- assert(e == io->output_event);
+
+ if (e == io->input_event) {
+ io->mainloop->io_free(io->input_event);
+ io->input_event = NULL;
+ }
+
+ if (e == io->output_event) {
+ io->mainloop->io_free(io->output_event);
+ io->output_event = NULL;
+ }
+ } else {
+
+ if ((f & PA_IO_EVENT_INPUT) && !io->readable) {
+ io->readable = 1;
+ changed = 1;
+ assert(e == io->input_event);
+ }
+
+ if ((f & PA_IO_EVENT_OUTPUT) && !io->writable) {
+ io->writable = 1;
+ changed = 1;
+ assert(e == io->output_event);
+ }
}
if (changed) {
int pa_iochannel_is_readable(struct pa_iochannel*io) {
assert(io);
- return io->readable;
+ return io->readable || io->hungup;
}
int pa_iochannel_is_writable(struct pa_iochannel*io) {
assert(io);
- return io->writable;
+ return io->writable && !io->hungup;
}
int pa_iochannel_is_hungup(struct pa_iochannel*io) {
ssize_t pa_iochannel_read(struct pa_iochannel*io, void*data, size_t l) {
ssize_t r;
-
assert(io && data && io->ifd >= 0);
if ((r = read(io->ifd, data, l)) >= 0) {
assert(io);
return pa_socket_set_sndbuf(io->ofd, l);
}
+