pike.git / src / modules / DVB / dvb.c

version» Context lines:

pike.git/src/modules/DVB/dvb.c:216:    if(st == NULL)    return 0;    while(st != NULL && st->pid != pid)    st = st->next;    if(st == NULL)    return 0;    return st;      }    - char *mk_devname(int devno, char *basename) { + static char devname_buf[24];    -  char *devname; -  -  if((devname = malloc(sizeof(basename)+4)) == NULL) -  return NULL; -  sprintf(devname, "%s%d", basename, devno); /* FIXME: uncorrect for v2.0+ !! */ -  return devname; + static INLINE char *mk_devname(int devno, const char *basename) { +  sprintf(devname_buf, "%s%d", basename, devno); /* FIXME: uncorrect for v2.0+ !! */ +  return devname_buf;   }         /*! @module DVB    *!    *! Implements Digital Video Broadcasting interface    *!    *! @note    *! Only Linux version is supported.    */
pike.git/src/modules/DVB/dvb.c:255:    *! The number of card equipment.    *!    *! @note    *! The number specifies which device will be opened.    *! Ie. /dev/ost/demux0, /dev/ost/demux1 ... for    *! DVB v0.9.4 or /dev/dvb/demux0, /dev/dvb/demux1 ...    *! for versions 2.0+    */   static void f_create(INT32 args) {    -  int fefd; +  int fefd, devno;    char *devname;       if(DVB->cardn != -1)    Pike_error("Create already called!\n");    -  DVB->cardn = 0; +  devno = 0;    if(args) {    if(TYPEOF(Pike_sp[-1]) != T_INT)    Pike_error("Invalid argument 1, expected int.\n");    else -  DVB->cardn = (u_short)Pike_sp[-1].u.integer; +  devno = (u_short)Pike_sp[-1].u.integer;    }    -  if((devname = mk_devname(DVB->cardn, FRONTENDDEVICE)) == NULL) -  Pike_error("Internal error: can't malloc buffer.\n"); +  devname = mk_devname(devno, FRONTENDDEVICE);    fefd = open (devname, O_RDWR | O_NONBLOCK);    if (fefd < 0) { -  DVB->cardn = -1; -  /* free(devname); */ +     Pike_error("Opening frontend '%s' failed.\n", devname);    }    DVB->fefd = fefd; -  +  DVB->cardn = devno;       /* Make sure this fd gets closed on exec. */    set_close_on_exec(fefd, 1);      } /* create */      /* LNB hi/lo band switch frequency in kHz */   #define SWITCHFREQ 11700000   /* LNB hi/lo band local oscillator frequencies in kHz */   #define LOF_HI 10600000
pike.git/src/modules/DVB/dvb.c:572:    pol = Pike_sp[-1].u.string->str[0] == 'V' ||    Pike_sp[-1].u.string->str[0] == 'v';    Pike_sp--;       freq = (u_short)Pike_sp[-1].u.integer * 1000;    Pike_sp--;       satno = (u_short)Pike_sp[-1].u.integer;      #if HAVE_DVB < 30 -  if((devname = mk_devname(dvb->cardn, SECDEVICE)) == NULL) -  Pike_error("Internal error: can't malloc buffer.\n"); +  devname = mk_devname(dvb->cardn, SECDEVICE);    secfd = open (devname, O_RDWR);    /* free(devname); */    if (secfd == -1) {    Pike_error ("opening SEC device failed\n");    }   #else    secfd = dvb->fefd;   #endif    THREADS_ALLOW();    result = ioctl (dvb->fefd, FE_GET_INFO, &fe_info);
pike.git/src/modules/DVB/dvb.c:618:      /*! @decl mapping|int get_pids()    *!    *! Returns mapping with info of currently tuned program's pids.    *!    *! @seealso    *! @[tune()]    */   static void f_get_pids(INT32 args) {    -  dvb_pid_t pids[7]; +  dvb_pid_t pids[5];    int cnt = 0, dmx, ret;    char *devname;       pop_n_elems(args);    if(!sl_count(DVB)) { -  if((devname = mk_devname(DVB->cardn, DEMUXDEVICE)) == NULL) -  Pike_error("Internal error: can't malloc buffer.\n"); +  devname = mk_devname(DVB->cardn, DEMUXDEVICE);    dmx = open (devname, O_RDWR | O_NONBLOCK);    /* free(devname); */    if (dmx < 0)    Pike_error("Opening demux failed.\n");    } else    /* FIXME: for which PMT ? */    dmx = DVB->stream->fd;    /* get the current PID settings */    THREADS_ALLOW();    ret = ioctl(dmx, DMX_GET_PES_PIDS, &pids);
pike.git/src/modules/DVB/dvb.c:652:    push_text("audio"); push_int( pids[DMX_PES_AUDIO] & 0x1fff );    cnt++;    push_text("video"); push_int( pids[DMX_PES_VIDEO] & 0x1fff );    cnt++;    push_text("teletext"); push_int( pids[DMX_PES_TELETEXT] & 0x1fff );    cnt++;    push_text("subtitle"); push_int( pids[DMX_PES_SUBTITLE] & 0x1fff );    cnt++;    push_text("pcr"); push_int( pids[DMX_PES_PCR] & 0x1fff );    cnt++; -  push_text("other"); push_int( pids[DMX_PES_OTHER] & 0x1fff ); -  cnt++; -  if(cnt) +     f_aggregate_mapping( 2 * cnt ); -  else -  push_int(0); +     } else    push_int(0);    if(!sl_count(DVB))    close(dmx);   }            /**    * Set a filter for a DVB stream
pike.git/src/modules/DVB/dvb.c:837:    int length,index;    int n;       int fd;    int p, cnt = 0;    int pid = -1;    int dmx;    char *devname;       pop_n_elems(args); -  if((devname = mk_devname(DVB->cardn, DEMUXDEVICE)) == NULL) -  Pike_error("Internal error: can't malloc buffer.\n"); +  devname = mk_devname(DVB->cardn, DEMUXDEVICE);    dmx = open (devname, O_RDWR | O_NONBLOCK); -  /* free(devname); */ +     if (dmx < 0) {    snprintf (DVB->low_errmsg, MAX_ERR_LEN, "DMX SET SECTION FILTER.\n");    push_int(0);    return;    }       /* The PAT is supposed to fit in a 184 bytes packet */    SetFilt(dmx,0,0);    do    {
pike.git/src/modules/DVB/dvb.c:1001:       int program_number;    int pmt_pid;    int dmx;    dvb_stream_data stream;    char *devname;    int cnt = 0, arr = 0;       check_all_args("DVB.dvb->analyze_pmt", args, BIT_INT, BIT_INT, 0);    -  if((devname = mk_devname(DVB->cardn, DEMUXDEVICE)) == NULL) -  Pike_error("Internal error: can't malloc buffer.\n"); +  devname = mk_devname(DVB->cardn, DEMUXDEVICE);    dmx = open (devname, O_RDWR | O_NONBLOCK); -  /* free(devname); */ +     if (dmx < 0) {    snprintf (DVB->low_errmsg, MAX_ERR_LEN, "DMX SET SECTION FILTER.\n");    push_int(0);    return;    }       pmt_pid = (u_short)Pike_sp[-1].u.integer;    Pike_sp--;       program_number = (u_short)Pike_sp[-1].u.integer;
pike.git/src/modules/DVB/dvb.c:1294:    Pike_sp--;       pid = (u_short)Pike_sp[-1].u.integer;    Pike_sp--;       dvbprog = Pike_sp[-1].u.object;    Pike_sp--;    if( !dvbprog || !(dvbstor = (dvb_data *)get_storage( dvbprog, dvb_program )) )    Pike_error("This class cannot be instantiated directly\n");    -  if((devname = mk_devname(DVB->cardn, DEMUXDEVICE)) == NULL) -  Pike_error("Internal error: can't malloc buffer.\n"); +  devname = mk_devname(DVB->cardn, DEMUXDEVICE);    fd = open (devname, O_RDWR /*| O_NONBLOCK*/); -  /* free(devname); */ +     if (fd < 0) {    Pike_error("Opening DEMUX failed.\n");    }    pesflt.pid = pid;    pesflt.input = DMX_IN_FRONTEND;    pesflt.output = DMX_OUT_TAP;    pesflt.pesType = ptype;    pesflt.flags = DMX_IMMEDIATE_START;   #ifdef DVB_DEBUG    printf("DEB: dvb: set_pes: PID=%d, type=%d\n", pid, ptype);
pike.git/src/modules/DVB/dvb.c:1507:    if(DVBAudio->fd != -1)    Pike_error("Create already called!\n");       if(args) {    if(TYPEOF(Pike_sp[-1]) != T_INT)    Pike_error("Invalid argument 1, expected int.\n");    else    devno = (u_short)Pike_sp[-1].u.integer;    }    pop_n_elems(args); -  if((devname = mk_devname(devno, AUDIODEVICE)) == NULL) -  Pike_error("Internal error: can't malloc buffer.\n"); +  devname = mk_devname(devno, AUDIODEVICE);    DVBAudio->fd = open( devname, O_RDWR ); -  /* free(devname); */ +     if (DVBAudio->fd < 0) {    DVB->cardn = -1;    Pike_error("Opening audio device failed.\n");    }   }         /*! @decl int mute(int mute)    *! @decl int mute()    *!
pike.git/src/modules/DVB/dvb.c:1851:      PIKE_MODULE_INIT {    if(!TEST_COMPAT(7,6))    HIDE_MODULE();   }      PIKE_MODULE_EXIT {   }      #endif +