summaryrefslogtreecommitdiffstats
path: root/audio/out
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-08-22 23:12:35 +0200
committerwm4 <wm4@nowhere>2013-08-22 23:12:35 +0200
commitedd36a3afce4ca3778461e61df64f6a79ba94079 (patch)
treea7916172632fea425b9c3a58e673573203850266 /audio/out
parentcb54c2dda8be8a79e8bc6c658b4815c55bdfc14e (diff)
downloadmpv-edd36a3afce4ca3778461e61df64f6a79ba94079.tar.bz2
mpv-edd36a3afce4ca3778461e61df64f6a79ba94079.tar.xz
audio/out: do some mp_msg conversions
Use the new MP_ macros for some AOs instead of mp_msg. Not all AOs are converted, and some only partially. In some cases, some additional cosmetic changes are made.
Diffstat (limited to 'audio/out')
-rw-r--r--audio/out/ao_alsa.c89
-rw-r--r--audio/out/ao_jack.c10
-rw-r--r--audio/out/ao_lavc.c74
-rw-r--r--audio/out/ao_openal.c6
-rw-r--r--audio/out/ao_pcm.c16
-rw-r--r--audio/out/ao_portaudio.c11
-rw-r--r--audio/out/ao_pulse.c45
-rw-r--r--audio/out/ao_sdl.c30
8 files changed, 118 insertions, 163 deletions
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index 63309c3dbd..2db5041b95 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -73,8 +73,7 @@ struct priv {
#define CHECK_ALSA_ERROR(message) \
do { \
if (err < 0) { \
- mp_msg(MSGT_VO, MSGL_ERR, "[AO_ALSA] %s: %s\n", \
- (message), snd_strerror(err)); \
+ MP_ERR(ao, "%s: %s\n", (message), snd_strerror(err)); \
goto alsa_error; \
} \
} while (0)
@@ -94,10 +93,10 @@ static void alsa_error_handler(const char *file, int line, const char *function,
va_end(va);
if (err) {
- mp_msg(MSGT_AO, MSGL_ERR, "[AO_ALSA] alsa-lib: %s:%i:(%s) %s: %s\n",
+ mp_msg(MSGT_AO, MSGL_ERR, "alsa-lib: %s:%i:(%s) %s: %s\n",
file, line, function, tmp, snd_strerror(err));
} else {
- mp_msg(MSGT_AO, MSGL_ERR, "[AO_ALSA] alsa-lib: %s:%i:(%s) %s\n",
+ mp_msg(MSGT_AO, MSGL_ERR, "alsa-lib: %s:%i:(%s) %s\n",
file, line, function, tmp);
}
}
@@ -145,10 +144,9 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
elem = snd_mixer_find_selem(handle, sid);
if (!elem) {
- mp_tmsg(MSGT_AO, MSGL_ERR,
- "[AO_ALSA] Unable to find simple control '%s',%i.\n",
- snd_mixer_selem_id_get_name(sid),
- snd_mixer_selem_id_get_index(sid));
+ MP_VERBOSE(ao, "Unable to find simple control '%s',%i.\n",
+ snd_mixer_selem_id_get_name(sid),
+ snd_mixer_selem_id_get_index(sid));
goto alsa_error;
}
@@ -164,15 +162,14 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
err = snd_mixer_selem_set_playback_volume
(elem, SND_MIXER_SCHN_FRONT_LEFT, set_vol);
CHECK_ALSA_ERROR("Error setting left channel");
- mp_msg(MSGT_AO, MSGL_DBG2, "left=%li, ", set_vol);
+ MP_DBG(ao, "left=%li, ", set_vol);
set_vol = vol->right / f_multi + pmin + 0.5;
err = snd_mixer_selem_set_playback_volume
(elem, SND_MIXER_SCHN_FRONT_RIGHT, set_vol);
CHECK_ALSA_ERROR("Error setting right channel");
- mp_msg(MSGT_AO, MSGL_DBG2,
- "right=%li, pmin=%li, pmax=%li, mult=%f\n",
+ MP_DBG(ao, "right=%li, pmin=%li, pmax=%li, mult=%f\n",
set_vol, pmin, pmax,
f_multi);
break;
@@ -185,8 +182,7 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
snd_mixer_selem_get_playback_volume
(elem, SND_MIXER_SCHN_FRONT_RIGHT, &get_vol);
vol->right = (get_vol - pmin) * f_multi;
- mp_msg(MSGT_AO, MSGL_DBG2, "left=%f, right=%f\n", vol->left,
- vol->right);
+ MP_DBG(ao, "left=%f, right=%f\n", vol->left, vol->right);
break;
}
case AOCONTROL_SET_MUTE: {
@@ -303,9 +299,8 @@ static const char *select_chmap(struct ao *ao)
}
char *name = mp_chmap_to_str(&ao->channels);
- mp_tmsg(MSGT_AO, MSGL_ERR,
- "[AO_ALSA] channel layout %s (%d ch) not supported.\n",
- name, ao->channels.num);
+ MP_ERR(ao, "channel layout %s (%d ch) not supported.\n",
+ name, ao->channels.num);
talloc_free(name);
return "default";
}
@@ -370,9 +365,8 @@ static int init(struct ao *ao)
struct priv *p = ao->priv;
- mp_msg(MSGT_AO, MSGL_V,
- "alsa-init: requested format: %d Hz, %d channels, %x\n",
- ao->samplerate, ao->channels.num, ao->format);
+ MP_VERBOSE(ao, "requested format: %d Hz, %d channels, %x\n",
+ ao->samplerate, ao->channels.num, ao->format);
p->prepause_frames = 0;
p->delay_before_pause = 0;
@@ -386,9 +380,8 @@ static int init(struct ao *ao)
const char *device;
if (AF_FORMAT_IS_IEC61937(ao->format)) {
device = "iec958";
- mp_msg(MSGT_AO, MSGL_V,
- "alsa-spdif-init: playing AC3/iec61937/iec958, %i channels\n",
- ao->channels.num);
+ MP_VERBOSE(ao, "playing AC3/iec61937/iec958, %i channels\n",
+ ao->channels.num);
} else {
device = select_chmap(ao);
if (strcmp(device, "default") != 0 && ao->format == AF_FORMAT_FLOAT_NE)
@@ -400,11 +393,11 @@ static int init(struct ao *ao)
if (p->cfg_device && p->cfg_device[0])
device = p->cfg_device;
- mp_msg(MSGT_AO, MSGL_V, "alsa-init: using device %s\n", device);
+ MP_VERBOSE(ao, "using device: %s\n", device);
p->can_pause = 1;
- mp_msg(MSGT_AO, MSGL_V, "alsa-init: using ALSA %s\n", snd_asoundlib_version());
+ MP_VERBOSE(ao, "using ALSA version: %s\n", snd_asoundlib_version());
snd_lib_error_set_handler(alsa_error_handler);
int open_mode = p->cfg_block ? 0 : SND_PCM_NONBLOCK;
@@ -413,7 +406,7 @@ static int init(struct ao *ao)
err = try_open_device(ao, device, open_mode, isac3);
if (err < 0) {
if (err != -EBUSY && !p->cfg_block) {
- mp_tmsg(MSGT_AO, MSGL_INFO, "[AO_ALSA] Open in nonblock-mode "
+ MP_WARN(ao, "Open in nonblock-mode "
"failed, trying to open in block-mode.\n");
err = try_open_device(ao, device, 0, isac3);
}
@@ -422,11 +415,9 @@ static int init(struct ao *ao)
err = snd_pcm_nonblock(p->alsa, 0);
if (err < 0) {
- mp_tmsg(MSGT_AO, MSGL_ERR,
- "[AL_ALSA] Error setting block-mode %s.\n",
- snd_strerror(err));
+ MP_ERR(ao, "Error setting block-mode: %s.\n", snd_strerror(err));
} else {
- mp_msg(MSGT_AO, MSGL_V, "alsa-init: pcm opened in blocking mode\n");
+ MP_VERBOSE(ao, "pcm opened in blocking mode\n");
}
snd_pcm_hw_params_t *alsa_hwparams;
@@ -451,8 +442,8 @@ static int init(struct ao *ao)
err = snd_pcm_hw_params_test_format(p->alsa, alsa_hwparams, p->alsa_fmt);
if (err < 0) {
- mp_tmsg(MSGT_AO, MSGL_INFO, "[AO_ALSA] Format %s is not supported "
- "by hardware, trying default.\n", af_fmt2str_short(ao->format));
+ MP_INFO(ao, "Format %s is not supported by hardware, trying default.\n",
+ af_fmt2str_short(ao->format));
p->alsa_fmt = SND_PCM_FORMAT_S16_LE;
if (AF_FORMAT_IS_AC3(ao->format))
ao->format = AF_FORMAT_AC3_LE;
@@ -471,8 +462,7 @@ static int init(struct ao *ao)
CHECK_ALSA_ERROR("Unable to set channels");
if (num_channels != ao->channels.num) {
- mp_tmsg(MSGT_AO, MSGL_ERR,
- "[AO_ALSA] Couldn't get requested number of channels.\n");
+ MP_ERR(ao, "Couldn't get requested number of channels.\n");
mp_chmap_from_channels_alsa(&ao->channels, num_channels);
}
@@ -508,13 +498,12 @@ static int init(struct ao *ao)
CHECK_ALSA_ERROR("Unable to get buffersize");
p->buffersize = bufsize * p->bytes_per_sample;
- mp_msg(MSGT_AO, MSGL_V, "alsa-init: got buffersize=%i\n",
- p->buffersize);
+ MP_VERBOSE(ao, "got buffersize=%i\n", p->buffersize);
err = snd_pcm_hw_params_get_period_size(alsa_hwparams, &chunk_size, NULL);
CHECK_ALSA_ERROR("Unable to get period size");
- mp_msg(MSGT_AO, MSGL_V, "alsa-init: got period size %li\n", chunk_size);
+ MP_VERBOSE(ao, "got period size %li\n", chunk_size);
p->outburst = chunk_size * p->bytes_per_sample;
/* setting software parameters */
@@ -546,10 +535,9 @@ static int init(struct ao *ao)
p->can_pause = snd_pcm_hw_params_can_pause(alsa_hwparams);
- mp_msg(MSGT_AO, MSGL_V,
- "alsa: %d Hz/%d channels/%d bpf/%d bytes buffer/%s\n",
- ao->samplerate, ao->channels.num, (int)p->bytes_per_sample,
- p->buffersize, snd_pcm_format_description(p->alsa_fmt));
+ MP_VERBOSE(ao, "opened: %d Hz/%d channels/%d bpf/%d bytes buffer/%s\n",
+ ao->samplerate, ao->channels.num, (int)p->bytes_per_sample,
+ p->buffersize, snd_pcm_format_description(p->alsa_fmt));
return 0;
@@ -573,7 +561,7 @@ static void uninit(struct ao *ao, bool immed)
err = snd_pcm_close(p->alsa);
CHECK_ALSA_ERROR("pcm close error");
- mp_msg(MSGT_AO, MSGL_V, "alsa-uninit: pcm closed\n");
+ MP_VERBOSE(ao, "uninit: pcm closed\n");
}
alsa_error:
@@ -590,8 +578,8 @@ static void audio_pause(struct ao *ao)
p->delay_before_pause = get_delay(ao);
err = snd_pcm_pause(p->alsa, 1);
CHECK_ALSA_ERROR("pcm pause error");
- mp_msg(MSGT_AO, MSGL_V, "alsa-pause: pause supported by hardware\n");
} else {
+ MP_VERBOSE(ao, "pause not supported by hardware\n");
if (snd_pcm_delay(p->alsa, &p->prepause_frames) < 0
|| p->prepause_frames < 0)
p->prepause_frames = 0;
@@ -610,16 +598,15 @@ static void audio_resume(struct ao *ao)
int err;
if (snd_pcm_state(p->alsa) == SND_PCM_STATE_SUSPENDED) {
- mp_tmsg(MSGT_AO, MSGL_INFO,
- "[AO_ALSA] Pcm in suspend mode, trying to resume.\n");
+ MP_INFO(ao, "PCM in suspend mode, trying to resume.\n");
while ((err = snd_pcm_resume(p->alsa)) == -EAGAIN)
sleep(1);
}
if (p->can_pause) {
err = snd_pcm_pause(p->alsa, 0);
CHECK_ALSA_ERROR("pcm resume error");
- mp_msg(MSGT_AO, MSGL_V, "alsa-resume: resume supported by hardware\n");
} else {
+ MP_VERBOSE(ao, "resume not supported by hardware\n");
err = snd_pcm_prepare(p->alsa);
CHECK_ALSA_ERROR("pcm prepare error");
if (p->prepause_frames) {
@@ -664,10 +651,8 @@ static int play(struct ao *ao, void *data, int len, int flags)
len = len / p->outburst * p->outburst;
num_frames = len / p->bytes_per_sample;
- //mp_msg(MSGT_AO,MSGL_ERR,"alsa-play: frames=%i, len=%i\n",num_frames,len);
-
if (!p->alsa) {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO_ALSA] Device configuration error.");
+ MP_ERR(ao, "Device configuration error.");
return 0;
}
@@ -681,16 +666,12 @@ static int play(struct ao *ao, void *data, int len, int flags)
/* nothing to do */
res = 0;
} else if (res == -ESTRPIPE) { /* suspend */
- mp_tmsg(MSGT_AO, MSGL_INFO,
- "[AO_ALSA] Pcm in suspend mode, trying to resume.\n");
+ MP_INFO(ao, "PCM in suspend mode, trying to resume.\n");
while ((res = snd_pcm_resume(p->alsa)) == -EAGAIN)
sleep(1);
}
if (res < 0) {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO_ALSA] Write error: %s\n",
- snd_strerror(res));
- mp_tmsg(MSGT_AO, MSGL_INFO,
- "[AO_ALSA] Trying to reset soundcard.\n");
+ MP_ERR(ao, "Write error: %s\n", snd_strerror(res));
res = snd_pcm_prepare(p->alsa);
int err = res;
CHECK_ALSA_ERROR("pcm prepare error");
diff --git a/audio/out/ao_jack.c b/audio/out/ao_jack.c
index 579dee2631..b1f105248f 100644
--- a/audio/out/ao_jack.c
+++ b/audio/out/ao_jack.c
@@ -190,7 +190,7 @@ static int init(struct ao *ao)
open_options |= JackNoStartServer;
p->client = jack_client_open(p->cfg_client_name, open_options, NULL);
if (!p->client) {
- mp_msg(MSGT_AO, MSGL_FATAL, "[JACK] cannot open server\n");
+ MP_FATAL(ao, "cannot open server\n");
goto err_out;
}
jack_set_process_callback(p->client, outputaudio, ao);
@@ -201,7 +201,7 @@ static int init(struct ao *ao)
port_flags |= JackPortIsPhysical;
matching_ports = jack_get_ports(p->client, port_name, NULL, port_flags);
if (!matching_ports || !matching_ports[0]) {
- mp_msg(MSGT_AO, MSGL_FATAL, "[JACK] no physical ports available\n");
+ MP_FATAL(ao, "no physical ports available\n");
goto err_out;
}
i = 1;
@@ -220,19 +220,19 @@ static int init(struct ao *ao)
jack_port_register(p->client, pname, JACK_DEFAULT_AUDIO_TYPE,
JackPortIsOutput, 0);
if (!p->ports[i]) {
- mp_msg(MSGT_AO, MSGL_FATAL, "[JACK] not enough ports available\n");
+ MP_FATAL(ao, "not enough ports available\n");
goto err_out;
}
}
if (jack_activate(p->client)) {
- mp_msg(MSGT_AO, MSGL_FATAL, "[JACK] activate failed\n");
+ MP_FATAL(ao, "activate failed\n");
goto err_out;
}
for (i = 0; i < p->num_ports; i++) {
if (jack_connect(p->client, jack_port_name(p->ports[i]),
matching_ports[i]))
{
- mp_msg(MSGT_AO, MSGL_FATAL, "[JACK] connecting failed\n");
+ MP_FATAL(ao, "connecting failed\n");
goto err_out;
}
}
diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c
index 0631d54aea..bf42a75ca3 100644
--- a/audio/out/ao_lavc.c
+++ b/audio/out/ao_lavc.c
@@ -71,13 +71,7 @@ static int init(struct ao *ao)
AVCodec *codec;
if (!encode_lavc_available(ao->encode_lavc_ctx)) {
- mp_msg(MSGT_ENCODE, MSGL_ERR,
- "ao-lavc: the option --o (output file) must be specified\n");
- return -1;
- }
-
- if (ac->stream) {
- mp_msg(MSGT_ENCODE, MSGL_ERR, "ao-lavc: rejecting reinitialization\n");
+ MP_ERR(ao, "the option --o (output file) must be specified\n");
return -1;
}
@@ -85,7 +79,7 @@ static int init(struct ao *ao)
AVMEDIA_TYPE_AUDIO);
if (!ac->stream) {
- mp_msg(MSGT_ENCODE, MSGL_ERR, "ao-lavc: could not get a new audio stream\n");
+ MP_ERR(ao, "could not get a new audio stream\n");
return -1;
}
@@ -243,8 +237,7 @@ out_takefirst:
}
if (!found_format && !found_planar_format) {
// shouldn't happen
- mp_msg(MSGT_ENCODE, MSGL_ERR,
- "ao-lavc: sample format not found\n");
+ MP_ERR(ao, "sample format not found\n");
}
}
@@ -285,8 +278,7 @@ out_takefirst:
ao->priv = ac;
if (ac->planarize)
- mp_msg(MSGT_ENCODE, MSGL_WARN,
- "ao-lavc: need to planarize audio data\n");
+ MP_WARN(ao, "need to planarize audio data\n");
return 0;
}
@@ -311,8 +303,7 @@ static void uninit(struct ao *ao, bool cut_audio)
struct encode_lavc_context *ectx = ao->encode_lavc_ctx;
if (!encode_lavc_start(ectx)) {
- mp_msg(MSGT_ENCODE, MSGL_WARN,
- "ao-lavc: not even ready to encode audio at end -> dropped");
+ MP_WARN(ao, "not even ready to encode audio at end -> dropped");
return;
}
@@ -329,8 +320,7 @@ static void uninit(struct ao *ao, bool cut_audio)
ac->sample_size, ac->sample_padding);
int written = play(ao, paddingbuf, ao->buffer.len + extralen, 0);
if (written < ao->buffer.len) {
- mp_msg(MSGT_ENCODE, MSGL_ERR,
- "ao-lavc: did not write enough data at the end\n");
+ MP_ERR(ao, "did not write enough data at the end\n");
}
talloc_free(paddingbuf);
ao->buffer.len = 0;
@@ -392,7 +382,7 @@ static int encode(struct ao *ao, double apts, void *data)
ac->stream->codec->sample_fmt, data,
audiolen, 1))
{
- mp_msg(MSGT_ENCODE, MSGL_ERR, "ao-lavc: error filling\n");
+ MP_ERR(ao, "error filling\n");
return -1;
}
@@ -408,9 +398,8 @@ static int encode(struct ao *ao, double apts, void *data)
if (ac->lastpts != MP_NOPTS_VALUE && frame_pts <= ac->lastpts) {
// this indicates broken video
// (video pts failing to increase fast enough to match audio)
- mp_msg(MSGT_ENCODE, MSGL_WARN, "ao-lavc: audio frame pts went backwards "
- "(%d <- %d), autofixed\n", (int)frame->pts,
- (int)ac->lastpts);
+ MP_WARN(ao, "audio frame pts went backwards (%d <- %d), autofixed\n",
+ (int)frame->pts, (int)ac->lastpts);
frame_pts = ac->lastpts + 1;
frame->pts = av_rescale_q(frame_pts, ac->worst_time_base, ac->stream->codec->time_base);
}
@@ -436,17 +425,15 @@ static int encode(struct ao *ao, double apts, void *data)
status = avcodec_encode_audio2(ac->stream->codec, &packet, NULL, &gotpacket);
}
- if(status)
- {
- mp_msg(MSGT_ENCODE, MSGL_ERR, "ao-lavc: error encoding\n");
+ if(status) {
+ MP_ERR(ao, "error encoding\n");
return -1;
}
if(!gotpacket)
return 0;
- mp_msg(MSGT_ENCODE, MSGL_DBG2,
- "ao-lavc: got pts %f (playback time: %f); out size: %d\n",
+ MP_DBG(ao, "got pts %f (playback time: %f); out size: %d\n",
apts, realapts, packet.size);
encode_lavc_write_stats(ao->encode_lavc_ctx, ac->stream);
@@ -455,7 +442,7 @@ static int encode(struct ao *ao, double apts, void *data)
// Do we need this at all? Better be safe than sorry...
if (packet.pts == AV_NOPTS_VALUE) {
- mp_msg(MSGT_ENCODE, MSGL_WARN, "ao-lavc: encoder lost pts, why?\n");
+ MP_WARN(ao, "encoder lost pts, why?\n");
if (ac->savepts != MP_NOPTS_VALUE)
packet.pts = ac->savepts;
}
@@ -475,7 +462,7 @@ static int encode(struct ao *ao, double apts, void *data)
ac->savepts = MP_NOPTS_VALUE;
if (encode_lavc_write_frame(ao->encode_lavc_ctx, &packet) < 0) {
- mp_msg(MSGT_ENCODE, MSGL_ERR, "ao-lavc: error writing at %f %f/%f\n",
+ MP_ERR(ao, "error writing at %f %f/%f\n",
realapts, (double) ac->stream->time_base.num,
(double) ac->stream->time_base.den);
return -1;
@@ -501,13 +488,11 @@ static int play(struct ao *ao, void *data, int len, int flags)
len /= ac->sample_size * ao->channels.num;
if (!encode_lavc_start(ectx)) {
- mp_msg(MSGT_ENCODE, MSGL_WARN,
- "ao-lavc: not ready yet for encoding audio\n");
+ MP_WARN(ao, "not ready yet for encoding audio\n");
return 0;
}
if (pts == MP_NOPTS_VALUE) {
- mp_msg(MSGT_ENCODE, MSGL_WARN,
- "ao-lavc: frame without pts, please report; synthesizing pts instead\n");
+ MP_WARN(ao, "frame without pts, please report; synthesizing pts instead\n");
// synthesize pts from previous expected next pts
pts = ac->expected_next_pts;
}
@@ -516,19 +501,21 @@ static int play(struct ao *ao, void *data, int len, int flags)
//if (ac->stream->codec->time_base.num / ac->stream->codec->time_base.den >= ac->stream->time_base.num / ac->stream->time_base.den)
if (ac->stream->codec->time_base.num * (double) ac->stream->time_base.den >=
ac->stream->time_base.num * (double) ac->stream->codec->time_base.den) {
- mp_msg(MSGT_ENCODE, MSGL_V, "ao-lavc: NOTE: using codec time base "
- "(%d/%d) for pts adjustment; the stream base (%d/%d) is "
- "not worse.\n", (int)ac->stream->codec->time_base.num,
- (int)ac->stream->codec->time_base.den, (int)ac->stream->time_base.num,
- (int)ac->stream->time_base.den);
+ MP_VERBOSE(ao, "NOTE: using codec time base (%d/%d) for pts "
+ "adjustment; the stream base (%d/%d) is not worse.\n",
+ (int)ac->stream->codec->time_base.num,
+ (int)ac->stream->codec->time_base.den,
+ (int)ac->stream->time_base.num,
+ (int)ac->stream->time_base.den);
ac->worst_time_base = ac->stream->codec->time_base;
ac->worst_time_base_is_stream = 0;
} else {
- mp_msg(MSGT_ENCODE, MSGL_WARN, "ao-lavc: NOTE: not using codec time "
- "base (%d/%d) for pts adjustment; the stream base (%d/%d) "
- "is worse.\n", (int)ac->stream->codec->time_base.num,
- (int)ac->stream->codec->time_base.den, (int)ac->stream->time_base.num,
- (int)ac->stream->time_base.den);
+ MP_WARN(ao, "NOTE: not using codec time base (%d/%d) for pts "
+ "adjustment; the stream base (%d/%d) is worse.\n",
+ (int)ac->stream->codec->time_base.num,
+ (int)ac->stream->codec->time_base.den,
+ (int)ac->stream->time_base.num,
+ (int)ac->stream->time_base.den);
ac->worst_time_base = ac->stream->time_base;
ac->worst_time_base_is_stream = 1;
}
@@ -596,7 +583,7 @@ static int play(struct ao *ao, void *data, int len, int flags)
*/
int finalbufpos = len - (len - bufpos) % ac->aframesize;
if (finalbufpos < 0) {
- mp_msg(MSGT_ENCODE, MSGL_WARN, "ao-lavc: cannot attain the "
+ MP_WARN(ao, "cannot attain the "
"exact requested audio sync; shifting by %d frames\n",
-finalbufpos);
bufpos -= finalbufpos;
@@ -611,8 +598,7 @@ static int play(struct ao *ao, void *data, int len, int flags)
ectx->discontinuity_pts_offset = ectx->next_in_pts - nextpts;
}
else if (fabs(nextpts + ectx->discontinuity_pts_offset - ectx->next_in_pts) > 30) {
- mp_msg(MSGT_ENCODE, MSGL_WARN,
- "ao-lavc: detected an unexpected discontinuity (pts jumped by "
+ MP_WARN(ao, "detected an unexpected discontinuity (pts jumped by "
"%f seconds)\n",
nextpts + ectx->discontinuity_pts_offset - ectx->next_in_pts);
ectx->discontinuity_pts_offset = ectx->next_in_pts - nextpts;
diff --git a/audio/out/ao_openal.c b/audio/out/ao_openal.c
index 1f9115a471..599672658d 100644
--- a/audio/out/ao_openal.c
+++ b/audio/out/ao_openal.c
@@ -127,7 +127,7 @@ static int init(struct ao *ao)
int i;
struct priv *p = ao->priv;
if (ao_data) {
- mp_msg(MSGT_AO, MSGL_FATAL, "[OpenAL] Not reentrant!\n");
+ MP_FATAL(ao, "Not reentrant!\n");
return -1;
}
ao_data = ao;
@@ -145,13 +145,13 @@ static int init(struct ao *ao)
speakers[i] = speaker_pos[n];
}
if (speakers[i].id < 0) {
- mp_msg(MSGT_AO, MSGL_FATAL, "[OpenAL] Unknown channel layout\n");
+ MP_FATAL(ao, "Unknown channel layout\n");
goto err_out;
}
}
dev = alcOpenDevice(p->cfg_device && p->cfg_device[0] ? p->cfg_device : NULL);
if (!dev) {
- mp_msg(MSGT_AO, MSGL_FATAL, "[OpenAL] could not open device\n");
+ MP_FATAL(ao, "could not open device\n");
goto err_out;
}
ctx = alcCreateContext(dev, attribs);
diff --git a/audio/out/ao_pcm.c b/audio/out/ao_pcm.c
index 207b75fddd..b1e3a79708 100644
--- a/audio/out/ao_pcm.c
+++ b/audio/out/ao_pcm.c
@@ -141,19 +141,16 @@ static int init(struct ao *ao)
ao->bps = ao->channels.num * ao->samplerate * (af_fmt2bits(ao->format) / 8);
- mp_tmsg(MSGT_AO, MSGL_INFO, "[AO PCM] File: %s (%s)\n"
- "PCM: Samplerate: %d Hz Channels: %d Format: %s\n",
+ MP_INFO(ao, "File: %s (%s)\nPCM: Samplerate: %d Hz Channels: %d Format: %s\n",
priv->outputfilename,
priv->waveheader ? "WAVE" : "RAW PCM", ao->samplerate,
ao->channels.num, af_fmt2str_short(ao->format));
- mp_tmsg(MSGT_AO, MSGL_INFO,
- "[AO PCM] Info: Faster dumping is achieved with -no-video\n"
- "[AO PCM] Info: To write WAVE files use -ao pcm:waveheader (default).\n");
+ MP_INFO(ao, "Info: Faster dumping is achieved with -no-video\n");
+ MP_INFO(ao, "Info: To write WAVE files use -ao pcm:waveheader (default).\n");
priv->fp = fopen(priv->outputfilename, "wb");
if (!priv->fp) {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO PCM] Failed to open %s for writing!\n",
- priv->outputfilename);
+ MP_ERR(ao, "Failed to open %s for writing!\n", priv->outputfilename);
return -1;
}
if (priv->waveheader) // Reserve space for wave header
@@ -177,11 +174,10 @@ static void uninit(struct ao *ao, bool cut_audio)
GetFileType((HANDLE)_get_osfhandle(_fileno(priv->fp)));
#endif
if (broken_seek || fseek(priv->fp, 0, SEEK_SET) != 0)
- mp_msg(MSGT_AO, MSGL_ERR, "Could not seek to start, "
- "WAV size headers not updated!\n");
+ MP_ERR(ao, "Could not seek to start, WAV size headers not updated!\n");
else {
if (priv->data_length > 0xfffff000) {
- mp_msg(MSGT_AO, MSGL_ERR, "File larger than allowed for "
+ MP_ERR(ao, "File larger than allowed for "
"WAV files, may play truncated!\n");
priv->data_length = 0xfffff000;
}
diff --git a/audio/out/ao_portaudio.c b/audio/out/ao_portaudio.c
index b80549398f..c9f55646a3 100644
--- a/audio/out/ao_portaudio.c
+++ b/audio/out/ao_portaudio.c
@@ -68,11 +68,11 @@ static const struct format_map format_maps[] = {
static bool check_pa_ret(int ret)
{
if (ret < 0) {
- mp_msg(MSGT_AO, MSGL_ERR, "[portaudio] %s\n",
+ mp_msg(MSGT_AO, MSGL_ERR, "[ao/portaudio] %s\n",
Pa_GetErrorText(ret));
if (ret == paUnanticipatedHostError) {
const PaHostErrorInfo* hosterr = Pa_GetLastHostErrorInfo();
- mp_msg(MSGT_AO, MSGL_ERR, "[portaudio] Host error: %s\n",
+ mp_msg(MSGT_AO, MSGL_ERR, "[ao/portaudio] Host error: %s\n",
hosterr->errorText);
}
return false;
@@ -121,7 +121,7 @@ static int find_device(const char *name)
}
}
if (found == paNoDevice && !help)
- mp_msg(MSGT_AO, MSGL_WARN, "[portaudio] Device '%s' not found!\n",
+ mp_msg(MSGT_AO, MSGL_WARN, "[ao/portaudio] Device '%s' not found!\n",
name);
return found;
}
@@ -183,7 +183,7 @@ static int stream_callback(const void *input,
res = paComplete;
priv->play_remaining = false;
} else {
- mp_msg(MSGT_AO, MSGL_ERR, "[portaudio] Buffer underflow!\n");
+ MP_ERR(ao, "Buffer underflow!\n");
}
fill_silence(output, len_bytes);
}
@@ -253,8 +253,7 @@ static int init(struct ao *ao)
fmt++;
}
if (!fmt->pa_format) {
- mp_msg(MSGT_AO, MSGL_V,
- "[portaudio] Unsupported format, using default.\n");
+ MP_VERBOSE(ao, "Unsupported format, using default.\n");
fmt = format_maps;
}
diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c
index 0a7d5347ba..7124ea34b4 100644
--- a/audio/out/ao_pulse.c
+++ b/audio/out/ao_pulse.c
@@ -57,9 +57,9 @@ struct priv {
char *cfg_sink;
};
-#define GENERIC_ERR_MSG(ctx, str) \
- mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] "str": %s\n", \
- pa_strerror(pa_context_errno(ctx)))
+#define GENERIC_ERR_MSG(str) \
+ MP_ERR(ao, str": %s\n", \
+ pa_strerror(pa_context_errno(((struct priv *)ao->priv)->context)))
static void context_state_cb(pa_context *c, void *userdata)
{
@@ -247,20 +247,19 @@ static int init(struct ao *ao)
* hangs somewhen. */
if (strncmp(version, "0.9.1", 5) == 0 && version[5] >= '1'
&& version[5] <= '4') {
- mp_msg(MSGT_AO, MSGL_WARN,
- "[pulse] working around probably broken pause functionality,\n"
- " see http://www.pulseaudio.org/ticket/440\n");
+ MP_WARN(ao, "working around probably broken pause functionality,\n"
+ " see http://www.pulseaudio.org/ticket/440\n");
priv->broken_pause = true;
}
if (!(priv->mainloop = pa_threaded_mainloop_new())) {
- mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] Failed to allocate main loop\n");
+ MP_ERR(ao, "Failed to allocate main loop\n");
goto fail;
}
if (!(priv->context = pa_context_new(pa_threaded_mainloop_get_api(
priv->mainloop), PULSE_CLIENT_NAME))) {
- mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] Failed to allocate context\n");
+ MP_ERR(ao, "Failed to allocate context\n");
goto fail;
}
@@ -286,8 +285,7 @@ static int init(struct ao *ao)
const struct format_map *fmt_map = format_maps;
while (fmt_map->mp_format != ao->format) {
if (fmt_map->mp_format == AF_FORMAT_UNKNOWN) {
- mp_msg(MSGT_AO, MSGL_V,
- "AO: [pulse] Unsupported format, using default\n");
+ MP_VERBOSE(ao, "Unsupported format, using default\n");
fmt_map = format_maps;
break;
}
@@ -297,7 +295,7 @@ static int init(struct ao *ao)
ss.format = fmt_map->pa_format;
if (!pa_sample_spec_valid(&ss)) {
- mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] Invalid sample spec\n");
+ MP_ERR(ao, "Invalid sample spec\n");
goto fail;
}
@@ -342,7 +340,7 @@ fail:
if (priv->context) {
if (!(pa_context_errno(priv->context) == PA_ERR_CONNECTIONREFUSED
&& ao->probing))
- GENERIC_ERR_MSG(priv->context, "Init failed");
+ GENERIC_ERR_MSG("Init failed");
}
uninit(ao, true);
return -1;
@@ -355,7 +353,7 @@ static void cork(struct ao *ao, bool pause)
priv->retval = 0;
if (!waitop(priv, pa_stream_cork(priv->stream, pause, success_cb, ao)) ||
!priv->retval)
- GENERIC_ERR_MSG(priv->context, "pa_stream_cork() failed");
+ GENERIC_ERR_MSG("pa_stream_cork() failed");
}
// Play the specified data to the pulseaudio server
@@ -365,7 +363,7 @@ static int play(struct ao *ao, void *data, int len, int flags)
pa_threaded_mainloop_lock(priv->mainloop);
if (pa_stream_write(priv->stream, data, len, NULL, 0,
PA_SEEK_RELATIVE) < 0) {
- GENERIC_ERR_MSG(priv->context, "pa_stream_write() failed");
+ GENERIC_ERR_MSG("pa_stream_write() failed");
len = -1;
}
if (flags & AOPLAY_FINAL_CHUNK) {
@@ -387,7 +385,7 @@ static void reset(struct ao *ao)
priv->retval = 0;
if (!waitop(priv, pa_stream_flush(priv->stream, success_cb, ao)) ||
!priv->retval)
- GENERIC_ERR_MSG(priv->context, "pa_stream_flush() failed");
+ GENERIC_ERR_MSG("pa_stream_flush() failed");
cork(ao, false);
}
@@ -438,20 +436,20 @@ static float get_delay(struct ao *ao)
struct priv *priv = ao->priv;
pa_threaded_mainloop_lock(priv->mainloop);
if (!waitop(priv, pa_stream_update_timing_info(priv->stream, NULL, NULL))) {
- GENERIC_ERR_MSG(priv->context, "pa_stream_update_timing_info() failed");
+ GENERIC_ERR_MSG("pa_stream_update_timing_info() failed");
return 0;
}
pa_threaded_mainloop_lock(priv->mainloop);
const pa_timing_info *ti = pa_stream_get_timing_info(priv->stream);
if (!ti) {
pa_threaded_mainloop_unlock(priv->mainloop);
- GENERIC_ERR_MSG(priv->context, "pa_stream_get_timing_info() failed");
+ GENERIC_ERR_MSG("pa_stream_get_timing_info() failed");
return 0;
}
const struct pa_sample_spec *ss = pa_stream_get_sample_spec(priv->stream);
if (!ss) {
pa_threaded_mainloop_unlock(priv->mainloop);
- GENERIC_ERR_MSG(priv->context, "pa_stream_get_sample_spec() failed");
+ GENERIC_ERR_MSG("pa_stream_get_sample_spec() failed");
return 0;
}
// data left in PulseAudio's main buffers (not written to sink yet)
@@ -485,7 +483,7 @@ static void info_func(struct pa_context *c, const struct pa_sink_input_info *i,
struct ao *ao = userdata;
struct priv *priv = ao->priv;
if (is_last < 0) {
- GENERIC_ERR_MSG(priv->context, "Failed to get sink input info");
+ GENERIC_ERR_MSG("Failed to get sink input info");
return;
}
if (!i)
@@ -504,8 +502,7 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
pa_threaded_mainloop_lock(priv->mainloop);
if (!waitop(priv, pa_context_get_sink_input_info(priv->context, devidx,
info_func, ao))) {
- GENERIC_ERR_MSG(priv->context,
- "pa_stream_get_sink_input_info() failed");
+ GENERIC_ERR_MSG("pa_stream_get_sink_input_info() failed");
return CONTROL_ERROR;
}
// Warning: some information in pi might be unaccessible, because
@@ -548,8 +545,7 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
&volume, NULL, NULL);
if (!o) {
pa_threaded_mainloop_unlock(priv->mainloop);
- GENERIC_ERR_MSG(priv->context,
- "pa_context_set_sink_input_volume() failed");
+ GENERIC_ERR_MSG("pa_context_set_sink_input_volume() failed");
return CONTROL_ERROR;
}
} else if (cmd == AOCONTROL_SET_MUTE) {
@@ -558,8 +554,7 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
*mute, NULL, NULL);
if (!o) {
pa_threaded_mainloop_unlock(priv->mainloop);
- GENERIC_ERR_MSG(priv->context,
- "pa_context_set_sink_input_mute() failed");
+ GENERIC_ERR_MSG("pa_context_set_sink_input_mute() failed");
return CONTROL_ERROR;
}
} else
diff --git a/audio/out/ao_sdl.c b/audio/out/ao_sdl.c
index 231b40681a..4ca153b4dd 100644
--- a/audio/out/ao_sdl.c
+++ b/audio/out/ao_sdl.c
@@ -124,7 +124,7 @@ static unsigned int ceil_power_of_two(unsigned int x)
static int init(struct ao *ao)
{
if (SDL_WasInit(SDL_INIT_AUDIO)) {
- mp_msg(MSGT_AO, MSGL_ERR, "[sdl] already initialized\n");
+ MP_ERR(ao, "already initialized\n");
return -1;
}
@@ -132,7 +132,7 @@ static int init(struct ao *ao)
if (SDL_InitSubSystem(SDL_INIT_AUDIO)) {
if (!ao->probing)
- mp_msg(MSGT_AO, MSGL_ERR, "[sdl] SDL_Init failed\n");
+ MP_ERR(ao, "SDL_Init failed\n");
uninit(ao, true);
return -1;
}
@@ -174,24 +174,23 @@ static int init(struct ao *ao)
desired.callback = audio_callback;
desired.userdata = ao;
- mp_msg(MSGT_AO, MSGL_V, "[sdl] requested format: %d Hz, %d channels, %x, "
- "buffer size: %d samples\n",
- (int) desired.freq, (int) desired.channels,
- (int) desired.format, (int) desired.samples);
+ MP_VERBOSE(ao, "requested format: %d Hz, %d channels, %x, "
+ "buffer size: %d samples\n",
+ (int) desired.freq, (int) desired.channels,
+ (int) desired.format, (int) desired.samples);
obtained = desired;
if (SDL_OpenAudio(&desired, &obtained)) {
if (!ao->probing)
- mp_msg(MSGT_AO, MSGL_ERR, "[sdl] could not open audio: %s\n",
- SDL_GetError());
+ MP_ERR(ao, "could not open audio: %s\n", SDL_GetError());
uninit(ao, true);
return -1;
}
- mp_msg(MSGT_AO, MSGL_V, "[sdl] obtained format: %d Hz, %d channels, %x, "
- "buffer size: %d samples\n",
- (int) obtained.freq, (int) obtained.channels,
- (int) obtained.format, (int) obtained.samples);
+ MP_VERBOSE(ao, "obtained format: %d Hz, %d channels, %x, "
+ "buffer size: %d samples\n",
+ (int) obtained.freq, (int) obtained.channels,
+ (int) obtained.format, (int) obtained.samples);
switch (obtained.format) {
case AUDIO_U8: ao->format = AF_FORMAT_U8; break;
@@ -214,8 +213,7 @@ static int init(struct ao *ao)
#endif
default:
if (!ao->probing)
- mp_msg(MSGT_AO, MSGL_ERR,
- "[sdl] could not find matching format\n");
+ MP_ERR(ao, "could not find matching format\n");
uninit(ao, true);
return -1;
}
@@ -229,13 +227,13 @@ static int init(struct ao *ao)
priv->buffer = av_fifo_alloc(obtained.size * priv->bufcnt);
priv->buffer_mutex = SDL_CreateMutex();
if (!priv->buffer_mutex) {
- mp_msg(MSGT_AO, MSGL_ERR, "[sdl] SDL_CreateMutex failed\n");
+ MP_ERR(ao, "SDL_CreateMutex failed\n");
uninit(ao, true);
return -1;
}
priv->underrun_cond = SDL_CreateCond();
if (!priv->underrun_cond) {
- mp_msg(MSGT_AO, MSGL_ERR, "[sdl] SDL_CreateCond failed\n");
+ MP_ERR(ao, "SDL_CreateCond failed\n");
uninit(ao, true);
return -1;
}