Commit c0ca06c3 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Add message type to message callback function.

parent baf927dd
......@@ -208,8 +208,16 @@ static void NewSubtableBAT(void * p_zero, dvbpsi_t *p_dvbpsi,
}
}
static void message(dvbpsi_t *handle, const char* msg)
static void message(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char* msg)
{
switch(level)
{
case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
default: /* do nothing */
return;
}
fprintf(stderr, "%s\n", msg);
}
......
......@@ -293,8 +293,16 @@ static void report_PCRPacketTiming( int i_cc, ts_pid_t *ts_pid,
#endif
}
static void message(dvbpsi_t *handle, const char* msg)
static void message(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char* msg)
{
switch(level)
{
case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
default: /* do nothing */
return;
}
fprintf(stderr, "%s\n", msg);
}
......
......@@ -96,8 +96,16 @@ static void DumpPAT(void* p_zero, dvbpsi_pat_t* p_pat)
dvbpsi_DeletePAT(p_pat);
}
static void message(dvbpsi_t *handle, const char* msg)
static void message(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char* msg)
{
switch(level)
{
case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
default: /* do nothing */
return;
}
fprintf(stderr, "%s\n", msg);
}
......
......@@ -239,8 +239,16 @@ static void DumpPMT(void* p_zero, dvbpsi_pmt_t* p_pmt)
dvbpsi_DeletePMT(p_pmt);
}
static void message(dvbpsi_t *handle, const char* msg)
static void message(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char* msg)
{
switch(level)
{
case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
default: /* do nothing */
return;
}
fprintf(stderr, "%s\n", msg);
}
......
......@@ -125,8 +125,16 @@ static void DumpSDT(void* p_zero, dvbpsi_sdt_t* p_sdt)
/*****************************************************************************
* DVBPSI messaging callback
*****************************************************************************/
static void message(dvbpsi_t *handle, const char* msg)
static void message(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char* msg)
{
switch(level)
{
case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
default: /* do nothing */
return;
}
fprintf(stderr, "%s\n", msg);
}
......
......@@ -266,8 +266,16 @@ mtime_t mdate(void)
/*****************************************************************************
* libdvbpsi message callback functions
*****************************************************************************/
static void dvbpsi_message(dvbpsi_t *p_dvbpsi, const char* msg)
static void dvbpsi_message(dvbpsi_t *p_dvbpsi, const dvbpsi_msg_level_t level, const char* msg)
{
switch(level)
{
case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
default: /* do nothing */
return;
}
fprintf(stderr, "%s\n", msg);
}
......@@ -1363,7 +1371,7 @@ bool libdvbpsi_process(ts_stream_t *stream, uint8_t *buf, ssize_t length)
{
stream->i_lost_bytes += i_lost;
i += i_lost;
fprintf(stderr, "dvbinfo: Lost %ld bytes out of %ld in buffer\n", i_lost, length);
fprintf(stderr, "dvbinfo: Lost %"PRId64" bytes out of %"PRId64" in buffer\n", (int64_t) i_lost, (int64_t)length);
if (i >= length)
return true;
}
......
......@@ -73,8 +73,16 @@ static dvbpsi_t *p_pmt_dvbpsi_fds[MAX_PROGRAMS];
/*****************************************************************************
* DVBPSI messaging callback
*****************************************************************************/
static void message(dvbpsi_t *handle, const char* msg)
static void message(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char* msg)
{
switch(level)
{
case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
default: /* do nothing */
return;
}
fprintf(stderr, "%s\n", msg);
}
......
......@@ -95,8 +95,16 @@ static void writePSI(uint8_t* p_packet, dvbpsi_psi_section_t* p_section)
}
}
static void message(dvbpsi_t *handle, const char* msg)
static void message(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char* msg)
{
switch(level)
{
case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
default: /* do nothing */
return;
}
fprintf(stderr, "%s\n", msg);
}
......
......@@ -98,8 +98,16 @@ static void writePSI(uint8_t* p_packet, dvbpsi_psi_section_t* p_section)
}
}
static void message(dvbpsi_t *handle, const char* msg)
static void message(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char* msg)
{
switch(level)
{
case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
default: /* do nothing */
return;
}
fprintf(stderr, "%s\n", msg);
}
......
......@@ -447,7 +447,7 @@ void dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data)
#endif
#ifdef HAVE_VARIADIC_MACROS
void message(dvbpsi_t *dvbpsi, const int level, const char *fmt, ...)
void message(dvbpsi_t *dvbpsi, const dvbpsi_msg_level_t level, const char *fmt, ...)
{
if ((dvbpsi->i_msg_level > DVBPSI_MSG_NONE) &&
(level <= dvbpsi->i_msg_level))
......@@ -470,7 +470,7 @@ void message(dvbpsi_t *dvbpsi, const int level, const char *fmt, ...)
va_end(ap);
if (err > DVBPSI_MSG_NONE) {
if (dvbpsi->pf_message)
dvbpsi->pf_message(dvbpsi, msg);
dvbpsi->pf_message(dvbpsi, level, msg);
}
free(msg);
}
......@@ -480,7 +480,7 @@ void message(dvbpsi_t *dvbpsi, const int level, const char *fmt, ...)
/* Common code for printing messages */
# if defined(_GNU_SOURCE)
# define DVBPSI_MSG_COMMON \
# define DVBPSI_MSG_COMMON(level) \
do { \
va_list ap; \
va_start(ap, fmt); \
......@@ -497,7 +497,7 @@ void message(dvbpsi_t *dvbpsi, const int level, const char *fmt, ...)
va_end(ap); \
if (err > 0) { \
if (dvbpsi->pf_message) \
dvbpsi->pf_message(dvbpsi, msg); \
dvbpsi->pf_message(dvbpsi, level, msg); \
} \
free(msg); \
} while(0);
......@@ -515,7 +515,7 @@ void message(dvbpsi_t *dvbpsi, const int level, const char *fmt, ...)
va_end(ap); \
if (err > 0) { \
if (dvbpsi->pf_message) \
dvbpsi->pf_message(dvbpsi, msg); \
dvbpsi->pf_message(dvbpsi, level, msg); \
} \
free(msg); \
} while(0);
......@@ -526,7 +526,7 @@ void dvbpsi_error(dvbpsi_t *dvbpsi, const char *src, const char *fmt, ...)
if ((dvbpsi->i_msg_level > DVBPSI_MSG_NONE) &&
(DVBPSI_MSG_ERROR <= dvbpsi->i_msg_level))
{
DVBPSI_MSG_COMMON
DVBPSI_MSG_COMMON(DVBPSI_MSG_ERROR)
}
}
......@@ -535,7 +535,7 @@ void dvbpsi_warning(dvbpsi_t *dvbpsi, const char *src, const char *fmt, ...)
if ((dvbpsi->i_msg_level > DVBPSI_MSG_NONE) &&
(DVBPSI_MSG_WARN <= dvbpsi->i_msg_level))
{
DVBPSI_MSG_COMMON
DVBPSI_MSG_COMMON(DVBPSI_MSG_WARN)
}
}
......@@ -544,7 +544,7 @@ void dvbpsi_debug(dvbpsi_t *dvbpsi, const char *src, const char *fmt, ...)
if ((dvbpsi->i_msg_level > DVBPSI_MSG_NONE) &&
(DVBPSI_MSG_DEBUG <= dvbpsi->i_msg_level))
{
DVBPSI_MSG_COMMON
DVBPSI_MSG_COMMON(DVBPSI_MSG_DEBUG)
}
}
#endif
......@@ -50,29 +50,31 @@ extern "C" {
*/
typedef struct dvbpsi_s dvbpsi_t;
/*!
* \enum dvbpsi_msg_level
* \brief DVBPSI message level enum
*/
typedef enum dvbpsi_msg_level
{
DVBPSI_MSG_NONE = -1, /*!< No messages */
DVBPSI_MSG_ERROR = 0, /*!< Error messages only */
DVBPSI_MSG_WARN = 1, /*!< Error and Warning messages */
DVBPSI_MSG_DEBUG = 2, /*!< Error, warning and debug messages */
} dvbpsi_msg_level_t;
/*****************************************************************************
* dvbpsi_message_cb
*****************************************************************************/
/*!
* \typedef void (* dvbpsi_message_cb)(dvbpsi_handle p_decoder,
* const dvbpse_msg_level_t level,
* const char* msg)
* \brief Callback type definition.
*/
typedef void (* dvbpsi_message_cb)(dvbpsi_t *handle,
const dvbpsi_msg_level_t level,
const char* msg);
/*!
* \enum dvbpsi_msg_level
* \brief DVBPSI message level enum
*/
enum dvbpsi_msg_level
{
DVBPSI_MSG_NONE = -1, /*!< No messages */
DVBPSI_MSG_ERROR = 0, /*!< Error messages only */
DVBPSI_MSG_WARN = 1, /*!< Error and Warning messages */
DVBPSI_MSG_DEBUG = 2, /*!< Error, warning and debug messages */
};
/*****************************************************************************
* dvbpsi_t
*****************************************************************************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment