[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.19-478-g0b3d7c6
Lennart Poettering
gitmailer-noreply at 0pointer.de
Sun Feb 21 13:01:03 PST 2010
This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.
The master branch has been updated
from ebf2116810fa8f18baf1fa693eaf35a8a83109ee (commit)
- Log -----------------------------------------------------------------
0b3d7c6 alsa-util: strip spaces from ALSA card/pcm names
0c7c965 conf-parser: make use of pa_strip() wherever applicable
f1af7a0 core-util: introduce generic function pa_strip()
f8aceaf http: support HTTP HEAD
-----------------------------------------------------------------------
Summary of changes:
src/modules/alsa/alsa-util.c | 12 ++++++----
src/pulsecore/conf-parser.c | 31 +-------------------------
src/pulsecore/core-util.c | 28 +++++++++++++++++++++---
src/pulsecore/core-util.h | 1 +
src/pulsecore/protocol-http.c | 47 ++++++++++++++++++++++++++++++++++++++--
5 files changed, 78 insertions(+), 41 deletions(-)
-----------------------------------------------------------------------
commit f8aceafb1321fb2254f6cafea25c14f07a78ad49
Author: Matthijs Kooijman <matthijs at stdin.nl>
Date: Sun Feb 21 21:46:06 2010 +0100
http: support HTTP HEAD
http://pulseaudio.org/ticket/781
diff --git a/src/pulsecore/protocol-http.c b/src/pulsecore/protocol-http.c
index c09e534..83067f8 100644
--- a/src/pulsecore/protocol-http.c
+++ b/src/pulsecore/protocol-http.c
@@ -80,6 +80,11 @@ enum state {
STATE_DATA
};
+enum method {
+ METHOD_GET,
+ METHOD_HEAD
+};
+
struct connection {
pa_http_protocol *protocol;
pa_iochannel *io;
@@ -89,6 +94,7 @@ struct connection {
pa_client *client;
enum state state;
char *url;
+ enum method method;
pa_module *module;
};
@@ -327,6 +333,11 @@ static void html_response(
http_response(c, code, msg, MIME_HTML);
+ if (c->method == METHOD_HEAD) {
+ pa_ioline_defer_close(c->line);
+ return;
+ }
+
if (!text)
text = msg;
@@ -363,6 +374,11 @@ static void handle_root(struct connection *c) {
http_response(c, 200, "OK", MIME_HTML);
+ if (c->method == METHOD_HEAD) {
+ pa_ioline_defer_close(c->line);
+ return;
+ }
+
pa_ioline_puts(c->line,
HTML_HEADER(PACKAGE_NAME" "PACKAGE_VERSION)
"<h1>"PACKAGE_NAME" "PACKAGE_VERSION"</h1>\n"
@@ -402,6 +418,11 @@ static void handle_css(struct connection *c) {
http_response(c, 200, "OK", MIME_CSS);
+ if (c->method == METHOD_HEAD) {
+ pa_ioline_defer_close(c->line);
+ return;
+ }
+
pa_ioline_puts(c->line,
"body { color: black; background-color: white; }\n"
"a:link, a:visited { color: #900000; }\n"
@@ -420,6 +441,12 @@ static void handle_status(struct connection *c) {
pa_assert(c);
http_response(c, 200, "OK", MIME_TEXT);
+
+ if (c->method == METHOD_HEAD) {
+ pa_ioline_defer_close(c->line);
+ return;
+ }
+
r = pa_full_status_string(c->protocol->core);
pa_ioline_puts(c->line, r);
pa_xfree(r);
@@ -439,6 +466,11 @@ static void handle_listen(struct connection *c) {
"<h2>Sinks</h2>\n"
"<p>\n");
+ if (c->method == METHOD_HEAD) {
+ pa_ioline_defer_close(c->line);
+ return;
+ }
+
PA_IDXSET_FOREACH(sink, c->protocol->core->sinks, idx) {
char *t, *m;
@@ -566,6 +598,10 @@ static void handle_listen_prefix(struct connection *c, const char *source_name)
http_response(c, 200, "OK", t);
pa_xfree(t);
+ if(c->method == METHOD_HEAD) {
+ connection_unlink(c);
+ return;
+ }
pa_ioline_set_callback(c->line, NULL, NULL);
if (pa_ioline_is_drained(c->line))
@@ -606,10 +642,15 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) {
switch (c->state) {
case STATE_REQUEST_LINE: {
- if (!pa_startswith(s, "GET "))
+ if (pa_startswith(s, "GET ")) {
+ c->method = METHOD_GET;
+ s +=4;
+ } else if (pa_startswith(s, "HEAD ")) {
+ c->method = METHOD_HEAD;
+ s +=5;
+ } else {
goto fail;
-
- s +=4;
+ }
c->url = pa_xstrndup(s, strcspn(s, " \r\n\t?"));
c->state = STATE_MIME_HEADER;
commit f1af7a02d12b29a63b5015aaef7f162b3fc7acb4
Author: Lennart Poettering <lennart at poettering.net>
Date: Sun Feb 21 21:59:53 2010 +0100
core-util: introduce generic function pa_strip()
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index b64c51e..323c98d 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -126,6 +126,9 @@
#define MSG_NOSIGNAL 0
#endif
+#define NEWLINE "\r\n"
+#define WHITESPACE "\n\r \t"
+
static pa_strlist *recorded_env = NULL;
#ifdef OS_IS_WIN32
@@ -830,9 +833,6 @@ char *pa_split(const char *c, const char *delimiter, const char**state) {
return pa_xstrndup(current, l);
}
-/* What is interpreted as whitespace? */
-#define WHITESPACE " \t\n"
-
/* Split a string into words. Otherwise similar to pa_split(). */
char *pa_split_spaces(const char *c, const char **state) {
const char *current = *state ? *state : c;
@@ -1189,7 +1189,27 @@ int pa_lock_fd(int fd, int b) {
char* pa_strip_nl(char *s) {
pa_assert(s);
- s[strcspn(s, "\r\n")] = 0;
+ s[strcspn(s, NEWLINE)] = 0;
+ return s;
+}
+
+char *pa_strip(char *s) {
+ char *e, *l = NULL;
+
+ /* Drops trailing whitespace. Modifies the string in
+ * place. Returns pointer to first non-space character */
+
+ s += strspn(s, WHITESPACE);
+
+ for (e = s; *e; e++)
+ if (!strchr(WHITESPACE, *e))
+ l = e;
+
+ if (l)
+ *(l+1) = 0;
+ else
+ *s = 0;
+
return s;
}
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index 31a83bc..0d63cfc 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -103,6 +103,7 @@ char *pa_split(const char *c, const char*delimiters, const char **state);
char *pa_split_spaces(const char *c, const char **state);
char *pa_strip_nl(char *s);
+char *pa_strip(char *s);
const char *pa_sig2str(int sig) PA_GCC_PURE;
commit 0c7c9653b10ce2ca6f48b36290d5c6864aaf8bc9
Author: Lennart Poettering <lennart at poettering.net>
Date: Sun Feb 21 22:00:16 2010 +0100
conf-parser: make use of pa_strip() wherever applicable
diff --git a/src/pulsecore/conf-parser.c b/src/pulsecore/conf-parser.c
index 34b4d6f..7152955 100644
--- a/src/pulsecore/conf-parser.c
+++ b/src/pulsecore/conf-parser.c
@@ -73,33 +73,6 @@ static int next_assignment(
return -1;
}
-/* Returns non-zero when c is contained in s */
-static int in_string(char c, const char *s) {
- pa_assert(s);
-
- for (; *s; s++)
- if (*s == c)
- return 1;
-
- return 0;
-}
-
-/* Remove all whitepsapce from the beginning and the end of *s. *s may
- * be modified. */
-static char *strip(char *s) {
- char *b = s+strspn(s, WHITESPACE);
- char *e, *l = NULL;
-
- for (e = b; *e; e++)
- if (!in_string(*e, WHITESPACE))
- l = e;
-
- if (l)
- *(l+1) = 0;
-
- return b;
-}
-
/* Parse a variable assignment line */
static int parse_line(const char *filename, unsigned line, char **section, const pa_config_item *t, char *l, void *userdata) {
char *e, *c, *b;
@@ -116,7 +89,7 @@ static int parse_line(const char *filename, unsigned line, char **section, const
char *path = NULL, *fn;
int r;
- fn = strip(b+9);
+ fn = pa_strip(b+9);
if (!pa_is_path_absolute(fn)) {
const char *k;
if ((k = strrchr(filename, '/'))) {
@@ -155,7 +128,7 @@ static int parse_line(const char *filename, unsigned line, char **section, const
*e = 0;
e++;
- return next_assignment(filename, line, *section, t, strip(b), strip(e), userdata);
+ return next_assignment(filename, line, *section, t, pa_strip(b), pa_strip(e), userdata);
}
/* Go through the file and parse each line */
commit 0b3d7c637cc9a65bf28f6fe8dac1629d1fa0ee6c
Author: Lennart Poettering <lennart at poettering.net>
Date: Sun Feb 21 22:00:49 2010 +0100
alsa-util: strip spaces from ALSA card/pcm names
http://pulseaudio.org/ticket/778
diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index 52f1259..1cbb3f3 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -874,12 +874,12 @@ void pa_alsa_init_proplist_card(pa_core *c, pa_proplist *p, int card) {
pa_proplist_setf(p, "alsa.card", "%i", card);
if (snd_card_get_name(card, &cn) >= 0) {
- pa_proplist_sets(p, "alsa.card_name", cn);
+ pa_proplist_sets(p, "alsa.card_name", pa_strip(cn));
free(cn);
}
if (snd_card_get_longname(card, &lcn) >= 0) {
- pa_proplist_sets(p, "alsa.long_card_name", lcn);
+ pa_proplist_sets(p, "alsa.long_card_name", pa_strip(lcn));
free(lcn);
}
@@ -937,8 +937,11 @@ void pa_alsa_init_proplist_pcm_info(pa_core *c, pa_proplist *p, snd_pcm_info_t *
if (alsa_subclass_table[subclass])
pa_proplist_sets(p, "alsa.subclass", alsa_subclass_table[subclass]);
- if ((n = snd_pcm_info_get_name(pcm_info)))
- pa_proplist_sets(p, "alsa.name", n);
+ if ((n = snd_pcm_info_get_name(pcm_info))) {
+ char *t = pa_xstrdup(n);
+ pa_proplist_sets(p, "alsa.name", pa_strip(t));
+ pa_xfree(t);
+ }
if ((id = snd_pcm_info_get_id(pcm_info)))
pa_proplist_sets(p, "alsa.id", id);
@@ -1331,6 +1334,5 @@ pa_bool_t pa_alsa_may_tsched(pa_bool_t want) {
return FALSE;
}
-
return TRUE;
}
--
hooks/post-receive
PulseAudio Sound Server
More information about the pulseaudio-commits
mailing list