summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-21 23:15:32 +0100
committerwm4 <wm4@nowhere>2013-12-21 23:15:32 +0100
commit0a3e9a9ac3a90da831b497e0613dfb66bc14f3d2 (patch)
treeb70f214f8c3fc802d6d6edbf8395273c854ac0fd /audio
parenta4fe95b0d8d339ba5afbdb5346ad8fd367a4a1c1 (diff)
parent245e5b844177e9ad9a9c07eff5efab7c3fccdebc (diff)
downloadmpv-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')
-rw-r--r--audio/chmap.c16
-rw-r--r--audio/chmap.h4
-rw-r--r--audio/decode/ad_lavc.c29
-rw-r--r--audio/decode/ad_mpg123.c16
-rw-r--r--audio/decode/ad_spdif.c9
-rw-r--r--audio/decode/dec_audio.c42
-rw-r--r--audio/decode/dec_audio.h2
-rw-r--r--audio/filter/af.c45
-rw-r--r--audio/filter/af.h5
-rw-r--r--audio/filter/af_bs2b.c5
-rw-r--r--audio/filter/af_channels.c23
-rw-r--r--audio/filter/af_delay.c8
-rw-r--r--audio/filter/af_dummy.c2
-rw-r--r--audio/filter/af_equalizer.c2
-rw-r--r--audio/filter/af_export.c19
-rw-r--r--audio/filter/af_format.c5
-rw-r--r--audio/filter/af_hrtf.c24
-rw-r--r--audio/filter/af_ladspa.c89
-rw-r--r--audio/filter/af_lavcac3enc.c22
-rw-r--r--audio/filter/af_lavfi.c11
-rw-r--r--audio/filter/af_lavrresample.c7
-rw-r--r--audio/filter/af_pan.c4
-rw-r--r--audio/filter/af_scaletempo.c14
-rw-r--r--audio/filter/af_sinesuppress.c2
-rw-r--r--audio/filter/af_surround.c6
-rw-r--r--audio/fmt-conversion.c21
-rw-r--r--audio/mixer.c21
-rw-r--r--audio/mixer.h4
-rw-r--r--audio/out/ao.c34
-rw-r--r--audio/out/ao_alsa.c21
-rw-r--r--audio/out/ao_coreaudio.c2
-rw-r--r--audio/out/ao_coreaudio_utils.c2
-rw-r--r--audio/out/ao_lavc.c5
-rw-r--r--audio/out/ao_openal.c10
-rw-r--r--audio/out/ao_portaudio.c49
-rw-r--r--audio/out/ao_wasapi.c164
36 files changed, 342 insertions, 402 deletions
diff --git a/audio/chmap.c b/audio/chmap.c
index ce301b6565..a67c4e1c70 100644
--- a/audio/chmap.c
+++ b/audio/chmap.c
@@ -471,19 +471,19 @@ bool mp_chmap_from_str(struct mp_chmap *dst, bstr src)
return true;
}
-void mp_chmap_print_help(int msgt, int msgl)
+void mp_chmap_print_help(struct mp_log *log)
{
- mp_msg(msgt, msgl, "Speakers:\n");
+ mp_info(log, "Speakers:\n");
for (int n = 0; n < MP_SPEAKER_ID_COUNT; n++) {
if (speaker_names[n][0])
- mp_msg(msgt, msgl, " %-16s (%s)\n",
- speaker_names[n][0], speaker_names[n][1]);
+ mp_info(log, " %-16s (%s)\n",
+ speaker_names[n][0], speaker_names[n][1]);
}
- mp_msg(msgt, msgl, "Standard layouts:\n");
+ mp_info(log, "Standard layouts:\n");
for (int n = 0; std_layout_names[n][0]; n++) {
- mp_msg(msgt, msgl, " %-16s (%s)\n",
- std_layout_names[n][0], std_layout_names[n][1]);
+ mp_info(log, " %-16s (%s)\n",
+ std_layout_names[n][0], std_layout_names[n][1]);
}
for (int n = 0; n < MP_NUM_CHANNELS; n++)
- mp_msg(msgt, msgl, " unknown%d\n", n);
+ mp_info(log, " unknown%d\n", n);
}
diff --git a/audio/chmap.h b/audio/chmap.h
index ca1e6c2508..306382db5a 100644
--- a/audio/chmap.h
+++ b/audio/chmap.h
@@ -121,7 +121,9 @@ void mp_chmap_get_reorder(int dst[MP_NUM_CHANNELS], const struct mp_chmap *from,
char *mp_chmap_to_str(const struct mp_chmap *src);
bool mp_chmap_from_str(struct mp_chmap *dst, bstr src);
-void mp_chmap_print_help(int msgt, int msgl);
+
+struct mp_log;
+void mp_chmap_print_help(struct mp_log *log);
// Use these to avoid chaos in case lavc's definition should diverge from MS.
#define mp_chmap_to_waveext mp_chmap_to_lavc
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;
}
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..ad9ccb504e 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;
@@ -141,21 +141,21 @@ int audio_init_best_codec(struct dec_audio *d_audio, char *audio_decoders)
struct mp_decoder_list *list =
audio_select_decoders(d_audio->header->codec, audio_decoders);
- mp_print_decoders(MSGT_DECAUDIO, MSGL_V, "Codec list:", list);
+ mp_print_decoders(d_audio->log, MSGL_V, "Codec list:", list);
for (int n = 0; n < list->num_entries; n++) {
struct mp_decoder_entry *sel = &list->entries[n];
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;
diff --git a/audio/filter/af.c b/audio/filter/af.c
index 417dede971..92ed2ad63e 100644
--- a/audio/filter/af.c
+++ b/audio/filter/af.c
@@ -23,6 +23,7 @@
#include <assert.h>
#include "common/common.h"
+#include "common/global.h"
#include "options/m_option.h"
#include "options/m_config.h"
@@ -179,8 +180,7 @@ static struct af_instance *af_create(struct af_stream *s, char *name,
{
struct m_obj_desc desc;
if (!m_obj_list_find(&desc, &af_obj_list, bstr0(name))) {
- mp_msg(MSGT_VFILTER, MSGL_ERR,
- "Couldn't find audio filter '%s'.\n", name);
+ MP_ERR(s, "Couldn't find audio filter '%s'.\n", name);
return NULL;
}
const struct af_info *info = desc.p;
@@ -189,22 +189,23 @@ static struct af_instance *af_create(struct af_stream *s, char *name,
if (info->flags & AF_FLAGS_NOT_REENTRANT) {
for (struct af_instance *cur = s->first; cur; cur = cur->next) {
if (cur->info == info) {
- mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] There can only be one "
+ MP_ERR(s, "There can only be one "
"instance of the filter '%s' in each stream\n", name);
return NULL;
}
}
}
- mp_msg(MSGT_AFILTER, MSGL_V, "[libaf] Adding filter %s \n", name);
+ MP_VERBOSE(s, "Adding filter %s \n", name);
struct af_instance *af = talloc_zero(NULL, struct af_instance);
*af = (struct af_instance) {
.info = info,
.mul = 1,
.data = talloc_zero(af, struct mp_audio),
+ .log = mp_log_new(af, s->log, name),
};
- struct m_config *config = m_config_from_obj_desc(af, &desc);
+ struct m_config *config = m_config_from_obj_desc(af, s->log, &desc);
if (m_config_apply_defaults(config, name, s->opts->af_defs) < 0)
goto error;
if (m_config_set_obj_params(config, args) < 0)
@@ -218,8 +219,7 @@ static struct af_instance *af_create(struct af_stream *s, char *name,
return af;
error:
- mp_msg(MSGT_AFILTER, MSGL_ERR,
- "[libaf] Couldn't create or open audio filter '%s'\n", name);
+ MP_ERR(s, "Couldn't create or open audio filter '%s'\n", name);
talloc_free(af);
return NULL;
}
@@ -280,8 +280,7 @@ static void af_remove(struct af_stream *s, struct af_instance *af)
return;
// Print friendly message
- mp_msg(MSGT_AFILTER, MSGL_V, "[libaf] Removing filter %s \n",
- af->info->name);
+ MP_VERBOSE(s, "Removing filter %s \n", af->info->name);
// Detach pointers
af->prev->next = af->next;
@@ -306,26 +305,26 @@ repeat:
static void af_print_filter_chain(struct af_stream *s, struct af_instance *at,
int msg_level)
{
- mp_msg(MSGT_AFILTER, msg_level, "Audio filter chain:\n");
+ MP_MSG(s, msg_level, "Audio filter chain:\n");
struct af_instance *af = s->first;
while (af) {
- mp_msg(MSGT_AFILTER, msg_level, " [%s] ", af->info->name);
+ MP_MSG(s, msg_level, " [%s] ", af->info->name);
if (af->data) {
char *info = mp_audio_config_to_str(af->data);
- mp_msg(MSGT_AFILTER, msg_level, "%s", info);
+ MP_MSG(s, msg_level, "%s", info);
talloc_free(info);
}
if (af == at)
- mp_msg(MSGT_AFILTER, msg_level, " <-");
- mp_msg(MSGT_AFILTER, msg_level, "\n");
+ MP_MSG(s, msg_level, " <-");
+ MP_MSG(s, msg_level, "\n");
af = af->next;
}
- mp_msg(MSGT_AFILTER, msg_level, " [ao] ");
+ MP_MSG(s, msg_level, " [ao] ");
char *info = mp_audio_config_to_str(&s->output);
- mp_msg(MSGT_AFILTER, msg_level, "%s\n", info);
+ MP_MSG(s, msg_level, "%s\n", info);
talloc_free(info);
}
@@ -555,8 +554,8 @@ static int af_reinit(struct af_stream *s)
break;
}
default:
- mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] Reinitialization did not "
- "work, audio filter '%s' returned error code %i\n",
+ MP_ERR(s, "Reinitialization did not work, "
+ "audio filter '%s' returned error code %i\n",
af->info->name, rv);
af_print_filter_chain(s, af, MSGL_ERR);
return AF_ERROR;
@@ -573,8 +572,7 @@ static int af_reinit(struct af_stream *s)
return af_config_equals(&s->output, &s->filter_output) ? AF_OK : AF_ERROR;
negotiate_error:
- mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] Unable to convert audio input "
- "format to output format.\n");
+ MP_ERR(s, "Unable to convert audio input format to output format.\n");
af_print_filter_chain(s, af, MSGL_ERR);
return AF_ERROR;
}
@@ -586,7 +584,7 @@ void af_uninit(struct af_stream *s)
af_remove(s, s->first->next);
}
-struct af_stream *af_new(struct MPOpts *opts)
+struct af_stream *af_new(struct mpv_global *global)
{
struct af_stream *s = talloc_zero(NULL, struct af_stream);
static struct af_info in = { .name = "in" };
@@ -611,7 +609,8 @@ struct af_stream *af_new(struct MPOpts *opts)
};
s->first->next = s->last;
s->last->prev = s->first;
- s->opts = opts;
+ s->opts = global->opts;
+ s->log = mp_log_new(s, global->log, "!af");
return s;
}
@@ -654,7 +653,7 @@ int af_init(struct af_stream *s)
if (af_reinit(s) != AF_OK) {
// Something is stuffed audio out will not work
- mp_msg(MSGT_AFILTER, MSGL_ERR, "Could not create audio filter chain.\n");
+ MP_ERR(s, "Could not create audio filter chain.\n");
af_uninit(s);
return -1;
}
diff --git a/audio/filter/af.h b/audio/filter/af.h
index d08560bece..6b0f0e9c01 100644
--- a/audio/filter/af.h
+++ b/audio/filter/af.h
@@ -30,6 +30,7 @@
#include "common/msg.h"
struct af_instance;
+struct mpv_global;
// Number of channels
#define AF_NCH MP_NUM_CHANNELS
@@ -57,6 +58,7 @@ struct af_info {
// Linked list of audio filters
struct af_instance {
const struct af_info *info;
+ struct mp_log *log;
int (*control)(struct af_instance *af, int cmd, void *arg);
void (*uninit)(struct af_instance *af);
/* flags is a bit mask of AF_FILTER_FLAG_* values
@@ -86,6 +88,7 @@ struct af_stream {
struct mp_audio output;
struct mp_audio filter_output;
+ struct mp_log *log;
struct MPOpts *opts;
};
@@ -120,7 +123,7 @@ typedef struct af_control_ext_s {
int ch; // Chanel number
} af_control_ext_t;
-struct af_stream *af_new(struct MPOpts *opts);
+struct af_stream *af_new(struct mpv_global *global);
void af_destroy(struct af_stream *s);
int af_init(struct af_stream *s);
void af_uninit(struct af_stream *s);
diff --git a/audio/filter/af_bs2b.c b/audio/filter/af_bs2b.c
index 48df9197dc..1ea31b260a 100644
--- a/audio/filter/af_bs2b.c
+++ b/audio/filter/af_bs2b.c
@@ -142,13 +142,12 @@ static int control(struct af_instance *af, int cmd, void *arg)
// bs2b have srate limits, try to resample if needed
if (af->data->rate > BS2B_MAXSRATE || af->data->rate < BS2B_MINSRATE) {
af->data->rate = BS2B_DEFAULT_SRATE;
- mp_msg(MSGT_AFILTER, MSGL_WARN,
- "[bs2b] Requested sample rate %d Hz is out of bounds [%d..%d] Hz.\n"
+ MP_WARN(af, "[bs2b] Requested sample rate %d Hz is out of bounds [%d..%d] Hz.\n"
"[bs2b] Trying to resample to %d Hz.\n",
af->data->rate, BS2B_MINSRATE, BS2B_MAXSRATE, BS2B_DEFAULT_SRATE);
}
bs2b_set_srate(s->filter, (long)af->data->rate);
- mp_msg(MSGT_AFILTER, MSGL_V, "[bs2b] using format %s\n",
+ MP_VERBOSE(af, "[bs2b] using format %s\n",
af_fmt_to_str(af->data->format));
return af_test_output(af,(struct mp_audio*)arg);
diff --git a/audio/filter/af_channels.c b/audio/filter/af_channels.c
index 7bbf952ffe..74a0de0fd6 100644
--- a/audio/filter/af_channels.c
+++ b/audio/filter/af_channels.c
@@ -41,7 +41,8 @@ typedef struct af_channels_s{
}af_channels_t;
// Local function for copying data
-static void copy(void* in, void* out, int ins, int inos,int outs, int outos, int len, int bps)
+static void copy(struct af_instance *af, void* in, void* out,
+ int ins, int inos,int outs, int outos, int len, int bps)
{
switch(bps){
case 1:{
@@ -112,24 +113,25 @@ static void copy(void* in, void* out, int ins, int inos,int outs, int outos, int
break;
}
default:
- mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] Unsupported number of bytes/sample: %i"
+ MP_ERR(af, "Unsupported number of bytes/sample: %i"
" please report this error on the MPlayer mailing list. \n",bps);
}
}
// Make sure the routes are sane
-static int check_routes(af_channels_t* s, int nin, int nout)
+static int check_routes(struct af_instance *af, int nin, int nout)
{
+ af_channels_t* s = af->priv;
int i;
if((s->nr < 1) || (s->nr > AF_NCH)){
- mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] The number of routing pairs must be"
+ MP_ERR(af, "[channels] The number of routing pairs must be"
" between 1 and %i. Current value is %i\n",AF_NCH,s->nr);
return AF_ERROR;
}
for(i=0;i<s->nr;i++){
if((s->route[i][FR] >= nin) || (s->route[i][TO] >= nout)){
- mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] Invalid routing in pair nr. %i.\n", i);
+ MP_ERR(af, "[channels] Invalid routing in pair nr. %i.\n", i);
return AF_ERROR;
}
}
@@ -174,7 +176,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
af->data->rate = ((struct mp_audio*)arg)->rate;
mp_audio_force_interleaved_format((struct mp_audio*)arg);
mp_audio_set_format(