summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-08-23 23:30:09 +0200
committerwm4 <wm4@nowhere>2013-08-23 23:30:09 +0200
commit0d8a62c08da87f6cfb5c45a86ee87c414c33323e (patch)
tree41091ca7dd1e3809f91a377d5f28b6594085df69 /audio
parent11a7a8b30b0c7a5ab5468385d3d43c64b24ddc9a (diff)
downloadmpv-0d8a62c08da87f6cfb5c45a86ee87c414c33323e.tar.bz2
mpv-0d8a62c08da87f6cfb5c45a86ee87c414c33323e.tar.xz
Some more mp_msg conversions
Also add a note to mp_msg.h, since it might be not clear which of the two mechanisms is preferred.
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao_dsound.c72
-rw-r--r--audio/out/ao_oss.c90
2 files changed, 61 insertions, 101 deletions
diff --git a/audio/out/ao_dsound.c b/audio/out/ao_dsound.c
index 039df2a7ed..3002b67dcc 100644
--- a/audio/out/ao_dsound.c
+++ b/audio/out/ao_dsound.c
@@ -152,25 +152,10 @@ static void UninitDirectSound(struct ao *ao)
FreeLibrary(p->hdsound_dll);
p->hdsound_dll = NULL;
}
- mp_msg(MSGT_AO, MSGL_V, "ao_dsound: DirectSound uninitialized\n");
+ MP_VERBOSE(ao, "DirectSound uninitialized\n");
}
/**
-\brief print the commandline help
-*/
-static void print_help(void)
-{
- mp_msg(MSGT_AO, MSGL_FATAL,
- "\n-ao dsound commandline help:\n"
- "Example: mpv -ao dsound:device=1\n"
- " sets 1st device\n"
- "\nOptions:\n"
- " device=<device-number>\n"
- " Sets device number, use -v to get a list\n");
-}
-
-
-/**
\brief enumerate direct sound devices
\return TRUE to continue with the enumeration
*/
@@ -180,13 +165,13 @@ static BOOL CALLBACK DirectSoundEnum(LPGUID guid, LPCSTR desc, LPCSTR module,
struct ao *ao = context;
struct priv *p = ao->priv;
- mp_msg(MSGT_AO, MSGL_V, "%i %s ", p->device_index, desc);
+ MP_VERBOSE(ao, "%i %s ", p->device_index, desc);
if (p->device_num == p->device_index) {
- mp_msg(MSGT_AO, MSGL_V, "<--");
+ MP_VERBOSE(ao, "<--");
if (guid)
memcpy(&p->device, guid, sizeof(GUID));
}
- mp_msg(MSGT_AO, MSGL_V, "\n");
+ MP_VERBOSE(ao, "\n");
p->device_index++;
return TRUE;
}
@@ -210,7 +195,7 @@ static int InitDirectSound(struct ao *ao)
p->hdsound_dll = LoadLibrary("DSOUND.DLL");
if (p->hdsound_dll == NULL) {
- mp_msg(MSGT_AO, MSGL_ERR, "ao_dsound: cannot load DSOUND.DLL\n");
+ MP_ERR(ao, "cannot load DSOUND.DLL\n");
return 0;
}
OurDirectSoundCreate = (void *)GetProcAddress(p->hdsound_dll,
@@ -219,21 +204,20 @@ static int InitDirectSound(struct ao *ao)
"DirectSoundEnumerateA");
if (OurDirectSoundCreate == NULL || OurDirectSoundEnumerate == NULL) {
- mp_msg(MSGT_AO, MSGL_ERR, "ao_dsound: GetProcAddress FAILED\n");
+ MP_ERR(ao, "GetProcAddress FAILED\n");
FreeLibrary(p->hdsound_dll);
return 0;
}
// Enumerate all directsound p->devices
- mp_msg(MSGT_AO, MSGL_V, "ao_dsound: Output Devices:\n");
+ MP_VERBOSE(ao, "Output Devices:\n");
OurDirectSoundEnumerate(DirectSoundEnum, ao);
// Create the direct sound object
if (FAILED(OurDirectSoundCreate((p->device_num) ? &p->device : NULL,
&p->hds, NULL)))
{
- mp_msg(MSGT_AO, MSGL_ERR,
- "ao_dsound: cannot create a DirectSound device\n");
+ MP_ERR(ao, "cannot create a DirectSound device\n");
FreeLibrary(p->hdsound_dll);
return 0;
}
@@ -251,22 +235,20 @@ static int InitDirectSound(struct ao *ao)
if (IDirectSound_SetCooperativeLevel(p->hds, GetDesktopWindow(),
DSSCL_EXCLUSIVE))
{
- mp_msg(MSGT_AO, MSGL_ERR,
- "ao_dsound: cannot set direct sound cooperative level\n");
+ MP_ERR(ao, "cannot set direct sound cooperative level\n");
IDirectSound_Release(p->hds);
FreeLibrary(p->hdsound_dll);
return 0;
}
- mp_msg(MSGT_AO, MSGL_V, "ao_dsound: DirectSound initialized\n");
+ MP_VERBOSE(ao, "DirectSound initialized\n");
memset(&dscaps, 0, sizeof(DSCAPS));
dscaps.dwSize = sizeof(DSCAPS);
if (DS_OK == IDirectSound_GetCaps(p->hds, &dscaps)) {
if (dscaps.dwFlags & DSCAPS_EMULDRIVER)
- mp_msg(MSGT_AO, MSGL_V,
- "ao_dsound: DirectSound is emulated, waveOut may give better performance\n");
+ MP_VERBOSE(ao, "DirectSound is emulated\n");
} else {
- mp_msg(MSGT_AO, MSGL_V, "ao_dsound: cannot get device capabilities\n");
+ MP_VERBOSE(ao, "cannot get device capabilities\n");
}
return 1;
@@ -424,9 +406,8 @@ static int init(struct ao *ao)
case AF_FORMAT_U8:
break;
default:
- mp_msg(MSGT_AO, MSGL_V,
- "ao_dsound: format %s not supported defaulting to Signed 16-bit Little-Endian\n",
- af_fmt2str_short(format));
+ MP_VERBOSE(ao, "format %s not supported defaulting to Signed 16-bit Little-Endian\n",
+ af_fmt2str_short(format));
format = AF_FORMAT_S16_LE;
}
//set our audio parameters
@@ -434,11 +415,10 @@ static int init(struct ao *ao)
ao->format = format;
ao->bps = ao->channels.num * rate * (af_fmt2bits(format) >> 3);
int buffersize = ao->bps; // space for 1 sec
- mp_msg(MSGT_AO, MSGL_V,
- "ao_dsound: Samplerate:%iHz Channels:%i Format:%s\n", rate,
- ao->channels.num, af_fmt2str_short(format));
- mp_msg(MSGT_AO, MSGL_V, "ao_dsound: Buffersize:%d bytes (%d msec)\n",
- buffersize, buffersize / ao->bps * 1000);
+ MP_VERBOSE(ao, "Samplerate:%iHz Channels:%i Format:%s\n", rate,
+ ao->channels.num, af_fmt2str_short(format));
+ MP_VERBOSE(ao, "Buffersize:%d bytes (%d msec)\n",
+ buffersize, buffersize / ao->bps * 1000);
//fill waveformatex
ZeroMemory(&wformat, sizeof(WAVEFORMATEXTENSIBLE));
@@ -494,19 +474,16 @@ static int init(struct ao *ao)
res = IDirectSound_CreateSoundBuffer(p->hds, &dsbpridesc, &p->hdspribuf, NULL);
if (res != DS_OK) {
UninitDirectSound(ao);
- mp_msg(MSGT_AO, MSGL_ERR,
- "ao_dsound: cannot create primary buffer (%s)\n",
- dserr2str(res));
+ MP_ERR(ao, "cannot create primary buffer (%s)\n", dserr2str(res));
return -1;
}
res = IDirectSoundBuffer_SetFormat(p->hdspribuf, (WAVEFORMATEX *)&wformat);
if (res != DS_OK) {
- mp_msg(MSGT_AO, MSGL_WARN,
- "ao_dsound: cannot set primary buffer format (%s), using "
- "standard setting (bad quality)", dserr2str(res));
+ MP_WARN(ao, "cannot set primary buffer format (%s), using "
+ "standard setting (bad quality)", dserr2str(res));
}
- mp_msg(MSGT_AO, MSGL_V, "ao_dsound: primary buffer created\n");
+ MP_VERBOSE(ao, "primary buffer created\n");
// now create the stream buffer
@@ -519,13 +496,12 @@ static int init(struct ao *ao)
}
if (res != DS_OK) {
UninitDirectSound(ao);
- mp_msg(MSGT_AO, MSGL_ERR,
- "ao_dsound: cannot create secondary (stream)buffer (%s)\n",
+ MP_ERR(ao, "cannot create secondary (stream)buffer (%s)\n",
dserr2str(res));
return -1;
}
}
- mp_msg(MSGT_AO, MSGL_V, "ao_dsound: secondary (stream)buffer created\n");
+ MP_VERBOSE(ao, "secondary (stream)buffer created\n");
return 0;
}
diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c
index 0e17bcb632..79b96c7bc1 100644
--- a/audio/out/ao_oss.c
+++ b/audio/out/ao_oss.c
@@ -107,8 +107,6 @@ static int format2oss(int format)
if (format_table[n][1] == format)
return format_table[n][0];
}
- mp_msg(MSGT_AO, MSGL_V, "OSS: Unknown/not supported internal format: %s\n",
- af_fmt2str_short(format));
return -1;
}
@@ -118,8 +116,6 @@ static int oss2format(int format)
if (format_table[n][0] == format)
return format_table[n][1];
}
- mp_tmsg(MSGT_GLOBAL, MSGL_ERR, "[AO OSS] Unknown/Unsupported OSS format: %x.\n",
- format);
return -1;
}
@@ -204,16 +200,15 @@ static int init(struct ao *ao)
if (p->cfg_oss_mixer_channel && p->cfg_oss_mixer_channel[0])
mchan = p->cfg_oss_mixer_channel;
- mp_msg(MSGT_AO, MSGL_V, "ao2: %d Hz %d chans %s\n", ao->samplerate,
- ao->channels.num, af_fmt2str_short(ao->format));
+ MP_VERBOSE(ao, "%d Hz %d chans %s\n", ao->samplerate,
+ ao->channels.num, af_fmt2str_short(ao->format));
if (mchan) {
int fd, devs, i;
if ((fd = open(p->oss_mixer_device, O_RDONLY)) == -1) {
- mp_tmsg(MSGT_AO, MSGL_ERR,
- "[AO OSS] audio_setup: Can't open mixer device %s: %s\n",
- p->oss_mixer_device, strerror(errno));
+ MP_ERR(ao, "Can't open mixer device %s: %s\n",
+ p->oss_mixer_device, strerror(errno));
} else {
ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devs);
close(fd);
@@ -221,9 +216,8 @@ static int init(struct ao *ao)
for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
if (!strcasecmp(mixer_channels[i], mchan)) {
if (!(devs & (1 << i))) {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO OSS] audio_setup: "
- "Audio card mixer does not have channel '%s', "
- "using default.\n", mchan);
+ MP_ERR(ao, "Audio card mixer does not have "
+ "channel '%s', using default.\n", mchan);
i = SOUND_MIXER_NRDEVICES + 1;
break;
}
@@ -232,20 +226,17 @@ static int init(struct ao *ao)
}
}
if (i == SOUND_MIXER_NRDEVICES) {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO OSS] audio_setup: Audio card "
- "mixer does not have channel '%s', using default.\n",
- mchan);
+ MP_ERR(ao, "Audio card mixer does not have "
+ "channel '%s', using default.\n", mchan);
}
}
} else {
p->oss_mixer_channel = SOUND_MIXER_PCM;
}
- mp_msg(MSGT_AO, MSGL_V, "audio_setup: using '%s' dsp device\n", p->dsp);
- mp_msg(MSGT_AO, MSGL_V, "audio_setup: using '%s' mixer device\n",
- p->oss_mixer_device);
- mp_msg(MSGT_AO, MSGL_V, "audio_setup: using '%s' mixer device\n",
- mixer_channels[p->oss_mixer_channel]);
+ MP_VERBOSE(ao, "using '%s' dsp device\n", p->dsp);
+ MP_VERBOSE(ao, "using '%s' mixer device\n", p->oss_mixer_device);
+ MP_VERBOSE(ao, "using '%s' mixer device\n", mixer_channels[p->oss_mixer_channel]);
#ifdef __linux__
p->audio_fd = open(p->dsp, O_WRONLY | O_NONBLOCK);
@@ -253,17 +244,14 @@ static int init(struct ao *ao)
p->audio_fd = open(p->dsp, O_WRONLY);
#endif
if (p->audio_fd < 0) {
- mp_tmsg(MSGT_AO, MSGL_ERR,
- "[AO OSS] audio_setup: Can't open audio device %s: %s\n",
- p->dsp, strerror(errno));
+ MP_ERR(ao, "Can't open audio device %s: %s\n", p->dsp, strerror(errno));
return -1;
}
#ifdef __linux__
/* Remove the non-blocking flag */
if (fcntl(p->audio_fd, F_SETFL, 0) < 0) {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO OSS] audio_setup: Can't make file "
- "descriptor blocking: %s\n", strerror(errno));
+ MP_ERR(ao, "Can't make file descriptor blocking: %s\n", strerror(errno));
return -1;
}
#endif
@@ -281,6 +269,8 @@ ac3_retry:
ao->format = AF_FORMAT_AC3_NE;
oss_format = format2oss(ao->format);
if (oss_format == -1) {
+ MP_VERBOSE(ao, "Unknown/not supported internal format: %s\n",
+ af_fmt2str_short(ao->format));
#if BYTE_ORDER == BIG_ENDIAN
oss_format = AFMT_S16_BE;
#else
@@ -291,19 +281,20 @@ ac3_retry:
if (ioctl(p->audio_fd, SNDCTL_DSP_SETFMT, &oss_format) < 0 ||
oss_format != format2oss(ao->format))
{
- mp_tmsg(MSGT_AO, MSGL_WARN, "[AO OSS] Can't set audio device %s to %s "
- "output, trying %s...\n", p->dsp, af_fmt2str_short(ao->format),
+ MP_WARN(ao, "Can't set audio device %s to %s output, trying %s...\n",
+ p->dsp, af_fmt2str_short(ao->format),
af_fmt2str_short(AF_FORMAT_S16_NE));
ao->format = AF_FORMAT_S16_NE;
goto ac3_retry;
}
ao->format = oss2format(oss_format);
- if (ao->format == -1)
+ if (ao->format == -1) {
+ MP_ERR(ao, "Unknown/Unsupported OSS format: %x.\n", oss_format);
return -1;
+ }
- mp_msg(MSGT_AO, MSGL_V, "audio_setup: sample format: %s\n",
- af_fmt2str_short(ao->format));
+ MP_VERBOSE(ao, "sample format: %s\n", af_fmt2str_short(ao->format));
if (!AF_FORMAT_IS_AC3(ao->format)) {
struct mp_chmap_sel sel = {0};
@@ -317,45 +308,39 @@ ac3_retry:
if (ioctl(p->audio_fd, SNDCTL_DSP_CHANNELS, &nchannels) == -1 ||
nchannels != reqchannels)
{
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO OSS] audio_setup: Failed to "
- "set audio device to %d channels.\n", reqchannels);
+ MP_ERR(ao, "Failed to set audio device to %d channels.\n",
+ reqchannels);
return -1;
}
} else {
int c = reqchannels - 1;
if (ioctl(p->audio_fd, SNDCTL_DSP_STEREO, &c) == -1) {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO OSS] audio_setup: Failed to "
- "set audio device to %d channels.\n", reqchannels);
+ MP_ERR(ao, "Failed to set audio device to %d channels.\n",
+ reqchannels);
return -1;
}
if (!ao_chmap_sel_get_def(ao, &sel, &ao->channels, c + 1))
return -1;
}
- mp_msg(MSGT_AO, MSGL_V,
- "audio_setup: using %d channels (requested: %d)\n",
- ao->channels.num, reqchannels);
+ MP_VERBOSE(ao, "using %d channels (requested: %d)\n",
+ ao->channels.num, reqchannels);
// set rate
ioctl(p->audio_fd, SNDCTL_DSP_SPEED, &ao->samplerate);
- mp_msg(MSGT_AO, MSGL_V, "audio_setup: using %d Hz samplerate\n",
- ao->samplerate);
+ MP_VERBOSE(ao, "using %d Hz samplerate\n", ao->samplerate);
}
if (ioctl(p->audio_fd, SNDCTL_DSP_GETOSPACE, &p->zz) == -1) {
int r = 0;
- mp_tmsg(MSGT_AO, MSGL_WARN, "[AO OSS] audio_setup: driver doesn't "
- "support SNDCTL_DSP_GETOSPACE\n");
+ MP_WARN(ao, "driver doesn't support SNDCTL_DSP_GETOSPACE\n");
if (ioctl(p->audio_fd, SNDCTL_DSP_GETBLKSIZE, &r) == -1)
- mp_msg(MSGT_AO, MSGL_V, "audio_setup: %d bytes/frag (config.h)\n",
- p->outburst);
+ MP_VERBOSE(ao, "%d bytes/frag (config.h)\n", p->outburst);
else {
p->outburst = r;
- mp_msg(MSGT_AO, MSGL_V, "audio_setup: %d bytes/frag (GETBLKSIZE)\n",
- p->outburst);
+ MP_VERBOSE(ao, "%d bytes/frag (GETBLKSIZE)\n", p->outburst);
}
} else {
- mp_msg(MSGT_AO, MSGL_V,
- "audio_setup: frags: %3d/%d (%d bytes/frag) free: %6d\n",
- p->zz.fragments, p->zz.fragstotal, p->zz.fragsize, p->zz.bytes);
+ MP_VERBOSE(ao, "frags: %3d/%d (%d bytes/frag) free: %6d\n",
+ p->zz.fragments, p->zz.fragstotal, p->zz.fragsize, p->zz.bytes);
p->buffersize = p->zz.bytes;
p->outburst = p->zz.fragsize;
}
@@ -381,9 +366,8 @@ ac3_retry:
}
free(data);
if (p->buffersize == 0) {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO OSS]\n *** Your audio driver "
- "DOES NOT support select() ***\n Recompile mpv with "
- "#undef HAVE_AUDIO_SELECT in config.h !\n\n");
+ MP_ERR(ao, "*** Your audio driver DOES NOT support select() ***\n");
+ MP_ERR(ao, "Recompile mpv with #undef HAVE_AUDIO_SELECT in config.h!\n");
return -1;
}
#endif
@@ -433,8 +417,8 @@ static void reset(struct ao *ao)
close_device(ao);
p->audio_fd = open(p->dsp, O_WRONLY);
if (p->audio_fd < 0) {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO OSS]\nFatal error: *** CANNOT "
- "RE-OPEN / RESET AUDIO DEVICE *** %s\n", strerror(errno));
+ MP_ERR(ao, "Fatal error: *** CANNOT "
+ "RE-OPEN / RESET AUDIO DEVICE *** %s\n", strerror(errno));
return;
}