static bool httpd_output_open(struct audio_output *ao, struct audio_format *audio_format, GError **error) { struct httpd_output *httpd = (struct httpd_output *)ao; bool success; g_mutex_lock(httpd->mutex); /* open the encoder */ success = httpd_output_encoder_open(httpd, audio_format, error); if (!success) { g_mutex_unlock(httpd->mutex); return false; } /* initialize other attributes */ httpd->clients = NULL; httpd->clients_cnt = 0; httpd->timer = timer_new(audio_format); httpd->open = true; g_mutex_unlock(httpd->mutex); return true; }
static bool httpd_output_open(void *data, struct audio_format *audio_format, GError **error) { struct httpd_output *httpd = data; bool success; GIOChannel *channel; g_mutex_lock(httpd->mutex); /* create and set up listener socket */ httpd->fd = socket_bind_listen(PF_INET, SOCK_STREAM, 0, (struct sockaddr *)&httpd->address, httpd->address_size, 16, error); if (httpd->fd < 0) { g_mutex_unlock(httpd->mutex); return false; } channel = g_io_channel_unix_new(httpd->fd); httpd->source_id = g_io_add_watch(channel, G_IO_IN, httpd_listen_in_event, httpd); g_io_channel_unref(channel); /* open the encoder */ success = httpd_output_encoder_open(httpd, audio_format, error); if (!success) { g_source_remove(httpd->source_id); close(httpd->fd); g_mutex_unlock(httpd->mutex); return false; } /* initialize other attributes */ httpd->clients = NULL; httpd->timer = timer_new(audio_format); g_mutex_unlock(httpd->mutex); return true; }