[vlc-commits] audiotrack: fix passthrough on Android API 23
Thomas Guillem
git at videolan.org
Fri Feb 8 13:42:12 CET 2019
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Feb 8 13:26:45 2019 +0100| [70acd1f7de867a9fb8a9460b9592ab04529cef68] | committer: Thomas Guillem
audiotrack: fix passthrough on Android API 23
This commit fixes passthrough playback for few devices on API 23. It was
working already for Nvidia Shield TV but not for some others (like devices
based on a Marvell chip).
Before API 23, we don't support passthrough and after we prefer to use
ENCODING_IEC61937.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=70acd1f7de867a9fb8a9460b9592ab04529cef68
---
modules/audio_output/audiotrack.c | 47 +++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/modules/audio_output/audiotrack.c b/modules/audio_output/audiotrack.c
index 8aef4aecfe..00acd7b9d2 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -1878,6 +1878,46 @@ AudioTrack_Thread( void *p_data )
return NULL;
}
+static int
+ConvertFromIEC61937( audio_output_t *p_aout, block_t *p_buffer )
+{
+ /* This function is only used for Android API 23 when AudioTrack is
+ * configured with ENCODING_ AC3/E_AC3/DTS. In that case, only the codec
+ * data is needed (without the IEC61937 encapsulation). This function
+ * recovers the codec data from an EC61937 frame. It is the opposite of the
+ * code found in converter/tospdif.c. We could also request VLC core to
+ * send us the codec data directly, but in that case, we wouldn't benefit
+ * from the eac3 block merger of tospdif.c. */
+
+ VLC_UNUSED( p_aout );
+ uint8_t i_length_mul;
+
+ switch( GetWBE( &p_buffer->p_buffer[4] ) & 0xFF )
+ {
+ case 0x01: /* IEC61937_AC3 */
+ i_length_mul = 8;
+ break;
+ case 0x15: /* IEC61937_EAC3 */
+ i_length_mul = 1;
+ break;
+ case 0x0B: /* IEC61937_DTS1 */
+ case 0x0C: /* IEC61937_DTS2 */
+ case 0x0D: /* IEC61937_DTS3 */
+ case 0x11: /* IEC61937_DTSHD */
+ i_length_mul = 8;
+ break;
+ default:
+ vlc_assert_unreachable();
+ }
+ uint16_t i_length = GetWBE( &p_buffer->p_buffer[6] );
+ if( i_length == 0 )
+ return -1;
+ p_buffer->p_buffer += 8; /* SPDIF_HEADER_SIZE */
+ p_buffer->i_buffer = i_length / i_length_mul;
+
+ return 0;
+}
+
static void
Play( audio_output_t *p_aout, block_t *p_buffer, vlc_tick_t i_date )
{
@@ -1885,6 +1925,13 @@ Play( audio_output_t *p_aout, block_t *p_buffer, vlc_tick_t i_date )
size_t i_buffer_offset = 0;
aout_sys_t *p_sys = p_aout->sys;
+ if( p_sys->b_passthrough && !jfields.AudioFormat.has_ENCODING_IEC61937
+ && ConvertFromIEC61937( p_aout, p_buffer ) != 0 )
+ {
+ block_Release(p_buffer);
+ return;
+ }
+
vlc_mutex_lock( &p_sys->lock );
if( p_sys->b_error || !( env = GET_ENV() ) )
More information about the vlc-commits
mailing list