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. --- stream/dvb_tune.c | 108 ++++++++++++++++++++++++++---------------------------- 1 file changed, 52 insertions(+), 56 deletions(-) (limited to 'stream/dvb_tune.c') 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; } -- cgit v1.2.3