[vlc-devel] [RFC 05/38] codec/lpcm: remove usage of abort
Filip Roséen
filip at videolabs.io
Mon Jun 27 13:43:16 CEST 2016
This patch names the previously unnamed enum in order for the compiler
to be able to tell us if we have cases where an enumerator is not
handled.
Given that CommonOpen will set "p_sys->i_type" to one of the enumerators
in LPCM_type, or return VLC_EGENERIC, the value of "p_sys->i_type" will
always be handled in the switch.
As a fail-safe, the invocation of abort has been replaced by
vlc_assert_unreachable.
---
modules/codec/lpcm.c | 76 +++++++++++++++++++++++++++-------------------------
1 file changed, 39 insertions(+), 37 deletions(-)
diff --git a/modules/codec/lpcm.c b/modules/codec/lpcm.c
index a380252..de13c28 100644
--- a/modules/codec/lpcm.c
+++ b/modules/codec/lpcm.c
@@ -77,39 +77,6 @@ vlc_module_begin ()
vlc_module_end ()
-/*****************************************************************************
- * decoder_sys_t : lpcm decoder descriptor
- *****************************************************************************/
-struct decoder_sys_t
-{
- /* Module mode */
- bool b_packetizer;
-
- /*
- * Output properties
- */
- date_t end_date;
-
- /* */
- unsigned i_header_size;
- int i_type;
- uint8_t i_chans_to_reorder;
- uint8_t pi_chan_table[AOUT_CHAN_MAX];
-};
-
-#ifdef ENABLE_SOUT
-struct encoder_sys_t
-{
- int i_channels;
- int i_rate;
-
- int i_frame_samples;
- uint8_t *p_buffer;
- int i_buffer_used;
- int i_frame_num;
-};
-#endif
-
/*
* LPCM DVD header :
* - number of frames in this packet (8 bits)
@@ -160,13 +127,14 @@ struct encoder_sys_t
#define LPCM_BD_HEADER_LEN (4)
#define LPCM_WIDI_HEADER_LEN (4)
-enum
+typedef enum
{
LPCM_VOB,
LPCM_AOB,
LPCM_BD,
LPCM_WIDI,
-};
+
+} LPCM_type;
typedef struct
{
@@ -176,6 +144,40 @@ typedef struct
} aob_group_t;
/*****************************************************************************
+ * decoder_sys_t : lpcm decoder descriptor
+ *****************************************************************************/
+struct decoder_sys_t
+{
+ /* Module mode */
+ bool b_packetizer;
+
+ /*
+ * Output properties
+ */
+ date_t end_date;
+
+ /* */
+ unsigned i_header_size;
+ LPCM_type i_type;
+ uint8_t i_chans_to_reorder;
+ uint8_t pi_chan_table[AOUT_CHAN_MAX];
+};
+
+#ifdef ENABLE_SOUT
+struct encoder_sys_t
+{
+ int i_channels;
+ int i_rate;
+
+ int i_frame_samples;
+ uint8_t *p_buffer;
+ int i_buffer_used;
+ int i_frame_num;
+};
+#endif
+
+
+/*****************************************************************************
* Local prototypes
*****************************************************************************/
static block_t *DecodeFrame ( decoder_t *, block_t ** );
@@ -217,7 +219,7 @@ static int OpenCommon( vlc_object_t *p_this, bool b_packetizer )
{
decoder_t *p_dec = (decoder_t*)p_this;
decoder_sys_t *p_sys;
- int i_type;
+ LPCM_type i_type;
int i_header_size;
switch( p_dec->fmt_in.i_codec )
@@ -393,7 +395,7 @@ static block_t *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
p_block->p_buffer );
break;
default:
- abort();
+ vlc_assert_unreachable();
}
if( i_ret || p_block->i_buffer <= p_sys->i_header_size + i_padding )
--
2.9.0
More information about the vlc-devel
mailing list