- }
-
- if ((events & PA_MAINLOOP_API_IO_EVENT_INPUT) && !io->readable) {
- io->readable = 1;
- changed = 1;
- assert(id == io->input_source);
- }
-
- if ((events & PA_MAINLOOP_API_IO_EVENT_OUTPUT) && !io->writable) {
- io->writable = 1;
- changed = 1;
- assert(id == io->output_source);
+
+ 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);
+ }