diff options
author | František Dvořák <valtri@users.sourceforge.net> | 2004-04-10 17:41:44 +0000 |
---|---|---|
committer | František Dvořák <valtri@users.sourceforge.net> | 2004-04-10 17:41:44 +0000 |
commit | 6c9b4d3d60563bebad18ee653a638d9e38381a07 (patch) | |
tree | f72cefe154f259e4d9ee9ca54f087bdc2fc0c4f4 | |
parent | 75a3e6582d0570541b1f6bdc54821b7550721128 (diff) | |
download | xine-lib-6c9b4d3d60563bebad18ee653a638d9e38381a07.tar.gz xine-lib-6c9b4d3d60563bebad18ee653a638d9e38381a07.tar.bz2 |
Permit (but not recommend) stream == NULL in io_helper functions.
CVS patchset: 6385
CVS date: 2004/04/10 17:41:44
-rw-r--r-- | src/input/input_cdda.c | 25 | ||||
-rw-r--r-- | src/xine-engine/io_helper.c | 18 | ||||
-rw-r--r-- | src/xine-engine/io_helper.h | 21 | ||||
-rw-r--r-- | src/xine-engine/xine_interface.c | 4 |
4 files changed, 49 insertions, 19 deletions
diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c index 5e4f33d4f..5985b36fe 100644 --- a/src/input/input_cdda.c +++ b/src/input/input_cdda.c @@ -20,7 +20,7 @@ * Compact Disc Digital Audio (CDDA) Input Plugin * by Mike Melanson (melanson@pcisys.net) * - * $Id: input_cdda.c,v 1.49 2004/04/10 15:45:10 mroi Exp $ + * $Id: input_cdda.c,v 1.50 2004/04/10 17:41:44 valtri Exp $ */ #ifdef HAVE_CONFIG_H @@ -894,13 +894,15 @@ static int network_command( xine_stream_t *stream, int socket, char *data_buf, c if( _x_io_tcp_write(stream, socket, buf, strlen(buf)) < (int)strlen(buf) ) { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "input_cdda: error writing to socket.\n"); + if (stream) + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "input_cdda: error writing to socket.\n"); return -1; } if (_x_io_tcp_read_line(stream, socket, buf, _BUFSIZ) <= 0) { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "input_cdda: error reading from socket.\n"); + if (stream) + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "input_cdda: error reading from socket.\n"); return -1; } @@ -908,8 +910,9 @@ static int network_command( xine_stream_t *stream, int socket, char *data_buf, c if( n ) { if( !data_buf ) { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "input_cdda: protocol error, data returned but no buffer provided.\n"); + if (stream) + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + "input_cdda: protocol error, data returned but no buffer provided.\n"); return -1; } if ( _x_io_tcp_read(stream, socket, data_buf, n) < n ) @@ -959,7 +962,8 @@ static int network_read_cdrom_toc(xine_stream_t *stream, int fd, cdrom_toc *toc) /* fetch the table of contents */ if( network_command(stream, fd, buf, "cdda_tochdr" ) == -1) { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "input_cdda: network CDROMREADTOCHDR error.\n"); + if (stream) + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "input_cdda: network CDROMREADTOCHDR error.\n"); return -1; } @@ -979,7 +983,8 @@ static int network_read_cdrom_toc(xine_stream_t *stream, int fd, cdrom_toc *toc) /* fetch the table of contents */ if( network_command( stream, fd, buf, "cdda_tocentry %d", i ) == -1) { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "input_cdda: network CDROMREADTOCENTRY error.\n"); + if (stream) + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "input_cdda: network CDROMREADTOCENTRY error.\n"); return -1; } @@ -996,7 +1001,8 @@ static int network_read_cdrom_toc(xine_stream_t *stream, int fd, cdrom_toc *toc) /* fetch the leadout as well */ if( network_command( stream, fd, buf, "cdda_tocentry %d", CD_LEADOUT_TRACK ) == -1) { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "input_cdda: network CDROMREADTOCENTRY error.\n"); + if (stream) + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "input_cdda: network CDROMREADTOCENTRY error.\n"); return -1; } @@ -2218,15 +2224,14 @@ static char ** cdda_class_get_autoplay_list (input_class_t *this_gen, * gets called, before a plugin instance has been created; * let's create a dummy instance in such a condition */ ip = (cdda_input_plugin_t *)xine_xmalloc(sizeof(cdda_input_plugin_t)); + ip->stream = NULL; #ifndef WIN32 if( strchr(this->cdda_device,':') ) { - ip->stream = xine_stream_new(this->xine, NULL, NULL); fd = network_connect(ip->stream, this->cdda_device); if( fd != -1 ) { err = network_read_cdrom_toc(ip->stream, fd, toc); } - xine_dispose(ip->stream); } #endif diff --git a/src/xine-engine/io_helper.c b/src/xine-engine/io_helper.c index 47038296d..0d23752ae 100644 --- a/src/xine-engine/io_helper.c +++ b/src/xine-engine/io_helper.c @@ -98,7 +98,8 @@ static int _x_io_tcp_connect_ipv4(xine_stream_t *stream, const char *host, int p if (connect(s, (struct sockaddr *)&sin, sizeof(sin))==-1 && errno != EINPROGRESS) { #else if (connect(s, (struct sockaddr *)&sin, sizeof(sin))==-1 && WSAGetLastError() != WSAEWOULDBLOCK) { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "io_helper: WSAGetLastError() = %d\n", WSAGetLastError()); + if (stream) + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "io_helper: WSAGetLastError() = %d\n", WSAGetLastError()); #endif /* WIN32 */ _x_message(stream, XINE_MSG_CONNECTION_REFUSED, strerror(errno), NULL); @@ -127,8 +128,9 @@ int _x_io_tcp_connect(xine_stream_t *stream, const char *host, int port) { hints.ai_family = PF_UNSPEC; snprintf(strport, sizeof(strport), "%d", port); - - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "Resolving host '%s' at port '%s'\n", host, strport); + + if (stream) + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "Resolving host '%s' at port '%s'\n", host, strport); error = getaddrinfo(host, strport, &hints, &res); @@ -166,8 +168,9 @@ int _x_io_tcp_connect(xine_stream_t *stream, const char *host, int port) { if (connect(s, tmpaddr->ai_addr, tmpaddr->ai_addrlen)==-1 && WSAGetLastError() != WSAEWOULDBLOCK) { - - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "io_helper: WSAGetLastError() = %d\n", WSAGetLastError()); + + if (stream) + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "io_helper: WSAGetLastError() = %d\n", WSAGetLastError()); #endif /* WIN32 */ error = errno; @@ -224,7 +227,7 @@ int _x_io_select (xine_stream_t *stream, int fd, int state, int timeout_msec) { * aborts current read if action pending. otherwise xine * cannot be stopped when no more data is available. */ - if (stream->demux_action_pending) + if (stream && stream->demux_action_pending) return XIO_ABORTED; total_time_usec += XIO_POLLING_INTERVAL; @@ -313,7 +316,8 @@ static off_t xio_rw_abort(xine_stream_t *stream, int fd, int cmd, char *buf, off #else if (WSAGetLastError() == WSAEWOULDBLOCK) continue; - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "io_helper: WSAGetLastError() = %d\n", WSAGetLastError()); + if (stream) + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "io_helper: WSAGetLastError() = %d\n", WSAGetLastError()); #endif return ret; diff --git a/src/xine-engine/io_helper.h b/src/xine-engine/io_helper.h index 9a174a09e..09267f882 100644 --- a/src/xine-engine/io_helper.h +++ b/src/xine-engine/io_helper.h @@ -44,11 +44,14 @@ * not freeze the engine. * * params : + * stream needed for aborting and reporting errors but may be NULL * fd file/socket descriptor * state XIO_READ_READY, XIO_WRITE_READY - * *abort an other thread can abort this function by setting *abort * timeout_sec timeout in seconds * + * An other thread can abort this function if stream != NULL by setting + * stream->demux_action_pending. + * * return value : * XIO_READY the file descriptor is ready for cmd * XIO_ERROR an i/o error occured @@ -61,12 +64,28 @@ int _x_io_select (xine_stream_t *stream, int fd, int state, int timeout_msec); /* * open a tcp connection * + * params : + * stream needed for reporting errors but may be NULL + * host address of target + * port port on target + * * returns a socket descriptor or -1 if an error occured */ int _x_io_tcp_connect(xine_stream_t *stream, const char *host, int port); /* * wait for finish connection + * + * params : + * stream needed for aborting and reporting errors but may be NULL + * fd socket descriptor + * timeout_msec timeout in milliseconds + * + * return value: + * XIO_READY host respond, the socket is ready for cmd + * XIO_ERROR an i/o error occured + * XIO_ABORTED command aborted by an other thread + * XIO_TIMEOUT the file descriptor is not ready after timeout */ int _x_io_tcp_connect_finish(xine_stream_t *stream, int fd, int timeout_msec); diff --git a/src/xine-engine/xine_interface.c b/src/xine-engine/xine_interface.c index 81531cb3e..ad426580e 100644 --- a/src/xine-engine/xine_interface.c +++ b/src/xine-engine/xine_interface.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_interface.c,v 1.80 2004/03/03 20:09:18 mroi Exp $ + * $Id: xine_interface.c,v 1.81 2004/04/10 17:41:44 valtri Exp $ * * convenience/abstraction layer, functions to implement * libxine's public interface @@ -868,6 +868,8 @@ int _x_message(xine_stream_t *stream, int type, ...) { "Security message:" }; + if (!stream) return 0; + if( type >= 0 && type < sizeof(std_explanation)/ sizeof(std_explanation[0]) ) { explanation = std_explanation[type]; |