diff options
Diffstat (limited to 'stream')
-rw-r--r-- | stream/ai_alsa1x.c | 36 | ||||
-rw-r--r-- | stream/ai_oss.c | 42 | ||||
-rw-r--r-- | stream/ai_sndio.c | 4 | ||||
-rw-r--r-- | stream/audio_in.c | 19 | ||||
-rw-r--r-- | stream/audio_in.h | 5 | ||||
-rw-r--r-- | stream/stream_radio.c | 2 | ||||
-rw-r--r-- | stream/tv.c | 110 | ||||
-rw-r--r-- | stream/tv.h | 7 | ||||
-rw-r--r-- | stream/tvi_dummy.c | 6 | ||||
-rw-r--r-- | stream/tvi_v4l2.c | 195 |
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 --- |