int main() { THREADING_init_main_thread_type(); assert(THREADING_is_main_thread()); assert(!THREADING_is_player_thread()); pthread_create(&thread, NULL, player_thread_func, NULL); sleep(1); assert(THREADING_is_main_thread()); assert(!THREADING_is_player_thread()); void *retval; pthread_join(thread, &retval); assert(retval==&thread); sleep(3); assert(THREADING_is_main_thread()); assert(!THREADING_is_player_thread()); printf("\n\n\n == Threading test success == \n"); return 0; }
void *tracker_alloc__(size_t size,void *(*AllocFunction)(size_t size2), const char *filename, int linenumber){ allocated+=size; R_ASSERT(THREADING_is_main_thread()); R_ASSERT(!PLAYER_current_thread_has_lock()); #ifndef DISABLE_BDWGC # ifdef _AMIGA return (*GC_amiga_allocwrapper_do)(size,AllocFunction); # else # if !defined(VALIDATE_MEM) void *ret = AllocFunction(size); # else void *ret = V_alloc(AllocFunction,size,filename,linenumber); void *actual_mem_start = V_allocated_mem_real_start(ret); #if defined(RELEASE) #error "oh no" #endif GC_register_finalizer_ignore_self(actual_mem_start, gcfinalizer, NULL, NULL, NULL); # endif # endif return ret; #else return OS_getmem(size); // For debugging. (wrong use of GC_malloced memory could be very difficult to trace) #endif }
void PC_StopPause(struct Tracker_Windows *window){ R_ASSERT(THREADING_is_main_thread()); g_pausing_level--; if (g_pausing_level < 0){ R_ASSERT(g_pausing_level < 0); g_pausing_level = 0; } //printf(" Leaving pause %d\n", g_pausing_level); if (g_pausing_level>0) return; if (window==NULL) window = root->song->tracker_windows; if (g_was_playing) { if (g_was_playing_range) PlayRangeCurrPos(window); else if (g_playtype==PLAYSONG) PlaySongCurrPos(window); else if (g_playtype==PLAYBLOCK) PlayBlockCurrPos(window); } }
// Note that it's perfectly fine calling PlayStop() between calling PC_Pause and PC_StopPause. PC_StopPause will still work as it's supposed to. void PC_Pause(void){ R_ASSERT(THREADING_is_main_thread()); //printf(" 000 Enter pause %d\n", g_pausing_level); g_pausing_level++; //printf(" Enter pause %d\n", g_pausing_level); if (g_pausing_level > 1) return; g_was_playing = false; g_playtype = 0; g_was_playing_range = false; if (is_playing()){ if(ATOMIC_GET(is_starting_up)==false){ struct Tracker_Windows *window = root->song->tracker_windows; window->message = "Temporarily stopping player"; window->message_duration_left = 100; } g_playtype = pc->playtype; g_was_playing_range = pc->is_playing_range; PlayStop(); g_was_playing = true; } }
void CRASHREPORTER_send_assert_message(Crash_Type crash_type, const char *fmt,...){ static bool is_currently_sending = false; #if 0 static int last_time = -10000; if ( last_time < (running_time.elapsed()-(30*1000))) return; last_time = running_time.elapsed(); #endif if (is_currently_sending) return; char message[1000]; va_list argp; va_start(argp,fmt); /* vfprintf(stderr,fmt,argp); */ vsprintf(message,fmt,argp); va_end(argp); if (g_crashreporter_file!=NULL) { if (!g_crashreporter_file->open()){ SYSTEM_show_message("Unable to create temprary file. Disk may be full"); send_crash_message_to_server(message, get_plugin_names(), NOEMERGENCYSAVE, crash_type); goto exit; } if (false==file_is_empty(g_crashreporter_file)) { g_crashreporter_file->close(); goto exit; } g_crashreporter_file->close(); } is_currently_sending = true; RT_request_to_stop_playing(); RT_pause_plugins(); CRASHREPORTER_send_message_with_backtrace(message, crash_type); #if 0 if (may_do_blocking && THREADING_is_main_thread()) send_crash_message_to_server(message, g_plugin_name, false); else{ const char *messages[1] = {message}; CRASHREPORTER_send_message(messages, 1, false); } #endif exit: is_currently_sending = false; }
void EVENTLOG_add_event(const char *log_entry){ R_ASSERT(THREADING_is_main_thread()); g_event_log[g_event_pos] = log_entry; g_event_pos++; if (g_event_pos==NUM_EVENTS) g_event_pos = 0; }
static void add_svg_ready(Devdata *devdata, bool success){ R_ASSERT(THREADING_is_main_thread()); radium::FAUST_calledRegularlyByParentReply &ready = devdata->ready; ready.has_new_data = true; ready.svg_is_ready = true; ready.svg_succeeded = success; }
static void *player_thread_func(void* arg) { THREADING_init_player_thread_type(); assert(!THREADING_is_main_thread()); assert(THREADING_is_player_thread()); sleep(2); return &thread; }