Lavc aud.: print error when open fails

This commit is contained in:
Martin Pulec
2020-09-09 09:13:20 +02:00
parent f4ac558bcf
commit 8ea7ab09b5

View File

@@ -329,8 +329,10 @@ static bool reinitialize_coder(struct libavcodec_codec_state *s, struct audio_de
pthread_mutex_lock(s->libav_global_lock);
/* open it */
if (avcodec_open2(s->codec_ctx, s->codec, NULL) < 0) {
fprintf(stderr, "Could not open codec\n");
if (int ret = 0; (ret = avcodec_open2(s->codec_ctx, s->codec, nullptr)) < 0) {
array<char, ERR_MSG_BUF_LEN> errbuf{};
av_strerror(ret, errbuf.data(), errbuf.size());
LOG(LOG_LEVEL_ERROR) << MOD_NAME << "Could not open codec: " << errbuf.data() << "(" << ret << ")\n";
pthread_mutex_unlock(s->libav_global_lock);
return false;
}