-#ifdef WORDS_BIGENDIAN
- static const u8 p_sync[6] = { 0xF8, 0x72, 0x4E, 0x1F, 0x00, 0x01 };
-#else
- static const u8 p_sync[6] = { 0x72, 0xF8, 0x1F, 0x4E, 0x01, 0x00 };
-# ifndef HAVE_SWAB
- u16 i;
-# endif
-#endif
- u16 i_length = p_in_buf->i_nb_samples;
- u16 * pi_length;
- byte_t * p_in = p_in_buf->p_buffer;
- byte_t * p_out = p_out_buf->p_buffer;
+ /* AC3 is natively big endian. Most SPDIF devices have the native
+ * endianness of the computer system.
+ * On Mac OS X however, little endian devices are also common.
+ */
+ static const uint8_t p_sync_le[6] = { 0x72, 0xF8, 0x1F, 0x4E, 0x01, 0x00 };
+ static const uint8_t p_sync_be[6] = { 0xF8, 0x72, 0x4E, 0x1F, 0x00, 0x01 };
+ uint16_t i_frame_size = p_in_buf->i_buffer / 2;
+ uint8_t * p_in = p_in_buf->p_buffer;
+
+ block_t *p_out_buf = filter_NewAudioBuffer( p_filter, AOUT_SPDIF_SIZE );
+ if( !p_out_buf )
+ goto out;
+ uint8_t * p_out = p_out_buf->p_buffer;