From 4abe6b862f07d4d2dfa75791c9fdd97ccbc8aeaa Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 21 Dec 2013 18:19:47 +0100 Subject: mixer: mp_msg conversions --- audio/mixer.c | 21 ++++++++++----------- audio/mixer.h | 4 ++-- player/main.c | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/audio/mixer.c b/audio/mixer.c index b3ba9c3a58..162d9d5a0a 100644 --- a/audio/mixer.c +++ b/audio/mixer.c @@ -24,11 +24,13 @@ #include "config.h" #include "audio/out/ao.h" #include "audio/filter/af.h" +#include "common/global.h" #include "common/msg.h" #include "talloc.h" #include "mixer.h" struct mixer { + struct mp_log *log; struct MPOpts *opts; struct ao *ao; struct af_stream *af; @@ -47,11 +49,12 @@ struct mixer { float balance; }; -struct mixer *mixer_init(void *talloc_ctx, struct MPOpts *opts) +struct mixer *mixer_init(void *talloc_ctx, struct mpv_global *global) { struct mixer *mixer = talloc_ptrtype(talloc_ctx, mixer); *mixer = (struct mixer) { - .opts = opts, + .log = mp_log_new(mixer, global->log, "mixer"), + .opts = global->opts, .vol_l = 100, .vol_r = 100, .driver = "", @@ -113,17 +116,15 @@ static void setvolume_internal(struct mixer *mixer, float l, float r) struct ao_control_vol vol = {.left = l, .right = r}; if (!mixer->softvol) { if (ao_control(mixer->ao, AOCONTROL_SET_VOLUME, &vol) != CONTROL_OK) - mp_msg(MSGT_GLOBAL, MSGL_ERR, - "[Mixer] Failed to change audio output volume.\n"); + MP_ERR(mixer, "Failed to change audio output volume.\n"); return; } float gain = (l + r) / 2.0 / 100.0 * mixer->opts->softvol_max / 100.0; if (!af_control_any_rev(mixer->af, AF_CONTROL_SET_VOLUME, &gain)) { - mp_msg(MSGT_GLOBAL, MSGL_V, "[Mixer] Inserting volume filter.\n"); + MP_VERBOSE(mixer, "Inserting volume filter.\n"); if (!(af_add(mixer->af, "volume", NULL) && af_control_any_rev(mixer->af, AF_CONTROL_SET_VOLUME, &gain))) - mp_msg(MSGT_GLOBAL, MSGL_ERR, - "[Mixer] No volume control available.\n"); + MP_ERR(mixer, "No volume control available.\n"); } } @@ -223,8 +224,7 @@ void mixer_setbalance(struct mixer *mixer, float val) return; if (!(af_pan_balance = af_add(mixer->af, "pan", NULL))) { - mp_msg(MSGT_GLOBAL, MSGL_ERR, - "[Mixer] No balance control available.\n"); + MP_ERR(mixer, "No balance control available.\n"); return; } @@ -264,8 +264,7 @@ static void probe_softvol(struct mixer *mixer) ao_control_vol_t vol; if (ao_control(mixer->ao, AOCONTROL_GET_VOLUME, &vol) != CONTROL_OK) { mixer->softvol = true; - mp_msg(MSGT_GLOBAL, MSGL_WARN, - "[mixer] Hardware volume control unavailable.\n"); + MP_WARN(mixer, "Hardware volume control unavailable.\n"); } } diff --git a/audio/mixer.h b/audio/mixer.h index e2e574c22e..7a14e0b23e 100644 --- a/audio/mixer.h +++ b/audio/mixer.h @@ -28,12 +28,12 @@ enum { SOFTVOL_AUTO = 2, }; -struct MPOpts; +struct mpv_global; struct ao; struct af_stream; struct mixer; -struct mixer *mixer_init(void *talloc_ctx, struct MPOpts *opts); +struct mixer *mixer_init(void *talloc_ctx, struct mpv_global *global); void mixer_reinit_audio(struct mixer *mixer, struct ao *ao, struct af_stream *af); void mixer_uninit_audio(struct mixer *mixer); bool mixer_audio_initialized(struct mixer *mixer); diff --git a/player/main.c b/player/main.c index acff77f94d..ab3e7b93f9 100644 --- a/player/main.c +++ b/player/main.c @@ -333,7 +333,7 @@ static int mpv_main(int argc, char *argv[]) init_libav(); GetCpuCaps(&gCpuCaps); screenshot_init(mpctx); - mpctx->mixer = mixer_init(mpctx, opts); + mpctx->mixer = mixer_init(mpctx, mpctx->global); command_init(mpctx); // Preparse the command line -- cgit v1.2.3