Commit 62eefa47 authored by Laurent Aimar's avatar Laurent Aimar

Fixed decoder init when libdca is not present + clean up.

parent ef3199b3
...@@ -35,7 +35,23 @@ ...@@ -35,7 +35,23 @@
#include <vlc_aout.h> #include <vlc_aout.h>
#include <vlc_block_helper.h> #include <vlc_block_helper.h>
#define DTS_HEADER_SIZE 14 /*****************************************************************************
* Module descriptor
*****************************************************************************/
static int OpenDecoder ( vlc_object_t * );
static int OpenPacketizer( vlc_object_t * );
static void CloseCommon ( vlc_object_t * );
vlc_module_begin ()
set_description( N_("DTS parser") )
set_capability( "decoder", 100 )
set_callbacks( OpenDecoder, CloseCommon )
add_submodule ()
set_description( N_("DTS audio packetizer") )
set_capability( "packetizer", 10 )
set_callbacks( OpenPacketizer, CloseCommon )
vlc_module_end ()
/***************************************************************************** /*****************************************************************************
* decoder_sys_t : decoder descriptor * decoder_sys_t : decoder descriptor
...@@ -77,57 +93,62 @@ enum { ...@@ -77,57 +93,62 @@ enum {
STATE_SEND_DATA STATE_SEND_DATA
}; };
#define DTS_HEADER_SIZE 14
/**************************************************************************** /****************************************************************************
* Local prototypes * Local prototypes
****************************************************************************/ ****************************************************************************/
static int OpenDecoder ( vlc_object_t * ); static int OpenCommon( vlc_object_t *, bool b_packetizer );
static int OpenPacketizer( vlc_object_t * ); static void *DecodeBlock( decoder_t *, block_t ** );
static void CloseDecoder ( vlc_object_t * );
static void *DecodeBlock ( decoder_t *, block_t ** );
static inline int SyncCode( const uint8_t * ); static inline int SyncCode( const uint8_t * );
static int SyncInfo ( const uint8_t *, unsigned int *, unsigned int *, static int SyncInfo( const uint8_t *, unsigned int *, unsigned int *,
unsigned int *, unsigned int *, unsigned int * ); unsigned int *, unsigned int *, unsigned int * );
static uint8_t *GetOutBuffer ( decoder_t *, void ** ); static uint8_t *GetOutBuffer ( decoder_t *, void ** );
static aout_buffer_t *GetAoutBuffer( decoder_t * ); static aout_buffer_t *GetAoutBuffer( decoder_t * );
static block_t *GetSoutBuffer( decoder_t * ); static block_t *GetSoutBuffer( decoder_t * );
/***************************************************************************** /*****************************************************************************
* Module descriptor * OpenDecoder: probe the decoder
*****************************************************************************/ *****************************************************************************/
vlc_module_begin () static int OpenDecoder( vlc_object_t *p_this )
set_description( N_("DTS parser") ) {
set_capability( "decoder", 100 ) /* HACK: Don't use this codec if we don't have an dts audio filter */
set_callbacks( OpenDecoder, CloseDecoder ) if( !module_exists( "dtstofloat32" ) )
return VLC_EGENERIC;
add_submodule () return OpenCommon( p_this, false );
set_description( N_("DTS audio packetizer") ) }
set_capability( "packetizer", 10 )
set_callbacks( OpenPacketizer, CloseDecoder )
vlc_module_end ()
/***************************************************************************** /*****************************************************************************
* OpenDecoder: probe the decoder and return score * OpenPacketizer: probe the packetizer
*****************************************************************************/ *****************************************************************************/
static int OpenDecoder( vlc_object_t *p_this ) static int OpenPacketizer( vlc_object_t *p_this )
{
return OpenCommon( p_this, true );
}
/*****************************************************************************
* OpenCommon:
*****************************************************************************/
static int OpenCommon( vlc_object_t *p_this, bool b_packetizer )
{ {
decoder_t *p_dec = (decoder_t*)p_this; decoder_t *p_dec = (decoder_t*)p_this;
decoder_sys_t *p_sys; decoder_sys_t *p_sys;
if( p_dec->fmt_in.i_codec != VLC_FOURCC('d','t','s',' ') if( p_dec->fmt_in.i_codec != VLC_FOURCC('d','t','s',' ') &&
&& p_dec->fmt_in.i_codec != VLC_FOURCC('d','t','s','b') ) p_dec->fmt_in.i_codec != VLC_FOURCC('d','t','s','b') )
{ {
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* Allocate the memory needed to store the decoder's structure */ /* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys = if( ( p_dec->p_sys = p_sys = malloc(sizeof(*p_sys)) ) == NULL )
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
return VLC_ENOMEM; return VLC_ENOMEM;
/* Misc init */ /* Misc init */
p_sys->b_packetizer = false; p_sys->b_packetizer = b_packetizer;
p_sys->i_state = STATE_NOSYNC; p_sys->i_state = STATE_NOSYNC;
aout_DateSet( &p_sys->end_date, 0 ); aout_DateSet( &p_sys->end_date, 0 );
...@@ -147,21 +168,8 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -147,21 +168,8 @@ static int OpenDecoder( vlc_object_t *p_this )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int OpenPacketizer( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t*)p_this;
int i_ret = OpenDecoder( p_this );
if( i_ret == VLC_SUCCESS ) p_dec->p_sys->b_packetizer = true;
return i_ret;
}
/**************************************************************************** /****************************************************************************
* DecodeBlock: the whole thing * DecodeBlock: the whole thing
****************************************************************************
* This function is called just after the thread is launched.
****************************************************************************/ ****************************************************************************/
static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
{ {
...@@ -170,7 +178,8 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) ...@@ -170,7 +178,8 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
uint8_t *p_buf; uint8_t *p_buf;
void *p_out_buffer; void *p_out_buffer;
if( !pp_block || !*pp_block ) return NULL; if( !pp_block || !*pp_block )
return NULL;
if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) ) if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
{ {
...@@ -317,9 +326,9 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) ...@@ -317,9 +326,9 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
} }
/***************************************************************************** /*****************************************************************************
* CloseDecoder: clean up the decoder * CloseCommon: clean up the decoder
*****************************************************************************/ *****************************************************************************/
static void CloseDecoder( vlc_object_t *p_this ) static void CloseCommon( vlc_object_t *p_this )
{ {
decoder_t *p_dec = (decoder_t*)p_this; decoder_t *p_dec = (decoder_t*)p_this;
decoder_sys_t *p_sys = p_dec->p_sys; decoder_sys_t *p_sys = p_dec->p_sys;
......
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