@@ -1037,18 +1037,41 @@ static void DecoderProcessVideo( decoder_t *p_dec, block_t *p_block )
1037
1037
}
1038
1038
}
1039
1039
1040
- static void DecoderPlayAudio ( decoder_t * p_dec , block_t * p_audio ,
1041
- int * pi_played_sum , int * pi_lost_sum )
1040
+ static int DecoderPlayAudio ( decoder_t * p_dec , block_t * p_audio ,
1041
+ int * pi_played_sum , int * pi_lost_sum )
1042
1042
{
1043
1043
decoder_owner_sys_t * p_owner = p_dec -> p_owner ;
1044
+ bool prerolled ;
1045
+
1046
+ assert ( p_audio != NULL );
1047
+
1048
+ vlc_mutex_lock ( & p_owner -> lock );
1049
+ if ( p_owner -> i_preroll_end > p_audio -> i_pts )
1050
+ {
1051
+ vlc_mutex_unlock ( & p_owner -> lock );
1052
+ block_Release ( p_audio );
1053
+ return -1 ;
1054
+ }
1055
+
1056
+ prerolled = p_owner -> i_preroll_end > INT64_MIN ;
1057
+ p_owner -> i_preroll_end = INT64_MIN ;
1058
+ vlc_mutex_unlock ( & p_owner -> lock );
1059
+
1060
+ if ( unlikely (prerolled ) )
1061
+ {
1062
+ msg_Dbg ( p_dec , "end of audio preroll" );
1063
+
1064
+ if ( p_owner -> p_aout )
1065
+ aout_DecFlush ( p_owner -> p_aout , false );
1066
+ }
1044
1067
1045
1068
/* */
1046
1069
if ( p_audio -> i_pts <= VLC_TS_INVALID ) // FIXME --VLC_TS_INVALID verify audio_output/*
1047
1070
{
1048
1071
msg_Warn ( p_dec , "non-dated audio buffer received" );
1049
1072
* pi_lost_sum += 1 ;
1050
1073
block_Release ( p_audio );
1051
- return ;
1074
+ return 0 ;
1052
1075
}
1053
1076
1054
1077
/* */
@@ -1077,40 +1100,13 @@ static void DecoderPlayAudio( decoder_t *p_dec, block_t *p_audio,
1077
1100
msg_Dbg ( p_dec , "discarded audio buffer" );
1078
1101
* pi_lost_sum += 1 ;
1079
1102
block_Release ( p_audio );
1080
- return ;
1103
+ return 0 ;
1081
1104
}
1082
1105
1083
1106
if ( aout_DecPlay ( p_aout , p_audio , i_rate ) == 0 )
1084
1107
* pi_played_sum += 1 ;
1085
1108
1086
1109
* pi_lost_sum += aout_DecGetResetLost ( p_aout );
1087
- }
1088
-
1089
- static int DecoderPreparePlayAudio ( decoder_t * p_dec , block_t * p_aout_buf )
1090
- {
1091
- decoder_owner_sys_t * p_owner = p_dec -> p_owner ;
1092
- bool prerolled ;
1093
-
1094
- vlc_mutex_lock ( & p_owner -> lock );
1095
- if ( p_owner -> i_preroll_end > p_aout_buf -> i_pts )
1096
- {
1097
- vlc_mutex_unlock ( & p_owner -> lock );
1098
- block_Release ( p_aout_buf );
1099
- return -1 ;
1100
- }
1101
-
1102
- prerolled = p_owner -> i_preroll_end > INT64_MIN ;
1103
- p_owner -> i_preroll_end = INT64_MIN ;
1104
- vlc_mutex_unlock ( & p_owner -> lock );
1105
-
1106
- if ( unlikely (prerolled ) )
1107
- {
1108
- msg_Dbg ( p_dec , "end of audio preroll" );
1109
-
1110
- if ( p_owner -> p_aout )
1111
- aout_DecFlush ( p_owner -> p_aout , false );
1112
- }
1113
-
1114
1110
return 0 ;
1115
1111
}
1116
1112
@@ -1133,17 +1129,14 @@ static void DecoderUpdateStatAudio( decoder_t *p_dec, int i_decoded,
1133
1129
1134
1130
static int DecoderQueueAudio ( decoder_t * p_dec , block_t * p_aout_buf )
1135
1131
{
1136
- assert ( p_aout_buf );
1137
1132
int i_lost = 0 ;
1138
1133
int i_played = 0 ;
1139
- int i_ret ;
1140
1134
1141
- if ( ( i_ret = DecoderPreparePlayAudio ( p_dec , p_aout_buf ) ) == 0 )
1142
- DecoderPlayAudio ( p_dec , p_aout_buf , & i_played , & i_lost );
1135
+ int ret = DecoderPlayAudio ( p_dec , p_aout_buf , & i_played , & i_lost );
1143
1136
1144
1137
DecoderUpdateStatAudio ( p_dec , 1 , i_lost , i_played );
1145
1138
1146
- return i_ret ;
1139
+ return ret ;
1147
1140
}
1148
1141
1149
1142
static void DecoderDecodeAudio ( decoder_t * p_dec , block_t * p_block )
@@ -1158,9 +1151,6 @@ static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
1158
1151
{
1159
1152
i_decoded ++ ;
1160
1153
1161
- if ( DecoderPreparePlayAudio ( p_dec , p_aout_buf ) != 0 )
1162
- continue ;
1163
-
1164
1154
DecoderPlayAudio ( p_dec , p_aout_buf , & i_played , & i_lost );
1165
1155
}
1166
1156
0 commit comments