diff options
author | Christian Pointner <equinox@spreadspace.org> | 2011-06-08 22:18:42 +0000 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2011-06-08 22:18:42 +0000 |
commit | aa33711bd59d5064fd9d45ecca34ad69bf7afbdb (patch) | |
tree | 857edec1273860a481a2f8fcaba427362195dc23 /src/streamer.c | |
parent | num_fds not in all older versions of gstreamer multifdsink (diff) |
client handling in seperate thread
Diffstat (limited to 'src/streamer.c')
-rw-r--r-- | src/streamer.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/streamer.c b/src/streamer.c index c5052e5..4130a89 100644 --- a/src/streamer.c +++ b/src/streamer.c @@ -138,6 +138,18 @@ static void remove_fd(streamer_t* streamer, int fd) log_printf(INFO, "removing fd %d from fdsink", fd); g_signal_emit_by_name(G_OBJECT(streamer->sink_), "remove-flush", fd, NULL); } + +struct client_struct { + int fd_; + streamer_t* streamer_; +}; + +static gpointer client_thread_func(gpointer data) +{ + struct client_struct *client = (struct client_struct*)data; + add_fd(client->streamer_, client->fd_); + free(client); +} static gpointer streamer_thread_func(gpointer data) { @@ -154,8 +166,15 @@ static gpointer streamer_thread_func(gpointer data) log_printf(ERROR, "accept() call failed"); break; } - log_printf(INFO, "new connection %s:%d (fd=%d)", inet_ntoa(remote_addr.sin_addr), ntohs(remote_addr.sin_port), new_client); - add_fd(streamer, new_client); + log_printf(INFO, "streamer: new connection %s:%d (fd=%d)", inet_ntoa(remote_addr.sin_addr), ntohs(remote_addr.sin_port), new_client); + struct client_struct* client = malloc(sizeof(struct client_struct)); + if(!client) { + log_printf(ERROR, "streamer: memory error"); + break; + } + client->fd_ = new_client; + client->streamer_ = streamer; + g_thread_create(client_thread_func, client, FALSE, NULL); } log_printf(NOTICE, "streamer thread stopped"); |