void init_status_window (gboolean showWindow,char* glade_file) { if (liststore_lock == NULL) liststore_lock = g_mutex_new(); GtkBuilder* builder = gtk_builder_new (); if (!glade_file) gtk_builder_add_from_file (builder, PREFIX "/noside/ui/rchip_status_window.glade", NULL); else gtk_builder_add_from_file (builder, glade_file, NULL); window = GTK_WIDGET (gtk_builder_get_object (builder, "statusWindow")); gtk_window_set_icon_name(window,"rchip-server"); init_status_labels(builder); init_xml_labels(builder); g_mutex_lock(liststore_lock); status_liststore = GTK_LIST_STORE(gtk_builder_get_object(builder, "status_window_liststore")); g_mutex_unlock(liststore_lock); g_object_unref (G_OBJECT (builder)); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(window_destroyed), NULL); queue_function_data* func = g_malloc(sizeof(queue_function_data)); func->func = *load_liststore_from_file; func->data = NULL; func->priority = TP_NORMAL; g_async_queue_push_sorted(gui_async_queue,(gpointer)func,(GCompareDataFunc)sort_async_queue,NULL); if (showWindow) gtk_widget_show (window); }
static void ephy_history_service_send_message (EphyHistoryService *self, EphyHistoryServiceMessage *message) { EphyHistoryServicePrivate *priv = self->priv; g_async_queue_push_sorted (priv->queue, message, (GCompareDataFunc)sort_messages, NULL); }
void update_song_info() { /*if the dbus is active, do the following, else try and connect*/ if (Hosts != NULL) if (dbus_is_connected(TRUE)) { playing_info_music pInfo = dbus_get_playing_info_music(); print_playing_info_music(pInfo); hostname_node *hosts; g_mutex_lock(Hosts_lock); for_each_hostname(hosts){ song_info_data* info = g_malloc(sizeof(song_info_data)); info->pInfo.Artist = g_strdup(pInfo.Artist); info->pInfo.Album = g_strdup(pInfo.Album); info->pInfo.Song = g_strdup(pInfo.Song); info->pInfo.Duration = pInfo.Duration; info->pInfo.isPlaying = pInfo.isPlaying; info->hostname = g_strdup(hosts->hostname); queue_function_data* func = g_malloc(sizeof(queue_function_data)); func->func = *set_song_info_rest; func->data = (gpointer)info; func->priority = TP_NORMAL; g_async_queue_push_sorted(network_async_queue,(gpointer)func,(GCompareDataFunc)sort_async_queue,NULL); } g_mutex_unlock(Hosts_lock); if (pInfo.isPlaying){ if (g_strcmp0(pInfo.Artist,"")!=0){g_free(pInfo.Artist);} if (g_strcmp0(pInfo.Album,"") != 0){g_free(pInfo.Album);} if (g_strcmp0(pInfo.Song,"") != 0){g_free(pInfo.Song);} } } }
long moose_job_manager_send(MooseJobManager *jm, int priority, gpointer job_data) { if(jm == NULL) { return -1; } MooseJobManagerPrivate *priv = jm->priv; /* Create a new job, with a unique job-id */ MooseJob *job = moose_job_create(jm); job->priority = priority; job->job_data = job_data; /* Lock the current job structure, since it gets read in the main thread */ g_mutex_lock(&priv->current_job_mutex); { if(priv->current_job != NULL) { if(priv->current_job->priority > priority) { priv->current_job->cancel = TRUE; } } /* Remember the last sended job */ priv->last_send_job = job->id; } g_mutex_unlock(&priv->current_job_mutex); /* Push the item sorted with priority (small prio comes earlier) */ g_async_queue_push_sorted(priv->job_queue, job, moose_job_manager_prio_sort_func, NULL); /* Return the Job ID, so users can get the result later */ return job->id; }
static void enter_thread (gpointer data, gpointer user_data) { gint len; gint id; gulong ms; id = GPOINTER_TO_INT (data); ms = g_random_int_range (MIN_TIME * 1000, MAX_TIME * 1000); DEBUG_MSG (("entered thread with id:%d, adding to queue in:%ld ms", id, ms)); g_usleep (ms * 1000); if (SORT_QUEUE_ON_PUSH) { g_async_queue_push_sorted (async_queue, GINT_TO_POINTER (id), sort_compare, NULL); } else { g_async_queue_push (async_queue, GINT_TO_POINTER (id)); } len = g_async_queue_length (async_queue); DEBUG_MSG (("thread id:%d added to async queue (size:%d)", id, len)); }
static void gst_vtdec_session_output_callback (void *decompression_output_ref_con, void *source_frame_ref_con, OSStatus status, VTDecodeInfoFlags info_flags, CVImageBufferRef image_buffer, CMTime pts, CMTime duration) { GstVtdec *vtdec = (GstVtdec *) decompression_output_ref_con; GstVideoCodecFrame *frame = (GstVideoCodecFrame *) source_frame_ref_con; GstBuffer *buf; GstVideoCodecState *state; GST_LOG_OBJECT (vtdec, "got output frame %p %d and VT buffer %p", frame, frame->decode_frame_number, image_buffer); if (status != noErr) { GST_ERROR_OBJECT (vtdec, "Error decoding frame %d", (int) status); goto drop; } if (image_buffer == NULL) { if (info_flags & kVTDecodeInfo_FrameDropped) GST_DEBUG_OBJECT (vtdec, "Frame dropped by video toolbox"); else GST_DEBUG_OBJECT (vtdec, "Decoded frame is NULL"); goto drop; } /* FIXME: use gst_video_decoder_allocate_output_buffer */ state = gst_video_decoder_get_output_state (GST_VIDEO_DECODER (vtdec)); if (state == NULL) { GST_WARNING_OBJECT (vtdec, "Output state not configured, release buffer"); /* release as this usually means that the baseclass isn't ready to do * the QoS that _drop requires and will lead to an assertion with the * segment.format being undefined */ goto release; } buf = gst_core_video_buffer_new (image_buffer, &state->info, vtdec->texture_cache == NULL); gst_video_codec_state_unref (state); GST_BUFFER_PTS (buf) = pts.value; GST_BUFFER_DURATION (buf) = duration.value; frame->output_buffer = buf; g_async_queue_push_sorted (vtdec->reorder_queue, frame, sort_frames_by_pts, NULL); return; drop: GST_WARNING_OBJECT (vtdec, "Frame dropped %p %d", frame, frame->decode_frame_number); gst_video_decoder_drop_frame (GST_VIDEO_DECODER (vtdec), frame); return; release: GST_WARNING_OBJECT (vtdec, "Frame released %p %d", frame, frame->decode_frame_number); gst_video_decoder_release_frame (GST_VIDEO_DECODER (vtdec), frame); return; }
gboolean update_active_devices(gpointer data){ queue_function_data* func = g_malloc(sizeof(queue_function_data)); func->func = *get_active_devices; func->priority = TP_NORMAL; func->data = NULL; g_async_queue_push_sorted(network_async_queue,(gpointer)func,(GCompareDataFunc)sort_async_queue,NULL); return TRUE; }
void get_next_cmd() { /*uts.nodename is the hostname of the computer*/ struct utsname uts; uname( &uts ); queue_function_data* func = g_malloc(sizeof(queue_function_data)); func->func = *get_cmd_from_server; func->priority = TP_NORMAL; func->data = (gpointer)g_strdup(uts.nodename); g_async_queue_push_sorted(network_async_queue,(gpointer)func,(GCompareDataFunc)sort_async_queue,NULL); }
/** * Add a RSIoJob to be executed later * @param job A RSIoJob. This will be unreffed upon completion * @param idle_class A user defined variable, this can be used with rs_io_idle_cancel_class() to cancel a batch of queued reads * @param priority Lower value means higher priority * @param user_data A pointer to pass to the callback */ void rs_io_idle_add_job(RSIoJob *job, gint idle_class, gint priority, gpointer user_data) { g_return_if_fail(RS_IS_IO_JOB(job)); job->idle_class = idle_class; job->priority = priority; job->user_data = user_data; g_async_queue_push_sorted(queue, job, queue_sort, NULL); }
/** * ppg_task_render_schedule: * @task: (in): A #PpgTaskRender. * * Schedules a render task using our private task queue. * * Returns: None. * Side effects: None. */ static void ppg_task_render_schedule (PpgTask *task) { g_async_queue_push_sorted(task_queue, g_object_ref_sink(task), ppg_task_render_compare, NULL); #if MAX_THREADS == 1 if (!render_handler) { g_timeout_add(0, ppg_task_render_timeout, NULL); } #endif }
gpointer* add_folder_to_playqueue(gpointer* data){ /* this sets threw each folder recursivly and adds all file to playqueue (although it's really a list)*/ DIR *dp; struct dirent *ep; char *newDirFile; char* dirFile = (char*) data; if ((dp=opendir(dirFile))==NULL) { dirFile = replace_str(dirFile,get_setting_str(VIDEO_ROOT),"/mnt/raid/"); add_file_to_playqueue((gpointer*)dirFile); } else { while((ep=readdir(dp))) { queue_function_data* func = g_malloc(sizeof(queue_function_data)); if (!strcmp(ep->d_name,".") || !strcmp(ep->d_name, "..")) { continue; } newDirFile = g_strdup_printf("%s/%s", dirFile, ep->d_name); printf("Directory: %s",newDirFile); switch(file_type(newDirFile)){ case FTDIR: func->func = *add_folder_to_playqueue; func->data = g_strdup(newDirFile); func->priority = TP_NORMAL; g_async_queue_push_sorted(file_async_queue,(gpointer)func,(GCompareDataFunc)sort_async_queue,NULL); break; case FTFILE: newDirFile = replace_str(newDirFile,get_setting_str(VIDEO_ROOT),"/mnt/raid/"); func->func = *add_file_to_playqueue; func->data = g_strdup(newDirFile); func->priority = TP_NORMAL; g_async_queue_push_sorted(file_async_queue,(gpointer)func,(GCompareDataFunc)sort_async_queue,NULL); break; case FTDONOTPROC: break; } g_free(newDirFile); } closedir(dp); } return NULL; }
void window_destroyed(GtkWidget *widget, gpointer gdata){ g_mutex_lock(liststore_lock); if ( status_liststore != NULL ) { queue_function_data* func = g_malloc(sizeof(queue_function_data)); func->func = *save_liststore_to_file; func->priority = TP_NORMAL; func->data = NULL; g_async_queue_push_sorted(gui_async_queue,(gpointer)func,(GCompareDataFunc)sort_async_queue,NULL); } g_mutex_unlock(liststore_lock); window=NULL; }
static void gst_vtdec_session_output_callback (void *decompression_output_ref_con, void *source_frame_ref_con, OSStatus status, VTDecodeInfoFlags info_flags, CVImageBufferRef image_buffer, CMTime pts, CMTime duration) { GstVtdec *vtdec = (GstVtdec *) decompression_output_ref_con; GstVideoCodecFrame *frame = (GstVideoCodecFrame *) source_frame_ref_con; GstVideoCodecState *state; GST_LOG_OBJECT (vtdec, "got output frame %p %d and VT buffer %p", frame, frame->decode_frame_number, image_buffer); frame->output_buffer = NULL; if (status != noErr) { GST_ERROR_OBJECT (vtdec, "Error decoding frame %d", (int) status); } if (image_buffer) { GstBuffer *buf = NULL; /* FIXME: use gst_video_decoder_allocate_output_buffer */ state = gst_video_decoder_get_output_state (GST_VIDEO_DECODER (vtdec)); if (state == NULL) { GST_WARNING_OBJECT (vtdec, "Output state not configured, release buffer"); frame->flags &= VTDEC_FRAME_FLAG_SKIP; } else { buf = gst_core_video_buffer_new (image_buffer, &state->info, vtdec->texture_cache); gst_video_codec_state_unref (state); GST_BUFFER_PTS (buf) = pts.value; GST_BUFFER_DURATION (buf) = duration.value; frame->output_buffer = buf; } } else { if (info_flags & kVTDecodeInfo_FrameDropped) { GST_DEBUG_OBJECT (vtdec, "Frame dropped by video toolbox %p %d", frame, frame->decode_frame_number); frame->flags |= VTDEC_FRAME_FLAG_DROP; } else { GST_DEBUG_OBJECT (vtdec, "Decoded frame is NULL"); frame->flags |= VTDEC_FRAME_FLAG_SKIP; } } g_async_queue_push_sorted (vtdec->reorder_queue, frame, sort_frames_by_pts, NULL); }
/* insert command and command text into cmdQueue, once per hsotname*/ void send_cmd(char* cmd, char* cmdTxt, thread_priority priority) { print(cmd,cmdTxt,DEBUG); hostname_node *hosts; g_mutex_lock(Hosts_lock); for_each_hostname(hosts){ queue_function_data* func = g_malloc(sizeof(queue_function_data)); command_data* data = g_malloc(sizeof(command_data)); data->command = g_strdup(cmd); data->command_text = g_strdup(cmdTxt); data->hostname = g_strdup(hosts->hostname); func->func = *send_cmd_to_server; func->priority = priority; func->data = (gpointer)data; g_async_queue_push_sorted(network_async_queue,(gpointer)func,(GCompareDataFunc)sort_async_queue,NULL); } g_mutex_unlock(Hosts_lock); }