From ac3b6d090c0b5c6ee4efecf0b80a6c01bfd4572f Mon Sep 17 00:00:00 2001 From: diego Date: Sun, 12 Oct 2008 12:12:41 +0000 Subject: Move socklen_t typedef from config.h to stream/network.h. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27744 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/librtsp/rtsp_rtp.c | 1 + stream/network.h | 3 +++ 2 files changed, 4 insertions(+) (limited to 'stream') diff --git a/stream/librtsp/rtsp_rtp.c b/stream/librtsp/rtsp_rtp.c index fd01524d89..b782b59cd5 100644 --- a/stream/librtsp/rtsp_rtp.c +++ b/stream/librtsp/rtsp_rtp.c @@ -42,6 +42,7 @@ #include "rtsp.h" #include "rtsp_rtp.h" #include "rtsp_session.h" +#include "stream/network.h" #include "stream/freesdp/common.h" #include "stream/freesdp/parser.h" diff --git a/stream/network.h b/stream/network.h index 76e2e6d520..36b470dfe4 100644 --- a/stream/network.h +++ b/stream/network.h @@ -25,6 +25,9 @@ #ifndef HAVE_CLOSESOCKET #define closesocket close #endif +#ifndef HAVE_SOCKLEN_T +typedef int socklen_t; +#endif #define BUFFER_SIZE 2048 -- cgit v1.2.3 From c8808af5a0e19e550a1779cb3725a0dcffe0d65b Mon Sep 17 00:00:00 2001 From: diego Date: Mon, 13 Oct 2008 15:13:40 +0000 Subject: Unconditionally #include osdep/shem.h, fixes the warnings on Cygwin: stream/cache2.c:244: warning: implicit declaration of function `shmem_alloc' stream/cache2.c:265: warning: implicit declaration of function `shmem_free' git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27757 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/cache2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'stream') diff --git a/stream/cache2.c b/stream/cache2.c index 53749afb5d..aff5a93a6f 100644 --- a/stream/cache2.c +++ b/stream/cache2.c @@ -16,6 +16,7 @@ #include #include +#include "osdep/shmem.h" #include "osdep/timer.h" #ifdef WIN32 #include @@ -26,7 +27,6 @@ static DWORD WINAPI ThreadProc(void* s); static void ThreadProc( void *s ); #else #include -#include "osdep/shmem.h" #endif #include "mp_msg.h" -- cgit v1.2.3 From bc7cf2efd85d4f1a88892cff71294adb4bc44a86 Mon Sep 17 00:00:00 2001 From: diego Date: Mon, 13 Oct 2008 15:25:34 +0000 Subject: Remove unused function, fixes the warning: stream/tvi_dshow.c:1311: warning: 'reconnect_pins' defined but not used git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27758 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/tvi_dshow.c | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) (limited to 'stream') diff --git a/stream/tvi_dshow.c b/stream/tvi_dshow.c index 726f469098..e06f4dc346 100644 --- a/stream/tvi_dshow.c +++ b/stream/tvi_dshow.c @@ -1298,52 +1298,6 @@ static void get_capabilities(priv_t * priv) * *--------------------------------------------------------------------------------------- */ -/** - * \brief routine for reconnecting two pins with new media type - * \param pGraph IGraphBuilder interface - * \param chan chain data - * \param pmt [in/out] new mediatype for pin connection - * - * \return S_OK if operation successfult, error code otherwise - * will also return media type of new connection into pmt variable - */ -static HRESULT reconnect_pins(IGraphBuilder *pGraph, chain_t *chain, AM_MEDIA_TYPE *pmt) -{ - AM_MEDIA_TYPE old_mt; - HRESULT hr; - - do { - /* save old media type for reconnection in case of error */ - hr = OLE_CALL_ARGS(chain->pCapturePin, ConnectionMediaType, &old_mt); - if(FAILED(hr)) - return hr; - - hr = OLE_CALL(chain->pCapturePin, Disconnect); - if(FAILED(hr)) - return hr; - - hr = OLE_CALL_ARGS(chain->pSG, SetMediaType, pmt); - if(FAILED(hr)) - return hr; - - hr = OLE_CALL_ARGS(pGraph, Connect, chain->pCapturePin, chain->pSGIn); - if(FAILED(hr)) - { - OLE_CALL_ARGS(chain->pSG, SetMediaType, &old_mt); - OLE_CALL_ARGS(pGraph, Connect, chain->pCapturePin, chain->pSGIn); - break; - } - hr = OLE_CALL_ARGS(chain->pCapturePin, ConnectionMediaType, &old_mt); - - hr = S_OK; - } while(0); - - FreeMediaType(pmt); - CopyMediaType(pmt, &old_mt); - FreeMediaType(&old_mt); - return hr; -} - /** * \brief building in graph audio/video capture chain * -- cgit v1.2.3 From 9214b77133591ef363bd13eda0da68782244dd5d Mon Sep 17 00:00:00 2001 From: diego Date: Mon, 13 Oct 2008 15:51:29 +0000 Subject: Declare ThreadProc as void, it does not return anything, fixes the warning: stream/cache2.c:364: warning: control reaches end of non-void function git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27759 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/cache2.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'stream') diff --git a/stream/cache2.c b/stream/cache2.c index aff5a93a6f..37889acaa0 100644 --- a/stream/cache2.c +++ b/stream/cache2.c @@ -20,11 +20,9 @@ #include "osdep/timer.h" #ifdef WIN32 #include -static DWORD WINAPI ThreadProc(void* s); #elif defined(__OS2__) #define INCL_DOS #include -static void ThreadProc( void *s ); #else #include #endif @@ -37,6 +35,7 @@ extern int use_gui; int stream_fill_buffer(stream_t *s); int stream_seek_long(stream_t *s,off_t pos); +static void ThreadProc(void *s); typedef struct { // constats: @@ -362,12 +361,9 @@ int stream_enable_cache(stream_t *stream,int size,int min,int seek_limit){ #if defined(WIN32) || defined(__OS2__) } -#ifdef WIN32 -static DWORD WINAPI ThreadProc(void*s){ -#else // OS2 + static void ThreadProc( void *s ){ #endif -#endif #ifdef CONFIG_GUI use_gui = 0; // mp_msg may not use gui stuff in forked code -- cgit v1.2.3 From 4d644f513c841eaf4617edffb348338a798d37be Mon Sep 17 00:00:00 2001 From: diego Date: Mon, 13 Oct 2008 16:23:55 +0000 Subject: Replace preprocessor check for WIN32 with checks for __MINGW32__ and __CYGWIN__. This avoids a pointless indirection that only obscures what is really done. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27761 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/cache2.c | 20 ++++++++++---------- stream/stream_cddb.c | 8 ++++---- stream/stream_file.c | 2 +- stream/stream_vcd.c | 12 ++++++------ 4 files changed, 21 insertions(+), 21 deletions(-) (limited to 'stream') diff --git a/stream/cache2.c b/stream/cache2.c index 37889acaa0..dd2423d765 100644 --- a/stream/cache2.c +++ b/stream/cache2.c @@ -18,7 +18,7 @@ #include "osdep/shmem.h" #include "osdep/timer.h" -#ifdef WIN32 +#if defined(__MINGW32__) || defined(__CYGWIN__) #include #elif defined(__OS2__) #define INCL_DOS @@ -239,7 +239,7 @@ static void cache_execute_control(cache_vars_t *s) { cache_vars_t* cache_init(int size,int sector){ int num; -#if !defined(WIN32) && !defined(__OS2__) +#if !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(__OS2__) cache_vars_t* s=shmem_alloc(sizeof(cache_vars_t)); #else cache_vars_t* s=malloc(sizeof(cache_vars_t)); @@ -253,14 +253,14 @@ cache_vars_t* cache_init(int size,int sector){ }//32kb min_size s->buffer_size=num*sector; s->sector_size=sector; -#if !defined(WIN32) && !defined(__OS2__) +#if !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(__OS2__) s->buffer=shmem_alloc(s->buffer_size); #else s->buffer=malloc(s->buffer_size); #endif if(s->buffer == NULL){ -#if !defined(WIN32) && !defined(__OS2__) +#if !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(__OS2__) shmem_free(s,sizeof(cache_vars_t)); #else free(s); @@ -276,7 +276,7 @@ cache_vars_t* cache_init(int size,int sector){ void cache_uninit(stream_t *s) { cache_vars_t* c = s->cache_data; if(!s->cache_pid) return; -#ifdef WIN32 +#if defined(__MINGW32__) || defined(__CYGWIN__) TerminateThread((HANDLE)s->cache_pid,0); #elif defined(__OS2__) DosKillThread( s->cache_pid ); @@ -286,7 +286,7 @@ void cache_uninit(stream_t *s) { waitpid(s->cache_pid,NULL,0); #endif if(!c) return; -#if defined(WIN32) || defined(__OS2__) +#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__OS2__) free(c->stream); free(c->buffer); free(s->cache_data); @@ -327,17 +327,17 @@ int stream_enable_cache(stream_t *stream,int size,int min,int seek_limit){ min = s->buffer_size - s->fill_limit; } -#if !defined(WIN32) && !defined(__OS2__) +#if !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(__OS2__) if((stream->cache_pid=fork())){ #else { -#ifdef WIN32 +#if defined(__MINGW32__) || defined(__CYGWIN__) DWORD threadId; #endif stream_t* stream2=malloc(sizeof(stream_t)); memcpy(stream2,s->stream,sizeof(stream_t)); s->stream=stream2; -#ifdef WIN32 +#if defined(__MINGW32__) || defined(__CYGWIN__) stream->cache_pid = CreateThread(NULL,0,ThreadProc,s,0,&threadId); #else // OS2 stream->cache_pid = _beginthread( ThreadProc, NULL, 256 * 1024, s ); @@ -359,7 +359,7 @@ int stream_enable_cache(stream_t *stream,int size,int min,int seek_limit){ return 1; // parent exits } -#if defined(WIN32) || defined(__OS2__) +#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__OS2__) } static void ThreadProc( void *s ){ diff --git a/stream/stream_cddb.c b/stream/stream_cddb.c index 5236a4ca9c..4702f86d8c 100644 --- a/stream/stream_cddb.c +++ b/stream/stream_cddb.c @@ -22,7 +22,7 @@ #include #include #include -#ifdef WIN32 +#if defined(__MINGW32__) || defined(__CYGWIN__) #ifdef __MINGW32__ #define mkdir(a,b) mkdir(a) #endif @@ -44,7 +44,7 @@ #include #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) #include -#elif defined(WIN32) +#elif defined(__MINGW32__) || defined(__CYGWIN__) #include #elif (__bsdi__) #include @@ -72,7 +72,7 @@ int read_toc(const char *dev) { int first = 0, last = -1; int i; -#ifdef WIN32 +#if defined(__MINGW32__) || defined(__CYGWIN__) HANDLE drive; DWORD r; CDROM_TOC toc; @@ -326,7 +326,7 @@ cddb_read_cache(cddb_data_t *cddb_data) { sprintf( file_name, "%s%08lx", cddb_data->cache_dir, cddb_data->disc_id); file_fd = open(file_name, O_RDONLY -#ifdef WIN32 +#if defined(__MINGW32__) || defined(__CYGWIN__) | O_BINARY #endif ); diff --git a/stream/stream_file.c b/stream/stream_file.c index 9b21d80d04..1abc2e1c9e 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -113,7 +113,7 @@ static int open_f(stream_t *stream,int mode, void* opts, int* file_format) { return STREAM_ERROR; } -#if defined(WIN32) || defined(__OS2__) +#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__OS2__) // extract '/' from '/x:/path' if( filename[ 0 ] == '/' && filename[ 1 ] && filename[ 2 ] == ':' ) filename++; diff --git a/stream/stream_vcd.c b/stream/stream_vcd.c index 4202a9786d..34844bcea9 100644 --- a/stream/stream_vcd.c +++ b/stream/stream_vcd.c @@ -1,7 +1,7 @@ #include "config.h" -#ifdef WIN32 +#if defined(__MINGW32__) || defined(__CYGWIN__) #include #endif @@ -14,7 +14,7 @@ #include #include #include -#ifndef WIN32 +#if !defined(__MINGW32__) && !defined(__CYGWIN__) #include #endif #include @@ -23,7 +23,7 @@ #include "vcd_read_fbsd.h" #elif defined(__APPLE__) #include "vcd_read_darwin.h" -#elif defined(WIN32) +#elif defined(__MINGW32__) || defined(__CYGWIN__) #include "vcd_read_win32.h" #else #include "vcd_read.h" @@ -81,13 +81,13 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) int bsize = VCD_SECTOR_SIZE; #endif -#ifdef WIN32 +#if defined(__MINGW32__) || defined(__CYGWIN__) HANDLE hd; char device[] = "\\\\.\\?:"; #endif if(mode != STREAM_READ -#ifdef WIN32 +#if defined(__MINGW32__) || defined(__CYGWIN__) || GetVersion() > 0x80000000 // Win9x #endif ) { @@ -102,7 +102,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { p->device = strdup(DEFAULT_CDROM_DEVICE); } -#ifdef WIN32 +#if defined(__MINGW32__) || defined(__CYGWIN__) device[4] = p->device[0]; /* open() can't be used for devices so do it the complicated way */ hd = CreateFile(device, GENERIC_READ, FILE_SHARE_READ, NULL, -- cgit v1.2.3 From 17f509905c0d005ca3283eafab850b78cc19968c Mon Sep 17 00:00:00 2001 From: diego Date: Thu, 16 Oct 2008 17:01:40 +0000 Subject: Rename stream/netstream.h to stream/stream_netstream.h; netstream.h to make it clearer that netstream.h belongs to stream_netstream.c. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27779 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/netstream.h | 151 ---------------------------------------------- stream/stream_netstream.c | 2 +- stream/stream_netstream.h | 151 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 152 insertions(+), 152 deletions(-) delete mode 100644 stream/netstream.h create mode 100644 stream/stream_netstream.h (limited to 'stream') diff --git a/stream/netstream.h b/stream/netstream.h deleted file mode 100644 index 533e6a3b93..0000000000 --- a/stream/netstream.h +++ /dev/null @@ -1,151 +0,0 @@ - -/* - * Common stuff for netstream - * Packets and so on are defined here along with a few helpers - * wich are used by both the client and the server - * - * Data is always low endian - */ - -#ifndef MPLAYER_NETSTREAM_H -#define MPLAYER_NETSTREAM_H - -#include -#include -#include -#include -#ifndef HAVE_WINSOCK2_H -#include -#endif -#include "mp_msg.h" -#include "mpbswap.h" - -typedef struct mp_net_stream_packet_st { - uint16_t len; - uint8_t cmd; - char data[0]; -} __attribute__ ((packed)) mp_net_stream_packet_t; - -#define PACKET_MAX_SIZE 4096 - -// Commands sent by the client -#define NET_STREAM_OPEN 0 -// data is the url -#define NET_STREAM_FILL_BUFFER 1 -// data is an uint16 wich is the max len of the data to return -#define NET_STREAM_SEEK 3 -// data is an uint64 wich the pos where to seek -#define NET_STREAM_CLOSE 4 -// no data -#define NET_STREAM_RESET 5 -// no data - -// Server response -#define NET_STREAM_OK 128 -// Data returned if open is successful -typedef struct mp_net_stream_opened_st { - uint32_t file_format; - uint32_t flags; - uint32_t sector_size; - uint64_t start_pos; - uint64_t end_pos; -} __attribute__ ((packed)) mp_net_stream_opened_t; -// FILL_BUFFER return the data -// CLOSE return nothing -#define NET_STREAM_ERROR 129 -// Data is the error message (if any ;) - -static int net_read(int fd, char* buf, int len) { - int r = 0; - while(len) { - r = recv(fd,buf,len,0); - if(r <= 0) { - if(errno == EINTR) continue; - if(r < 0) - mp_msg(MSGT_NETST,MSGL_ERR,"Read failed: %s\n",strerror(errno)); - return 0; - } - len -= r; - buf += r; - } - return 1; -} - -static mp_net_stream_packet_t* read_packet(int fd) { - uint16_t len; - mp_net_stream_packet_t* pack = - (mp_net_stream_packet_t*)malloc(sizeof(mp_net_stream_packet_t)); - - if(!net_read(fd,(char*)pack,sizeof(mp_net_stream_packet_t))) { - free(pack); - return NULL; - } - pack->len = le2me_16(pack->len); - - if(pack->len < sizeof(mp_net_stream_packet_t)) { - mp_msg(MSGT_NETST,MSGL_WARN,"Got invalid packet (too small: %d)\n",pack->len); - free(pack); - return NULL; - } - if(pack->len > PACKET_MAX_SIZE) { - mp_msg(MSGT_NETST,MSGL_WARN,"Got invalid packet (too big: %d)\n",pack->len); - free(pack); - return NULL; - } - len = pack->len; - if(len > sizeof(mp_net_stream_packet_t)) { - pack = realloc(pack,len); - if(!pack) { - mp_msg(MSGT_NETST,MSGL_ERR,"Failed to get memory for the packet (%d bytes)\n",len); - return NULL; - } - if(!net_read(fd,pack->data,len - sizeof(mp_net_stream_packet_t))) - return NULL; - } - // printf ("Read packet %d %d %d\n",fd,pack->cmd,pack->len); - return pack; -} - -static int net_write(int fd, char* buf, int len) { - int w; - while(len) { - w = send(fd,buf,len,0); - if(w <= 0) { - if(errno == EINTR) continue; - if(w < 0) - mp_msg(MSGT_NETST,MSGL_ERR,"Write failed: %s\n",strerror(errno)); - return 0; - } - len -= w; - buf += w; - } - return 1; -} - -static int write_packet(int fd, uint8_t cmd,char* data,int len) { - mp_net_stream_packet_t* pack = malloc(len + sizeof(mp_net_stream_packet_t)); - - if(len > 0 && data) - memcpy(pack->data,data,len); - pack->len = len + sizeof(mp_net_stream_packet_t); - pack->cmd = cmd; - - // printf("Write packet %d %d (%p) %d\n",fd,cmd,data,len); - pack->len = le2me_16(pack->len); - if(net_write(fd,(char*)pack,pack->len)) { - free(pack); - return 1; - } - free(pack); - return 0; -} - -static void net_stream_opened_2_me(mp_net_stream_opened_t* o) { - o->file_format = le2me_32(o->file_format); - o->flags = le2me_32(o->flags); - o->sector_size = le2me_32(o->sector_size); - o->start_pos = le2me_64(o->start_pos); - o->end_pos = le2me_64(o->end_pos); -} - -#endif /* MPLAYER_NETSTREAM_H */ diff --git a/stream/stream_netstream.c b/stream/stream_netstream.c index 5a3de1ce58..84e10a2c81 100644 --- a/stream/stream_netstream.c +++ b/stream/stream_netstream.c @@ -59,7 +59,7 @@ #include "mpbswap.h" #include "network.h" -#include "netstream.h" +#include "stream_netstream.h" #include "tcp.h" static struct stream_priv_s { diff --git a/stream/stream_netstream.h b/stream/stream_netstream.h new file mode 100644 index 0000000000..533e6a3b93 --- /dev/null +++ b/stream/stream_netstream.h @@ -0,0 +1,151 @@ + +/* + * Common stuff for netstream + * Packets and so on are defined here along with a few helpers + * wich are used by both the client and the server + * + * Data is always low endian + */ + +#ifndef MPLAYER_NETSTREAM_H +#define MPLAYER_NETSTREAM_H + +#include +#include +#include +#include +#ifndef HAVE_WINSOCK2_H +#include +#endif +#include "mp_msg.h" +#include "mpbswap.h" + +typedef struct mp_net_stream_packet_st { + uint16_t len; + uint8_t cmd; + char data[0]; +} __attribute__ ((packed)) mp_net_stream_packet_t; + +#define PACKET_MAX_SIZE 4096 + +// Commands sent by the client +#define NET_STREAM_OPEN 0 +// data is the url +#define NET_STREAM_FILL_BUFFER 1 +// data is an uint16 wich is the max len of the data to return +#define NET_STREAM_SEEK 3 +// data is an uint64 wich the pos where to seek +#define NET_STREAM_CLOSE 4 +// no data +#define NET_STREAM_RESET 5 +// no data + +// Server response +#define NET_STREAM_OK 128 +// Data returned if open is successful +typedef struct mp_net_stream_opened_st { + uint32_t file_format; + uint32_t flags; + uint32_t sector_size; + uint64_t start_pos; + uint64_t end_pos; +} __attribute__ ((packed)) mp_net_stream_opened_t; +// FILL_BUFFER return the data +// CLOSE return nothing +#define NET_STREAM_ERROR 129 +// Data is the error message (if any ;) + +static int net_read(int fd, char* buf, int len) { + int r = 0; + while(len) { + r = recv(fd,buf,len,0); + if(r <= 0) { + if(errno == EINTR) continue; + if(r < 0) + mp_msg(MSGT_NETST,MSGL_ERR,"Read failed: %s\n",strerror(errno)); + return 0; + } + len -= r; + buf += r; + } + return 1; +} + +static mp_net_stream_packet_t* read_packet(int fd) { + uint16_t len; + mp_net_stream_packet_t* pack = + (mp_net_stream_packet_t*)malloc(sizeof(mp_net_stream_packet_t)); + + if(!net_read(fd,(char*)pack,sizeof(mp_net_stream_packet_t))) { + free(pack); + return NULL; + } + pack->len = le2me_16(pack->len); + + if(pack->len < sizeof(mp_net_stream_packet_t)) { + mp_msg(MSGT_NETST,MSGL_WARN,"Got invalid packet (too small: %d)\n",pack->len); + free(pack); + return NULL; + } + if(pack->len > PACKET_MAX_SIZE) { + mp_msg(MSGT_NETST,MSGL_WARN,"Got invalid packet (too big: %d)\n",pack->len); + free(pack); + return NULL; + } + len = pack->len; + if(len > sizeof(mp_net_stream_packet_t)) { + pack = realloc(pack,len); + if(!pack) { + mp_msg(MSGT_NETST,MSGL_ERR,"Failed to get memory for the packet (%d bytes)\n",len); + return NULL; + } + if(!net_read(fd,pack->data,len - sizeof(mp_net_stream_packet_t))) + return NULL; + } + // printf ("Read packet %d %d %d\n",fd,pack->cmd,pack->len); + return pack; +} + +static int net_write(int fd, char* buf, int len) { + int w; + while(len) { + w = send(fd,buf,len,0); + if(w <= 0) { + if(errno == EINTR) continue; + if(w < 0) + mp_msg(MSGT_NETST,MSGL_ERR,"Write failed: %s\n",strerror(errno)); + return 0; + } + len -= w; + buf += w; + } + return 1; +} + +static int write_packet(int fd, uint8_t cmd,char* data,int len) { + mp_net_stream_packet_t* pack = malloc(len + sizeof(mp_net_stream_packet_t)); + + if(len > 0 && data) + memcpy(pack->data,data,len); + pack->len = len + sizeof(mp_net_stream_packet_t); + pack->cmd = cmd; + + // printf("Write packet %d %d (%p) %d\n",fd,cmd,data,len); + pack->len = le2me_16(pack->len); + if(net_write(fd,(char*)pack,pack->len)) { + free(pack); + return 1; + } + free(pack); + return 0; +} + +static void net_stream_opened_2_me(mp_net_stream_opened_t* o) { + o->file_format = le2me_32(o->file_format); + o->flags = le2me_32(o->flags); + o->sector_size = le2me_32(o->sector_size); + o->start_pos = le2me_64(o->start_pos); + o->end_pos = le2me_64(o->end_pos); +} + +#endif /* MPLAYER_NETSTREAM_H */ -- cgit v1.2.3 From 629db77d89d6bdead91fd18faa6445632a750e94 Mon Sep 17 00:00:00 2001 From: diego Date: Thu, 16 Oct 2008 18:28:38 +0000 Subject: Move DEFAULT_CDROM_DEVICE/DEFAULT_DVD_DEVICE to stream.h where it belongs. config.h should only contain option definitions, no logic. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27787 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/stream.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'stream') diff --git a/stream/stream.h b/stream/stream.h index 4e872195a5..4eab9b5d85 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -65,6 +65,33 @@ #define STREAM_CTRL_GET_ANGLE 10 #define STREAM_CTRL_SET_ANGLE 11 +#ifdef __sun +#define DEFAULT_CDROM_DEVICE "/vol/dev/aliases/cdrom0" +#define DEFAULT_DVD_DEVICE DEFAULT_CDROM_DEVICE +#elif defined(__MINGW32__) || defined(__CYGWIN__) || defined(__OS2__) +#define DEFAULT_CDROM_DEVICE "D:" +#define DEFAULT_DVD_DEVICE DEFAULT_CDROM_DEVICE +#elif defined(__APPLE__) || defined(__DARWIN__) +#define DEFAULT_CDROM_DEVICE "/dev/disk1" +#define DEFAULT_DVD_DEVICE "/dev/rdiskN" +#elif defined(__OpenBSD__) +#define DEFAULT_CDROM_DEVICE "/dev/rcd0a" +#define DEFAULT_DVD_DEVICE DEFAULT_CDROM_DEVICE +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#define DEFAULT_CDROM_DEVICE "/dev/acd0" +#define DEFAULT_DVD_DEVICE DEFAULT_CDROM_DEVICE +#elif defined(__DragonFly__) +#define DEFAULT_CDROM_DEVICE "/dev/cd0" +#define DEFAULT_DVD_DEVICE DEFAULT_CDROM_DEVICE +#elif defined(__AMIGAOS4__) +#define DEFAULT_CDROM_DEVICE "a1ide.device:2" +#define DEFAULT_DVD_DEVICE DEFAULT_CDROM_DEVICE +#else +#define DEFAULT_CDROM_DEVICE "/dev/cdrom" +#define DEFAULT_DVD_DEVICE "/dev/dvd" +#endif + + #ifdef CONFIG_NETWORK #include "network.h" #endif -- cgit v1.2.3 From 2195547220674940ef20e9ea38bb3610541d04b3 Mon Sep 17 00:00:00 2001 From: diego Date: Thu, 16 Oct 2008 19:24:21 +0000 Subject: Revert declaring ThreadProc as void, it breaks the WINAPI. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27790 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/cache2.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'stream') diff --git a/stream/cache2.c b/stream/cache2.c index dd2423d765..7decd32d01 100644 --- a/stream/cache2.c +++ b/stream/cache2.c @@ -20,9 +20,11 @@ #include "osdep/timer.h" #if defined(__MINGW32__) || defined(__CYGWIN__) #include +static DWORD WINAPI ThreadProc(void* s); #elif defined(__OS2__) #define INCL_DOS #include +static void ThreadProc( void *s ); #else #include #endif @@ -35,7 +37,6 @@ extern int use_gui; int stream_fill_buffer(stream_t *s); int stream_seek_long(stream_t *s,off_t pos); -static void ThreadProc(void *s); typedef struct { // constats: @@ -361,9 +362,12 @@ int stream_enable_cache(stream_t *stream,int size,int min,int seek_limit){ #if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__OS2__) } - +#if defined(__MINGW32__) || defined(__CYGWIN__) +static DWORD WINAPI ThreadProc(void*s){ +#else // OS2 static void ThreadProc( void *s ){ #endif +#endif #ifdef CONFIG_GUI use_gui = 0; // mp_msg may not use gui stuff in forked code -- cgit v1.2.3 From 834d4c5b7b9a2c0344445cfb1719e37838ea5844 Mon Sep 17 00:00:00 2001 From: reimar Date: Sun, 19 Oct 2008 17:28:23 +0000 Subject: Remove useless casts. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27803 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/cache2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'stream') diff --git a/stream/cache2.c b/stream/cache2.c index 7decd32d01..b7326b4832 100644 --- a/stream/cache2.c +++ b/stream/cache2.c @@ -375,10 +375,10 @@ static void ThreadProc( void *s ){ // cache thread mainloop: signal(SIGTERM,exit_sighandler); // kill while(1){ - if(!cache_fill((cache_vars_t*)s)){ + if(!cache_fill(s)){ usec_sleep(FILL_USLEEP_TIME); // idle } - cache_execute_control((cache_vars_t*)s); + cache_execute_control(s); // cache_stats(s->cache_data); } } -- cgit v1.2.3 From 3d1f36e3e704a830d6a4048a46367f5ee72f8747 Mon Sep 17 00:00:00 2001 From: reimar Date: Sun, 19 Oct 2008 18:05:45 +0000 Subject: Avoid CreateThread and especially TerminateThread since they cause a memleak. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27804 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/cache2.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'stream') diff --git a/stream/cache2.c b/stream/cache2.c index b7326b4832..aa06bc1b51 100644 --- a/stream/cache2.c +++ b/stream/cache2.c @@ -20,7 +20,7 @@ #include "osdep/timer.h" #if defined(__MINGW32__) || defined(__CYGWIN__) #include -static DWORD WINAPI ThreadProc(void* s); +static void ThreadProc( void *s ); #elif defined(__OS2__) #define INCL_DOS #include @@ -198,14 +198,15 @@ int cache_fill(cache_vars_t* s){ } -static void cache_execute_control(cache_vars_t *s) { +static int cache_execute_control(cache_vars_t *s) { + int res = 1; static unsigned last; if (!s->stream->control) { s->stream_time_length = 0; s->control_new_pos = 0; s->control_res = STREAM_UNSUPPORTED; s->control = -1; - return; + return res; } if (GetTimerMS() - last > 99) { double len; @@ -215,7 +216,7 @@ static void cache_execute_control(cache_vars_t *s) { s->stream_time_length = 0; last = GetTimerMS(); } - if (s->control == -1) return; + if (s->control == -1) return res; switch (s->control) { case STREAM_CTRL_GET_CURRENT_TIME: case STREAM_CTRL_SEEK_TO_TIME: @@ -230,12 +231,15 @@ static void cache_execute_control(cache_vars_t *s) { case STREAM_CTRL_SET_ANGLE: s->control_res = s->stream->control(s->stream, s->control, &s->control_uint_arg); break; + case -2: + res = 0; default: s->control_res = STREAM_UNSUPPORTED; break; } s->control_new_pos = s->stream->pos; s->control = -1; + return res; } cache_vars_t* cache_init(int size,int sector){ @@ -277,11 +281,8 @@ cache_vars_t* cache_init(int size,int sector){ void cache_uninit(stream_t *s) { cache_vars_t* c = s->cache_data; if(!s->cache_pid) return; -#if defined(__MINGW32__) || defined(__CYGWIN__) - TerminateThread((HANDLE)s->cache_pid,0); -#elif defined(__OS2__) - DosKillThread( s->cache_pid ); - DosWaitThread( &s->cache_pid, DCWW_WAIT ); +#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__OS2__) + cache_do_control(s, -2, NULL); #else kill(s->cache_pid,SIGKILL); waitpid(s->cache_pid,NULL,0); @@ -332,15 +333,12 @@ int stream_enable_cache(stream_t *stream,int size,int min,int seek_limit){ if((stream->cache_pid=fork())){ #else { -#if defined(__MINGW32__) || defined(__CYGWIN__) - DWORD threadId; -#endif stream_t* stream2=malloc(sizeof(stream_t)); memcpy(stream2,s->stream,sizeof(stream_t)); s->stream=stream2; #if defined(__MINGW32__) || defined(__CYGWIN__) - stream->cache_pid = CreateThread(NULL,0,ThreadProc,s,0,&threadId); -#else // OS2 + stream->cache_pid = _beginthread( ThreadProc, 0, s ); +#else stream->cache_pid = _beginthread( ThreadProc, NULL, 256 * 1024, s ); #endif #endif @@ -362,25 +360,23 @@ int stream_enable_cache(stream_t *stream,int size,int min,int seek_limit){ #if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__OS2__) } -#if defined(__MINGW32__) || defined(__CYGWIN__) -static DWORD WINAPI ThreadProc(void*s){ -#else // OS2 static void ThreadProc( void *s ){ #endif -#endif #ifdef CONFIG_GUI use_gui = 0; // mp_msg may not use gui stuff in forked code #endif // cache thread mainloop: signal(SIGTERM,exit_sighandler); // kill - while(1){ + do { if(!cache_fill(s)){ usec_sleep(FILL_USLEEP_TIME); // idle } - cache_execute_control(s); // cache_stats(s->cache_data); - } + } while (cache_execute_control(s)); +#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__OS2__) + _endthread(); +#endif } int cache_stream_fill_buffer(stream_t *s){ @@ -455,6 +451,7 @@ int cache_do_control(stream_t *stream, int cmd, void *arg) { case STREAM_CTRL_GET_ASPECT_RATIO: case STREAM_CTRL_GET_NUM_ANGLES: case STREAM_CTRL_GET_ANGLE: + case -2: s->control = cmd; break; default: -- cgit v1.2.3 From 6f6bf7f765c8eb182da524983790e5ae0b60643b Mon Sep 17 00:00:00 2001 From: diego Date: Mon, 20 Oct 2008 09:55:38 +0000 Subject: Replace typeof by __typeof__, the former is a non-portable GNU extension. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27807 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/stream_dvd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'stream') diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index b28cb874b7..ec0b7983c8 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -398,7 +398,7 @@ read_next: // See also gcc problem report PR c/7847: // http://gcc.gnu.org/cgi-bin/gnatsweb.pl?database=gcc&cmd=view+audit-trail&pr=7847 for(i=0;i<9;i++) { // check if all values zero: - typeof(d->dsi_pack.sml_agli.data[i].address) tmp_addr; + __typeof__(d->dsi_pack.sml_agli.data[i].address) tmp_addr; memcpy(&tmp_addr,&d->dsi_pack.sml_agli.data[i].address,sizeof(tmp_addr)); if((skip=tmp_addr)!=0) break; } -- cgit v1.2.3 From ed0af8844ae1a89b758ff30f588cfef20c598efc Mon Sep 17 00:00:00 2001 From: diego Date: Tue, 21 Oct 2008 07:02:25 +0000 Subject: Determine default CD/DVD device in configure instead of using an #ifdef jungle. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27809 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/stream.h | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'stream') diff --git a/stream/stream.h b/stream/stream.h index 4eab9b5d85..686288071f 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -65,32 +65,6 @@ #define STREAM_CTRL_GET_ANGLE 10 #define STREAM_CTRL_SET_ANGLE 11 -#ifdef __sun -#define DEFAULT_CDROM_DEVICE "/vol/dev/aliases/cdrom0" -#define DEFAULT_DVD_DEVICE DEFAULT_CDROM_DEVICE -#elif defined(__MINGW32__) || defined(__CYGWIN__) || defined(__OS2__) -#define DEFAULT_CDROM_DEVICE "D:" -#define DEFAULT_DVD_DEVICE DEFAULT_CDROM_DEVICE -#elif defined(__APPLE__) || defined(__DARWIN__) -#define DEFAULT_CDROM_DEVICE "/dev/disk1" -#define DEFAULT_DVD_DEVICE "/dev/rdiskN" -#elif defined(__OpenBSD__) -#define DEFAULT_CDROM_DEVICE "/dev/rcd0a" -#define DEFAULT_DVD_DEVICE DEFAULT_CDROM_DEVICE -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -#define DEFAULT_CDROM_DEVICE "/dev/acd0" -#define DEFAULT_DVD_DEVICE DEFAULT_CDROM_DEVICE -#elif defined(__DragonFly__) -#define DEFAULT_CDROM_DEVICE "/dev/cd0" -#define DEFAULT_DVD_DEVICE DEFAULT_CDROM_DEVICE -#elif defined(__AMIGAOS4__) -#define DEFAULT_CDROM_DEVICE "a1ide.device:2" -#define DEFAULT_DVD_DEVICE DEFAULT_CDROM_DEVICE -#else -#define DEFAULT_CDROM_DEVICE "/dev/cdrom" -#define DEFAULT_DVD_DEVICE "/dev/dvd" -#endif - #ifdef CONFIG_NETWORK #include "network.h" -- cgit v1.2.3 From c0f231ac477aa6ee55526e6401ed114026473980 Mon Sep 17 00:00:00 2001 From: diego Date: Fri, 24 Oct 2008 09:13:04 +0000 Subject: Conditionally declare a conditionally used variable, fixes the warning: stream/dvb_tune.c:99: warning: unused variable 'sec_dev' git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27820 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/dvb_tune.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'stream') diff --git a/stream/dvb_tune.c b/stream/dvb_tune.c index 64a2b0fb0a..b42d69d17e 100644 --- a/stream/dvb_tune.c +++ b/stream/dvb_tune.c @@ -96,7 +96,10 @@ int dvb_set_ts_filt(int fd, uint16_t pid, dmx_pes_type_t pestype); int dvb_open_devices(dvb_priv_t *priv, int n, int demux_cnt) { int i; - char frontend_dev[32], dvr_dev[32], demux_dev[32], sec_dev[32]; + char frontend_dev[32], dvr_dev[32], demux_dev[32]; +#ifndef CONFIG_DVB_HEAD + char sec_dev[32]; +#endif #ifdef CONFIG_DVB_HEAD sprintf(frontend_dev, "/dev/dvb/adapter%d/frontend0", n); -- cgit v1.2.3