aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--common/encode_lavc.c9
-rw-r--r--common/playlist_parser.c2
-rw-r--r--demux/demux_mf.c2
-rw-r--r--input/input.c2
-rw-r--r--player/loadfile.c4
-rw-r--r--player/timeline/tl_cue.c2
-rw-r--r--player/timeline/tl_matroska.c4
-rw-r--r--player/timeline/tl_mpv_edl.c2
-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/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.c127
-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/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
-rw-r--r--video/out/gl_lcms.c9
39 files changed, 557 insertions, 739 deletions
diff --git a/common/encode_lavc.c b/common/encode_lavc.c
index 18f6395b6d..1efe388507 100644
--- a/common/encode_lavc.c
+++ b/common/encode_lavc.c
@@ -399,8 +399,8 @@ static void encode_2pass_prepare(struct encode_lavc_context *ctx,
buf[sizeof(buf) - 1] = 0;
if (value_has_flag(de ? de->value : "", "pass2")) {
- if (!(*bytebuf = stream_open(buf, NULL))) {
- mp_msg(MSGT_ENCODE, MSGL_WARN, "%s: could not open '%s', "
+ if (!(*bytebuf = stream_open(buf, ctx->global))) {
+ MP_WARN(ctx, "%s: could not open '%s', "
"disabling 2-pass encoding at pass 2\n", prefix, buf);
stream->codec->flags &= ~CODEC_FLAG_PASS2;
set_to_avdictionary(ctx, dictp, "flags", "-pass2");
@@ -421,9 +421,8 @@ static void encode_2pass_prepare(struct encode_lavc_context *ctx,
}
if (value_has_flag(de ? de->value : "", "pass1")) {
- if (!(*bytebuf = open_output_stream(buf, NULL))) {
- mp_msg(
- MSGT_ENCODE, MSGL_WARN,
+ if (!(*bytebuf = open_output_stream(buf, ctx->global))) {
+ MP_WARN(ctx,
"%s: could not open '%s', disabling "
"2-pass encoding at pass 1\n",
prefix, ctx->avc->filename);
diff --git a/common/playlist_parser.c b/common/playlist_parser.c
index f33f7204b6..2e06009db5 100644
--- a/common/playlist_parser.c
+++ b/common/playlist_parser.c
@@ -499,7 +499,7 @@ struct playlist *playlist_parse_file(const char *file, struct mpv_global *global
{
struct mp_log *log = mp_log_new(NULL, global->log, "!playlist_parser");
struct playlist *ret = NULL;
- stream_t *stream = stream_open(file, global->opts);
+ stream_t *stream = stream_open(file, global);
if(!stream) {
mp_err(log, "Error while opening playlist file %s: %s\n",
file, strerror(errno));
diff --git a/demux/demux_mf.c b/demux/demux_mf.c
index 1d80cfaa85..1284c7fd7f 100644
--- a/demux/demux_mf.c
+++ b/demux/demux_mf.c
@@ -68,7 +68,7 @@ static int demux_mf_fill_buffer(demuxer_t *demuxer)
if (!stream) {
char *filename = mf->names[mf->curr_frame];
if (filename)
- stream = stream_open(filename, demuxer->opts);
+ stream = stream_open(filename, demuxer->global);
}
if (stream) {
diff --git a/input/input.c b/input/input.c
index 8dd8e76bd8..8756985793 100644
--- a/input/input.c
+++ b/input/input.c
@@ -2208,7 +2208,7 @@ static int parse_config_file(struct input_ctx *ictx, char *file, bool warn)
"Input config file %s not found.\n", file);
goto done;
}
- s = stream_open(file, NULL);
+ s = stream_open(file, ictx->global);
if (!s) {
MP_ERR(ictx, "Can't open input config file %s.\n", file);
goto done;
diff --git a/player/loadfile.c b/player/loadfile.c
index 1d668b9c2c..63c83e64e4 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -724,7 +724,7 @@ static struct track *open_external_file(struct MPContext *mpctx, char *filename,
char *disp_filename = filename;
if (strncmp(disp_filename, "memory://", 9) == 0)
disp_filename = "memory://"; // avoid noise
- struct stream *stream = stream_open(filename, mpctx->opts);
+ struct stream *stream = stream_open(filename, mpctx->global);
if (!stream)
goto err_out;
stream_enable_cache_percent(&stream, stream_cache,
@@ -1046,7 +1046,7 @@ static void play_current_file(struct MPContext *mpctx)
}
stream_filename = mpctx->resolve_result->url;
}
- mpctx->stream = stream_open(stream_filename, opts);
+ mpctx->stream = stream_open(stream_filename, mpctx->global);
if (!mpctx->stream) { // error...
demux_was_interrupted(mpctx);
goto terminate_playback;
diff --git a/player/timeline/tl_cue.c b/player/timeline/tl_cue.c
index 80eaf5ef76..6731ab4058 100644
--- a/player/timeline/tl_cue.c
+++ b/player/timeline/tl_cue.c
@@ -188,7 +188,7 @@ static bool try_open(struct MPContext *mpctx, char *filename)
|| bstrcasecmp(bstr0(mpctx->demuxer->filename), bfilename) == 0)
return false;
- struct stream *s = stream_open(filename, mpctx->opts);
+ struct stream *s = stream_open(filename, mpctx->global);
if (!s)
return false;
struct demuxer *d = demux_open(s, NULL, NULL, mpctx->global);
diff --git a/player/timeline/tl_matroska.c b/player/timeline/tl_matroska.c
index 720bd3f979..59dc024e14 100644
--- a/player/timeline/tl_matroska.c
+++ b/player/timeline/tl_matroska.c
@@ -127,7 +127,7 @@ static int enable_cache(struct MPContext *mpctx, struct stream **stream,
free_demuxer(*demuxer);
free_stream(*stream);
- *stream = stream_open(filename, opts);
+ *stream = stream_open(filename, mpctx->global);
if (!*stream) {
talloc_free(filename);
return -1;
@@ -174,7 +174,7 @@ static bool check_file_seg(struct MPContext *mpctx, struct demuxer ***sources,
.matroska_wanted_segment = segment,
.matroska_was_valid = &was_valid,
};
- struct stream *s = stream_open(filename, mpctx->opts);
+ struct stream *s = stream_open(filename, mpctx->global);
if (!s)
return false;
struct demuxer *d = demux_open(s, "mkv", &params, mpctx->global);
diff --git a/player/timeline/tl_mpv_edl.c b/player/timeline/tl_mpv_edl.c
index b256e0bdd5..651c937c23 100644
--- a/player/timeline/tl_mpv_edl.c
+++ b/player/timeline/tl_mpv_edl.c
@@ -123,7 +123,7 @@ static struct demuxer *open_file(char *filename, struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
struct demuxer *d = NULL;
- struct stream *s = stream_open(filename, opts);
+ struct stream *s = stream_open(filename, mpctx->global);
if (s) {
stream_enable_cache_percent(&s,
opts->stream_cache_size,
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)
{
int fd;
char *buffer = NULL;
- mp_msg(MSGT_NETWORK, MSGL_V, "Loading cookie file: %s\n", filename);
+ mp_verbose(log, "Loading cookie file: %s\n", filename);
fd = open(filename, O_RDONLY | O_CLOEXEC);
if (fd < 0) {
- mp_msg(MSGT_NETWORK, MSGL_V, "Could not open");
+ mp_verbose(log, "Could not open");
goto err_out;
}
*length = lseek(fd, 0, SEEK_END);
if (*length < 0) {
- mp_msg(MSGT_NETWORK, MSGL_V, "Could not find EOF");
+ mp_verbose(log, "Could not find EOF");
goto err_out;
}
if (*length > SIZE_MAX - 1) {
- mp_msg(MSGT_NETWORK, MSGL_V, "File too big, could not malloc.");
+ mp_verbose(log, "File too big, could not malloc.");
goto err_out;
}
lseek(fd, 0, SEEK_SET);
if (!(buffer = malloc(*length + 1))) {
- mp_msg(MSGT_NETWORK, MSGL_V, "Could not malloc.");
+ mp_verbose(log, "Could not malloc.");
goto err_out;
}
if (read(fd, buffer, *length) != *length) {
- mp_msg(MSGT_NETWORK, MSGL_V, "Read is behaving funny.");
+ mp_verbose(log, "Read is behaving funny.");
goto err_out;
}
close(fd);
@@ -140,14 +140,15 @@ err_out:
}
/* Loads a cookies.txt file into a linked list. */
-static struct cookie_list_type *load_cookies_from(const char *filename,
+static struct cookie_list_type *load_cookies_from(struct mp_log *log,
+ const char *filename,
struct cookie_list_type
*list)
{
char *ptr, *file;
int64_t length;
- ptr = file = load_file(filename, &length);
+ ptr = file = load_file(log, filename, &length);
if (!ptr)
return list;
@@ -169,22 +170,13 @@ static struct cookie_list_type *load_cookies_from(const char *filename,
return list;
}
-/* Attempt to load cookies.txt. Returns a pointer to the linked list contain the cookies. */
-static struct cookie_list_type *load_cookies(void)
-{
- if (cookies_file)
- return load_cookies_from(cookies_file, NULL);
-
- return NULL;
-}
-
// Return a cookies string as expected by lavf (libavformat/http.c). The format
// is like a Set-Cookie header (http://curl.haxx.se/rfc/cookie_spec.html),
// separated by newlines.
-char *cookies_lavf(void)
+char *cookies_lavf(struct mp_log *log)
{
- if (!cookie_list)
- cookie_list = load_cookies();
+ if (!cookie_list && cookies_file)
+ cookie_list = load_cookies_from(log, cookies_file, NULL);
struct cookie_list_type *list = cookie_list;
char *res = talloc_strdup(NULL, "");
diff --git a/stream/cookies.h b/stream/cookies.h
index e8b548c112..86c1e3bce9 100644
--- a/stream/cookies.h
+++ b/stream/cookies.h
@@ -24,6 +24,6 @@
#ifndef MPLAYER_COOKIES_H
#define MPLAYER_COOKIES_H
-char *cookies_lavf(void);
+char *cookies_lavf(struct mp_log *log);
#endif /* MPLAYER_COOKIES_H */
diff --git a/stream/dvb_tune.c b/stream/dvb_tune.c
index 0e40ea088f..0cf19a8fba 100644
--- a/stream/dvb_tune.c
+++ b/stream/dvb_tune.c
@@ -43,7 +43,7 @@
-int dvb_get_tuner_type(int fe_fd)
+int dvb_get_tuner_type(int fe_fd, struct mp_log *log)
{
struct dvb_frontend_info fe_info;
@@ -52,31 +52,31 @@ int dvb_get_tuner_type(int fe_fd)
res = ioctl(fe_fd, FE_GET_INFO, &fe_info);
if(res < 0)
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "FE_GET_INFO error: %d, FD: %d\n\n", errno, fe_fd);
+ mp_err(log, "FE_GET_INFO error: %d, FD: %d\n\n", errno, fe_fd);
return 0;
}
switch(fe_info.type)
{
case FE_OFDM:
- mp_msg(MSGT_DEMUX, MSGL_V, "TUNER TYPE SEEMS TO BE DVB-T\n");
+ mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-T\n");
return TUNER_TER;
case FE_QPSK:
- mp_msg(MSGT_DEMUX, MSGL_V, "TUNER TYPE SEEMS TO BE DVB-S\n");
+ mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-S\n");
return TUNER_SAT;
case FE_QAM:
- mp_msg(MSGT_DEMUX, MSGL_V, "TUNER TYPE SEEMS TO BE DVB-C\n");
+ mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-C\n");
return TUNER_CBL;
#ifdef DVB_ATSC
case FE_ATSC:
- mp_msg(MSGT_DEMUX, MSGL_V, "TUNER TYPE SEEMS TO BE DVB-ATSC\n");
+ mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-ATSC\n");
return TUNER_ATSC;
#endif
default:
- mp_msg(MSGT_DEMUX, MSGL_ERR, "UNKNOWN TUNER TYPE\n");
+ mp_err(log, "UNKNOWN TUNER TYPE\n");
return 0;
}
@@ -93,22 +93,22 @@ int dvb_open_devices(dvb_priv_t *priv, int n, int demux_cnt)
priv->fe_fd = open(frontend_dev, O_RDWR | O_NONBLOCK | O_CLOEXEC);
if(priv->fe_fd < 0)
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING FRONTEND DEVICE %s: ERRNO %d\n", frontend_dev, errno);
+ MP_ERR(priv, "ERROR OPENING FRONTEND DEVICE %s: ERRNO %d\n", frontend_dev, errno);
return 0;
}
priv->demux_fds_cnt = 0;
- mp_msg(MSGT_DEMUX, MSGL_V, "DVB_OPEN_DEVICES(%d)\n", demux_cnt);
+ MP_VERBOSE(priv, "DVB_OPEN_DEVICES(%d)\n", demux_cnt);
for(i = 0; i < demux_cnt; i++)
{
priv->demux_fds[i] = open(demux_dev, O_RDWR | O_NONBLOCK | O_CLOEXEC);
if(priv->demux_fds[i] < 0)
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING DEMUX 0: %d\n", errno);
+ MP_ERR(priv, "ERROR OPENING DEMUX 0: %d\n", errno);
return 0;
}
else
{
- mp_msg(MSGT_DEMUX, MSGL_V, "OPEN(%d), file %s: FD=%d, CNT=%d\n", i, demux_dev, priv->demux_fds[i], priv->demux_fds_cnt);
+ MP_VERBOSE(priv, "OPEN(%d), file %s: FD=%d, CNT=%d\n", i, demux_dev, priv->demux_fds[i], priv->demux_fds_cnt);
priv->demux_fds_cnt++;
}
}
@@ -117,7 +117,7 @@ int dvb_open_devices(dvb_priv_t *priv, int n, int demux_cnt)
priv->dvr_fd = open(dvr_dev, O_RDONLY| O_NONBLOCK | O_CLOEXEC);
if(priv->dvr_fd < 0)
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING DVR DEVICE %s: %d\n", dvr_dev, errno);
+ MP_ERR(priv, "ERROR OPENING DVR DEVICE %s: %d\n", dvr_dev, errno);
return 0;
}
@@ -131,12 +131,12 @@ int dvb_fix_demuxes(dvb_priv_t *priv, int cnt)
char demux_dev[32];
sprintf(demux_dev, "/dev/dvb/adapter%d/demux0", priv->card);
- mp_msg(MSGT_DEMUX, MSGL_V, "FIX %d -> %d\n", priv->demux_fds_cnt, cnt);
+ MP_VERBOSE(priv, "FIX %d -> %d\n", priv->demux_fds_cnt, cnt);
if(priv->demux_fds_cnt >= cnt)
{
for(i = priv->demux_fds_cnt-1; i >= cnt; i--)
{
- mp_msg(MSGT_DEMUX, MSGL_V, "FIX, CLOSE fd(%d): %d\n", i, priv->demux_fds[i]);
+ MP_VERBOSE(priv, "FIX, CLOSE fd(%d): %d\n", i, priv->demux_fds[i]);
close(priv->demux_fds[i]);
}
priv->demux_fds_cnt = cnt;
@@ -146,10 +146,10 @@ int dvb_fix_demuxes(dvb_priv_t *priv, int cnt)
for(i = priv->demux_fds_cnt; i < cnt; i++)
{
priv->demux_fds[i] = open(demux_dev, O_RDWR | O_NONBLOCK | O_CLOEXEC);
- mp_msg(MSGT_DEMUX, MSGL_V, "FIX, OPEN fd(%d): %d\n", i, priv->demux_fds[i]);
+ MP_VERBOSE(priv, "FIX, OPEN fd(%d): %d\n", i, priv->demux_fds[i]);
if(priv->demux_fds[i] < 0)
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING DEMUX 0: %d\n", errno);
+ MP_ERR(priv, "ERROR OPENING DEMUX 0: %d\n", errno);
return 0;
}
else
@@ -160,7 +160,7 @@ int dvb_fix_demuxes(dvb_priv_t *priv, int cnt)
return 1;
}
-int dvb_set_ts_filt(int fd, uint16_t pid, dmx_pes_type_t pestype)
+int dvb_set_ts_filt(dvb_priv_t *priv, int fd, uint16_t pid, dmx_pes_type_t pestype)
{
int i;
struct dmx_pes_filter_params pesFilterParams;
@@ -174,11 +174,11 @@ int dvb_set_ts_filt(int fd, uint16_t pid, dmx_pes_type_t pestype)
errno = 0;
if ((i = ioctl(fd, DMX_SET_PES_FILTER, &pesFilterParams)) < 0)
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR IN SETTING DMX_FILTER %i for fd %d: ERRNO: %d", pid, fd, errno);
+ MP_ERR(priv, "ERROR IN SETTING DMX_FILTER %i for fd %d: ERRNO: %d", pid, fd, errno);
return 0;
}
- mp_msg(MSGT_DEMUX, MSGL_V, "SET PES FILTER ON PID %d to fd %d, RESULT: %d, ERRNO: %d\n", pid, fd, i, errno);
+ MP_VERBOSE(priv, "SET PES FILTER ON PID %d to fd %d, RESULT: %d, ERRNO: %d\n", pid, fd, i, errno);
return 1;
}
@@ -188,8 +188,6 @@ int dvb_demux_stop(int fd)
int i;
i = ioctl(fd, DMX_STOP);
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "STOPPING FD: %d, RESULT: %d\n", fd, i);
-
return i == 0;
}
@@ -199,26 +197,24 @@ int dvb_demux_start(int fd)
int i;
i = ioctl(fd, DMX_START);
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "STARTING FD: %d, RESULT: %d\n", fd, i);
-
return i == 0;
}
-static void print_status(fe_status_t festatus)
+static void print_status(dvb_priv_t *priv, fe_status_t festatus)
{
- mp_msg(MSGT_DEMUX, MSGL_V, "FE_STATUS:");
- if (festatus & FE_HAS_SIGNAL) mp_msg(MSGT_DEMUX, MSGL_V," FE_HAS_SIGNAL");
- if (festatus & FE_TIMEDOUT) mp_msg(MSGT_DEMUX, MSGL_V, " FE_TIMEDOUT");
- if (festatus & FE_HAS_LOCK) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_LOCK");
- if (festatus & FE_HAS_CARRIER) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_CARRIER");
- if (festatus & FE_HAS_VITERBI) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_VITERBI");
- if (festatus & FE_HAS_SYNC) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_SYNC");
- mp_msg(MSGT_DEMUX, MSGL_V, "\n");
+ MP_VERBOSE(priv, "FE_STATUS:");
+ if (festatus & FE_HAS_SIGNAL) MP_VERBOSE(priv, " FE_HAS_SIGNAL");
+ if (festatus & FE_TIMEDOUT) MP_VERBOSE(priv, " FE_TIMEDOUT");
+ if (festatus & FE_HAS_LOCK) MP_VERBOSE(priv, " FE_HAS_LOCK");
+ if (festatus & FE_HAS_CARRIER) MP_VERBOSE(priv, " FE_HAS_CARRIER");
+ if (festatus & FE_HAS_VITERBI) MP_VERBOSE(priv, " FE_HAS_VITERBI");
+ if (festatus & FE_HAS_SYNC) MP_VERBOSE(priv, " FE_HAS_SYNC");
+ MP_VERBOSE(priv, "\n");
}
-static int check_status(int fd_frontend, int tmout)
+static int check_status(dvb_priv_t *priv, int fd_frontend, int tmout)
{
int32_t strength;
fe_status_t festatus;
@@ -229,7 +225,7 @@ static int check_status(int fd_frontend, int tmout)
pfd[0].fd = fd_frontend;
pfd[0].events = POLLPRI;
- mp_msg(MSGT_DEMUX, MSGL_V, "Getting frontend status\n");
+ MP_VERBOSE(priv, "Getting frontend status\n");
tm1 = tm2 = time((time_t*) NULL);
while(!ok)
{
@@ -253,25 +249,25 @@ static int check_status(int fd_frontend, int tmout)
{
strength=0;
if(ioctl(fd_frontend,FE_READ_BER,&strength) >= 0)
- mp_msg(MSGT_DEMUX, MSGL_V, "Bit error rate: %d\n",strength);
+ MP_VERBOSE(priv, "Bit error rate: %d\n",strength);
strength=0;
if(ioctl(fd_frontend,FE_READ_SIGNAL_STRENGTH,&strength) >= 0)
- mp_msg(MSGT_DEMUX, MSGL_V, "Signal strength: %d\n",strength);
+ MP_VERBOSE(priv, "Signal strength: %d\n",strength);
strength=0;
if(ioctl(fd_frontend,FE_READ_SNR,&strength) >= 0)
- mp_msg(MSGT_DEMUX, MSGL_V, "SNR: %d\n",strength);
+ MP_VERBOSE(priv, "SNR: %d\n",strength);
strength=0;
if(ioctl(fd_frontend,FE_READ_UNCORRECTED_BLOCKS,&strength) >= 0)
- mp_msg(MSGT_DEMUX, MSGL_V, "UNC: %d\n",strength);
+ MP_VERBOSE(priv, "UNC: %d\n",strength);
- print_status(festatus);
+ print_status(priv, festatus);
}
else
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "Not able to lock to the signal on the given frequency, timeout: %d\n", tmout);
+ MP_ERR(priv, "Not able to lock to the signal on the given frequency, timeout: %d\n", tmout);
return -1;
}
return 0;
@@ -322,7 +318,7 @@ static int do_diseqc(int secfd, int sat_no, int polv, int hi_lo)
(sat_no / 4) % 2 ? SEC_MINI_B : SEC_MINI_A);
}
-static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone,
+static int tune_it(dvb_priv_t *priv, int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone,
fe_spectral_inversion_t specInv, unsigned int diseqc, fe_modulation_t modulation, fe_code_rate_t HP_CodeRate,
fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth,
fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout)
@@ -331,18 +327,18 @@ static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int
struct dvb_frontend_parameters feparams;
struct dvb_frontend_info fe_info;
- mp_msg(MSGT_DEMUX, MSGL_V, "TUNE_IT, fd_frontend %d, fd_sec %d\nfreq %lu, srate %lu, pol %c, tone %i, specInv, diseqc %u, fe_modulation_t modulation,fe_code_rate_t HP_CodeRate, fe_transmit_mode_t TransmissionMode,fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth\n",
+ MP_VERBOSE(priv, "TUNE_IT, fd_frontend %d, fd_sec %d\nfreq %lu, srate %lu, pol %c, tone %i, specInv, diseqc %u, fe_modulation_t modulation,fe_code_rate_t HP_CodeRate, fe_transmit_mode_t TransmissionMode,fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth\n",
fd_frontend, fd_sec, (long unsigned int)freq, (long unsigned int)srate, pol, tone, diseqc);
memset(&feparams, 0, sizeof(feparams));
if ( ioctl(fd_frontend,FE_GET_INFO, &fe_info) < 0)
{
- mp_msg(MSGT_DEMUX, MSGL_FATAL, "FE_GET_INFO FAILED\n");
+ MP_FATAL(priv, "FE_GET_INFO FAILED\n");
return -1;
}
- mp_msg(MSGT_DEMUX, MSGL_V, "Using DVB card \"%s\"\n", fe_info.name);
+ MP_VERBOSE(priv, "Using DVB card \"%s\"\n", fe_info.name);
switch(fe_info.type)
{
@@ -357,7 +353,7 @@ static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int
feparams.u.ofdm.transmission_mode=TransmissionMode;
feparams.u.ofdm.guard_interval=guardInterval;
feparams.u.ofdm.hierarchy_information=hier;
- mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-T to %d Hz, bandwidth: %d\n",freq, bandwidth);
+ MP_VERBOSE(priv, "tuning DVB-T to %d Hz, bandwidth: %d\n",freq, bandwidth);
break;
case FE_QPSK:
if (freq > 2200000)
@@ -385,18 +381,18 @@ static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int
feparams.u.qpsk.fec_inner=HP_CodeRate;
dfd = fd_frontend;
- mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-S to Freq: %u, Pol: %c Srate: %d, 22kHz: %s, LNB: %d\n",freq,pol,srate,hi_lo ? "on" : "off", diseqc);
+ MP_VERBOSE(priv, "tuning DVB-S to Freq: %u, Pol: %c Srate: %d, 22kHz: %s, LNB: %d\n",freq,pol,srate,hi_lo ? "on" : "off", diseqc);
if(do_diseqc(dfd, diseqc, (pol == 'V' ? 1 : 0), hi_lo) == 0)
- mp_msg(MSGT_DEMUX, MSGL_V, "DISEQC SETTING SUCCEDED\n");
+ MP_VERBOSE(priv, "DISEQC SETTING SUCCEDED\n");
else
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "DISEQC SETTING FAILED\n");
+ MP_ERR(priv, "DISEQC SETTING FAILED\n");
return -1;
}
break;
case FE_QAM:
- mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-C to %d, srate=%d\n",freq,srate);
+ MP_VERBOSE(priv, "tuning DVB-C to %d, srate=%d\n",freq,srate);
feparams.frequency=freq;
feparams.inversion=specInv;
feparams.u.qam.symbol_rate = srate;
@@ -405,24 +401,24 @@ static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int
break;
#ifdef DVB_ATSC
case FE_ATSC:
- mp_msg(MSGT_DEMUX, MSGL_V, "tuning ATSC to %d, modulation=%d\n",freq,modulation);
+ MP_VERBOSE(priv, "tuning ATSC to %d, modulation=%d\n",freq,modulation);
feparams.frequency=freq;
feparams.u.vsb.modulation = modulation;
break;
#endif
default:
- mp_msg(MSGT_DEMUX, MSGL_V, "Unknown FE type. Aborting\n");
+ MP_VERBOSE(priv, "Unknown FE type. Aborting\n");
return 0;
}
usleep(100000);
if(ioctl(fd_frontend,FE_SET_FRONTEND,&feparams) < 0)
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR tuning channel\n");
+ MP_ERR(priv, "ERROR tuning channel\n");
return -1;
}
- return check_status(fd_frontend, timeout);
+ return check_status(priv, fd_frontend, timeout);
}
@@ -433,12 +429,12 @@ int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, int to
{
int ris;
- mp_msg(MSGT_DEMUX, MSGL_INFO, "dvb_tune Freq: %lu\n", (long unsigned int) freq);
+ MP_INFO(priv, "dvb_tune Freq: %lu\n", (long unsigned int) freq);
- ris = tune_it(priv->fe_fd, priv->sec_fd, freq, srate, pol, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth, LP_CodeRate, hier, timeout);
+ ris = tune_it(priv, priv->fe_fd, priv->sec_fd, freq, srate, pol, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth, LP_CodeRate, hier, timeout);
if(ris != 0)
- mp_msg(MSGT_DEMUX, MSGL_INFO, "dvb_tune, TUNING FAILED\n");
+ MP_INFO(priv, "dvb_tune, TUNING FAILED\n");
return ris == 0;
}
diff --git a/stream/dvb_tune.h b/stream/dvb_tune.h
index c3d2c63104..5bd1269e83 100644
--- a/stream/dvb_tune.h
+++ b/stream/dvb_tune.h
@@ -21,10 +21,12 @@
#include "dvbin.h"
-int dvb_get_tuner_type(int fe_fd);
+struct mp_log;
+
+int dvb_get_tuner_type(int fe_fd, struct mp_log *log);
int dvb_open_devices(dvb_priv_t *priv, int n, int demux_cnt);
int dvb_fix_demuxes(dvb_priv_t *priv, int cnt);
-int dvb_set_ts_filt(int fd, uint16_t pid, dmx_pes_type_t pestype);
+int dvb_set_ts_filt(dvb_priv_t *priv, int fd, uint16_t pid, dmx_pes_type_t pestype);
int dvb_demux_stop(int fd);
int dvb_demux_start(int fd);
int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc,
diff --git a/stream/dvbin.h b/stream/dvbin.h
index 54655fdcb2..38b1d15c6d 100644
--- a/stream/dvbin.h
+++ b/stream/dvbin.h
@@ -76,6 +76,7 @@ typedef struct {
} dvb_config_t;
typedef struct {
+ struct mp_log *log;
int fd;
int card;
int fe_fd;
@@ -104,7 +105,7 @@ typedef struct {
int dvb_step_channel(stream_t *, int);
int dvb_set_channel(stream_t *, int, int);
-dvb_config_t *dvb_get_config(void);
+dvb_config_t *dvb_get_config(stream_t *);
void dvb_free_config(dvb_config_t *config);
#endif /* MPLAYER_DVBIN_H */
diff --git a/stream/rar.c b/stream/rar.c
index cb54c6ebbb..31211c777b 100644
--- a/stream/rar.c
+++ b/stream/rar.c
@@ -198,7 +198,7 @@ static int SkipFile(struct stream *s, int *count, rar_file_t ***file,
rar_file_t *current = NULL;
if (method != 0x30) {
- mp_msg(MSGT_STREAM, MSGL_WARN, "Ignoring compressed file %s (method=0x%2.2x)\n", name, method);
+ MP_WARN(s, "Ignoring compressed file %s (method=0x%2.2x)\n", name, method);
goto exit;
}
@@ -386,7 +386,7 @@ int RarParse(struct stream *s, int *count, rar_file_t ***file)
if (!volume_mrl)
goto done;
- vol = stream_create(volume_mrl, STREAM_READ | STREAM_NO_FILTERS, s->opts);
+ vol = stream_create(volume_mrl, STREAM_READ | STREAM_NO_FILTERS, s->global);
if (!vol)
goto done;
@@ -423,7 +423,7 @@ int RarSeek(rar_file_t *file, uint64_t position)
free_stream(file->s);
file->s = stream_create(file->current_chunk->mrl,
STREAM_READ | STREAM_NO_FILTERS,
- file->opts);
+ file->global);
}
return file->s ? stream_seek(file->s, offset) : 0;
}
diff --git a/stream/rar.h b/stream/rar.h
index 6b001244a5..c9003b8a1b 100644
--- a/stream/rar.h
+++ b/stream/rar.h
@@ -44,7 +44,7 @@ typedef struct {
uint64_t real_size; /* Gathered size */
// When actually reading the data
- struct MPOpts *opts;
+ struct mpv_global *global;
uint64_t i_pos;
stream_t *s;
rar_file_chunk_t *current_chunk;
diff --git a/stream/stream.c b/stream/stream.c
index de3f0b118e..3332e66ace 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -38,6 +38,7 @@
#include "config.h"
#include "common/common.h"
+#include "common/global.h"
#include "bstr/bstr.h"
#include "common/msg.h"
#include "options/path.h"
@@ -228,14 +229,14 @@ static bool parse_url(struct stream *st, struct m_config *config)
if (f[n].len) {
const char *opt = find_url_opt(st, f_names[n]);
if (!opt) {
- mp_msg(MSGT_OPEN, MSGL_ERR, "Stream type '%s' accepts no '%s' "
- "field in URLs.\n", st->info->name, f_names[n]);
+ MP_ERR(st, "Stream type '%s' accepts no '%s' field in URLs.\n",
+ st->info->name, f_names[n]);
return false;
}
int r = m_config_set_option(config, bstr0(opt), f[n]);
if (r < 0) {
- mp_msg(MSGT_OPEN, MSGL_ERR, "Error setting stream option: %s\n",
- m_option_strerror(r));
+ MP_ERR(st, "Error setting stream option: %s\n",
+ m_option_strerror(r));
return false;
}
}
@@ -263,7 +264,7 @@ static const char *match_proto(const char *url, const char *proto)
}
static int open_internal(const stream_info_t *sinfo, struct stream *underlying,
- const char *url, int flags, struct MPOpts *options,
+ const char *url, int flags, struct mpv_global *global,
struct stream **ret)
{
if (sinfo->stream_filter != !!underlying)
@@ -285,8 +286,10 @@ static int open_internal(const stream_info_t *sinfo, struct stream *underlying,
}
stream_t *s = new_stream();
+ s->log = mp_log_new(s, global->log, sinfo->name);
s->info = sinfo;
- s->opts = options;
+ s->opts = global->opts;
+ s->global = global;
s->url = talloc_strdup(s, url);
s->path = talloc_strdup(s, path);
s->source = underlying;
@@ -299,10 +302,10 @@ static int open_internal(const stream_info_t *sinfo, struct stream *underlying,
.priv_defaults = sinfo->priv_defaults,
.options = sinfo->options,
};
- struct m_config *config = m_config_from_obj_desc(s, mp_null_log, &desc);
+ struct m_config *config = m_config_from_obj_desc(s, s->log, &desc);
s->priv = config->optstruct;
if (s->info->url_options && !parse_url(s, config)) {
- mp_msg(MSGT_OPEN, MSGL_ERR, "URL parsing failed on url %s\n", url);
+ MP_ERR(s, "URL parsing failed on url %s\n", url);
talloc_free(s);
return STREAM_ERROR;
}
@@ -329,43 +332,44 @@ static int open_internal(const stream_info_t *sinfo, struct stream *underlying,
s->uncached_type = s->type;
- mp_msg(MSGT_OPEN, MSGL_V, "[stream] [%s] %s\n", sinfo->name, url);
+ MP_VERBOSE(s, "Opened: [%s] %s\n", sinfo->name, url);
if (s->mime_type)
- mp_msg(MSGT_OPEN, MSGL_V, "Mime-type: '%s'\n", s->mime_type);
+ MP_VERBOSE(s, "Mime-type: '%s'\n", s->mime_type);
*ret = s;
return STREAM_OK;
}
-struct stream *stream_create(const char *url, int flags, struct MPOpts *options)
+struct stream *stream_create(const char *url, int flags, struct mpv_global *global)
{
+ struct mp_log *log = mp_log_new(NULL, global->log, "!stream");
struct stream *s = NULL;
assert(url);
// Open stream proper
for (int i = 0; stream_list[i]; i++) {
- int r = open_internal(stream_list[i], NULL, url, flags, options, &s);
+ int r = open_internal(stream_list[i], NULL, url, flags, global, &s);
if (r == STREAM_OK)
break;
if (r == STREAM_NO_MATCH || r == STREAM_UNSUPPORTED)
continue;
if (r != STREAM_OK) {
- mp_msg(MSGT_OPEN, MSGL_ERR, "Failed to open %s.\n", url);
- return NULL;
+ mp_err(log, "Failed to open %s.\n", url);
+ goto done;
}
}
if (!s) {
- mp_msg(MSGT_OPEN, MSGL_ERR, "No stream found to handle url %s\n", url);
- return NULL;
+ mp_err(log, "No stream found to handle url %s\n", url);
+ goto done;
}
// Open stream filters
for (;;) {
struct stream *new = NULL;
for (int i = 0; stream_list[i]; i++) {
- int r = open_internal(stream_list[i], s, s->url, flags, options, &new);
+ int r = open_internal(stream_list[i], s, s->url, flags, global, &new);
if (r == STREAM_OK)
break;
}
@@ -374,17 +378,19 @@ struct stream *stream_create(const char *url, int flags, struct MPOpts *options)
s = new;
}
+done:
+ talloc_free(log);
return s;
}
-struct stream *stream_open(const char *filename, struct MPOpts *options)
+struct stream *stream_open(const char *filename, struct mpv_global *global)
{
- return stream_create(filename, STREAM_READ, options);
+ return stream_create(filename, STREAM_READ, global);
}
-stream_t *open_output_stream(const char *filename, struct MPOpts *options)
+stream_t *open_output_stream(const char *filename, struct mpv_global *global)
{
- return stream_create(filename, STREAM_WRITE, options);
+ return stream_create(filename, STREAM_WRITE, global);
}
static int stream_reconnect(stream_t *s)
@@ -397,8 +403,7 @@ static int stream_reconnect(stream_t *s)
return 0;
int64_t pos = s->pos;
for (int retry = 0; retry < MAX_RECONNECT_RETRIES; retry++) {
- mp_msg(MSGT_STREAM, MSGL_WARN,
- "Connection lost! Attempting to reconnect (%d)...\n", retry + 1);
+ MP_WARN(s, "Connection lost! Attempting to reconnect (%d)...\n", retry + 1);
if (stream_check_interrupt(retry ? RECONNECT_SLEEP_MS : 0))
return 0;
@@ -432,8 +437,7 @@ void stream_set_capture_file(stream_t *s, const char *filename)
if (s->capture_file) {
s->capture_filename = talloc_strdup(NULL, filename);
} else {
- mp_msg(MSGT_GLOBAL, MSGL_ERR,
- "Error opening capture file: %s\n", strerror(errno));
+ MP_ERR(s, "Error opening capture file: %s\n", strerror(errno));
}
}
}
@@ -443,8 +447,7 @@ static void stream_capture_write(stream_t *s, void *buf, size_t len)
{
if (s->capture_file && len > 0) {
if (fwrite(buf, len, 1, s->capture_file) < 1) {
- mp_msg(MSGT_GLOBAL, MSGL_ERR, "Error writing capture file: %s\n",
- strerror(errno));
+ MP_ERR(s, "Error writing capture file: %s\n", strerror(errno));
stream_set_capture_file(s, NULL);
}
}
@@ -619,16 +622,15 @@ static int stream_seek_unbuffered(stream_t *s, int64_t newpos)
{
if (newpos != s->pos) {
if (newpos > s->pos && !(s->flags & MP_STREAM_SEEK_FW)) {
- mp_msg(MSGT_STREAM, MSGL_ERR, "Can not seek in this stream\n");
+ MP_ERR(s, "Can not seek in this stream\n");
return 0;
}
if (newpos < s->pos && !(s->flags & MP_STREAM_SEEK_BW)) {
- mp_msg(MSGT_STREAM, MSGL_ERR,
- "Cannot seek backward in linear streams!\n");
+ MP_ERR(s, "Cannot seek backward in linear streams!\n");
return 1;
}
if (s->seek(s, newpos) <= 0) {
- mp_msg(MSGT_STREAM, MSGL_ERR, "Seek failed\n");
+ MP_ERR(s, "Seek failed\n");
return 0;
}
}
@@ -653,8 +655,8 @@ static int stream_seek_long(stream_t *s, int64_t pos)
if (s->sector_size)
newpos = (pos / s->sector_size) * s->sector_size;
- mp_msg(MSGT_STREAM, MSGL_DBG3, "Seek from %" PRId64 " to %" PRId64
- " (with offset %d)\n", s->pos, pos, (int)(pos - newpos));
+ MP_TRACE(s, "Seek from %" PRId64 " to %" PRId64
+ " (with offset %d)\n", s->pos, pos, (int)(pos - newpos));
if (pos >= s->pos && !(s->flags & MP_STREAM_SEEK) &&
(s->flags & MP_STREAM_FAST_SKIPPING))
@@ -672,22 +674,20 @@ static int stream_seek_long(stream_t *s, int64_t pos)
s->buf_len = 0;
s->eof = 0; // eof should be set only on read
- mp_msg(MSGT_STREAM, MSGL_V,
- "stream_seek: Seek to/past EOF: no buffer preloaded.\n");
+ MP_VERBOSE(s, "Seek to/past EOF: no buffer preloaded.\n");
return 1;
}
int stream_seek(stream_t *s, int64_t pos)
{
- mp_msg(MSGT_DEMUX, MSGL_DBG3, "seek to 0x%llX\n", (long long)pos);
+ MP_TRACE(s, "seek to 0x%llX\n", (long long)pos);
if (pos == stream_tell(s))
return 1;
if (pos < 0) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, "Invalid seek to negative position %llx!\n",
- (long long)pos);
+ MP_ERR(s, "Invalid seek to negative position %llx!\n", (long long)pos);
pos = 0;
}
if (pos < s->pos) {
@@ -772,8 +772,11 @@ int stream_check_interrupt(int time)
stream_t *open_memory_stream(void *data, int len)
{
assert(len >= 0);
- stream_t *s = stream_open("memory://", NULL);
+ struct mpv_global *dummy = talloc_zero(NULL, struct mpv_global);
+ dummy->log = mp_null_log;
+ stream_t *s = stream_open("memory://", dummy);
assert(s);
+ talloc_steal(s, dummy);
stream_control(s, STREAM_CTRL_SET_CONTENTS, &(bstr){data, len});
return s;
}
@@ -822,9 +825,12 @@ static int stream_enable_cache(stream_t **stream, int64_t size, int64_t min,
cache->lavf_type = talloc_strdup(cache, orig->lavf_type);
cache->safe_origin = orig->safe_origin;
cache->opts = orig->opts;
+ cache->global = orig->global;
cache->start_pos = orig->start_pos;
cache->end_pos = orig->end_pos;
+ cache->log = mp_log_new(cache, cache->global->log, "cache");
+
int res = stream_cache_init(cache, orig, size, min, seek_limit);
if (res <= 0) {
cache->uncached_stream = NULL; // don't free original stream
diff --git a/stream/stream.h b/stream/stream.h
index 1a774c60fa..9cb227bfa8 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -158,7 +158,9 @@ typedef struct stream {
char *lavf_type; // name of expected demuxer type for lavf
bool safe_origin; // used for playlists that can be opened safely
bool allow_caching; // stream cache makes sense
+ struct mp_log *log;
struct MPOpts *opts;
+ struct mpv_global *global;
FILE *capture_file;
char *capture_filename;
@@ -236,16 +238,16 @@ int stream_read_partial(stream_t *s, char *buf, int buf_size);
struct bstr stream_peek(stream_t *s, int len);
void stream_drop_buffers(stream_t *s);
-struct MPOpts;
+struct mpv_global;
struct bstr stream_read_complete(struct stream *s, void *talloc_ctx,
int max_size);
int stream_control(stream_t *s, int cmd, void *arg);
void stream_update_size(stream_t *s);
void free_stream(stream_t *s);
-struct stream *stream_create(const char *url, int flags, struct MPOpts *options);
-struct stream *stream_open(const char *filename, struct MPOpts *options);
-stream_t *open_output_stream(const char *filename, struct MPOpts *options);
+struct stream *stream_create(const char *url, int flags, struct mpv_global *global);
+struct stream *stream_open(const char *filename, struct mpv_global *global);
+stream_t *open_output_stream(const char *filename, struct mpv_global *global);
stream_t *open_memory_stream(void *data, int len);
struct demux_stream;
diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c
index 3ee6aa46fe..56cbee42d1 100644
--- a/stream/stream_bluray.c
+++ b/stream/stream_bluray.c
@@ -308,25 +308,23 @@ static int bluray_stream_open(stream_t *s, int mode)
device = bluray_device;
if (!device) {
- mp_msg(MSGT_OPEN, MSGL_ERR,
- "No Blu-ray device/location was specified ...\n");
+ MP_ERR(s, "No Blu-ray device/location was specified ...\n");
return STREAM_UNSUPPORTED;
}
/* open device */
bd = bd_open(device, NULL);
if (!bd) {
- mp_msg(MSGT_OPEN, MSGL_ERR, "Couldn't open Blu-ray device: %s\n",
+ MP_ERR(s, "Couldn't open Blu-ray device: %s\n",
device);
return STREAM_UNSUPPORTED;
}
/* check for available titles on disc */
b->num_titles = bd_get_titles(bd, TITLES_RELEVANT, angle);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_BLURAY_TITLES=%d\n", b->num_titles);
+ MP_SMODE(s, "ID_BLURAY_TITLES=%d\n", b->num_titles);
if (!b->num_titles) {
- mp_msg(MSGT_OPEN, MSGL_ERR,
- "Can't find any Blu-ray-compatible title here.\n");
+ MP_ERR(s, "Can't find any Blu-ray-compatible title here.\n");
bd_close(bd);
return STREAM_UNSUPPORTED;
}
@@ -344,12 +342,9 @@ static int bluray_stream_open(stream_t *s, int mode)
sec = ti->duration / 90000;
msec = (ti->duration - sec) % 1000;
- mp_msg(MSGT_IDENTIFY, MSGL_INFO,
- "ID_BLURAY_TITLE_%d_CHAPTERS=%d\n", i + 1, ti->chapter_count);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO,
- "ID_BLURAY_TITLE_%d_ANGLE=%d\n", i + 1, ti->angle_count);
- mp_msg(MSGT_IDENTIFY, MSGL_V,
- "ID_BLURAY_TITLE_%d_LENGTH=%d.%03d\n", i + 1, sec, msec);
+ MP_SMODE(s, "ID_BLURAY_TITLE_%d_CHAPTERS=%d\n", i + 1, ti->chapter_count);
+ MP_SMODE(s, "ID_BLURAY_TITLE_%d_ANGLE=%d\n", i + 1, ti->angle_count);
+ MP_SMODE(s, "ID_BLURAY_TITLE_%d_LENGTH=%d.%03d\n", i + 1, sec, msec);
/* try to guess which title may contain the main movie */
if (ti->duration > max_duration) {
@@ -367,8 +362,7 @@ static int bluray_stream_open(stream_t *s, int mode)
bd_select_title(bd, title);
title_size = bd_get_title_size(bd);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO,
- "ID_BLURAY_CURRENT_TITLE=%d\n", title + 1);
+ MP_SMODE(s, "ID_BLURAY_CURRENT_TITLE=%d\n", title + 1);
/* Get current title information */
info = bd_get_title_info(bd, title, angle);
@@ -382,7 +376,7 @@ static int bluray_stream_open(stream_t *s, int mode)
if (angle)
bd_select_angle(bd, angle);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_BLURAY_CURRENT_ANGLE=%d\n", angle + 1);
+ MP_SMODE(s, "ID_BLURAY_CURRENT_ANGLE=%d\n", angle + 1);
bd_free_title_info(info);
@@ -401,7 +395,7 @@ err_no_info:
s->flags = MP_STREAM_SEEK;
s->priv = b;
- mp_msg(MSGT_OPEN, MSGL_V, "Blu-ray successfully opened.\n");
+ MP_VERBOSE(s, "Blu-ray successfully opened.\n");
return STREAM_OK;
}
diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c
index bc026843c8..5d095f6d74 100644
--- a/stream/stream_cdda.c
+++ b/stream/stream_cdda.c
@@ -133,7 +133,7 @@ static bool print_cdtext(stream_t *s, int track)
cdtext_t *text = cdio_get_cdtext(p->cd->p_cdio);
#endif
if (text) {
- mp_msg(MSGT_SEEK, MSGL_INFO, "CD-Text (%s):\n", track ? "track" : "CD");
+ MP_INFO(s, "CD-Text (%s):\n", track ? "track" : "CD");
for (int i = 0; i < sizeof(cdtext_name) / sizeof(cdtext_name[0]); i++) {
const char *name = cdtext_name[i];
#ifdef OLD_API
@@ -142,7 +142,7 @@ static bool print_cdtext(stream_t *s, int track)
const char *value = cdtext_get_const(text, i, track);
#endif
if (name && value)
- mp_msg(MSGT_SEEK, MSGL_INFO, " %s: '%s'\n", name, value);
+ MP_INFO(s, " %s: '%s'\n", name, value);
}
return true;
}
@@ -154,13 +154,13 @@ static void print_track_info(stream_t *s, int track)
cdda_priv* p = (cdda_priv*)s->priv;
cd_track_t *cd_track = cd_info_get_track(p->cd_info, track);
if( cd_track!=NULL ) {
- mp_msg(MSGT_SEEK, MSGL_INFO, "\n%s\n", cd_track->name);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDA_TRACK=%d\n",
+ MP_INFO(s, "\n%s\n", cd_track->name);
+ MP_INFO(s, "ID_CDDA_TRACK=%d\n",
cd_track->track_nb);
}
if (print_cdtext(s, track)) {
// hack for term OSD overwriting the last line of CDTEXT
- mp_msg(MSGT_SEEK, MSGL_INFO, "\n");
+ MP_INFO(s, "\n");
}
}
@@ -340,7 +340,7 @@ static int open_cdda(stream_t *st, int m)
#endif
if (!cdd) {
- mp_msg(MSGT_OPEN, MSGL_ERR, "Can't open CDDA device.\n");
+ MP_ERR(st, "Can't open CDDA device.\n");
return STREAM_ERROR;
}
@@ -350,13 +350,13 @@ static int open_cdda(stream_t *st, int m)
cdd->nsectors = p->sector_size;
if (cdda_open(cdd) != 0) {
- mp_msg(MSGT_OPEN, MSGL_ERR, "Can't open disc.\n");
+ MP_ERR(st, "Can't open disc.\n");
cdda_close(cdd);
return STREAM_ERROR;
}
cd_info = cd_info_new();
- mp_msg(MSGT_OPEN, MSGL_INFO, "Found audio CD with %d tracks.\n",
+ MP_INFO(st, "Found audio CD with %d tracks.\n",
(int)cdda_tracks(cdd));
for (i = 0; i < cdd->tracks; i++) {
char track_name[80];
diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c
index 698c497d48..aabe7170a9 100644
--- a/stream/stream_dvb.c
+++ b/stream/stream_dvb.c
@@ -51,6 +51,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "options/path.h"
#include "dvbin.h"
+#include "dvb_tune.h"
#define MAX_CHANNELS 8
@@ -87,20 +88,7 @@ const m_option_t dvbin_opts_conf[] = {
-int dvb_set_ts_filt(int fd, uint16_t pid, dmx_pes_type_t pestype);
-int dvb_demux_stop(int fd);
-int dvb_get_tuner_type(int fd);
-int dvb_open_devices(dvb_priv_t *priv, int n, int demux_cnt);
-int dvb_fix_demuxes(dvb_priv_t *priv, int cnt);
-
-int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, int tone,
- fe_spectral_inversion_t specInv, fe_modulation_t modulation, fe_guard_interval_t guardInterval,
- fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth, fe_code_rate_t HP_CodeRate,
- fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout);
-
-
-
-static dvb_channels_list *dvb_get_channels(char *filename, int type)
+static dvb_channels_list *dvb_get_channels(struct mp_log *log, char *filename, int type)
{
dvb_channels_list *list;
FILE *f;
@@ -118,10 +106,10 @@ static dvb_channels_list *dvb_get_channels(char *filename, int type)
const char *ter_conf = "%d:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]\n";
const char *atsc_conf = "%d:%255[^:]:%255[^:]:%255[^:]\n";
- mp_msg(MSGT_DEMUX, MSGL_V, "CONFIG_READ FILE: %s, type: %d\n", filename, type);
+ mp_verbose(log, "CONFIG_READ FILE: %s, type: %d\n", filename, type);
if((f=fopen(filename, "r"))==NULL)
{
- mp_msg(MSGT_DEMUX, MSGL_FATAL, "CAN'T READ CONFIG FILE %s\n", filename);
+ mp_fatal(log, "CAN'T READ CONFIG FILE %s\n", filename);
return NULL;
}
@@ -129,7 +117,7 @@ static dvb_channels_list *dvb_get_channels(char *filename, int type)
if(list == NULL)
{
fclose(f);
- mp_msg(MSGT_DEMUX, MSGL_V, "DVB_GET_CHANNELS: couldn't malloc enough memory\n");
+ mp_verbose(log, "DVB_GET_CHANNELS: couldn't malloc enough memory\n");
return NULL;
}
@@ -166,8 +154,7 @@ static dvb_channels_list *dvb_get_channels(char *filename, int type)
fields = sscanf(&line[k], ter_conf,
&ptr->freq, inv, bw, cr, tmp_lcr, mod,
transm, gi, tmp_hier, vpid_str, apid_str);
- mp_msg(MSGT_DEMUX, MSGL_V,
- "TER, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d",
+ mp_verbose(log, "TER, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d",
list->NUM_CHANNELS, fields, ptr->name, ptr->freq);
}
else if(type == TUNER_CBL)
@@ -175,8 +162,7 @@ static dvb_channels_list *dvb_get_channels(char *filename, int type)
fields = sscanf(&line[k], cbl_conf,
&ptr->freq, inv, &ptr->srate,
cr, mod, vpid_str, apid_str);
- mp_msg(MSGT_DEMUX, MSGL_V,
- "CBL, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d, SRATE: %d",
+ mp_verbose(log, "CBL, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d, SRATE: %d",
list->NUM_CHANNELS, fields, ptr->name, ptr->freq, ptr->srate);
}
#ifdef DVB_ATSC
@@ -184,8 +170,7 @@ static dvb_channels_list *dvb_get_channels(char *filename, int type)
{
fields = sscanf(&line[k], atsc_conf,
&ptr->freq, mod, vpid_str, apid_str);
- mp_msg(MSGT_DEMUX, MSGL_V,
- "ATSC, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d\n",
+ mp_verbose(log, "ATSC, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d\n",
list->NUM_CHANNELS, fields, ptr->name, ptr->freq);
}
#endif
@@ -203,8 +188,7 @@ static dvb_channels_list *dvb_get_channels(char *filename, int type)
continue;
if(ptr->diseqc > 0)
ptr->diseqc--;
- mp_msg(MSGT_DEMUX, MSGL_V,
- "SAT, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d, SRATE: %d, POL: %c, DISEQC: %d",
+ mp_verbose(log, "SAT, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d, SRATE: %d, POL: %c, DISEQC: %d",
list->NUM_CHANNELS, fields, ptr->name, ptr->freq, ptr->srate, ptr->pol, ptr->diseqc);
}
@@ -252,10 +236,10 @@ static dvb_channels_list *dvb_get_channels(char *filename, int type)
ptr->pids[ptr->pids_cnt] = 0; //PID 0 is the PAT
ptr->pids_cnt++;
}
- mp_msg(MSGT_DEMUX, MSGL_V, " PIDS: ");
+ mp_verbose(log, " PIDS: ");
for(cnt = 0; cnt < ptr->pids_cnt; cnt++)
- mp_msg(MSGT_DEMUX, MSGL_V, " %d ", ptr->pids[cnt]);
- mp_msg(MSGT_DEMUX, MSGL_V, "\n");
+ mp_verbose(log, " %d ", ptr->pids[cnt]);
+ mp_verbose(log, "\n");
if((type == TUNER_TER) || (type == TUNER_CBL))
{
@@ -380,7 +364,7 @@ static dvb_channels_list *dvb_get_channels(char *filename, int type)
list->NUM_CHANNELS++;
if(sizeof(dvb_channel_t) * list->NUM_CHANNELS >= 1024*1024)
{
- mp_msg(MSGT_DEMUX, MSGL_V, "dvbin.c, > 1MB allocated for channels struct, dropping the rest of the file\r\n");
+ mp_verbose(log, "dvbin.c, > 1MB allocated for channels struct, dropping the rest of the file\r\n");
break;
}
}
@@ -423,7 +407,7 @@ static int dvb_streaming_read(stream_t *stream, char *buffer, int size)
int pos=0, tries, rk, fd;
dvb_priv_t *priv = (dvb_priv_t *) stream->priv;
- mp_msg(MSGT_DEMUX, MSGL_DBG3, "dvb_streaming_read(%d)\n", size);
+ MP_TRACE(stream, "dvb_streaming_read(%d)\n", size);
tries = priv->retry + 1;
@@ -436,7 +420,7 @@ static int dvb_streaming_read(stream_t *stream, char *buffer, int size)
rk = size - pos;
if(poll(pfds, 1, 500) <= 0)
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "dvb_streaming_read, attempt N. %d failed with errno %d when reading %d bytes\n", tries, errno, size-pos);
+ MP_ERR(stream, "dvb_streaming_read, attempt N. %d failed with errno %d when reading %d bytes\n", tries, errno, size-pos);
errno = 0;
if(--tries > 0)
continue;
@@ -446,13 +430,13 @@ static int dvb_streaming_read(stream_t *stream, char *buffer, int size)
if((rk = read(fd, &buffer[pos], rk)) > 0)
{
pos += rk;
- mp_msg(MSGT_DEMUX, MSGL_DBG3, "ret (%d) bytes\n", pos);
+ MP_TRACE(stream, "ret (%d) bytes\n", pos);
}
}
if(! pos)
- mp_msg(MSGT_DEMUX, MSGL_ERR, "dvb_streaming_read, return %d bytes\n", pos);
+ MP_ERR(stream, "dvb_streaming_read, return %d bytes\n", pos);
return pos;
}
@@ -471,7 +455,7 @@ int dvb_set_channel(stream_t *stream, int card, int n)
if((card < 0) || (card > conf->count))
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "dvb_set_channel: INVALID CARD NUMBER: %d vs %d, abort\n", card, conf->count);
+ MP_ERR(stream, "dvb_set_channel: INVALID CARD NUMBER: %d vs %d, abort\n", card, conf->count);
return 0;
}
@@ -479,7 +463,7 @@ int dvb_set_channel(stream_t *stream, int card, int n)
new_list = conf->cards[card].list;
if((n > new_list->NUM_CHANNELS) || (n < 0))
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "dvb_set_channel: INVALID CHANNEL NUMBER: %d, for card %d, abort\n", n, card);
+ MP_ERR(stream, "dvb_set_channel: INVALID CHANNEL NUMBER: %d, for card %d, abort\n", n, card);
return 0;
}
channel = &(new_list->channels[n]);
@@ -496,7 +480,7 @@ int dvb_set_channel(stream_t *stream, int card, int n)
dvbin_close(stream);
if(! dvb_open_devices(priv, devno, channel->pids_cnt))
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "DVB_SET_CHANNEL, COULDN'T OPEN DEVICES OF CARD: %d, EXIT\n", card);
+ MP_ERR(stream, "DVB_SET_CHANNEL, COULDN'T OPEN DEVICES OF CARD: %d, EXIT\n", card);
return 0;
}
}
@@ -510,7 +494,7 @@ int dvb_set_channel(stream_t *stream, int card, int n)
{
if(! dvb_open_devices(priv, devno, channel->pids_cnt))
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "DVB_SET_CHANNEL2, COULDN'T OPEN DEVICES OF CARD: %d, EXIT\n", card);
+ MP_ERR(stream, "DVB_SET_CHANNEL2, COULDN'T OPEN DEVICES OF CARD: %d, EXIT\n", card);
return 0;
}
}
@@ -520,7 +504,7 @@ int dvb_set_channel(stream_t *stream, int card, int n)
priv->retry = 5;
new_list->current = n;
priv->fd = priv->dvr_fd;
- mp_msg(MSGT_DEMUX, MSGL_V, "DVB_SET_CHANNEL: new channel name=%s, card: %d, channel %d\n", channel->name, card, n);
+ MP_VERBOSE(stream, "DVB_SET_CHANNEL: new channel name=%s, card: %d, channel %d\n", channel->name, card, n);
stream->buf_pos = stream->buf_len = 0;
stream->pos = 0;
@@ -536,7 +520,7 @@ int dvb_set_channel(stream_t *stream, int card, int n)
//sets demux filters and restart the stream
for(i = 0; i < channel->pids_cnt; i++)
{
- if(! dvb_set_ts_filt(priv->demux_fds[i], channel->pids[i], DMX_PES_OTHER))
+ if(! dvb_set_ts_filt(priv,priv->demux_fds[i], channel->pids[i], DMX_PES_OTHER))
return 0;
}
@@ -551,18 +535,18 @@ int dvb_step_channel(stream_t *stream, int dir)
dvb_channels_list *list;
dvb_priv_t *priv = stream->priv;
- mp_msg(MSGT_DEMUX, MSGL_V, "DVB_STEP_CHANNEL dir %d\n", dir);
+ MP_VERBOSE(stream, "DVB_STEP_CHANNEL dir %d\n", dir);
if(priv == NULL)
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "dvb_step_channel: NULL priv_ptr, quit\n");
+ MP_ERR(stream, "dvb_step_channel: NULL priv_ptr, quit\n");
return 0;
}
list = priv->list;
if(list == NULL)
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "dvb_step_channel: NULL list_ptr, quit\n");
+ MP_ERR(stream, "dvb_step_channel: NULL list_ptr, quit\n");
return 0;
}
@@ -582,7 +566,7 @@ static void dvbin_close(stream_t *stream)
for(i = priv->demux_fds_cnt-1; i >= 0; i--)
{
priv->demux_fds_cnt--;
- mp_msg(MSGT_DEMUX, MSGL_V, "DVBIN_CLOSE, close(%d), fd=%d, COUNT=%d\n", i, priv->demux_fds[i], priv->demux_fds_cnt);
+ MP_VERBOSE(stream, "DVBIN_CLOSE, close(%d), fd=%d, COUNT=%d\n", i, priv->demux_fds[i], priv->demux_fds_cnt);
close(priv->demux_fds[i]);
}
close(priv->dvr_fd);
@@ -602,7 +586,7 @@ static int dvb_streaming_start(stream_t *stream, int tuner_type, char *progname)
dvb_priv_t *priv = stream->priv;
dvb_priv_t *opts = priv;
- mp_msg(MSGT_DEMUX, MSGL_V, "\r\ndvb_streaming_start(PROG: %s, CARD: %d)\r\n",
+ MP_VERBOSE(stream, "\r\ndvb_streaming_start(PROG: %s, CARD: %d)\r\n",
opts->cfg_prog, opts->cfg_card);
priv->is_on = 0;
@@ -619,23 +603,23 @@ static int dvb_streaming_start(stream_t *stream, int tuner_type, char *progname)
if(channel != NULL)
{
priv->list->current = i-1;
- mp_msg(MSGT_DEMUX, MSGL_V, "PROGRAM NUMBER %d: name=%s, freq=%u\n", i-1, channel->name, channel->freq);
+ MP_VERBOSE(stream, "PROGRAM NUMBER %d: name=%s, freq=%u\n", i-1, channel->name, channel->freq);
}
else
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "\n\nDVBIN: no such channel \"%s\"\n\n", progname);
+ MP_ERR(stream, "\n\nDVBIN: no such channel \"%s\"\n\n", progname);
return 0;
}
if(!dvb_set_channel(stream, priv->card, priv->list->current))
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR, COULDN'T SET CHANNEL %i: ", priv->list->current);
+ MP_ERR(stream, "ERROR, COULDN'T SET CHANNEL %i: ", priv->list->current);
dvbin_close(stream);
return 0;
}
- mp_msg(MSGT_DEMUX, MSGL_V, "SUCCESSFUL EXIT from dvb_streaming_start\n");
+ MP_VERBOSE(stream, "SUCCESSFUL EXIT from dvb_streaming_start\n");
return 1;
}
@@ -648,6 +632,7 @@ static int dvb_open(stream_t *stream, int mode)
// I don't force the file format bacause, although it's almost always TS,
// there are some providers that stream an IP multicast with M$ Mpeg4 inside
dvb_priv_t *priv = stream->priv;
+ priv->log = stream->log;
dvb_priv_t *p = priv;
char *progname;
int tuner_type = 0, i;
@@ -657,10 +642,10 @@ static int dvb_open(stream_t *stream, int mode)
return STREAM_UNSUPPORTED;
priv->fe_fd = priv->sec_fd = priv->dvr_fd = -1;
- priv->config = dvb_get_config();
+ priv->config = dvb_get_config(stream);
if(priv->config == NULL)
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "DVB CONFIGURATION IS EMPTY, exit\n");
+ MP_ERR(stream, "DVB CONFIGURATION IS EMPTY, exit\n");
return STREAM_ERROR;
}
@@ -676,7 +661,7 @@ static int dvb_open(stream_t *stream, int mode)
if(priv->card == -1)
{
- mp_msg(MSGT_DEMUX, MSGL_ERR, "NO CONFIGURATION FOUND FOR CARD N. %d, exit\n", p->cfg_card);
+ MP_ERR(stream, "NO CONFIGURATION FOUND FOR CARD N. %d, exit\n", p->cfg_card);
return STREAM_ERROR;
}
priv->timeout = p->cfg_timeout;
@@ -685,14 +670,14 @@ static int dvb_open(stream_t *stream, int mode)
if(tuner_type == 0)
{
- mp_msg(MSGT_DEMUX, MSGL_V, "OPEN_DVB: UNKNOWN OR UNDETECTABLE TUNER TYPE, EXIT\n");
+ MP_VERBOSE(stream, "OPEN_DVB: UNKNOWN OR UNDETECTABLE TUNER TYPE, EXIT\n");
return STREAM_ERROR;
}
priv->tuner_type = tuner_type;
- mp_msg(MSGT_DEMUX, MSGL_V, "OPEN_DVB: prog=%s, card=%d, type=%d\n",
+ MP_VERBOSE(stream, "OPEN_DVB: prog=%s, card=%d, type=%d\n",
p->cfg_prog, priv->card+1, priv->tuner_type);
priv->list = priv->config->cards[priv->card].list;
@@ -719,8 +704,10 @@ static int dvb_open(stream_t *stream, int mode)
}
#define MAX_CARDS 4
-dvb_config_t *dvb_get_config(void)
+dvb_config_t *dvb_get_config(stream_t *stream)
{
+ struct mp_log *log = stream->log;
+ struct mpv_global *global = stream->global;
int i, fd, type, size;
char filename[30], *conf_file, *name;
dvb_channels_list *list;
@@ -741,51 +728,47 @@ dvb_config_t *dvb_get_config(void)
fd = open(filename, O_RDONLY|O_NONBLOCK|O_CLOEXEC);
if(fd < 0)
{
- mp_msg(MSGT_DEMUX, MSGL_V, "DVB_CONFIG, can't open device %s, skipping\n", filename);
+ mp_verbose(log, "DVB_CONFIG, can't open device %s, skipping\n", filename);
continue;
}
- type = dvb_get_tuner_type(fd);
+ type = dvb_get_tuner_type(fd, log);
close(fd);
if(type != TUNER_SAT && type != TUNER_TER && type != TUNER_CBL && type != TUNER_ATSC)
{
- mp_msg(MSGT_DEMUX, MSGL_V, "DVB_CONFIG, can't detect tuner type of card %d, skipping\n", i);
+ mp_verbose(log, "DVB_CONFIG, can't detect tuner type of card %d, skipping\n", i);
continue;
}
+// rebase hack
+#define mp_find_user_config_file(a,b,c) mp_find_user_config_file(c)
+#define mp_find_global_config_file(a, b, c) mp_find_global_config_file(c)
void *talloc_ctx = talloc_new(NULL);
- conf_file = talloc_steal(talloc_ctx,
- mp_find_user_config_file("channels.conf"));
+ conf_file = mp_find_user_config_file(talloc_ctx, global, "channels.conf");
switch(type) {
case TUNER_TER:
- conf_file = talloc_steal(talloc_ctx,
- mp_find_user_config_file("channels.conf.ter"));
+ conf_file = mp_find_user_config_file(talloc_ctx, global, "channels.conf.ter");
break;
case TUNER_CBL:
- conf_file = talloc_steal(talloc_ctx,
- mp_find_user_config_file("channels.conf.cbl"));
+ conf_file = mp_find_user_config_file(talloc_ctx, global, "channels.conf.cbl");
break;
case TUNER_SAT:
- conf_file = talloc_steal(talloc_ctx,
- mp_find_user_config_file("channels.conf.sat"));
+ conf_file = mp_find_user_config_file(talloc_ctx, global, "channels.conf.sat");
break;
case TUNER_ATSC:
- conf_file = talloc_steal(talloc_ctx,
- mp_find_user_config_file("channels.conf.atsc"));
+ conf_file = mp_find_user_config_file(talloc_ctx, global, "channels.conf.atsc");
break;
}
if(conf_file && (access(conf_file, F_OK | R_OK) != 0)) {
- conf_file = talloc_steal(talloc_ctx,
- mp_find_user_config_file("channels.conf"));
+ conf_file = mp_find_user_config_file(talloc_ctx, global, "channels.conf");
if(conf_file && (access(conf_file, F_OK | R_OK) != 0)) {
- conf_file = talloc_steal(talloc_ctx,
- mp_find_global_config_file("channels.conf"));
+ conf_file = mp_find_global_config_file(talloc_ctx, global, "channels.conf");
}
}
- list = dvb_get_channels(conf_file, type);
+ list = dvb_get_channels(log, conf_file, type);
talloc_free(talloc_ctx);
if(list == NULL)
diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c
index ece9975e4d..92af9f969b 100644
--- a/stream/stream_dvd.c
+++ b/stream/stream_dvd.c
@@ -124,14 +124,14 @@ int dvd_aid_from_lang(stream_t *stream, char **lang) {
code = lang[n][1] | (lang[n][0] << 8);
for(i=0;i<d->nr_of_channels;i++) {
if(d->audio_streams[i].language==code) {
- mp_msg(MSGT_OPEN,MSGL_INFO,"Selected DVD audio channel: %d language: %c%c\n",
+ MP_INFO(stream, "Selected DVD audio channel: %d language: %c%c\n",
d->audio_streams[i].id, lang[n][0], lang[n][1]);
return d->audio_streams[i].id;
}
//printf("%X != %X (%c%c)\n",code,d->audio_streams[i].language,lang[0],lang[1]);
}
}
- mp_msg(MSGT_OPEN,MSGL_WARN,"No matching DVD audio language found!\n");
+ MP_WARN(stream, "No matching DVD audio language found!\n");
return -1;
}
@@ -165,19 +165,19 @@ int dvd_sid_from_lang(stream_t *stream, char **lang) {
code = lang[n][1] | (lang[n][0] << 8);
for(i=0;i<d->nr_of_subtitles;i++) {
if(d->subtitles[i].language==code) {
- mp_msg(MSGT_OPEN,MSGL_INFO,"Selected DVD subtitle channel: %d language: %c%c\n", i, lang[n][0], lang[n][1]);
+ MP_INFO(stream, "Selected DVD subtitle channel: %d language: %c%c\n", i, lang[n][0], lang[n][1]);
return d->subtitles[i].id;
}
}
}
- mp_msg(MSGT_OPEN,MSGL_WARN,"No matching DVD subtitle language found!\n");
+ MP_WARN(stream, "No matching DVD subtitle language found!\n");
return -1;
}
-static int dvd_next_cell(dvd_priv_t *d) {
+static int dvd_next_cell(stream_t *stream, dvd_priv_t *d) {
int next_cell=d->cur_cell;
- mp_msg(MSGT_DVD,MSGL_DBG2, "dvd_next_cell: next1=0x%X \n",next_cell);
+ MP_DBG(stream, "dvd_next_cell: next1=0x%X \n",next_cell);
if( d->cur_pgc->cell_playback[ next_cell ].block_type == BLOCK_TYPE_ANGLE_BLOCK ) {
while(next_cell<d->last_cell) {
if( d->cur_pgc->cell_playback[next_cell].block_mode == BLOCK_MODE_LAST_CELL )
@@ -185,7 +185,7 @@ static int dvd_next_cell(dvd_priv_t *d) {
++next_cell;
}
}
- mp_msg(MSGT_DVD,MSGL_DBG2, "dvd_next_cell: next2=0x%X \n",next_cell);
+ MP_DBG(stream, "dvd_next_cell: next2=0x%X \n",next_cell);
++next_cell;
if(next_cell>=d->last_cell)
@@ -195,11 +195,11 @@ static int dvd_next_cell(dvd_priv_t *d) {
if(next_cell>=d->last_cell)
return -1; // EOF
}
- mp_msg(MSGT_DVD,MSGL_DBG2, "dvd_next_cell: next3=0x%X \n",next_cell);
+ MP_DBG(stream, "dvd_next_cell: next3=0x%X \n",next_cell);
return next_cell;
}
-static int dvd_read_sector(dvd_priv_t *d, unsigned char *data)
+static int dvd_read_sector(stream_t *stream, dvd_priv_t *d, unsigned char *data)
{
int len;
@@ -216,10 +216,10 @@ static int dvd_read_sector(dvd_priv_t *d, unsigned char *data)
*/
if(d->dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL) {
d->cur_pack= d->dsi_pack.dsi_gi.nv_pck_lbn + ( d->dsi_pack.vobu_sri.next_vobu & 0x7fffffff );
- mp_msg(MSGT_DVD,MSGL_DBG2, "Navi new pos=0x%X \n",d->cur_pack);
+ MP_DBG(stream, "Navi new pos=0x%X \n",d->cur_pack);
} else {
// end of cell! find next cell!
- mp_msg(MSGT_DVD,MSGL_V, "--- END OF CELL !!! ---\n");
+ MP_VERBOSE(stream, "--- END OF CELL !!! ---\n");
d->cur_pack=d->cell_last_pack+1;
}
}
@@ -227,14 +227,14 @@ static int dvd_read_sector(dvd_priv_t *d, unsigned char *data)
read_next:
if(d->cur_pack>d->cell_last_pack) {
// end of cell!
- int next=dvd_next_cell(d);
+ int next=dvd_next_cell(stream, d);
if(next>=0) {
d->cur_cell=next;
// if( d->cur_pgc->cell_playback[d->cur_cell].block_type
// == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle-1;
d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector;
d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector;
- mp_msg(MSGT_DVD,MSGL_V, "DVD next cell: %d pack: 0x%X-0x%X \n",d->cur_cell,d->cur_pack,d->cell_last_pack);
+ MP_VERBOSE(stream, "DVD next cell: %d pack: 0x%X-0x%X \n",d->cur_cell,d->cur_pack,d->cell_last_pack);
} else
return -1; // EOF
}
@@ -252,14 +252,14 @@ read_next:
navRead_DSI(&d->dsi_pack, &(data[ DSI_START_BYTE ]), sizeof(dsi_t));
#endif
if(d->cur_pack != d->dsi_pack.dsi_gi.nv_pck_lbn ) {
- mp_msg(MSGT_DVD,MSGL_V, "Invalid NAVI packet! lba=0x%X navi=0x%X \n",
+ MP_VERBOSE(stream, "Invalid NAVI packet! lba=0x%X navi=0x%X \n",
d->cur_pack,d->dsi_pack.dsi_gi.nv_pck_lbn);
} else {
// process!
d->packs_left = d->dsi_pack.dsi_gi.vobu_ea;
- mp_msg(MSGT_DVD,MSGL_DBG2, "Found NAVI packet! lba=0x%X len=%d \n",d->cur_pack,d->packs_left);
+ MP_DBG(stream, "Found NAVI packet! lba=0x%X len=%d \n",d->cur_pack,d->packs_left);
//navPrint_DSI(&d->dsi_pack);
- mp_msg(MSGT_DVD,MSGL_DBG3,"\r### CELL %d: Navi: %d/%d IFO: %d/%d \n",d->cur_cell,
+ MP_TRACE(stream, "\r### CELL %d: Navi: %d/%d IFO: %d/%d \n",d->cur_cell,
d->dsi_pack.dsi_gi.vobu_c_idn,d->dsi_pack.dsi_gi.vobu_vob_idn,
d->cur_pgc->cell_position[d->cur_cell].cell_nr,
d->cur_pgc->cell_position[d->cur_cell].vob_id_nr);
@@ -274,13 +274,13 @@ read_next:
d->dsi_pack.sml_agli.data[dvd_angle-1].address;
d->angle_seek=0;
d->cur_pack--;
- mp_msg(MSGT_DVD,MSGL_V, "Angle-seek synced using sml_agli map! new_lba=0x%X \n",d->cur_pack);
+ MP_VERBOSE(stream, "Angle-seek synced using sml_agli map! new_lba=0x%X \n",d->cur_pack);
} else {
// check if we're in the right cell, jump otherwise:
if( (d->dsi_pack.dsi_gi.vobu_c_idn==d->cur_pgc->cell_position[d->cur_cell].cell_nr) &&
(d->dsi_pack.dsi_gi.vobu_vob_idn==d->cur_pgc->cell_position[d->cur_cell].vob_id_nr) ){
d->angle_seek=0;
- mp_msg(MSGT_DVD,MSGL_V, "Angle-seek synced by cell/vob IDN search! \n");
+ MP_VERBOSE(stream, "Angle-seek synced by cell/vob IDN search! \n");
} else {
// wrong angle, skip this vobu:
d->cur_pack=d->dsi_pack.dsi_gi.nv_pck_lbn+
@@ -298,14 +298,14 @@ read_next:
if(d->packs_left>=0) --d->packs_left;
if(d->angle_seek) {
- if(d->angle_seek==2) mp_msg(MSGT_DVD,MSGL_V, "!!! warning! reading packet while angle_seek !!!\n");
+ if(d->angle_seek==2) MP_VERBOSE(stream, "!!! warning! reading packet while angle_seek !!!\n");
goto read_next; // searching for Navi packet
}
return d->cur_pack-1;
}
-static void dvd_seek(dvd_priv_t *d, int pos)
+static void dvd_seek(stream_t *stream, dvd_priv_t *d, int pos)
{
d->packs_left=-1;
d->cur_pack=pos;
@@ -329,7 +329,7 @@ static void dvd_seek(dvd_priv_t *d, int pos)
}
}
- mp_msg(MSGT_DVD,MSGL_V, "DVD Seek! lba=0x%X cell=%d packs: 0x%X-0x%X \n",
+ MP_VERBOSE(stream, "DVD Seek! lba=0x%X cell=%d packs: 0x%X-0x%X \n",
d->cur_pack,d->cur_cell,d->cur_pgc->cell_playback[ d->cur_cell ].first_sector,d->cell_last_pack);
// if we're in interleaved multi-angle cell, find the right angle chain!
@@ -337,21 +337,12 @@ static void dvd_seek(dvd_priv_t *d, int pos)
d->angle_seek=1;
}
-static void dvd_close(dvd_priv_t *d)
-{
- ifoClose(d->vts_file);
- ifoClose(d->vmg_file);
- DVDCloseFile(d->title);
- DVDClose(d->dvd);
- dvd_set_speed(dvd_device_current, -1); /* -1 => restore default */
-}
-
static int fill_buffer(stream_t *s, char *buf, int len)
{
int64_t pos;
if (len < 2048)
return -1;
- pos = dvd_read_sector(s->priv, buf);
+ pos = dvd_read_sector(s, s->priv, buf);
if (pos < 0)
return -1;
// dvd_read_sector() sometimes internally skips disk-level blocks
@@ -360,12 +351,17 @@ static int fill_buffer(stream_t *s, char *buf, int len)
}
static int seek(stream_t *s, int64_t newpos) {
- dvd_seek(s->priv,newpos/2048);
+ dvd_seek(s, s->priv,newpos/2048);
return 1;
}
static void stream_dvd_close(stream_t *s) {
- dvd_close(s->priv);
+ dvd_priv_t *d = s->priv;
+ ifoClose(d->vts_file);
+ ifoClose(d->vmg_file);
+ DVDCloseFile(d->title);
+ DVDClose(d->dvd);
+ dvd_set_speed(s,dvd_device_current, -1); /* -1 => restore default */
}
static int mp_get_titleset_length(ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int title_no)
@@ -388,7 +384,7 @@ static int mp_get_titleset_length(ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, in
}
-static int mp_describe_titleset(dvd_reader_t *dvd, tt_srpt_t *tt_srpt, int vts_no)
+static int mp_describe_titleset(stream_t *stream, dvd_reader_t *dvd, tt_srpt_t *tt_srpt, int vts_no)
{
ifo_handle_t *vts_file;
int title_no, msec=0;
@@ -408,7 +404,7 @@ static int mp_describe_titleset(dvd_reader_t *dvd, tt_srpt_t *tt_srpt, int vts_n
if (tt_srpt->title[title_no].title_set_nr != vts_no)
continue;
msec = mp_get_titleset_length(vts_file, tt_srpt, title_no);
- mp_msg(MSGT_IDENTIFY, MSGL_V, "ID_DVD_TITLE_%d_LENGTH=%d.%03d\n", title_no + 1, msec / 1000, msec % 1000);
+ MP_SMODE(stream, "ID_DVD_TITLE_%d_LENGTH=%d.%03d\n", title_no + 1, msec / 1000, msec % 1000);
}
ifoClose(vts_file);
return 1;
@@ -468,7 +464,7 @@ static int seek_to_chapter(stream_t *stream, ifo_handle_t *vts_file, tt_srpt_t *
pos = (int64_t) d->cur_pack * 2048;
stream_seek(stream, pos);
- mp_msg(MSGT_OPEN,MSGL_V,"\r\nSTREAM_DVD, seeked to chapter: %d, cell: %u, pos: %"PRIu64"\n",
+ MP_VERBOSE(stream, "\r\nSTREAM_DVD, seeked to chapter: %d, cell: %u, pos: %"PRIu64"\n",
chapter, d->cur_pack, pos);
return chapter;
@@ -513,9 +509,9 @@ static int get_chapter_time(ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int titl
return 0;
}
-static void list_chapters(ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int title_no)
+static void list_chapters(stream_t *stream, ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int title_no)
{
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "CHAPTERS: ");
+ MP_INFO(stream, "CHAPTERS: ");
for (int n = 0; ; n++) {
double p = n;
int r;
@@ -523,9 +519,9 @@ static void list_chapters(ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int title_
if (!r)
break;
int t = p * 1000;
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "%02d:%02d:%02d.%03d,", t/3600000, (t/60000)%60, (t/1000)%60, t%1000);
+ MP_INFO(stream, "%02d:%02d:%02d.%03d,", t/3600000, (t/60000)%60, (t/1000)%60, t%1000);
}
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "\n");
+ MP_INFO(stream, "\n");
}
static double dvd_get_current_time(stream_t *stream, int cell)
@@ -741,7 +737,7 @@ static int open_s(stream_t *stream, int mode)
int k;
dvd_priv_t *d = stream->priv;
- mp_msg(MSGT_OPEN,MSGL_V,"URL: %s\n", stream->url);
+ MP_VERBOSE(stream, "URL: %s\n", stream->url);
dvd_title = d->cfg_title;
if(1){
//int ret,ret2;
@@ -761,7 +757,7 @@ static int open_s(stream_t *stream, int mode)
dvd_device_current = dvd_device;
else
dvd_device_current = DEFAULT_DVD_DEVICE;
- dvd_set_speed(dvd_device_current, dvd_speed);
+ dvd_set_speed(stream,dvd_device_current, dvd_speed);
#if defined(__APPLE__) || defined(__DARWIN__)
/* Dynamic DVD drive selection on Darwin */
if(!strcmp(dvd_device_current, "/dev/rdiskN")) {
@@ -773,12 +769,12 @@ static int open_s(stream_t *stream, int mode)
snprintf(temp_device, len, "/dev/rdisk%d", i);
dvd = DVDOpen(temp_device);
if(!dvd) {
- mp_msg(MSGT_OPEN,MSGL_ERR,"Couldn't open DVD device: %s (%s)\n",temp_device, strerror(errno));
+ MP_ERR(stream, "Couldn't open DVD device: %s (%s)\n",temp_device, strerror(errno));
} else {
#if DVDREAD_VERSION <= LIBDVDREAD_VERSION(0,9,4)
dvd_file_t *dvdfile = DVDOpenFile(dvd,dvd_title,DVD_READ_INFO_FILE);
if(!dvdfile) {
- mp_msg(MSGT_OPEN,MSGL_ERR,"Couldn't open DVD device: %s (%s)\n",temp_device, strerror(errno));
+ MP_ERR(stream, "Couldn't open DVD device: %s (%s)\n",temp_device, strerror(errno));
DVDClose(dvd);
continue;
}
@@ -797,12 +793,12 @@ static int open_s(stream_t *stream, int mode)
{
dvd = DVDOpen(dvd_device_current);
if(!dvd) {
- mp_msg(MSGT_OPEN,MSGL_ERR,"Couldn't open DVD device: %s (%s)\n",dvd_device_current, strerror(errno));
+ MP_ERR(stream, "Couldn't open DVD device: %s (%s)\n",dvd_device_current, strerror(errno));
return STREAM_UNSUPPORTED;
}
}
- mp_msg(MSGT_OPEN,MSGL_V,"Reading disc structure, please wait...\n");
+ MP_VERBOSE(stream, "Reading disc structure, please wait...\n");
/**
* Load the video manager to find out the information about the titles on
@@ -810,57 +806,57 @@ static int open_s(stream_t *stream, int mode)
*/
vmg_file = ifoOpen(dvd, 0);
if(!vmg_file) {
- mp_msg(MSGT_OPEN,MSGL_ERR, "Can't open VMG info!\n");
+ MP_ERR(stream, "Can't open VMG info!\n");
DVDClose( dvd );
return STREAM_UNSUPPORTED;
}
tt_srpt = vmg_file->tt_srpt;
- if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO))
+ if (mp_msg_test_log(stream->log, MSGL_SMODE))
{
int title_no; ///< title number
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_DVD_TITLES=%d\n", tt_srpt->nr_of_srpts);
+ MP_SMODE(stream, "ID_DVD_TITLES=%d\n", tt_srpt->nr_of_srpts);
for (title_no = 0; title_no < tt_srpt->nr_of_srpts; title_no++)
{
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_DVD_TITLE_%d_CHAPTERS=%d\n", title_no + 1, tt_srpt->title[title_no].nr_of_ptts);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_DVD_TITLE_%d_ANGLES=%d\n", title_no + 1, tt_srpt->title[title_no].nr_of_angles);
+ MP_SMODE(stream, "ID_DVD_TITLE_%d_CHAPTERS=%d\n", title_no + 1, tt_srpt->title[title_no].nr_of_ptts);
+ MP_SMODE(stream, "ID_DVD_TITLE_%d_ANGLES=%d\n", title_no + 1, tt_srpt->title[title_no].nr_of_angles);
}
}
- if (mp_msg_test(MSGT_IDENTIFY, MSGL_V))
+ if (mp_msg_test_log(stream->log, MSGL_SMODE))
{
char volid[32];
unsigned char discid [16]; ///< disk ID, a 128 bit MD5 sum
int vts_no; ///< video title set number
for (vts_no = 1; vts_no <= vmg_file->vts_atrt->nr_of_vtss; vts_no++)
- mp_describe_titleset(dvd, tt_srpt, vts_no);
+ mp_describe_titleset(stream, dvd, tt_srpt, vts_no);
if (DVDDiscID(dvd, discid) >= 0)
{
int i;
- mp_msg(MSGT_IDENTIFY, MSGL_V, "ID_DVD_DISC_ID=");
+ MP_SMODE(stream, "ID_DVD_DISC_ID=");
for (i = 0; i < 16; i ++)
- mp_msg(MSGT_IDENTIFY, MSGL_V, "%02X", discid[i]);
- mp_msg(MSGT_IDENTIFY, MSGL_V, "\n");
+ MP_SMODE(stream, "%02X", discid[i]);
+ MP_SMODE(stream, "\n");
}
if (DVDUDFVolumeInfo(dvd, volid, sizeof(volid), NULL, 0) >= 0 || DVDISOVolumeInfo(dvd, volid, sizeof(volid), NULL, 0) >= 0)
- mp_msg(MSGT_IDENTIFY, MSGL_V, "ID_DVD_VOLUME_ID=%s\n", volid);
+ MP_SMODE(stream, "ID_DVD_VOLUME_ID=%s\n", volid);
}
/**
* Make sure our title number is valid.
*/
- mp_msg(MSGT_OPEN,MSGL_STATUS, "There are %d titles on this DVD.\n", tt_srpt->nr_of_srpts );
+ MP_INFO(stream, "There are %d titles on this DVD.\n", tt_srpt->nr_of_srpts );
if(dvd_title < 1 || dvd_title > tt_srpt->nr_of_srpts) {
- mp_msg(MSGT_OPEN,MSGL_ERR, "Invalid DVD title number: %d\n", dvd_title);
+ MP_ERR(stream, "Invalid DVD title number: %d\n", dvd_title);
ifoClose( vmg_file );
DVDClose( dvd );
return STREAM_UNSUPPORTED;
}
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_DVD_CURRENT_TITLE=%d\n", dvd_title);
+ MP_SMODE(stream, "ID_DVD_CURRENT_TITLE=%d\n", dvd_title);
--dvd_title; // remap 1.. -> 0..
/**
* Make sure the angle number is valid for this title.
*/
- mp_msg(MSGT_OPEN,MSGL_STATUS, "There are %d angles in this DVD title.\n", tt_srpt->title[dvd_title].nr_of_angles);
+ MP_INFO(stream, "There are %d angles in this DVD title.\n", tt_srpt->title[dvd_title].nr_of_angles);
if(dvd_angle<1 || dvd_angle>tt_srpt->title[dvd_title].nr_of_angles) {
- mp_msg(MSGT_OPEN,MSGL_ERR, "Invalid DVD angle number: %d\n", dvd_angle);
+ MP_ERR(stream, "Invalid DVD angle number: %d\n", dvd_angle);
goto fail;
}
@@ -870,7 +866,7 @@ static int open_s(stream_t *stream, int mode)
*/
vts_file = ifoOpen( dvd, tt_srpt->title[dvd_title].title_set_nr );
if(!vts_file) {
- mp_msg(MSGT_OPEN,MSGL_ERR, "Cannot open the IFO file for DVD title %d.\n", tt_srpt->title[dvd_title].title_set_nr );
+ MP_ERR(stream, "Cannot open the IFO file for DVD title %d.\n", tt_srpt->title[dvd_title].title_set_nr );
goto fail;
}
/**
@@ -878,12 +874,12 @@ static int open_s(stream_t *stream, int mode)
*/
title = DVDOpenFile(dvd, tt_srpt->title[dvd_title].title_set_nr, DVD_READ_TITLE_VOBS);
if(!title) {
- mp_msg(MSGT_OPEN,MSGL_ERR, "Cannot open title VOBS (VTS_%02d_1.VOB).\n", tt_srpt->title[dvd_title].title_set_nr);
+ MP_ERR(stream, "Cannot open title VOBS (VTS_%02d_1.VOB).\n", tt_srpt->title[dvd_title].title_set_nr);
ifoClose( vts_file );
goto fail;
}
- mp_msg(MSGT_OPEN,MSGL_V, "DVD successfully opened.\n");
+ MP_VERBOSE(stream, "DVD successfully opened.\n");
// store data
d->dvd=dvd;
d->title=title;
@@ -937,21 +933,21 @@ static int open_s(stream_t *stream, int mode)
// 1 - stereo
// 5 - 5.1
audio_stream->channels=audio->channels;
- mp_msg(MSGT_OPEN,MSGL_STATUS,"audio stream: %d format: %s (%s) language: %s aid: %d.\n",
+ MP_INFO(stream, "audio stream: %d format: %s (%s) language: %s aid: %d.\n",
d->nr_of_channels,
dvd_audio_stream_types[ audio->audio_format ],
dvd_audio_stream_channels[ audio->channels ],
tmp,
audio_stream->id
);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_ID=%d\n", audio_stream->id);
+ MP_SMODE(stream, "ID_AUDIO_ID=%d\n", audio_stream->id);
if(language && tmp[0])
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_LANG=%s\n", audio_stream->id, tmp);
+ MP_SMODE(stream, "ID_AID_%d_LANG=%s\n", audio_stream->id, tmp);
d->nr_of_channels++;
}
}
- mp_msg(MSGT_OPEN,MSGL_STATUS,"number of audio channels on disk: %d.\n",d->nr_of_channels );
+ MP_INFO(stream, "number of audio channels on disk: %d.\n",d->nr_of_channels );
}
/**
@@ -983,13 +979,13 @@ static int open_s(stream_t *stream, int mode)
else if(video->display_aspect_ratio == 3) /* 16:9 */
sub_stream->id = pgc->subp_control[i] >> 8 & 31;
- mp_msg(MSGT_OPEN,MSGL_STATUS,"subtitle ( sid ): %d language: %s\n", sub_stream->id, tmp);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SUBTITLE_ID=%d\n", sub_stream->id);
+ MP_INFO(stream, "subtitle ( sid ): %d language: %s\n", sub_stream->id, tmp);
+ MP_SMODE(stream, "ID_SUBTITLE_ID=%d\n", sub_stream->id);
if(language && tmp[0])
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SID_%d_LANG=%s\n", sub_stream->id, tmp);
+ MP_SMODE(stream, "ID_SID_%d_LANG=%s\n", sub_stream->id, tmp);
d->nr_of_subtitles++;
}
- mp_msg(MSGT_OPEN,MSGL_STATUS,"number of subtitles on disk: %d\n",d->nr_of_subtitles);
+ MP_INFO(stream, "number of subtitles on disk: %d\n",d->nr_of_subtitles);
}
/**
@@ -1009,7 +1005,7 @@ static int open_s(stream_t *stream, int mode)
d->cur_cell+=dvd_angle-1;
d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector;
d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector;
- mp_msg(MSGT_DVD,MSGL_V, "DVD start cell: %d pack: 0x%X-0x%X \n",d->cur_cell,d->cur_pack,d->cell_last_pack);
+ MP_VERBOSE(stream, "DVD start cell: %d pack: 0x%X-0x%X \n",d->cur_cell,d->cur_pack,d->cell_last_pack);
//assign cell_times_table
d->cell_times_table = malloc(sizeof(unsigned int) * d->cur_pgc->nr_of_cells);
@@ -1017,7 +1013,7 @@ static int open_s(stream_t *stream, int mode)
return STREAM_UNSUPPORTED;
for(k=0; k<d->cur_pgc->nr_of_cells; k++)
d->cell_times_table[k] = mp_dvdtimetomsec(&d->cur_pgc->cell_playback[k].playback_time);
- list_chapters(vts_file,tt_srpt,dvd_title);
+ list_chapters(stream, vts_file,tt_srpt,dvd_title);
// ... (unimplemented)
// return NULL;
@@ -1030,7 +1026,7 @@ static int open_s(stream_t *stream, int mode)
stream->close = stream_dvd_close;
stream->start_pos = (int64_t)d->cur_pack*2048;
stream->end_pos = (int64_t)(d->cur_pgc->cell_playback[d->last_cell-1].last_sector)*2048;
- mp_msg(MSGT_DVD,MSGL_V,"DVD start=%d end=%d \n",d->cur_pack,d->cur_pgc->cell_playback[d->last_cell-1].last_sector);
+ MP_VERBOSE(stream, "DVD start=%d end=%d \n",d->cur_pack,d->cur_pgc->cell_playback[d->last_cell-1].last_sector);
stream->priv = (void*)d;
return STREAM_OK;
@@ -1039,7 +1035,7 @@ fail:
DVDClose(dvd);
return STREAM_UNSUPPORTED;
}
- mp_msg(MSGT_DVD,MSGL_ERR,"mpv was compiled without DVD support, exiting.\n");
+ MP_ERR(stream, "mpv was compiled without DVD support, exiting.\n");
return STREAM_UNSUPPORTED;
}
@@ -1058,7 +1054,7 @@ static int ifo_stream_open (stream_t *stream, int mode)
if (len < 4 || strcasecmp (stream->path + len - 4, ".ifo"))
return STREAM_UNSUPPORTED;
- mp_msg(MSGT_DVD, MSGL_INFO, ".IFO detected. Redirecting to dvd://\n");
+ MP_INFO(stream, ".IFO detected. Redirecting to dvd://\n");
filename = strdup(basename(stream->path));
diff --git a/stream/stream_dvd_common.c b/stream/stream_dvd_common.c
index 31d045ae5b..6c29d446c5 100644
--- a/stream/stream_dvd_common.c
+++ b/stream/stream_dvd_common.c
@@ -49,7 +49,7 @@ const char * const dvd_audio_stream_channels[6] = { "mono", "stereo", "unknown",
int dvd_speed=0; /* 0 => don't touch speed */
-void dvd_set_speed(char *device, unsigned speed)
+void dvd_set_speed(stream_t *stream, char *device, unsigned speed)
{
#if defined(__linux__) && defined(SG_IO) && defined(GPCMD_SET_STREAMING)
int fd;
@@ -69,13 +69,13 @@ void dvd_set_speed(char *device, unsigned speed)
return;
case -1: /* restore default value */
if (dvd_speed == 0) return; /* we haven't touched the speed setting */
- mp_msg(MSGT_OPEN, MSGL_INFO, "Restoring DVD speed... ");
+ MP_INFO(stream, "Restoring DVD speed... ");
break;
default: /* limit to <speed> KB/s */
// speed < 100 is multiple of DVD single speed (1350KB/s)
if (speed < 100)
speed *= 1350;
- mp_msg(MSGT_OPEN, MSGL_INFO, "Limiting DVD speed to %dKB/s... ", speed);
+ MP_INFO(stream, "Limiting DVD speed to %dKB/s... ", speed);
break;
}
@@ -108,14 +108,14 @@ void dvd_set_speed(char *device, unsigned speed)
fd = open(device, O_RDWR | O_NONBLOCK | O_CLOEXEC);
if (fd == -1) {
- mp_msg(MSGT_OPEN, MSGL_INFO, "Couldn't open DVD device for writing, changing DVD speed needs write access.\n");
+ MP_INFO(stream, "Couldn't open DVD device for writing, changing DVD speed needs write access.\n");
return;
}
if (ioctl(fd, SG_IO, &sghdr) < 0)
- mp_msg(MSGT_OPEN, MSGL_INFO, "failed\n");
+ MP_INFO(stream, "failed\n");
else
- mp_msg(MSGT_OPEN, MSGL_INFO, "successful\n");
+ MP_INFO(stream, "successful\n");
close(fd);
#endif
diff --git a/stream/stream_dvd_common.h b/stream/stream_dvd_common.h
index 0a6c6789e1..4a1aef9af0 100644
--- a/stream/stream_dvd_common.h
+++ b/stream/stream_dvd_common.h
@@ -22,11 +22,12 @@
#include "config.h"
#include <inttypes.h>
#include <dvdread/ifo_types.h>
+#include "stream.h"
extern const char * const dvd_audio_stream_channels[6];
extern const char * const dvd_audio_stream_types[8];
-void dvd_set_speed(char *device, unsigned speed);
+void dvd_set_speed(stream_t *stream, char *device, unsigned speed);
int mp_dvdtimetomsec(dvd_time_t *dt);
#endif /* MPLAYER_STREAM_DVD_COMMON_H */
diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c
index b9339e70e0..ca17846921 100644
--- a/stream/stream_dvdnav.c
+++ b/stream/stream_dvdnav.c
@@ -156,7 +156,7 @@ static void handle_menu_input(stream_t *stream, const char *cmd)
dvdnav_status_t status = DVDNAV_STATUS_ERR;
pci_t *pci = dvdnav_get_current_nav_pci(nav);
- mp_msg(MSGT_CPLAYER, MSGL_V, "DVDNAV: input '%s'\n", cmd);
+ MP_VERBOSE(stream, "DVDNAV: input '%s'\n", cmd);
if (!pci)
return;
@@ -185,7 +185,7 @@ static void handle_menu_input(stream_t *stream, const char *cmd)
} else if (strcmp(cmd, "mouse") == 0) {
status = dvdnav_mouse_activate(nav, pci, priv->mousex, priv->mousey);
} else {
- mp_msg(MSGT_CPLAYER, MSGL_V, "Unknown DVDNAV command: '%s'\n", cmd);
+ MP_VERBOSE(stream, "Unknown DVDNAV command: '%s'\n", cmd);
}
}
@@ -273,7 +273,7 @@ static int mp_dvdnav_number_of_subs(stream_t *stream)
static void handle_cmd(stream_t *s, struct mp_nav_cmd *ev)
{
struct priv *priv = s->priv;
- mp_msg(MSGT_CPLAYER, MSGL_V, "DVDNAV: input '%s'\n",
+ MP_VERBOSE(s, "DVDNAV: input '%s'\n",
LOOKUP_NAME(mp_nav_cmd_types, ev->event));
switch (ev->event) {
case MP_NAV_CMD_ENABLE:
@@ -331,8 +331,8 @@ static void fill_next_event(stream_t *s, struct mp_nav_event **ret)
*ret = talloc(NULL, struct mp_nav_event);
**ret = e;
- mp_msg(MSGT_CPLAYER, MSGL_V, "DVDNAV: player event '%s'\n",
- LOOKUP_NAME(mp_nav_event_types, e.event));
+ MP_VERBOSE(s, "DVDNAV: player event '%s'\n",
+ LOOKUP_NAME(mp_nav_event_types, e.event));
}
}
@@ -352,14 +352,13 @@ static int fill_buffer(stream_t *s, char *buf, int max_len)
int event = DVDNAV_NOP;
if (dvdnav_get_next_block(dvdnav, buf, &event, &len) != DVDNAV_STATUS_OK)
{
- mp_msg(MSGT_CPLAYER, MSGL_ERR,
- "Error getting next block from DVD %d (%s)\n",
+ MP_ERR(s, "Error getting next block from DVD %d (%s)\n",
event, dvdnav_err_to_string(dvdnav));
return 0;
}
if (event != DVDNAV_BLOCK_OK) {
const char *name = LOOKUP_NAME(mp_dvdnav_events, event);
- mp_msg(MSGT_CPLAYER, MSGL_V, "DVDNAV: event %s (%d).\n", name, event);
+ MP_VERBOSE(s, "DVDNAV: event %s (%d).\n", name, event);
dvdnav_get_highlight(priv, 1);
}
switch (event) {
@@ -376,7 +375,7 @@ static int fill_buffer(stream_t *s, char *buf, int max_len)
priv->still_length = still_event->length;
if (priv->still_length == 255)
priv->still_length = -1;
- mp_msg(MSGT_CPLAYER, MSGL_V, "len=%d\n", priv->still_length);
+ MP_VERBOSE(s, "len=%d\n", priv->still_length);
/* set still frame duration */
if (priv->still_length <= 1) {
pci_t *pnavpci = dvdnav_get_current_nav_pci(dvdnav);
@@ -406,7 +405,7 @@ static int fill_buffer(stream_t *s, char *buf, int max_len)
int tit = 0, part = 0;
dvdnav_vts_change_event_t *vts_event =
(dvdnav_vts_change_event_t *)s->buffer;
- mp_msg(MSGT_CPLAYER, MSGL_INFO, "DVDNAV, switched to title: %d\n",
+ MP_INFO(s, "DVDNAV, switched to title: %d\n",
vts_event->new_vtsN);
if (!priv->had_initial_vts) {
// dvdnav sends an initial VTS change before any data; don't
@@ -419,11 +418,11 @@ static int fill_buffer(stream_t *s, char *buf, int max_len)
priv->next_event |= 1 << MP_NAV_EVENT_RESET_ALL;
if (dvdnav_current_title_info(dvdnav, &tit, &part) == DVDNAV_STATUS_OK)
{
- mp_msg(MSGT_CPLAYER, MSGL_V, "DVDNAV, NEW TITLE %d\n", tit);
+ MP_VERBOSE(s, "DVDNAV, NEW TITLE %d\n", tit);
dvdnav_get_highlight(priv, 0);
if (priv->title > 0 && tit != priv->title) {
priv->next_event |= 1 << MP_NAV_EVENT_EOF;;
- mp_msg(MSGT_CPLAYER, MSGL_WARN, "Requested title not found\n");
+ MP_WARN(s, "Requested title not found\n");
return 0;
}
}
@@ -613,11 +612,12 @@ static void stream_dvdnav_close(stream_t *s)
struct priv *priv = s->priv;
dvdnav_close(priv->dvdnav);
priv->dvdnav = NULL;
- dvd_set_speed(priv->filename, -1);
+ dvd_set_speed(s, priv->filename, -1);
}
-static struct priv *new_dvdnav_stream(struct priv *priv, char *filename)
+static struct priv *new_dvdnav_stream(stream_t *stream, char *filename)
{
+ struct priv *priv = stream->priv;
const char *title_str;
if (!filename)
@@ -626,7 +626,7 @@ static struct priv *new_dvdnav_stream(struct priv *priv, char *filename)
if (!(priv->filename = strdup(filename)))
return NULL;
- dvd_set_speed(priv->filename, dvd_speed);
+ dvd_set_speed(stream, priv->filename, dvd_speed);
if (dvdnav_open(&(priv->dvdnav), priv->filename) != DVDNAV_STATUS_OK) {
free(priv->filename);
@@ -639,11 +639,10 @@ static struct priv *new_dvdnav_stream(struct priv *priv, char *filename)
dvdnav_set_readahead_flag(priv->dvdnav, 1);
if (dvdnav_set_PGC_positioning_flag(priv->dvdnav, 1) != DVDNAV_STATUS_OK)
- mp_msg(MSGT_OPEN, MSGL_ERR,
- "stream_dvdnav, failed to set PGC positioning\n");
+ MP_ERR(stream, "stream_dvdnav, failed to set PGC positioning\n");
/* report the title?! */
if (dvdnav_get_title_string(priv->dvdnav, &title_str) == DVDNAV_STATUS_OK)
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_DVD_VOLUME_ID=%s\n", title_str);
+ MP_SMODE(stream, "ID_DVD_VOLUME_ID=%s\n", title_str);
return priv;
}
@@ -660,8 +659,8 @@ static int open_s(stream_t *stream, int mode)
filename = dvd_device;
else
filename = DEFAULT_DVD_DEVICE;
- if (!new_dvdnav_stream(priv, filename)) {
- mp_msg(MSGT_OPEN, MSGL_ERR, "Couldn't open DVD device: %s\n",
+ if (!new_dvdnav_stream(stream, filename)) {
+ MP_ERR(stream, "Couldn't open DVD device: %s\n",
filename);
return STREAM_UNSUPPORTED;
}
@@ -684,19 +683,18 @@ static int open_s(stream_t *stream, int mode)
}
}
}
- mp_msg(MSGT_OPEN, MSGL_INFO, "Selecting title %d.\n", best_title);
+ MP_INFO(stream, "Selecting title %d.\n", best_title);
p->track = best_title;
}
if (p->track > 0) {
priv->title = p->track;
if (dvdnav_title_play(priv->dvdnav, p->track) != DVDNAV_STATUS_OK) {
- mp_msg(MSGT_OPEN, MSGL_FATAL,
- "dvdnav_stream, couldn't select title %d, error '%s'\n",
+ MP_FATAL(stream, "dvdnav_stream, couldn't select title %d, error '%s'\n",
p->track, dvdnav_err_to_string(priv->dvdnav));
return STREAM_UNSUPPORTED;
}
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_DVD_CURRENT_TITLE=%d\n", p->track);
+ MP_SMODE(stream, "ID_DVD_CURRENT_TITLE=%d\n", p->track);
} else {
if (dvdnav_menu_call(priv->dvdnav, DVD_MENU_Root) != DVDNAV_STATUS_OK)
dvdnav_menu_call(priv->dvdnav, DVD_MENU_Title);
diff --git a/stream/stream_file.c b/stream/stream_file.c
index 9f88e5bf6e..9b27b7bc82 100644
--- a/stream/stream_file.c
+++ b/stream/stream_file.c
@@ -107,7 +107,7 @@ static int open_f(stream_t *stream, int mode)
else if (mode == STREAM_WRITE)
m |= O_RDWR | O_CREAT | O_TRUNC;
else {
- mp_msg(MSGT_OPEN, MSGL_ERR, "[file] Unknown open mode %d\n", mode);
+ MP_ERR(stream, "Unknown open mode %d\n", mode);
return STREAM_UNSUPPORTED;
}
@@ -123,13 +123,13 @@ static int open_f(stream_t *stream, int mode)
if (!strcmp(filename, "-")) {
if (mode == STREAM_READ) {
- mp_msg(MSGT_OPEN, MSGL_INFO, "Reading from stdin...\n");
+ MP_INFO(stream, "Reading from stdin...\n");
fd = 0;
#if HAVE_SETMODE
setmode(fileno(stdin), O_BINARY);
#endif
} else {
- mp_msg(MSGT_OPEN, MSGL_INFO, "Writing to stdout\n");
+ MP_INFO(stream, "Writing to stdout\n");
fd = 1;
#if HAVE_SETMODE
setmode(fileno(stdout), O_BINARY);
@@ -144,14 +144,14 @@ static int open_f(stream_t *stream, int mode)
#endif
fd = open(filename, m | O_BINARY, openmode);
if (fd < 0) {
- mp_msg(MSGT_OPEN, MSGL_ERR, "Cannot open file '%s': %s\n",
+ MP_ERR(stream, "Cannot open file '%s': %s\n",
filename, strerror(errno));
return STREAM_ERROR;
}
#ifndef __MINGW32__
struct stat st;
if (fstat(fd, &st) == 0 && S_ISDIR(st.st_mode)) {
- mp_msg(MSGT_OPEN, MSGL_ERR, "File is a directory: '%s'\n",
+ MP_ERR(stream, "File is a directory: '%s'\n",
filename);
close(fd);
return STREAM_ERROR;
@@ -175,7 +175,7 @@ static int open_f(stream_t *stream, int mode)
stream->end_pos = len;
}
- mp_msg(MSGT_OPEN, MSGL_V, "[file] File size is %" PRId64 " bytes\n", len);
+ MP_VERBOSE(stream, "File size is %" PRId64 " bytes\n", len);
stream->fill_buffer = fill_buffer;
stream->write_buffer = write_buffer;
diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c
index 5a14cbdeb5..a161c19cf9 100644
--- a/stream/stream_lavf.c
+++ b/stream/stream_lavf.c
@@ -142,14 +142,14 @@ static int open_f(stream_t *stream, int mode)
else if (mode == STREAM_WRITE)
flags = AVIO_FLAG_WRITE;
else {
- mp_msg(MSGT_OPEN, MSGL_ERR, "[ffmpeg] Unknown open mode %d\n", mode);
+ MP_ERR(stream, "[ffmpeg] Unknown open mode %d\n", mode);
res = STREAM_UNSUPPORTED;
goto out;
}
const char *filename = stream->url;
if (!filename) {
- mp_msg(MSGT_OPEN, MSGL_ERR, "[ffmpeg] No URL\n");
+ MP_ERR(stream, "[ffmpeg] No URL\n");
goto out;
}
for (int i = 0; i < sizeof(prefix) / sizeof(prefix[0]); i++)
@@ -168,7 +168,7 @@ static int open_f(stream_t *stream, int mode)
talloc_free(temp);
return STREAM_OK;
}
- mp_msg(MSGT_OPEN, MSGL_V, "[ffmpeg] Opening %s\n", filename);
+ MP_VERBOSE(stream, "[ffmpeg] Opening %s\n", filename);
// Replace "mms://" with "mmsh://", so that most mms:// URLs just work.
bstr b_filename = bstr0(filename);
@@ -182,7 +182,7 @@ static int open_f(stream_t *stream, int mode)
if (network_useragent)
av_dict_set(&dict, "user-agent", network_useragent, 0);
if (network_cookies_enabled)
- av_dict_set(&dict, "cookies", talloc_steal(temp, cookies_lavf()), 0);
+ av_dict_set(&dict, "cookies", talloc_steal(temp, cookies_lavf(stream->log)), 0);
av_dict_set(&dict, "tls_verify", network_tls_verify ? "1" : "0", 0);
if (network_tls_ca_file)
av_dict_set(&dict, "ca_file", network_tls_ca_file, 0);
@@ -204,14 +204,14 @@ static int open_f(stream_t *stream, int mode)
int err = avio_open2(&avio, filename, flags, NULL, &dict);
if (err < 0) {
if (err == AVERROR_PROTOCOL_NOT_FOUND)
- mp_msg(MSGT_OPEN, MSGL_ERR, "[ffmpeg] Protocol not found. Make sure"
+ MP_ERR(stream, "[ffmpeg] Protocol not found. Make sure"
" ffmpeg/Libav is compiled with networking support.\n");
goto out;
}
AVDictionaryEntry *t = NULL;
while ((t = av_dict_get(dict, "", t, AV_DICT_IGNORE_SUFFIX))) {
- mp_msg(MSGT_OPEN, MSGL_V, "[ffmpeg] Could not set stream option %s=%s\n",
+ MP_VERBOSE(stream, "[ffmpeg] Could not set stream option %s=%s\n",
t->key, t->value);
}
diff --git a/stream/stream_pvr.c b/stream/stream_pvr.c
index 29ea354293..e88529e589 100644
--- a/stream/stream_pvr.c
+++ b/stream/stream_pvr.c
@@ -109,6 +109,7 @@ typedef struct stationlist_s {
} stationlist_t;
struct pvr_t {
+ struct mp_log *log;
int dev_fd;
char *video_dev;
@@ -204,7 +205,7 @@ pvr_uninit (struct pvr_t *pvr)
* @see parse_setup_stationlist
*/
static int
-copycreate_stationlist (stationlist_t *stationlist, int num)
+copycreate_stationlist (struct pvr_t *pvr, stationlist_t *stationlist, int num)
{
int i;
@@ -223,8 +224,7 @@ copycreate_stationlist (stationlist_t *stationlist, int num)
if (!stationlist->list)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s No memory allocated for station list, giving up\n",
+ MP_ERR(pvr, "%s No memory allocated for station list, giving up\n",
LOG_LEVEL_V4L2);
return -1;
}
@@ -256,8 +256,7 @@ print_all_stations (struct pvr_t *pvr)
for (i = 0; i < pvr->stationlist.total; i++)
{
- mp_msg (MSGT_OPEN, MSGL_V,
- "%s %3d: [%c] channel: %8s - freq: %8d - station: %s\n",
+ MP_VERBOSE(pvr, "%s %3d: [%c] channel: %8s - freq: %8d - station: %s\n",
LOG_LEVEL_V4L2, i, (pvr->stationlist.list[i].enabled) ? 'X' : ' ',
pvr->stationlist.list[i].name, pvr->stationlist.list[i].freq,
pvr->stationlist.list[i].station);
@@ -328,8 +327,7 @@ set_station (struct pvr_t *pvr, const char *station,
else
BUFPRINTF(pvr->stationlist.list[i].station, "F %d", freq);
- mp_msg (MSGT_OPEN, MSGL_DBG2,
- "%s Set user station channel: %8s - freq: %8d - station: %s\n",
+ MP_DBG(pvr, "%s Set user station channel: %8s - freq: %8d - station: %s\n",
LOG_LEVEL_V4L2, pvr->stationlist.list[i].name,
pvr->stationlist.list[i].freq,
pvr->stationlist.list[i].station);
@@ -339,8 +337,7 @@ set_station (struct pvr_t *pvr, const char *station,
/* from here on, we have to create a new entry, frequency is mandatory */
if (freq < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s Cannot add new station/channel without frequency\n",
+ MP_ERR(pvr, "%s Cannot add new station/channel without frequency\n",
LOG_LEVEL_V4L2);
return -1;
}
@@ -358,8 +355,7 @@ set_station (struct pvr_t *pvr, const char *station,
if (!pvr->stationlist.list)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s No memory allocated for station list, giving up\n",
+ MP_ERR(pvr, "%s No memory allocated for station list, giving up\n",
LOG_LEVEL_V4L2);
return -1;
}
@@ -384,8 +380,7 @@ set_station (struct pvr_t *pvr, const char *station,
pvr->stationlist.list[i].freq = freq;
- mp_msg (MSGT_OPEN, MSGL_DBG2,
- "%s Add user station channel: %8s - freq: %8d - station: %s\n",
+ MP_DBG(pvr, "%s Add user station channel: %8s - freq: %8d - station: %s\n",
LOG_LEVEL_V4L2, pvr->stationlist.list[i].name,
pvr->stationlist.list[i].freq,
pvr->stationlist.list[i].station);
@@ -424,29 +419,25 @@ parse_setup_stationlist (struct pvr_t *pvr)
}
if (!chanlists[i].name)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s unable to find channel list %s, using default %s\n",
+ MP_ERR(pvr, "%s unable to find channel list %s, using default %s\n",
LOG_LEVEL_V4L2, stream_tv_defaults.chanlist, chanlists[chantab].name);
}
else
{
- mp_msg (MSGT_OPEN, MSGL_INFO,
- "%s select channel list %s, entries %d\n", LOG_LEVEL_V4L2,
+ MP_INFO(pvr, "%s select channel list %s, entries %d\n", LOG_LEVEL_V4L2,
chanlists[chantab].name, chanlists[chantab].count);
}
}
if (0 > chantab)
{
- mp_msg (MSGT_OPEN, MSGL_FATAL,
- "%s No channel list selected, giving up\n", LOG_LEVEL_V4L2);
+ MP_FATAL(pvr, "%s No channel list selected, giving up\n", LOG_LEVEL_V4L2);
return -1;
}
- if (copycreate_stationlist (&(pvr->stationlist), -1) < 0)
+ if (copycreate_stationlist (pvr,&(pvr->stationlist), -1) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_FATAL,
- "%s No memory allocated for station list, giving up\n",
+ MP_FATAL(pvr, "%s No memory allocated for station list, giving up\n",
LOG_LEVEL_V4L2);
return -1;
}
@@ -486,8 +477,7 @@ parse_setup_stationlist (struct pvr_t *pvr)
if (set_station (pvr, station, (freq <= 0) ? channel : NULL, freq) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s Unable to set user station channel: %8s - freq: %8d - station: %s\n", LOG_LEVEL_V4L2,
+ MP_ERR(pvr, "%s Unable to set user station channel: %8s - freq: %8d - station: %s\n", LOG_LEVEL_V4L2,
channel, freq, station);
}
}
@@ -514,14 +504,14 @@ get_v4l2_freq (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_G_TUNER, &vt) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR, "%s can't set tuner (%s).\n",
+ MP_ERR(pvr, "%s can't set tuner (%s).\n",
LOG_LEVEL_V4L2, strerror (errno));
return -1;
}
if (ioctl (pvr->dev_fd, VIDIOC_G_FREQUENCY, &vf) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR, "%s can't get frequency %d.\n",
+ MP_ERR(pvr, "%s can't get frequency %d.\n",
LOG_LEVEL_V4L2, errno);
return -1;
}
@@ -544,8 +534,7 @@ set_v4l2_freq (struct pvr_t *pvr)
if (0 >= pvr->freq)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s Frequency invalid %d !!!\n", LOG_LEVEL_V4L2, pvr->freq);
+ MP_ERR(pvr, "%s Frequency invalid %d !!!\n", LOG_LEVEL_V4L2, pvr->freq);
return -1;
}
@@ -554,8 +543,7 @@ set_v4l2_freq (struct pvr_t *pvr)
*/
if (get_v4l2_freq (pvr) == pvr->freq)
{
- mp_msg (MSGT_OPEN, MSGL_STATUS,
- "%s Frequency %d already set.\n", LOG_LEVEL_V4L2, pvr->freq);
+ MP_INFO(pvr, "%s Frequency %d already set.\n", LOG_LEVEL_V4L2, pvr->freq);
return 0;
}
@@ -567,7 +555,7 @@ set_v4l2_freq (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_G_TUNER, &vt) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR, "%s can't get tuner (%s).\n",
+ MP_ERR(pvr, "%s can't get tuner (%s).\n",
LOG_LEVEL_V4L2, strerror (errno));
return -1;
}
@@ -580,7 +568,7 @@ set_v4l2_freq (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_S_FREQUENCY, &vf) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR, "%s can't set frequency (%s).\n",
+ MP_ERR(pvr, "%s can't set frequency (%s).\n",
LOG_LEVEL_V4L2, strerror (errno));
return -1;
}
@@ -588,17 +576,17 @@ set_v4l2_freq (struct pvr_t *pvr)
memset (&vt, 0, sizeof(vt));
if (ioctl (pvr->dev_fd, VIDIOC_G_TUNER, &vt) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR, "%s can't set tuner (%s).\n",
+ MP_ERR(pvr, "%s can't set tuner (%s).\n",
LOG_LEVEL_V4L2, strerror (errno));
return -1;
}
/* just a notification */
if (!vt.signal)
- mp_msg (MSGT_OPEN, MSGL_ERR, "%s NO SIGNAL at frequency %d (%d)\n",
+ MP_ERR(pvr, "%s NO SIGNAL at frequency %d (%d)\n",
LOG_LEVEL_V4L2, pvr->freq, vf.frequency);
else
- mp_msg (MSGT_OPEN, MSGL_STATUS, "%s Got signal at frequency %d (%d)\n",
+ MP_INFO(pvr, "%s Got signal at frequency %d (%d)\n",
LOG_LEVEL_V4L2, pvr->freq, vf.frequency);
return 0;
@@ -619,15 +607,13 @@ set_station_by_step (struct pvr_t *pvr, int step, int v4lAction)
{
chidx = (chidx + pvr->stationlist.used) % pvr->stationlist.used;
- mp_msg (MSGT_OPEN, MSGL_DBG2,
- "%s Offset switch: current %d, enabled %d, step %d -> %d\n",
+ MP_DBG(pvr, "%s Offset switch: current %d, enabled %d, step %d -> %d\n",
LOG_LEVEL_V4L2, pvr->chan_idx,
pvr->stationlist.enabled, step, chidx);
if (!pvr->stationlist.list[chidx].enabled)
{
- mp_msg (MSGT_OPEN, MSGL_DBG2,
- "%s Switch disabled to user station channel: %8s - freq: %8d - station: %s\n", LOG_LEVEL_V4L2,
+ MP_DBG(pvr, "%s Switch disabled to user station channel: %8s - freq: %8d - station: %s\n", LOG_LEVEL_V4L2,
pvr->stationlist.list[chidx].name,
pvr->stationlist.list[chidx].freq,
pvr->stationlist.list[chidx].station);
@@ -641,8 +627,7 @@ set_station_by_step (struct pvr_t *pvr, int step, int v4lAction)
pvr->chan_idx_last = pvr->chan_idx;
pvr->chan_idx = chidx;
- mp_msg (MSGT_OPEN, MSGL_INFO,
- "%s Switch to user station channel: %8s - freq: %8d - station: %s\n", LOG_LEVEL_V4L2,
+ MP_INFO(pvr, "%s Switch to user station channel: %8s - freq: %8d - station: %s\n", LOG_LEVEL_V4L2,
pvr->stationlist.list[chidx].name,
pvr->stationlist.list[chidx].freq,
pvr->stationlist.list[chidx].station);
@@ -653,8 +638,7 @@ set_station_by_step (struct pvr_t *pvr, int step, int v4lAction)
return (pvr->freq > 0) ? 0 : -1;
}
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s Ooops couldn't set freq by channel entry step %d to current %d, enabled %d\n", LOG_LEVEL_V4L2,
+ MP_ERR(pvr, "%s Ooops couldn't set freq by channel entry step %d to current %d, enabled %d\n", LOG_LEVEL_V4L2,
step, pvr->chan_idx, pvr->stationlist.enabled);
return -1;
@@ -671,8 +655,7 @@ set_station_by_channelname_or_freq (struct pvr_t *pvr, const char *channel,
if (0 >= pvr->stationlist.enabled)
{
- mp_msg (MSGT_OPEN, MSGL_WARN,
- "%s No enabled station, cannot switch channel/frequency\n",
+ MP_WARN(pvr, "%s No enabled station, cannot switch channel/frequency\n",
LOG_LEVEL_V4L2);
return -1;
}
@@ -686,8 +669,7 @@ set_station_by_channelname_or_freq (struct pvr_t *pvr, const char *channel,
{
if (!pvr->stationlist.list[i].enabled)
{
- mp_msg (MSGT_OPEN, MSGL_WARN,
- "%s Switch disabled to user station channel: %8s - freq: %8d - station: %s\n", LOG_LEVEL_V4L2,
+ MP_WARN(pvr, "%s Switch disabled to user station channel: %8s - freq: %8d - station: %s\n", LOG_LEVEL_V4L2,
pvr->stationlist.list[i].name,
pvr->stationlist.list[i].freq,
pvr->stationlist.list[i].station);
@@ -711,8 +693,7 @@ set_station_by_channelname_or_freq (struct pvr_t *pvr, const char *channel,
{
if (!pvr->stationlist.list[i].enabled)
{
- mp_msg (MSGT_OPEN, MSGL_WARN,
- "%s Switch disabled to user station channel: %8s - freq: %8d - station: %s\n", LOG_LEVEL_V4L2,
+ MP_WARN(pvr, "%s Switch disabled to user station channel: %8s - freq: %8d - station: %s\n", LOG_LEVEL_V4L2,
pvr->stationlist.list[i].name,
pvr->stationlist.list[i].freq,
pvr->stationlist.list[i].station);
@@ -731,16 +712,13 @@ set_station_by_channelname_or_freq (struct pvr_t *pvr, const char *channel,
if (i >= pvr->stationlist.used)
{
if (channel)
- mp_msg (MSGT_OPEN, MSGL_WARN,
- "%s unable to find channel %s\n", LOG_LEVEL_V4L2, channel);
+ MP_WARN(pvr, "%s unable to find channel %s\n", LOG_LEVEL_V4L2, channel);
else
- mp_msg (MSGT_OPEN, MSGL_WARN,
- "%s unable to find frequency %d\n", LOG_LEVEL_V4L2, freq);
+ MP_WARN(pvr, "%s unable to find frequency %d\n", LOG_LEVEL_V4L2, freq);
return -1;
}
- mp_msg (MSGT_OPEN, MSGL_INFO,
- "%s Switch to user station channel: %8s - freq: %8d - station: %s\n", LOG_LEVEL_V4L2,
+ MP_INFO(pvr, "%s Switch to user station channel: %8s - freq: %8d - station: %s\n", LOG_LEVEL_V4L2,
pvr->stationlist.list[i].name,
pvr->stationlist.list[i].freq,
pvr->stationlist.list[i].station);
@@ -763,8 +741,7 @@ force_freq_step (struct pvr_t *pvr, int step)
if (freq)
{
- mp_msg (MSGT_OPEN, MSGL_INFO,
- "%s Force Frequency %d + %d = %d \n", LOG_LEVEL_V4L2,
+ MP_INFO(pvr, "%s Force Frequency %d + %d = %d \n", LOG_LEVEL_V4L2,
pvr->freq, step, freq);
pvr->freq = freq;
@@ -1090,7 +1067,7 @@ set_encoder_settings (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_S_EXT_CTRLS, &ctrls) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR, "%s Error setting MPEG controls (%s).\n",
+ MP_ERR(pvr, "%s Error setting MPEG controls (%s).\n",
LOG_LEVEL_ENCODER, strerror (errno));
free (ext_ctrl);
return -1;
@@ -1117,8 +1094,7 @@ parse_v4l2_tv_options (struct pvr_t *pvr)
{
if (stream_tv_defaults.freq)
{
- mp_msg (MSGT_OPEN, MSGL_HINT,
- "%s tv param freq %s is overwritten by channel setting freq %d\n", LOG_LEVEL_V4L2,
+ MP_INFO(pvr, "%s tv param freq %s is overwritten by channel setting freq %d\n", LOG_LEVEL_V4L2,
stream_tv_defaults.freq, pvr->freq);
}
}
@@ -1126,14 +1102,13 @@ parse_v4l2_tv_options (struct pvr_t *pvr)
if (pvr->freq < 0 && stream_tv_defaults.freq)
{
- mp_msg (MSGT_OPEN, MSGL_HINT, "%s tv param freq %s is used directly\n",
+ MP_INFO(pvr, "%s tv param freq %s is used directly\n",
LOG_LEVEL_V4L2, stream_tv_defaults.freq);
if (set_station_by_channelname_or_freq (pvr, NULL,
atoi (stream_tv_defaults.freq), 0)<0)
{
- mp_msg (MSGT_OPEN, MSGL_WARN,
- "%s tv param freq %s invalid to set station\n",
+ MP_WARN(pvr, "%s tv param freq %s invalid to set station\n",
LOG_LEVEL_V4L2, stream_tv_defaults.freq);
}
}
@@ -1189,8 +1164,7 @@ set_v4l2_settings (struct pvr_t *pvr)
ctrl.value = 1;
if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s can't mute (%s).\n", LOG_LEVEL_V4L2, strerror (errno));
+ MP_ERR(pvr, "%s can't mute (%s).\n", LOG_LEVEL_V4L2, strerror (errno));
return -1;
}
}
@@ -1200,8 +1174,7 @@ set_v4l2_settings (struct pvr_t *pvr)
{
if (ioctl (pvr->dev_fd, VIDIOC_S_INPUT, &pvr->input) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s can't set input (%s)\n", LOG_LEVEL_V4L2, strerror (errno));
+ MP_ERR(pvr, "%s can't set input (%s)\n", LOG_LEVEL_V4L2, strerror (errno));
return -1;
}
}
@@ -1214,18 +1187,15 @@ set_v4l2_settings (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_ENUMSTD, &std) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s can't set norm (%s)\n", LOG_LEVEL_V4L2, strerror (errno));
+ MP_ERR(pvr, "%s can't set norm (%s)\n", LOG_LEVEL_V4L2, strerror (errno));
return -1;
}
- mp_msg (MSGT_OPEN, MSGL_V,
- "%s set norm to %s\n", LOG_LEVEL_V4L2, std.name);
+ MP_VERBOSE(pvr, "%s set norm to %s\n", LOG_LEVEL_V4L2, std.name);
if (ioctl (pvr->dev_fd, VIDIOC_S_STD, &std.id) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s can't set norm (%s)\n", LOG_LEVEL_V4L2, strerror (errno));
+ MP_ERR(pvr, "%s can't set norm (%s)\n", LOG_LEVEL_V4L2, strerror (errno));
return -1;
}
}
@@ -1244,8 +1214,7 @@ set_v4l2_settings (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s can't set brightness to %d (%s).\n",
+ MP_ERR(pvr, "%s can't set brightness to %d (%s).\n",
LOG_LEVEL_V4L2, ctrl.value, strerror (errno));
return -1;
}
@@ -1265,8 +1234,7 @@ set_v4l2_settings (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s can't set contrast to %d (%s).\n",
+ MP_ERR(pvr, "%s can't set contrast to %d (%s).\n",
LOG_LEVEL_V4L2, ctrl.value, strerror (errno));
return -1;
}
@@ -1286,8 +1254,7 @@ set_v4l2_settings (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s can't set hue to %d (%s).\n",
+ MP_ERR(pvr, "%s can't set hue to %d (%s).\n",
LOG_LEVEL_V4L2, ctrl.value, strerror (errno));
return -1;
}
@@ -1307,8 +1274,7 @@ set_v4l2_settings (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s can't set saturation to %d (%s).\n",
+ MP_ERR(pvr, "%s can't set saturation to %d (%s).\n",
LOG_LEVEL_V4L2, ctrl.value, strerror (errno));
return -1;
}
@@ -1324,8 +1290,7 @@ set_v4l2_settings (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_S_FMT, &vfmt) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s can't set resolution to %dx%d (%s).\n",
+ MP_ERR(pvr, "%s can't set resolution to %dx%d (%s).\n",
LOG_LEVEL_V4L2, pvr->width, pvr->height, strerror (errno));
return -1;
}
@@ -1334,8 +1299,7 @@ set_v4l2_settings (struct pvr_t *pvr)
if (pvr->freq < 0)
{
int freq = get_v4l2_freq (pvr);
- mp_msg (MSGT_OPEN, MSGL_INFO,
- "%s Using current set frequency %d, to set channel\n",
+ MP_INFO(pvr, "%s Using current set frequency %d, to set channel\n",
LOG_LEVEL_V4L2, freq);
if (0 < freq)
@@ -1365,57 +1329,55 @@ v4l2_list_capabilities (struct pvr_t *pvr)
/* list available video inputs */
vin.index = 0;
err = 1;
- mp_msg (MSGT_OPEN, MSGL_INFO,
- "%s Available video inputs: ", LOG_LEVEL_V4L2);
+ MP_INFO(pvr, "%s Available video inputs: ", LOG_LEVEL_V4L2);
while (ioctl (pvr->dev_fd, VIDIOC_ENUMINPUT, &vin) >= 0)
{
err = 0;
- mp_msg (MSGT_OPEN, MSGL_INFO, "'#%d, %s' ", vin.index, vin.name);
+ MP_INFO(pvr, "'#%d, %s' ", vin.index, vin.name);
vin.index++;
}
if (err)
{
- mp_msg (MSGT_OPEN, MSGL_INFO, "none\n");
+ MP_INFO(pvr, "none\n");
return -1;
}
else
- mp_msg (MSGT_OPEN, MSGL_INFO, "\n");
+ MP_INFO(pvr, "\n");
/* list available audio inputs */
vaudio.index = 0;
err = 1;
- mp_msg (MSGT_OPEN, MSGL_INFO,
- "%s Available audio inputs: ", LOG_LEVEL_V4L2);
+ MP_INFO(pvr, "%s Available audio inputs: ", LOG_LEVEL_V4L2);
while (ioctl (pvr->dev_fd, VIDIOC_ENUMAUDIO, &vaudio) >= 0)
{
err = 0;
- mp_msg (MSGT_OPEN, MSGL_INFO, "'#%d, %s' ", vaudio.index, vaudio.name);
+ MP_INFO(pvr, "'#%d, %s' ", vaudio.index, vaudio.name);
vaudio.index++;
}
if (err)
{
- mp_msg (MSGT_OPEN, MSGL_INFO, "none\n");
+ MP_INFO(pvr, "none\n");
return -1;
}
else
- mp_msg (MSGT_OPEN, MSGL_INFO, "\n");
+ MP_INFO(pvr, "\n");
/* list available norms */
vs.index = 0;
- mp_msg (MSGT_OPEN, MSGL_INFO, "%s Available norms: ", LOG_LEVEL_V4L2);
+ MP_INFO(pvr, "%s Available norms: ", LOG_LEVEL_V4L2);
while (ioctl (pvr->dev_fd, VIDIOC_ENUMSTD, &vs) >= 0)
{
err = 0;
- mp_msg (MSGT_OPEN, MSGL_INFO, "'#%d, %s' ", vs.index, vs.name);
+ MP_INFO(pvr, "'#%d, %s' ", vs.index, vs.name);
vs.index++;
}
if (err)
{
- mp_msg (MSGT_OPEN, MSGL_INFO, "none\n");
+ MP_INFO(pvr, "none\n");
return -1;
}
else
- mp_msg (MSGT_OPEN, MSGL_INFO, "\n");
+ MP_INFO(pvr, "\n");
return 0;
}
@@ -1441,31 +1403,26 @@ v4l2_display_settings (struct pvr_t *pvr)
vin.index = input;
if (ioctl (pvr->dev_fd, VIDIOC_ENUMINPUT, &vin) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s can't get input (%s).\n", LOG_LEVEL_V4L2, strerror (errno));
+ MP_ERR(pvr, "%s can't get input (%s).\n", LOG_LEVEL_V4L2, strerror (errno));
return -1;
}
else
- mp_msg (MSGT_OPEN, MSGL_INFO,
- "%s Video input: %s\n", LOG_LEVEL_V4L2, vin.name);
+ MP_INFO(pvr, "%s Video input: %s\n", LOG_LEVEL_V4L2, vin.name);
}
else
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s can't get input (%s).\n", LOG_LEVEL_V4L2, strerror (errno));
+ MP_ERR(pvr, "%s can't get input (%s).\n", LOG_LEVEL_V4L2, strerror (errno));
return -1;
}
/* get current audio input */
if (ioctl (pvr->dev_fd, VIDIOC_G_AUDIO, &vaudio) == 0)
{
- mp_msg (MSGT_OPEN, MSGL_INFO,
- "%s Audio input: %s\n", LOG_LEVEL_V4L2, vaudio.name);
+ MP_INFO(pvr, "%s Audio input: %s\n", LOG_LEVEL_V4L2, vaudio.name);
}
else
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s can't get input (%s).\n", LOG_LEVEL_V4L2, strerror (errno));
+ MP_ERR(pvr, "%s can't get input (%s).\n", LOG_LEVEL_V4L2, strerror (errno));
return -1;
}
@@ -1478,8 +1435,7 @@ v4l2_display_settings (struct pvr_t *pvr)
{
if (vs.id == std)
{
- mp_msg (MSGT_OPEN, MSGL_INFO,
- "%s Norm: %s.\n", LOG_LEVEL_V4L2, vs.name);
+ MP_INFO(pvr, "%s Norm: %s.\n", LOG_LEVEL_V4L2, vs.name);
break;
}
vs.index++;
@@ -1487,8 +1443,7 @@ v4l2_display_settings (struct pvr_t *pvr)
}
else
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s can't get norm (%s)\n", LOG_LEVEL_V4L2, strerror (errno));
+ MP_ERR(pvr, "%s can't get norm (%s)\n", LOG_LEVEL_V4L2, strerror (errno));
return -1;
}
@@ -1535,8 +1490,7 @@ pvr_stream_read (stream_t *stream, char *buffer, int size)
if (poll (pfds, 1, 500) <= 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s failed with errno %d when reading %d bytes\n",
+ MP_ERR(pvr, "%s failed with errno %d when reading %d bytes\n",
LOG_LEVEL_PVR, errno, size-pos);
break;
}
@@ -1545,13 +1499,12 @@ pvr_stream_read (stream_t *stream, char *buffer, int size)
if (rk > 0)
{
pos += rk;
- mp_msg (MSGT_OPEN, MSGL_DBG3,
- "%s read (%d) bytes\n", LOG_LEVEL_PVR, pos);
+ MP_TRACE(pvr, "%s read (%d) bytes\n", LOG_LEVEL_PVR, pos);
}
}
if (!pos)
- mp_msg (MSGT_OPEN, MSGL_ERR, "%s read %d bytes\n", LOG_LEVEL_PVR, pos);
+ MP_ERR(pvr, "%s read %d bytes\n", LOG_LEVEL_PVR, pos);
return pos;
}
@@ -1582,12 +1535,10 @@ pvr_stream_open (stream_t *stream, int mode)
/* open device */
pvr->dev_fd = open (pvr->video_dev, O_RDWR | O_CLOEXEC);
- mp_msg (MSGT_OPEN, MSGL_INFO,
- "%s Using device %s\n", LOG_LEVEL_PVR, pvr->video_dev);
+ MP_INFO(pvr, "%s Using device %s\n", LOG_LEVEL_PVR, pvr->video_dev);
if (pvr->dev_fd == -1)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s error opening device %s\n", LOG_LEVEL_PVR, pvr->video_dev);
+ MP_ERR(pvr, "%s error opening device %s\n", LOG_LEVEL_PVR, pvr->video_dev);
pvr_uninit (pvr);
return STREAM_ERROR;
}
@@ -1595,21 +1546,18 @@ pvr_stream_open (stream_t *stream, int mode)
/* query capabilities (i.e test V4L2 support) */
if (ioctl (pvr->dev_fd, VIDIOC_QUERYCAP, &vcap) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s device is not V4L2 compliant (%s).\n",
+ MP_ERR(pvr, "%s device is not V4L2 compliant (%s).\n",
LOG_LEVEL_PVR, strerror (errno));
pvr_uninit (pvr);
return STREAM_ERROR;
}
else
- mp_msg (MSGT_OPEN, MSGL_INFO,
- "%s Detected %s\n", LOG_LEVEL_PVR, vcap.card);
+ MP_INFO(pvr, "%s Detected %s\n", LOG_LEVEL_PVR, vcap.card);
/* check for a valid V4L2 capture device */
if (!(vcap.capabilities & V4L2_CAP_VIDEO_CAPTURE))
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s device is not a valid V4L2 capture device.\n",
+ MP_ERR(pvr, "%s device is not a valid V4L2 capture device.\n",
LOG_LEVEL_PVR);
pvr_uninit (pvr);
return STREAM_ERROR;
@@ -1622,16 +1570,14 @@ pvr_stream_open (stream_t *stream, int mode)
if (ioctl (pvr->dev_fd, VIDIOC_G_EXT_CTRLS, &ctrls) < 0)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s device do not support MPEG input.\n", LOG_LEVEL_ENCODER);
+ MP_ERR(pvr, "%s device do not support MPEG input.\n", LOG_LEVEL_ENCODER);
return STREAM_ERROR;
}
/* list V4L2 capabilities */
if (v4l2_list_capabilities (pvr) == -1)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s can't get v4l2 capabilities\n", LOG_LEVEL_PVR);
+ MP_ERR(pvr, "%s can't get v4l2 capabilities\n", LOG_LEVEL_PVR);
pvr_uninit (pvr);
return STREAM_ERROR;
}
@@ -1639,8 +1585,7 @@ pvr_stream_open (stream_t *stream, int mode)
/* apply V4L2 settings */
if (set_v4l2_settings (pvr) == -1)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s can't set v4l2 settings\n", LOG_LEVEL_PVR);
+ MP_ERR(pvr, "%s can't set v4l2 settings\n", LOG_LEVEL_PVR);
pvr_uninit (pvr);
return STREAM_ERROR;
}
@@ -1648,8 +1593,7 @@ pvr_stream_open (stream_t *stream, int mode)
/* apply encoder settings */
if (set_encoder_settings (pvr) == -1)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s can't set encoder settings\n", LOG_LEVEL_PVR);
+ MP_ERR(pvr, "%s can't set encoder settings\n", LOG_LEVEL_PVR);
pvr_uninit (pvr);
return STREAM_ERROR;
}
@@ -1657,8 +1601,7 @@ pvr_stream_open (stream_t *stream, int mode)
/* display current V4L2 settings */
if (v4l2_display_settings (pvr) == -1)
{
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s can't get v4l2 settings\n", LOG_LEVEL_PVR);
+ MP_ERR(pvr, "%s can't get v4l2 settings\n", LOG_LEVEL_PVR);
pvr_uninit (pvr);
return STREAM_ERROR;
}
diff --git a/stream/stream_radio.c b/stream/stream_radio.c
index 3f60bb77c2..d6d7319ea9 100644
--- a/stream/stream_radio.c
+++ b/stream/stream_radio.c
@@ -87,6 +87,7 @@ radio_param_t stream_radio_defaults={
};
typedef struct radio_priv_s {
+ struct mp_log *log;
int radio_fd; ///< radio device descriptor
int frac; ///< fraction value (see comment to init_frac)
radio_channels_t* radio_channel_list;
@@ -154,7 +155,7 @@ static int parse_channels(radio_priv_t* priv,float freq_channel,float* pfreq){
/*parsing channels string*/
channels=priv->radio_param->channels;
- mp_msg(MSGT_RADIO, MSGL_INFO, "[radio] Radio channel names detected.\n");
+ MP_INFO(priv, "Radio channel names detected.\n");
priv->radio_channel_list = malloc(sizeof(radio_channels_t));
priv->radio_channel_list->index=1;
priv->radio_channel_list->next=NULL;
@@ -172,7 +173,7 @@ static int parse_channels(radio_priv_t* priv,float freq_channel,float* pfreq){
priv->radio_channel_current->freq=atof(tmp);
if ((priv->radio_channel_current->freq>priv->rangehigh)||(priv->radio_channel_current->freq<priv->rangelow))
- mp_msg(MSGT_RADIO, MSGL_ERR, "[radio] Wrong frequency for channel %s\n",
+ MP_ERR(priv, "Wrong frequency for channel %s\n",
priv->radio_channel_current->name);
while ((sep=strchr(priv->radio_channel_current->name, '_'))) sep[0] = ' ';
@@ -198,17 +199,17 @@ static int parse_channels(radio_priv_t* priv,float freq_channel,float* pfreq){
priv->radio_channel_current = priv->radio_channel_current->next;
if (priv->radio_channel_current->index!=channel){
if (((float)((int)freq_channel))!=freq_channel)
- mp_msg(MSGT_RADIO, MSGL_ERR, "[radio] Wrong channel number: %.2f\n",freq_channel);
+ MP_ERR(priv, "Wrong channel number: %.2f\n",freq_channel);
else
- mp_msg(MSGT_RADIO, MSGL_ERR, "[radio] Wrong channel number: %d\n",(int)freq_channel);
+ MP_ERR(priv, "Wrong channel number: %d\n",(int)freq_channel);
return STREAM_ERROR;
}
- mp_msg(MSGT_RADIO, MSGL_INFO, "[radio] Selected channel: %d - %s (freq: %.2f)\n", priv->radio_channel_current->index,
+ MP_INFO(priv, "Selected channel: %d - %s (freq: %.2f)\n", priv->radio_channel_current->index,
priv->radio_channel_current->name, priv->radio_channel_current->freq);
*pfreq=priv->radio_channel_current->freq;
}else{
if (freq_channel){
- mp_msg(MSGT_RADIO, MSGL_INFO, "[radio] Radio frequency parameter detected.\n");
+ MP_INFO(priv, "Radio frequency parameter detected.\n");
priv->radio_channel_list=malloc(sizeof(radio_channels_t));
priv->radio_channel_list->next=NULL;
priv->radio_channel_list->prev=NULL;
@@ -219,7 +220,7 @@ static int parse_channels(radio_priv_t* priv,float freq_channel,float* pfreq){
*pfreq=freq_channel;
}
}
- mp_msg(MSGT_RADIO, MSGL_DBG2, "[radio] Done parsing channels.\n");
+ MP_DBG(priv, "Done parsing channels.\n");
return STREAM_OK;
}
@@ -242,25 +243,25 @@ static int init_frac_v4l2(radio_priv_t* priv){
memset(&tuner,0,sizeof(tuner));
tuner.index=0;
if (ioctl(priv->radio_fd, VIDIOC_G_TUNER, &tuner)<0){
- mp_msg(MSGT_RADIO,MSGL_WARN,"[radio] Warning: ioctl get tuner failed: %s. Setting frac to %d.\n",strerror(errno),priv->frac);
+ MP_WARN(priv, "Warning: ioctl get tuner failed: %s. Setting frac to %d.\n",strerror(errno),priv->frac);
return STREAM_ERROR;
}
if(tuner.type!=V4L2_TUNER_RADIO){
- mp_msg(MSGT_RADIO,MSGL_ERR,"[radio] %s is no radio device!\n",priv->radio_param->device);
+ MP_ERR(priv, "%s is no radio device!\n",priv->radio_param->device);
return STREAM_ERROR;
}
if(tuner.capability & V4L2_TUNER_CAP_LOW){
priv->frac=16000;
- mp_msg(MSGT_RADIO,MSGL_DBG2,"[radio] tuner is low:yes frac=%d\n",priv->frac);
+ MP_DBG(priv, "tuner is low:yes frac=%d\n",priv->frac);
}
else{
priv->frac=16;
- mp_msg(MSGT_RADIO,MSGL_DBG2,"[radio] tuner is low:no frac=%d\n",priv->frac);
+ MP_DBG(priv, "tuner is low:no frac=%d\n",priv->frac);
}
priv->rangelow=((float)tuner.rangelow)/priv->frac;
priv->rangehigh=((float)tuner.rangehigh)/priv->frac;
- mp_msg(MSGT_RADIO,MSGL_V,"[radio] Allowed frequency range is %.2f-%.2f MHz.\n",priv->rangelow,priv->rangehigh);
+ MP_VERBOSE(priv, "Allowed frequency range is %.2f-%.2f MHz.\n",priv->rangelow,priv->rangehigh);
return STREAM_OK;
}
@@ -277,7 +278,7 @@ static int set_frequency_v4l2(radio_priv_t* priv,float frequency){
freq.type=V4L2_TUNER_RADIO;
freq.frequency=frequency*priv->frac;
if(ioctl(priv->radio_fd,VIDIOC_S_FREQUENCY,&freq)<0){
- mp_msg(MSGT_RADIO,MSGL_ERR,"[radio] ioctl set frequency 0x%x (%.2f) failed: %s\n",freq.frequency,
+ MP_ERR(priv, "ioctl set frequency 0x%x (%.2f) failed: %s\n",freq.frequency,
frequency,strerror(errno));
return STREAM_ERROR;
}
@@ -293,7 +294,7 @@ static int get_frequency_v4l2(radio_priv_t* priv,float* frequency){
struct v4l2_frequency freq;
memset(&freq,0,sizeof(freq));
if (ioctl(priv->radio_fd, VIDIOC_G_FREQUENCY, &freq) < 0) {
- mp_msg(MSGT_RADIO,MSGL_ERR,"[radio] ioctl get frequency failed: %s\n",strerror(errno));
+ MP_ERR(priv, "ioctl get frequency failed: %s\n",strerror(errno));
return STREAM_ERROR;
}
*frequency=((float)freq.frequency)/priv->frac;
@@ -317,13 +318,13 @@ static void set_volume_v4l2(radio_priv_t* priv,int volume){
control.id=V4L2_CID_AUDIO_MUTE;
control.value = (volume==0?1:0);
if (ioctl(priv->radio_fd, VIDIOC_S_CTRL, &control)<0){
- mp_msg(MSGT_RADIO,MSGL_WARN,"[radio] ioctl set mute failed: %s\n",strerror(errno));
+ MP_WARN(priv, "ioctl set mute failed: %s\n",strerror(errno));
}
memset(&qctrl,0,sizeof(qctrl));
qctrl.id = V4L2_CID_AUDIO_VOLUME;
if (ioctl(priv->radio_fd, VIDIOC_QUERYCTRL, &qctrl) < 0) {
- mp_msg(MSGT_RADIO, MSGL_WARN, "[radio] ioctl query control failed: %s\n",strerror(errno));
+ MP_WARN(priv, "ioctl query control failed: %s\n",strerror(errno));
return;
}
@@ -331,7 +332,7 @@ static void set_volume_v4l2(radio_priv_t* priv,int volume){
control.id=V4L2_CID_AUDIO_VOLUME;
control.value=qctrl.minimum+volume*(qctrl.maximum-qctrl.minimum)/100;
if (ioctl(priv->radio_fd, VIDIOC_S_CTRL, &control) < 0) {
- mp_msg(MSGT_RADIO, MSGL_WARN,"[radio] ioctl set volume failed: %s\n",strerror(errno));
+ MP_WARN(priv, "ioctl set volume failed: %s\n",strerror(errno));
}
}
@@ -347,14 +348,14 @@ static int get_volume_v4l2(radio_priv_t* priv,int* volume){
memset(&qctrl,0,sizeof(qctrl));
qctrl.id = V4L2_CID_AUDIO_VOLUME;
if (ioctl(priv->radio_fd, VIDIOC_QUERYCTRL, &qctrl) < 0) {
- mp_msg(MSGT_RADIO, MSGL_ERR, "[radio] ioctl query control failed: %s\n",strerror(errno));
+ MP_ERR(priv, "ioctl query control failed: %s\n",strerror(errno));
return STREAM_ERROR;
}
memset(&control,0,sizeof(control));
control.id=V4L2_CID_AUDIO_VOLUME;
if (ioctl(priv->radio_fd, VIDIOC_G_CTRL, &control) < 0) {
- mp_msg(MSGT_RADIO, MSGL_ERR,"[radio] ioctl get volume failed: %s\n",strerror(errno));
+ MP_ERR(priv, "ioctl get volume failed: %s\n",strerror(errno));
return STREAM_ERROR;
}
@@ -373,7 +374,7 @@ static int get_volume_v4l2(radio_priv_t* priv,int* volume){
/* v4l2 driver info structure */
static const radio_driver_t radio_driver_v4l2={
"v4l2",
- _("[radio] Using V4Lv2 radio interface.\n"),
+ _("Using V4Lv2 radio interface.\n"),
init_frac_v4l2,
set_volume_v4l2,
get_volume_v4l2,
@@ -387,7 +388,7 @@ static inline int init_frac(radio_priv_t* priv){
}
static inline int set_frequency(radio_priv_t* priv,float frequency){
if ((frequency<priv->rangelow)||(frequency>priv->rangehigh)){
- mp_msg(MSGT_RADIO,MSGL_ERR,"[radio] Wrong frequency: %.2f\n",frequency);
+ MP_ERR(priv, "Wrong frequency: %.2f\n",frequency);
return STREAM_ERROR;
}
if(priv->driver->set_frequency(priv,frequency)!=STREAM_OK)
@@ -395,7 +396,7 @@ static inline int set_frequency(radio_priv_t* priv,float frequency){
#if HAVE_RADIO_CAPTURE
if(clear_buffer(priv)!=STREAM_OK){
- mp_msg(MSGT_RADIO,MSGL_ERR,"[radio] Clearing buffer failed: %s\n",strerror(errno));
+ MP_ERR(priv, "Clearing buffer failed: %s\n",strerror(errno));
return STREAM_ERROR;
}
#endif
@@ -450,16 +451,16 @@ static int read_chunk(audio_in_t *ai, unsigned char *buffer)
if (ret != ai->alsa.chunk_size) {
if (ret < 0) {
if (ret==-EAGAIN) return -1;
- mp_msg(MSGT_RADIO, 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_RADIO, 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_RADIO, MSGL_ERR, "Fatal error, cannot recover!\n");
+ MP_ERR(ai, "Fatal error, cannot recover!\n");
}
}
} else {
- mp_msg(MSGT_RADIO, MSGL_ERR, "\nNot enough audio samples!\n");
+ MP_ERR(ai, "\nNot enough audio samples!\n");
}
return -1;
}
@@ -481,7 +482,7 @@ static int read_chunk(audio_in_t *ai, unsigned char *buffer)
if (ret<0){
if (errno==EAGAIN && bt==0) return -1; //no data avail yet
if (errno==EAGAIN) { usleep(1000); continue;} //nilling buffer to blocksize size
- mp_msg(MSGT_RADIO, MSGL_ERR, "\nError reading audio: %s\n", strerror(errno));
+ MP_ERR(ai, "\nError reading audio: %s\n", strerror(errno));
return -1;
}
bt+=ret;
@@ -513,7 +514,7 @@ static int read_chunk(audio_in_t *ai, unsigned char *buffer)
static int grab_audio_frame(radio_priv_t *priv, char *buffer, int len)
{
int i;
- mp_msg(MSGT_RADIO, MSGL_DBG3, "[radio] %s: in buffer=%d dropped=%d\n","grab_audio_frame",priv->audio_cnt,priv->audio_drop);
+ MP_TRACE(priv, "%s: in buffer=%d dropped=%d\n","grab_audio_frame",priv->audio_cnt,priv->audio_drop);
/* Cache buffer must be filled by some audio packets when playing starts.
Otherwise MPlayer will quit with EOF error.
Probably, there is need more carefull checking rather than simple 'for' loop
@@ -563,7 +564,7 @@ static int init_audio(radio_priv_t *priv)
}
priv->do_capture=1;
- mp_msg(MSGT_RADIO,MSGL_V,"[radio] Starting capture stuff.\n");
+ MP_VERBOSE(priv, "Starting capture stuff.\n");
#if HAVE_ALSA
while ((tmp = strrchr(priv->radio_param->adevice, '='))){
tmp[0] = ':';
@@ -574,8 +575,8 @@ static int init_audio(radio_priv_t *priv)
tmp[0] = ',';
#endif
- 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");
+ if(audio_in_init(&priv->audio_in, priv->log, is_oss?AUDIO_IN_OSS:AUDIO_IN_ALSA)<0){
+ MP_ERR(priv, "audio_in_init failed.\n");
}
audio_in_set_device(&priv->audio_in, priv->radio_param->adevice);
@@ -583,7 +584,7 @@ static int init_audio(radio_priv_t *priv)
audio_in_set_samplerate(&priv->audio_in, priv->radio_param->arate);
if (audio_in_setup(&priv->audio_in) < 0) {
- mp_msg(MSGT_RADIO, MSGL_ERR, "[radio] audio_in_setup call failed: %s\n", strerror(errno));
+ MP_ERR(priv, "audio_in_setup call failed: %s\n", strerror(errno));
return STREAM_ERROR;
}
#if HAVE_OSS_AUDIO
@@ -599,12 +600,12 @@ static int init_audio(radio_priv_t *priv)
priv->audio_in.bytes_per_sample+priv->audio_in.blocksize;
if (priv->audio_buffer_size < 256*priv->audio_in.blocksize)
priv->audio_buffer_size = 256*priv->audio_in.blocksize;
- mp_msg(MSGT_RADIO, MSGL_V, "[radio] Audio capture - buffer=%d bytes (block=%d bytes).\n",
+ MP_VERBOSE(priv, "Audio capture - buffer=%d bytes (block=%d bytes).\n",
priv->audio_buffer_size,priv->audio_in.blocksize);
/* start capture */
priv->audio_ringbuffer = calloc(1, priv->audio_buffer_size);
if (!priv->audio_ringbuffer) {
- mp_msg(MSGT_RADIO, MSGL_ERR, "[radio] cannot allocate audio buffer (block=%d,buf=%d): %s\n",priv->audio_in.blocksize, priv->audio_buffer_size, strerror(errno));
+ MP_ERR(priv, "cannot allocate audio buffer (block=%d,buf=%d): %s\n",priv->audio_in.blocksize, priv->audio_buffer_size, strerror(errno));
return STREAM_ERROR;
}
priv->audio_head = 0;
@@ -652,7 +653,7 @@ int radio_set_freq(struct stream *stream, float frequency){
if (get_frequency(priv,&frequency)!=STREAM_OK){
return 0;
}
- mp_msg(MSGT_RADIO, MSGL_INFO, "[radio] Current frequency: %.2f\n",frequency);
+ MP_INFO(priv, "Current frequency: %.2f\n",frequency);
return 1;
}
@@ -697,7 +698,7 @@ int radio_step_channel(struct stream *stream, int direction) {
priv->radio_channel_current = priv->radio_channel_list;
if(!radio_set_freq(stream,priv->radio_channel_current->freq))
return 0;
- mp_msg(MSGT_RADIO, MSGL_V, "[radio] Selected channel: %d - %s (freq: %.2f)\n",
+ MP_VERBOSE(priv, "Selected channel: %d - %s (freq: %.2f)\n",
priv->radio_channel_current->index, priv->radio_channel_current->name,
priv->radio_channel_current->freq);
break;
@@ -709,13 +710,13 @@ int radio_step_channel(struct stream *stream, int direction) {
priv->radio_channel_current = priv->radio_channel_current->next;
if(!radio_set_freq(stream,priv->radio_channel_current->freq))
return 0;
- mp_msg(MSGT_RADIO, MSGL_V, "[radio] Selected channel: %d - %s (freq: %.2f)\n",
+ MP_VERBOSE(priv, "Selected channel: %d - %s (freq: %.2f)\n",
priv->radio_channel_current->index, priv->radio_channel_current->name,
priv->radio_channel_current->freq);
break;
}
}else
- mp_msg(MSGT_RADIO, MSGL_ERR, "[radio] Can not change channel: no channel list given.\n");
+ MP_ERR(priv, "Can not change channel: no channel list given.\n");
return 1;
}
@@ -734,7 +735,7 @@ int radio_set_channel(struct stream *stream, char *channel) {
char* endptr;
if (*channel=='\0')
- mp_msg(MSGT_RADIO,MSGL_ERR,"[radio] Wrong channel name: %s\n",channel);
+ MP_ERR(priv, "Wrong channel name: %s\n",channel);
if (priv->radio_channel_list) {
channel_int = strtol(channel,&endptr,10);
@@ -745,7 +746,7 @@ int radio_set_channel(struct stream *stream, char *channel) {
if (!strncmp(channel,tmp->name,sizeof(tmp->name)-1))
break;
if (!tmp){
- mp_msg(MSGT_RADIO,MSGL_ERR,"[radio] Wrong channel name: %s\n",channel);
+ MP_ERR(priv, "Wrong channel name: %s\n",channel);
return 0;
}
}else{
@@ -755,17 +756,17 @@ int radio_set_channel(struct stream *stream, char *channel) {
else
break;
if (tmp->index!=channel_int){
- mp_msg(MSGT_RADIO,MSGL_ERR,"[radio] Wrong channel number: %d\n",channel_int);
+ MP_ERR(priv, "Wrong channel number: %d\n",channel_int);
return 0;
}
}
priv->radio_channel_current=tmp;
- mp_msg(MSGT_RADIO, MSGL_V, "[radio] Selected channel: %d - %s (freq: %.2f)\n", priv->radio_channel_current->index,
+ MP_VERBOSE(priv, "Selected channel: %d - %s (freq: %.2f)\n", priv->radio_channel_current->index,
priv->radio_channel_current->name, priv->radio_channel_current->freq);
if(!radio_set_freq(stream, priv->radio_channel_current->freq))
return 0;
} else
- mp_msg(MSGT_RADIO, MSGL_ERR, "[radio] Can not change channel: no channel list given.\n");
+ MP_ERR(priv, "Can not change channel: no channel list given.\n");
return 1;
}
@@ -836,6 +837,7 @@ static int open_s(stream_t *stream,int mode)
return STREAM_ERROR;
+ priv->log = stream->log;
priv->radio_param=stream->priv;
stream->priv=NULL;
@@ -853,18 +855,18 @@ static int open_s(stream_t *stream,int mode)
else
priv->driver=NULL;
- mp_msg(MSGT_RADIO,MSGL_V,"[radio] Available drivers: ");
+ MP_VERBOSE(priv, "Available drivers: ");
for(i=0;radio_drivers[i];i++){
- mp_msg(MSGT_RADIO,MSGL_V,"%s, ",radio_drivers[i]->name);
+ MP_VERBOSE(priv, "%s, ",radio_drivers[i]->name);
if(strcmp(priv->radio_param->driver,radio_drivers[i]->name)==0)
priv->driver=radio_drivers[i];
}
- mp_msg(MSGT_RADIO,MSGL_V,"\n");
+ MP_VERBOSE(priv, "\n");
if(priv->driver)
- mp_msg(MSGT_RADIO, MSGL_INFO, priv->driver->info);
+ MP_INFO(priv, priv->driver->info);
else{
- mp_msg(MSGT_RADIO, MSGL_INFO, "[radio] Unknown driver name: %s\n",priv->radio_param->driver);
+ MP_INFO(priv, "Unknown driver name: %s\n",priv->radio_param->driver);
close_s(stream);
return STREAM_ERROR;
}
@@ -884,12 +886,12 @@ static int open_s(stream_t *stream,int mode)
priv->radio_fd = open(priv->radio_param->device, O_RDONLY | O_CLOEXEC);
if (priv->radio_fd < 0) {
- mp_msg(MSGT_RADIO, MSGL_ERR, "[radio] Unable to open '%s': %s\n",
+ MP_ERR(priv, "Unable to open '%s': %s\n",
priv->radio_param->device, strerror(errno));
close_s(stream);
return STREAM_ERROR;
}
- mp_msg(MSGT_RADIO, MSGL_V, "[radio] Radio fd: %d, %s\n", priv->radio_fd,priv->radio_param->device);
+ MP_VERBOSE(priv, "Radio fd: %d, %s\n", priv->radio_fd,priv->radio_param->device);
fcntl(priv->radio_fd, F_SETFD, FD_CLOEXEC);
get_volume(priv, &priv->old_snd_volume);
@@ -906,11 +908,11 @@ static int open_s(stream_t *stream,int mode)
}
if ((frequency<priv->rangelow)||(frequency>priv->rangehigh)){
- mp_msg(MSGT_RADIO, MSGL_ERR, "[radio] Wrong frequency: %.2f\n",frequency);
+ MP_ERR(priv, "Wrong frequency: %.2f\n",frequency);
close_s(stream);
return STREAM_ERROR;
}else
- mp_msg(MSGT_RADIO, MSGL_INFO, "[radio] Using frequency: %.2f.\n",frequency);
+ MP_INFO(priv, "Using frequency: %.2f.\n",frequency);
if(set_frequency(priv,frequency)!=STREAM_OK){
close_s(stream);
diff --git a/stream/stream_rar.c b/stream/stream_rar.c
index 5b6880fbe1..cae5e02020 100644
--- a/stream/stream_rar.c
+++ b/stream/stream_rar.c
@@ -97,7 +97,7 @@ static int rar_entry_open(stream_t *stream, int mode)
mp_url_unescape_inplace(base);
struct stream *rar =
- stream_create(base, STREAM_READ | STREAM_NO_FILTERS, stream->opts);
+ stream_create(base, STREAM_READ | STREAM_NO_FILTERS, stream->global);
if (!rar)
return STREAM_ERROR;
@@ -126,7 +126,7 @@ static int rar_entry_open(stream_t *stream, int mode)
};
file->current_chunk = &dummy;
file->s = rar; // transfer ownership
- file->opts = stream->opts;
+ file->global = stream->global;
RarSeek(file, 0);
stream->priv = file;
diff --git a/stream/stream_smb.c b/stream/stream_smb.c
index 804c5e9df4..72108aca67 100644
--- a/stream/stream_smb.c
+++ b/stream/stream_smb.c
@@ -124,24 +124,24 @@ static int open_f (stream_t *stream, int mode)
else if (mode == STREAM_WRITE) //who's gonna do that ?
m = O_RDWR|O_CREAT|O_TRUNC;
else {
- mp_msg(MSGT_OPEN, MSGL_ERR, "[smb] Unknown open mode %d\n", mode);
+ MP_ERR(stream, "[smb] Unknown open mode %d\n", mode);
return STREAM_UNSUPPORTED;
}
if(!filename) {
- mp_msg(MSGT_OPEN,MSGL_ERR, "[smb] Bad url\n");
+ MP_ERR(stream, "[smb] Bad url\n");
return STREAM_ERROR;
}
err = smbc_init(smb_auth_fn, 1);
if (err < 0) {
- mp_msg(MSGT_OPEN,MSGL_ERR,"Cannot init the libsmbclient library: %d\n",err);
+ MP_ERR(stream, "Cannot init the libsmbclient library: %d\n",err);
return STREAM_ERROR;
}
fd = smbc_open(filename, m,0644);
if (fd < 0) {
- mp_msg(MSGT_OPEN,MSGL_ERR,"Could not open from LAN: '%s'\n", filename);
+ MP_ERR(stream, "Could not open from LAN: '%s'\n", filename);
return STREAM_ERROR;
}
diff --git a/stream/stream_vcd.c b/stream/stream_vcd.c
index 2460bc65b6..3a9d644cc6 100644
--- a/stream/stream_vcd.c
+++ b/stream/stream_vcd.c
@@ -117,26 +117,26 @@ static int open_s(stream_t *stream,int mode)
f=open(dev,O_RDONLY | O_CLOEXEC);
#endif
if(f<0){
- mp_msg(MSGT_OPEN,MSGL_ERR,"CD-ROM Device '%s' not found.\n",dev);
+ MP_ERR(stream, "CD-ROM Device '%s' not found.\n",dev);
return STREAM_ERROR;
}
- vcd = vcd_read_toc(f);
+ vcd = vcd_read_toc(stream, f);
if(!vcd) {
- mp_msg(MSGT_OPEN,MSGL_ERR,"Failed to get cd toc\n");
+ MP_ERR(stream, "Failed to get cd toc\n");
close(f);
return STREAM_ERROR;
}
ret2=vcd_get_track_end(vcd,1);
if(ret2<0){
- mp_msg(MSGT_OPEN, MSGL_ERR, "%s (get)\n", "Error selecting VCD track.");
+ MP_ERR(stream, "%s (get)\n", "Error selecting VCD track.");
close(f);
free(vcd);
return STREAM_ERROR;
}
ret=vcd_seek_to_track(vcd,1);
if(ret<0){
- mp_msg(MSGT_OPEN, MSGL_ERR, "%s (seek)\n", "Error selecting VCD track.");
+ MP_ERR(stream, "%s (seek)\n", "Error selecting VCD track.");
close(f);
free(vcd);
return STREAM_ERROR;
@@ -149,15 +149,15 @@ static int open_s(stream_t *stream,int mode)
if (vcd_read(vcd, mem) != VCD_SECTOR_DATA || mem[2] || mem[3])
break;
}
- mp_msg(MSGT_OPEN, MSGL_DBG2, "%d leading sectors skipped\n", tmp - sect);
+ MP_DBG(stream, "%d leading sectors skipped\n", tmp - sect);
vcd_set_msf(vcd, tmp);
ret = tmp * VCD_SECTOR_DATA;
- mp_msg(MSGT_OPEN,MSGL_V,"VCD start byte position: 0x%X end: 0x%X\n",ret,ret2);
+ MP_VERBOSE(stream, "VCD start byte position: 0x%X end: 0x%X\n",ret,ret2);
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
if (ioctl (f, CDRIOCSETBLOCKSIZE, &bsize) == -1) {
- mp_msg(MSGT_OPEN,MSGL_WARN,"Error in CDRIOCSETBLOCKSIZE");
+ MP_WARN(stream, "Error in CDRIOCSETBLOCKSIZE");
}
#endif
diff --git a/stream/vcd_read.h b/stream/vcd_read.h
index 85a58fcf61..c6a49603a4 100644
--- a/stream/vcd_read.h
+++ b/stream/vcd_read.h
@@ -42,6 +42,7 @@ static int sun_vcd_read(mp_vcd_priv_t*, int*);
#endif
struct mp_vcd_priv_st {
+ stream_t *stream;
int fd;
struct cdrom_tocentry entry;
char buf[VCD_SECTOR_SIZE];
@@ -68,7 +69,7 @@ static int vcd_seek_to_track(mp_vcd_priv_t* vcd, int track)
vcd->entry.cdte_format = CDROM_MSF;
vcd->entry.cdte_track = track;
if (ioctl(vcd->fd, CDROMREADTOCENTRY, &vcd->entry)) {
- mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif1: %s\n",strerror(errno));
+ MP_ERR(vcd->stream, "ioctl dif1: %s\n",strerror(errno));
return -1;
}
return VCD_SECTOR_DATA*vcd_get_msf(vcd);
@@ -78,22 +79,20 @@ static int vcd_get_track_end(mp_vcd_priv_t* vcd,int track){
vcd->entry.cdte_format = CDROM_MSF;
vcd->entry.cdte_track = track<vcd->tochdr.cdth_trk1?(track+1):CDROM_LEADOUT;
if (ioctl(vcd->fd, CDROMREADTOCENTRY, &vcd->entry)) {
- mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif2: %s\n",strerror(errno));
+ MP_ERR(vcd->stream, "ioctl dif2: %s\n",strerror(errno));
return -1;
}
return VCD_SECTOR_DATA*vcd_get_msf(vcd);
}
-static mp_vcd_priv_t* vcd_read_toc(int fd){
+static mp_vcd_priv_t* vcd_read_toc(stream_t *stream, int fd){
struct cdrom_tochdr tochdr;
mp_vcd_priv_t* vcd;
- int i, min = 0, sec = 0, frame = 0;
+ int i;
if (ioctl(fd,CDROMREADTOCHDR,&tochdr)==-1) {
- mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno));
+ MP_ERR(stream, "read CDROM toc header: %s\n",strerror(errno));
return NULL;
}
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_START_TRACK=%d\n", tochdr.cdth_trk0);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_END_TRACK=%d\n", tochdr.cdth_trk1);
for (i=tochdr.cdth_trk0 ; i<=tochdr.cdth_trk1 + 1; i++){
struct cdrom_tocentry tocentry;
@@ -101,12 +100,12 @@ static mp_vcd_priv_t* vcd_read_toc(int fd){
tocentry.cdte_format = CDROM_MSF;
if (ioctl(fd,CDROMREADTOCENTRY,&tocentry)==-1) {
- mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc entry: %s\n",strerror(errno));
+ MP_ERR(stream, "read CDROM toc entry: %s\n",strerror(errno));
return NULL;
}
if (i<=tochdr.cdth_trk1)
- mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d mode: %d\n",
+ MP_INFO(stream, "track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d mode: %d\n",
(int)tocentry.cdte_track,
(int)tocentry.cdte_adr,
(int)tocentry.cdte_ctrl,
@@ -117,31 +116,9 @@ static mp_vcd_priv_t* vcd_read_toc(int fd){
(int)tocentry.cdte_datamode
);
- if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO))
- {
- if (i > tochdr.cdth_trk0)
- {
- min = tocentry.cdte_addr.msf.minute - min;
- sec = tocentry.cdte_addr.msf.second - sec;
- frame = tocentry.cdte_addr.msf.frame - frame;
- if ( frame < 0 )
- {
- frame += 75;
- sec --;
- }
- if ( sec < 0 )
- {
- sec += 60;
- min --;
- }
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_TRACK_%d_MSF=%02d:%02d:%02d\n", i - 1, min, sec, frame);
- }
- min = tocentry.cdte_addr.msf.minute;
- sec = tocentry.cdte_addr.msf.second;
- frame = tocentry.cdte_addr.msf.frame;
- }
}
vcd = malloc(sizeof(mp_vcd_priv_t));
+ vcd->stream = stream;
vcd->fd = fd;
vcd->tochdr = tochdr;
return vcd;
@@ -193,7 +170,7 @@ static int sun_vcd_read(mp_vcd_priv_t* vcd, int *offset)
cdxa.cdxa_format = CDROM_XA_SECTOR_DATA;
if(ioctl(vcd->fd,CDROMCDXA,&cdxa)==-1) {
- mp_msg(MSGT_STREAM,MSGL_ERR,"CDROMCDXA: %s\n",strerror(errno));
+ MP_ERR(vcd->stream, "CDROMCDXA: %s\n",strerror(errno));
return 0;
}
*offset = 0;
@@ -204,7 +181,7 @@ static int sun_vcd_read(mp_vcd_priv_t* vcd, int *offset)
cdread.cdread_buflen = 2336;
if(ioctl(vcd->fd,CDROMREADMODE2,&cdread)==-1) {
- mp_msg(MSGT_STREAM,MSGL_ERR,"CDROMREADMODE2: %s\n",strerror(errno));
+ MP_ERR(vcd->stream, "CDROMREADMODE2: %s\n",strerror(errno));
return 0;
}
*offset = 8;
@@ -230,11 +207,11 @@ static int sun_vcd_read(mp_vcd_priv_t* vcd, int *offset)
sc.uscsi_flags = USCSI_ISOLATE | USCSI_READ;
sc.uscsi_timeout = 20;
if (ioctl(vcd->fd, USCSICMD, &sc)) {
- mp_msg(MSGT_STREAM,MSGL_ERR,"USCSICMD: READ CD: %s\n",strerror(errno));
+ MP_ERR(vcd->stream, "USCSICMD: READ CD: %s\n",strerror(errno));
return -1;
}
if (sc.uscsi_status) {
- mp_msg(MSGT_STREAM,MSGL_ERR,"scsi command failed with status %d\n", sc.uscsi_status);
+ MP_ERR(vcd->stream, "scsi command failed with status %d\n", sc.uscsi_status);
return -1;
}
*offset = 0;
diff --git a/stream/vcd_read_darwin.h b/stream/vcd_read_darwin.h
index a81d9c481d..10430a41ae 100644
--- a/stream/vcd_read_darwin.h
+++ b/stream/vcd_read_darwin.h
@@ -50,6 +50,7 @@ typedef struct
typedef struct mp_vcd_priv_st
{
+ stream_t *stream;
int fd;
cdsector_t buf;
dk_cd_read_track_info_t entry;
@@ -79,7 +80,7 @@ static int vcd_seek_to_track(mp_vcd_priv_t* vcd, int track)
if (ioctl(vcd->fd, DKIOCCDREADTRACKINFO, &vcd->entry))
{
- mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif1: %s\n",strerror(errno));
+ MP_ERR(vcd->stream, "ioctl dif1: %s\n",strerror(errno));
return -1;
}
vcd->msf = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress));
@@ -91,8 +92,7 @@ static int vcd_get_track_end(mp_vcd_priv_t* vcd, int track)
struct CDTrackInfo entry;
if (track > vcd->hdr.lastTrackNumberInLastSessionLSB) {
- mp_msg(MSGT_OPEN, MSGL_ERR,
- "track number %d greater than last track number %d\n",
+ MP_ERR(vcd->stream, "track number %d greater than last track number %d\n",
track, vcd->hdr.lastTrackNumberInLastSessionLSB);
return -1;
}
@@ -106,7 +106,7 @@ static int vcd_get_track_end(mp_vcd_priv_t* vcd, int track)
if (ioctl(vcd->fd, DKIOCCDREADTRACKINFO, &vcd->entry))
{
- mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif2: %s\n",strerror(errno));
+ MP_ERR(vcd->stream, "ioctl dif2: %s\n",strerror(errno));
return -1;
}
if (track == vcd->hdr.lastTrackNumberInLastSessionLSB)
@@ -117,7 +117,7 @@ static int vcd_get_track_end(mp_vcd_priv_t* vcd, int track)
return VCD_SECTOR_DATA*vcd_get_msf(vcd);
}
-static mp_vcd_priv_t* vcd_read_toc(int fd)
+static mp_vcd_priv_t* vcd_read_toc(stream_t *stream, int fd)
{
dk_cd_read_disc_info_t tochdr;
struct CDDiscInfo hdr;
@@ -127,7 +127,7 @@ static mp_vcd_priv_t* vcd_read_toc(int fd)
CDMSF trackMSF;
mp_vcd_priv_t* vcd;
- int i, min = 0, sec = 0, frame = 0;
+ int i;
//read toc header
memset(&tochdr, 0, sizeof(tochdr));
@@ -136,13 +136,11 @@ static mp_vcd_priv_t* vcd_read_toc(int fd)
if (ioctl(fd, DKIOCCDREADDISCINFO, &tochdr) < 0)
{
- mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno));
+ MP_ERR(stream, "read CDROM toc header: %s\n",strerror(errno));
return NULL;
}
//print all track info
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_START_TRACK=%d\n", hdr.firstTrackNumberInLastSessionLSB);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_END_TRACK=%d\n", hdr.lastTrackNumberInLastSessionLSB);
for (i=hdr.firstTrackNumberInLastSessionLSB ; i<=hdr.lastTrackNumberInLastSessionLSB + 1; i++)
{
if (i <= hdr.lastTrackNumberInLastSessionLSB) {
@@ -154,7 +152,7 @@ static mp_vcd_priv_t* vcd_read_toc(int fd)
if (ioctl(fd,DKIOCCDREADTRACKINFO,&tocentry)==-1)
{
- mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc entry: %s\n",strerror(errno));
+ MP_ERR(stream, "read CDROM toc entry: %s\n",strerror(errno));
return NULL;
}
@@ -164,9 +162,9 @@ static mp_vcd_priv_t* vcd_read_toc(int fd)
trackMSF = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress)
+ be2me_32(entry.trackSize));
- //mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n",
+ //MP_INFO(vcd->stream, "track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n",
if (i<=hdr.lastTrackNumberInLastSessionLSB)
- mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: format=%d %02d:%02d:%02d\n",
+ MP_INFO(stream, "track %02d: format=%d %02d:%02d:%02d\n",
(int)tocentry.address,
//(int)tocentry.entry.addr_type,
//(int)tocentry.entry.control,
@@ -176,32 +174,10 @@ static mp_vcd_priv_t* vcd_read_toc(int fd)
(int)trackMSF.frame
);
- if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO))
- {
- if (i > hdr.firstTrackNumberInLastSessionLSB)
- {
- min = trackMSF.minute - min;
- sec = trackMSF.second - sec;
- frame = trackMSF.frame - frame;
- if ( frame < 0 )
- {
- frame += 75;
- sec --;
- }
- if ( sec < 0 )
- {
- sec += 60;
- min --;
- }
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_TRACK_%d_MSF=%02d:%02d:%02d\n", i - 1, min, sec, frame);
- }
- min = trackMSF.minute;
- sec = trackMSF.second;
- frame = trackMSF.frame;
- }
}
vcd = malloc(sizeof(mp_vcd_priv_t));
+ vcd->stream = stream;
vcd->fd = fd;
vcd->hdr = hdr;
vcd->msf = trackMSF;
diff --git a/stream/vcd_read_fbsd.h b/stream/vcd_read_fbsd.h
index 0765163b35..fe3bb8c5ae 100644
--- a/stream/vcd_read_fbsd.h
+++ b/stream/vcd_read_fbsd.h
@@ -132,7 +132,6 @@ read_toc_entry(mp_vcd_priv_t *vcd, int nr)
vcd->entry.track = nr;
#endif
if (ioctl(vcd->fd, READ_TOC, &vcd->entry) == -1) {
- mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc entry: %s\n",strerror(errno));
return 0;
}
return 1;
@@ -155,18 +154,15 @@ vcd_get_track_end(mp_vcd_priv_t* vcd, int track)
return VCD_SECTOR_DATA * vcd_get_msf(vcd);
}
-static mp_vcd_priv_t*
-vcd_read_toc(int fd)
+static mp_vcd_priv_t* vcd_read_toc(stream_t *stream, int fd)
{
struct ioc_toc_header tochdr;
mp_vcd_priv_t* vcd;
int i, last_startsect;
if (ioctl(fd, CDIOREADTOCHEADER, &tochdr) == -1) {
- mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno));
+ MP_ERR(stream, "read CDROM toc header: %s\n",strerror(errno));
return NULL;
}
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_START_TRACK=%d\n", tochdr.starting_track);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_END_TRACK=%d\n", tochdr.ending_track);
vcd = malloc(sizeof(mp_vcd_priv_t));
vcd->fd = fd;
vcd->tochdr = tochdr;
@@ -178,7 +174,7 @@ vcd_read_toc(int fd)
}
if (i <= tochdr.ending_track)
- mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n",
+ MP_INFO(stream, "track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n",
#ifdef VCD_NETBSD
(int)vcd->entry.starting_track,
(int)vcd->entry.data->addr_type,
@@ -194,22 +190,6 @@ vcd_read_toc(int fd)
(int)TOCADDR(vcd->entry).msf.frame
);
- if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO))
- {
- int startsect = vcd_get_msf(vcd);
- if (i > tochdr.starting_track)
- {
- // convert duraion to MSF
- vcd_set_msf(vcd, startsect - last_startsect);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO,
- "ID_VCD_TRACK_%d_MSF=%02d:%02d:%02d\n",
- i - 1,
- TOCADDR(vcd->entry).msf.minute,
- TOCADDR(vcd->entry).msf.second,
- TOCADDR(vcd->entry).msf.frame);
- }
- last_startsect = startsect;
- }
}
return vcd;
}
@@ -240,12 +220,9 @@ vcd_read(mp_vcd_priv_t* vcd, char *mem)
sc.timeout = 10000;
rc = ioctl(vcd->fd, SCIOCCOMMAND, &sc);
if (rc == -1) {
- mp_msg(MSGT_STREAM,MSGL_ERR,"SCIOCCOMMAND: %s\n",strerror(errno));
return -1;
}
if (sc.retsts || sc.error) {
- mp_msg(MSGT_STREAM,MSGL_ERR,"scsi command failed: status %d error %d\n",
- sc.retsts,sc.error);
return -1;
}
#else
diff --git a/stream/vcd_read_win32.h b/stream/vcd_read_win32.h
index d5d4032050..7c5117db16 100644
--- a/stream/vcd_read_win32.h
+++ b/stream/vcd_read_win32.h
@@ -70,11 +70,11 @@ static int vcd_get_track_end(mp_vcd_priv_t* vcd, int track)
return VCD_SECTOR_DATA * (vcd_get_msf(vcd, track + 1));
}
-static mp_vcd_priv_t* vcd_read_toc(int fd)
+static mp_vcd_priv_t* vcd_read_toc(stream_t *stream, int fd)
{
DWORD dwBytesReturned;
HANDLE hd;
- int i, min = 0, sec = 0, frame = 0;
+ int i;
mp_vcd_priv_t* vcd = malloc(sizeof(mp_vcd_priv_t));
if (!vcd)
return NULL;
@@ -82,21 +82,16 @@ static mp_vcd_priv_t* vcd_read_toc(int fd)
hd = (HANDLE)_get_osfhandle(fd);
if (!DeviceIoControl(hd, IOCTL_CDROM_READ_TOC, NULL, 0, &vcd->toc,
sizeof(CDROM_TOC), &dwBytesReturned, NULL)) {
- mp_msg(MSGT_OPEN, MSGL_ERR, "read CDROM toc header: %lu\n",
+ MP_ERR(stream, "read CDROM toc header: %lu\n",
GetLastError());
free(vcd);
return NULL;
}
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_START_TRACK=%d\n",
- vcd->toc.FirstTrack);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_END_TRACK=%d\n",
- vcd->toc.LastTrack);
-
for (i = vcd->toc.FirstTrack; i <= vcd->toc.LastTrack + 1; i++) {
int index = i - vcd->toc.FirstTrack;
if (i <= vcd->toc.LastTrack) {
- mp_msg(MSGT_OPEN, MSGL_INFO, "track %02d: adr=%d ctrl=%d"
+ MP_INFO(stream, "track %02d: adr=%d ctrl=%d"
" %02d:%02d:%02d\n",
vcd->toc.TrackData[index].TrackNumber,
vcd->toc.TrackData[index].Adr,
@@ -105,27 +100,6 @@ static mp_vcd_priv_t* vcd_read_toc(int fd)
vcd->toc.TrackData[index].Address[2],
vcd->toc.TrackData[index].Address[3]);
}
-
- if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO)) {
- if (i > vcd->toc.FirstTrack) {
- min = vcd->toc.TrackData[index].Address[1] - min;
- sec = vcd->toc.TrackData[index].Address[2] - sec;
- frame = vcd->toc.TrackData[index].Address[3] - frame;
- if (frame < 0) {
- frame += 75;
- sec--;
- }
- if (sec < 0) {
- sec += 60;
- min--;
- }
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_TRACK_%d_MSF="
- "%02d:%02d:%02d\n", i - 1, min, sec, frame);
- min = vcd->toc.TrackData[index].Address[1];
- sec = vcd->toc.TrackData[index].Address[2];
- frame = vcd->toc.TrackData[index].Address[3];
- }
- }
}
vcd->hd = hd;
diff --git a/video/out/gl_lcms.c b/video/out/gl_lcms.c
index db4c7dc97b..5da2411c4c 100644
--- a/video/out/gl_lcms.c
+++ b/video/out/gl_lcms.c
@@ -90,11 +90,12 @@ static void lcms2_error_handler(cmsContext ctx, cmsUInt32Number code,
mp_msg_log(lcms2_dumb_crap, MSGL_ERR, "lcms2: %s\n", msg);
}
-static struct bstr load_file(void *talloc_ctx, const char *filename)
+static struct bstr load_file(void *talloc_ctx, const char *filename,
+ struct mpv_global *global)
{
struct bstr res = {0};
char *fname = mp_get_user_path(NULL, filename);
- stream_t *s = stream_open(fname, NULL);
+ stream_t *s = stream_open(fname, global);
if (s) {
res = stream_read_complete(s, talloc_ctx, 1000000000);
free_stream(s);
@@ -121,7 +122,7 @@ struct lut3d *mp_load_icc(struct mp_icc_opts *opts, struct mp_log *log,
bool locked = false;
mp_msg_log(log, MSGL_INFO, "Opening ICC profile '%s'\n", opts->profile);
- struct bstr iccdata = load_file(tmp, opts->profile);
+ struct bstr iccdata = load_file(tmp, opts->profile, global);
if (!iccdata.len)
goto error_exit;
@@ -132,7 +133,7 @@ struct lut3d *mp_load_icc(struct mp_icc_opts *opts, struct mp_log *log,
if (opts->cache) {
mp_msg_log(log, MSGL_INFO, "Opening 3D LUT cache in file '%s'.\n",
opts->cache);
- struct bstr cachedata = load_file(tmp, opts->cache);
+ struct bstr cachedata = load_file(tmp, opts->cache, global);
if (bstr_eatstart(&cachedata, bstr0(LUT3D_CACHE_HEADER))
&& bstr_eatstart(&cachedata, bstr0(cache_info))
&& bstr_eatstart(&cachedata, iccdata)