* directx.c: Windows DirectX audio output method
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: directx.c,v 1.17 2003/04/07 16:02:08 gbazin Exp $
+ * $Id: directx.c,v 1.18 2003/04/29 16:03:14 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
if( var_Get( p_aout, "audio-device", &val ) < 0 )
{
/* Probe() has failed. */
- free( p_aout->output.p_sys );
- return VLC_EGENERIC;
+ goto error;
}
/* Then create the notification events */
p_aout->output.p_sys->i_frame_size, VLC_FALSE )
!= VLC_SUCCESS )
{
- msg_Err( p_aout, "cannot open waveout audio device" );
+ msg_Err( p_aout, "cannot open directx audio device" );
free( p_aout->output.p_sys );
return VLC_EGENERIC;
}
p_aout->output.output.i_rate, VLC_FALSE )
!= VLC_SUCCESS )
{
- msg_Err( p_aout, "cannot open waveout audio device" );
+ msg_Err( p_aout, "cannot open directx audio device" );
free( p_aout->output.p_sys );
return VLC_EGENERIC;
}
p_aout->output.p_sys->p_dsobject, &dsbdesc,
&p_aout->output.p_sys->p_dsbuffer, NULL) )
{
- goto error;
+ return VLC_EGENERIC;
}
/* Stop here if we were just probing */
return VLC_SUCCESS;
error:
- if( p_aout->output.p_sys->p_dsbuffer )
- {
- IDirectSoundBuffer_Release( p_aout->output.p_sys->p_dsbuffer );
- p_aout->output.p_sys->p_dsbuffer = NULL;
- }
- if( p_aout->output.p_sys->p_dsnotify )
- {
- IDirectSoundBuffer_Release( p_aout->output.p_sys->p_dsbuffer );
- p_aout->output.p_sys->p_dsnotify = NULL;
- }
+ DestroyDSBuffer( p_aout );
return VLC_EGENERIC;
}
* vout.c: Windows DirectX video output display method
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: directx.c,v 1.16 2003/03/30 18:14:39 gbazin Exp $
+ * $Id: directx.c,v 1.17 2003/04/29 16:03:14 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
DDBLT_ASYNC, &ddbltfx );
if( dxresult != DD_OK )
{
- msg_Warn( p_vout, "could not blit surface (error %i)", dxresult );
+ msg_Warn( p_vout, "could not blit surface (error %li)", dxresult );
return;
}
NULL, DDFLIP_WAIT );
if( dxresult != DD_OK )
{
- msg_Warn( p_vout, "could not flip overlay (error %i)", dxresult );
+ msg_Warn( p_vout, "could not flip overlay (error %li)", dxresult );
}
/* set currently displayed pic */
&p_display, NULL );
if( dxresult != DD_OK )
{
- msg_Err( p_vout, "cannot get primary surface (error %i)", dxresult );
+ msg_Err( p_vout, "cannot get primary surface (error %li)", dxresult );
return VLC_EGENERIC;
}
if ( dxresult != DD_OK )
{
msg_Err( p_vout, "cannot query IDirectDrawSurface2 interface "
- "(error %i)", dxresult );
+ "(error %li)", dxresult );
return VLC_EGENERIC;
}
if( dxresult != DD_OK )
{
msg_Warn( p_vout, "DirectXUpdateOverlay GetPixelFormat failed "
- "(error %i)", dxresult );
+ "(error %li)", dxresult );
}
p_vout->p_sys->i_colorkey = (DWORD)((( p_vout->p_sys->i_rgb_colorkey
* pixel_format.dwRBitMask) / 255)
&p_vout->p_sys->p_clipper, NULL );
if( dxresult != DD_OK )
{
- msg_Warn( p_vout, "cannot create clipper (error %i)", dxresult );
+ msg_Warn( p_vout, "cannot create clipper (error %li)", dxresult );
goto error;
}
p_vout->p_sys->hwnd);
if( dxresult != DD_OK )
{
- msg_Warn( p_vout, "cannot attach clipper to window (error %i)",
+ msg_Warn( p_vout, "cannot attach clipper to window (error %li)",
dxresult );
goto error;
}
p_vout->p_sys->p_clipper);
if( dxresult != DD_OK )
{
- msg_Warn( p_vout, "cannot attach clipper to surface (error %i)",
+ msg_Warn( p_vout, "cannot attach clipper to surface (error %li)",
dxresult );
goto error;
}
if ( dxresult != DD_OK )
{
msg_Err( p_vout, "cannot query IDirectDrawSurface2 interface "
- "(error %i)", dxresult );
+ "(error %li)", dxresult );
*pp_surface_final = NULL;
return VLC_EGENERIC;
}
{
if( p_vout->p_sys->b_hw_yuv )
{
- i_ret = DirectXCreateSurface( p_vout, &p_surface,
- p_vout->output.i_chroma,
- 0 /* no overlay */,
- 0 /* no back buffers */ );
+ DWORD i_codes;
+ DWORD *pi_codes;
+ vlc_bool_t b_result = VLC_FALSE;
+
+ /* Check if the chroma is supported first. This is required
+ * because a few buggy drivers don't mind creating the surface
+ * even if they don't know about the chroma. */
+ if( IDirectDraw2_GetFourCCCodes( p_vout->p_sys->p_ddobject,
+ &i_codes, NULL ) )
+ {
+ pi_codes = malloc( i_codes * sizeof(DWORD) );
+ if( pi_codes && IDirectDraw2_GetFourCCCodes(
+ p_vout->p_sys->p_ddobject, &i_codes, pi_codes ) )
+ {
+ for( i = 0; i < (int)i_codes; i++ )
+ {
+ if( p_vout->output.i_chroma == pi_codes[i] )
+ {
+ b_result = VLC_TRUE;
+ break;
+ }
+ }
+ }
+ }
+
+ if( b_result )
+ i_ret = DirectXCreateSurface( p_vout, &p_surface,
+ p_vout->output.i_chroma,
+ 0 /* no overlay */,
+ 0 /* no back buffers */ );
+ else
+ p_vout->p_sys->b_hw_yuv = VLC_FALSE;
}
if( i_ret || !p_vout->p_sys->b_hw_yuv )
else
{
BOOL bHasOverlay, bHasOverlayFourCC, bCanClipOverlay,
- bHasColorKey, bCanStretch;
+ bHasColorKey, bCanStretch, bCanBltFourcc;
/* Determine if the hardware supports overlay surfaces */
bHasOverlay = ((ddcaps.dwCaps & DDCAPS_OVERLAY) ==
/* Determine if the hardware supports scaling of the overlay surface */
bCanStretch = ((ddcaps.dwCaps & DDCAPS_OVERLAYSTRETCH) ==
DDCAPS_OVERLAYSTRETCH) ? TRUE : FALSE;
+ /* Determine if the hardware supports color conversion during a blit */
+ bCanBltFourcc = ((ddcaps.dwCaps & DDCAPS_BLTFOURCC ) ==
+ DDCAPS_BLTFOURCC) ? TRUE : FALSE;
+
msg_Dbg( p_vout, "DirectDraw Capabilities: overlay=%i yuvoverlay=%i "
- "can_clip_overlay=%i colorkey=%i stretch=%i",
+ "can_clip_overlay=%i colorkey=%i stretch=%i "
+ "bltfourcc=%i",
bHasOverlay, bHasOverlayFourCC, bCanClipOverlay,
- bHasColorKey, bCanStretch );
+ bHasColorKey, bCanStretch, bCanBltFourcc );
/* Overlay clipping support is interesting for us as it means we can
* get rid of the colorkey alltogether */
p_vout->p_sys->b_caps_overlay_clipping = bCanClipOverlay;
+ /* Don't ask for troubles */
+ if( !bCanBltFourcc ) p_vout->p_sys->b_hw_yuv = FALSE;
}
}