1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-13 11:40:38 +02:00

fix error message

This commit is contained in:
Laserlicht 2023-10-08 02:37:54 +02:00
parent 3c647334b0
commit 39e06ea5e1

View File

@ -541,15 +541,22 @@ std::pair<std::unique_ptr<ui8 []>, si64> CVideoPlayer::getAudio(const VideoPath
while (av_read_frame(formatAudio, &packet) >= 0) while (av_read_frame(formatAudio, &packet) >= 0)
{ {
avcodec_send_packet(codecContextAudio, &packet); if(packet.stream_index == streamAudio)
avcodec_receive_frame(codecContextAudio, frameAudio);
for (int s = 0; s < frameAudio->linesize[0]; s+=sizeof(ui8))
{ {
ui8 value; int rc = avcodec_send_packet(codecContextAudio, &packet);
memcpy(&value, &frameAudio->data[0][s], sizeof(ui8)); if (rc >= 0)
samples.push_back(value); packet.size = 0;
rc = avcodec_receive_frame(codecContextAudio, frameAudio);
if (rc >= 0)
for (int s = 0; s < frameAudio->linesize[0]; s+=sizeof(ui8))
{
ui8 value;
memcpy(&value, &frameAudio->data[0][s], sizeof(ui8));
samples.push_back(value);
}
} }
av_packet_unref(&packet);
} }
typedef struct WAV_HEADER { typedef struct WAV_HEADER {