summaryrefslogtreecommitdiff
path: root/src/input/input_dvb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/input/input_dvb.c')
-rw-r--r--src/input/input_dvb.c76
1 files changed, 46 insertions, 30 deletions
diff --git a/src/input/input_dvb.c b/src/input/input_dvb.c
index ae7c0c21e..9ff40f7ea 100644
--- a/src/input/input_dvb.c
+++ b/src/input/input_dvb.c
@@ -27,7 +27,7 @@
* Date Author
* ---- ------
*
- * 01-Feb-2005 Pekka Jääskeläinen <poj@iki.fi>
+ * 01-Feb-2005 Pekka Jääskeläinen <poj@iki.fi>
*
* - This history log started.
* - Disabled the automatic EPG updater thread until EPG demuxer
@@ -66,14 +66,17 @@
* OSD - this will allow for filtering/searching of epg data - useful for automatic recording :)
*/
-/* pthread.h must be included first so rest of the headers are imported
- thread safely (on some systems). */
-#include <pthread.h>
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+/* pthread.h must be included first so rest of the headers are imported
+ thread safely (on some systems).
+ However, including it before config.h causes problems with asprintf not
+ being declared (glibc 2.3.6)
+*/
+#include <pthread.h>
+
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@@ -97,14 +100,17 @@
#endif
#include <ctype.h>
-/* These will eventually be #include <linux/dvb/...> */
-#include "dvb/dmx.h"
-#include "dvb/frontend.h"
+/* XDG */
+#include <basedir.h>
+
+#include <linux/dvb/dmx.h>
+#include <linux/dvb/frontend.h>
#define LOG_MODULE "input_dvb"
#define LOG_VERBOSE
/*
#define LOG
+#define LOG_READS
*/
#include "xine_internal.h"
@@ -114,7 +120,7 @@
#define BUFSIZE 16384
-#define NOPID 0xffff
+#define DVB_NOPID 0xffff
/* define stream types
* administrative/system PIDs first */
@@ -583,7 +589,8 @@ static tuner_t *tuner_init(xine_t * xine, int adapter)
this = (tuner_t *) xine_xmalloc(sizeof(tuner_t));
_x_assert(this != NULL);
-
+
+ xprintf(this->xine, XINE_VERBOSITY_DEBUG, "tuner_init adapter=%d\n", adapter);
this->fd_frontend = -1;
for (x = 0; x < MAX_FILTERS; x++)
this->fd_pidfilter[x] = 0;
@@ -628,7 +635,7 @@ static tuner_t *tuner_init(xine_t * xine, int adapter)
xprintf(this->xine,XINE_VERBOSITY_DEBUG,"input_dvb: couldn't set EIT to nonblock: %s\n",strerror(errno));
/* and the internal filter used for PAT & PMT */
if(fcntl(this->fd_pidfilter[INTERNAL_FILTER], F_SETFL, O_NONBLOCK)<0)
- xprintf(this->xine,XINE_VERBOSITY_DEBUG,"input_dvb: couldn't set EIT to nonblock: %s\n",strerror(errno));
+ xprintf(this->xine,XINE_VERBOSITY_DEBUG,"input_dvb: couldn't set INTERNAL to nonblock: %s\n",strerror(errno));
/* and the frontend */
fcntl(this->fd_frontend, F_SETFL, O_NONBLOCK);
@@ -655,7 +662,7 @@ static int dvb_set_pidfilter(dvb_input_plugin_t * this, int filter, ushort pid,
{
tuner_t *tuner = this->tuner;
- if(this->channels[this->channel].pid [filter] !=NOPID) {
+ if(this->channels[this->channel].pid [filter] !=DVB_NOPID) {
ioctl(tuner->fd_pidfilter[filter], DMX_STOP);
}
@@ -678,7 +685,7 @@ static int dvb_set_sectfilter(dvb_input_plugin_t * this, int filter, ushort pid,
{
tuner_t *tuner = this->tuner;
- if(this->channels[this->channel].pid [filter] !=NOPID) {
+ if(this->channels[this->channel].pid [filter] !=DVB_NOPID) {
ioctl(tuner->fd_pidfilter[filter], DMX_STOP);
}
@@ -885,8 +892,8 @@ static channel_t *load_channels(xine_t *xine, xine_stream_t *stream, int *num_ch
int num_alloc = 0;
int i;
struct stat st;
-
- snprintf(filename, BUFSIZE, "%s/.xine/channels.conf", xine_get_homedir());
+
+ snprintf(filename, BUFSIZE, "%s/"PACKAGE"/channels.conf", xdgConfigHome(xine->basedir_handle));
f = fopen(filename, "r");
if (!f) {
@@ -1004,7 +1011,7 @@ static int tuner_tune_it (tuner_t *this, struct dvb_frontend_parameters
while (ioctl(this->fd_frontend, FE_GET_EVENT, &event) != -1);
if (ioctl(this->fd_frontend, FE_SET_FRONTEND, front_param) <0) {
- xprintf(this->xine, XINE_VERBOSITY_DEBUG, "setfront front: %s\n", strerror(errno));
+ xprintf(this->xine, XINE_VERBOSITY_DEBUG, "input_dvb: setfront front: %s\n", strerror(errno));
return 0;
}
@@ -1030,7 +1037,7 @@ static int tuner_tune_it (tuner_t *this, struct dvb_frontend_parameters
do {
status = 0;
if (ioctl(this->fd_frontend, FE_READ_STATUS, &status) < 0) {
- xprintf(this->xine, XINE_VERBOSITY_DEBUG, "fe get event: %s\n", strerror(errno));
+ xprintf(this->xine, XINE_VERBOSITY_DEBUG, "input_dvb: fe get event: %s\n", strerror(errno));
return 0;
}
@@ -1146,7 +1153,7 @@ static void parse_pmt(dvb_input_plugin_t *this, const unsigned char *buf, int se
* parsing the descriptor. */
if(has_subs <= MAX_SUBTITLES) {
xprintf(this->stream->xine,XINE_VERBOSITY_LOG,"input_dvb: Adding SUBTITLES: PID 0x%04x\n", elementary_pid);
- if(this->channels[this->channel].subpid [has_subs] !=NOPID) {
+ if(this->channels[this->channel].subpid [has_subs] !=DVB_NOPID) {
ioctl(this->tuner->fd_subfilter[has_subs], DMX_STOP);
}
this->channels[this->channel].subpid [has_subs] = elementary_pid;
@@ -1299,8 +1306,8 @@ static void dvb_parse_si(dvb_input_plugin_t *this) {
/* Helper function for finding the channel index in the channels struct
given the service_id. If channel is not found, -1 is returned. */
-static int channel_index(dvb_input_plugin_t* this, unsigned int service_id) {
- unsigned int n;
+static int channel_index(dvb_input_plugin_t* this, int service_id) {
+ int n;
for (n=0; n < this->num_channels; n++)
if (this->channels[n].service_id == service_id)
return n;
@@ -2461,8 +2468,10 @@ static void ts_rewrite_packets (dvb_input_plugin_t *this, unsigned char * origin
}
static off_t dvb_plugin_read (input_plugin_t *this_gen,
- char *buf, off_t len) {
+ void *buf_gen, off_t len) {
dvb_input_plugin_t *this = (dvb_input_plugin_t *) this_gen;
+ char *buf = (char *)buf_gen;
+
off_t n=0, total=0;
int have_mutex=0;
struct pollfd pfd;
@@ -2470,8 +2479,10 @@ static off_t dvb_plugin_read (input_plugin_t *this_gen,
if (!this->tuned_in)
return 0;
dvb_event_handler (this);
+#ifdef LOG_READS
xprintf(this->class->xine,XINE_VERBOSITY_DEBUG,
"input_dvb: reading %" PRIdMAX " bytes...\n", (intmax_t)len);
+#endif
#ifndef DVB_NO_BUFFERING
nbc_check_buffers (this->nbc);
@@ -2523,9 +2534,11 @@ static off_t dvb_plugin_read (input_plugin_t *this_gen,
break;
}
+#ifdef LOG_READS
xprintf(this->class->xine,XINE_VERBOSITY_DEBUG,
"input_dvb: got %" PRIdMAX " bytes (%" PRIdMAX "/%" PRIdMAX " bytes read)\n",
(intmax_t)n, (intmax_t)total, (intmax_t)len);
+#endif
if (n > 0){
this->curpos += n;
@@ -2789,7 +2802,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen)
* by numbers...
*/
int chanlen = strlen(channame);
- int offset = 0;
+ size_t offset = 0;
xprintf(this->class->xine, XINE_VERBOSITY_LOG,
_("input_dvb: exact match for %s not found: trying partial matches\n"), channame);
@@ -2806,7 +2819,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen)
idx++;
}
offset++;
- xprintf(this->class->xine,XINE_VERBOSITY_LOG,"%d,%d,%d\n", offset, idx, num_channels);
+ xprintf(this->class->xine,XINE_VERBOSITY_LOG,"%zd,%d,%d\n", offset, idx, num_channels);
}
while ((offset < 6) && (idx == num_channels));
if (idx < num_channels) {
@@ -2899,13 +2912,13 @@ static int dvb_plugin_open(input_plugin_t * this_gen)
{
fprintf(stderr,"input_dvb: 2a %x\n",tuner->feinfo.type);
/*
- * This is dvbc://<channel name>:<qam tuning parameters>
+ * This is dvba://<channel name>:<atsc tuning parameters>
*/
if (tuner->feinfo.type != FE_ATSC)
{
fprintf(stderr,"input_dvb: FAILED 1\n");
xprintf(this->class->xine, XINE_VERBOSITY_LOG,
- _("input_dvb: dvbc mrl specified but the tuner doesn't appear to be QAM (DVB-C)\n"));
+ _("input_dvb: dvba mrl specified but the tuner doesn't appear to be ATSC (DVB-A)\n"));
tuner_dispose(tuner);
return 0;
}
@@ -3050,7 +3063,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen)
/* Clear all pids, the pmt will tell us which to use */
for (x = 0; x < MAX_FILTERS; x++){
- this->channels[this->channel].pid[x] = NOPID;
+ this->channels[this->channel].pid[x] = DVB_NOPID;
}
@@ -3156,11 +3169,14 @@ static char **dvb_class_get_autoplay_list(input_class_t * this_gen,
num_channels = 0;
if (!(channels = load_channels(class->xine, NULL, &num_channels, 0))) {
+ static char *placefile = NULL;
/* channels.conf not found in .xine */
- class->mrls[0]="Sorry, No channels.conf found";
- class->mrls[1]="Please run the dvbscan utility";
- class->mrls[2]="from the dvb drivers apps package";
- class->mrls[3]="and place the file in ~/.xine/";
+ class->mrls[0]="Sorry, no channels.conf found.";
+ class->mrls[1]="Please run the scan utility from the DVB";
+ class->mrls[2]="drivers apps package and place the file in";
+ if (!placefile)
+ asprintf (&placefile, "%s/"PACKAGE"/", xdgConfigHome(class->xine->basedir_handle));
+ class->mrls[3]=placefile;
*num_files=4;
return class->mrls;
}