Commit ef84fdfe authored by Jon Lech Johansen's avatar Jon Lech Johansen

  * Overlay now works under latest QNX release.
parent 1c27686a
/***************************************************************************** /*****************************************************************************
* aout_qnx.c : Alsa functions library * aout_qnx.c : QNX audio output
***************************************************************************** *****************************************************************************
* Copyright (C) 2000 VideoLAN * Copyright (C) 2000, 2001 VideoLAN
* *
* Authors: Henri Fallon <henri@videolan.org> * Authors: Henri Fallon <henri@videolan.org>
* Jon Lech Johansen <jon-vl@nanocrew.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -50,25 +51,11 @@ ...@@ -50,25 +51,11 @@
#include "modules.h" #include "modules.h"
#include "modules_export.h" #include "modules_export.h"
typedef struct alsa_device_s
{
int i_num;
} alsa_device_t;
typedef struct alsa_card_s
{
int i_num;
} alsa_card_t;
/* here we store plugin dependant informations */
typedef struct aout_sys_s typedef struct aout_sys_s
{ {
snd_pcm_t * p_alsa_handle; snd_pcm_t * p_pcm_handle;
alsa_device_t s_alsa_device; int i_card;
alsa_card_t s_alsa_card; int i_device;
snd_pcm_channel_params_t s_alsa_channel_params;
snd_pcm_format_t s_alsa_format;
} aout_sys_t; } aout_sys_t;
/***************************************************************************** /*****************************************************************************
...@@ -104,33 +91,24 @@ void _M( aout_getfunctions )( function_list_t * p_function_list ) ...@@ -104,33 +91,24 @@ void _M( aout_getfunctions )( function_list_t * p_function_list )
*****************************************************************************/ *****************************************************************************/
static int aout_Probe( probedata_t *p_data ) static int aout_Probe( probedata_t *p_data )
{ {
int i_open_return, i_close_return; int i_ret;
aout_sys_t local_sys; aout_sys_t adev;
/* This is the same as the beginning of the aout_Open */
/* open audio device */
/* Initialize */ if( ( i_ret = snd_pcm_open_preferred( &adev.p_pcm_handle,
local_sys.s_alsa_device.i_num = 0; &adev.i_card, &adev.i_device,
local_sys.s_alsa_card.i_num = 0; SND_PCM_OPEN_PLAYBACK ) ) < 0 )
/* Open device */
i_open_return = snd_pcm_open( &(local_sys.p_alsa_handle),
local_sys.s_alsa_card.i_num,
local_sys.s_alsa_device.i_num,
SND_PCM_OPEN_PLAYBACK );
if( i_open_return )
{ {
intf_WarnMsg( 2, "aout info: could not probe ALSA device (%s)", intf_WarnMsg( 2, "aout error: unable to open audio device (%s)",
snd_strerror( i_open_return ) ); snd_strerror( i_ret ) );
return ( 0 ); return( 0 );
} }
/* Close it */ /* close audio device */
i_close_return = snd_pcm_close( local_sys.p_alsa_handle ); if( ( i_ret = snd_pcm_close( adev.p_pcm_handle ) ) < 0 )
if( i_close_return )
{ {
intf_ErrMsg( "aout error: could not close ALSA device (%s)", intf_WarnMsg( 2, "aout error: unable to close audio device (%s)",
snd_strerror( i_close_return ) ); snd_strerror( i_ret ) );
return( 0 ); return( 0 );
} }
...@@ -139,7 +117,7 @@ static int aout_Probe( probedata_t *p_data ) ...@@ -139,7 +117,7 @@ static int aout_Probe( probedata_t *p_data )
return( 999 ); return( 999 );
} }
/* And return score */ /* return score */
return( 50 ); return( 50 );
} }
...@@ -150,125 +128,113 @@ static int aout_Probe( probedata_t *p_data ) ...@@ -150,125 +128,113 @@ static int aout_Probe( probedata_t *p_data )
*****************************************************************************/ *****************************************************************************/
static int aout_Open( aout_thread_t *p_aout ) static int aout_Open( aout_thread_t *p_aout )
{ {
int i_open_returns; int i_ret;
/* Allocate structures */ /* allocate structure */
p_aout->p_sys = malloc( sizeof( aout_sys_t ) ); p_aout->p_sys = malloc( sizeof( aout_sys_t ) );
if( p_aout->p_sys == NULL ) if( p_aout->p_sys == NULL )
{ {
intf_ErrMsg( "aout error: failed allocating memory for ALSA (%s)", intf_ErrMsg( "aout error: unable to allocate memory (%s)",
strerror(ENOMEM) ); strerror( ENOMEM ) );
return( 1 ); return( 1 );
} }
/* Initialize */ /* initialize */
p_aout->p_sys->s_alsa_device.i_num = 0; p_aout->i_format = AOUT_FORMAT_DEFAULT;
p_aout->p_sys->s_alsa_card.i_num = 0; p_aout->i_channels = main_GetIntVariable( AOUT_STEREO_VAR,
/* FIXME : why not other format ? */ AOUT_STEREO_DEFAULT ) + 1;
p_aout->i_format = AOUT_FMT_S16_LE; p_aout->l_rate = main_GetIntVariable( AOUT_RATE_VAR,
/* FIXME : why always 2 channels ?*/ AOUT_RATE_DEFAULT );
p_aout->i_channels = 2;
p_aout->l_rate = main_GetIntVariable( AOUT_RATE_VAR, AOUT_RATE_DEFAULT ); /* open audio device */
if( ( i_ret = snd_pcm_open_preferred( &p_aout->p_sys->p_pcm_handle,
/* Open device */ &p_aout->p_sys->i_card,
if( ( i_open_returns = snd_pcm_open( &(p_aout->p_sys->p_alsa_handle), &p_aout->p_sys->i_device,
p_aout->p_sys->s_alsa_card.i_num, SND_PCM_OPEN_PLAYBACK ) ) < 0 )
p_aout->p_sys->s_alsa_device.i_num,
SND_PCM_OPEN_PLAYBACK ) ) )
{ {
intf_ErrMsg( "aout error: could not open ALSA device (%s)", intf_ErrMsg( "aout error: unable to open audio device (%s)",
snd_strerror(i_open_returns) ); snd_strerror( i_ret ) );
return( -1 ); return( 1 );
}
/* disable mmap */
if( ( i_ret = snd_pcm_plugin_set_disable( p_aout->p_sys->p_pcm_handle,
PLUGIN_DISABLE_MMAP ) ) < 0 )
{
intf_ErrMsg( "aout error: unable to disable mmap (%s)",
snd_strerror( i_ret ) );
aout_Close( p_aout );
return( 1 );
} }
intf_DbgMsg( "aout info: ALSA device successfully opened" );
return( 0 ); return( 0 );
} }
/***************************************************************************** /*****************************************************************************
* aout_SetFormat : sets the alsa output format * aout_SetFormat : set the audio output format
***************************************************************************** *****************************************************************************
* This function prepares the device, sets the rate, format, the mode * This function prepares the device, sets the rate, format, the mode
* ("play as soon as you have data"), and buffer information. * ("play as soon as you have data"), and buffer information.
*****************************************************************************/ *****************************************************************************/
static int aout_SetFormat( aout_thread_t *p_aout ) static int aout_SetFormat( aout_thread_t *p_aout )
{ {
int i_ret;
snd_pcm_channel_info_t pi;
snd_pcm_channel_params_t pp;
int i_set_param_returns; memset( &pi, 0, sizeof(pi) );
int i_prepare_playback_returns; memset( &pp, 0, sizeof(pp) );
int i_playback_go_returns;
/* Fill with zeros */
memset( &p_aout->p_sys->s_alsa_channel_params, 0,
sizeof( p_aout->p_sys->s_alsa_channel_params ) );
/* Fill the s_alsa_channel_params structure */ pi.channel = SND_PCM_CHANNEL_PLAYBACK;
if( ( i_ret = snd_pcm_plugin_info( p_aout->p_sys->p_pcm_handle,
/* Tranfer mode and direction*/ &pi ) ) < 0 )
p_aout->p_sys->s_alsa_channel_params.channel = SND_PCM_CHANNEL_PLAYBACK ;
p_aout->p_sys->s_alsa_channel_params.mode = SND_PCM_MODE_STREAM;
/* Format and rate */
p_aout->p_sys->s_alsa_channel_params.format.interleave = 1;
if( p_aout->i_format == AOUT_FMT_S16_LE )
{
p_aout->p_sys->s_alsa_channel_params.format.format =
SND_PCM_SFMT_S16_LE;
}
else
{ {
p_aout->p_sys->s_alsa_channel_params.format.format = intf_ErrMsg( "aout error: unable to get plugin info (%s)",
SND_PCM_SFMT_S16_BE; snd_strerror( i_ret ) );
return( 1 );
} }
p_aout->p_sys->s_alsa_channel_params.format.rate = p_aout->l_rate;
p_aout->p_sys->s_alsa_channel_params.format.voices = p_aout->i_channels ;
/* When to start playing and when to stop */
p_aout->p_sys->s_alsa_channel_params.start_mode = SND_PCM_START_DATA;
p_aout->p_sys->s_alsa_channel_params.stop_mode = SND_PCM_STOP_STOP;
/* Buffer information . I have chosen the stream mode here pp.mode = SND_PCM_MODE_STREAM;
* instead of the block mode. I don't know whether i'm wrong pp.channel = SND_PCM_CHANNEL_PLAYBACK;
* but it seemed more logical */ pp.start_mode = SND_PCM_START_DATA;
/* TODO : find the best value to put here. Probably depending pp.stop_mode = SND_PCM_STOP_STOP;
* on many parameters */
p_aout->p_sys->s_alsa_channel_params.buf.stream.queue_size = 131072;
p_aout->p_sys->s_alsa_channel_params.buf.stream.fill = SND_PCM_FILL_NONE ; pp.buf.stream.queue_size = pi.max_fragment_size;
p_aout->p_sys->s_alsa_channel_params.buf.stream.max_fill = 0 ; pp.buf.stream.fill = SND_PCM_FILL_NONE;
pp.buf.stream.max_fill = 0;
/* Now we pass this to the driver */ pp.format.interleave = 1;
i_set_param_returns = snd_pcm_channel_params( pp.format.rate = p_aout->l_rate;
p_aout->p_sys->p_alsa_handle, pp.format.voices = p_aout->i_channels;
&(p_aout->p_sys->s_alsa_channel_params) );
if( i_set_param_returns ) switch( p_aout->i_format )
{ {
intf_ErrMsg( "aout error: unable to set parameters (%s)", case AOUT_FMT_S16_LE:
snd_strerror( i_set_param_returns ) ); pp.format.format = SND_PCM_SFMT_S16_LE;
return( -1 ); break;
}
/* we shall now prepare the channel */ default:
i_prepare_playback_returns = pp.format.format = SND_PCM_SFMT_S16_BE;
snd_pcm_playback_prepare( p_aout->p_sys->p_alsa_handle ); break;
}
if( i_prepare_playback_returns ) /* set parameters */
if( ( i_ret = snd_pcm_plugin_params( p_aout->p_sys->p_pcm_handle,
&pp ) ) < 0 )
{ {
intf_ErrMsg( "aout error: unable to prepare channel (%s)", intf_ErrMsg( "aout error: unable to set parameters (%s)",
snd_strerror( i_set_param_returns ) ); snd_strerror( i_ret ) );
return( -1 ); return( 1 );
} }
/* then we may go */ /* prepare channel */
i_playback_go_returns = if( ( i_ret = snd_pcm_plugin_prepare( p_aout->p_sys->p_pcm_handle,
snd_pcm_playback_go( p_aout->p_sys->p_alsa_handle ); SND_PCM_CHANNEL_PLAYBACK ) ) < 0 )
if( i_playback_go_returns )
{ {
intf_ErrMsg( "aout error: unable to prepare channel (bis) (%s)", intf_ErrMsg( "aout error: unable to prepare channel (%s)",
snd_strerror( i_set_param_returns ) ); snd_strerror( i_ret ) );
return( -1 ); return( 1 );
} }
p_aout->i_latency = 0; p_aout->i_latency = 0;
...@@ -286,45 +252,34 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -286,45 +252,34 @@ static int aout_SetFormat( aout_thread_t *p_aout )
*****************************************************************************/ *****************************************************************************/
static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit ) static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
{ {
snd_pcm_channel_status_t alsa_channel_status; int i_ret;
int i_alsa_get_status_returns; snd_pcm_channel_status_t status;
memset( &alsa_channel_status, 0, sizeof( alsa_channel_status ) );
i_alsa_get_status_returns = snd_pcm_channel_status(
p_aout->p_sys->p_alsa_handle, &alsa_channel_status );
if( i_alsa_get_status_returns ) /* get current pcm status */
memset( &status, 0, sizeof(status) );
if( ( i_ret = snd_pcm_plugin_status( p_aout->p_sys->p_pcm_handle,
&status ) ) < 0 )
{ {
intf_ErrMsg( "aout error: failed getting alsa buffer info (%s)", intf_ErrMsg( "aout error: unable to get device status (%s)",
snd_strerror ( i_alsa_get_status_returns ) ); snd_strerror( i_ret ) );
return( -1 ); return( -1 );
} }
switch( alsa_channel_status.status ) /* check for underrun */
switch( status.status )
{ {
case SND_PCM_STATUS_NOTREADY: case SND_PCM_STATUS_READY:
{
intf_ErrMsg( "aout error: status NOT READY" );
break;
}
case SND_PCM_STATUS_UNDERRUN: case SND_PCM_STATUS_UNDERRUN:
if( ( i_ret = snd_pcm_plugin_prepare( p_aout->p_sys->p_pcm_handle,
SND_PCM_CHANNEL_PLAYBACK ) ) < 0 )
{ {
int i_prepare_returns; intf_ErrMsg( "aout error: unable to prepare channel (%s)",
intf_ErrMsg( "aout error: status UNDERRUN ... resetting queue "); snd_strerror( i_ret ) );
i_prepare_returns = snd_pcm_playback_prepare(
p_aout->p_sys->p_alsa_handle );
if ( i_prepare_returns )
{
intf_ErrMsg( "aout error: could not flush (%s)",
snd_strerror(i_prepare_returns) );
} }
break; break;
} }
}
return( alsa_channel_status.count ); return( status.count );
} }
/***************************************************************************** /*****************************************************************************
...@@ -334,34 +289,29 @@ static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit ) ...@@ -334,34 +289,29 @@ static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
*****************************************************************************/ *****************************************************************************/
static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size ) static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size )
{ {
int i_write_returns; int i_ret;
i_write_returns = (int) snd_pcm_write (
p_aout->p_sys->p_alsa_handle, (void *) buffer, (size_t) i_size );
if( i_write_returns <= 0 ) if( ( i_ret = snd_pcm_plugin_write( p_aout->p_sys->p_pcm_handle,
(void *) buffer,
(size_t) i_size ) ) <= 0 )
{ {
intf_ErrMsg( "aout error: writing blocks failed (%s)", intf_ErrMsg( "aout error: unable to write data (%s)",
snd_strerror( i_write_returns ) ); snd_strerror( i_ret ) );
} }
} }
/***************************************************************************** /*****************************************************************************
* aout_Close : close the Alsa device * aout_Close : close the audio device
*****************************************************************************/ *****************************************************************************/
static void aout_Close( aout_thread_t *p_aout ) static void aout_Close( aout_thread_t *p_aout )
{ {
int i_close_returns; int i_ret;
i_close_returns = snd_pcm_close( p_aout->p_sys->p_alsa_handle );
if( i_close_returns ) if( ( i_ret = snd_pcm_close( p_aout->p_sys->p_pcm_handle ) ) < 0 )
{ {
intf_ErrMsg( "aout error: failed closing ALSA device (%s)", intf_ErrMsg( "aout error: unable to close audio device (%s)",
snd_strerror( i_close_returns ) ); snd_strerror( i_ret ) );
} }
free( p_aout->p_sys );
intf_DbgMsg( "aout: ALSA device closed" ); free( p_aout->p_sys );
} }
...@@ -94,8 +94,10 @@ typedef struct vout_sys_s ...@@ -94,8 +94,10 @@ typedef struct vout_sys_s
/* position & dimensions */ /* position & dimensions */
PhPoint_t pos; PhPoint_t pos;
PhDim_t dim; PhDim_t dim;
PhPoint_t old_pos;
PhDim_t old_dim; PhDim_t old_dim;
PhDim_t screen_dim; PhDim_t screen_dim;
PhRect_t frame;
} vout_sys_t; } vout_sys_t;
/***************************************************************************** /*****************************************************************************
...@@ -109,9 +111,9 @@ static void vout_Destroy ( struct vout_thread_s * ); ...@@ -109,9 +111,9 @@ static void vout_Destroy ( struct vout_thread_s * );
static int vout_Manage ( struct vout_thread_s * ); static int vout_Manage ( struct vout_thread_s * );
static void vout_Display ( struct vout_thread_s * ); static void vout_Display ( struct vout_thread_s * );
static int QNXInitDisplay ( struct vout_thread_s * );
static int QNXCreateWnd ( struct vout_thread_s * ); static int QNXCreateWnd ( struct vout_thread_s * );
static int QNXDestroyWnd ( struct vout_thread_s * ); static int QNXDestroyWnd ( struct vout_thread_s * );
static int QNXInitDisplay ( struct vout_thread_s * );
/***************************************************************************** /*****************************************************************************
* Functions exported as capabilities. They are declared as static so that * Functions exported as capabilities. They are declared as static so that
...@@ -265,8 +267,7 @@ static int vout_Init( vout_thread_t *p_vout ) ...@@ -265,8 +267,7 @@ static int vout_Init( vout_thread_t *p_vout )
} }
/* set bytes per line, clear buffers, set buffers */ /* set bytes per line, clear buffers, set buffers */
p_vout->i_bytes_per_line = p_vout->i_bytes_per_line = p_vout->p_sys->p_ctx[0]->pitch;
p_vout->i_bytes_per_pixel * p_vout->p_sys->dim.w;
memset( p_vout->p_sys->p_buf[0], 0, memset( p_vout->p_sys->p_buf[0], 0,
p_vout->i_bytes_per_line * p_vout->p_sys->dim.h ); p_vout->i_bytes_per_line * p_vout->p_sys->dim.h );
memset( p_vout->p_sys->p_buf[1], 0, memset( p_vout->p_sys->p_buf[1], 0,
...@@ -276,25 +277,47 @@ static int vout_Init( vout_thread_t *p_vout ) ...@@ -276,25 +277,47 @@ static int vout_Init( vout_thread_t *p_vout )
} }
else if( p_vout->p_sys->i_mode == MODE_VIDEO_OVERLAY ) else if( p_vout->p_sys->i_mode == MODE_VIDEO_OVERLAY )
{ {
int i_ret;
PgScalerProps_t props; PgScalerProps_t props;
props.size = sizeof( props ); props.size = sizeof( props );
props.format = p_vout->p_sys->i_vc_format; props.format = p_vout->p_sys->i_vc_format;
props.viewport.ul.x = p_vout->p_sys->pos.x + 4;
props.viewport.ul.y = p_vout->p_sys->pos.y + 20;
props.viewport.lr.x = p_vout->p_sys->dim.w + props.viewport.ul.x;
props.viewport.lr.y = p_vout->p_sys->dim.h + props.viewport.ul.y;
props.src_dim.w = p_vout->p_sys->dim.w;
props.src_dim.h = p_vout->p_sys->dim.h;
props.flags = Pg_SCALER_PROP_SCALER_ENABLE | props.flags = Pg_SCALER_PROP_SCALER_ENABLE |
Pg_SCALER_PROP_DOUBLE_BUFFER; Pg_SCALER_PROP_DOUBLE_BUFFER;
if( PgConfigScalerChannel( p_vout->p_sys->p_channel, &props ) == -1 ) /* enable chroma keying if available */
if( p_vout->p_sys->i_vc_flags & Pg_SCALER_CAP_DST_CHROMA_KEY )
{
props.flags |= Pg_SCALER_PROP_CHROMA_ENABLE;
}
/* set viewport position */
props.viewport.ul.x = p_vout->p_sys->pos.x;
props.viewport.ul.y = p_vout->p_sys->pos.y;
if( !p_vout->b_fullscreen )
{
props.viewport.ul.x += p_vout->p_sys->frame.ul.x;
props.viewport.ul.y += p_vout->p_sys->frame.ul.y;
}
/* set viewport dimension */
props.viewport.lr.x = p_vout->p_sys->dim.w + props.viewport.ul.x;
props.viewport.lr.y = p_vout->p_sys->dim.h + props.viewport.ul.y;
/* set source dimension */
props.src_dim.w = p_vout->i_width;
props.src_dim.h = p_vout->i_height;
/* configure scaler channel */
i_ret = PgConfigScalerChannel( p_vout->p_sys->p_channel, &props );
if( i_ret == -1 )
{ {
intf_ErrMsg( "vout error: unable to configure video channel" ); intf_ErrMsg( "vout error: unable to configure video channel" );
return( 1 ); return( 1 );
} }
else if( i_ret == 1 )
{
p_vout->p_sys->p_vc_y[0] = p_vout->p_sys->p_vc_y[0] =
PdGetOffscreenContextPtr( p_vout->p_sys->p_channel->yplane1 ); PdGetOffscreenContextPtr( p_vout->p_sys->p_channel->yplane1 );
p_vout->p_sys->p_vc_y[1] = p_vout->p_sys->p_vc_y[1] =
...@@ -306,8 +329,9 @@ static int vout_Init( vout_thread_t *p_vout ) ...@@ -306,8 +329,9 @@ static int vout_Init( vout_thread_t *p_vout )
intf_ErrMsg( "vout error: unable to get video channel ctx ptr" ); intf_ErrMsg( "vout error: unable to get video channel ctx ptr" );
return( 1 ); return( 1 );
} }
}
if( p_vout->p_sys->i_vc_format == Pg_VIDEO_FORMAT_YV12 ) if( p_vout->p_sys->i_vc_format == Pg_VIDEO_FORMAT_YV12 && i_ret == 1 )
{ {
p_vout->b_need_render = 0; p_vout->b_need_render = 0;
...@@ -333,11 +357,11 @@ static int vout_Init( vout_thread_t *p_vout ) ...@@ -333,11 +357,11 @@ static int vout_Init( vout_thread_t *p_vout )
{ {
/* set bytes per line, clear buffers, set buffers */ /* set bytes per line, clear buffers, set buffers */
p_vout->i_bytes_per_line = p_vout->i_bytes_per_line =
p_vout->i_bytes_per_pixel * p_vout->p_sys->dim.w; p_vout->p_sys->p_channel->yplane1->pitch;
memset( p_vout->p_sys->p_vc_y[0], 0, memset( p_vout->p_sys->p_vc_y[0], 0,
p_vout->i_bytes_per_line * p_vout->p_sys->dim.h ); p_vout->i_bytes_per_line * p_vout->i_height );
memset( p_vout->p_sys->p_vc_y[1], 0, memset( p_vout->p_sys->p_vc_y[1], 0,
p_vout->i_bytes_per_line * p_vout->p_sys->dim.h ); p_vout->i_bytes_per_line * p_vout->i_height );
p_vout->pf_setbuffers( p_vout, p_vout->pf_setbuffers( p_vout,
p_vout->p_sys->p_vc_y[0], p_vout->p_sys->p_vc_y[1] ); p_vout->p_sys->p_vc_y[0], p_vout->p_sys->p_vc_y[1] );
} }
...@@ -435,16 +459,16 @@ static int vout_Manage( vout_thread_t *p_vout ) ...@@ -435,16 +459,16 @@ static int vout_Manage( vout_thread_t *p_vout )
break; break;
case Ph_WM_MOVE: case Ph_WM_MOVE:
b_repos = 1;
p_vout->p_sys->pos.x = p_ev->pos.x; p_vout->p_sys->pos.x = p_ev->pos.x;
p_vout->p_sys->pos.y = p_ev->pos.y; p_vout->p_sys->pos.y = p_ev->pos.y;
b_repos = 1;
break; break;
case Ph_WM_RESIZE: case Ph_WM_RESIZE:
p_vout->p_sys->old_dim.w = p_vout->p_sys->dim.w; p_vout->p_sys->old_dim.w = p_vout->p_sys->dim.w;
p_vout->p_sys->old_dim.h = p_vout->p_sys->dim.h; p_vout->p_sys->old_dim.h = p_vout->p_sys->dim.h;
p_vout->p_sys->dim.w = p_vout->i_width = p_ev->size.w; p_vout->p_sys->dim.w = p_ev->size.w;
p_vout->p_sys->dim.h = p_vout->i_height = p_ev->size.h; p_vout->p_sys->dim.h = p_ev->size.h;
p_vout->i_changes |= VOUT_SIZE_CHANGE; p_vout->i_changes |= VOUT_SIZE_CHANGE;
break; break;
} }
...@@ -501,7 +525,6 @@ static int vout_Manage( vout_thread_t *p_vout ) ...@@ -501,7 +525,6 @@ static int vout_Manage( vout_thread_t *p_vout )
if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE ) if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )
{ {
PhDim_t dim; PhDim_t dim;
PhPoint_t pos;
intf_DbgMsg( "vout: changing full-screen status" ); intf_DbgMsg( "vout: changing full-screen status" );
...@@ -510,42 +533,34 @@ static int vout_Manage( vout_thread_t *p_vout ) ...@@ -510,42 +533,34 @@ static int vout_Manage( vout_thread_t *p_vout )
if( p_vout->b_fullscreen ) if( p_vout->b_fullscreen )
{ {
pos.x = pos.y = 0; p_vout->p_sys->old_pos.x = p_vout->p_sys->pos.x;
p_vout->p_sys->old_pos.y = p_vout->p_sys->pos.y;
p_vout->p_sys->pos.x = p_vout->p_sys->pos.y = 0;
dim.w = p_vout->p_sys->screen_dim.w + 1; dim.w = p_vout->p_sys->screen_dim.w + 1;
dim.h = p_vout->p_sys->screen_dim.h + 1; dim.h = p_vout->p_sys->screen_dim.h + 1;
} }
else else
{ {
pos.x = p_vout->p_sys->pos.x; p_vout->p_sys->pos.x = p_vout->p_sys->old_pos.x;
pos.y = p_vout->p_sys->pos.y; p_vout->p_sys->pos.y = p_vout->p_sys->old_pos.y;
dim.w = p_vout->p_sys->old_dim.w + 1; dim.w = p_vout->p_sys->old_dim.w + 1;
dim.h = p_vout->p_sys->old_dim.h + 1; dim.h = p_vout->p_sys->old_dim.h + 1;
} }
/* modify render flags, border */
PtSetResource( p_vout->p_sys->p_window, PtSetResource( p_vout->p_sys->p_window,
Pt_ARG_WINDOW_RENDER_FLAGS, Pt_ARG_WINDOW_RENDER_FLAGS,
p_vout->b_fullscreen ? Pt_FALSE : Pt_TRUE, p_vout->b_fullscreen ? Pt_FALSE : Pt_TRUE,
Ph_WM_RENDER_BORDER | Ph_WM_RENDER_TITLE ); Ph_WM_RENDER_BORDER | Ph_WM_RENDER_TITLE );
/* set position and dimension */
PtSetResource( p_vout->p_sys->p_window, PtSetResource( p_vout->p_sys->p_window,
Pt_ARG_POS, &pos, 0 ); Pt_ARG_POS, &p_vout->p_sys->pos, 0 );
PtSetResource( p_vout->p_sys->p_window, PtSetResource( p_vout->p_sys->p_window,
Pt_ARG_DIM, &dim, 0 ); Pt_ARG_DIM, &dim, 0 );
}
/*
* vout window resizing
*/
if( ( p_vout->i_width != p_vout->p_sys->dim.w ) ||
( p_vout->i_height != p_vout->p_sys->dim.h ) )
{
intf_DbgMsg( "vout: resizing output window" );
p_vout->p_sys->dim.w = p_vout->i_width; /* mark as damaged to force redraw */
p_vout->p_sys->dim.h = p_vout->i_height; PtDamageWidget( p_vout->p_sys->p_window );
/* set new dimension */
PtSetResource( p_vout->p_sys->p_window,
Pt_ARG_DIM, &p_vout->p_sys->dim, 0 );
} }
/* /*
...@@ -556,6 +571,13 @@ static int vout_Manage( vout_thread_t *p_vout ) ...@@ -556,6 +571,13 @@ static int vout_Manage( vout_thread_t *p_vout )
intf_DbgMsg( "vout: resizing window" ); intf_DbgMsg( "vout: resizing window" );
p_vout->i_changes &= ~VOUT_SIZE_CHANGE; p_vout->i_changes &= ~VOUT_SIZE_CHANGE;
if( p_vout->p_sys->i_mode != MODE_VIDEO_OVERLAY )
{
p_vout->i_width = p_vout->p_sys->dim.w;
p_vout->i_height = p_vout->p_sys->dim.h;
p_vout->i_changes |= VOUT_YUV_CHANGE;
}
vout_End( p_vout ); vout_End( p_vout );
if( vout_Init( p_vout ) ) if( vout_Init( p_vout ) )
{ {
...@@ -563,9 +585,8 @@ static int vout_Manage( vout_thread_t *p_vout ) ...@@ -563,9 +585,8 @@ static int vout_Manage( vout_thread_t *p_vout )
return( 1 ); return( 1 );
} }
p_vout->i_changes |= VOUT_YUV_CHANGE;
intf_Msg( "vout: video display resized (%dx%d)", intf_Msg( "vout: video display resized (%dx%d)",
p_vout->i_width, p_vout->i_height ); p_vout->p_sys->dim.w, p_vout->p_sys->dim.h );
} }
/* /*
...@@ -664,6 +685,14 @@ static int QNXInitDisplay( p_vout_thread_t p_vout ) ...@@ -664,6 +685,14 @@ static int QNXInitDisplay( p_vout_thread_t p_vout )
return( 1 ); return( 1 );
} }
/* switch to normal mode if no overlay support */
if( p_vout->p_sys->i_mode == MODE_VIDEO_OVERLAY &&
!( minfo.mode_capabilities1 & PgVM_MODE_CAP1_VIDEO_OVERLAY ) )
{
intf_ErrMsg( "vout error: no overlay support detected" );
p_vout->p_sys->i_mode = MODE_NORMAL_MEM;
}
/* use video ram if we have enough available */ /* use video ram if we have enough available */
if( p_vout->p_sys->i_mode == MODE_NORMAL_MEM && if( p_vout->p_sys->i_mode == MODE_NORMAL_MEM &&
hwcaps.currently_available_video_ram >= hwcaps.currently_available_video_ram >=
...@@ -729,36 +758,17 @@ static int QNXCreateWnd( p_vout_thread_t p_vout ) ...@@ -729,36 +758,17 @@ static int QNXCreateWnd( p_vout_thread_t p_vout )
PhPoint_t pos = { 0, 0 }; PhPoint_t pos = { 0, 0 };
PgColor_t color = Pg_BLACK; PgColor_t color = Pg_BLACK;
/* correct way to check for overlay support:
1. call PgGetGraphicsHWCaps and check
the results for Pg_VIDEO_OVERLAY
2. check if the current graphics mode
has PgVM_MODE_CAP1_VIDEO_OVERLAY set
3. call PgGetScalerCapabilities for info
problems:
1. Pg_VIDEO_OVERLAY is not defined in any
header files :)
2. PgVM_MODE_CAP1_VIDEO_OVERLAY is not set
even if the current mode supports overlay
3. the flags (chroma, etc) do not reflect
the actual capabilities
*/
if( p_vout->p_sys->i_mode == MODE_VIDEO_OVERLAY ) if( p_vout->p_sys->i_mode == MODE_VIDEO_OVERLAY )
{ {
int i = 0;
PgScalerCaps_t vcaps;
if( ( p_vout->p_sys->p_channel = if( ( p_vout->p_sys->p_channel =
PgCreateVideoChannel( Pg_VIDEO_CHANNEL_SCALER, 0 ) ) == NULL ) PgCreateVideoChannel( Pg_VIDEO_CHANNEL_SCALER, 0 ) ) == NULL )
{ {
intf_ErrMsg( "vout error: unable to create video channel" ); intf_ErrMsg( "vout error: unable to create video channel" );
return( 1 ); return( 1 );
} }
else
{
int i = 0;
PgScalerCaps_t vcaps;
vcaps.size = sizeof( vcaps ); vcaps.size = sizeof( vcaps );
while( PgGetScalerCapabilities( p_vout->p_sys->p_channel, while( PgGetScalerCapabilities( p_vout->p_sys->p_channel,
...@@ -777,14 +787,15 @@ static int QNXCreateWnd( p_vout_thread_t p_vout ) ...@@ -777,14 +787,15 @@ static int QNXCreateWnd( p_vout_thread_t p_vout )
if( p_vout->p_sys->i_vc_format == 0 ) if( p_vout->p_sys->i_vc_format == 0 )
{ {
intf_ErrMsg( "vout error: need YV12 or RGB8888 overlay" ); intf_ErrMsg( "vout error: need YV12 or RGB8888 overlay" );
return( 1 ); return( 1 );
} }
else if( vcaps.flags & Pg_SCALER_CAP_DST_CHROMA_KEY )
if( p_vout->p_sys->i_vc_flags & Pg_SCALER_CAP_DST_CHROMA_KEY )
{ {
color = PgGetOverlayChromaColor(); color = PgGetOverlayChromaColor();
} }
} }
}
/* fullscreen, set dimension */ /* fullscreen, set dimension */
if( p_vout->b_fullscreen ) if( p_vout->b_fullscreen )
...@@ -823,6 +834,15 @@ static int QNXCreateWnd( p_vout_thread_t p_vout ) ...@@ -823,6 +834,15 @@ static int QNXCreateWnd( p_vout_thread_t p_vout )
return( 1 ); return( 1 );
} }
/* get window frame size */
if( PtWindowFrameSize( NULL, p_vout->p_sys->p_window,
&p_vout->p_sys->frame ) != 0 )
{
intf_ErrMsg( "vout error: unable to get window frame size" );
PtDestroyWidget( p_vout->p_sys->p_window );
return( 1 );
}
return( 0 ); return( 0 );
} }
......
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