mirror of
https://github.com/mpv-player/mpv
synced 2025-01-26 01:23:17 +00:00
cache support for OS/2
patch by KO Myung-Hun, komh chollian net git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26109 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
effb6040ee
commit
23defac730
@ -16,12 +16,16 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "osdep/timer.h"
|
#include "osdep/timer.h"
|
||||||
#ifndef WIN32
|
#ifdef WIN32
|
||||||
#include <sys/wait.h>
|
|
||||||
#include "osdep/shmem.h"
|
|
||||||
#else
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
static DWORD WINAPI ThreadProc(void* s);
|
static DWORD WINAPI ThreadProc(void* s);
|
||||||
|
#elif defined(__OS2__)
|
||||||
|
#define INCL_DOS
|
||||||
|
#include <os2.h>
|
||||||
|
static void ThreadProc( void *s );
|
||||||
|
#else
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include "osdep/shmem.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mp_msg.h"
|
#include "mp_msg.h"
|
||||||
@ -190,7 +194,7 @@ int cache_fill(cache_vars_t* s){
|
|||||||
|
|
||||||
cache_vars_t* cache_init(int size,int sector){
|
cache_vars_t* cache_init(int size,int sector){
|
||||||
int num;
|
int num;
|
||||||
#ifndef WIN32
|
#if !defined(WIN32) && !defined(__OS2__)
|
||||||
cache_vars_t* s=shmem_alloc(sizeof(cache_vars_t));
|
cache_vars_t* s=shmem_alloc(sizeof(cache_vars_t));
|
||||||
#else
|
#else
|
||||||
cache_vars_t* s=malloc(sizeof(cache_vars_t));
|
cache_vars_t* s=malloc(sizeof(cache_vars_t));
|
||||||
@ -204,14 +208,14 @@ cache_vars_t* cache_init(int size,int sector){
|
|||||||
}//32kb min_size
|
}//32kb min_size
|
||||||
s->buffer_size=num*sector;
|
s->buffer_size=num*sector;
|
||||||
s->sector_size=sector;
|
s->sector_size=sector;
|
||||||
#ifndef WIN32
|
#if !defined(WIN32) && !defined(__OS2__)
|
||||||
s->buffer=shmem_alloc(s->buffer_size);
|
s->buffer=shmem_alloc(s->buffer_size);
|
||||||
#else
|
#else
|
||||||
s->buffer=malloc(s->buffer_size);
|
s->buffer=malloc(s->buffer_size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(s->buffer == NULL){
|
if(s->buffer == NULL){
|
||||||
#ifndef WIN32
|
#if !defined(WIN32) && !defined(__OS2__)
|
||||||
shmem_free(s,sizeof(cache_vars_t));
|
shmem_free(s,sizeof(cache_vars_t));
|
||||||
#else
|
#else
|
||||||
free(s);
|
free(s);
|
||||||
@ -227,20 +231,23 @@ cache_vars_t* cache_init(int size,int sector){
|
|||||||
void cache_uninit(stream_t *s) {
|
void cache_uninit(stream_t *s) {
|
||||||
cache_vars_t* c = s->cache_data;
|
cache_vars_t* c = s->cache_data;
|
||||||
if(!s->cache_pid) return;
|
if(!s->cache_pid) return;
|
||||||
#ifndef WIN32
|
#ifdef WIN32
|
||||||
|
TerminateThread((HANDLE)s->cache_pid,0);
|
||||||
|
#elif defined(__OS2__)
|
||||||
|
DosKillThread( s->cache_pid );
|
||||||
|
DosWaitThread( &s->cache_pid, DCWW_WAIT );
|
||||||
|
#else
|
||||||
kill(s->cache_pid,SIGKILL);
|
kill(s->cache_pid,SIGKILL);
|
||||||
waitpid(s->cache_pid,NULL,0);
|
waitpid(s->cache_pid,NULL,0);
|
||||||
#else
|
|
||||||
TerminateThread((HANDLE)s->cache_pid,0);
|
|
||||||
free(c->stream);
|
|
||||||
#endif
|
#endif
|
||||||
if(!c) return;
|
if(!c) return;
|
||||||
#ifndef WIN32
|
#if defined(WIN32) || defined(__OS2__)
|
||||||
shmem_free(c->buffer,c->buffer_size);
|
free(c->stream);
|
||||||
shmem_free(s->cache_data,sizeof(cache_vars_t));
|
|
||||||
#else
|
|
||||||
free(c->buffer);
|
free(c->buffer);
|
||||||
free(s->cache_data);
|
free(s->cache_data);
|
||||||
|
#else
|
||||||
|
shmem_free(c->buffer,c->buffer_size);
|
||||||
|
shmem_free(s->cache_data,sizeof(cache_vars_t));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,15 +282,21 @@ int stream_enable_cache(stream_t *stream,int size,int min,int seek_limit){
|
|||||||
min = s->buffer_size - s->fill_limit;
|
min = s->buffer_size - s->fill_limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WIN32
|
#if !defined(WIN32) && !defined(__OS2__)
|
||||||
if((stream->cache_pid=fork())){
|
if((stream->cache_pid=fork())){
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
|
#ifdef WIN32
|
||||||
DWORD threadId;
|
DWORD threadId;
|
||||||
|
#endif
|
||||||
stream_t* stream2=malloc(sizeof(stream_t));
|
stream_t* stream2=malloc(sizeof(stream_t));
|
||||||
memcpy(stream2,s->stream,sizeof(stream_t));
|
memcpy(stream2,s->stream,sizeof(stream_t));
|
||||||
s->stream=stream2;
|
s->stream=stream2;
|
||||||
|
#ifdef WIN32
|
||||||
stream->cache_pid = CreateThread(NULL,0,ThreadProc,s,0,&threadId);
|
stream->cache_pid = CreateThread(NULL,0,ThreadProc,s,0,&threadId);
|
||||||
|
#else // OS2
|
||||||
|
stream->cache_pid = _beginthread( ThreadProc, NULL, 256 * 1024, s );
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
// wait until cache is filled at least prefill_init %
|
// 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",
|
mp_msg(MSGT_CACHE,MSGL_V,"CACHE_PRE_INIT: %"PRId64" [%"PRId64"] %"PRId64" pre:%d eof:%d \n",
|
||||||
@ -301,9 +314,13 @@ int stream_enable_cache(stream_t *stream,int size,int min,int seek_limit){
|
|||||||
return 1; // parent exits
|
return 1; // parent exits
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
#if defined(WIN32) || defined(__OS2__)
|
||||||
}
|
}
|
||||||
|
#ifdef WIN32
|
||||||
static DWORD WINAPI ThreadProc(void*s){
|
static DWORD WINAPI ThreadProc(void*s){
|
||||||
|
#else // OS2
|
||||||
|
static void ThreadProc( void *s ){
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_NEW_GUI
|
#ifdef HAVE_NEW_GUI
|
||||||
|
Loading…
Reference in New Issue
Block a user