diff options
Diffstat (limited to 'stream')
-rw-r--r-- | stream/cache.c | 43 | ||||
-rw-r--r-- | stream/cdd.h | 4 | ||||
-rw-r--r-- | stream/cdinfo.c | 41 | ||||
-rw-r--r-- | stream/cookies.c | 34 | ||||
-rw-r--r-- | stream/cookies.h | 2 | ||||
-rw-r--r-- | stream/dvb_tune.c | 108 | ||||
-rw-r--r-- | stream/dvb_tune.h | 6 | ||||
-rw-r--r-- | stream/dvbin.h | 3 | ||||
-rw-r--r-- | stream/rar.c | 6 | ||||
-rw-r--r-- | stream/rar.h | 2 | ||||
-rw-r--r-- | stream/stream.c | 84 | ||||
-rw-r--r-- | stream/stream.h | 10 | ||||
-rw-r--r-- | stream/stream_bluray.c | 26 | ||||
-rw-r--r-- | stream/stream_cdda.c | 16 | ||||
-rw-r--r-- | stream/stream_dvb.c | 127 | ||||
-rw-r--r-- | stream/stream_dvd.c | 152 | ||||
-rw-r--r-- | stream/stream_dvd_common.c | 12 | ||||
-rw-r--r-- | stream/stream_dvd_common.h | 3 | ||||
-rw-r--r-- | stream/stream_dvdnav.c | 46 | ||||
-rw-r--r-- | stream/stream_file.c | 12 | ||||
-rw-r--r-- | stream/stream_lavf.c | 12 | ||||
-rw-r--r-- | stream/stream_pvr.c | 219 | ||||
-rw-r--r-- | stream/stream_radio.c | 106 | ||||
-rw-r--r-- | stream/stream_rar.c | 4 | ||||
-rw-r--r-- | stream/stream_smb.c | 8 | ||||
-rw-r--r-- | stream/stream_vcd.c | 16 | ||||
-rw-r--r-- | stream/vcd_read.h | 49 | ||||
-rw-r--r-- | stream/vcd_read_darwin.h | 46 | ||||
-rw-r--r-- | stream/vcd_read_fbsd.h | 29 | ||||
-rw-r--r-- | stream/vcd_read_win32.h | 34 |
30 files changed, 539 insertions, 721 deletions
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); |