static void vc_destroy(vdpau_codec_t *vc) { vc_cleanup(vc); assert(TAILQ_FIRST(&vc->vc_vvs_alloc) == NULL); free(vc); }
/** Deallocate the memory that was allocated by rwlock_initialize(). */ static void rwlock_cleanup(struct rwlock_info* p) { struct rwlock_thread_info* q; tl_assert(p); if (s_trace_rwlock) { VG_(message)(Vg_UserMsg, "[%d/%d] rwlock_destroy 0x%lx", VG_(get_running_tid)(), thread_get_running_tid(), p->a1); } if (rwlock_is_locked(p)) { RwlockErrInfo REI = { p->a1 }; VG_(maybe_record_error)(VG_(get_running_tid)(), RwlockErr, VG_(get_IP)(VG_(get_running_tid)()), "Destroying locked rwlock", &REI); } VG_(OSetGen_ResetIter)(p->thread_info); for ( ; (q = VG_(OSetGen_Next)(p->thread_info)); q++) { vc_cleanup(&q->vc); } VG_(OSetGen_Destroy)(p->thread_info); }
void sg_cleanup(Segment* const sg) { tl_assert(sg); vc_cleanup(&sg->vc); bm_delete(sg->bm); sg->bm = 0; }
/** * Discard all segments that have a defined order against the latest vector * clock of every thread -- these segments can no longer be involved in a * data race. */ static void thread_discard_ordered_segments(void) { unsigned i; VectorClock thread_vc_min; s_discard_ordered_segments_count++; vc_init(&thread_vc_min, 0, 0); thread_compute_minimum_vc(&thread_vc_min); if (sg_get_trace()) { char msg[256]; VectorClock thread_vc_max; vc_init(&thread_vc_max, 0, 0); thread_compute_maximum_vc(&thread_vc_max); VG_(snprintf)(msg, sizeof(msg), "Discarding ordered segments -- min vc is "); vc_snprint(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg), &thread_vc_min); VG_(snprintf)(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg), ", max vc is "); vc_snprint(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg), &thread_vc_max); VG_(message)(Vg_UserMsg, "%s", msg); vc_cleanup(&thread_vc_max); } for (i = 0; i < sizeof(s_threadinfo) / sizeof(s_threadinfo[0]); i++) { Segment* sg; Segment* sg_next; for (sg = s_threadinfo[i].first; sg && (sg_next = sg->next) && vc_lte(&sg->vc, &thread_vc_min); sg = sg_next) { thread_discard_segment(i, sg); } } vc_cleanup(&thread_vc_min); }
/** Deallocate the memory that was allocated by mutex_initialize(). */ static void mutex_cleanup(struct mutex_info* p) { if (s_trace_mutex) { VG_(message)(Vg_UserMsg, "[%d/%d] mutex_destroy %s 0x%lx", VG_(get_running_tid)(), thread_get_running_tid(), mutex_get_typename(p), p->a1); } if (mutex_is_locked(p)) { MutexErrInfo MEI = { p->a1, p->recursion_count, p->owner }; VG_(maybe_record_error)(VG_(get_running_tid)(), MutexErr, VG_(get_IP)(VG_(get_running_tid)()), "Destroying locked mutex", &MEI); } vc_cleanup(&p->vc); }
int main (int argc, char *argv[]) { int opt; int quiet = 0; /* Initialize the app_data structure */ vc_init_data(&app_data); /* Parse command line */ while ((opt = getopt(argc, argv, "dqs:h")) != -1) { switch (opt) { case 'd': /* Daemonize - do not open /dev/stdin */ app_data.daemonize = 1; break; case 'q': /* Quiet - do not print startup messages */ quiet = 1; break; case 's': /* Server IP address */ strcpy(app_data.cfg.server_ip_addr, optarg); break; case 'h': default: /* '?' */ vs_print_help(); return 0; } } if(!strlen(app_data.cfg.server_ip_addr)){ vs_print_help(); return 0; } if(!quiet){ printf("glivec - Gstreamer Live Example Client \n" "(C) John Weber, Avnet Electronics Marketing\n"); } /* Initialize configuration data */ app_data.cfg.rtp_recv_port = DEFAULT_RX_RTP_PORT; app_data.cfg.rtcp_send_port = DEFAULT_TX_RTCP_PORT; app_data.cfg.rtcp_recv_port = DEFAULT_RX_RTCP_PORT; app_data.cfg.server_port = DEFAULT_SERVER_PORT; printf( "Server IP address: %s\n" "Server port: %d\n" "Sending RTP data on port: %d\n" "Sending RTCP data on port: %d\n" "Expecting RTCP data on port: %d\n", app_data.cfg.server_ip_addr, app_data.cfg.server_port, app_data.cfg.rtp_recv_port, app_data.cfg.rtcp_send_port, app_data.cfg.rtcp_recv_port); /* Setup the file descriptors for polling, starting with /dev/stdin */ if(!app_data.daemonize){ app_data.fds[FD_INDEX_STDIN].fd = open("/dev/stdin", O_RDONLY); if( app_data.fds[FD_INDEX_STDIN].fd == -1) { printf("Error opening /dev/stdin for reading\n"); return -1; } app_data.fds[FD_INDEX_STDIN].events = POLLIN; } else { printf("glivec starting as background task.\n"); } if(link_init_as_client((char*)app_data.cfg.server_ip_addr, app_data.cfg.server_port) < 0){ debug_printf("%s: Failed to init link as client\n", __func__); return -1; } /* Initialization */ gst_init (&argc, &argv); vc_sigint_setup(); /* Main Loop */ printf ("Running...\n"); vc_mainloop(&app_data); /* Out of the main loop, clean up nicely */ printf ("Returned, stopping playback\n"); return vc_cleanup(&app_data); }