int32_t coolapi_open_device (int32_t demux_index, int32_t demux_id) { dmx_t * dmx; coolapi_open(); dmx = find_demux(0, demux_index); if(!dmx) { cs_log("no free demux found"); return 0; } if (!ll_cool_filter) ll_cool_filter = ll_create("ll_cool_filter"); if (!ll_cool_chanhandle) ll_cool_chanhandle = ll_create("ll_cool_chanhandle"); dmx->demux_index = demux_index; dmx->demux_id = demux_id; dmx->pid = -1; dmx->device = dmx_device[demux_index]; dmx->opened = 1; pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK_NP); pthread_mutex_init(&dmx->mutex, &attr); return dmx->fd; }
int32_t coolapi_open_device (int32_t demux_index, int32_t demux_id) { int32_t result = 0; buffer_open_arg_t bufarg; channel_open_arg_t chanarg; int32_t uBufferSize = 8256; dmx_t * dmx; coolapi_open(); dmx = find_demux(0, demux_index); if(dmx == 0) { cs_log("no free demux found"); return 0; } dmx->demux_index = demux_index; dmx->demux_id = demux_id; dmx->pid = -1; memset(&bufarg, 0, sizeof(bufarg)); dmx->device = dmx_device[demux_index]; dmx->opened = true; bufarg.type = 3; bufarg.size = uBufferSize; bufarg.unknown3 = (uBufferSize * 7) / 8; result = cnxt_cbuf_open(&dmx->buffer1, &bufarg, NULL, NULL); check_error ("cnxt_cbuf_open", result); bufarg.type = 0; result = cnxt_cbuf_open(&dmx->buffer2, &bufarg, NULL, NULL); check_error ("cnxt_cbuf_open", result); memset(&chanarg, 0, sizeof(channel_open_arg_t)); chanarg.type = 4; result = cnxt_dmx_channel_open(dmx->device, &dmx->channel, &chanarg, dmx_callback, dmx); check_error ("cnxt_dmx_channel_open", result); result = cnxt_dmx_set_channel_buffer(dmx->channel, 0, dmx->buffer1); check_error ("cnxt_dmx_set_channel_buffer", result); result = cnxt_dmx_channel_attach(dmx->channel, 0xB, 0, dmx->buffer2); check_error ("cnxt_dmx_channel_attach", result); result = cnxt_cbuf_attach(dmx->buffer2, 2, dmx->channel); check_error ("cnxt_cbuf_attach", result); pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK_NP); pthread_mutex_init(&dmx->mutex, &attr); cs_debug_mask(D_DVBAPI, "fd %08x demux #%d demux_id %d channel %x", dmx->fd, demux_index, demux_id, (int) dmx->channel); return dmx->fd; }