コード例 #1
0
ファイル: utils.c プロジェクト: dluobo/ingex
void destroy_mutex(pthread_mutex_t* mutex)
{
    int err;

    if (mutex == NULL)
    {
        return;
    }

	if ((err = pthread_mutex_destroy(mutex)) != 0)
    {
        ml_log_warn("Failed to destroy mutex: %s\n", strerror(err));
    }
}
コード例 #2
0
ファイル: utils.c プロジェクト: dluobo/ingex
void destroy_cond_var(pthread_cond_t* cond)
{
    int err;

    if (cond == NULL)
    {
        return;
    }

    if ((err = pthread_cond_destroy(cond) != 0))
    {
        ml_log_warn("Failed to destroy conditional variable: %s\n", strerror(err));
    }
}
コード例 #3
0
ファイル: utils.c プロジェクト: dluobo/ingex
void cancel_and_join_thread(pthread_t* thread, void* data, void (*stop_func)(void*))
{
    int result;
    void* status;

    if (*thread != 0)
    {
        if (stop_func != NULL)
        {
            stop_func(data);
        }

        if ((result = pthread_cancel(*thread)) != 0)
        {
            ml_log_warn("Failed to cancel thread: %s\n", strerror(result));
        }

        if ((result = pthread_join(*thread, (void **)&status)) != 0)
        {
            ml_log_warn("Failed to join thread: %s\n", strerror(result));
        }
        *thread = 0;
    }
}
コード例 #4
0
ファイル: clip_source.c プロジェクト: dluobo/ingex
int cps_create(MediaSource* targetSource, const Rational* frameRate, int64_t start, int64_t duration, ClipSource** clipSource)
{
    ClipSource* newClipSource;

    if (start > 0 && !msc_seek(targetSource, start))
    {
        ml_log_warn("Failed to seek to start of the clip\n");
    }

    CALLOC_ORET(newClipSource, ClipSource, 1);

    newClipSource->targetSource = targetSource;
    newClipSource->start = (start < 0) ? 0 : start;
    newClipSource->duration = duration;
    newClipSource->frameRate = *frameRate; /* note: frameRate could be 0/0 */

    newClipSource->mediaSource.data = newClipSource;
    newClipSource->mediaSource.is_complete = cps_is_complete;
    newClipSource->mediaSource.post_complete = cps_post_complete;
    newClipSource->mediaSource.finalise_blank_source = cps_finalise_blank_source;
    newClipSource->mediaSource.get_num_streams = cps_get_num_streams;
    newClipSource->mediaSource.get_stream_info = cps_get_stream_info;
    newClipSource->mediaSource.set_frame_rate_or_disable = cps_set_frame_rate_or_disable;
    newClipSource->mediaSource.disable_stream = cps_disable_stream;
    newClipSource->mediaSource.disable_audio = cps_disable_audio;
    newClipSource->mediaSource.disable_video = cps_disable_video;
    newClipSource->mediaSource.stream_is_disabled = cps_stream_is_disabled;
    newClipSource->mediaSource.read_frame = cps_read_frame;
    newClipSource->mediaSource.is_seekable = cps_is_seekable;
    newClipSource->mediaSource.seek = cps_seek;
    newClipSource->mediaSource.seek_timecode = cps_seek_timecode;
    newClipSource->mediaSource.get_length = cps_get_length;
    newClipSource->mediaSource.get_position = cps_get_position;
    newClipSource->mediaSource.get_available_length = cps_get_available_length;
    newClipSource->mediaSource.eof = cps_eof;
    newClipSource->mediaSource.set_source_name = cps_set_source_name;
    newClipSource->mediaSource.set_clip_id = cps_set_clip_id;
    newClipSource->mediaSource.close = cps_close;
    newClipSource->mediaSource.get_buffer_state = cps_get_buffer_state;
    newClipSource->mediaSource.convert_position = cps_convert_position;

    *clipSource = newClipSource;
    return 1;
}
コード例 #5
0
ファイル: dv_stream_connect.c プロジェクト: UIKit0/bbc-ingex
void free_dv_decoder_resources()
{
    int i;
    DVDecoder* decoder = NULL;
    int refCount;

    if (g_decoderResourceRefCount <= 0)
    {
        return;
    }

    PTHREAD_MUTEX_LOCK(&g_decoderResource.resourceMutex);
    g_decoderResourceRefCount--;
    refCount = g_decoderResourceRefCount;
    PTHREAD_MUTEX_UNLOCK(&g_decoderResource.resourceMutex);

    if (refCount == 0)
    {
        if (g_decoderResource.numDecodersInUse > 0)
        {
            ml_log_warn("There are %d DV decoder resources still in use - please fix the source code\n",
                g_decoderResource.numDecodersInUse);
        }

        for (i = 0; i < g_decoderResource.numDecoders; i++)
        {
            /* set decoder NULL in list so that free doesn't just change it to !inUse */
            decoder = g_decoderResource.decoder[i];
            g_decoderResource.decoder[i] = NULL;

            free_dv_decoder(&decoder);
        }

        destroy_mutex(&g_decoderResource.resourceMutex);

        memset(&g_decoderResource, 0, sizeof(DVDecoderResource));
    }
}