mirror of
https://github.com/mpv-player/mpv
synced 2024-12-24 07:33:46 +01:00
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
This commit is contained in:
parent
7562937d95
commit
c6eed70a13
@ -68,6 +68,9 @@ static int freq_id=0;
|
|||||||
// return: 1=success 0=fail
|
// return: 1=success 0=fail
|
||||||
static int init(int rate,int channels,int format,int flags){
|
static int init(int rate,int channels,int format,int flags){
|
||||||
|
|
||||||
|
if(dxr2_fd <= 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
ao_data.outburst=2048;
|
ao_data.outburst=2048;
|
||||||
ao_data.samplerate=rate;
|
ao_data.samplerate=rate;
|
||||||
ao_data.channels=channels;
|
ao_data.channels=channels;
|
||||||
@ -139,7 +142,6 @@ static void audio_resume()
|
|||||||
extern void dxr2_send_packet(unsigned char* data,int len,int id,int timestamp);
|
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 void dxr2_send_lpcm_packet(unsigned char* data,int len,int id,int timestamp,int freq_id);
|
||||||
extern int vo_pts;
|
extern int vo_pts;
|
||||||
static int preload = 1;
|
|
||||||
// return: how many bytes can be played without blocking
|
// return: how many bytes can be played without blocking
|
||||||
static int get_space(){
|
static int get_space(){
|
||||||
float x=(float)(vo_pts-ao_data.pts)/90000.0;
|
float x=(float)(vo_pts-ao_data.pts)/90000.0;
|
||||||
|
@ -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)
|
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;
|
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);
|
ioctl(dxr2_fd, DXR2_IOC_SET_TV_OUTPUT_FORMAT, &arg);
|
||||||
|
|
||||||
// Subtitles
|
// Subtitles
|
||||||
|
|
||||||
|
arg = DXR2_SUBPICTURE_ON;
|
||||||
|
ioctl(dxr2_fd,DXR2_IOC_ENABLE_SUBPICTURE,&arg);
|
||||||
arg3.arg1 = DXR2_STREAM_SUBPICTURE;
|
arg3.arg1 = DXR2_STREAM_SUBPICTURE;
|
||||||
arg3.arg2 = 0;
|
arg3.arg2 = 0;
|
||||||
ioctl(dxr2_fd, DXR2_IOC_SELECT_STREAM, &arg3);
|
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[])
|
static uint32_t draw_frame(uint8_t * src[])
|
||||||
{
|
{
|
||||||
vo_mpegpes_t *p=(vo_mpegpes_t *)src[0];
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,9 +562,12 @@ static void uninit(void)
|
|||||||
{
|
{
|
||||||
mp_msg(MSGT_VO,MSGL_DBG2, "VO: [dxr2] Uninitializing\n" );
|
mp_msg(MSGT_VO,MSGL_DBG2, "VO: [dxr2] Uninitializing\n" );
|
||||||
|
|
||||||
dxr2_send_eof();
|
|
||||||
flush_dxr2();
|
|
||||||
if (dxr2_fd > 0) {
|
if (dxr2_fd > 0) {
|
||||||
|
if(playing) {
|
||||||
|
dxr2_send_eof();
|
||||||
|
flush_dxr2();
|
||||||
|
playing = 0;
|
||||||
|
}
|
||||||
close(dxr2_fd);
|
close(dxr2_fd);
|
||||||
dxr2_fd = -1;
|
dxr2_fd = -1;
|
||||||
}
|
}
|
||||||
@ -675,8 +734,8 @@ static uint32_t preinit(const char *arg) {
|
|||||||
ioctl(dxr2_fd, DXR2_IOC_SET_VGA_PARAMETERS, &vga);
|
ioctl(dxr2_fd, DXR2_IOC_SET_VGA_PARAMETERS, &vga);
|
||||||
|
|
||||||
// Remove the white screen
|
// Remove the white screen
|
||||||
sub_vo->check_events(); // at least x11 need this to remove his window
|
|
||||||
sub_vo->uninit();
|
sub_vo->uninit();
|
||||||
|
vo_uninit(); // x11 need this to fully disapear
|
||||||
sub_vo = NULL;
|
sub_vo = NULL;
|
||||||
|
|
||||||
om.arg = DXR2_OVERLAY_WINDOW_KEY;
|
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);
|
ioctl(dxr2_fd, DXR2_IOC_SET_OVERLAY_POSITION,&win);
|
||||||
return VO_TRUE;
|
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:
|
case VOCTRL_QUERY_VAA:
|
||||||
query_vaa((vo_vaa_t*)data);
|
query_vaa((vo_vaa_t*)data);
|
||||||
return VO_TRUE;
|
return VO_TRUE;
|
||||||
|
@ -60,7 +60,7 @@ static int dpms_disabled=0;
|
|||||||
static int timeout_save=0;
|
static int timeout_save=0;
|
||||||
|
|
||||||
char* mDisplayName=NULL;
|
char* mDisplayName=NULL;
|
||||||
Display* mDisplay;
|
Display* mDisplay=NULL;
|
||||||
Window mRootWin;
|
Window mRootWin;
|
||||||
int mScreen;
|
int mScreen;
|
||||||
int mLocalDisplay;
|
int mLocalDisplay;
|
||||||
@ -381,6 +381,7 @@ void vo_uninit( void )
|
|||||||
XSetErrorHandler(NULL);
|
XSetErrorHandler(NULL);
|
||||||
XCloseDisplay( mDisplay );
|
XCloseDisplay( mDisplay );
|
||||||
vo_depthonscreen = 0;
|
vo_depthonscreen = 0;
|
||||||
|
mDisplay=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "../linux/keycodes.h"
|
#include "../linux/keycodes.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user