summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-21 20:24:20 +0100
committerwm4 <wm4@nowhere>2013-12-21 21:43:16 +0100
commit3dbc9007b080028f0aebbbf8b9ab1233cd70c45b (patch)
treee6e46e5dd238338c44d421ef4f9101c9898c3cbf /stream
parent9149e2af568d4cb251f8b105f360c3e6b9fd9d86 (diff)
downloadmpv-3dbc9007b080028f0aebbbf8b9ab1233cd70c45b.tar.bz2
mpv-3dbc9007b080028f0aebbbf8b9ab1233cd70c45b.tar.xz
demux: mp_msg conversions
The TV code pretends to be part of stream/, but it's actually demuxer code too. The audio_in code is shared between the TV code and stream_radio.c, so stream_radio.c needs a small hack until stream.c is converted.
Diffstat (limited to 'stream')
-rw-r--r--stream/ai_alsa1x.c36
-rw-r--r--stream/ai_oss.c42
-rw-r--r--stream/ai_sndio.c4
-rw-r--r--stream/audio_in.c19
-rw-r--r--stream/audio_in.h5
-rw-r--r--stream/stream_radio.c2
-rw-r--r--stream/tv.c110
-rw-r--r--stream/tv.h7
-rw-r--r--stream/tvi_dummy.c6
-rw-r--r--stream/tvi_v4l2.c195
10 files changed, 217 insertions, 209 deletions
diff --git a/stream/ai_alsa1x.c b/stream/ai_alsa1x.c
index 880817a94e..8360c88100 100644
--- a/stream/ai_alsa1x.c
+++ b/stream/ai_alsa1x.c
@@ -40,27 +40,27 @@ int ai_alsa_setup(audio_in_t *ai)
err = snd_pcm_hw_params_any(ai->alsa.handle, params);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "Broken configuration for this PCM: no configurations available.\n");
+ MP_ERR(ai, "Broken configuration for this PCM: no configurations available.\n");
return -1;
}
err = snd_pcm_hw_params_set_access(ai->alsa.handle, params,
SND_PCM_ACCESS_RW_INTERLEAVED);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "Access type not available.\n");
+ MP_ERR(ai, "Access type not available.\n");
return -1;
}
err = snd_pcm_hw_params_set_format(ai->alsa.handle, params, SND_PCM_FORMAT_S16_LE);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "Sample format not available.\n");
+ MP_ERR(ai, "Sample format not available.\n");
return -1;
}
err = snd_pcm_hw_params_set_channels(ai->alsa.handle, params, ai->req_channels);
if (err < 0) {
snd_pcm_hw_params_get_channels(params, &ai->channels);
- mp_msg(MSGT_TV, MSGL_ERR, "Channel count not available - reverting to default: %d\n",
+ MP_ERR(ai, "Channel count not available - reverting to default: %d\n",
ai->channels);
} else {
ai->channels = ai->req_channels;
@@ -70,7 +70,7 @@ int ai_alsa_setup(audio_in_t *ai)
rate = ai->req_samplerate;
err = snd_pcm_hw_params_set_rate_near(ai->alsa.handle, params, &rate, &dir);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "Cannot set samplerate.\n");
+ MP_ERR(ai, "Cannot set samplerate.\n");
}
ai->samplerate = rate;
@@ -79,7 +79,7 @@ int ai_alsa_setup(audio_in_t *ai)
err = snd_pcm_hw_params_set_buffer_time_near(ai->alsa.handle, params,
&ai->alsa.buffer_time, &dir);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "Cannot set buffer time.\n");
+ MP_ERR(ai, "Cannot set buffer time.\n");
}
dir = 0;
@@ -87,12 +87,12 @@ int ai_alsa_setup(audio_in_t *ai)
err = snd_pcm_hw_params_set_period_time_near(ai->alsa.handle, params,
&ai->alsa.period_time, &dir);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "Cannot set period time.\n");
+ MP_ERR(ai, "Cannot set period time.\n");
}
err = snd_pcm_hw_params(ai->alsa.handle, params);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "Unable to install hardware parameters: %s", snd_strerror(err));
+ MP_ERR(ai, "Unable to install hardware parameters: %s", snd_strerror(err));
snd_pcm_hw_params_dump(params, ai->alsa.log);
return -1;
}
@@ -102,7 +102,7 @@ int ai_alsa_setup(audio_in_t *ai)
snd_pcm_hw_params_get_buffer_size(params, &buffer_size);
ai->alsa.chunk_size = period_size;
if (period_size == buffer_size) {
- mp_msg(MSGT_TV, MSGL_ERR, "Can't use period equal to buffer size (%u == %lu)\n", ai->alsa.chunk_size, (long)buffer_size);
+ MP_ERR(ai, "Can't use period equal to buffer size (%u == %lu)\n", ai->alsa.chunk_size, (long)buffer_size);
return -1;
}
@@ -113,12 +113,12 @@ int ai_alsa_setup(audio_in_t *ai)
err = snd_pcm_sw_params_set_stop_threshold(ai->alsa.handle, swparams, buffer_size);
if (snd_pcm_sw_params(ai->alsa.handle, swparams) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "Unable to install software parameters:\n");
+ MP_ERR(ai, "Unable to install software parameters:\n");
snd_pcm_sw_params_dump(swparams, ai->alsa.log);
return -1;
}
- if (mp_msg_test(MSGT_TV, MSGL_V)) {
+ if (mp_msg_test_log(ai->log, MSGL_V)) {
snd_pcm_dump(ai->alsa.handle, ai->alsa.log);
}
@@ -137,7 +137,7 @@ int ai_alsa_init(audio_in_t *ai)
err = snd_pcm_open(&ai->alsa.handle, ai->alsa.device, SND_PCM_STREAM_CAPTURE, 0);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "Error opening audio: %s\n", snd_strerror(err));
+ MP_ERR(ai, "Error opening audio: %s\n", snd_strerror(err));
return -1;
}
@@ -171,7 +171,7 @@ int ai_alsa_xrun(audio_in_t *ai)
snd_pcm_status_alloca(&status);
if ((res = snd_pcm_status(ai->alsa.handle, status))<0) {
- mp_msg(MSGT_TV, MSGL_ERR, "ALSA status error: %s", snd_strerror(res));
+ MP_ERR(ai, "ALSA status error: %s", snd_strerror(res));
return -1;
}
if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) {
@@ -179,18 +179,18 @@ int ai_alsa_xrun(audio_in_t *ai)
gettimeofday(&now, 0);
snd_pcm_status_get_trigger_tstamp(status, &tstamp);
timersub(&now, &tstamp, &diff);
- mp_msg(MSGT_TV, MSGL_ERR, "ALSA xrun!!! (at least %.3f ms long)\n",
+ MP_ERR(ai, "ALSA xrun!!! (at least %.3f ms long)\n",
diff.tv_sec * 1000 + diff.tv_usec / 1000.0);
- if (mp_msg_test(MSGT_TV, MSGL_V)) {
- mp_msg(MSGT_TV, MSGL_ERR, "ALSA Status:\n");
+ if (mp_msg_test_log(ai->log, MSGL_V)) {
+ MP_ERR(ai, "ALSA Status:\n");
snd_pcm_status_dump(status, ai->alsa.log);
}
if ((res = snd_pcm_prepare(ai->alsa.handle))<0) {
- mp_msg(MSGT_TV, MSGL_ERR, "ALSA xrun: prepare error: %s", snd_strerror(res));
+ MP_ERR(ai, "ALSA xrun: prepare error: %s", snd_strerror(res));
return -1;
}
return 0; /* ok, data should be accepted again */
}
- mp_msg(MSGT_TV, MSGL_ERR, "ALSA read/write error");
+ MP_ERR(ai, "ALSA read/write error");
return -1;
}
diff --git a/stream/ai_oss.c b/stream/ai_oss.c
index bf57ec4198..8672d13fc0 100644
--- a/stream/ai_oss.c
+++ b/stream/ai_oss.c
@@ -57,10 +57,10 @@ int ai_oss_set_channels(audio_in_t *ai)
if (ai->req_channels > 2)
{
ioctl_param = ai->req_channels;
- mp_msg(MSGT_TV, MSGL_V, "ioctl dsp channels: %d\n",
+ MP_VERBOSE(ai, "ioctl dsp channels: %d\n",
err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_CHANNELS, &ioctl_param));
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "Unable to set channel count: %d\n",
+ MP_ERR(ai, "Unable to set channel count: %d\n",
ai->req_channels);
return -1;
}
@@ -69,11 +69,11 @@ int ai_oss_set_channels(audio_in_t *ai)
else
{
ioctl_param = (ai->req_channels == 2);
- mp_msg(MSGT_TV, MSGL_V, "ioctl dsp stereo: %d (req: %d)\n",
+ MP_VERBOSE(ai, "ioctl dsp stereo: %d (req: %d)\n",
err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_STEREO, &ioctl_param),
ioctl_param);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "Unable to set stereo: %d\n",
+ MP_ERR(ai, "Unable to set stereo: %d\n",
ai->req_channels == 2);
return -1;
}
@@ -90,65 +90,65 @@ int ai_oss_init(audio_in_t *ai)
ai->oss.audio_fd = open(ai->oss.device, O_RDONLY | O_CLOEXEC);
if (ai->oss.audio_fd < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, "Unable to open '%s': %s\n",
+ MP_ERR(ai, "Unable to open '%s': %s\n",
ai->oss.device, strerror(errno));
return -1;
}
ioctl_param = 0 ;
- mp_msg(MSGT_TV, MSGL_V, "ioctl dsp getfmt: %d\n",
+ MP_VERBOSE(ai, "ioctl dsp getfmt: %d\n",
ioctl(ai->oss.audio_fd, SNDCTL_DSP_GETFMTS, &ioctl_param));
- mp_msg(MSGT_TV, MSGL_V, "Supported formats: %x\n", ioctl_param);
+ MP_VERBOSE(ai, "Supported formats: %x\n", ioctl_param);
if (!(ioctl_param & AFMT_S16_LE))
- mp_msg(MSGT_TV, MSGL_ERR, "unsupported format\n");
+ MP_ERR(ai, "unsupported format\n");
ioctl_param = AFMT_S16_LE;
- mp_msg(MSGT_TV, MSGL_V, "ioctl dsp setfmt: %d\n",
+ MP_VERBOSE(ai, "ioctl dsp setfmt: %d\n",
err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_SETFMT, &ioctl_param));
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "Unable to set audio format.");
+ MP_ERR(ai, "Unable to set audio format.");
return -1;
}
if (ai_oss_set_channels(ai) < 0) return -1;
ioctl_param = ai->req_samplerate;
- mp_msg(MSGT_TV, MSGL_V, "ioctl dsp speed: %d\n",
+ MP_VERBOSE(ai, "ioctl dsp speed: %d\n",
err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_SPEED, &ioctl_param));
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "Unable to set samplerate: %d\n",
+ MP_ERR(ai, "Unable to set samplerate: %d\n",
ai->req_samplerate);
return -1;
}
ai->samplerate = ioctl_param;
- mp_msg(MSGT_TV, MSGL_V, "ioctl dsp trigger: %d\n",
+ MP_VERBOSE(ai, "ioctl dsp trigger: %d\n",
ioctl(ai->oss.audio_fd, SNDCTL_DSP_GETTRIGGER, &ioctl_param));
- mp_msg(MSGT_TV, MSGL_V, "trigger: %x\n", ioctl_param);
+ MP_VERBOSE(ai, "trigger: %x\n", ioctl_param);
ioctl_param = PCM_ENABLE_INPUT;
- mp_msg(MSGT_TV, MSGL_V, "ioctl dsp trigger: %d\n",
+ MP_VERBOSE(ai, "ioctl dsp trigger: %d\n",
err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_SETTRIGGER, &ioctl_param));
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "Unable to set trigger: %d\n",
+ MP_ERR(ai, "Unable to set trigger: %d\n",
PCM_ENABLE_INPUT);
}
ai->blocksize = 0;
- mp_msg(MSGT_TV, MSGL_V, "ioctl dsp getblocksize: %d\n",
+ MP_VERBOSE(ai, "ioctl dsp getblocksize: %d\n",
err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_GETBLKSIZE, &ai->blocksize));
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "Unable to get block size!\n");
+ MP_ERR(ai, "Unable to get block size!\n");
}
- mp_msg(MSGT_TV, MSGL_V, "blocksize: %d\n", ai->blocksize);
+ MP_VERBOSE(ai, "blocksize: %d\n", ai->blocksize);
// correct the blocksize to a reasonable value
if (ai->blocksize <= 0) {
ai->blocksize = 4096*ai->channels*2;
- mp_msg(MSGT_TV, MSGL_ERR, "Audio block size is zero, setting to %d!\n", ai->blocksize);
+ MP_ERR(ai, "Audio block size is zero, setting to %d!\n", ai->blocksize);
} else if (ai->blocksize < 4096*ai->channels*2) {
ai->blocksize *= 4096*ai->channels*2/ai->blocksize;
- mp_msg(MSGT_TV, MSGL_ERR, "Audio block size too low, setting to %d!\n", ai->blocksize);
+ MP_ERR(ai, "Audio block size too low, setting to %d!\n", ai->blocksize);
}
ai->samplesize = 16;
diff --git a/stream/ai_sndio.c b/stream/ai_sndio.c
index 08ddac1e03..3cd68e5ee1 100644
--- a/stream/ai_sndio.c
+++ b/stream/ai_sndio.c
@@ -21,7 +21,7 @@ int ai_sndio_setup(audio_in_t *ai)
par.appbufsz = ai->req_samplerate; /* 1 sec */
if (!sio_setpar(ai->sndio.hdl, &par) || !sio_getpar(ai->sndio.hdl, &par)) {
- mp_msg(MSGT_TV, MSGL_ERR, "could not configure sndio audio");
+ MP_ERR(ai, "could not configure sndio audio");
return -1;
}
@@ -39,7 +39,7 @@ int ai_sndio_init(audio_in_t *ai)
int err;
if ((ai->sndio.hdl = sio_open(ai->sndio.device, SIO_REC, 0)) == NULL) {
- mp_msg(MSGT_TV, MSGL_ERR, "could not open sndio audio");
+ MP_ERR(ai, "could not open sndio audio");
return -1;
}
diff --git a/stream/audio_in.c b/stream/audio_in.c
index 1d80ab762b..6592735aa9 100644
--- a/stream/audio_in.c
+++ b/stream/audio_in.c
@@ -28,10 +28,11 @@
#include <errno.h>
// sanitizes ai structure before calling other functions
-int audio_in_init(audio_in_t *ai, int type)
+int audio_in_init(audio_in_t *ai, struct mp_log *log, int type)
{
ai->type = type;
ai->setup = 0;
+ ai->log = log;
ai->channels = -1;
ai->samplerate = -1;
@@ -247,16 +248,16 @@ int audio_in_read_chunk(audio_in_t *ai, unsigned char *buffer)
ret = snd_pcm_readi(ai->alsa.handle, buffer, ai->alsa.chunk_size);
if (ret != ai->alsa.chunk_size) {
if (ret < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "\nError reading audio: %s\n", snd_strerror(ret));
+ MP_ERR(ai, "\nError reading audio: %s\n", snd_strerror(ret));
if (ret == -EPIPE) {
if (ai_alsa_xrun(ai) == 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "Recovered from cross-run, some frames may be left out!\n");
+ MP_ERR(ai, "Recovered from cross-run, some frames may be left out!\n");
} else {
- mp_msg(MSGT_TV, MSGL_ERR, "Fatal error, cannot recover!\n");
+ MP_ERR(ai, "Fatal error, cannot recover!\n");
}
}
} else {
- mp_msg(MSGT_TV, MSGL_ERR, "\nNot enough audio samples!\n");
+ MP_ERR(ai, "\nNot enough audio samples!\n");
}
return -1;
}
@@ -267,10 +268,10 @@ int audio_in_read_chunk(audio_in_t *ai, unsigned char *buffer)
ret = read(ai->oss.audio_fd, buffer, ai->blocksize);
if (ret != ai->blocksize) {
if (ret < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "\nError reading audio: %s\n", strerror(errno));
+ MP_ERR(ai, "\nError reading audio: %s\n", strerror(errno));
} else {
- mp_msg(MSGT_TV, MSGL_ERR, "\nNot enough audio samples!\n");
+ MP_ERR(ai, "\nNot enough audio samples!\n");
}
return -1;
}
@@ -281,9 +282,9 @@ int audio_in_read_chunk(audio_in_t *ai, unsigned char *buffer)
ret = sio_read(ai->sndio.hdl, buffer, ai->blocksize);
if (ret != ai->blocksize) {
if (ret < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "\nError reading audio: %s\n", strerror(errno));
+ MP_ERR(ai, "\nError reading audio: %s\n", strerror(errno));
} else {
- mp_msg(MSGT_TV, MSGL_ERR, "\nNot enough audio samples!\n");
+ MP_ERR(ai, "\nNot enough audio samples!\n");
}
return -1;
}
diff --git a/stream/audio_in.h b/stream/audio_in.h
index af2cecd28d..0afd926335 100644
--- a/stream/audio_in.h
+++ b/stream/audio_in.h
@@ -25,6 +25,8 @@
#include "config.h"
+struct mp_log;
+
#if HAVE_ALSA
#include <alsa/asoundlib.h>
@@ -58,6 +60,7 @@ typedef struct {
typedef struct
{
+ struct mp_log *log;
int type;
int setup;
@@ -83,7 +86,7 @@ typedef struct
#endif
} audio_in_t;
-int audio_in_init(audio_in_t *ai, int type);
+int audio_in_init(audio_in_t *ai, struct mp_log *log, int type);
int audio_in_setup(audio_in_t *ai);
int audio_in_set_device(audio_in_t *ai, char *device);
int audio_in_set_samplerate(audio_in_t *ai, int rate);
diff --git a/stream/stream_radio.c b/stream/stream_radio.c
index 3a954251f0..3f60bb77c2 100644
--- a/stream/stream_radio.c
+++ b/stream/stream_radio.c
@@ -574,7 +574,7 @@ static int init_audio(radio_priv_t *priv)
tmp[0] = ',';
#endif
- if(audio_in_init(&priv->audio_in, is_oss?AUDIO_IN_OSS:AUDIO_IN_ALSA)<0){
+ if(audio_in_init(&priv->audio_in, mp_null_log, is_oss?AUDIO_IN_OSS:AUDIO_IN_ALSA)<0){
mp_msg(MSGT_RADIO, MSGL_ERR, "[radio] audio_in_init failed.\n");
}
diff --git a/stream/tv.c b/stream/tv.c
index 594af4fd30..b9e5a97b9b 100644
--- a/stream/tv.c
+++ b/stream/tv.c
@@ -67,7 +67,7 @@ static const tvi_info_t* tvi_driver_list[]={
NULL
};
-tvi_handle_t *tv_new_handle(int size, const tvi_functions_t *functions)
+tvi_handle_t *tv_new_handle(int size, struct mp_log *log, const tvi_functions_t *functions)
{
tvi_handle_t *h = malloc(sizeof(*h));
@@ -81,6 +81,7 @@ tvi_handle_t *tv_new_handle(int size, const tvi_functions_t *functions)
return NULL;
}
+ h->log = log;
h->functions = functions;
h->seq = 0;
h->chanlist = -1;
@@ -103,7 +104,7 @@ void tv_free_handle(tvi_handle_t *h)
void tv_start_scan(tvi_handle_t *tvh, int start)
{
- mp_msg(MSGT_TV,MSGL_INFO,"start scan\n");
+ MP_INFO(tvh, "start scan\n");
tvh->tv_param->scan=start?1:0;
}
@@ -124,7 +125,7 @@ static void tv_scan(tvi_handle_t *tvh)
//Channel scanner without tuner is useless and causes crash due to uninitialized chanlist_s
if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE)
{
- mp_msg(MSGT_TV, MSGL_WARN, "Channel scanner is not available without tuner\n");
+ MP_WARN(tvh, "Channel scanner is not available without tuner\n");
tvh->tv_param->scan=0;
return;
}
@@ -154,7 +155,7 @@ static void tv_scan(tvi_handle_t *tvh)
tv_channel_tmp=tv_channel_tmp->next;
}
if (!found) {
- mp_msg(MSGT_TV, MSGL_INFO, "Found new channel: %s (#%d). \n",cl.name,index);
+ MP_INFO(tvh, "Found new channel: %s (#%d). \n",cl.name,index);
scan->new_channels++;
tv_channel_tmp = malloc(sizeof(tv_channels_t));
tv_channel_tmp->index=index;
@@ -171,24 +172,24 @@ static void tv_scan(tvi_handle_t *tvh)
tv_channel_list->prev=tv_channel_tmp;
}
}else
- mp_msg(MSGT_TV, MSGL_INFO, "Found existing channel: %s-%s.\n",
+ MP_INFO(tvh, "Found existing channel: %s-%s.\n",
tv_channel_tmp->number,tv_channel_tmp->name);
}
scan->channel_num++;
scan->scan_timer=now+1e6*tvh->tv_param->scan_period;
if (scan->channel_num>=chanlists[tvh->chanlist].count) {
tvh->tv_param->scan=0;
- mp_msg(MSGT_TV, MSGL_INFO, "TV scan end. Found %d new channels.\n", scan->new_channels);
+ MP_INFO(tvh, "TV scan end. Found %d new channels.\n", scan->new_channels);
tv_channel_tmp=tv_channel_list;
if(tv_channel_tmp){
- mp_msg(MSGT_TV,MSGL_INFO,"channels=");
+ MP_INFO(tvh, "channels=");
while(tv_channel_tmp){
- mp_msg(MSGT_TV,MSGL_INFO,"%s-%s",tv_channel_tmp->number,tv_channel_tmp->name);
+ MP_INFO(tvh, "%s-%s",tv_channel_tmp->number,tv_channel_tmp->name);
if(tv_channel_tmp->next)
- mp_msg(MSGT_TV,MSGL_INFO,",");
+ MP_INFO(tvh, ",");
tv_channel_tmp=tv_channel_tmp->next;
}
- mp_msg(MSGT_TV, MSGL_INFO, "\n");
+ MP_INFO(tvh, "\n");
}
if (!tv_channel_current) tv_channel_current=tv_channel_list;
if (tv_channel_current)
@@ -198,7 +199,7 @@ static void tv_scan(tvi_handle_t *tvh)
}else{
cl = tvh->chanlist_s[scan->channel_num];
tv_set_freq_float(tvh, cl.freq);
- mp_msg(MSGT_TV, MSGL_INFO, "Trying: %s (%.2f). \n",cl.name,1e-3*cl.freq);
+ MP_INFO(tvh, "Trying: %s (%.2f). \n",cl.name,1e-3*cl.freq);
}
}
@@ -276,7 +277,7 @@ static int norm_from_string(tvi_handle_t *tvh, char* norm)
if(ret!=TVI_CONTROL_UNKNOWN)
{
- mp_msg(MSGT_TV, MSGL_WARN, "tv.c: norm_from_string(%s): Bogus norm parameter, setting %s.\n", norm,"default");
+ MP_WARN(tvh, "tv.c: norm_from_string(%s): Bogus norm parameter, setting %s.\n", norm,"default");
return 0;
}
@@ -295,7 +296,7 @@ static int norm_from_string(tvi_handle_t *tvh, char* norm)
else if (!strcasecmp(norm, "ntscjp"))
return TV_NORM_NTSCJP;
else {
- mp_msg(MSGT_TV, MSGL_WARN, "tv.c: norm_from_string(%s): Bogus norm parameter, setting %s.\n", norm, "PAL");
+ MP_WARN(tvh, "tv.c: norm_from_string(%s): Bogus norm parameter, setting %s.\n", norm, "PAL");
return TV_NORM_PAL;
}
}
@@ -304,7 +305,7 @@ static void parse_channels(tvi_handle_t *tvh)
{
char** channels = tvh->tv_param->channels;
- mp_msg(MSGT_TV, MSGL_INFO, "TV channel names detected.\n");
+ MP_INFO(tvh, "TV channel names detected.\n");
tv_channel_list = malloc(sizeof(tv_channels_t));
tv_channel_list->index=1;
tv_channel_list->next=NULL;
@@ -344,7 +345,7 @@ static void parse_channels(tvi_handle_t *tvh)
}
}
if (tv_channel_current->freq == 0)
- mp_msg(MSGT_TV, MSGL_ERR, "Couldn't find frequency for channel %s (%s)\n",
+ MP_ERR(tvh, "Couldn't find frequency for channel %s (%s)\n",
tv_channel_current->number, tv_channel_current->name);
else {
sep = strchr(tv_channel_current->name, '-');
@@ -364,7 +365,7 @@ static void parse_channels(tvi_handle_t *tvh)
}
}
- /*mp_msg(MSGT_TV, MSGL_INFO, "-- Detected channel %s - %s (%5.3f)\n",
+ /*MP_INFO(tvh, "-- Detected channel %s - %s (%5.3f)\n",
tv_channel_current->number, tv_channel_current->name,
(float)tv_channel_current->freq/1000);*/
@@ -384,9 +385,9 @@ int tv_set_norm(tvi_handle_t *tvh, char* norm)
{
tvh->norm = norm_from_string(tvh, norm);
- mp_msg(MSGT_TV, MSGL_V, "Selected norm : %s\n", norm);
+ MP_VERBOSE(tvh, "Selected norm : %s\n", norm);
if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm) != TVI_CONTROL_TRUE) {
- mp_msg(MSGT_TV, MSGL_ERR, "Error: Cannot set norm!\n");
+ MP_ERR(tvh, "Error: Cannot set norm!\n");
return 0;
}
return 1;
@@ -396,9 +397,9 @@ static int tv_set_norm_i(tvi_handle_t *tvh, int norm)
{
tvh->norm = norm;
- mp_msg(MSGT_TV, MSGL_V, "Selected norm id: %d\n", norm);
+ MP_VERBOSE(tvh, "Selected norm id: %d\n", norm);
if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm) != TVI_CONTROL_TRUE) {
- mp_msg(MSGT_TV, MSGL_ERR, "Error: Cannot set norm!\n");
+ MP_ERR(tvh, "Error: Cannot set norm!\n");
return 0;
}
@@ -407,7 +408,7 @@ static int tv_set_norm_i(tvi_handle_t *tvh, int norm)
static void set_norm_and_freq(tvi_handle_t *tvh, tv_channels_t *chan)
{
- mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n",
+ MP_INFO(tvh, "Selected channel: %s - %s (freq: %.3f)\n",
chan->number, chan->name, chan->freq/1000.0);
tv_set_norm_i(tvh, chan->norm);
tv_set_freq_float(tvh, chan->freq);
@@ -430,7 +431,7 @@ static int open_tv(tvi_handle_t *tvh)
if (funcs->control(tvh->priv, TVI_CONTROL_IS_VIDEO, 0) != TVI_CONTROL_TRUE)
{
- mp_msg(MSGT_TV, MSGL_ERR, "Error: No video input present!\n");
+ MP_ERR(tvh, "Error: No video input present!\n");
return 0;
}
@@ -458,8 +459,7 @@ static int open_tv(tvi_handle_t *tvh)
case MP_FOURCC_BGR15:
break;
default:
- mp_msg(MSGT_TV, MSGL_ERR,
- "==================================================================\n"\
+ MP_ERR(tvh, "==================================================================\n"\
" WARNING: UNTESTED OR UNKNOWN OUTPUT IMAGE FORMAT REQUESTED (0x%x)\n"\
" This may cause buggy playback or program crash! Bug reports will\n"\
" be ignored! You should try again with YV12 (which is the default\n"\
@@ -492,7 +492,7 @@ static int open_tv(tvi_handle_t *tvh)
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_WIDTH, &tvh->tv_param->width);
else
{
- mp_msg(MSGT_TV, MSGL_ERR, "Unable to set requested width: %d\n", tvh->tv_param->width);
+ MP_ERR(tvh, "Unable to set requested width: %d\n", tvh->tv_param->width);
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &tvh->tv_param->width);
}
}
@@ -504,14 +504,14 @@ static int open_tv(tvi_handle_t *tvh)
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HEIGHT, &tvh->tv_param->height);
else
{
- mp_msg(MSGT_TV, MSGL_ERR, "Unable to set requested height: %d\n", tvh->tv_param->height);
+ MP_ERR(tvh, "Unable to set requested height: %d\n", tvh->tv_param->height);
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &tvh->tv_param->height);
}
}
if (funcs->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE)
{
- mp_msg(MSGT_TV, MSGL_WARN, "Selected input hasn't got a tuner!\n");
+ MP_WARN(tvh, "Selected input hasn't got a tuner!\n");
goto done;
}
@@ -527,16 +527,16 @@ static int open_tv(tvi_handle_t *tvh)
}
if (tvh->chanlist == -1) {
- mp_msg(MSGT_TV, MSGL_WARN, "Unable to find selected channel list! (%s)\n",
+ MP_WARN(tvh, "Unable to find selected channel list! (%s)\n",
tvh->tv_param->chanlist);
return 0;
} else
- mp_msg(MSGT_TV, MSGL_V, "Selected channel list: %s (including %d channels)\n",
+ MP_VERBOSE(tvh, "Selected channel list: %s (including %d channels)\n",
chanlists[tvh->chanlist].name, chanlists[tvh->chanlist].count);
if (tvh->tv_param->freq && tvh->tv_param->channel)
{
- mp_msg(MSGT_TV, MSGL_WARN, "You can't set frequency and channel simultaneously!\n");
+ MP_WARN(tvh, "You can't set frequency and channel simultaneously!\n");
goto done;
}
@@ -589,14 +589,14 @@ static int open_tv(tvi_handle_t *tvh)
funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
- mp_msg(MSGT_TV, MSGL_V, "Selected frequency: %lu (%.3f)\n",
+ MP_VERBOSE(tvh, "Selected frequency: %lu (%.3f)\n",
freq, freq/16.0);
}
if (tvh->tv_param->channel) {
struct CHANLIST cl;
- mp_msg(MSGT_TV, MSGL_V, "Requested channel: %s\n", tvh->tv_param->channel);
+ MP_VERBOSE(tvh, "Requested channel: %s\n", tvh->tv_param->channel);
for (i = 0; i < chanlists[tvh->chanlist].count; i++)
{
cl = tvh->chanlist_s[i];
@@ -606,7 +606,7 @@ static int open_tv(tvi_handle_t *tvh)
{
strcpy(tv_channel_last_real, cl.name);
tvh->channel = i;
- mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
+ MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n",
cl.name, cl.freq/1000.0);
tv_set_freq_float(tvh, cl.freq);
break;
@@ -639,24 +639,24 @@ done:
return 1;
}
-static tvi_handle_t *tv_begin(tv_param_t* tv_param)
+static tvi_handle_t *tv_begin(tv_param_t* tv_param, struct mp_log *log)
{
int i;
tvi_handle_t* h;
if(tv_param->driver && !strcmp(tv_param->driver,"help")){
- mp_msg(MSGT_TV,MSGL_INFO,"Available drivers:\n");
+ mp_info(log, "Available drivers:\n");
for(i=0;tvi_driver_list[i];i++){
- mp_msg(MSGT_TV,MSGL_INFO," %s\t%s",tvi_driver_list[i]->short_name,tvi_driver_list[i]->name);
+ mp_info(log, " %s\t%s",tvi_driver_list[i]->short_name,tvi_driver_list[i]->name);
if(tvi_driver_list[i]->comment)
- mp_msg(MSGT_TV,MSGL_INFO," (%s)",tvi_driver_list[i]->comment);
- mp_msg(MSGT_TV,MSGL_INFO,"\n");
+ mp_info(log, " (%s)",tvi_driver_list[i]->comment);
+ mp_info(log, "\n");
}
return NULL;
}
for(i=0;tvi_driver_list[i];i++){
if (!tv_param->driver || !strcmp(tvi_driver_list[i]->short_name, tv_param->driver)){
- h=tvi_driver_list[i]->tvi_init(tv_param);
+ h=tvi_driver_list[i]->tvi_init(log, tv_param);
//Requested driver initialization failed
if (!h && tv_param->driver)
return NULL;
@@ -665,7 +665,7 @@ static tvi_handle_t *tv_begin(tv_param_t* tv_param)
continue;
h->tv_param=tv_param;
- mp_msg(MSGT_TV, MSGL_INFO, "Selected driver: %s\n name: %s\n author: %s\n comment: %s\n", tvi_driver_list[i]->short_name,
+ MP_INFO(h, "Selected driver: %s\n name: %s\n author: %s\n comment: %s\n", tvi_driver_list[i]->short_name,
tvi_driver_list[i]->name,
tvi_driver_list[i]->author,
tvi_driver_list[i]->comment?tvi_driver_list[i]->comment:"");
@@ -675,9 +675,9 @@ static tvi_handle_t *tv_begin(tv_param_t* tv_param)
}
if(tv_param->driver)
- mp_msg(MSGT_TV, MSGL_ERR, "No such driver: %s\n", tv_param->driver);
+ mp_err(log, "No such driver: %s\n", tv_param->driver);
else
- mp_msg(MSGT_TV, MSGL_ERR, "TV driver autodetection failed.\n");
+ mp_err(log, "TV driver autodetection failed.\n");
return NULL;
}
@@ -705,7 +705,7 @@ static int demux_open_tv(demuxer_t *demuxer, enum demux_check check)
return -1;
demuxer->priv=NULL;
- if(!(tvh=tv_begin(demuxer->stream->priv))) return -1;
+ if(!(tvh=tv_begin(demuxer->stream->priv, demuxer->log))) return -1;
if (!tvh->functions->init(tvh->priv)) return -1;
tvh->demuxer = demuxer;
@@ -784,7 +784,7 @@ static int demux_open_tv(demuxer_t *demuxer, enum demux_check check)
break;
case AF_FORMAT_MPEG2:
default:
- mp_msg(MSGT_TV, MSGL_ERR, "Audio type '%s' unsupported!\n",
+ MP_ERR(tvh, "Audio type '%s' unsupported!\n",
af_fmt_to_str(audio_format));
goto no_audio;
}
@@ -816,7 +816,7 @@ static int demux_open_tv(demuxer_t *demuxer, enum demux_check check)
sh_audio->wf->nBlockAlign = samplesize * sh_audio->channels.num;
sh_audio->wf->nAvgBytesPerSec = sh_audio->i_bps;
- mp_msg(MSGT_DECVIDEO, MSGL_V, " TV audio: %d channels, %d bits, %d Hz\n",
+ MP_VERBOSE(tvh, " TV audio: %d channels, %d bits, %d Hz\n",
sh_audio->wf->nChannels, sh_audio->wf->wBitsPerSample,
sh_audio->wf->nSamplesPerSec);
}
@@ -836,7 +836,7 @@ no_audio:
if(tvh->tv_param->gain!=-1)
if(funcs->control(tvh->priv,TVI_CONTROL_VID_SET_GAIN,&tvh->tv_param->gain)!=TVI_CONTROL_TRUE)
- mp_msg(MSGT_TV,MSGL_WARN,"Unable to set gain control!\n");
+ MP_WARN(tvh, "Unable to set gain control!\n");
return 0;
}
@@ -865,7 +865,7 @@ int tv_set_color_options(tvi_handle_t *tvh, int opt, int value)
case TV_COLOR_CONTRAST:
return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_CONTRAST, &value);
default:
- mp_msg(MSGT_TV, MSGL_WARN, "Unknown color option (%d) specified!\n", opt);
+ MP_WARN(tvh, "Unknown color option (%d) specified!\n", opt);
}
return TVI_CONTROL_UNKNOWN;
@@ -886,7 +886,7 @@ int tv_get_color_options(tvi_handle_t *tvh, int opt, int* value)
case TV_COLOR_CONTRAST:
return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_CONTRAST, value);
default:
- mp_msg(MSGT_TV, MSGL_WARN, "Unknown color option (%d) specified!\n", opt);
+ MP_WARN(tvh, "Unknown color option (%d) specified!\n", opt);
}
return TVI_CONTROL_UNKNOWN;
@@ -897,7 +897,7 @@ int tv_get_freq(tvi_handle_t *tvh, unsigned long *freq)
if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) == TVI_CONTROL_TRUE)
{
tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, freq);
- mp_msg(MSGT_TV, MSGL_V, "Current frequency: %lu (%.3f)\n",
+ MP_VERBOSE(tvh, "Current frequency: %lu (%.3f)\n",
*freq, *freq/16.0);
}
return 1;
@@ -913,7 +913,7 @@ int tv_set_freq(tvi_handle_t *tvh, unsigned long freq)
tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
- mp_msg(MSGT_TV, MSGL_V, "Current frequency: %lu (%.3f)\n",
+ MP_VERBOSE(tvh, "Current frequency: %lu (%.3f)\n",
freq, freq/16.0);
}
return 1;
@@ -956,7 +956,7 @@ int tv_step_channel_real(tvi_handle_t *tvh, int direction)
{
strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
cl = tvh->chanlist_s[--tvh->channel];
- mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
+ MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n",
cl.name, cl.freq/1000.0);
tv_set_freq_float(tvh, cl.freq);
}
@@ -968,7 +968,7 @@ int tv_step_channel_real(tvi_handle_t *tvh, int direction)
{
strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
cl = tvh->chanlist_s[++tvh->channel];
- mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
+ MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n",
cl.name, cl.freq/1000.0);
tv_set_freq_float(tvh, cl.freq);
}
@@ -1014,7 +1014,7 @@ int tv_set_channel_real(tvi_handle_t *tvh, char *channel) {
if (!strcasecmp(cl.name, channel))
{
tvh->channel = i;
- mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
+ MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n",
cl.name, cl.freq/1000.0);
tv_set_freq_float(tvh, cl.freq);
break;
@@ -1061,7 +1061,7 @@ int tv_last_channel(tvi_handle_t *tvh) {
{
strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
tvh->channel = i;
- mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
+ MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n",
cl.name, cl.freq/1000.0);
tv_set_freq_float(tvh, cl.freq);
break;
@@ -1079,7 +1079,7 @@ int tv_step_norm(tvi_handle_t *tvh)
tvh->norm = 0;
if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM,
&tvh->norm) != TVI_CONTROL_TRUE) {
- mp_msg(MSGT_TV, MSGL_ERR, "Error: Cannot set norm!\n");
+ MP_ERR(tvh, "Error: Cannot set norm!\n");
return 0;
}
}
diff --git a/stream/tv.h b/stream/tv.h
index 9cbc7ef652..4ab064e7fd 100644
--- a/stream/tv.h
+++ b/stream/tv.h
@@ -25,6 +25,8 @@
#ifndef MPLAYER_TV_H
#define MPLAYER_TV_H
+struct mp_log;
+
typedef struct tv_param_s {
char *freq;
char *channel;
@@ -77,7 +79,7 @@ extern tv_param_t stream_tv_defaults;
typedef struct tvi_info_s
{
- struct tvi_handle_s * (*tvi_init)(tv_param_t* tv_param);
+ struct tvi_handle_s * (*tvi_init)(struct mp_log *log, tv_param_t* tv_param);
const char *name;
const char *short_name;
const char *author;
@@ -100,6 +102,7 @@ typedef struct tvi_functions_s
} tvi_functions_t;
typedef struct tvi_handle_s {
+ struct mp_log *log;
const tvi_functions_t *functions;
void *priv;
int seq;
@@ -225,7 +228,7 @@ int tv_set_norm(tvi_handle_t *tvh, char* norm);
void tv_start_scan(tvi_handle_t *tvh, int start);
-tvi_handle_t *tv_new_handle(int size, const tvi_functions_t *functions);
+tvi_handle_t *tv_new_handle(int size, struct mp_log *log, const tvi_functions_t *functions);
void tv_free_handle(tvi_handle_t *h);
#define TV_NORM_PAL 1
diff --git a/stream/tvi_dummy.c b/stream/tvi_dummy.c
index 24590fa428..0d9e86c210 100644
--- a/stream/tvi_dummy.c
+++ b/stream/tvi_dummy.c
@@ -24,7 +24,7 @@
#include "video/img_fourcc.h"
#include "tv.h"
-static tvi_handle_t *tvi_init_dummy(tv_param_t* tv_param);
+static tvi_handle_t *tvi_init_dummy(struct mp_log *log, tv_param_t* tv_param);
/* information about this file */
const tvi_info_t tvi_info_dummy = {
tvi_init_dummy,
@@ -43,9 +43,9 @@ typedef struct priv {
#include "tvi_def.h"
/* handler creator - entry point ! */
-static tvi_handle_t *tvi_init_dummy(tv_param_t* tv_param)
+static tvi_handle_t *tvi_init_dummy(struct mp_log *log, tv_param_t* tv_param)
{
- return tv_new_handle(sizeof(priv_t), &functions);
+ return tv_new_handle(sizeof(priv_t), log, &functions);
}
/* initialisation */
diff --git a/stream/tvi_v4l2.c b/stream/tvi_v4l2.c
index 6132ad7708..b6f77edf31 100644
--- a/stream/tvi_v4l2.c
+++ b/stream/tvi_v4l2.c
@@ -72,7 +72,7 @@ known issues:
#endif
#define info tvi_info_v4l2
-static tvi_handle_t *tvi_init_v4l2(tv_param_t* tv_param);
+static tvi_handle_t *tvi_init_v4l2(struct mp_log *log, tv_param_t* tv_param);
/* information about this file */
const tvi_info_t tvi_info_v4l2 = {
tvi_init_v4l2,
@@ -100,6 +100,7 @@ typedef struct {
/* private data */
typedef struct priv {
/* video */
+ struct mp_log *log;
char *video_dev;
int video_fd;
int mp_format;
@@ -395,7 +396,7 @@ static void setup_audio_buffer_sizes(priv_t *priv)
*bytes_per_sample/priv->audio_in.blocksize;
if (priv->aud_skew_cnt < 16) priv->aud_skew_cnt = 16;
- mp_msg(MSGT_TV, MSGL_V, "Audio capture - buffer %d blocks of %d bytes, skew average from %d meas.\n",
+ MP_VERBOSE(priv, "Audio capture - buffer %d blocks of %d bytes, skew average from %d meas.\n",
priv->audio_buffer_size, priv->audio_in.blocksize, priv->aud_skew_cnt);
}
@@ -406,11 +407,11 @@ static void init_audio(priv_t *priv)
if (!priv->tv_param->noaudio) {
#if HAVE_ALSA
if (priv->tv_param->alsa)
- audio_in_init(&priv->audio_in, AUDIO_IN_ALSA);
+ audio_in_init(&priv->audio_in, priv->log, AUDIO_IN_ALSA);
else
- audio_in_init(&priv->audio_in, AUDIO_IN_OSS);
+ audio_in_init(&priv->audio_in, priv->log, AUDIO_IN_OSS);
#else
- audio_in_init(&priv->audio_in, AUDIO_IN_OSS);
+ audio_in_init(&priv->audio_in, priv->log, AUDIO_IN_OSS);
#endif
if (priv->audio_dev) {
@@ -458,7 +459,7 @@ static int getfmt(priv_t *priv)
priv->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if ((i = v4l2_ioctl(priv->video_fd, VIDIOC_G_FMT, &priv->format)) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get format failed: %s\n",
+ MP_ERR(priv, "%s: ioctl get format failed: %s\n",
info.short_name, strerror(errno));
}
return i;
@@ -478,7 +479,7 @@ static int getstd(priv_t *priv)
parm.type=V4L2_BUF_TYPE_VIDEO_CAPTURE;
if(v4l2_ioctl(priv->video_fd, VIDIOC_G_PARM, &parm) >= 0) {
- mp_msg(MSGT_TV, MSGL_WARN, "%s: your device driver does not support VIDIOC_G_STD ioctl,"
+ MP_WARN(priv, "%s: your device driver does not support VIDIOC_G_STD ioctl,"
" VIDIOC_G_PARM was used instead.\n", info.short_name);
priv->standard.index=0;
priv->standard.id=0;
@@ -486,7 +487,7 @@ static int getstd(priv_t *priv)
return 0;
}
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get standard failed: %s\n",
+ MP_ERR(priv, "%s: ioctl get standard failed: %s\n",
info.short_name, strerror(errno));
return -1;
}
@@ -513,7 +514,7 @@ static int set_mute(priv_t *priv, int value)
control.id = V4L2_CID_AUDIO_MUTE;
control.value = value;
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_CTRL, &control) < 0) {
- mp_msg(MSGT_TV,MSGL_ERR,"%s: ioctl set mute failed: %s\n",
+ MP_ERR(priv, "%s: ioctl set mute failed: %s\n",
info.short_name, strerror(errno));
return 0;
}
@@ -528,7 +529,7 @@ static int set_control(priv_t *priv, struct v4l2_control *control, int val_signe
struct v4l2_queryctrl qctrl;
qctrl.id = control->id;
if (v4l2_ioctl(priv->video_fd, VIDIOC_QUERYCTRL, &qctrl) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl query control failed: %s\n",
+ MP_ERR(priv, "%s: ioctl query control failed: %s\n",
info.short_name, strerror(errno));
return TVI_CONTROL_FALSE;
}
@@ -553,11 +554,11 @@ static int set_control(priv_t *priv, struct v4l2_control *control, int val_signe
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_CTRL, control) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR,"%s: ioctl set %s %d failed: %s\n",
+ MP_ERR(priv, "%s: ioctl set %s %d failed: %s\n",
info.short_name, qctrl.name, control->value, strerror(errno));
return TVI_CONTROL_FALSE;
}
- mp_msg(MSGT_TV, MSGL_V, "%s: set %s: %d [%d, %d]\n", info.short_name,
+ MP_VERBOSE(priv, "%s: set %s: %d [%d, %d]\n", info.short_name,
qctrl.name, control->value, qctrl.minimum, qctrl.maximum);
return TVI_CONTROL_TRUE;
@@ -572,17 +573,17 @@ static int get_control(priv_t *priv, struct v4l2_control *control, int val_signe
qctrl.id = control->id;
if (v4l2_ioctl(priv->video_fd, VIDIOC_QUERYCTRL, &qctrl) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl query control failed: %s\n",
+ MP_ERR(priv, "%s: ioctl query control failed: %s\n",
info.short_name, strerror(errno));
return TVI_CONTROL_FALSE;
}
if (v4l2_ioctl(priv->video_fd, VIDIOC_G_CTRL, control) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR,"%s: ioctl get %s failed: %s\n",
+ MP_ERR(priv, "%s: ioctl get %s failed: %s\n",
info.short_name, qctrl.name, strerror(errno));
return TVI_CONTROL_FALSE;
}
- mp_msg(MSGT_TV, MSGL_V, "%s: get %s: %d [%d, %d]\n", info.short_name,
+ MP_VERBOSE(priv, "%s: get %s: %d [%d, %d]\n", info.short_name,
qctrl.name, control->value, qctrl.minimum, qctrl.maximum);
if (val_signed) {
@@ -625,19 +626,19 @@ static int do_control(priv_t *priv, int cmd, void *arg)
return TVI_CONTROL_TRUE;
case TVI_CONTROL_VID_GET_FPS:
*(float *)arg = getfps(priv);
- mp_msg(MSGT_TV, MSGL_V, "%s: get fps: %f\n", info.short_name,
+ MP_VERBOSE(priv, "%s: get fps: %f\n", info.short_name,
*(float *)arg);
return TVI_CONTROL_TRUE;
case TVI_CONTROL_VID_GET_BITS:
if (getfmt(priv) < 0) return TVI_CONTROL_FALSE;
*(int *)arg = pixfmt2depth(priv->format.fmt.pix.pixelformat);
- mp_msg(MSGT_TV, MSGL_V, "%s: get depth: %d\n", info.short_name,
+ MP_VERBOSE(priv, "%s: get depth: %d\n", info.short_name,
*(int *)arg);
return TVI_CONTROL_TRUE;
case TVI_CONTROL_VID_GET_FORMAT:
if (getfmt(priv) < 0) return TVI_CONTROL_FALSE;
*(int *)arg = fcc_vl2mp(priv->format.fmt.pix.pixelformat);
- mp_msg(MSGT_TV, MSGL_V, "%s: get format: %s\n", info.short_name,
+ MP_VERBOSE(priv, "%s: get format: %s\n", info.short_name,
pixfmt2name(priv->format.fmt.pix.pixelformat));
return TVI_CONTROL_TRUE;
case TVI_CONTROL_VID_SET_FORMAT:
@@ -646,10 +647,10 @@ static int do_control(priv_t *priv, int cmd, void *arg)
priv->format.fmt.pix.field = V4L2_FIELD_ANY;
priv->mp_format = *(int *)arg;
- mp_msg(MSGT_TV, MSGL_V, "%s: set format: %s\n", info.short_name,
+ MP_VERBOSE(priv, "%s: set format: %s\n", info.short_name,
pixfmt2name(priv->format.fmt.pix.pixelformat));
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set format failed: %s\n",
+ MP_ERR(priv, "%s: ioctl set format failed: %s\n",
info.short_name, strerror(errno));
return TVI_CONTROL_FALSE;
}
@@ -660,7 +661,7 @@ static int do_control(priv_t *priv, int cmd, void *arg)
case TVI_CONTROL_VID_GET_WIDTH:
if (getfmt(priv) < 0) return TVI_CONTROL_FALSE;
*(int *)arg = priv->format.fmt.pix.width;
- mp_msg(MSGT_TV, MSGL_V, "%s: get width: %d\n", info.short_name,
+ MP_VERBOSE(priv, "%s: get width: %d\n", info.short_name,
*(int *)arg);
return TVI_CONTROL_TRUE;
case TVI_CONTROL_VID_CHK_WIDTH:
@@ -676,10 +677,10 @@ static int do_control(priv_t *priv, int cmd, void *arg)
case TVI_CONTROL_VID_SET_WIDTH:
if (getfmt(priv) < 0) return TVI_CONTROL_FALSE;
priv->format.fmt.pix.width = *(int *)arg;
- mp_msg(MSGT_TV, MSGL_V, "%s: set width: %d\n", info.short_name,
+ MP_VERBOSE(priv, "%s: set width: %d\n", info.short_name,
*(int *)arg);
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set width failed: %s\n",
+ MP_ERR(priv, "%s: ioctl set width failed: %s\n",
info.short_name, strerror(errno));
return TVI_CONTROL_FALSE;
}
@@ -687,7 +688,7 @@ static int do_control(priv_t *priv, int cmd, void *arg)
case TVI_CONTROL_VID_GET_HEIGHT:
if (getfmt(priv) < 0) return TVI_CONTROL_FALSE;
*(int *)arg = priv->format.fmt.pix.height;
- mp_msg(MSGT_TV, MSGL_V, "%s: get height: %d\n", info.short_name,
+ MP_VERBOSE(priv, "%s: get height: %d\n", info.short_name,
*(int *)arg);
return TVI_CONTROL_TRUE;
case TVI_CONTROL_VID_CHK_HEIGHT:
@@ -696,10 +697,10 @@ static int do_control(priv_t *priv, int cmd, void *arg)
if (getfmt(priv) < 0) return TVI_CONTROL_FALSE;
priv->format.fmt.pix.height = *(int *)arg;
priv->format.fmt.pix.field = V4L2_FIELD_ANY;
- mp_msg(MSGT_TV, MSGL_V, "%s: set height: %d\n", info.short_name,
+ MP_VERBOSE(priv, "%s: set height: %d\n", info.short_name,
*(int *)arg);
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set height failed: %s\n",
+ MP_ERR(priv, "%s: ioctl set height failed: %s\n",
info.short_name, strerror(errno));
return TVI_CONTROL_FALSE;
}
@@ -786,7 +787,7 @@ static int do_control(priv_t *priv, int cmd, void *arg)
frequency.tuner = 0;
frequency.type = V4L2_TUNER_ANALOG_TV;
if (v4l2_ioctl(priv->video_fd, VIDIOC_G_FREQUENCY, &frequency) < 0) {
- mp_msg(MSGT_TV,MSGL_ERR,"%s: ioctl get frequency failed: %s\n",
+ MP_ERR(priv, "%s: ioctl get frequency failed: %s\n",
info.short_name, strerror(errno));
return TVI_CONTROL_FALSE;
}
@@ -801,7 +802,7 @@ static int do_control(priv_t *priv, int cmd, void *arg)
frequency.type = V4L2_TUNER_ANALOG_TV;
frequency.frequency = *(int *)arg;
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_FREQUENCY, &frequency) < 0) {
- mp_msg(MSGT_TV,MSGL_ERR,"%s: ioctl set frequency failed: %s\n",
+ MP_ERR(priv, "%s: ioctl set frequency failed: %s\n",
info.short_name, strerror(errno));
return TVI_CONTROL_FALSE;
}
@@ -811,17 +812,17 @@ static int do_control(priv_t *priv, int cmd, void *arg)
#endif
return TVI_CONTROL_TRUE;
case TVI_CONTROL_TUN_GET_TUNER:
- mp_msg(MSGT_TV, MSGL_V, "%s: get tuner\n",info.short_name);
+ MP_VERBOSE(priv, "%s: get tuner\n",info.short_name);
if (v4l2_ioctl(priv->video_fd, VIDIOC_G_TUNER, &priv->tuner) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get tuner failed: %s\n",
+ MP_ERR(priv, "%s: ioctl get tuner failed: %s\n",
info.short_name, strerror(errno));
return TVI_CONTROL_FALSE;
}
return TVI_CONTROL_TRUE;
case TVI_CONTROL_TUN_SET_TUNER:
- mp_msg(MSGT_TV, MSGL_V, "%s: set tuner\n",info.short_name);
+ MP_VERBOSE(priv, "%s: set tuner\n",info.short_name);
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_TUNER, &priv->tuner) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set tuner failed: %s\n",
+ MP_ERR(priv, "%s: ioctl set tuner failed: %s\n",
info.short_name, strerror(errno));
return TVI_CONTROL_FALSE;
}
@@ -831,7 +832,7 @@ static int do_control(priv_t *priv, int cmd, void *arg)
return TVI_CONTROL_TRUE;
case TVI_CONTROL_TUN_GET_SIGNAL:
if (v4l2_ioctl(priv->video_fd, VIDIOC_G_TUNER, &priv->tuner) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get tuner failed: %s\n",
+ MP_ERR(priv, "%s: ioctl get tuner failed: %s\n",
info.short_name, strerror(errno));
return TVI_CONTROL_FALSE;
}
@@ -840,13 +841,13 @@ static int do_control(priv_t *priv, int cmd, void *arg)
case TVI_CONTROL_TUN_SET_NORM:
priv->standard.index = *(int *)arg;
if (v4l2_ioctl(priv->video_fd, VIDIOC_ENUMSTD, &priv->standard) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl enum norm failed: %s\n",
+ MP_ERR(priv, "%s: ioctl enum norm failed: %s\n",
info.short_name, strerror(errno));
return TVI_CONTROL_FALSE;
}
- mp_msg(MSGT_TV, MSGL_V, "%s: set norm: %s\n", info.short_name, priv->standard.name);
+ MP_VERBOSE(priv, "%s: set norm: %s\n", info.short_name, priv->standard.name);
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_STD, &priv->standard.id) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set norm failed: %s\n",
+ MP_ERR(priv, "%s: ioctl set norm failed: %s\n",
info.short_name, strerror(errno));
return TVI_CONTROL_FALSE;
}
@@ -869,21 +870,21 @@ static int do_control(priv_t *priv, int cmd, void *arg)
}
case TVI_CONTROL_SPC_GET_INPUT:
if (v4l2_ioctl(priv->video_fd, VIDIOC_G_INPUT, (int *)arg) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get input failed: %s\n",
+ MP_ERR(priv, "%s: ioctl get input failed: %s\n",
info.short_name, strerror(errno));
return TVI_CONTROL_FALSE;
}
return TVI_CONTROL_TRUE;
case TVI_CONTROL_SPC_SET_INPUT:
- mp_msg(MSGT_TV, MSGL_V, "%s: set input: %d\n", info.short_name, *(int *)arg);
+ MP_VERBOSE(priv, "%s: set input: %d\n", info.short_name, *(int *)arg);
priv->input.index = *(int *)arg;
if (v4l2_ioctl(priv->video_fd, VIDIOC_ENUMINPUT, &priv->input) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl enum input failed: %s\n",
+ MP_ERR(priv, "%s: ioctl enum input failed: %s\n",
info.short_name, strerror(errno));
return TVI_CONTROL_FALSE;
}
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_INPUT, (int *)arg) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set input failed: %s\n",
+ MP_ERR(priv, "%s: ioctl set input failed: %s\n",
info.short_name, strerror(errno));
return TVI_CONTROL_FALSE;
}
@@ -892,32 +893,32 @@ static int do_control(priv_t *priv, int cmd, void *arg)
init_audio(priv);
if (!priv->audio_initialized) return TVI_CONTROL_FALSE;
*(int *)arg = AF_FORMAT_S16_LE;
- mp_msg(MSGT_TV, MSGL_V, "%s: get audio format: %d\n",
+ MP_VERBOSE(priv, "%s: get audio format: %d\n",
info.short_name, *(int *)arg);
return TVI_CONTROL_TRUE;
case TVI_CONTROL_AUD_GET_SAMPLERATE:
init_audio(priv);
if (!priv->audio_initialized) return TVI_CONTROL_FALSE;
*(int *)arg = priv->audio_in.samplerate;
- mp_msg(MSGT_TV, MSGL_V, "%s: get audio samplerate: %d\n",
+ MP_VERBOSE(priv, "%s: get audio samplerate: %d\n",
info.short_name, *(int *)arg);
return TVI_CONTROL_TRUE;
case TVI_CONTROL_AUD_GET_CHANNELS:
init_audio(priv);
if (!priv->audio_initialized) return TVI_CONTROL_FALSE;
*(int *)arg = priv->audio_in.channels;
- mp_msg(MSGT_TV, MSGL_V, "%s: get audio channels: %d\n",
+ MP_VERBOSE(priv, "%s: get audio channels: %d\n",
info.short_name, *(int *)arg);
return TVI_CONTROL_TRUE;
case TVI_CONTROL_AUD_SET_SAMPLERATE:
init_audio(priv);
- mp_msg(MSGT_TV, MSGL_V, "%s: set audio samplerate: %d\n",
+ MP_VERBOSE(priv, "%s: set audio samplerate: %d\n",
info.short_name, *(int *)arg);
if (audio_in_set_samplerate(&priv->audio_in, *(int*)arg) < 0) return TVI_CONTROL_FALSE;
// setup_audio_buffer_sizes(priv);
return TVI_CONTROL_TRUE;
}
- mp_msg(MSGT_TV, MSGL_V, "%s: unknown control: %d\n", info.short_name, cmd);
+ MP_VERBOSE(priv, "%s: unknown control: %d\n", info.short_name, cmd);
return TVI_CONTROL_UNKNOWN;
}
@@ -925,14 +926,15 @@ static int do_control(priv_t *priv, int cmd, void *arg)
#define PRIV ((priv_t *) (tvi_handle->priv))
/* handler creator - entry point ! */
-static tvi_handle_t *tvi_init_v4l2(tv_param_t* tv_param)
+static tvi_handle_t *tvi_init_v4l2(struct mp_log *log, tv_param_t* tv_param)
{
tvi_handle_t *tvi_handle;
- tvi_handle = tv_new_handle(sizeof(priv_t), &functions);
+ tvi_handle = tv_new_handle(sizeof(priv_t), log, &functions);
if (!tvi_handle) {
return NULL;
}
+ PRIV->log = log;
PRIV->video_fd = -1;
PRIV->video_dev = strdup(tv_param->device? tv_param->device: "/dev/video0");
@@ -975,7 +977,7 @@ static int uninit(priv_t *priv)
/* turn off streaming */
if (v4l2_ioctl(priv->video_fd, VIDIOC_STREAMOFF, &(priv->map[0].buf.type)) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl streamoff failed: %s\n",
+ MP_ERR(priv, "%s: ioctl streamoff failed: %s\n",
info.short_name, strerror(errno));
}
priv->streamon = 0;
@@ -990,7 +992,7 @@ static int uninit(priv_t *priv)
/* unmap all buffers */
for (i = 0; i < priv->mapcount; i++) {
if (v4l2_munmap(priv->map[i].addr, priv->map[i].len) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: munmap capture buffer failed: %s\n",
+ MP_ERR(priv, "%s: munmap capture buffer failed: %s\n",
info.short_name, strerror(errno));
}
}
@@ -1025,10 +1027,9 @@ static int uninit(priv_t *priv)
}
/* show some nice statistics ;-) */
- mp_msg(MSGT_TV, MSGL_INFO,
- "%s: %d frames successfully processed, %d frames dropped.\n",
+ MP_INFO(priv, "%s: %d frames successfully processed, %d frames dropped.\n",
info.short_name, priv->frames, dropped);
- mp_msg(MSGT_TV, MSGL_V, "%s: up to %u video frames buffered.\n",
+ MP_VERBOSE(priv, "%s: up to %u video frames buffered.\n",
info.short_name, priv->video_buffer_size_current);
return 1;
}
@@ -1048,12 +1049,12 @@ static int init(priv_t *priv)
/* Open the video device. */
priv->video_fd = v4l2_open(priv->video_dev, O_RDWR);
if (priv->video_fd < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: unable to open '%s': %s\n",
+ MP_ERR(priv, "%s: unable to open '%s': %s\n",
info.short_name, priv->video_dev, strerror(errno));
uninit(priv);
return 0;
}
- mp_msg(MSGT_TV, MSGL_DBG2, "%s: video fd: %s: %d\n",
+ MP_DBG(priv, "%s: video fd: %s: %d\n",
info.short_name, priv->video_dev, priv->video_fd);
/*
@@ -1061,7 +1062,7 @@ static int init(priv_t *priv)
** for further control calls.
*/
if (v4l2_ioctl(priv->video_fd, VIDIOC_QUERYCAP, &priv->capability) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl query capabilities failed: %s\n",
+ MP_ERR(priv, "%s: ioctl query capabilities failed: %s\n",
info.short_name, strerror(errno));
uninit(priv);
return 0;
@@ -1069,7 +1070,7 @@ static int init(priv_t *priv)
if (!(priv->capability.capabilities & V4L2_CAP_VIDEO_CAPTURE))
{
- mp_msg(MSGT_TV, MSGL_ERR, "Device %s is not a video capture device.\n",
+ MP_ERR(priv, "Device %s is not a video capture device.\n",
priv->video_dev);
return 0;
}
@@ -1085,25 +1086,25 @@ static int init(priv_t *priv)
*/
if (priv->capability.capabilities & V4L2_CAP_TUNER) {
if (v4l2_ioctl(priv->video_fd, VIDIOC_G_TUNER, &priv->tuner) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get tuner failed: %s\n",
+ MP_ERR(priv, "%s: ioctl get tuner failed: %s\n",
info.short_name, strerror(errno));
uninit(priv);
return 0;
}
}
- mp_msg(MSGT_TV, MSGL_INFO, "Selected device: %s\n", priv->capability.card);
+ MP_INFO(priv, "Selected device: %s\n", priv->capability.card);
if (priv->capability.capabilities & V4L2_CAP_TUNER) {
- mp_msg(MSGT_TV, MSGL_INFO, " Tuner cap:%s%s%s\n",
+ MP_INFO(priv, " Tuner cap:%s%s%s\n",
(priv->tuner.capability & V4L2_TUNER_CAP_STEREO) ? " STEREO" : "",
(priv->tuner.capability & V4L2_TUNER_CAP_LANG1) ? " LANG1" : "",
(priv->tuner.capability & V4L2_TUNER_CAP_LANG2) ? " LANG2" : "");
- mp_msg(MSGT_TV, MSGL_INFO, " Tuner rxs:%s%s%s%s\n",
+ MP_INFO(priv, " Tuner rxs:%s%s%s%s\n",
(priv->tuner.rxsubchans & V4L2_TUNER_SUB_MONO) ? " MONO" : "",
(priv->tuner.rxsubchans & V4L2_TUNER_SUB_STEREO) ? " STEREO" : "",
(priv->tuner.rxsubchans & V4L2_TUNER_SUB_LANG1) ? " LANG1" : "",
(priv->tuner.rxsubchans & V4L2_TUNER_SUB_LANG2) ? " LANG2" : "");
}
- mp_msg(MSGT_TV, MSGL_INFO, " Capabilities:%s%s%s%s%s%s%s%s%s%s%s\n",
+ MP_INFO(priv, " Capabilities:%s%s%s%s%s%s%s%s%s%s%s\n",
priv->capability.capabilities & V4L2_CAP_VIDEO_CAPTURE?
" video capture": "",
priv->capability.capabilities & V4L2_CAP_VIDEO_OUTPUT?
@@ -1126,16 +1127,16 @@ static int init(priv_t *priv)
" async i/o": "",
priv->capability.capabilities & V4L2_CAP_STREAMING?
" streaming": "");
- mp_msg(MSGT_TV, MSGL_INFO, " supported norms:");
+ MP_INFO(priv, " supported norms:");
for (i = 0;; i++) {
struct v4l2_standard standard;
memset(&standard, 0, sizeof(standard));
standard.index = i;
if (-1 == v4l2_ioctl(priv->video_fd, VIDIOC_ENUMSTD, &standard))
break;
- mp_msg(MSGT_TV, MSGL_INFO, " %d = %s;", i, standard.name);
+ MP_INFO(priv, " %d = %s;", i, standard.name);
}
- mp_msg(MSGT_TV, MSGL_INFO, "\n inputs:");
+ MP_INFO(priv, "\n inputs:");
for (i = 0; 1; i++) {
struct v4l2_input input;
@@ -1143,14 +1144,14 @@ static int init(priv_t *priv)
if (v4l2_ioctl(priv->video_fd, VIDIOC_ENUMINPUT, &input) < 0) {
break;
}
- mp_msg(MSGT_TV, MSGL_INFO, " %d = %s;", i, input.name);
+ MP_INFO(priv, " %d = %s;", i, input.name);
}
i = -1;
if (v4l2_ioctl(priv->video_fd, VIDIOC_G_INPUT, &i) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get input failed: %s\n",
+ MP_ERR(priv, "%s: ioctl get input failed: %s\n",
info.short_name, strerror(errno));
}
- mp_msg(MSGT_TV, MSGL_INFO, "\n Current input: %d\n", i);
+ MP_INFO(priv, "\n Current input: %d\n", i);
for (i = 0; ; i++) {
struct v4l2_fmtdesc fmtdesc;
@@ -1159,11 +1160,11 @@ static int init(priv_t *priv)
if (v4l2_ioctl(priv->video_fd, VIDIOC_ENUM_FMT, &fmtdesc) < 0) {
break;
}
- mp_msg(MSGT_TV, MSGL_V, " Format %-6s (%2d bits, %s)\n",
+ MP_VERBOSE(priv, " Format %-6s (%2d bits, %s)\n",
pixfmt2name(fmtdesc.pixelformat), pixfmt2depth(fmtdesc.pixelformat),
fmtdesc.description);
}
- mp_msg(MSGT_TV, MSGL_INFO, " Current format: %s\n",
+ MP_INFO(priv, " Current format: %s\n",
pixfmt2name(priv->format.fmt.pix.pixelformat));
/* set some nice defaults */
@@ -1171,7 +1172,7 @@ static int init(priv_t *priv)
priv->format.fmt.pix.width = 640;
priv->format.fmt.pix.height = 480;
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set format failed: %s\n",
+ MP_ERR(priv, "%s: ioctl set format failed: %s\n",
info.short_name, strerror(errno));
uninit(priv);
return 0;
@@ -1182,15 +1183,15 @@ static int init(priv_t *priv)
if (priv->capability.capabilities & V4L2_CAP_TUNER) {
struct v4l2_control control;
if (priv->tv_param->amode >= 0) {
- mp_msg(MSGT_TV, MSGL_V, "%s: setting audio mode\n", info.short_name);
+ MP_VERBOSE(priv, "%s: setting audio mode\n", info.short_name);
priv->tuner.audmode = amode2v4l(priv->tv_param->amode);
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_TUNER, &priv->tuner) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set tuner failed: %s\n",
+ MP_ERR(priv, "%s: ioctl set tuner failed: %s\n",
info.short_name, strerror(errno));
return TVI_CONTROL_FALSE;
}
}
- mp_msg(MSGT_TV, MSGL_INFO, "%s: current audio mode is :%s%s%s%s\n", info.short_name,
+ MP_INFO(priv, "%s: current audio mode is :%s%s%s%s\n", info.short_name,
(priv->tuner.audmode == V4L2_TUNER_MODE_MONO) ? " MONO" : "",
(priv->tuner.audmode == V4L2_TUNER_MODE_STEREO) ? " STEREO" : "",
(priv->tuner.audmode == V4L2_TUNER_MODE_LANG1) ? " LANG1" : "",
@@ -1267,18 +1268,18 @@ static int start(priv_t *priv)
setup_audio_buffer_sizes(priv);
priv->audio_skew_buffer = calloc(priv->aud_skew_cnt, sizeof(long long));
if (!priv->audio_skew_buffer) {
- mp_msg(MSGT_TV, MSGL_ERR, "cannot allocate skew buffer: %s\n", strerror(errno));
+ MP_ERR(priv, "cannot allocate skew buffer: %s\n", strerror(errno));
return 0;
}
priv->audio_skew_delta_buffer = calloc(priv->aud_skew_cnt, sizeof(long long));
if (!priv->audio_skew_delta_buffer) {
- mp_msg(MSGT_TV, MSGL_ERR, "cannot allocate skew buffer: %s\n", strerror(errno));
+ MP_ERR(priv, "cannot allocate skew buffer: %s\n", strerror(errno));
return 0;
}
priv->audio_ringbuffer = calloc(priv->audio_in.blocksize, priv->audio_buffer_size);
if (!priv->audio_ringbuffer) {
- mp_msg(MSGT_TV, MSGL_ERR, "cannot allocate audio buffer: %s\n", strerror(errno));
+ MP_ERR(priv, "cannot allocate audio buffer: %s\n", strerror(errno));
return 0;
}
@@ -1307,7 +1308,7 @@ static int start(priv_t *priv)
/* setup video parameters */
if (!priv->tv_param->noaudio) {
if (priv->video_buffer_size_max < 3*getfps(priv)*priv->audio_secs_per_block) {
- mp_msg(MSGT_TV, MSGL_ERR, "Video buffer shorter than 3 times audio frame duration.\n"
+ MP_ERR(priv, "Video buffer shorter than 3 times audio frame duration.\n"
"You will probably experience heavy framedrops.\n");
}
}
@@ -1315,14 +1316,14 @@ static int start(priv_t *priv)
{
int bytesperline = priv->format.fmt.pix.width*pixfmt2depth(priv->format.fmt.pix.pixelformat)/8;
- mp_msg(MSGT_TV, MSGL_V, "Using a ring buffer for maximum %d frames, %d MB total size.\n",
+ MP_VERBOSE(priv, "Using a ring buffer for maximum %d frames, %d MB total size.\n",
priv->video_buffer_size_max,
priv->video_buffer_size_max*priv->format.fmt.pix.height*bytesperline/(1024*1024));
}
priv->video_ringbuffer = calloc(priv->video_buffer_size_max, sizeof(video_buffer_entry));
if (!priv->video_ringbuffer) {
- mp_msg(MSGT_TV, MSGL_ERR, "cannot allocate video buffer: %s\n", strerror(errno));
+ MP_ERR(priv, "cannot allocate video buffer: %s\n", strerror(errno));
return 0;
}
memset(priv->video_ringbuffer,0,priv->video_buffer_size_max * sizeof(video_buffer_entry));
@@ -1343,14 +1344,14 @@ static int start(priv_t *priv)
request.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
request.memory = V4L2_MEMORY_MMAP;
if (v4l2_ioctl(priv->video_fd, VIDIOC_REQBUFS, &request) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl request buffers failed: %s\n",
+ MP_ERR(priv, "%s: ioctl request buffers failed: %s\n",
info.short_name, strerror(errno));
return 0;
}
/* query buffers */
if (!(priv->map = calloc(request.count, sizeof(struct map)))) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: malloc capture buffers failed: %s\n",
+ MP_ERR(priv, "%s: malloc capture buffers failed: %s\n",
info.short_name, strerror(errno));
return 0;
}
@@ -1362,7 +1363,7 @@ static int start(priv_t *priv)
priv->map[i].buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
priv->map[i].buf.memory = V4L2_MEMORY_MMAP;
if (v4l2_ioctl(priv->video_fd, VIDIOC_QUERYBUF, &(priv->map[i].buf)) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl query buffer failed: %s\n",
+ MP_ERR(priv, "%s: ioctl query buffer failed: %s\n",
info.short_name, strerror(errno));
free(priv->map);
priv->map = NULL;
@@ -1371,7 +1372,7 @@ static int start(priv_t *priv)
priv->map[i].addr = v4l2_mmap (0, priv->map[i].buf.length, PROT_READ |
PROT_WRITE, MAP_SHARED, priv->video_fd, priv->map[i].buf.m.offset);
if (priv->map[i].addr == MAP_FAILED) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: mmap capture buffer failed: %s\n",
+ MP_ERR(priv, "%s: mmap capture buffer failed: %s\n",
info.short_name, strerror(errno));
priv->map[i].len = 0;
return 0;
@@ -1381,7 +1382,7 @@ static int start(priv_t *priv)
priv->mapcount++;
if (v4l2_ioctl(priv->video_fd, VIDIOC_QBUF, &(priv->map[i].buf)) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl queue buffer failed: %s\n",
+ MP_ERR(priv, "%s: ioctl queue buffer failed: %s\n",
info.short_name, strerror(errno));
return 0;
}
@@ -1434,9 +1435,9 @@ static void *video_grabber(void *data)
prev_interval = 0;
prev_skew = 0;
- mp_msg(MSGT_TV, MSGL_V, "%s: going to capture\n", info.short_name);
+ MP_VERBOSE(priv, "%s: going to capture\n", info.short_name);
if (v4l2_ioctl(priv->video_fd, VIDIOC_STREAMON, &(priv->format.type)) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl streamon failed: %s\n",
+ MP_ERR(priv, "%s: ioctl streamon failed: %s\n",
info.short_name, strerror(errno));
return 0;
}
@@ -1467,12 +1468,12 @@ static void *video_grabber(void *data)
i = select(priv->video_fd + 1, &rdset, NULL, NULL, &timeout);
if (i < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: select failed: %s\n",
+ MP_ERR(priv, "%s: select failed: %s\n",
info.short_name, strerror(errno));
continue;
}
else if (i == 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: select timeout\n", info.short_name);
+ MP_ERR(priv, "%s: select timeout\n", info.short_name);
continue;
}
else if (!FD_ISSET(priv->video_fd, &rdset)) {
@@ -1493,7 +1494,7 @@ static void *video_grabber(void *data)
observed with saa7134 0.2.8
don't know if is it a bug or (mis)feature
*/
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl dequeue buffer failed: %s, idx = %d\n",
+ MP_ERR(priv, "%s: ioctl dequeue buffer failed: %s, idx = %d\n",
info.short_name, strerror(errno), buf.index);
for (i = 0; i < priv->mapcount; i++) {
memset(&buf,0,sizeof(buf));
@@ -1502,13 +1503,13 @@ static void *video_grabber(void *data)
buf.index = i;
ret = v4l2_ioctl(priv->video_fd, VIDIOC_QUERYBUF, &buf);
if (ret < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl query buffer failed: %s, idx = %d\n",
+ MP_ERR(priv, "%s: ioctl query buffer failed: %s, idx = %d\n",
info.short_name, strerror(errno), buf.index);
return 0;
}
if ((buf.flags & (V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_DONE)) == V4L2_BUF_FLAG_MAPPED) {
if (v4l2_ioctl(priv->video_fd, VIDIOC_QBUF, &(priv->map[i].buf)) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl queue buffer failed: %s\n",
+ MP_ERR(priv, "%s: ioctl queue buffer failed: %s\n",
info.short_name, strerror(errno));
return 0;
}
@@ -1544,10 +1545,10 @@ static void *video_grabber(void *data)
}
}
- mp_msg(MSGT_TV, MSGL_DBG3, "\nfps = %f, interval = %f, a_skew = %f, corr_skew = %f\n",
+ MP_TRACE(priv, "\nfps = %f, interval = %f, a_skew = %f, corr_skew = %f\n",
delta ? (double)1e6/delta : -1,
(double)1e-6*interval, (double)1e-6*xskew, (double)1e-6*skew);
- mp_msg(MSGT_TV, MSGL_DBG3, "vcnt = %d, acnt = %d\n", priv->video_cnt, priv->audio_cnt);
+ MP_TRACE(priv, "vcnt = %d, acnt = %d\n", priv->video_cnt, priv->audio_cnt);
prev_skew = skew;
prev_interval = interval;
@@ -1570,7 +1571,7 @@ static void *video_grabber(void *data)
if (priv->video_cnt == priv->video_buffer_size_current) {
if (!priv->immediate_mode) {
- mp_msg(MSGT_TV, MSGL_ERR, "\nvideo buffer full - dropping frame\n");
+ MP_ERR(priv, "\nvideo buffer full - dropping frame\n");
if (priv->audio_insert_null_samples) {
pthread_mutex_lock(&priv->audio_mutex);
priv->dropped_frames_timeshift += delta;
@@ -1599,7 +1600,7 @@ static void *video_grabber(void *data)
priv->video_cnt++;
}
if (v4l2_ioctl(priv->video_fd, VIDIOC_QBUF, &buf) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl queue buffer failed: %s\n",
+ MP_ERR(priv, "%s: ioctl queue buffer failed: %s\n",
info.short_name, strerror(errno));
return 0;
}
@@ -1746,7 +1747,7 @@ static void *audio_grabber(void *data)
pthread_mutex_lock(&priv->audio_mutex);
if ((priv->audio_tail+1) % priv->audio_buffer_size == priv->audio_head) {
- mp_msg(MSGT_TV, MSGL_ERR, "\ntoo bad - dropping audio frame !\n");
+ MP_ERR(priv, "\ntoo bad - dropping audio frame !\n");
priv->audio_drop++;
} else {
priv->audio_tail = (priv->audio_tail+1) % priv->audio_buffer_size;
@@ -1759,7 +1760,7 @@ static void *audio_grabber(void *data)
static double grab_audio_frame(priv_t *priv, char *buffer, int len)
{
- mp_msg(MSGT_TV, MSGL_DBG2, "grab_audio_frame(priv=%p, buffer=%p, len=%d)\n",
+ MP_DBG(priv, "grab_audio_frame(priv=%p, buffer=%p, len=%d)\n",
priv, buffer, len);
// hack: if grab_audio_frame is called first, it means we are used by mplayer