@@ -114,6 +114,7 @@ struct aout_sys_t {
114
114
} smoothpos ;
115
115
116
116
uint32_t i_bytes_per_frame ; /* byte per frame */
117
+ uint32_t i_frame_length ; /* frame length */
117
118
uint32_t i_max_audiotrack_samples ;
118
119
bool b_spdif ;
119
120
uint8_t i_chans_to_reorder ; /* do we need channel reordering */
@@ -461,21 +462,15 @@ frames_to_us( aout_sys_t *p_sys, uint64_t i_nb_frames )
461
462
static inline uint64_t
462
463
bytes_to_frames ( aout_sys_t * p_sys , size_t i_bytes )
463
464
{
464
- if ( p_sys -> b_spdif )
465
- return i_bytes * A52_FRAME_NB / p_sys -> i_bytes_per_frame ;
466
- else
467
- return i_bytes / p_sys -> i_bytes_per_frame ;
465
+ return i_bytes * p_sys -> i_frame_length / p_sys -> i_bytes_per_frame ;
468
466
}
469
467
#define BYTES_TO_FRAMES (x ) bytes_to_frames( p_sys, (x) )
470
468
#define BYTES_TO_US (x ) frames_to_us( p_sys, bytes_to_frames( p_sys, (x) ) )
471
469
472
470
static inline size_t
473
471
frames_to_bytes ( aout_sys_t * p_sys , uint64_t i_frames )
474
472
{
475
- if ( p_sys -> b_spdif )
476
- return i_frames * p_sys -> i_bytes_per_frame / A52_FRAME_NB ;
477
- else
478
- return i_frames * p_sys -> i_bytes_per_frame ;
473
+ return i_frames * p_sys -> i_bytes_per_frame / p_sys -> i_frame_length ;
479
474
}
480
475
#define FRAMES_TO_BYTES (x ) frames_to_bytes( p_sys, (x) )
481
476
@@ -881,10 +876,7 @@ AudioTrack_Create( JNIEnv *env, audio_output_t *p_aout,
881
876
msg_Warn ( p_aout , "getMinBufferSize returned an invalid size" ) ;
882
877
return -1 ;
883
878
}
884
- if ( i_vlc_format == VLC_CODEC_SPDIFB )
885
- i_size = ( i_min_buffer_size / AOUT_SPDIF_SIZE + 1 ) * AOUT_SPDIF_SIZE ;
886
- else
887
- i_size = i_min_buffer_size * 2 ;
879
+ i_size = i_min_buffer_size * 2 ;
888
880
889
881
/* create AudioTrack object */
890
882
if ( AudioTrack_New ( env , p_aout , i_rate , i_channel_config ,
@@ -904,8 +896,7 @@ Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt )
904
896
{
905
897
aout_sys_t * p_sys = p_aout -> sys ;
906
898
JNIEnv * env ;
907
- int i_nb_channels , i_max_channels , i_bytes_per_frame , i_native_rate = 0 ,
908
- i_ret ;
899
+ int i_nb_channels , i_max_channels , i_native_rate = 0 , i_ret ;
909
900
unsigned int i_rate ;
910
901
bool b_spdif ;
911
902
@@ -989,8 +980,6 @@ Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt )
989
980
do
990
981
{
991
982
i_nb_channels = aout_FormatNbChannels ( & p_sys -> fmt );
992
- i_bytes_per_frame = i_nb_channels *
993
- aout_BitsPerSample ( p_sys -> fmt .i_format ) / 8 ;
994
983
i_rate = p_sys -> fmt .i_format == VLC_CODEC_SPDIFB ?
995
984
VLC_CLIP ( p_sys -> fmt .i_rate , 32000 , 48000 )
996
985
: (unsigned int ) i_native_rate ;
@@ -1036,9 +1025,10 @@ Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt )
1036
1025
p_sys -> b_spdif = p_sys -> fmt .i_format == VLC_CODEC_SPDIFB ;
1037
1026
if ( p_sys -> b_spdif )
1038
1027
{
1028
+ p_sys -> i_bytes_per_frame =
1039
1029
p_sys -> fmt .i_bytes_per_frame = AOUT_SPDIF_SIZE ;
1030
+ p_sys -> i_frame_length =
1040
1031
p_sys -> fmt .i_frame_length = A52_FRAME_NB ;
1041
- p_sys -> i_bytes_per_frame = p_sys -> fmt .i_bytes_per_frame ;
1042
1032
}
1043
1033
else
1044
1034
{
@@ -1050,7 +1040,10 @@ Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt )
1050
1040
aout_CheckChannelReorder ( NULL , p_chans_out ,
1051
1041
p_sys -> fmt .i_physical_channels ,
1052
1042
p_sys -> p_chan_table );
1053
- p_sys -> i_bytes_per_frame = i_bytes_per_frame ;
1043
+ p_sys -> i_bytes_per_frame = i_nb_channels
1044
+ * aout_BitsPerSample ( p_sys -> fmt .i_format )
1045
+ / 8 ;
1046
+ p_sys -> i_frame_length = 1 ;
1054
1047
}
1055
1048
p_sys -> i_max_audiotrack_samples = BYTES_TO_FRAMES ( p_sys -> audiotrack_args .i_size );
1056
1049
@@ -1091,7 +1084,9 @@ Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt )
1091
1084
p_sys -> circular .i_read = p_sys -> circular .i_write = 0 ;
1092
1085
/* 2 seconds of buffering */
1093
1086
p_sys -> circular .i_size = (int )i_rate * AOUT_MAX_PREPARE_TIME
1094
- * i_bytes_per_frame / CLOCK_FREQ ;
1087
+ * p_sys -> i_bytes_per_frame
1088
+ / p_sys -> i_frame_length
1089
+ / CLOCK_FREQ ;
1095
1090
1096
1091
/* Allocate circular buffer */
1097
1092
switch ( p_sys -> i_write_type )
0 commit comments