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

version» Context lines:

pike.git/src/modules/DVB/dvb.c:16:    *    * Distro: aconfig.h (automake-> config.h.in), configure.in, Makefile.in    *    * Todo:    * - remove crc32 table and use Gz.crc32() call    * - "Frontend", "Mux" ...    */      #include "config.h"   #include "module.h" + #include "module_support.h"      #ifdef HAVE_DVB    - #include <stdlib.h> - #include <limits.h> - #include <string.h> +    #include <errno.h>   #include <sys/ioctl.h>   #include <sys/types.h>   #include <sys/stat.h>   #include <sys/poll.h>   #include <fcntl.h>   #include <time.h>   #include <unistd.h>      #include <stdint.h>
pike.git/src/modules/DVB/dvb.c:58:   # include <ost/frontend.h>   # include <ost/dmx.h>   # include <ost/audio.h>   # define SECDEVICE "/dev/ost/sec"   # define FRONTENDDEVICE "/dev/ost/frontend"   # define DEMUXDEVICE "/dev/ost/demux"   # define AUDIODEVICE "/dev/ost/audio"   #endif      #include "interpret.h" - #include "svalue.h" - #include "stralloc.h" - #include "array.h" - #include "object.h" - #include "mapping.h" +    #include "pike_macros.h"   #include "threads.h"   #include "fd_control.h" - #include "module_support.h" +    #include "builtin_functions.h"   #include "operators.h"   #include "pike_types.h"      #include "dvb.h"      #if HAVE_DVB >= 30   /* Compat with old DVB. */   /* frontend.h */   typedef struct dvb_frontend_info FrontendInfo;
pike.git/src/modules/DVB/dvb.c:97:   /* audio.h */   typedef audio_status_t audioStatus_t;   typedef audio_mixer_t audioMixer_t;   #define AVSyncState AV_sync_state   #define muteState mute_state   #define playState play_state   #define streamSource stream_source   #define channelSelect channel_select   #define bypassMode bypass_mode   /* dmx.h */ - typedef __u16 dvb_pid_t; + typedef unsigned INT16 dvb_pid_t;   #define dmxSctFilterParams dmx_sct_filter_params   #define dmxPesFilterParams dmx_pes_filter_params   #define pesType pes_type   #endif      /* WARNING: It is a design limit of DVB-S full cards! */   #define MAX_PES_FD 8      #define _DMX_PES_RDS 129   
pike.git/src/modules/DVB/dvb.c:548:    uint ifreq;    int hiband, result;    FrontendInfo fe_info;       int satno;    uint freq;    int pol;    uint sr;    char *devname;    -  check_all_args("DVB.dvb->tune", args, BIT_INT, BIT_INT, BIT_INT | BIT_STRING, +  check_all_args(NULL, args, BIT_INT, BIT_INT, BIT_INT | BIT_STRING,    BIT_INT, 0);       sr = (u_short)Pike_sp[-1].u.integer * 1000;    Pike_sp--;       if(TYPEOF(Pike_sp[-1]) == T_INT)    pol = (u_short)Pike_sp[-1].u.integer;    else    pol = Pike_sp[-1].u.string->str[0] == 'V' ||    Pike_sp[-1].u.string->str[0] == 'v';
pike.git/src/modules/DVB/dvb.c:983:       int pnr = -1;       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); +  check_all_args(NULL, args, BIT_INT, BIT_INT, 0);       devname = mk_devname(DVB->cardn, DEMUXDEVICE);    dmx = open (devname, O_RDWR | O_NONBLOCK);    if (dmx < 0) {    snprintf (DVB->low_errmsg, MAX_ERR_LEN, "DMX SET SECTION FILTER.\n");    push_int(0);    return;    }       /* Clear the stream, and most notably, set stream.ecminfo to NULL. */
pike.git/src/modules/DVB/dvb.c:1139:    *! @seealso    *! @[DVB.Stream()->read()]    */   static void f_stream_attach(INT32 args) {       int err, ptype = PID_NONE;    unsigned int pid;    struct svalue feeder;    unsigned char *pktdata;    -  check_all_args("DVB.dvb->stream", args, BIT_INT, +  check_all_args(NULL, args, BIT_INT,    BIT_FUNCTION | BIT_INT | BIT_VOID, BIT_INT | BIT_VOID, 0);       if(sl_count(DVB) >= MAX_PES_FD)    Pike_error("Max opened DEMUX devices reached.\n");       if(args > 2) {    ptype = (u_short)Pike_sp[-1].u.integer;    Pike_sp--;    }    if(args > 1) {
pike.git/src/modules/DVB/dvb.c:1180:    if(TYPEOF(Pike_sp[-1]) != PIKE_T_OBJECT)    Pike_error("Failed to create Stream object!\n");      }      static void f__sprintf(INT32 args) {       int n = 0, x, cnt;    dvb_stream_data *st = DVB->stream;    -  check_all_args("DVB.dvb->_sprintf", args, BIT_INT, BIT_MAPPING | BIT_VOID, 0); +  check_all_args(NULL, args, BIT_INT, BIT_MAPPING | BIT_VOID, 0);       x = Pike_sp[-args].u.integer;    pop_n_elems(args);    switch (x) {    case 'O':    n++; push_static_text("DVB.dvb(");    n++; push_text(mk_devname(DVB->cardn, DEMUXDEVICE));    n++; push_static_text(": ");    cnt = 0;    while(st != NULL) {
pike.git/src/modules/DVB/dvb.c:1238:    * @note    * The size is 4096 by default.    *    * @seealso    * @[read()]    */   static void f_stream_set_buffer(INT32 args) {       int buflen;    -  check_all_args("DVB.Stream->set_buffer", args, BIT_INT, 0); +  check_all_args(NULL, args, BIT_INT, 0);    buflen = (u_short)Pike_sp[-1].u.integer;    Pike_sp--;    DVBStream->buflen = buflen;    push_int(1);   }            static void f_stream_create(INT32 args) {       struct dmxPesFilterParams pesflt;    int err, pid, fd, ix, ptype;    struct svalue feeder;    unsigned char *pktdata;    struct object *dvbprog;    dvb_data *dvbstor;    char *devname;    -  check_all_args("DVB.dvb->stream", args, BIT_OBJECT, BIT_INT, +  check_all_args(NULL, args, BIT_OBJECT, BIT_INT,    BIT_FUNCTION | BIT_INT, BIT_INT, 0);       ptype = (u_short)Pike_sp[-1].u.integer;    Pike_sp--;    if(ptype == PID_NONE)    ptype = DMX_PES_OTHER;      #if 0    feeder = Pike_sp[1-args].u.svalue;    apply_svalue(&feeder, 0); /* we want more data */
pike.git/src/modules/DVB/dvb.c:1323:    push_int(1);   #else    if(sl_add(dvbstor, DVBStream))    push_int(1);    else    push_int(0);   #endif      }    - /*! @decl int destroy() + /*! @decl int _destruct()    *!    *! Purge a stream reader.    *!    *! @seealso    *! @[DVB.dvb()->stream()], @[read()]    */   static void f_stream_detach(INT32 args) {       pop_n_elems(args);    close(DVBStream->fd);
pike.git/src/modules/DVB/dvb.c:1365:    */   static void f_stream_read(INT32 args) {       dvb_stream_data *dvb_stream = DVBStream;    int all = 1, ret, e, cnt, ix = 0;    unsigned char buf[MAX_DVB_READ_SIZE], *bufptr;       if(dvb_stream->fd < 0)    Pike_error("Object destroyed!\n");    -  check_all_args("DVB.dvb->stream_read", args, BIT_INT | BIT_VOID, 0); +  check_all_args(NULL, args, BIT_INT | BIT_VOID, 0);    if(args > 1)    all = (u_short)Pike_sp[-1].u.integer;    pop_n_elems(args);       if(dvb_stream->pkt.payload_len > 0)    memcpy(buf, dvb_stream->pkt.payload, dvb_stream->pkt.payload_len);    for(;;) {    e = 0;    THREADS_ALLOW();    ret = read(dvb_stream->fd, buf + dvb_stream->pkt.payload_len,
pike.git/src/modules/DVB/dvb.c:1436:    printf("DEB: dvb: ret=%d (ix: %d)\n", ret, ix);   #endif    return;    }    push_int(0);      }      static void f_stream_info(INT32 args) {    -  check_all_args("DVB.dvb->stream_info", args, BIT_INT, 0); +  check_all_args(NULL, args, BIT_INT, 0);    pop_n_elems(args);    push_int(0);      }      /*! @decl void close()    *!    *! Closes an open stream.    *!    *! @seealso
pike.git/src/modules/DVB/dvb.c:1513:    *!    *| @seealso    *| @[mixer()]    */   static void f_audio_mute(INT32 args) {       dvb_audio_data *dvb_audio = DVBAudio;    int mute = 1; /* default is mute = on */    int ret;    -  check_all_args("DVB.dvb->audio_mute", args, BIT_INT | BIT_VOID, 0); +  check_all_args(NULL, args, BIT_INT | BIT_VOID, 0);       if(args) {    mute = (u_short)Pike_sp[-1].u.integer;    Pike_sp--;    }       THREADS_ALLOW();    ret = ioctl(dvb_audio->fd, AUDIO_SET_MUTE, mute);    THREADS_DISALLOW();    if(ret < 0)
pike.git/src/modules/DVB/dvb.c:1589:    }      }      static void f_audio_ctrl(INT32 args) {       dvb_audio_data *dvb_audio = DVBAudio;    int ret;    int cw = -1;    -  check_all_args("DVB.dvb->ctrl", args, BIT_INT | BIT_STRING, 0); +  check_all_args(NULL, args, BIT_INT | BIT_STRING, 0);       if(TYPEOF(Pike_sp[-1]) == T_INT)    cw = (u_short)Pike_sp[-1].u.integer;    else    if(!strcmp(Pike_sp[-1].u.string->str, "play"))    cw = AUDIO_PLAY;    else    if(!strcmp(Pike_sp[-1].u.string->str, "pause"))    cw = AUDIO_PAUSE;    else
pike.git/src/modules/DVB/dvb.c:1633:    *!    *| @seealso    *| @[mute()]    */   static void f_audio_mixer(INT32 args) {       dvb_audio_data *dvb_audio = DVBAudio;    int ret;    audioMixer_t mixer;    -  check_all_args("DVB.dvb->audio_mixer", args, BIT_INT, BIT_INT | BIT_VOID, 0); +  check_all_args(NULL, args, BIT_INT, BIT_INT | BIT_VOID, 0);       mixer.volume_right = (unsigned int)Pike_sp[-1].u.integer;    Pike_sp--;    if(args > 1) {    mixer.volume_left = (unsigned int)Pike_sp[-1].u.integer;    Pike_sp--;    } else    mixer.volume_left = mixer.volume_right;       THREADS_ALLOW();
pike.git/src/modules/DVB/dvb.c:1783:    dvb_program = end_program();    add_program_constant("dvb", dvb_program, 0);       /* PES streams */    start_new_program();    ADD_STORAGE(dvb_stream_data);    set_init_callback(init_dvb_stream);    set_exit_callback(exit_dvb_stream);       ADD_FUNCTION("create", f_stream_create, tFunc(tObj tInt tOr(tFunction,tInt) tInt, tVoid), 0); -  ADD_FUNCTION("destroy", f_stream_detach, tFunc(tVoid,tVoid), 0); +  ADD_FUNCTION("_destruct", f_stream_detach, tFunc(tVoid,tVoid), 0);    ADD_FUNCTION("read", f_stream_read, tFunc(tOr(tInt,tVoid),tOr(tInt,tStr)),0);    ADD_FUNCTION("set_buffer", f_stream_set_buffer, tFunc(tInt,tInt), 0);    ADD_FUNCTION("info", f_stream_info, tFunc(tInt, tOr(tMapping,tInt)), 0);    ADD_FUNCTION("close", f_stream_close, tFunc(tVoid,tVoid), 0);       dvb_stream_program = end_program();    add_program_constant("Stream", dvb_stream_program, 0);       /* Audio */    start_new_program();
pike.git/src/modules/DVB/dvb.c:1823:    }    if(dvb_program) {    free_program(dvb_program);    dvb_program = NULL;    }   } /* PIKE_MODULE_EXIT */      #else      #include "program.h" - #include "module_support.h" +       PIKE_MODULE_INIT {    HIDE_MODULE();   }      PIKE_MODULE_EXIT {   }      #endif