Mercurial > mplayer.hg
changeset 6111:582960ab7cc7
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()
author | albeu |
---|---|
date | Fri, 17 May 2002 23:51:37 +0000 |
parents | 7bea806b9c5f |
children | 69b3c25728fb |
files | libao2/ao_dxr2.c libvo/vo_dxr2.c libvo/x11_common.c |
diffstat | 3 files changed, 76 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libao2/ao_dxr2.c Fri May 17 23:47:27 2002 +0000 +++ b/libao2/ao_dxr2.c Fri May 17 23:51:37 2002 +0000 @@ -68,6 +68,9 @@ // return: 1=success 0=fail static int init(int rate,int channels,int format,int flags){ + if(dxr2_fd <= 0) + return 0; + ao_data.outburst=2048; ao_data.samplerate=rate; ao_data.channels=channels; @@ -139,7 +142,6 @@ extern void dxr2_send_packet(unsigned char* data,int len,int id,int timestamp); extern void dxr2_send_lpcm_packet(unsigned char* data,int len,int id,int timestamp,int freq_id); extern int vo_pts; -static int preload = 1; // return: how many bytes can be played without blocking static int get_space(){ float x=(float)(vo_pts-ao_data.pts)/90000.0;
--- a/libvo/vo_dxr2.c Fri May 17 23:47:27 2002 +0000 +++ b/libvo/vo_dxr2.c Fri May 17 23:51:37 2002 +0000 @@ -315,6 +315,57 @@ } } +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 @@ 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 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 @@ { 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 @@ 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 @@ 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;
--- a/libvo/x11_common.c Fri May 17 23:47:27 2002 +0000 +++ b/libvo/x11_common.c Fri May 17 23:51:37 2002 +0000 @@ -60,7 +60,7 @@ static int timeout_save=0; char* mDisplayName=NULL; -Display* mDisplay; +Display* mDisplay=NULL; Window mRootWin; int mScreen; int mLocalDisplay; @@ -381,6 +381,7 @@ XSetErrorHandler(NULL); XCloseDisplay( mDisplay ); vo_depthonscreen = 0; + mDisplay=NULL; } #include "../linux/keycodes.h"