Commit 4c1e4249 authored by Vincent Seguin's avatar Vincent Seguin

GGI fonctionnel. N'oubliez pas de d�finit GII_INPUT.

Nettoyage de video_* et intf_*.
parent fa66a86a
......@@ -17,7 +17,7 @@
VIDEO=X11
#VIDEO=DGA (not yet supported)
#VIDEO=FB
#VIDEO=GGI (not yet supported)
#VIDEO=GGI
#VIDEO=BEOS (not yet supported)
# Target architecture and optimization
......@@ -69,7 +69,9 @@ ifeq ($(VIDEO),X11)
LIB += -L/usr/X11R6/lib
LIB += -lX11
LIB += -lXext
LIB += -lXpm
endif
ifeq ($(VIDEO),GGI)
LIB += -lggi
endif
# System dependant libraries
......@@ -265,7 +267,7 @@ vlc: $(C_OBJ) $(ASM_OBJ)
# Generic rules (see below)
#
$(dependancies): %.d: FORCE
@make -s --no-print-directory -f Makefile.dep $@
@$(MAKE) -s --no-print-directory -f Makefile.dep $@
$(C_OBJ): %.o: dep/%.d
......
......@@ -29,6 +29,8 @@
#define VIDEO_OPTIONS "X11"
#elif defined(VIDEO_FB)
#define VIDEO_OPTIONS "Framebuffer"
#elif defined(VIDEO_GGI)
#define VIDEO_OPTIONS "GGI"
#else
#define VIDEO_OPTIONS ""
#endif
......@@ -47,8 +49,6 @@
* General compilation options
*******************************************************************************/
#define FRAMEBUFFER
/* Define for DVB support - Note that some extensions or restrictions may be
* incompatible with native MPEG2 streams */
//#define DVB_EXTENSIONS
......
......@@ -5,20 +5,14 @@
* This module describes the programming interface for video output threads.
* It includes functions allowing to open a new thread, send pictures to a
* thread, and destroy a previously oppenned video output thread.
*******************************************************************************
* Requires:
* "config.h"
* "common.h"
* "mtime.h"
* "vlc_thread.h"
* "video.h"
*******************************************************************************/
/*******************************************************************************
* vout_thread_t: video output thread descriptor
*******************************************************************************
* Any independant video output device, such as an X11 window, is represented
* by a video output thread, and described using following structure.
* Any independant video output device, such as an X11 window or a GGI device,
* is represented by a video output thread, and described using following
* structure.
*******************************************************************************/
typedef struct vout_thread_s
{
......@@ -38,13 +32,6 @@ typedef struct vout_thread_s
float f_x_ratio; /* horizontal display ratio */
float f_y_ratio; /* vertical display ratio */
/* Output method */
p_vout_sys_t p_sys; /* system output method */
/* Video heap */
int i_pictures; /* current heap size */
picture_t p_picture[VOUT_MAX_PICTURES]; /* pictures */
#ifdef STATS
/* Statistics */
count_t c_loops; /* number of loops */
......@@ -52,6 +39,13 @@ typedef struct vout_thread_s
count_t c_pictures; /* number of pictures added to heap */
#endif
/* Output method */
p_vout_sys_t p_sys; /* system output method */
/* Video heap */
int i_pictures; /* current heap size */
picture_t p_picture[VOUT_MAX_PICTURES]; /* pictures */
/* YUV translation tables, for 15,16 and 24/32 bpp displays. 16 bits and 32
* bits pointers points on the same data.
* CAUTION: these tables are translated: their origin is -384 */
......@@ -61,37 +55,14 @@ typedef struct vout_thread_s
u32 * pi_trans32_red;
u32 * pi_trans32_green;
u32 * pi_trans32_blue;
/* Rendering functions - these functions are of vout_render_blank_t and
* vout_render_line_t, but are not declared here using these types since
* they require vout_thread_t to be defined */
/* void (* RenderRGBBlank) ( struct vout_thread_s *p_vout, pixel_t pixel,
int i_x, int i_y, int i_width, int i_height );
void (* RenderPixelBlank) ( struct vout_thread_s *p_vout, pixel_t pixel,
int i_x, int i_y, int i_width, int i_height );
void (* RenderRGBLine) ( struct vout_thread_s *p_vout, picture_t *p_pic,
int i_x, int i_y, int i_pic_x, int i_pic_y,
int i_width, int i_line_width, int i_ratio );
void (* RenderPixelLine) ( struct vout_thread_s *p_vout, picture_t *p_pic,
int i_x, int i_y, int i_pic_x, int i_pic_y,
int i_width, int i_line_width, int i_ratio );
void (* RenderRGBMaskLine) ( struct vout_thread_s *p_vout, picture_t *p_pic,
int i_x, int i_y, int i_pic_x, int i_pic_y,
int i_width, int i_line_width, int i_ratio );
void (* RenderPixelMaskLine) ( struct vout_thread_s *p_vout, picture_t *p_pic,
int i_x, int i_y, int i_pic_x, int i_pic_y,
int i_width, int i_line_width, int i_ratio );
*/ /* ?? add YUV types */
} vout_thread_t;
/*******************************************************************************
* Prototypes
*******************************************************************************/
vout_thread_t * vout_CreateThread (
#if defined(VIDEO_X11)
#ifdef VIDEO_X11
char *psz_display, Window root_window,
#elif defined(VIDEO_FB)
//??void
#endif
int i_width, int i_height, int *pi_status
);
......@@ -105,9 +76,6 @@ void vout_DisplayPicture ( vout_thread_t *p_vout, picture
void vout_LinkPicture ( vout_thread_t *p_vout, picture_t *p_pic );
void vout_UnlinkPicture ( vout_thread_t *p_vout, picture_t *p_pic );
#ifdef DEBUG
void vout_PrintHeap ( vout_thread_t *p_vout, char *psz_str );
#endif
......
......@@ -6,11 +6,11 @@
/*******************************************************************************
* Prototypes
*******************************************************************************/
#if defined(VIDEO_X11)
int vout_SysCreate ( p_vout_thread_t p_vout, char *psz_display, Window root_window );
#elif defined(VIDEO_FB)
int vout_SysCreate ( p_vout_thread_t p_vout );
int vout_SysCreate ( p_vout_thread_t p_vout
#ifdef VIDEO_X11
, char *psz_display, Window root_window
#endif
);
int vout_SysInit ( p_vout_thread_t p_vout );
void vout_SysEnd ( p_vout_thread_t p_vout );
void vout_SysDestroy ( p_vout_thread_t p_vout );
......
......@@ -22,12 +22,13 @@
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <sys/shm.h>
#include <sys/soundcard.h>
......
......@@ -15,6 +15,8 @@
#include <stdio.h> /* "intf_msg.h" */
#include <stdlib.h> /* malloc(), free() */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h> /* ntohl() */
#include <sys/soundcard.h> /* "audio_output.h" */
#include <sys/uio.h> /* "input.h" */
......
......@@ -8,6 +8,8 @@
#include <unistd.h>
#include <stdio.h> /* "intf_msg.h" */
#include <stdlib.h> /* malloc(), free() */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h> /* ntohl() */
#include <sys/soundcard.h> /* "audio_output.h" */
#include <sys/uio.h>
......
......@@ -6,6 +6,7 @@
/*******************************************************************************
* Preamble
*******************************************************************************/
#include <sys/types.h>
#include <sys/uio.h>
#include "common.h"
......
......@@ -8,6 +8,7 @@
/*******************************************************************************
* Preamble
*******************************************************************************/
#include <sys/types.h>
#include <sys/uio.h>
#include <stdlib.h>
#include <stdio.h>
......
......@@ -8,6 +8,7 @@
/*******************************************************************************
* Preamble
*******************************************************************************/
#include <sys/types.h>
#include <sys/uio.h>
#include <string.h>
#include <stdio.h>
......@@ -17,7 +18,6 @@
#include <netinet/in.h> /* sockaddr_in, htons(), htonl() */
#include <errno.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include "common.h"
......
......@@ -9,8 +9,10 @@
* Preamble
*******************************************************************************/
#include <stdio.h>
#include <sys/types.h>
#include <sys/uio.h> /* iovec */
#include <stdlib.h> /* atoi(), malloc(), free() */
#include <sys/socket.h>
#include <netinet/in.h>
#include "config.h"
......
......@@ -12,6 +12,8 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/uio.h> /* for input.h */
#include "config.h"
......@@ -42,13 +44,12 @@ intf_thread_t* intf_Create( void )
p_intf = malloc( sizeof( intf_thread_t ) );
if( !p_intf )
{
errno = ENOMEM;
intf_ErrMsg("error: %s\n", strerror( ENOMEM ) );
return( NULL );
}
p_intf->b_die = 0;
intf_DbgMsg( "0x%x\n", p_intf );
/* Initialize structure */
p_intf->b_die = 0;
p_intf->p_vout = NULL;
p_intf->p_input = NULL;
......@@ -56,18 +57,19 @@ intf_thread_t* intf_Create( void )
p_intf->p_console = intf_ConsoleCreate();
if( p_intf->p_console == NULL )
{
intf_ErrMsg("intf error: can't create control console\n");
intf_ErrMsg("error: can't create control console\n");
free( p_intf );
return( NULL );
}
if( intf_SysCreate( p_intf ) )
{
intf_ErrMsg("intf error: can't create interface\n");
intf_ErrMsg("error: can't create interface\n");
intf_ConsoleDestroy( p_intf->p_console );
free( p_intf );
return( NULL );
}
intf_Msg("Interface initialized\n");
return( p_intf );
}
......@@ -78,13 +80,11 @@ intf_thread_t* intf_Create( void )
*******************************************************************************/
void intf_Run( intf_thread_t *p_intf )
{
intf_DbgMsg("0x%x begin\n", p_intf );
/* Execute the initialization script - if a positive number is returned,
* the script could be executed but failed */
if( intf_ExecScript( main_GetPszVariable( INTF_INIT_SCRIPT_VAR, INTF_INIT_SCRIPT_DEFAULT ) ) > 0 )
{
intf_ErrMsg("intf error: error during initialization script\n");
intf_ErrMsg("warning: error(s) during startup script\n");
}
/* Main loop */
......@@ -100,8 +100,6 @@ void intf_Run( intf_thread_t *p_intf )
* keyboard events, a 100ms delay is a good compromise */
msleep( INTF_IDLE_SLEEP );
}
intf_DbgMsg("0x%x end\n", p_intf );
}
/*******************************************************************************
......@@ -111,8 +109,6 @@ void intf_Run( intf_thread_t *p_intf )
*******************************************************************************/
void intf_Destroy( intf_thread_t *p_intf )
{
intf_DbgMsg("0x%x\n", p_intf );
/* Destroy interfaces */
intf_SysDestroy( p_intf );
intf_ConsoleDestroy( p_intf->p_console );
......
......@@ -25,6 +25,7 @@
* Preamble
*******************************************************************************/
#include "vlc.h"
#include <sys/stat.h>
/*??#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
......@@ -33,7 +34,6 @@
#include <string.h>
#include <unistd.h>
#include <sys/soundcard.h>
#include <sys/stat.h>
#include <sys/uio.h>
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
......
......@@ -17,10 +17,11 @@
#include <errno.h>
#include <string.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
#include "config.h"
#include "common.h"
......
/*******************************************************************************
* vout_ggi.c: GGI video output display method
* (c)1998 VideoLAN
*******************************************************************************/
/*******************************************************************************
* Preamble
*******************************************************************************/
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <ggi/ggi.h>
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "video.h"
#include "video_output.h"
#include "video_sys.h"
#include "intf_msg.h"
/*******************************************************************************
* vout_sys_t: video output GGI method descriptor
*******************************************************************************
* This structure is part of the video output thread descriptor.
* It describes the GGI specific properties of an output thread.
*******************************************************************************/
typedef struct vout_sys_s
{
/* GGI system informations */
ggi_visual_t p_display; /* display device */
/* Buffer index */
int i_buffer_index;
} vout_sys_t;
/*******************************************************************************
* Local prototypes
*******************************************************************************/
static int GGIOpenDisplay ( vout_thread_t *p_vout );
static void GGICloseDisplay ( vout_thread_t *p_vout );
/*******************************************************************************
* vout_SysCreate: allocate GGI video thread output method
*******************************************************************************
* This function allocate and initialize a GGI vout method. It uses some of the
* vout properties to choose the correct mode, and change them according to the
* mode actually used.
*******************************************************************************/
int vout_SysCreate( vout_thread_t *p_vout )
{
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
intf_ErrMsg("error: %s\n", strerror(ENOMEM) );
return( 1 );
}
/* Open and initialize device */
if( GGIOpenDisplay( p_vout ) )
{
intf_ErrMsg("error: can't initialize GGI display\n");
free( p_vout->p_sys );
return( 1 );
}
return( 0 );
}
/*******************************************************************************
* vout_SysInit: initialize GGI video thread output method
*******************************************************************************
* This function initialize the GGI display device.
*******************************************************************************/
int vout_SysInit( vout_thread_t *p_vout )
{
p_vout->p_sys->i_buffer_index = 0;
return( 0 );
}
/*******************************************************************************
* vout_SysEnd: terminate Sys video thread output method
*******************************************************************************
* Terminate an output method created by vout_SysCreateOutputMethod
*******************************************************************************/
void vout_SysEnd( vout_thread_t *p_vout )
{
;
}
/*******************************************************************************
* vout_SysDestroy: destroy Sys video thread output method
*******************************************************************************
* Terminate an output method created by vout_SysCreateOutputMethod
*******************************************************************************/
void vout_SysDestroy( vout_thread_t *p_vout )
{
GGICloseDisplay( p_vout );
free( p_vout->p_sys );
}
/*******************************************************************************
* vout_SysManage: handle Sys events
*******************************************************************************
* This function should be called regularly by video output thread. It returns
* a negative value if something happened which does not allow the thread to
* continue, and a positive one if the thread can go on, but the images have
* been modified and therefore it is useless to display them.
*******************************************************************************/
int vout_SysManage( vout_thread_t *p_vout )
{
//??
return( 0 );
}
/*******************************************************************************
* vout_SysDisplay: displays previously rendered output
*******************************************************************************
* This function send the currently rendered image to the display, wait until
* it is displayed and switch the two rendering buffer, preparing next frame.
*******************************************************************************/
void vout_SysDisplay( vout_thread_t *p_vout )
{
/* Change display frame */
ggiFlush( p_vout->p_sys->p_display ); // ??
ggiSetDisplayFrame( p_vout->p_sys->p_display, p_vout->p_sys->i_buffer_index );
/* Swap buffers and change write frame */
p_vout->p_sys->i_buffer_index = ++p_vout->p_sys->i_buffer_index & 1;
ggiSetWriteFrame( p_vout->p_sys->p_display, p_vout->p_sys->i_buffer_index );
}
/*******************************************************************************
* vout_SysGetPicture: get current display buffer informations
*******************************************************************************
* This function returns the address of the current display buffer, and the
* number of samples per line. For 15, 16 and 32 bits displays, this value is
* the number of pixels in a line.
*******************************************************************************/
byte_t * vout_SysGetPicture( vout_thread_t *p_vout, int *pi_eol_offset )
{
*pi_eol_offset = p_vout->i_width;
//????
// return( p_vout->p_sys->p_ximage[ p_vout->p_sys->i_buffer_index ].data );
}
/* following functions are local */
/*******************************************************************************
* GGIOpenDisplay: open and initialize GGI device
*******************************************************************************
* Open and initialize display according to preferences specified in the vout
* thread fields.
*******************************************************************************/
static int GGIOpenDisplay( vout_thread_t *p_vout )
{
ggi_mode mode; /* mode descriptor */
/* Initialize library */
if( ggiInit() )
{
intf_ErrMsg("error: can't initialize GGI library\n");
return( 1 );
}
/* Open display */
p_vout->p_sys->p_display = ggiOpen( NULL );
if( p_vout->p_sys->p_display == NULL )
{
intf_ErrMsg("error: can't open GGI default display\n");
ggiExit();
return( 1 );
}
/* Find most appropriate mode */
mode.frames = 2; /* 2 buffers */
mode.visible.x = p_vout->i_width; /* minimum width */
mode.visible.y = p_vout->i_width; /* maximum width */
mode.virt.x = GGI_AUTO;
mode.virt.y = GGI_AUTO;
mode.size.x = GGI_AUTO;
mode.size.y = GGI_AUTO;
mode.graphtype = GT_15BIT; /* minimum usable screen depth */
mode.dpp.x = GGI_AUTO;
mode.dpp.y = GGI_AUTO;
ggiCheckMode( p_vout->p_sys->p_display, &mode );
/* Check that returned mode has some minimum properties */
//??
/* Set mode */
if( ggiSetMode( p_vout->p_sys->p_display, &mode ) )
{
intf_ErrMsg("error: can't set GGI mode\n");
ggiClose( p_vout->p_sys->p_display );
ggiExit();
return( 1 );
}
/* Set thread information */
p_vout->i_width = mode.visible.x;
p_vout->i_height = mode.visible.y;
switch( mode.graphtype )
{
case GT_15BIT:
p_vout->i_screen_depth = 15;
p_vout->i_bytes_per_pixel = 2;
break;
case GT_16BIT:
p_vout->i_screen_depth = 16;
p_vout->i_bytes_per_pixel = 2;
break;
case GT_24BIT:
p_vout->i_screen_depth = 24;
p_vout->i_bytes_per_pixel = 3;
break;
case GT_32BIT:
p_vout->i_screen_depth = 32;
p_vout->i_bytes_per_pixel = 4;
break;
default:
intf_ErrMsg("error: unsupported screen depth\n");
ggiClose( p_vout->p_sys->p_display );
ggiExit();
return( 1 );
break;
}
return( 0 );
}
/*******************************************************************************
* GGICloseDisplay: close and reset GGI device
*******************************************************************************
* This function returns all resources allocated by GGIOpenDisplay and restore
* the original state of the device.
*******************************************************************************/
static void GGICloseDisplay( vout_thread_t *p_vout )
{
// Restore original mode and close display
ggiClose( p_vout->p_sys->p_display );
// Exit library
ggiExit();
}
......@@ -36,12 +36,12 @@
* (0 or 255) */
#define CLIP_BYTE( i_val ) ( (i_val < 0) ? 0 : ((i_val > 255) ? 255 : i_val) )
/* YUV_TRANSFORM_16: parametric macro. Due to the high performance need of this
* loop, all possible conditions evaluations are made outside the transformation
* loop. However, the code does not change much for two different loops. This
* macro allows to change slightly the content of the loop without having to
* copy and paste code. It is used in RenderYUVPicture function.
*/
/* YUV_TRANSFORM: parametric macro for YUV transformation.
* Due to the high performance need of this loop, all possible conditions
* evaluations are made outside the transformation loop. However, the code does
* not change much for two different loops. This macro allows to change slightly
* the content of the loop without having to copy and paste code. It is used in
* RenderYUVPicture function. */
#define YUV_TRANSFORM( CHROMA, TRANS_RED, TRANS_GREEN, TRANS_BLUE, P_PIC ) \
/* Main loop */ \
for (i_pic_y=0; i_pic_y < p_pic->i_height ; i_pic_y++) \
......@@ -101,7 +101,6 @@ static int InitThread ( vout_thread_t *p_vout );
static void RunThread ( vout_thread_t *p_vout );
static void ErrorThread ( vout_thread_t *p_vout );
static void EndThread ( vout_thread_t *p_vout );
static void RenderPicture ( vout_thread_t *p_vout, picture_t *p_pic );
static void RenderYUVPicture( vout_thread_t *p_vout, picture_t *p_pic );
......@@ -110,22 +109,12 @@ static void RenderYUVPicture( vout_thread_t *p_vout, picture_t *p_pic );
*******************************************************************************
* This function creates a new video output thread, and returns a pointer
* to its description. On error, it returns NULL.
* Following configuration properties are used:
* VIDEO_CFG_SIZE video heap maximal size
* VIDEO_CFG_WIDTH window width
* VIDEO_CFG_HEIGHT window height
* Using X11 display method (the only one supported yet):
* VIDEO_CFG_DISPLAY display used
* VIDEO_CFG_TITLE window title
* VIDEO_CFG_SHM_EXT try to use XShm extension
* If pi_status is NULL, then the function will block until the thread is ready.
* If not, pi_error will be updated using one of the THREAD_* constants.
* If not, it will be updated using one of the THREAD_* constants.
*******************************************************************************/
vout_thread_t * vout_CreateThread (
#if defined(VIDEO_X11)
#ifdef VIDEO_X11
char *psz_display, Window root_window,
#elif defined(VIDEO_FB)
//??
#endif
int i_width, int i_height, int *pi_status
)
......@@ -133,45 +122,67 @@ vout_thread_t * vout_CreateThread (
vout_thread_t * p_vout; /* thread descriptor */
int i_status; /* thread status */
/* Allocate descriptor and create method */
/* Allocate descriptor */
p_vout = (vout_thread_t *) malloc( sizeof(vout_thread_t) );
if( p_vout == NULL ) /* error */
if( p_vout == NULL )
{
intf_ErrMsg("error: %s\n", strerror(ENOMEM));
return( NULL );
}
intf_DbgMsg( "%p\n", p_vout );
/* Initialize some fields used by the system-dependant method - these fields will
* probably be modified by the method */
p_vout->i_width = i_width;
p_vout->i_height = i_height;
p_vout->i_screen_depth = 15;
p_vout->i_bytes_per_pixel = 2;
p_vout->f_x_ratio = 1;
p_vout->f_y_ratio = 1;
intf_DbgMsg("wished configuration: %dx%dx%d (%d bytes per pixel), ratio %f:%f\n",
p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
p_vout->i_bytes_per_pixel, p_vout->f_x_ratio, p_vout->f_y_ratio );
/* Create and initialize system-dependant method - this function issues its
* own error messages */
if( vout_SysCreate( p_vout
#if defined(VIDEO_X11)
, psz_display, root_window
#elif defined(VIDEO_FB)
//??
#endif
) )
{
free( p_vout );
return( NULL );
}
intf_DbgMsg("actual configuration: %dx%dx%d (%d bytes per pixel), ratio %f:%f\n",
p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
p_vout->i_bytes_per_pixel, p_vout->f_x_ratio, p_vout->f_y_ratio );
/* Initialize */
p_vout->i_width = i_width;
p_vout->i_height = i_height;
p_vout->pi_status = (pi_status != NULL) ? pi_status : &i_status;
*p_vout->pi_status = THREAD_CREATE;
/* Terminate the initialization */
p_vout->b_die = 0;
p_vout->b_error = 0;
p_vout->b_active = 0;
p_vout->pi_status = (pi_status != NULL) ? pi_status : &i_status;
*p_vout->pi_status = THREAD_CREATE;
#ifdef STATS
p_vout->c_loops = 0;
p_vout->c_idle_loops = 0;
p_vout->c_pictures = 0;
#endif
/* Create thread and set locks */
vlc_mutex_init( &p_vout->lock );
if( vlc_thread_create( &p_vout->thread_id, "video output",
(void *) RunThread, (void *) p_vout) )
{
intf_ErrMsg("vout error: %s\n", strerror(ENOMEM));
intf_ErrMsg("error: %s\n", strerror(ENOMEM));
vout_SysDestroy( p_vout );
free( p_vout );
return( NULL );
}
intf_Msg("Video: display initialized (%dx%d, %d bpp)\n",
p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth );
/* If status is NULL, wait until the thread is created */
if( pi_status == NULL )
{
......@@ -185,7 +196,6 @@ vout_thread_t * vout_CreateThread (
return( NULL );
}
}
return( p_vout );
}
......@@ -201,8 +211,6 @@ void vout_DestroyThread( vout_thread_t *p_vout, int *pi_status )
{
int i_status; /* thread status */
intf_DbgMsg( "%p\n", p_vout );
/* Set status */
p_vout->pi_status = (pi_status != NULL) ? pi_status : &i_status;
*p_vout->pi_status = THREAD_DESTROY;
......@@ -313,7 +321,7 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
/* Allocate memory */
switch( i_type )
{
case YUV_420_PICTURE: /* YUV picture: 3*16 ?? bits per pixel */
case YUV_420_PICTURE: /* YUV picture: bits per pixel */
case YUV_422_PICTURE:
case YUV_444_PICTURE:
p_free_picture->p_data = malloc( 3 * i_height * i_bytes_per_line );
......@@ -323,8 +331,9 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
break;
#ifdef DEBUG
default:
intf_DbgMsg("%p error: unknown picture type %d\n", p_vout, i_type );
intf_DbgMsg("unknown picture type %d\n", i_type );
p_free_picture->p_data = NULL;
break;
#endif
}
......@@ -345,7 +354,7 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
p_free_picture->i_type = EMPTY_PICTURE;
p_free_picture->i_status = FREE_PICTURE;
p_free_picture = NULL;
intf_DbgMsg("%p malloc for new picture failed\n", p_vout );
intf_ErrMsg("warning: %s\n", strerror( ENOMEM ) );
}
vlc_mutex_unlock( &p_vout->lock );
......@@ -353,7 +362,7 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
}
// No free or destroyed picture could be found
intf_DbgMsg("%p no picture available\n", p_vout );
intf_DbgMsg( "heap is full\n" );
vlc_mutex_unlock( &p_vout->lock );
return( NULL );
}
......@@ -368,11 +377,7 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
void vout_DestroyPicture( vout_thread_t *p_vout, picture_t *p_pic )
{
vlc_mutex_lock( &p_vout->lock );
/* Mark picture for destruction */
p_pic->i_status = DESTROYED_PICTURE;
intf_DbgMsg("%p picture %p destroyed\n", p_vout, p_pic );
vlc_mutex_unlock( &p_vout->lock );
}
......@@ -423,24 +428,15 @@ static int InitThread( vout_thread_t *p_vout )
*p_vout->pi_status = THREAD_START;
/* Initialize pictures */
p_vout->i_pictures = 0;
for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++)
{
p_vout->p_picture[i_index].i_type = EMPTY_PICTURE;
p_vout->p_picture[i_index].i_status= FREE_PICTURE;
}
/* Initialize other properties */
p_vout->i_pictures = 0;
#ifdef STATS
p_vout->c_loops = 0;
p_vout->c_idle_loops = 0;
p_vout->c_pictures = 0;
p_vout->c_rendered_pictures = 0;
#endif
/* Initialize output method - width, height, screen depth and bytes per
* pixel are initialized by this call. */
if( vout_SysInit( p_vout ) ) /* error */
/* Initialize output method - this function issues its own error messages */
if( vout_SysInit( p_vout ) )
{
*p_vout->pi_status = THREAD_ERROR;
return( 1 );
......@@ -454,9 +450,17 @@ static int InitThread( vout_thread_t *p_vout )
break;
case 3: /* 24 or 32 bpp, use 32 bits translations tables */
case 4:
#ifndef DEBUG
default:
#endif
i_pixel_size = sizeof( u32 );
break;
#ifdef DEBUG
default:
intf_DbgMsg("invalid bytes_per_pixel %d\n", p_vout->i_bytes_per_pixel );
i_pixel_size = sizeof( u32 );
break;
#endif
}
p_vout->pi_trans32_red = (u32 *)p_vout->pi_trans16_red =
(u16 *)malloc( 1024 * i_pixel_size );
......@@ -468,7 +472,7 @@ static int InitThread( vout_thread_t *p_vout )
(p_vout->pi_trans16_green == NULL ) ||
(p_vout->pi_trans16_blue == NULL ) )
{
intf_ErrMsg("vout error: %s\n", strerror(ENOMEM) );
intf_ErrMsg("error: %s\n", strerror(ENOMEM) );
*p_vout->pi_status = THREAD_ERROR;
if( p_vout->pi_trans16_red != NULL )
{
......@@ -521,11 +525,17 @@ static int InitThread( vout_thread_t *p_vout )
p_vout->pi_trans32_blue[i_index] = CLIP_BYTE( i_index ) ;
}
break;
#ifdef DEBUG
default:
intf_DbgMsg("invalid screen depth %d\n", p_vout->i_screen_depth );
break;
#endif
}
/* Mark thread as running and return */
p_vout->b_active = 1;
*p_vout->pi_status = THREAD_READY;
intf_DbgMsg("%p -> succeeded\n", p_vout);
intf_DbgMsg("thread ready");
return(0);
}
......@@ -541,15 +551,11 @@ static void RunThread( vout_thread_t *p_vout)
int i_picture; /* picture index */
int i_err; /* error code */
mtime_t current_date; /* current date */
picture_t * p_pic = NULL;
#ifdef VOUT_DEBUG
char sz_date[MSTRTIME_MAX_SIZE]; /* date buffer */
#endif
picture_t * p_pic = NULL; /* picture pointer */
/*
* Initialize thread and free configuration
*/
intf_DbgMsg( "%p begin\n", p_vout );
p_vout->b_error = InitThread( p_vout );
if( p_vout->b_error )
{
......@@ -603,7 +609,7 @@ static void RunThread( vout_thread_t *p_vout)
p_pic->i_status = DESTROYED_PICTURE;
}
vlc_mutex_unlock( &p_vout->lock );
intf_ErrMsg( "vout error: picture %p was late - skipped\n", p_pic );
intf_ErrMsg( "warning: late picture skipped\n" );
p_pic = NULL;
}
else if( p_pic->date > current_date + VOUT_DISPLAY_DELAY )
......@@ -683,7 +689,7 @@ static void RunThread( vout_thread_t *p_vout)
/* End of thread */
EndThread( p_vout );
intf_DbgMsg( "%p end\n", p_vout );
intf_DbgMsg( "thread end\n" );
}
/*******************************************************************************
......@@ -734,12 +740,11 @@ static void EndThread( vout_thread_t *p_vout )
/* Destroy thread structures allocated by InitThread */
vout_SysEnd( p_vout );
vout_SysDestroy( p_vout ); /* destroy output method */
vout_SysDestroy( p_vout );
free( p_vout );
/* Update status */
*pi_status = THREAD_OVER;
intf_DbgMsg("%p\n", p_vout);
}
/*******************************************************************************
......@@ -759,18 +764,19 @@ static void RenderPicture( vout_thread_t *p_vout, picture_t *p_pic )
case YUV_444_PICTURE:
RenderYUVPicture( p_vout, p_pic );
break;
#ifdef DEBUG
default:
intf_DbgMsg("unknown picture type %d\n", p_pic->i_type );
break;
#endif
}
intf_DbgMsg("%p Picture %p type=%d, %dx%d\n",
p_vout, p_pic, p_pic->i_type, p_pic->i_width, p_pic->i_height );
/*???*/
}
/*******************************************************************************
* RenderYUVPicture: render a YUV picture
*******************************************************************************
* Performs the YUV convertion.
* Performs the YUV convertion. The picture sent to this function should only
* have YUV_420, YUV_422 or YUV_444 types.
*******************************************************************************/
static void RenderYUVPicture( vout_thread_t *p_vout, picture_t *p_pic )
{
......@@ -893,6 +899,11 @@ static void RenderYUVPicture( vout_thread_t *p_vout, picture_t *p_pic )
break;
}
break;
#ifdef DEBUG
default:
intf_DbgMsg("invalid screen depth %d\n", p_vout->i_screen_depth );
break;
#endif
}
}
/*******************************************************************************
* vout_x11.c: X11 video output display method
* (c)1998 VideoLAN
*******************************************************************************
* The X11 method for video output thread. It's properties (and the vout_x11_t
* type) are defined in vout.h. The functions declared here should not be
* needed by any other module than vout.c.
*******************************************************************************/
/*******************************************************************************
......@@ -14,6 +10,8 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
......@@ -23,6 +21,7 @@
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "video.h"
#include "video_output.h"
#include "video_sys.h"
......@@ -48,12 +47,6 @@ typedef struct vout_sys_s
Window window; /* window instance handler */
GC gc; /* graphic context instance handler */
/* Color maps and translation tables - some of those tables are shifted,
* see x11.c for more informations. */
u8 * trans_16bpp_red; /* red (16 bpp) (SHIFTED !) */
u8 * trans_16bpp_green; /* green (16 bpp) (SHIFTED !) */
u8 * trans_16bpp_blue; /* blue (16 bpp) (SHIFTED !) */
/* Display buffers and shared memory information */
int i_buffer_index; /* buffer index */
XImage * p_ximage[2]; /* XImage pointer */
......@@ -63,10 +56,10 @@ typedef struct vout_sys_s
/*******************************************************************************
* Local prototypes
*******************************************************************************/
static int X11GetProperties ( vout_thread_t *p_vout );
static int X11OpenDisplay ( vout_thread_t *p_vout, char *psz_display, Window root_window );
static void X11CloseDisplay ( vout_thread_t *p_vout );
static int X11CreateWindow ( vout_thread_t *p_vout );
static int X11CreateImages ( vout_thread_t *p_vout );
static void X11DestroyImages ( vout_thread_t *p_vout );
static void X11DestroyWindow ( vout_thread_t *p_vout );
static int X11CreateImage ( vout_thread_t *p_vout, XImage **pp_ximage );
static void X11DestroyImage ( XImage *p_ximage );
......@@ -75,71 +68,115 @@ static int X11CreateShmImage ( vout_thread_t *p_vout, XImage **pp_ximage,
static void X11DestroyShmImage ( vout_thread_t *p_vout, XImage *p_ximage,
XShmSegmentInfo *p_shm_info );
/*******************************************************************************
* vout_SysCreate: allocate X11 video thread output method
*******************************************************************************
* This function allocate and initialize a X11 vout method.
* This function allocate and initialize a X11 vout method. It uses some of the
* vout properties to choose the window size, and change them according to the
* actual properties of the display.
*******************************************************************************/
int vout_SysCreate( vout_thread_t *p_vout, char *psz_display, Window root_window )
{
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
intf_ErrMsg("vout error: %s\n", strerror(ENOMEM) );
intf_ErrMsg("error: %s\n", strerror(ENOMEM) );
return( 1 );
}
/* Since XLib is usually not thread-safe, we can't use the same display
* pointer than the interface or another thread. However, the window
* id is still valid */
p_vout->p_sys->p_display = XOpenDisplay( psz_display );
if( !p_vout->p_sys->p_display ) /* error */
/* Open and initialize device. This function issues its own error messages.
* Since XLib is usually not thread-safe, we can't use the same display
* pointer than the interface or another thread. However, the root window
* id is still valid. */
if( X11OpenDisplay( p_vout, psz_display, root_window ) )
{
intf_ErrMsg("vout error: can't open display %s\n", psz_display );
intf_ErrMsg("error: can't initialize X11 display\n" );
free( p_vout->p_sys );
return( 1 );
}
p_vout->p_sys->root_window = root_window;
return( 0 );
}
/*******************************************************************************
* vout_SysInit: initialize X11 video thread output method
*******************************************************************************
* This function create a X11 window according to the user configuration.
* This function create the XImages needed by the output thread.
*******************************************************************************/
int vout_SysInit( vout_thread_t *p_vout )
{
if( X11GetProperties( p_vout ) ) /* get display properties */
int i_err;
/* Create XImages using XShm extension - on failure, fall back to regular
* way (and destroy the first image if it was created successfully) */
if( p_vout->p_sys->b_shm )
{
return( 1 );
/* Create first image */
i_err = X11CreateShmImage( p_vout, &p_vout->p_sys->p_ximage[0],
&p_vout->p_sys->shm_info[0] );
if( !i_err ) /* first image has been created */
{
/* Create second image */
if( X11CreateShmImage( p_vout, &p_vout->p_sys->p_ximage[1],
&p_vout->p_sys->shm_info[1] ) )
{ /* error creating the second image */
X11DestroyShmImage( p_vout, p_vout->p_sys->p_ximage[0],
&p_vout->p_sys->shm_info[0] );
i_err = 1;
}
if( X11CreateWindow( p_vout ) ) /* create window */
}
if( i_err ) /* an error occured */
{
intf_Msg("warning: XShm video extension desactivated\n" );
p_vout->p_sys->b_shm = 0;
}
}
/* Create XImages without XShm extension */
if( !p_vout->p_sys->b_shm )
{
if( X11CreateImage( p_vout, &p_vout->p_sys->p_ximage[0] ) )
{
intf_Msg("error: can't create images\n");
p_vout->p_sys->p_ximage[0] = NULL;
p_vout->p_sys->p_ximage[1] = NULL;
return( 1 );
}
if( X11CreateImages( p_vout ) ) /* create images */
if( X11CreateImage( p_vout, &p_vout->p_sys->p_ximage[1] ) )
{
X11DestroyWindow( p_vout );
intf_Msg("error: can't create images\n");
X11DestroyImage( p_vout->p_sys->p_ximage[0] );
p_vout->p_sys->p_ximage[0] = NULL;
p_vout->p_sys->p_ximage[1] = NULL;
return( 1 );
}
intf_Msg("vout: X11 display initialized, depth=%d bpp, Shm=%d\n",
p_vout->i_screen_depth, p_vout->p_sys->b_shm );
}
/* Set buffer index to 0 */
p_vout->p_sys->i_buffer_index = 0;
return( 0 );
}
/*******************************************************************************
* vout_SysEnd: terminate X11 video thread output method
*******************************************************************************
* Terminate an output method created by vout_X11CreateOutputMethod
* Destroy the X11 XImages created by vout_SysInit.
*******************************************************************************/
void vout_SysEnd( vout_thread_t *p_vout )
{
X11DestroyImages( p_vout );
X11DestroyWindow( p_vout );
intf_DbgMsg("%p\n", p_vout );
if( p_vout->p_sys->b_shm ) /* Shm XImages... */
{
X11DestroyShmImage( p_vout, p_vout->p_sys->p_ximage[0],
&p_vout->p_sys->shm_info[0] );
X11DestroyShmImage( p_vout, p_vout->p_sys->p_ximage[1],
&p_vout->p_sys->shm_info[1] );
}
else /* ...or regular XImages */
{
X11DestroyImage( p_vout->p_sys->p_ximage[0] );
X11DestroyImage( p_vout->p_sys->p_ximage[1] );
}
}
/*******************************************************************************
......@@ -149,7 +186,7 @@ void vout_SysEnd( vout_thread_t *p_vout )
*******************************************************************************/
void vout_SysDestroy( vout_thread_t *p_vout )
{
XCloseDisplay( p_vout->p_sys->p_display );
X11CloseDisplay( p_vout );
free( p_vout->p_sys );
}
......@@ -161,8 +198,6 @@ void vout_SysDestroy( vout_thread_t *p_vout )
* something happened which does not allow the thread to continue, and a
* positive one if the thread can go on, but the images have been modified and
* therefore it is useless to display them.
*******************************************************************************
* Messages type: vout, major code: 103
*******************************************************************************/
int vout_SysManage( vout_thread_t *p_vout )
{
......@@ -175,19 +210,19 @@ int vout_SysManage( vout_thread_t *p_vout )
/* If window has been resized, re-create images */
if( b_resized )
/* ?? if( b_resized )
{
intf_DbgMsg("%p -> resizing window\n", p_vout);
X11DestroyImages( p_vout );
if( X11CreateImages( p_vout ) )
{
{ */
/* A fatal error occured: images could not be re-created. Note
* that in this case, the images pointers will be NULL, so the
* image destructor will know it does not need to destroy them. */
return( -1 );
/* return( -1 );
}
return( 1 );
}
}*/
return( 0 );
}
......@@ -249,20 +284,28 @@ byte_t * vout_SysGetPicture( vout_thread_t *p_vout, int *pi_eol_offset )
/* following functions are local */
/*******************************************************************************
* X11GetProperties: get properties of a given display
* X11OpenDisplay: open and initialize X11 device
*******************************************************************************
* Opens an X11 display and try to detect usable X extensions.
* Create a window according to video output given size, and set other
* properties according to the display properties.
*******************************************************************************/
static int X11GetProperties( vout_thread_t *p_vout )
static int X11OpenDisplay( vout_thread_t *p_vout, char *psz_display, Window root_window )
{
/* Check if extensions are supported */
p_vout->p_sys->b_shm = VOUT_XSHM && (XShmQueryExtension(p_vout->p_sys->p_display) == True);
/* Open display */
p_vout->p_sys->p_display = XOpenDisplay( psz_display );
if( p_vout->p_sys->p_display == NULL )
{
intf_ErrMsg("error: can't open display %s\n", psz_display );
return( 1 );
}
/* Get the screen number and depth (bpp) - select functions depending
* of this value. i_bytes_per_pixel is required since on some hardware,
* depth as 15bpp are used, which can cause problems with later memory
* allocation. */
/* Initialize structure */
p_vout->p_sys->root_window = root_window;
p_vout->p_sys->b_shm = VOUT_XSHM &&
(XShmQueryExtension(p_vout->p_sys->p_display) == True);
p_vout->p_sys->i_screen = DefaultScreen( p_vout->p_sys->p_display );
/* Get the screen depth */
p_vout->i_screen_depth = DefaultDepth( p_vout->p_sys->p_display,
p_vout->p_sys->i_screen );
switch( p_vout->i_screen_depth )
......@@ -271,24 +314,43 @@ static int X11GetProperties( vout_thread_t *p_vout )
case 16: /* 16 bpp (65536 colors) */
p_vout->i_bytes_per_pixel = 2;
break;
case 24: /* 24 bpp (millions of colors) */
p_vout->i_bytes_per_pixel = 3;
break;
case 32: /* 32 bpp (millions of colors) */
p_vout->i_bytes_per_pixel = 4;
break;
default: /* unsupported screen depth */
intf_ErrMsg("vout error: screen depth %i is not supported\n",
intf_ErrMsg("error: screen depth %d is not supported\n",
p_vout->i_screen_depth);
XCloseDisplay( p_vout->p_sys->p_display );
return( 1 );
break;
}
/* Create a window */
if( X11CreateWindow( p_vout ) ) /* create window */
{
intf_ErrMsg("error: can't open a window\n");
XCloseDisplay( p_vout->p_sys->p_display );
return( 1 );
}
return( 0 );
}
/*******************************************************************************
* X11CloseDisplay: close X11 device
*******************************************************************************
* Returns all resources allocated by X11OpenDisplay and restore the original
* state of the display.
*******************************************************************************/
static void X11CloseDisplay( vout_thread_t *p_vout )
{
X11DestroyWindow( p_vout );
XCloseDisplay( p_vout->p_sys->p_display );
}
/*******************************************************************************
* X11CreateWindow: create X11 vout window
*******************************************************************************
......@@ -308,8 +370,7 @@ static int X11CreateWindow( vout_thread_t *p_vout )
/* Prepare window attributes */
xwindow_attributes.backing_store = Always; /* save the hidden part */
/* Create the window and set hints - the window must receive ConfigureNotify
* events, and, until it is displayed, Expose and MapNotify events. */
/* Create the window and set hints */
p_vout->p_sys->window = XCreateSimpleWindow( p_vout->p_sys->p_display,
p_vout->p_sys->root_window,
0, 0,
......@@ -349,94 +410,11 @@ static int X11CreateWindow( vout_thread_t *p_vout )
while( !( b_expose && b_map_notify ) );
XSelectInput( p_vout->p_sys->p_display, p_vout->p_sys->window, 0 );
/* At this stage, the window is openned, displayed, and ready to receive data */
p_vout->b_active = 1;
/* At this stage, the window is openned, displayed, and ready to receive
* data */
return( 0 );
}
/*******************************************************************************
* X11CreateImages: create X11 rendering buffers
*******************************************************************************
* Create two XImages which will be used as rendering buffers. On error, non 0
* will be returned and the images pointer will be set to NULL (see
* vout_X11ManageOutputMethod()).
*******************************************************************************/
static int X11CreateImages( vout_thread_t *p_vout )
{
int i_err;
/* Create XImages using XShm extension - on failure, fall back to regular
* way (and destroy the first image if it was created successfully) */
if( p_vout->p_sys->b_shm )
{
/* Create first image */
i_err = X11CreateShmImage( p_vout, &p_vout->p_sys->p_ximage[0],
&p_vout->p_sys->shm_info[0] );
if( !i_err ) /* first image has been created */
{
/* Create second image */
if( X11CreateShmImage( p_vout, &p_vout->p_sys->p_ximage[1],
&p_vout->p_sys->shm_info[1] ) )
{ /* error creating the second image */
X11DestroyShmImage( p_vout, p_vout->p_sys->p_ximage[0],
&p_vout->p_sys->shm_info[0] );
i_err = 1;
}
}
if( i_err ) /* an error occured */
{
intf_Msg("vout: XShm extension desactivated\n" );
p_vout->p_sys->b_shm = 0;
}
}
/* Create XImages without XShm extension */
if( !p_vout->p_sys->b_shm )
{
if( X11CreateImage( p_vout, &p_vout->p_sys->p_ximage[0] ) )
{
intf_Msg("vout error: can't create images\n");
p_vout->p_sys->p_ximage[0] = NULL;
p_vout->p_sys->p_ximage[1] = NULL;
return( -1 );
}
if( X11CreateImage( p_vout, &p_vout->p_sys->p_ximage[1] ) )
{
intf_Msg("vout error: can't create images\n");
X11DestroyImage( p_vout->p_sys->p_ximage[0] );
p_vout->p_sys->p_ximage[0] = NULL;
p_vout->p_sys->p_ximage[1] = NULL;
return( -1 );
}
}
/* Set buffer index to 0 */
p_vout->p_sys->i_buffer_index = 0;
return( 0 );
}
/*******************************************************************************
* X11DestroyImages: destroy X11 rendering buffers
*******************************************************************************
* Destroy buffers created by vout_X11CreateImages().
*******************************************************************************/
static void X11DestroyImages( vout_thread_t *p_vout )
{
if( p_vout->p_sys->b_shm ) /* Shm XImages... */
{
X11DestroyShmImage( p_vout, p_vout->p_sys->p_ximage[0],
&p_vout->p_sys->shm_info[0] );
X11DestroyShmImage( p_vout, p_vout->p_sys->p_ximage[1],
&p_vout->p_sys->shm_info[1] );
}
else /* ...or regular XImages */
{
X11DestroyImage( p_vout->p_sys->p_ximage[0] );
X11DestroyImage( p_vout->p_sys->p_ximage[1] );
}
}
/*******************************************************************************
* X11DestroyWindow: destroy X11 window
*******************************************************************************
......@@ -444,7 +422,6 @@ static void X11DestroyImages( vout_thread_t *p_vout )
*******************************************************************************/
static void X11DestroyWindow( vout_thread_t *p_vout )
{
intf_DbgMsg("vout window: 0x%x\n", p_vout->p_sys->window );
XUnmapWindow( p_vout->p_sys->p_display, p_vout->p_sys->window );
XFreeGC( p_vout->p_sys->p_display, p_vout->p_sys->gc );
XDestroyWindow( p_vout->p_sys->p_display, p_vout->p_sys->window );
......@@ -464,8 +441,8 @@ static int X11CreateImage( vout_thread_t *p_vout, XImage **pp_ximage )
* p_vout->i_height );
if( !pb_data ) /* error */
{
intf_ErrMsg("vout error: %s\n", strerror(ENOMEM));
return( -1 );
intf_ErrMsg("error: %s\n", strerror(ENOMEM));
return( 1 );
}
/* Optimize the quantum of a scanline regarding its size - the quantum is
......@@ -493,9 +470,9 @@ static int X11CreateImage( vout_thread_t *p_vout, XImage **pp_ximage )
p_vout->i_width, p_vout->i_height, i_quantum, 0);
if(! *pp_ximage ) /* error */
{
intf_ErrMsg( "vout error: can't create XImages\n" );
intf_ErrMsg( "error: XCreateImage() failed\n" );
free( pb_data );
return( -1 );
return( 1 );
}
return 0;
......@@ -525,8 +502,8 @@ static int X11CreateShmImage( vout_thread_t *p_vout, XImage **pp_ximage,
p_shm_info, p_vout->i_width, p_vout->i_height );
if(! *pp_ximage ) /* error */
{
intf_ErrMsg("vout error: can't create XImages with shared memory\n");
return( -1 );
intf_ErrMsg("error: XShmCreateImage() failed\n");
return( 1 );
}
/* Allocate shared memory segment - 0777 set the access permission
......@@ -536,21 +513,21 @@ static int X11CreateShmImage( vout_thread_t *p_vout, XImage **pp_ximage,
IPC_CREAT | 0777);
if( p_shm_info->shmid < 0) /* error */
{
intf_ErrMsg("vout error: can't allocate shared image data (%s)\n",
intf_ErrMsg("error: can't allocate shared image data (%s)\n",
strerror(errno));
XDestroyImage( *pp_ximage );
return( -1 );
return( 1 );
}
/* Attach shared memory segment to process (read/write) */
p_shm_info->shmaddr = (*pp_ximage)->data = shmat(p_shm_info->shmid, 0, 0);
if(! p_shm_info->shmaddr )
{ /* error */
intf_ErrMsg("vout error: can't attach shared memory (%s)\n",
intf_ErrMsg("error: can't attach shared memory (%s)\n",
strerror(errno));
shmctl( p_shm_info->shmid, IPC_RMID, 0 ); /* free shared memory */
XDestroyImage( *pp_ximage );
return( -1 );
return( 1 );
}
/* Mark the shm segment to be removed when there will be no more
......@@ -561,11 +538,11 @@ static int X11CreateShmImage( vout_thread_t *p_vout, XImage **pp_ximage,
p_shm_info->readOnly = True;
if( XShmAttach( p_vout->p_sys->p_display, p_shm_info ) == False ) /* error */
{
intf_ErrMsg("vout error: can't attach shared memory to X11 server\n");
intf_ErrMsg("error: can't attach shared memory to X11 server\n");
shmdt( p_shm_info->shmaddr ); /* detach shared memory from process
* and automatic free */
XDestroyImage( *pp_ximage );
return( -1 );
return( 1 );
}
return( 0 );
}
......@@ -575,8 +552,6 @@ static int X11CreateShmImage( vout_thread_t *p_vout, XImage **pp_ximage,
*******************************************************************************
* Destroy XImage AND associated data. If pointer is NULL, the image won't be
* destroyed (see vout_X11ManageOutputMethod())
*******************************************************************************
* Messages type: vout, major code 114
*******************************************************************************/
static void X11DestroyImage( XImage *p_ximage )
{
......@@ -592,8 +567,6 @@ static void X11DestroyImage( XImage *p_ximage )
* Destroy XImage AND associated data. Detach shared memory segment from
* server and process, then free it. If pointer is NULL, the image won't be
* destroyed (see vout_X11ManageOutputMethod())
*******************************************************************************
* Messages type: vout, major code 115
*******************************************************************************/
static void X11DestroyShmImage( vout_thread_t *p_vout, XImage *p_ximage,
XShmSegmentInfo *p_shm_info )
......@@ -608,10 +581,8 @@ static void X11DestroyShmImage( vout_thread_t *p_vout, XImage *p_ximage,
XDestroyImage( p_ximage );
if( shmdt( p_shm_info->shmaddr ) ) /* detach shared memory from process */
{ /* also automatic freeing... */
intf_ErrMsg("vout error: can't detach shared memory (%s)\n",
intf_ErrMsg("error: can't detach shared memory (%s)\n",
strerror(errno));
}
}
/* following functions are local rendering functions */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment