From 0335011f11d9d13f70db6c46ed6189a74d48ec67 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 21 Dec 2013 20:36:45 +0100 Subject: stream: mp_msg conversions We also drop some slave mode stuff from stream_vcd. --- common/encode_lavc.c | 9 +- common/playlist_parser.c | 2 +- demux/demux_mf.c | 2 +- input/input.c | 2 +- player/loadfile.c | 4 +- player/timeline/tl_cue.c | 2 +- player/timeline/tl_matroska.c | 4 +- player/timeline/tl_mpv_edl.c | 2 +- stream/cache.c | 43 ++++----- stream/cdd.h | 4 +- stream/cdinfo.c | 41 ++++---- stream/cookies.c | 34 +++---- stream/cookies.h | 2 +- stream/dvb_tune.c | 108 ++++++++++----------- stream/dvb_tune.h | 6 +- stream/dvbin.h | 3 +- stream/rar.c | 6 +- stream/rar.h | 2 +- stream/stream.c | 84 ++++++++-------- stream/stream.h | 10 +- stream/stream_bluray.c | 26 ++--- stream/stream_cdda.c | 16 +-- stream/stream_dvb.c | 127 +++++++++++------------- stream/stream_dvd.c | 152 ++++++++++++++--------------- stream/stream_dvd_common.c | 12 +-- stream/stream_dvd_common.h | 3 +- stream/stream_dvdnav.c | 46 +++++---- stream/stream_file.c | 12 +-- stream/stream_lavf.c | 12 +-- stream/stream_pvr.c | 219 ++++++++++++++++-------------------------- stream/stream_radio.c | 106 ++++++++++---------- stream/stream_rar.c | 4 +- stream/stream_smb.c | 8 +- stream/stream_vcd.c | 16 +-- stream/vcd_read.h | 49 +++------- stream/vcd_read_darwin.h | 46 +++------ stream/vcd_read_fbsd.h | 29 +----- stream/vcd_read_win32.h | 34 +------ video/out/gl_lcms.c | 9 +- 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", ¶ms, 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 +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 lis