summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authoralbeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-05-17 23:51:37 +0000
committeralbeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-05-17 23:51:37 +0000
commitc6eed70a1316fe7207c3b3ce5d8aa76360b13833 (patch)
tree4f644341d806c79eae0f5353f4cd787582034aa7 /libvo
parent7562937d959ec617d4f78fd6d06aed7164b22255 (diff)
downloadmpv-c6eed70a1316fe7207c3b3ce5d8aa76360b13833.tar.bz2
mpv-c6eed70a1316fe7207c3b3ce5d8aa76360b13833.tar.xz
Workaround the bug in x11 vo's (if it's one) wich let a window in the way
even after vo->uninit(). Support for dvd/vobsub subtitles. No more crash if vo->config is not called before vo->uninit() git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6112 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r--libvo/vo_dxr2.c76
-rw-r--r--libvo/x11_common.c3
2 files changed, 73 insertions, 6 deletions
diff --git a/libvo/vo_dxr2.c b/libvo/vo_dxr2.c
index f370c69a36..4791912d13 100644
--- a/libvo/vo_dxr2.c
+++ b/libvo/vo_dxr2.c
@@ -315,6 +315,57 @@ void dxr2_send_lpcm_packet(unsigned char* data,int len,int id,unsigned int times
}
}
+void dxr2_send_sub_packet(unsigned char* data,int len,int id,unsigned int timestamp) {
+ int ptslen=5;
+
+ if(dxr2_fd < 0) {
+ mp_msg(MSGT_VO,MSGL_ERR,"DXR2 fd is not valid\n");
+ return;
+ }
+
+ if (((int) timestamp)<0)
+ timestamp=0;
+
+ mp_msg(MSGT_VO,MSGL_DBG2,"dxr2_send_sub_packet(timestamp=%d)\n", timestamp);
+ // startcode:
+ pack[0]=pack[1]=0;pack[2]=0x01;
+
+ // stream id
+ pack[3]=0xBD;
+
+ while(len>=4){
+ int payload_size= PACK_MAX_SIZE-(7+ptslen+3);
+ if(payload_size>len) payload_size= len;
+
+ pack[4]=(3+ptslen+1+payload_size)>>8;
+ pack[5]=(3+ptslen+1+payload_size)&255;
+
+ pack[6]=0x81;
+ if(ptslen){
+ int x;
+ pack[7]=0x80;
+ pack[8]=ptslen;
+ // presentation time stamp:
+ x=(0x02 << 4) | (((timestamp >> 30) & 0x07) << 1) | 1;
+ pack[9]=x;
+ x=((((timestamp >> 15) & 0x7fff) << 1) | 1);
+ pack[10]=x>>8; pack[11]=x&255;
+ x=((((timestamp) & 0x7fff) << 1) | 1);
+ pack[12]=x>>8; pack[13]=x&255;
+ } else {
+ pack[7]=0x00;
+ pack[8]=0x00;
+ }
+ pack[ptslen+9] = id;
+
+ write_dxr2(pack,7+ptslen+3);
+ write_dxr2(data,payload_size);
+ len -= payload_size;
+ data += payload_size;
+ ptslen = 0;
+ }
+}
+
static uint32_t config(uint32_t s_width, uint32_t s_height, uint32_t width, uint32_t height, uint32_t flags, char *title, uint32_t format, const vo_tune_info_t *info)
{
int arg;
@@ -422,6 +473,9 @@ static uint32_t config(uint32_t s_width, uint32_t s_height, uint32_t width, uint
ioctl(dxr2_fd, DXR2_IOC_SET_TV_OUTPUT_FORMAT, &arg);
// Subtitles
+
+ arg = DXR2_SUBPICTURE_ON;
+ ioctl(dxr2_fd,DXR2_IOC_ENABLE_SUBPICTURE,&arg);
arg3.arg1 = DXR2_STREAM_SUBPICTURE;
arg3.arg2 = 0;
ioctl(dxr2_fd, DXR2_IOC_SELECT_STREAM, &arg3);
@@ -475,8 +529,10 @@ static void draw_osd(void)
static uint32_t draw_frame(uint8_t * src[])
{
vo_mpegpes_t *p=(vo_mpegpes_t *)src[0];
- dxr2_send_packet(p->data, p->size, p->id, p->timestamp);
-
+ if(p->id == 0x1E0) {// Video
+ dxr2_send_packet(p->data, p->size, p->id, p->timestamp);
+ } else if(p->id == 0x20) // Subtitles
+ dxr2_send_sub_packet(p->data, p->size, p->id, p->timestamp);
return 0;
}
@@ -506,9 +562,12 @@ static void uninit(void)
{
mp_msg(MSGT_VO,MSGL_DBG2, "VO: [dxr2] Uninitializing\n" );
- dxr2_send_eof();
- flush_dxr2();
if (dxr2_fd > 0) {
+ if(playing) {
+ dxr2_send_eof();
+ flush_dxr2();
+ playing = 0;
+ }
close(dxr2_fd);
dxr2_fd = -1;
}
@@ -675,8 +734,8 @@ static uint32_t preinit(const char *arg) {
ioctl(dxr2_fd, DXR2_IOC_SET_VGA_PARAMETERS, &vga);
// Remove the white screen
- sub_vo->check_events(); // at least x11 need this to remove his window
sub_vo->uninit();
+ vo_uninit(); // x11 need this to fully disapear
sub_vo = NULL;
om.arg = DXR2_OVERLAY_WINDOW_KEY;
@@ -716,6 +775,13 @@ static uint32_t control(uint32_t request, void *data, ...)
ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_POSITION,&win);
return VO_TRUE;
}
+ case VOCTRL_SET_SPU_PALETTE: {
+ if(ioctl(dxr2_fd,DXR2_IOC_SET_SUBPICTURE_PALETTE,data) < 0) {
+ mp_msg(MSGT_VO,MSGL_WARN,"VO: [dxr2] SPU palette loading failed\n");
+ return VO_ERROR;
+ }
+ return VO_TRUE;
+ }
case VOCTRL_QUERY_VAA:
query_vaa((vo_vaa_t*)data);
return VO_TRUE;
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index 564824130c..a572560e6c 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -60,7 +60,7 @@ static int dpms_disabled=0;
static int timeout_save=0;
char* mDisplayName=NULL;
-Display* mDisplay;
+Display* mDisplay=NULL;
Window mRootWin;
int mScreen;
int mLocalDisplay;
@@ -381,6 +381,7 @@ void vo_uninit( void )
XSetErrorHandler(NULL);
XCloseDisplay( mDisplay );
vo_depthonscreen = 0;
+ mDisplay=NULL;
}
#include "../linux/keycodes.h"