|
|
@ -204,6 +204,7 @@ end: |
|
|
|
|
|
|
|
|
|
|
|
AUDIO_PLAYER_FUNC(void, play, jstring input_jstr, jstring filter_jstr) { |
|
|
|
AUDIO_PLAYER_FUNC(void, play, jstring input_jstr, jstring filter_jstr) { |
|
|
|
int got_frame = 0, ret = 0; |
|
|
|
int got_frame = 0, ret = 0; |
|
|
|
|
|
|
|
AVPacket packet; |
|
|
|
AVFilterGraph *audioFilterGraph; |
|
|
|
AVFilterGraph *audioFilterGraph; |
|
|
|
AVFilterContext *audioSrcContext; |
|
|
|
AVFilterContext *audioSrcContext; |
|
|
|
AVFilterContext *audioSinkContext; |
|
|
|
AVFilterContext *audioSinkContext; |
|
|
@ -238,7 +239,6 @@ AUDIO_PLAYER_FUNC(void, play, jstring input_jstr, jstring filter_jstr) { |
|
|
|
LOGE(TAG, "Couldn't open audio decoder"); |
|
|
|
LOGE(TAG, "Couldn't open audio decoder"); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
auto *packet = (AVPacket *) av_malloc(sizeof(AVPacket)); |
|
|
|
|
|
|
|
AVFrame *frame = av_frame_alloc(); |
|
|
|
AVFrame *frame = av_frame_alloc(); |
|
|
|
SwrContext *swrCtx = swr_alloc(); |
|
|
|
SwrContext *swrCtx = swr_alloc(); |
|
|
|
enum AVSampleFormat in_sample_fmt = codecCtx->sample_fmt; |
|
|
|
enum AVSampleFormat in_sample_fmt = codecCtx->sample_fmt; |
|
|
@ -286,9 +286,9 @@ AUDIO_PLAYER_FUNC(void, play, jstring input_jstr, jstring filter_jstr) { |
|
|
|
mVisualizer->init_visualizer(); |
|
|
|
mVisualizer->init_visualizer(); |
|
|
|
|
|
|
|
|
|
|
|
//read audio frame
|
|
|
|
//read audio frame
|
|
|
|
while (av_read_frame(pFormatCtx, packet) >= 0 && !filter_release) { |
|
|
|
while (av_read_frame(pFormatCtx, &packet) >= 0 && !filter_release) { |
|
|
|
if (packet->stream_index != audio_stream_idx) { |
|
|
|
if (packet.stream_index != audio_stream_idx) { |
|
|
|
av_packet_unref(packet); |
|
|
|
av_packet_unref(&packet); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
if (filter_again) { |
|
|
|
if (filter_again) { |
|
|
@ -300,7 +300,7 @@ AUDIO_PLAYER_FUNC(void, play, jstring input_jstr, jstring filter_jstr) { |
|
|
|
} |
|
|
|
} |
|
|
|
LOGE(TAG, "play again,filter_descr=_=%s", filter_desc); |
|
|
|
LOGE(TAG, "play again,filter_descr=_=%s", filter_desc); |
|
|
|
} |
|
|
|
} |
|
|
|
ret = avcodec_decode_audio4(codecCtx, frame, &got_frame, packet); |
|
|
|
ret = avcodec_decode_audio4(codecCtx, frame, &got_frame, &packet); |
|
|
|
if (ret < 0) { |
|
|
|
if (ret < 0) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -343,7 +343,7 @@ AUDIO_PLAYER_FUNC(void, play, jstring input_jstr, jstring filter_jstr) { |
|
|
|
usleep(SLEEP_TIME); |
|
|
|
usleep(SLEEP_TIME); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
av_packet_unref(packet); |
|
|
|
av_packet_unref(&packet); |
|
|
|
} |
|
|
|
} |
|
|
|
end: |
|
|
|
end: |
|
|
|
av_free(out_buffer); |
|
|
|
av_free(out_buffer); |
|
|
|