summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrantišek Dvořák <valtri@users.sourceforge.net>2006-05-07 09:31:57 +0000
committerFrantišek Dvořák <valtri@users.sourceforge.net>2006-05-07 09:31:57 +0000
commit3b1dc58073ea3ededb67ca672dedf62b2471590f (patch)
treec46b127b630f18638d3a6295625c064f6ab404ce /src
parent855fca8b75c5734fba4b9065750fbd52848c41ae (diff)
downloadxine-lib-3b1dc58073ea3ededb67ca672dedf62b2471590f.tar.gz
xine-lib-3b1dc58073ea3ededb67ca672dedf62b2471590f.tar.bz2
Setup FS segment to make win32 gods happy with the smiley red deamon.
(fixed multithread audio and video playback on FreeBSD with different LDTs) One coverity fix. CVS patchset: 7988 CVS date: 2006/05/07 09:31:57
Diffstat (limited to 'src')
-rw-r--r--src/libw32dll/qt_decoder.c9
-rw-r--r--src/libw32dll/w32codec.c8
-rw-r--r--src/libw32dll/wine/ldt_keeper.c32
-rw-r--r--src/libw32dll/wine/ldt_keeper.h5
-rw-r--r--src/libw32dll/wine/pe_resource.c2
5 files changed, 31 insertions, 25 deletions
diff --git a/src/libw32dll/qt_decoder.c b/src/libw32dll/qt_decoder.c
index 4a0439d1b..0f8dc8002 100644
--- a/src/libw32dll/qt_decoder.c
+++ b/src/libw32dll/qt_decoder.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000-2004 the xine project
+ * Copyright (C) 2000-2006 the xine project
*
* This file is part of xine, a free video player.
*
@@ -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: qt_decoder.c,v 1.41 2006/05/03 19:46:08 dsalt Exp $
+ * $Id: qt_decoder.c,v 1.42 2006/05/07 09:31:57 valtri Exp $
*
* quicktime video/audio decoder plugin, using win32 dlls
* most of this code comes directly from MPlayer
@@ -458,7 +458,7 @@ static void qta_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
long out_frames, out_bytes;
int error, frames_left, bytes_sent;
- Check_FS_Segment();
+ Check_FS_Segment(this->ldt_fs);
pthread_mutex_lock(&win32_codec_mutex);
error = this->SoundConverterConvertBuffer (this->myConverter,
@@ -900,6 +900,7 @@ static void qtv_init_driver (qtv_decoder_t *this, buf_element_t *buf) {
lprintf ("video: framedescHandle = %x\n", this->framedescHandle);
memcpy (*this->framedescHandle, id, id->idSize);
+ free(id);
/*
* alloc video plane
@@ -988,7 +989,7 @@ static void qtv_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
ComponentResult cres;
vo_frame_t *img;
- Check_FS_Segment();
+ Check_FS_Segment(this->ldt_fs);
pthread_mutex_lock(&win32_codec_mutex);
diff --git a/src/libw32dll/w32codec.c b/src/libw32dll/w32codec.c
index de3927abc..d567b9183 100644
--- a/src/libw32dll/w32codec.c
+++ b/src/libw32dll/w32codec.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000-2003 the xine project
+ * Copyright (C) 2000-2006 the xine project
*
* This file is part of xine, a free video player.
*
@@ -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: w32codec.c,v 1.151 2006/05/03 19:46:08 dsalt Exp $
+ * $Id: w32codec.c,v 1.152 2006/05/07 09:31:57 valtri Exp $
*
* routines for using w32 codecs
* DirectShow support by Miguel Freitas (Nov/2001)
@@ -856,7 +856,7 @@ static void w32v_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
vo_frame_t *img;
uint8_t *img_buffer = this->img_buffer;
- Check_FS_Segment();
+ Check_FS_Segment(this->ldt_fs);
/* decoder video frame */
@@ -1494,7 +1494,7 @@ static void w32a_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
if( (int)buf->size <= 0 )
return;
- Check_FS_Segment();
+ Check_FS_Segment(this->ldt_fs);
w32a_decode_audio (this, buf->content, buf->size,
buf->decoder_flags & BUF_FLAG_FRAME_END,
diff --git a/src/libw32dll/wine/ldt_keeper.c b/src/libw32dll/wine/ldt_keeper.c
index 49cdc4e87..11711ce62 100644
--- a/src/libw32dll/wine/ldt_keeper.c
+++ b/src/libw32dll/wine/ldt_keeper.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000-2003 the xine project
+ * Copyright (C) 2000-2006 the xine project
*
* This file is part of xine, a free video player.
*
@@ -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: ldt_keeper.c,v 1.14 2006/04/05 22:12:21 valtri Exp $
+ * $Id: ldt_keeper.c,v 1.15 2006/05/07 09:31:57 valtri Exp $
*
*
* contents:
@@ -138,35 +138,37 @@ struct modify_ldt_ldt_s {
#define TEB_SEL_IDX 1024
#endif
-static unsigned int teb_sel = LDT_SEL(TEB_SEL_IDX);
-
static ldt_fs_t global_ldt_fs;
static int global_usage_count = 0;
#ifdef __cplusplus
extern "C"
#endif
-void Setup_FS_Segment(void)
+void Setup_FS_Segment(ldt_fs_t *ldt_fs)
{
__asm__ __volatile__(
- "movl %0,%%eax; movw %%ax, %%fs" : : "r" (teb_sel) : "%eax"
+ "movl %0,%%eax; movw %%ax, %%fs" : : "r" (ldt_fs->teb_sel) : "%eax"
);
}
-void Check_FS_Segment(void)
+void Check_FS_Segment(ldt_fs_t *ldt_fs)
{
+#if defined(__FreeBSD__) && defined(LDT_AUTO_ALLOC)
int fs;
__asm__ __volatile__(
"movw %%fs,%%ax; mov %%eax,%0" : "=r" (fs) :: "%eax"
);
fs = fs & 0xffff;
- if( fs != teb_sel ) {
+ if( fs != ldt_fs->teb_sel ) {
printf("ldt_keeper: FS segment is not set or has being lost!\n");
printf(" Please report this error to xine-devel@lists.sourceforge.net\n");
printf(" Aborting....\n");
abort();
}
+#else
+ Setup_FS_Segment(ldt_fs);
+#endif
}
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
@@ -185,10 +187,12 @@ static void LDT_EntryToBytes( unsigned long *buffer, const struct modify_ldt_ldt
}
#endif
-static int _modify_ldt(struct modify_ldt_ldt_s array)
+static int _modify_ldt(ldt_fs_t *ldt_fs, struct modify_ldt_ldt_s array)
{
int ret;
+ ldt_fs->teb_sel = LDT_SEL(TEB_SEL_IDX);
+
#ifdef __linux__
ret=modify_ldt(0x1, &array, sizeof(struct modify_ldt_ldt_s));
if(ret<0)
@@ -206,7 +210,7 @@ static int _modify_ldt(struct modify_ldt_ldt_s array)
#if defined(__FreeBSD__) && defined(LDT_AUTO_ALLOC)
ret = i386_set_ldt(LDT_AUTO_ALLOC, (union descriptor *)d, 1);
array.entry_number = ret;
- teb_sel = LDT_SEL(ret);
+ ldt_fs->teb_sel = LDT_SEL(ret);
#else
ret = i386_set_ldt(array.entry_number, (union descriptor *)d, 1);
#endif
@@ -223,7 +227,7 @@ static int _modify_ldt(struct modify_ldt_ldt_s array)
#if defined(__svr4__)
{
struct ssd ssd;
- ssd.sel = teb_sel;
+ ssd.sel = ldt_fs->teb_sel;
ssd.bo = array.base_addr;
ssd.ls = array.limit;
ssd.acc1 = ((array.read_exec_only == 0) << 1) |
@@ -317,7 +321,7 @@ ldt_fs_t* Setup_LDT_Keeper(void)
array.contents=MODIFY_LDT_CONTENTS_DATA;
array.limit_in_pages=0;
- ret = _modify_ldt(array);
+ ret = _modify_ldt(ldt_fs, array);
ldt_fs->prev_struct = (char*)malloc(sizeof(char) * 8);
*(void**)array.base_addr = ldt_fs->prev_struct;
@@ -331,7 +335,7 @@ ldt_fs_t* Setup_LDT_Keeper(void)
memcpy( ldt_fs, &global_ldt_fs, sizeof(ldt_fs_t) );
}
- Setup_FS_Segment();
+ Setup_FS_Segment(ldt_fs);
return ldt_fs;
}
@@ -362,7 +366,7 @@ void Restore_LDT_Keeper(ldt_fs_t* ldt_fs)
/* mark LDT entry as free again */
memset(&array, 0, sizeof(struct modify_ldt_ldt_s));
array.entry_number=TEB_SEL_IDX;
- _modify_ldt(array);
+ _modify_ldt(ldt_fs, array);
}
free(ldt_fs);
}
diff --git a/src/libw32dll/wine/ldt_keeper.h b/src/libw32dll/wine/ldt_keeper.h
index ca084d885..0851eaa0c 100644
--- a/src/libw32dll/wine/ldt_keeper.h
+++ b/src/libw32dll/wine/ldt_keeper.h
@@ -10,11 +10,12 @@ typedef struct {
void* fs_seg;
char* prev_struct;
int fd;
+ unsigned int teb_sel;
} ldt_fs_t;
-void Setup_FS_Segment(void);
+void Setup_FS_Segment(ldt_fs_t *ldt_fs);
ldt_fs_t* Setup_LDT_Keeper(void);
-void Check_FS_Segment(void);
+void Check_FS_Segment(ldt_fs_t *ldt_fs);
void Restore_LDT_Keeper(ldt_fs_t* ldt_fs);
#ifdef __cplusplus
}
diff --git a/src/libw32dll/wine/pe_resource.c b/src/libw32dll/wine/pe_resource.c
index 2af09f60e..6acfef2f0 100644
--- a/src/libw32dll/wine/pe_resource.c
+++ b/src/libw32dll/wine/pe_resource.c
@@ -253,7 +253,7 @@ PE_EnumResourceNamesA(
else
typeW = (LPWSTR)type;
resdir = GetResDirEntryW(resdir,typeW,(DWORD)pem->pe_resource,FALSE);
- if (HIWORD(typeW))
+ if (HIWORD(type))
HeapFree(heap,0,typeW);
if (!resdir)
return FALSE;