Last active
December 11, 2015 06:14
-
-
Save tmm1/868e6f9de5ed7423389a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From: Aman <aman@tmm1.net> | |
Date: Fri Aug 10 16:02:07 2012 +0200 | |
Subject: enable ac3 passthru in audiounit_ios | |
--- | |
diff --git a/extras/package/ios/build.sh b/extras/package/ios/build.sh | |
index c2a1462..3070c02 100755 | |
--- a/extras/package/ios/build.sh | |
+++ b/extras/package/ios/build.sh | |
@@ -453,7 +453,6 @@ speex_resampler | |
remoteosd | |
magnify | |
gradient | |
-tospdif | |
dtstofloat32 | |
logger | |
visual | |
diff --git a/modules/audio_output/audiounit_ios.m b/modules/audio_output/audiounit_ios.m | |
index cee8eab..1ffb71e 100644 | |
--- a/modules/audio_output/audiounit_ios.m | |
+++ b/modules/audio_output/audiounit_ios.m | |
@@ -201,16 +201,34 @@ static int StartAnalog(audio_output_t *p_aout, audio_sample_format_t *fmt) | |
if (status != noErr) | |
msg_Warn(p_aout, "failed to set IO mode (%i)", (int)status); | |
+ AVAudioSession *instance = [AVAudioSession sharedInstance]; | |
+ | |
/* Get the current format */ | |
AudioStreamBasicDescription streamDescription; | |
streamDescription.mSampleRate = fmt->i_rate; | |
- fmt->i_format = VLC_CODEC_FL32; | |
- fmt->i_physical_channels = fmt->i_original_channels = AOUT_CHANS_STEREO; | |
streamDescription.mFormatID = kAudioFormatLinearPCM; | |
- streamDescription.mFormatFlags = kAudioFormatFlagsNativeFloatPacked; // FL32 | |
- streamDescription.mChannelsPerFrame = aout_FormatNbChannels(fmt); | |
- streamDescription.mFramesPerPacket = 1; | |
- streamDescription.mBitsPerChannel = 32; | |
+ | |
+ if (AOUT_FMT_SPDIF(fmt) && var_InheritBool(p_aout, "spdif")) { | |
+ // request spdif | |
+ fmt->i_format = VLC_CODEC_SPDIFL; | |
+ fmt->i_bytes_per_frame = AOUT_SPDIF_SIZE; | |
+ fmt->i_frame_length = A52_FRAME_NB; | |
+ | |
+ streamDescription.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked; // S16LE | |
+ streamDescription.mChannelsPerFrame = 2; | |
+ streamDescription.mFramesPerPacket = 1; | |
+ streamDescription.mBitsPerChannel = 16; | |
+ } else { | |
+ // request fl32 pcm | |
+ fmt->i_format = VLC_CODEC_FL32; | |
+ fmt->i_physical_channels = fmt->i_original_channels = AOUT_CHANS_STEREO; | |
+ | |
+ streamDescription.mFormatFlags = kAudioFormatFlagsNativeFloatPacked; // FL32 | |
+ streamDescription.mChannelsPerFrame = aout_FormatNbChannels(fmt); | |
+ streamDescription.mFramesPerPacket = 1; | |
+ streamDescription.mBitsPerChannel = 32; | |
+ } | |
+ | |
streamDescription.mBytesPerFrame = streamDescription.mBitsPerChannel * streamDescription.mChannelsPerFrame / 8; | |
streamDescription.mBytesPerPacket = streamDescription.mBytesPerFrame * streamDescription.mFramesPerPacket; | |
i_param_size = sizeof(streamDescription); | |
@@ -265,10 +283,11 @@ static int StartAnalog(audio_output_t *p_aout, audio_sample_format_t *fmt) | |
} | |
/* setup circular buffer */ | |
- TPCircularBufferInit(&p_sys->circular_buffer, AUDIO_BUFFER_SIZE_IN_SECONDS * fmt->i_rate * fmt->i_bytes_per_frame); | |
- | |
- /* start audio session so playback continues if mute switch is on */ | |
- AVAudioSession *instance = [AVAudioSession sharedInstance]; | |
+ if (fmt->i_format == VLC_CODEC_SPDIFL) { | |
+ TPCircularBufferInit(&p_sys->circular_buffer, 200 * AOUT_SPDIF_SIZE); | |
+ } else { | |
+ TPCircularBufferInit(&p_sys->circular_buffer, AUDIO_BUFFER_SIZE_IN_SECONDS * fmt->i_rate * fmt->i_bytes_per_frame); | |
+ } | |
/* Set audio session to mediaplayback */ | |
NSError *error = nil; | |
diff --git a/modules/codec/a52.c b/modules/codec/a52.c | |
index 7450d6b..7ee1cce 100644 | |
--- a/modules/codec/a52.c | |
+++ b/modules/codec/a52.c | |
@@ -150,7 +150,7 @@ static int OpenCommon( vlc_object_t *p_this, bool b_packetizer ) | |
static int OpenDecoder( vlc_object_t *p_this ) | |
{ | |
/* HACK: Don't use this codec if we don't have an a52 audio filter */ | |
- if( !module_exists( "a52tofloat32" ) ) | |
+ if( !module_exists( "a52tofloat32" ) && !(module_exists("a52tospdif") && var_InheritBool(p_this, "spdif")) ) | |
return VLC_EGENERIC; | |
return OpenCommon( p_this, false ); | |
} | |
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h | |
index 9c17963..56d5dd3 100644 | |
--- a/include/vlc/libvlc_media_player.h | |
+++ b/include/vlc/libvlc_media_player.h | |
@@ -1885,6 +1885,16 @@ LIBVLC_API int64_t libvlc_audio_get_delay( libvlc_media_player_t *p_mi ); | |
LIBVLC_API int libvlc_audio_set_delay( libvlc_media_player_t *p_mi, int64_t i_delay ); | |
/** | |
+ * Set audio spdif mode. | |
+ * | |
+ * \param p_mi media player | |
+ * \param enabled the spdif state | |
+ * \return 0 on success, -1 on error | |
+ * \version LibVLC 2.x.x or later | |
+ */ | |
+LIBVLC_API int libvlc_audio_set_spdif( libvlc_media_player_t *p_mi, bool enabled ); | |
+ | |
+/** | |
* Get the number of equalizer presets. | |
* | |
* \return number of presets | |
diff --git a/lib/audio.c b/lib/audio.c | |
index 7901c64..3877311 100644 | |
--- a/lib/audio.c | |
+++ b/lib/audio.c | |
@@ -472,6 +472,22 @@ int libvlc_audio_set_channel( libvlc_media_player_t *mp, int channel ) | |
} | |
/***************************************************************************** | |
+ * libvlc_audio_set_spdif : Enable/disable spdif mode | |
+ *****************************************************************************/ | |
+int libvlc_audio_set_spdif( libvlc_media_player_t *p_mi, bool enabled ) | |
+{ | |
+ int ret = 0; | |
+ | |
+ if( var_SetBool( p_mi, "spdif", enabled ) < 0 ) | |
+ { | |
+ libvlc_printerr( "Error setting 'spdif'" ); | |
+ ret = -1; | |
+ } | |
+ | |
+ return ret; | |
+} | |
+ | |
+/***************************************************************************** | |
* libvlc_audio_get_delay : Get the current audio delay | |
*****************************************************************************/ | |
int64_t libvlc_audio_get_delay( libvlc_media_player_t *p_mi ) | |
diff --git a/lib/media_player.c b/lib/media_player.c | |
index 880bbe0..d24bf44 100644 | |
--- a/lib/media_player.c | |
+++ b/lib/media_player.c | |
@@ -598,6 +598,7 @@ libvlc_media_player_new( libvlc_instance_t *instance ) | |
var_Create (mp, "zoom", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT); | |
var_Create (mp, "aspect-ratio", VLC_VAR_STRING); | |
var_Create (mp, "crop", VLC_VAR_STRING); | |
+ var_Create (mp, "spdif", VLC_VAR_BOOL | VLC_VAR_DOINHERIT); | |
var_Create (mp, "deinterlace", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); | |
var_Create (mp, "deinterlace-mode", VLC_VAR_STRING); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Headers/Public/VLCMediaPlayer.h b/Headers/Public/VLCMediaPlayer.h | |
index 85c7e46..d484d61 100644 | |
--- a/Headers/Public/VLCMediaPlayer.h | |
+++ b/Headers/Public/VLCMediaPlayer.h | |
@@ -392,6 +392,8 @@ extern NSString *const VLCTitleDescriptionIsMenu; | |
/* Audio Options */ | |
+- (void)setSPDIF:(BOOL)value; | |
+ | |
/** | |
* Return the current audio track index | |
* | |
diff --git a/Sources/VLCMediaPlayer.m b/Sources/VLCMediaPlayer.m | |
index 21ad9ed..402e65a 100644 | |
--- a/Sources/VLCMediaPlayer.m | |
+++ b/Sources/VLCMediaPlayer.m | |
@@ -839,6 +839,14 @@ static void HandleMediaPlayerSnapshot(const libvlc_event_t * event, void * self) | |
} | |
#pragma mark - | |
+#pragma mark S/PDIF | |
+ | |
+- (void)setSPDIF:(BOOL)value | |
+{ | |
+ libvlc_audio_set_spdif(_playerInstance, value); | |
+} | |
+ | |
+#pragma mark - | |
#pragma mark Audio tracks | |
- (void)setCurrentAudioTrackIndex:(int)value | |
{ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment