summaryrefslogtreecommitdiff
path: root/apps/osc.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/osc.c')
-rw-r--r--apps/osc.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/apps/osc.c b/apps/osc.c
index 9172625..656d400 100644
--- a/apps/osc.c
+++ b/apps/osc.c
@@ -87,6 +87,12 @@ int osc_init(osc_t* o, const char* port)
{
assert(o != NULL);
+ o->server_ = NULL;
+ slist_init(&(o->done_data_), free_osc_done_data);
+
+ if(!port)
+ return 0;
+
o->server_ = lo_server_new(port, print_error);
if(!o->server_)
return -1;
@@ -94,20 +100,26 @@ int osc_init(osc_t* o, const char* port)
if(!lo_server_add_method(o->server_, "/lang/switch", "s", lang_handler, (void*)o))
return -1;
- slist_init(&(o->done_data_), free_osc_done_data);
-
return 0;
}
int osc_get_poll_fd_count(osc_t* o)
{
+ assert(o);
+
+ if(!o->server_)
+ return 0;
+
return 1;
}
int osc_get_poll_fds(osc_t* o, struct pollfd *pfds, int npfds)
{
- assert(o && pfds && npfds == 1);
+ assert(o);
+
+ if(!o->server_)
+ return 0;
pfds[0].fd = lo_server_get_socket_fd(o->server_);
pfds[0].events = POLLIN;
@@ -118,7 +130,10 @@ int osc_get_poll_fds(osc_t* o, struct pollfd *pfds, int npfds)
int osc_handle_revents(osc_t* o, struct pollfd *pfds, int npfds, mixer_t* x)
{
- assert(o && pfds && npfds == 1);
+ assert(o);
+
+ if(!o->server_)
+ return 0;
if(pfds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) {
error(0, 0, "OSC: got POLLERR, POLLHUP or POLLNVAL");