/* GStreamer
- * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005-2009> Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
{
guint left;
- if (*idx > size)
+ if (G_UNLIKELY (*idx > size))
return GST_RTSP_ERROR;
left = size - *idx;
gint r;
r = WRITE_SOCKET (fd, &buffer[*idx], left);
- if (r == 0) {
+ if (G_UNLIKELY (r == 0)) {
return GST_RTSP_EINTR;
- } else if (r < 0) {
+ } else if (G_UNLIKELY (r < 0)) {
if (ERRNO_IS_EAGAIN)
return GST_RTSP_EINTR;
if (!ERRNO_IS_EINTR)
{
guint left;
- if (*idx > size)
+ if (G_UNLIKELY (*idx > size))
return GST_RTSP_ERROR;
left = size - *idx;
gint r;
r = fill_bytes (fd, &buffer[*idx], left, ctx);
- if (r == 0) {
+ if (G_UNLIKELY (r == 0)) {
return GST_RTSP_EEOF;
- } else if (r < 0) {
+ } else if (G_UNLIKELY (r < 0)) {
if (ERRNO_IS_EAGAIN)
return GST_RTSP_EINTR;
if (!ERRNO_IS_EINTR)
gint r;
r = fill_bytes (fd, &c, 1, ctx);
- if (r == 0) {
+ if (G_UNLIKELY (r == 0)) {
return GST_RTSP_EEOF;
- } else if (r < 0) {
+ } else if (G_UNLIKELY (r < 0)) {
if (ERRNO_IS_EAGAIN)
return GST_RTSP_EINTR;
if (!ERRNO_IS_EINTR)
if (c == '\r') /* ignore \r */
continue;
- if (*idx < size - 1)
+ if (G_LIKELY (*idx < size - 1))
buffer[(*idx)++] = c;
}
}
while (TRUE) {
/* try to write */
res = write_bytes (conn->writefd->fd, data, &offset, size);
- if (res == GST_RTSP_OK)
+ if (G_LIKELY (res == GST_RTSP_OK))
break;
- if (res != GST_RTSP_EINTR)
+ if (G_UNLIKELY (res != GST_RTSP_EINTR))
goto write_error;
/* not all is written, wait until we can write more */
retval = gst_poll_wait (conn->fdset, to);
} while (retval == -1 && (errno == EINTR || errno == EAGAIN));
- if (retval == 0)
+ if (G_UNLIKELY (retval == 0))
goto timeout;
- if (retval == -1) {
+ if (G_UNLIKELY (retval == -1)) {
if (errno == EBUSY)
goto stopped;
else
g_return_val_if_fail (conn != NULL, GST_RTSP_EINVAL);
g_return_val_if_fail (message != NULL, GST_RTSP_EINVAL);
- if (!(string = message_to_string (conn, message)))
+ if (G_UNLIKELY (!(string = message_to_string (conn, message))))
goto no_message;
if (conn->tunneled) {
}
parse_string (urlstr, sizeof (urlstr), &bptr);
- if (*urlstr == '\0')
+ if (G_UNLIKELY (*urlstr == '\0'))
goto invalid_url;
parse_string (versionstr, sizeof (versionstr), &bptr);
- if (*bptr != '\0')
+ if (G_UNLIKELY (*bptr != '\0'))
goto invalid_version;
if (strcmp (versionstr, "RTSP/1.0") == 0) {
/* read key */
parse_key (key, keysize, &bptr);
- if (*bptr != ':')
+ if (G_UNLIKELY (*bptr != ':'))
goto no_column;
bptr++;
GstRTSPHeaderField field;
res = parse_key_value (buffer, key, sizeof (key), &value);
- if (res != GST_RTSP_OK)
+ if (G_UNLIKELY (res != GST_RTSP_OK))
goto parse_error;
if (conn->tstate == TUNNEL_STATE_GET || conn->tstate == TUNNEL_STATE_POST) {
g_return_val_if_fail (data != NULL, GST_RTSP_EINVAL);
g_return_val_if_fail (conn->readfd != NULL, GST_RTSP_EINVAL);
- if (size == 0)
+ if (G_UNLIKELY (size == 0))
return GST_RTSP_OK;
offset = 0;
while (TRUE) {
res = read_bytes (conn->readfd->fd, data, &offset, size, conn->ctxp);
- if (res == GST_RTSP_EEOF)
+ if (G_UNLIKELY (res == GST_RTSP_EEOF))
goto eof;
- if (res == GST_RTSP_OK)
+ if (G_LIKELY (res == GST_RTSP_OK))
break;
- if (res != GST_RTSP_EINTR)
+ if (G_UNLIKELY (res != GST_RTSP_EINTR))
goto read_error;
do {
} while (retval == -1 && (errno == EINTR || errno == EAGAIN));
/* check for timeout */
- if (retval == 0)
+ if (G_UNLIKELY (retval == 0))
goto select_timeout;
- if (retval == -1) {
+ if (G_UNLIKELY (retval == -1)) {
if (errno == EBUSY)
goto stopped;
else
memset (&builder, 0, sizeof (GstRTSPBuilder));
while (TRUE) {
res = build_next (&builder, message, conn);
- if (res == GST_RTSP_EEOF)
+ if (G_UNLIKELY (res == GST_RTSP_EEOF))
goto eof;
- if (res == GST_RTSP_OK)
+ if (G_LIKELY (res == GST_RTSP_OK))
break;
if (res == GST_RTSP_ETGET) {
GString *str;
/* tunnel POST request, return the value, the caller now has to link the
* two connections. */
break;
- } else if (res != GST_RTSP_EINTR)
+ } else if (G_UNLIKELY (res != GST_RTSP_EINTR))
goto read_error;
do {
} while (retval == -1 && (errno == EINTR || errno == EAGAIN));
/* check for timeout */
- if (retval == 0)
+ if (G_UNLIKELY (retval == 0))
goto select_timeout;
- if (retval == -1) {
+ if (G_UNLIKELY (retval == -1)) {
if (errno == EBUSY)
goto stopped;
else
retval = gst_poll_wait (conn->fdset, to);
} while (retval == -1 && (errno == EINTR || errno == EAGAIN));
- if (retval == 0)
+ if (G_UNLIKELY (retval == 0))
goto select_timeout;
- if (retval == -1) {
+ if (G_UNLIKELY (retval == -1)) {
if (errno == EBUSY)
goto stopped;
else
res = build_next (&watch->builder, &watch->message, watch->conn);
if (res == GST_RTSP_EINTR)
break;
- if (res == GST_RTSP_EEOF)
+ if (G_UNLIKELY (res == GST_RTSP_EEOF))
goto eof;
if (res == GST_RTSP_ETGET) {
GString *str;
* GET connection */
if (watch->funcs.tunnel_complete)
watch->funcs.tunnel_complete (watch, watch->user_data);
- } else if (res != GST_RTSP_OK)
+ } else if (G_UNLIKELY (res != GST_RTSP_OK))
goto error;
- if (res == GST_RTSP_OK) {
+ if (G_LIKELY (res == GST_RTSP_OK)) {
if (watch->funcs.message_received)
watch->funcs.message_received (watch, &watch->message,
watch->user_data);
&watch->write_off, watch->write_len);
if (res == GST_RTSP_EINTR)
break;
- if (res != GST_RTSP_OK)
+ if (G_UNLIKELY (res != GST_RTSP_OK))
goto error;
if (watch->funcs.message_sent && watch->write_cseq != UNKNOWN_CSEQ)