summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
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/cache.c43
-rw-r--r--stream/cdd.h4
-rw-r--r--stream/cdinfo.c41
-rw-r--r--stream/cookies.c34
-rw-r--r--stream/cookies.h2
-rw-r--r--stream/dvb_tune.c108
-rw-r--r--stream/dvb_tune.h6
-rw-r--r--stream/dvbin.h3
-rw-r--r--stream/rar.c6
-rw-r--r--stream/rar.h2
-rw-r--r--stream/resolve/resolve.h6
-rw-r--r--stream/resolve/resolve_quvi.c13
-rw-r--r--stream/resolve/resolve_quvi9.c28
-rw-r--r--stream/stream.c84
-rw-r--r--stream/stream.h10
-rw-r--r--stream/stream_bluray.c26
-rw-r--r--stream/stream_cdda.c16
-rw-r--r--stream/stream_dvb.c124
-rw-r--r--stream/stream_dvd.c152
-rw-r--r--stream/stream_dvd_common.c12
-rw-r--r--stream/stream_dvd_common.h3
-rw-r--r--stream/stream_dvdnav.c46
-rw-r--r--stream/stream_file.c12
-rw-r--r--stream/stream_lavf.c12
-rw-r--r--stream/stream_pvr.c219
-rw-r--r--stream/stream_radio.c106
-rw-r--r--stream/stream_rar.c4
-rw-r--r--stream/stream_smb.c8
-rw-r--r--stream/stream_vcd.c16
-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
-rw-r--r--stream/vcd_read.h49
-rw-r--r--stream/vcd_read_darwin.h46
-rw-r--r--stream/vcd_read_fbsd.h29
-rw-r--r--stream/vcd_read_win32.h34
42 files changed, 782 insertions, 946 deletions
diff --git a/stream/ai_alsa1x.c b/stream/ai_alsa1x.c
index 880817a94e..c1a7199c71 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(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(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/cache.c b/stream/cache.c
index 5f01275674..e622ae9af8 100644
--- a/stream/cache.c
+++ b/stream/cache.c
@@ -73,6 +73,8 @@ struct priv {
int64_t seek_limit; // keep filling cache if distance is less that seek limit
struct byte_meta *bm; // additional per-byte metadata
+ struct mp_log *log;
+
// Owned by the main thread
stream_t *cache; // wrapper stream, used by demuxer etc.
@@ -142,10 +144,9 @@ static int cache_wakeup_and_wait(struct priv *s, double *retry_time)
// Print a "more severe" warning after waiting 1 second and no new data
if ((*retry_time) >= 1.0) {
- mp_msg(MSGT_CACHE, MSGL_ERR, "Cache keeps not responding.\n");
+ MP_ERR(s, "Cache keeps not responding.\n");
} else if (*retry_time > 0.1) {
- mp_msg(MSGT_CACHE, MSGL_WARN,
- "Cache is not responding - slow/stuck network connection?\n");
+ MP_WARN(s, "Cache is not responding - slow/stuck network connection?\n");
}
double start = mp_time_sec();
@@ -211,14 +212,13 @@ static bool cache_fill(struct priv *s)
if (read < s->min_filepos || read > s->max_filepos) {
// seek...
- mp_msg(MSGT_CACHE, MSGL_DBG2,
- "Out of boundaries... seeking to %" PRId64 " \n", read);
+ MP_DBG(s, "Out of boundaries... seeking to %" PRId64 " \n", read);
// drop cache contents only if seeking backward or too much fwd.
// This is also done for on-disk files, since it loses the backseek cache.
// That in turn can cause major bandwidth increase and performance
// issues with e.g. mov or badly interleaved files
if (read < s->min_filepos || read >= s->max_filepos + s->seek_limit) {
- mp_msg(MSGT_CACHE, MSGL_V, "Dropping cache at pos %"PRId64", "
+ MP_VERBOSE(s, "Dropping cache at pos %"PRId64", "
"cached range: %"PRId64"-%"PRId64".\n", read,
s->min_filepos, s->max_filepos);
cache_drop_contents(s);
@@ -280,7 +280,7 @@ static bool cache_fill(struct priv *s)
s->idle = s->eof;
s->reads++;
if (s->eof)
- mp_msg(MSGT_CACHE, MSGL_V, "EOF reached.\n");
+ MP_VERBOSE(s, "EOF reached.\n");
pthread_cond_signal(&s->wakeup);
@@ -404,10 +404,10 @@ static void cache_execute_control(struct priv *s)
bool pos_changed = old_pos != stream_tell(s->stream);
bool ok = s->control_res == STREAM_OK;
if (pos_changed && !ok) {
- mp_msg(MSGT_STREAM, MSGL_ERR, "STREAM_CTRL changed stream pos but "
+ MP_ERR(s, "STREAM_CTRL changed stream pos but "
"returned error, this is not allowed!\n");
} else if (pos_changed || (ok && control_needs_flush(s->control))) {
- mp_msg(MSGT_CACHE, MSGL_V, "Dropping cache due to control()\n");
+ MP_VERBOSE(s, "Dropping cache due to control()\n");
s->read_filepos = stream_tell(s->stream);
s->control_flush = true;
cache_drop_contents(s);
@@ -442,7 +442,7 @@ static void *cache_thread(void *arg)
}
pthread_cond_signal(&s->wakeup);
pthread_mutex_unlock(&s->mutex);
- mp_msg(MSGT_CACHE, MSGL_V, "Cache exiting...\n");
+ MP_VERBOSE(s, "Cache exiting...\n");
return NULL;
}
@@ -454,8 +454,7 @@ static int cache_fill_buffer(struct stream *cache, char *buffer, int max_len)
pthread_mutex_lock(&s->mutex);
if (cache->pos != s->read_filepos)
- mp_msg(MSGT_CACHE, MSGL_ERR,
- "!!! read_filepos differs !!! report this bug...\n");
+ MP_ERR(s, "!!! read_filepos differs !!! report this bug...\n");
int t = cache_read(s, buffer, max_len);
// wakeup the cache thread, possibly make it read more data ahead
@@ -471,7 +470,7 @@ static int cache_seek(stream_t *cache, int64_t pos)
pthread_mutex_lock(&s->mutex);
- mp_msg(MSGT_CACHE, MSGL_DBG2, "request seek: %" PRId64 " <= to=%" PRId64
+ MP_DBG(s, "request seek: %" PRId64 " <= to=%" PRId64
" (cur=%" PRId64 ") <= %" PRId64 " \n",
s->min_filepos, pos, s->read_filepos, s->max_filepos);
@@ -496,7 +495,7 @@ static int cache_control(stream_t *cache, int cmd, void *arg)
if (r != STREAM_ERROR)
goto done;
- mp_msg(MSGT_CACHE, MSGL_V, "[cache] blocking for STREAM_CTRL %d\n", cmd);
+ MP_VERBOSE(s, "[cache] blocking for STREAM_CTRL %d\n", cmd);
s->control = cmd;
s->control_arg = arg;
@@ -524,7 +523,7 @@ static void cache_uninit(stream_t *cache)
{
struct priv *s = cache->priv;
if (s->cache_thread_running) {
- mp_msg(MSGT_CACHE, MSGL_V, "Terminating cache...\n");
+ MP_VERBOSE(s, "Terminating cache...\n");
pthread_mutex_lock(&s->mutex);
s->control = CACHE_CTRL_QUIT;
pthread_cond_signal(&s->wakeup);
@@ -546,16 +545,16 @@ int stream_cache_init(stream_t *cache, stream_t *stream, int64_t size,
if (size < 1)
return -1;
- mp_msg(MSGT_NETWORK, MSGL_INFO, "Cache size set to %" PRId64 " KiB\n",
+ MP_INFO(cache, "Cache size set to %" PRId64 " KiB\n",
size / 1024);
if (size > SIZE_MAX) {
- mp_msg(MSGT_CACHE, MSGL_FATAL,
- "Cache size larger than max. allocation size\n");
+ MP_FATAL(cache, "Cache size larger than max. allocation size\n");
return -1;
}
struct priv *s = talloc_zero(NULL, struct priv);
+ s->log = cache->log;
//64kb min_size
s->fill_limit = FFMAX(16 * 1024, BYTE_META_CHUNK_SIZE * 2);
@@ -566,7 +565,7 @@ int stream_cache_init(stream_t *cache, stream_t *stream, int64_t size,
s->bm = malloc((s->buffer_size / BYTE_META_CHUNK_SIZE + 2) *
sizeof(struct byte_meta));
if (!s->buffer || !s->bm) {
- mp_msg(MSGT_CACHE, MSGL_ERR, "Failed to allocate cache buffer.\n");
+ MP_ERR(s, "Failed to allocate cache buffer.\n");
free(s->buffer);
free(s->bm);
talloc_free(s);
@@ -594,7 +593,7 @@ int stream_cache_init(stream_t *cache, stream_t *stream, int64_t size,
min = s->buffer_size - s->fill_limit;
if (pthread_create(&s->cache_thread, NULL, cache_thread, s) != 0) {
- mp_msg(MSGT_CACHE, MSGL_ERR, "Starting cache process/thread failed: %s.\n",
+ MP_ERR(s, "Starting cache process/thread failed: %s.\n",
strerror(errno));
return -1;
}
@@ -610,7 +609,7 @@ int stream_cache_init(stream_t *cache, stream_t *stream, int64_t size,
break;
if (stream_control(s->cache, STREAM_CTRL_GET_CACHE_IDLE, &idle) < 0)
break;
- mp_msg(MSGT_CACHE, MSGL_STATUS, "\rCache fill: %5.2f%% "
+ MP_INFO(s, "\rCache fill: %5.2f%% "
"(%" PRId64 " bytes) ", 100.0 * fill / s->buffer_size, fill);
if (fill >= min)
break;
@@ -623,6 +622,6 @@ int stream_cache_init(stream_t *cache, stream_t *stream, int64_t size,
cache_wakeup_and_wait(s, &(double){0});
pthread_mutex_unlock(&s->mutex);
}
- mp_msg(MSGT_CACHE, MSGL_STATUS, "\n");
+ MP_INFO(s, "\n");
return 1;
}
diff --git a/stream/cdd.h b/stream/cdd.h
index e44b2ae24a..93b3dfb2b2 100644
--- a/stream/cdd.h
+++ b/stream/cdd.h
@@ -21,6 +21,8 @@
#include <sys/types.h>
+struct mp_log;
+
typedef struct cd_track {
char *name;
unsigned int track_nb;
@@ -51,6 +53,6 @@ void cd_info_free(cd_info_t *cd_info);
cd_track_t* cd_info_add_track(cd_info_t *cd_info, char *track_name, unsigned int track_nb, unsigned int min, unsigned int sec, unsigned int msec, unsigned long frame_begin, unsigned long frame_length);
cd_track_t* cd_info_get_track(cd_info_t *cd_info, unsigned int track_nb);
-void cd_info_debug(cd_info_t *cd_info);
+void cd_info_debug(cd_info_t *cd_info, struct mp_log *log);
#endif /* MPLAYER_CDD_H */
diff --git a/stream/cdinfo.c b/stream/cdinfo.c
index 6398809a0a..2e6e34b1be 100644
--- a/stream/cdinfo.c
+++ b/stream/cdinfo.c
@@ -40,7 +40,6 @@ cd_info_new(void) {
cd_info = malloc(sizeof(cd_info_t));
if( cd_info==NULL ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, "Memory allocation failed.\n");
return NULL;
}
@@ -74,14 +73,12 @@ cd_info_add_track(cd_info_t *cd_info, char *track_name, unsigned int track_nb, u
cd_track = malloc(sizeof(cd_track_t));
if( cd_track==NULL ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, "Memory allocation failed.\n");
return NULL;
}
memset(cd_track, 0, sizeof(cd_track_t));
cd_track->name = malloc(strlen(track_name)+1);
if( cd_track->name==NULL ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, "Memory allocation failed.\n");
free(cd_track);
return NULL;
}
@@ -126,32 +123,32 @@ cd_info_get_track(cd_info_t *cd_info, unsigned int track_nb) {
return NULL;
}
-void
-cd_info_debug(cd_info_t *cd_info) {
+void cd_info_debug(cd_info_t *cd_info, struct mp_log *log)
+{
cd_track_t *current_track;
- mp_msg(MSGT_DEMUX, MSGL_INFO, "================ CD INFO === start =========\n");
+ mp_info(log, "================ CD INFO === start =========\n");
if( cd_info==NULL ) {
- mp_msg(MSGT_DEMUX, MSGL_INFO, "cd_info is NULL\n");
+ mp_info(log, "cd_info is NULL\n");
return;
}
- mp_msg(MSGT_DEMUX, MSGL_INFO, " artist=[%s]\n", cd_info->artist);
- mp_msg(MSGT_DEMUX, MSGL_INFO, " album=[%s]\n", cd_info->album);
- mp_msg(MSGT_DEMUX, MSGL_INFO, " genre=[%s]\n", cd_info->genre);
- mp_msg(MSGT_DEMUX, MSGL_INFO, " nb_tracks=%d\n", cd_info->nb_tracks);
- mp_msg(MSGT_DEMUX, MSGL_INFO, " length= %2d:%02d.%02d\n", cd_info->min, cd_info->sec, cd_info->msec);
-
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDB_INFO_ARTIST=%s\n", cd_info->artist);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDB_INFO_ALBUM=%s\n", cd_info->album);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDB_INFO_GENRE=%s\n", cd_info->genre);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDB_INFO_LENGTH_MSF=%02d:%02d.%02d\n", cd_info->min, cd_info->sec, cd_info->msec);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDB_INFO_TRACKS=%d\n", cd_info->nb_tracks);
+ mp_info(log, " artist=[%s]\n", cd_info->artist);
+ mp_info(log, " album=[%s]\n", cd_info->album);
+ mp_info(log, " genre=[%s]\n", cd_info->genre);
+ mp_info(log, " nb_tracks=%d\n", cd_info->nb_tracks);
+ mp_info(log, " length= %2d:%02d.%02d\n", cd_info->min, cd_info->sec, cd_info->msec);
+
+ mp_info(log, "ID_CDDB_INFO_ARTIST=%s\n", cd_info->artist);
+ mp_info(log, "ID_CDDB_INFO_ALBUM=%s\n", cd_info->album);
+ mp_info(log, "ID_CDDB_INFO_GENRE=%s\n", cd_info->genre);
+ mp_info(log, "ID_CDDB_INFO_LENGTH_MSF=%02d:%02d.%02d\n", cd_info->min, cd_info->sec, cd_info->msec);
+ mp_info(log, "ID_CDDB_INFO_TRACKS=%d\n", cd_info->nb_tracks);
current_track = cd_info->first;
while( current_track!=NULL ) {
- mp_msg(MSGT_DEMUX, MSGL_INFO, " #%2d %2d:%02d.%02d @ %7ld\t[%s] \n", current_track->track_nb, current_track->min, current_track->sec, current_track->msec, current_track->frame_begin, current_track->name);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDB_INFO_TRACK_%d_NAME=%s\n", current_track->track_nb, current_track->name);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDB_INFO_TRACK_%d_MSF=%02d:%02d.%02d\n", current_track->track_nb, current_track->min, current_track->sec, current_track->msec);
+ mp_info(log, " #%2d %2d:%02d.%02d @ %7ld\t[%s] \n", current_track->track_nb, current_track->min, current_track->sec, current_track->msec, current_track->frame_begin, current_track->name);
+ mp_info(log, "ID_CDDB_INFO_TRACK_%d_NAME=%s\n", current_track->track_nb, current_track->name);
+ mp_info(log, "ID_CDDB_INFO_TRACK_%d_MSF=%02d:%02d.%02d\n", current_track->track_nb, current_track->min, current_track->sec, current_track->msec);
current_track = current_track->next;
}
- mp_msg(MSGT_DEMUX, MSGL_INFO, "================ CD INFO === end =========\n");
+ mp_info(log, "================ CD INFO === end =========\n");
}
diff --git a/stream/cookies.c b/stream/cookies.c
index 3fcf11b68f..f29db88b57 100644
--- a/stream/cookies.c
+++ b/stream/cookies.c
@@ -92,40 +92,40 @@ static int parse_line(char **ptr, char *cols[6])
}
/* Loads a file into RAM */
-static char *load_file(const char *filename, int64_t * length)
+static char *load_file(struct mp_log *log, const char *filename, int64_t * length)