예제 #1
0
파일: job.c 프로젝트: bbshocking/gstreamill
static void job_finalize (GObject *obj)
{
        Job *job = JOB (obj);
        GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);

        g_array_free (job->encoder_array, TRUE);

        G_OBJECT_CLASS (parent_class)->finalize (obj);
}
예제 #2
0
파일: thpool.c 프로젝트: JamieBeverley/Dirt
bool thpool_add_job(thpool_t* p, void *(*function)(void*), void* args) {
    bool res = jobqueue_push(p->queue, JOB(function, args));

    if (res) {
        pthread_mutex_lock(&p->update_mutex);
        pthread_cond_broadcast(&p->update_cv);
        pthread_mutex_unlock(&p->update_mutex);
    }

    return res;
}
예제 #3
0
파일: job.c 프로젝트: rongwj/gstreamill
static void job_set_property (GObject *obj, guint prop_id, const GValue *value, GParamSpec *pspec)
{
        g_return_if_fail (IS_JOB (obj));

        switch (prop_id) {
        case JOB_PROP_NAME:
                JOB (obj)->name = (gchar *)g_value_dup_string (value);
                break;

        case JOB_PROP_DESCRIPTION:
                JOB (obj)->description = (gchar *)g_value_dup_string (value);
                break;

        case JOB_PROP_EXEPATH:
                JOB (obj)->exe_path = (gchar *)g_value_dup_string (value);
                break;

        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
                break;
        }
}
예제 #4
0
파일: job.c 프로젝트: rongwj/gstreamill
static void job_finalize (GObject *obj)
{
        Job *job = JOB (obj);
        GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
        Encoder *encoder;
        gint i;

        /* free source  */
        g_object_unref (job->source);

        /* free encoders */
        for (i = 0; i < job->encoder_array->len; i++) {
                encoder = g_array_index (job->encoder_array, gpointer, i);
                g_object_unref (encoder);
        }
        g_array_free (job->encoder_array, TRUE);

        G_OBJECT_CLASS (parent_class)->finalize (obj);
}
예제 #5
0
파일: job.c 프로젝트: rongwj/gstreamill
static void job_get_property (GObject *obj, guint prop_id, GValue *value, GParamSpec *pspec)
{
        Job *job = JOB (obj);

        switch (prop_id) {
        case JOB_PROP_NAME:
                g_value_set_string (value, job->name);
                break;

        case JOB_PROP_DESCRIPTION:
                g_value_set_string (value, job->description);
                break;

        case JOB_PROP_EXEPATH:
                g_value_set_string (value, job->exe_path);
                break;

        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
                break;
        }
}
예제 #6
0
파일: job.c 프로젝트: rongwj/gstreamill
static void job_dispose (GObject *obj)
{
        Job *job = JOB (obj);
        GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
        JobOutput *output;
        gint i;
        gchar *name_hexstr;

        if (job->output == NULL) {
                return;
        }
        output = job->output;

        /* free semaphore */
        if (output->semaphore != NULL) {
                if (sem_close (output->semaphore) == -1) {
                        GST_ERROR ("sem_close failure: %s", g_strerror (errno));
                }
                if (sem_unlink (output->semaphore_name) == -1) {
                        GST_ERROR ("sem_unlink %s error: %s", job->name, g_strerror (errno));
                }
                g_free (output->semaphore_name);
        }

        /* free encoders output */
        if (job->is_live) {
                if (output->master_m3u8_playlist != NULL) {
                        g_free (output->master_m3u8_playlist);
                        for (i = 0; i < output->encoder_count; i++) {
                                if (output->encoders[i].record_path != NULL) {
                                        g_free (output->encoders[i].record_path);
                                }
                                m3u8playlist_free (output->encoders[i].m3u8_playlist);
                        }
                }
        }
        g_free (output->encoders);

        /* free share memory */
        if (job->output_fd != -1) {
                g_close (job->output_fd, NULL);
                if (munmap (output->job_description, job->output_size) == -1) {
                        GST_ERROR ("munmap %s error: %s", job->name, g_strerror (errno));
                }
                name_hexstr = unicode_file_name_2_shm_name (job->name);
                if (shm_unlink (name_hexstr) == -1) {
                        GST_ERROR ("shm_unlink %s error: %s", job->name, g_strerror (errno));
                }
                g_free (name_hexstr);
        }
        g_free (output);

        if (job->description != NULL) {
                g_free (job->description);
                job->description = NULL;
        }

        if (job->exe_path != NULL) {
                g_free (job->exe_path);
                job->exe_path = NULL;
        }

        if (job->name != NULL) {
                g_free (job->name);
                job->name = NULL;
        }

        G_OBJECT_CLASS (parent_class)->dispose (obj);
}
예제 #7
0
파일: job.c 프로젝트: bbshocking/gstreamill
static void job_dispose (GObject *obj)
{
        Job *job = JOB (obj);
        GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
        JobOutput *output;
        gint i;
        gchar *name, *name_hexstr;

        if (job->output == NULL) {
                return;
        }
        output = job->output;
        if (output->semaphore != NULL) {
                if (sem_close (output->semaphore) == -1) {
                        GST_ERROR ("sem_close failure: %s", g_strerror (errno));
                }
                if (sem_unlink (output->semaphore_name) == -1) {
                        GST_ERROR ("sem_unlink %s error: %s", job->name, g_strerror (errno));
                }
                g_free (output->semaphore_name);
        }
        for (i = 0; i < output->encoder_count; i++) {
                /* message queue release */
                name = g_strdup_printf ("/%s.%d", job->name, i);
                if ((output->encoders[i].mqdes != -1) && (mq_close (output->encoders[i].mqdes) == -1)) {
                        GST_ERROR ("mq_close %s error: %s", name, g_strerror (errno));
                }
                if ((output->encoders[i].mqdes != -1) && (mq_unlink (name) == -1)) {
                        GST_ERROR ("mq_unlink %s error: %s", name, g_strerror (errno));
                }
                if (job->is_live && (output->encoders[i].record_path != NULL)) {
                        g_free (output->encoders[i].record_path);
                }
                g_free (name);
        }
        /* share memory release */
        if (job->output_fd != -1) {
                g_close (job->output_fd, NULL);
                if (munmap (output->job_description, job->output_size) == -1) {
                        GST_ERROR ("munmap %s error: %s", job->name, g_strerror (errno));
                }
                name_hexstr = unicode_file_name_2_shm_name (job->name);
                if (shm_unlink (name_hexstr) == -1) {
                        GST_ERROR ("shm_unlink %s error: %s", job->name, g_strerror (errno));
                }
                g_free (name_hexstr);
        }
        g_free (output);

        if (job->name != NULL) {
                g_free (job->name);
                job->name = NULL;
        }

        if (job->description != NULL) {
                g_free (job->description);
                job->description = NULL;
        }

        if (job->exe_path != NULL) {
                g_free (job->exe_path);
                job->exe_path = NULL;
        }

        G_OBJECT_CLASS (parent_class)->dispose (obj);
}