[MPlayer-dev-eng] [PATCH] OS/2 Patches

Diego Biurrun diego at biurrun.de
Wed Jul 11 11:31:02 CEST 2007


On Tue, Jul 10, 2007 at 11:13:26PM +0900, KO Myung-Hun wrote:
> Hi/2, all.
> 
> I attach OS/2 patches using InnoTek GCC v3.3.5.

You may wish to join the discussion there, OS/2 support has just been
removed from FFmpeg due to lack of maintenance and parts of your patch
touch FFmpeg.

> --- stream/cache2.c	(revision 23757)
> +++ stream/cache2.c	(working copy)
> @@ -16,12 +16,16 @@
>  #include <unistd.h>
>  
>  #include "osdep/timer.h"
> -#ifndef WIN32
> +#if !defined(WIN32) && !defined(__OS2__)
>  #include <sys/wait.h>
>  #include "osdep/shmem.h"
> -#else
> +#elif defined(WIN32)
>  #include <windows.h>
>  static DWORD WINAPI ThreadProc(void* s);
> +#else   // OS2
> +#define INCL_DOS
> +#include <os2.h>
> +static void ThreadProc( void *s );
>  #endif
>  
>  #include "mp_msg.h"
> @@ -189,7 +193,7 @@
>  
>  cache_vars_t* cache_init(int size,int sector){
>    int num;
> -#ifndef WIN32
> +#if !defined(WIN32) && !defined(__OS2__)
>    cache_vars_t* s=shmem_alloc(sizeof(cache_vars_t));
>  #else
>    cache_vars_t* s=malloc(sizeof(cache_vars_t));
> @@ -203,14 +207,14 @@
>    }//32kb min_size
>    s->buffer_size=num*sector;
>    s->sector_size=sector;
> -#ifndef WIN32
> +#if !defined(WIN32) && !defined(__OS2__)
>    s->buffer=shmem_alloc(s->buffer_size);
>  #else
>    s->buffer=malloc(s->buffer_size);
>  #endif
>  
>    if(s->buffer == NULL){
> -#ifndef WIN32
> +#if !defined(WIN32) && !defined(__OS2__)
>      shmem_free(s,sizeof(cache_vars_t));
>  #else
>      free(s);
> @@ -226,15 +230,19 @@
>  void cache_uninit(stream_t *s) {
>    cache_vars_t* c = s->cache_data;
>    if(!s->cache_pid) return;
> -#ifndef WIN32
> +#if !defined(WIN32) && !defined(__OS2__)
>    kill(s->cache_pid,SIGKILL);
>    waitpid(s->cache_pid,NULL,0);
>  #else
> +#ifdef WIN32
>    TerminateThread((HANDLE)s->cache_pid,0);
> +#else   // OS2
> +  DosKillThread( s->cache_pid );
> +#endif
>    free(c->stream);
>  #endif
>    if(!c) return;
> -#ifndef WIN32
> +#if !defined(WIN32) && !defined(__OS2__)
>    shmem_free(c->buffer,c->buffer_size);
>    shmem_free(s->cache_data,sizeof(cache_vars_t));
>  #else
> @@ -274,16 +282,22 @@
>       min = s->buffer_size - s->fill_limit;
>    }
>    
> -#ifndef WIN32  
> +#if !defined(WIN32) && !defined(__OS2__)
>    if((stream->cache_pid=fork())){
>  #else
>    {
> +#ifdef WIN32
>      DWORD threadId;
> +#endif
>      stream_t* stream2=malloc(sizeof(stream_t));
>      memcpy(stream2,s->stream,sizeof(stream_t));
>      s->stream=stream2;
> +#ifdef WIN32
>      stream->cache_pid = CreateThread(NULL,0,ThreadProc,s,0,&threadId);
> +#else   // OS2
> +    stream->cache_pid = _beginthread( ThreadProc, NULL, 256 * 1024, s );
>  #endif
> +#endif
>      // wait until cache is filled at least prefill_init %
>      mp_msg(MSGT_CACHE,MSGL_V,"CACHE_PRE_INIT: %"PRId64" [%"PRId64"] %"PRId64"  pre:%d  eof:%d  \n",
>  	(int64_t)s->min_filepos,(int64_t)s->read_filepos,(int64_t)s->max_filepos,min,s->eof);
> @@ -300,12 +314,17 @@
>      return 1; // parent exits
>    }
>    
> +#if defined(WIN32) || defined(__OS2__)
> +}
>  #ifdef WIN32
> -}
>  static DWORD WINAPI ThreadProc(void*s){
> +#else   // OS2
> +static void ThreadProc( void *s ){
>  #endif
> +#endif
>    
>  // cache thread mainloop:
> +
>    signal(SIGTERM,exit_sighandler); // kill
>    while(1){
>      if(!cache_fill((cache_vars_t*)s)){

I don't really like this porting style at all.  Littering files with
preprocessor conditionals is not a good solution.  Yes, I know that
MPlayer is already full of code like this...

> --- libao2/ao_dart.c	(revision 0)
> +++ libao2/ao_dart.c	(revision 0)
> @@ -0,0 +1,253 @@
> +/*
> + * ao_dart.c - libao2 DART Audio Output Driver for MPlayer
> + *
> + * Copyleft 2007 by KO Myung-Hun (komh at chollian.net)
> + *
> + * Changes :
> + *     KO Myung-Hun <komh at chollian.net> 2007/07/08
> + *         - Call fast_memcpy instead of memcpy()
> + */

If you add a new file please put in a proper license header like
vidix/vidixlib.c for example.

> --- libvo/vo_kva.c	(revision 0)
> +++ libvo/vo_kva.c	(revision 0)
> @@ -0,0 +1,875 @@
> +/*
> + *  vo_kva.c
> + *
> + *  Copyleft 2007 by KO Myung-Hun (komh at chollian.net)
> + *
> + *  Changes :
> + *      KO Myung-Hun <komh at chollian.net> 2007/06/11
> + *          - Added workaround for T23 laptop with S3 Video
> + *
> + *      KO Myung-Hun <komh at chollian.net> 2007/06/17
> + *          - Implemented VOCTRL_SET_EQUALIZER and VOCTRL_GET_EQUALIZER
> + *          - Added YV12 as a supported image format
> + *          - Added process VK_ENTER and VK_NEWLINE
> + *
> + *      KO Myung-Hun <komh at chollian.net> 2007/07/08
> + *          - Call fast_memcpy() instead of memcpy()
> + *
> + */

ditto

> --- dvdread/dvd_reader.c	(revision 23757)
> +++ dvdread/dvd_reader.c	(working copy)
> @@ -460,7 +460,7 @@
>              }
>              fclose( mntfile );
>  	}
> -#elif defined(__MINGW32__)	
> +#elif defined(__MINGW32__) || defined( __OS2__ )
>  	dev_name = strdup(path);
>  	auth_drive = DVDOpenImageFile( path, have_css );
>  #endif

This patch should be sent upstream to libdvdread (as well).

> --- libdvdcss/device.c	(revision 23757)
> +++ libdvdcss/device.c	(working copy)

This patch should be sent upstream to libdvdcss (as well).

> @@ -110,6 +123,10 @@
>      {
>          return 1;
>      }
> +#elif defined( __OS2__ )
> +    /* We should consider a case of file ? */
> +
> +    return 1;
>  #else
>      struct stat fileinfo;
>      int ret;

I don't understand the comment.

> Index: configure
> ===================================================================
> --- configure	(revision 23757)
> +++ configure	(working copy)
> @@ -1175,6 +1185,9 @@
>    MINGW32*)
>      system_name=MINGW32
>      ;;
> +  OS/2)
> +    system_name=OS/2
> +    ;;

This is wrong, no system_name mangling is necessary.

> @@ -7402,7 +7479,7 @@
>  LIBDIR = \$(DESTDIR)$_libdir
>  # FFmpeg uses libdir instead of LIBDIR
>  libdir = \$(LIBDIR)
> -#AR = ar
> +AR = $_ar
>  CC = $_cc
>  CXX = $_cc
>  HOST_CC = $_host_cc

This is unused.

> --- osdep/getch2-os2.c	(revision 0)
> +++ osdep/getch2-os2.c	(revision 0)
> @@ -0,0 +1,163 @@
> +/* OS/2 TermIO for MPlayer          (C) 2007 KO Myung-Hun */

same as above, license missing

> --- libavformat/os_support.c	(revision 9571)
> +++ libavformat/os_support.c	(working copy)
> @@ -24,7 +24,7 @@
>  #if defined(__MINGW32__)
>  #include <sys/types.h>
>  #include <sys/timeb.h>
> -#elif defined(CONFIG_OS2)
> +#elif defined(__OS2__)
>  #include <string.h>
>  #include <sys/time.h>
>  #else
> --- libavformat/os_support.h	(revision 9571)
> +++ libavformat/os_support.h	(working copy)
> @@ -26,7 +26,7 @@
>   * @file os_support.h
>   * miscellaneous OS support macros and functions.
>   *
> - * - socklen_t typedef (BeOS, Innotek libc)
> + * - socklen_t typedef (BeOS, OS/2)
>   * - usleep() (Win32, BeOS, OS/2)
>   * - lseek() (Win32)
>   * - floatf() (OS/2)
> @@ -35,7 +35,7 @@
>   * - poll() (BeOS, MinGW)
>   */
>  
> -#if defined(__BEOS__) || defined(__INNOTEK_LIBC__)
> +#if defined(__BEOS__) || defined(__OS2__)
>  typedef int socklen_t;
>  #endif
>  
> @@ -68,7 +68,7 @@
>  #  endif
>  #endif
>  
> -#if defined(CONFIG_OS2)
> +#if defined(__OS2__) && !defined(__INNOTEK_LIBC__)
>  #include <stdlib.h>
>  static inline int usleep(unsigned int t) { return _sleep2(t / 1000); }
>  static inline int strcasecmp(const char* s1, const char* s2) { return stricmp(s1,s2); }
> --- libavutil/internal.h	(revision 9571)
> +++ libavutil/internal.h	(working copy)
> @@ -102,12 +102,12 @@
>  #    define vsnprintf _vsnprintf
>  
>  /* __MINGW32__ end */
> -#elif defined (CONFIG_OS2)
> +#elif defined (__OS2__)
>  /* OS/2 EMX */
>  
>  #    include <float.h>
>  
> -#endif /* !__MINGW32__ && CONFIG_OS2 */
> +#endif /* !__MINGW32__ && __OS2__ */
>  
>  #ifdef USE_FASTMEMCPY
>  #    include "libvo/fastmemcpy.h"

FFmpeg patches should be sent to ffmpeg-devel.

Diego



More information about the MPlayer-dev-eng mailing list