Add raop_is_running function.
authorJuho Vähä-Herttua <juhovh@iki.fi>
Wed, 28 Mar 2012 20:33:47 +0000 (23:33 +0300)
committerJuho Vähä-Herttua <juhovh@iki.fi>
Wed, 16 May 2012 21:33:32 +0000 (00:33 +0300)
src/include/raop.h
src/lib/httpd.c
src/lib/httpd.h
src/lib/raop.c

index 01d03eab8b56a177cd0e835ade69a0f1d15284e3..e5158cb2634bce4fc156241a26ea095111ce2185 100644 (file)
@@ -26,6 +26,8 @@ typedef struct raop_callbacks_s raop_callbacks_t;
 RAOP_API raop_t *raop_init(raop_callbacks_t *callbacks, const char *pemkey);
 RAOP_API raop_t *raop_init_from_keyfile(raop_callbacks_t *callbacks, const char *keyfile);
 
+RAOP_API int raop_is_running(raop_t *raop);
+
 RAOP_API int raop_start(raop_t *raop, unsigned short *port, const char *hwaddr, int hwaddrlen, const char *password);
 RAOP_API void raop_stop(raop_t *raop);
 
index 8a3844329d86fde041d4d83b14182e7ff7a2076b..0dbc84776caf8b5383ac7e90718ff3055bcb098f 100644 (file)
@@ -336,6 +336,20 @@ httpd_start(httpd_t *httpd, unsigned short *port)
        return 1;
 }
 
+int
+httpd_is_running(httpd_t *httpd)
+{
+       int running;
+
+       assert(httpd);
+
+       MUTEX_LOCK(httpd->run_mutex);
+       running = httpd->running || !httpd->joined;
+       MUTEX_UNLOCK(httpd->run_mutex);
+
+       return running;
+}
+
 void
 httpd_stop(httpd_t *httpd)
 {
index ef9fecc232f459269f31e321042eef23144e9215..887778d49f10d5e7a39e533967f86cf65436e8f4 100644 (file)
@@ -32,6 +32,8 @@ typedef struct httpd_callbacks_s httpd_callbacks_t;
 
 httpd_t *httpd_init(logger_t *logger, httpd_callbacks_t *callbacks, int max_connections, int use_rtsp);
 
+int httpd_is_running(httpd_t *httpd);
+
 int httpd_start(httpd_t *httpd, unsigned short *port);
 void httpd_stop(httpd_t *httpd);
 
index 8ddb0887e8b541d486f739f28970ececc4836192..fe57735329f95d6a9f672d4054a56a383b29312f 100644 (file)
@@ -429,6 +429,14 @@ raop_destroy(raop_t *raop)
        }
 }
 
+int
+raop_is_running(raop_t *raop)
+{
+       assert(raop);
+
+       return httpd_is_running(raop->httpd);
+}
+
 int
 raop_start(raop_t *raop, unsigned short *port, const char *hwaddr, int hwaddrlen, const char *password)
 {