示例#1
0
/* This function releases a previously claimed stream. It will take into
   account associated VBI streams. */
void cx18_release_stream(struct cx18_stream *s)
{
	struct cx18 *cx = s->cx;
	struct cx18_stream *s_assoc;

	s->id = -1;
	if (s->type == CX18_ENC_STREAM_TYPE_IDX) {
		/*
		 * The IDX stream is only used internally, and can
		 * only be indirectly unclaimed by unclaiming the MPG stream.
		 */
		return;
	}

	if (s->type == CX18_ENC_STREAM_TYPE_VBI &&
		test_bit(CX18_F_S_INTERNAL_USE, &s->s_flags)) {
		/* this stream is still in use internally */
		return;
	}
	if (!test_and_clear_bit(CX18_F_S_CLAIMED, &s->s_flags)) {
		CX18_DEBUG_WARN("Release stream %s not in use!\n", s->name);
		return;
	}

	cx18_flush_queues(s);

	/*
	 * CX18_ENC_STREAM_TYPE_MPG needs to release the
	 * CX18_ENC_STREAM_TYPE_VBI and/or CX18_ENC_STREAM_TYPE_IDX streams.
	 *
	 * For all other streams we're done.
	 */
	if (s->type != CX18_ENC_STREAM_TYPE_MPG)
		return;

	/* Unclaim the associated MPEG Index stream */
	s_assoc = &cx->streams[CX18_ENC_STREAM_TYPE_IDX];
	if (test_and_clear_bit(CX18_F_S_INTERNAL_USE, &s_assoc->s_flags)) {
		clear_bit(CX18_F_S_CLAIMED, &s_assoc->s_flags);
		cx18_flush_queues(s_assoc);
	}

	/* Unclaim the associated VBI stream */
	s_assoc = &cx->streams[CX18_ENC_STREAM_TYPE_VBI];
	if (test_and_clear_bit(CX18_F_S_INTERNAL_USE, &s_assoc->s_flags)) {
		if (s_assoc->id == -1) {
			/*
			 * The VBI stream is not still claimed by a file
			 * descriptor, so completely unclaim it.
			 */
			clear_bit(CX18_F_S_CLAIMED, &s_assoc->s_flags);
			cx18_flush_queues(s_assoc);
		}
	}
}
示例#2
0
/* This function releases a previously claimed stream. It will take into
   account associated VBI streams. */
static void cx18_release_stream(struct cx18_stream *s)
{
    struct cx18 *cx = s->cx;
    struct cx18_stream *s_vbi;

    s->id = -1;
    if (s->type == CX18_ENC_STREAM_TYPE_VBI &&
            test_bit(CX18_F_S_INTERNAL_USE, &s->s_flags)) {
        /* this stream is still in use internally */
        return;
    }
    if (!test_and_clear_bit(CX18_F_S_CLAIMED, &s->s_flags)) {
        CX18_DEBUG_WARN("Release stream %s not in use!\n", s->name);
        return;
    }

    cx18_flush_queues(s);

    /* CX18_ENC_STREAM_TYPE_MPG needs to release CX18_ENC_STREAM_TYPE_VBI,
       for all other streams we're done */
    if (s->type == CX18_ENC_STREAM_TYPE_MPG)
        s_vbi = &cx->streams[CX18_ENC_STREAM_TYPE_VBI];
    else
        return;

    /* clear internal use flag */
    if (!test_and_clear_bit(CX18_F_S_INTERNAL_USE, &s_vbi->s_flags)) {
        /* was already cleared */
        return;
    }
    if (s_vbi->id != -1) {
        /* VBI stream still claimed by a file descriptor */
        return;
    }
    clear_bit(CX18_F_S_CLAIMED, &s_vbi->s_flags);
    cx18_flush_queues(s_vbi);
}