diff options
author | wm4 <wm4@nowhere> | 2013-12-21 23:15:32 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-12-21 23:15:32 +0100 |
commit | 0a3e9a9ac3a90da831b497e0613dfb66bc14f3d2 (patch) | |
tree | b70f214f8c3fc802d6d6edbf8395273c854ac0fd /audio/decode/ad_lavc.c | |
parent | a4fe95b0d8d339ba5afbdb5346ad8fd367a4a1c1 (diff) | |
parent | 245e5b844177e9ad9a9c07eff5efab7c3fccdebc (diff) | |
download | mpv-0a3e9a9ac3a90da831b497e0613dfb66bc14f3d2.tar.bz2 mpv-0a3e9a9ac3a90da831b497e0613dfb66bc14f3d2.tar.xz |
Merge branch 'msg_refactor'
This branch changes mp_msg() so that it doesn't require global context.
The changes are pretty violent.
Diffstat (limited to 'audio/decode/ad_lavc.c')
-rw-r--r-- | audio/decode/ad_lavc.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c index b2d1c879e9..b2f29505c2 100644 --- a/audio/decode/ad_lavc.c +++ b/audio/decode/ad_lavc.c @@ -137,14 +137,17 @@ static int setup_format(struct dec_audio *da) // Note: invalid parameters are rejected by dec_audio.c - mp_audio_set_format(&da->decoded, af_from_avformat(lavc_context->sample_fmt)); + int fmt = lavc_context->sample_fmt; + mp_audio_set_format(&da->decoded, af_from_avformat(fmt)); + if (!da->decoded.format) + MP_FATAL(da, "unsupported lavc format %s", av_get_sample_fmt_name(fmt)); da->decoded.rate = lavc_context->sample_rate; if (!da->decoded.rate && sh_audio->wf) { // If not set, try container samplerate. // (Maybe this can't happen, and it's an artifact from the past.) da->decoded.rate = sh_audio->wf->nSamplesPerSec; - mp_msg(MSGT_DECAUDIO, MSGL_WARN, "ad_lavc: using container rate.\n"); + MP_WARN(da, "using container rate.\n"); } struct mp_chmap lavc_chmap; @@ -198,8 +201,7 @@ static int init(struct dec_audio *da, const char *decoder) lavc_codec = avcodec_find_decoder_by_name(decoder); if (!lavc_codec) { - mp_msg(MSGT_DECAUDIO, MSGL_ERR, - "Cannot find codec '%s' in libavcodec...\n", decoder); + MP_ERR(da, "Cannot find codec '%s' in libavcodec...\n", decoder); uninit(da); return 0; } @@ -225,8 +227,7 @@ static int init(struct dec_audio *da, const char *decoder) if (opts->avopt) { if (parse_avopts(lavc_context, opts->avopt) < 0) { - mp_msg(MSGT_DECVIDEO, MSGL_ERR, - "ad_lavc: setting AVOptions '%s' failed.\n", opts->avopt); + MP_ERR(da, "setting AVOptions '%s' failed.\n", opts->avopt); uninit(da); return 0; } @@ -257,24 +258,22 @@ static int init(struct dec_audio *da, const char *decoder) /* open it */ if (avcodec_open2(lavc_context, lavc_codec, NULL) < 0) { - mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Could not open codec.\n"); + MP_ERR(da, "Could not open codec.\n"); uninit(da); return 0; } - mp_msg(MSGT_DECAUDIO, MSGL_V, "INFO: libavcodec \"%s\" init OK!\n", + MP_VERBOSE(da, "INFO: libavcodec \"%s\" init OK!\n", lavc_codec->name); // Decode at least 1 sample: (to get header filled) for (int tries = 1; ; tries++) { int x = decode_new_packet(da); if (x >= 0 && ctx->frame.samples > 0) { - mp_msg(MSGT_DECAUDIO, MSGL_V, - "Initial decode succeeded after %d packets.\n", tries); + MP_VERBOSE(da, "Initial decode succeeded after %d packets.\n", tries); break; } if (tries >= 50) { - mp_msg(MSGT_DECAUDIO, MSGL_ERR, - "ad_lavc: initial decode failed\n"); + MP_ERR(da, "initial decode failed\n"); uninit(da); return 0; } @@ -296,7 +295,7 @@ static void uninit(struct dec_audio *da) if (lavc_context) { if (avcodec_close(lavc_context) < 0) - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Could not close codec.\n"); + MP_ERR(da, "Could not close codec.\n"); av_freep(&lavc_context->extradata); av_freep(&lavc_context); } @@ -361,7 +360,7 @@ static int decode_new_packet(struct dec_audio *da) return 0; } if (ret < 0) { - mp_msg(MSGT_DECAUDIO, MSGL_V, "lavc_audio: error\n"); + MP_VERBOSE(da, "lavc_audio: error\n"); return -1; } if (!got_frame) @@ -381,7 +380,7 @@ static int decode_new_packet(struct dec_audio *da) da->pts_offset = 0; } - mp_msg(MSGT_DECAUDIO, MSGL_DBG2, "Decoded %d -> %d samples\n", in_len, + MP_DBG(da, "Decoded %d -> %d samples\n", in_len, priv->frame.samples); return 0; } |