summaryrefslogtreecommitdiffstats
path: root/audio/decode
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-21 18:23:59 +0100
committerwm4 <wm4@nowhere>2013-12-21 20:50:12 +0100
commit1974c9b49d7bf09469362ef6ba1214f625ecb40a (patch)
treed670f2a12652f2f98531905e388f1290ebbee126 /audio/decode
parent4abe6b862f07d4d2dfa75791c9fdd97ccbc8aeaa (diff)
downloadmpv-1974c9b49d7bf09469362ef6ba1214f625ecb40a.tar.bz2
mpv-1974c9b49d7bf09469362ef6ba1214f625ecb40a.tar.xz
audio: mp_msg conversions
Diffstat (limited to 'audio/decode')
-rw-r--r--audio/decode/ad_lavc.c24
-rw-r--r--audio/decode/ad_mpg123.c16
-rw-r--r--audio/decode/ad_spdif.c9
-rw-r--r--audio/decode/dec_audio.c40
-rw-r--r--audio/decode/dec_audio.h2
5 files changed, 42 insertions, 49 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index b2d1c879e9..5f73002d14 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -144,7 +144,7 @@ static int setup_format(struct dec_audio *da)
// 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 +198,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 +224,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 +255,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 +292,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 +357,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 +377,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;
}
diff --git a/audio/decode/ad_mpg123.c b/audio/decode/ad_mpg123.c
index 57f84e136f..4d4fd52862 100644
--- a/audio/decode/ad_mpg123.c
+++ b/audio/decode/ad_mpg123.c
@@ -115,10 +115,10 @@ static int preinit(struct dec_audio *da)
bad_end:
if (!con->handle)
- mp_msg(MSGT_DECAUDIO, MSGL_ERR, "mpg123 preinit error: %s\n",
+ MP_ERR(da, "mpg123 preinit error: %s\n",
mpg123_plain_strerror(err));
else
- mp_msg(MSGT_DECAUDIO, MSGL_ERR, "mpg123 preinit error: %s\n",
+ MP_ERR(da, "mpg123 preinit error: %s\n",
mpg123_strerror(con->handle));
uninit(da);
@@ -156,8 +156,7 @@ static int set_format(struct dec_audio *da)
int af = mpg123_format_to_af(encoding);
if (!af) {
/* This means we got a funny custom build of libmpg123 that only supports an unknown format. */
- mp_msg(MSGT_DECAUDIO, MSGL_ERR,
- "Bad encoding from mpg123: %i.\n", encoding);
+ MP_ERR(da, "Bad encoding from mpg123: %i.\n", encoding);
return MPG123_ERR;
}
mp_audio_set_format(&da->decoded, af);
@@ -236,9 +235,9 @@ static int init(struct dec_audio *da, const char *decoder)
fail:
if (ret == MPG123_NEED_MORE) {
- mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Could not find mp3 stream.\n");
+ MP_ERR(da, "Could not find mp3 stream.\n");
} else {
- mp_msg(MSGT_DECAUDIO, MSGL_ERR, "mpg123 init error: %s\n",
+ MP_ERR(da, "mpg123 init error: %s\n",
mpg123_strerror(con->handle));
}
@@ -337,7 +336,7 @@ static int decode_audio(struct dec_audio *da, struct mp_audio *buffer, int maxle
return 0;
mpg123_fail:
- mp_msg(MSGT_DECAUDIO, MSGL_ERR, "mpg123 decoding error: %s\n",
+ MP_ERR(da, "mpg123 decoding error: %s\n",
mpg123_strerror(con->handle));
return -1;
}
@@ -351,8 +350,7 @@ static int control(struct dec_audio *da, int cmd, void *arg)
mpg123_close(con->handle);
if (mpg123_open_feed(con->handle) != MPG123_OK) {
- mp_msg(MSGT_DECAUDIO, MSGL_ERR,
- "mpg123 failed to reopen stream: %s\n",
+ MP_ERR(da, "mpg123 failed to reopen stream: %s\n",
mpg123_strerror(con->handle));
return CONTROL_FALSE;
}
diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c
index 5532d6b5a8..c055715a32 100644
--- a/audio/decode/ad_spdif.c
+++ b/audio/decode/ad_spdif.c
@@ -34,6 +34,7 @@
#define OUTBUF_SIZE 65536
struct spdifContext {
+ struct mp_log *log;
AVFormatContext *lavf_ctx;
int iec61937_packet_size;
int out_buffer_len;
@@ -48,7 +49,7 @@ static int write_packet(void *p, uint8_t *buf, int buf_size)
int buffer_left = ctx->out_buffer_size - ctx->out_buffer_len;
if (buf_size > buffer_left) {
- mp_msg(MSGT_DECAUDIO, MSGL_ERR, "spdif packet too large.\n");
+ MP_ERR(ctx, "spdif packet too large.\n");
buf_size = buffer_left;
}
@@ -76,6 +77,7 @@ static int init(struct dec_audio *da, const char *decoder)
{
struct spdifContext *spdif_ctx = talloc_zero(NULL, struct spdifContext);
da->priv = spdif_ctx;
+ spdif_ctx->log = da->log;
AVFormatContext *lavf_ctx = avformat_alloc_context();
if (!lavf_ctx)
@@ -166,8 +168,7 @@ static int init(struct dec_audio *da, const char *decoder)
da->decoded.rate = samplerate;
if (avformat_write_header(lavf_ctx, &format_opts) < 0) {
- mp_msg(MSGT_DECAUDIO, MSGL_FATAL,
- "libavformat spdif initialization failed.\n");
+ MP_FATAL(da, "libavformat spdif initialization failed.\n");
av_dict_free(&format_opts);
goto fail;
}
@@ -204,7 +205,7 @@ static int decode_audio(struct dec_audio *da, struct mp_audio *buffer, int maxle
AVPacket pkt;
mp_set_av_packet(&pkt, mpkt, NULL);
pkt.pts = pkt.dts = 0;
- mp_msg(MSGT_DECAUDIO, MSGL_V, "spdif packet, size=%d\n", pkt.size);
+ MP_VERBOSE(da, "spdif packet, size=%d\n", pkt.size);
if (mpkt->pts != MP_NOPTS_VALUE) {
da->pts = mpkt->pts;
da->pts_offset = 0;
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c
index 51966a7cc6..ae3c72d7aa 100644
--- a/audio/decode/dec_audio.c
+++ b/audio/decode/dec_audio.c
@@ -68,7 +68,7 @@ static const struct ad_functions * const ad_drivers[] = {
static bool reinit_audio_buffer(struct dec_audio *da)
{
if (!mp_audio_config_valid(&da->decoded)) {
- mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Audio decoder did not specify audio "
+ MP_ERR(da, "Audio decoder did not specify audio "
"format, or requested an unsupported configuration!\n");
return false;
}
@@ -80,7 +80,7 @@ static bool reinit_audio_buffer(struct dec_audio *da)
static void uninit_decoder(struct dec_audio *d_audio)
{
if (d_audio->ad_driver) {
- mp_msg(MSGT_DECAUDIO, MSGL_V, "Uninit audio decoder.\n");
+ MP_VERBOSE(d_audio, "Uninit audio decoder.\n");
d_audio->ad_driver->uninit(d_audio);
}
d_audio->ad_driver = NULL;
@@ -91,7 +91,7 @@ static void uninit_decoder(struct dec_audio *d_audio)
static int init_audio_codec(struct dec_audio *d_audio, const char *decoder)
{
if (!d_audio->ad_driver->init(d_audio, decoder)) {
- mp_msg(MSGT_DECAUDIO, MSGL_V, "Audio decoder init failed.\n");
+ MP_VERBOSE(d_audio, "Audio decoder init failed.\n");
d_audio->ad_driver = NULL;
uninit_decoder(d_audio);
return 0;
@@ -148,14 +148,14 @@ int audio_init_best_codec(struct dec_audio *d_audio, char *audio_decoders)
const struct ad_functions *driver = find_driver(sel->family);
if (!driver)
continue;
- mp_msg(MSGT_DECAUDIO, MSGL_V, "Opening audio decoder %s:%s\n",
- sel->family, sel->decoder);
+ MP_VERBOSE(d_audio, "Opening audio decoder %s:%s\n",
+ sel->family, sel->decoder);
d_audio->ad_driver = driver;
if (init_audio_codec(d_audio, sel->decoder)) {
decoder = sel;
break;
}
- mp_msg(MSGT_DECAUDIO, MSGL_WARN, "Audio decoder init failed for "
+ MP_WARN(d_audio, "Audio decoder init failed for "
"%s:%s\n", sel->family, sel->decoder);
}
@@ -163,19 +163,16 @@ int audio_init_best_codec(struct dec_audio *d_audio, char *audio_decoders)
d_audio->decoder_desc =
talloc_asprintf(d_audio, "%s [%s:%s]", decoder->desc, decoder->family,
decoder->decoder);
- mp_msg(MSGT_DECAUDIO, MSGL_INFO, "Selected audio codec: %s\n",
- d_audio->decoder_desc);
- mp_msg(MSGT_DECAUDIO, MSGL_V,
- "AUDIO: %d Hz, %d ch, %s\n",
- d_audio->decoded.rate, d_audio->decoded.channels.num,
- af_fmt_to_str(d_audio->decoded.format));
- mp_msg(MSGT_IDENTIFY, MSGL_INFO,
- "ID_AUDIO_BITRATE=%d\nID_AUDIO_RATE=%d\n" "ID_AUDIO_NCH=%d\n",
- d_audio->i_bps * 8, d_audio->decoded.rate,
- d_audio->decoded.channels.num);
+ MP_INFO(d_audio, "Selected audio codec: %s\n",
+ d_audio->decoder_desc);
+ MP_VERBOSE(d_audio, "AUDIO: %d Hz, %d ch, %s\n",
+ d_audio->decoded.rate, d_audio->decoded.channels.num,
+ af_fmt_to_str(d_audio->decoded.format));
+ MP_SMODE(d_audio, "ID_AUDIO_BITRATE=%d\nID_AUDIO_RATE=%d\n" "ID_AUDIO_NCH=%d\n",
+ d_audio->i_bps * 8, d_audio->decoded.rate,
+ d_audio->decoded.channels.num);
} else {
- mp_msg(MSGT_DECAUDIO, MSGL_ERR,
- "Failed to initialize an audio decoder for codec '%s'.\n",
+ MP_ERR(d_audio, "Failed to initialize an audio decoder for codec '%s'.\n",
d_audio->header->codec ? d_audio->header->codec : "<unknown>");
}
@@ -188,7 +185,7 @@ void audio_uninit(struct dec_audio *d_audio)
if (!d_audio)
return;
if (d_audio->afilter) {
- mp_msg(MSGT_DECAUDIO, MSGL_V, "Uninit audio filters...\n");
+ MP_VERBOSE(d_audio, "Uninit audio filters...\n");
af_destroy(d_audio->afilter);
d_audio->afilter = NULL;
}
@@ -203,7 +200,7 @@ int audio_init_filters(struct dec_audio *d_audio, int in_samplerate,
int *out_format)
{
if (!d_audio->afilter)
- d_audio->afilter = af_new(d_audio->opts);
+ d_audio->afilter = af_new(d_audio->global);
struct af_stream *afs = d_audio->afilter;
// input format: same as codec's output format:
@@ -218,8 +215,7 @@ int audio_init_filters(struct dec_audio *d_audio, int in_samplerate,
char *s_from = mp_audio_config_to_str(&afs->input);
char *s_to = mp_audio_config_to_str(&afs->output);
- mp_msg(MSGT_DECAUDIO, MSGL_V,
- "Building audio filter chain for %s -> %s...\n", s_from, s_to);
+ MP_VERBOSE(d_audio, "Building audio filter chain for %s -> %s...\n", s_from, s_to);
talloc_free(s_from);
talloc_free(s_to);
diff --git a/audio/decode/dec_audio.h b/audio/decode/dec_audio.h
index 7e8896fa61..c17a3baca3 100644
--- a/audio/decode/dec_audio.h
+++ b/audio/decode/dec_audio.h
@@ -27,7 +27,9 @@ struct mp_audio_buffer;
struct mp_decoder_list;
struct dec_audio {
+ struct mp_log *log;
struct MPOpts *opts;
+ struct mpv_global *global;
const struct ad_functions *ad_driver;
struct sh_stream *header;
struct mp_audio_buffer *decode_buffer;