static void pvr2_dvb_stream_end(struct pvr2_dvb_adapter *adap) { unsigned int idx; struct pvr2_stream *stream; if (adap->thread) { kthread_stop(adap->thread); adap->thread = NULL; } if (adap->channel.stream) { stream = adap->channel.stream->stream; } else { stream = NULL; } if (stream) { pvr2_hdw_set_streaming(adap->channel.hdw, 0); pvr2_stream_set_callback(stream, NULL, NULL); pvr2_stream_kill(stream); pvr2_stream_set_buffer_count(stream, 0); pvr2_channel_claim_stream(&adap->channel, NULL); } if (adap->stream_run) { for (idx = 0; idx < PVR2_DVB_BUFFER_COUNT; idx++) { if (!(adap->buffer_storage[idx])) continue; kfree(adap->buffer_storage[idx]); adap->buffer_storage[idx] = NULL; } adap->stream_run = 0; } }
static void pvr2_channel_disclaim_stream(struct pvr2_channel *cp) { if (!cp->stream) return; pvr2_stream_kill(cp->stream->stream); cp->stream->user = NULL; cp->stream = NULL; }
int pvr2_ioread_setup(struct pvr2_ioread *cp,struct pvr2_stream *sp) { int ret; unsigned int idx; struct pvr2_buffer *bp; mutex_lock(&cp->mutex); do { if (cp->stream) { pvr2_trace(PVR2_TRACE_START_STOP, "/*---TRACE_READ---*/ pvr2_ioread_setup (tear-down) id=%p", cp); pvr2_ioread_stop(cp); pvr2_stream_kill(cp->stream); if (pvr2_stream_get_buffer_count(cp->stream)) { pvr2_stream_set_buffer_count(cp->stream,0); } cp->stream = NULL; } if (sp) { pvr2_trace(PVR2_TRACE_START_STOP, "/*---TRACE_READ---*/ pvr2_ioread_setup (setup) id=%p", cp); pvr2_stream_kill(sp); ret = pvr2_stream_set_buffer_count(sp,BUFFER_COUNT); if (ret < 0) { mutex_unlock(&cp->mutex); return ret; } for (idx = 0; idx < BUFFER_COUNT; idx++) { bp = pvr2_stream_get_buffer(sp,idx); pvr2_buffer_set_buffer(bp, cp->buffer_storage[idx], BUFFER_SIZE); } cp->stream = sp; } } while (0); mutex_unlock(&cp->mutex); return 0; }
static void pvr2_ioread_stop(struct pvr2_ioread *cp) { if (!(cp->enabled)) return; pvr2_trace(PVR2_TRACE_START_STOP, "/*---TRACE_READ---*/ pvr2_ioread_stop id=%p",cp); pvr2_stream_kill(cp->stream); cp->c_buf = NULL; cp->c_data_ptr = NULL; cp->c_data_len = 0; cp->c_data_offs = 0; cp->enabled = 0; cp->stream_running = 0; cp->spigot_open = 0; if (cp->sync_state) { pvr2_trace(PVR2_TRACE_DATA_FLOW, "/*---TRACE_READ---*/ sync_state <== 0"); cp->sync_state = 0; } }