@@ -1543,12 +1543,21 @@ static int player_set_data_source(State *state, const char *file_path,
1543
1543
player -> stream_indexs [AVMEDIA_TYPE_AUDIO ], -1 , NULL , 0 );
1544
1544
1545
1545
if (st_index [AVMEDIA_TYPE_AUDIO ] >= 0 ) {
1546
- err = stream_component_open (player , st_index [AVMEDIA_TYPE_AUDIO ]);
1547
- if (err < 0 )
1548
- goto error ;
1549
- err = player_create_audio_track (player , state );
1550
- if (err < 0 )
1551
- goto error ;
1546
+ AVCodecContext * avctx = ic -> streams [st_index [AVMEDIA_TYPE_AUDIO ]]-> codec ;
1547
+ if (avctx -> sample_rate > 0 && avctx -> channels > 0 ) {
1548
+ LOGI (3 , "player_set_data_source open audio" );
1549
+ err = stream_component_open (player , st_index [AVMEDIA_TYPE_AUDIO ]);
1550
+ if (err < 0 )
1551
+ goto error ;
1552
+
1553
+ err = player_create_audio_track (player , state );
1554
+ if (err < 0 )
1555
+ goto error ;
1556
+ } else {
1557
+ LOGI (3 , "player_set_data_source: audio sample rate or channels are not recognized" );
1558
+ // Note: we try to ignore the un-recognized audio stream
1559
+ player -> stream_indexs [AVMEDIA_TYPE_AUDIO ] = -1 ;
1560
+ }
1552
1561
}
1553
1562
if (st_index [AVMEDIA_TYPE_VIDEO ] >= 0 ) {
1554
1563
err = stream_component_open (player , st_index [AVMEDIA_TYPE_VIDEO ]);
@@ -1804,6 +1813,9 @@ void jni_player_dealloc(JNIEnv *env, jobject thiz) {
1804
1813
}
1805
1814
pthread_mutex_unlock (& player -> mutex_operation );
1806
1815
LOGI (1 , "jni_player_dealloc: render stopped..." );
1816
+ pthread_mutex_destroy (& player -> mutex_operation );
1817
+ pthread_mutex_destroy (& player -> mutex_queue );
1818
+ pthread_cond_destroy (& player -> cond_queue );
1807
1819
free (player );
1808
1820
LOGI (1 , "jni_player_dealloc: bye bye" );
1809
1821
}
0 commit comments