/** * check Video Loss * * register * R101[0] * * oldname: CheckDecoderVDLOSS(). * * @param n: wait counter * @return * 0:Video detected * 1:Video not present. Video Loss */ BYTE DecoderCheckVDLOSS( BYTE n ) { volatile BYTE mode; BYTE start; dPrintf("\nDecoderCheckVDLOSS(%d) start",(WORD)n); start = n; WriteTW88Page(PAGE1_DECODER ); while (n--) { mode = ReadTW88(REG101); //read Chip Status if (( mode & 0x80 ) == 0 ) { dPrintf("->end%bd",start - n); return ( 0 ); //check video detect flag } delay1ms(10); } ePrintf("\nDecoderCheckVDLOSS->fail"); return ( 1 ); //fail. We loss the Video }
int rbuf::get_size() { #if DBG dPrintf("()"); #endif pthread_mutex_lock(&mutex); int ret = __get_size(); pthread_mutex_unlock(&mutex); return ret; }
int output::__add(char* target, map_pidtype &pids) { int search_id = search(target); if (search_id >= 0) { dPrintf("target already exists #%d: %s", search_id, target); return search_id; } int target_id = num_targets; dPrintf("(%d->%s)", target_id, target); /* push data into output buffer */ int ret = output_streams[target_id].add(target, pids); if (ret == 0) num_targets++; else dPrintf("failed to add target #%d: %s", target_id, target); dPrintf("~(%d->%s)", target_id, target); return (ret == 0) ? target_id : ret; }
void CDomiServer::showToConsole(const char* pFormat, ...){ if (!pFormat || !*pFormat) return; char szStrint[2048] = { 0 }; va_list argptr; va_start(argptr, pFormat); dVsprintf(szStrint, sizeof(szStrint), pFormat, argptr); va_end(argptr); CConsoleColor clColor(_BIT32(CConsoleColor::color_green) | _BIT32(CConsoleColor::color_intensity)); dPrintf("%s\n", szStrint); }
int output_stream::start() { if (f_streaming) { dPrintf("(%d) already streaming", sock); return 0; } if ((sock < 0) && ((stream_method != OUTPUT_STREAM_FUNC) && (stream_method != OUTPUT_STREAM_INTF) && (stream_method != OUTPUT_STREAM_STDOUT))) return sock; dPrintf("(%d)", sock); ringbuffer.set_capacity(OUTPUT_STREAM_BUF_SIZE); int ret = pthread_create(&h_thread, NULL, output_stream_thread, this); if (0 != ret) perror("pthread_create() failed"); return ret; }
void rbuf::set_capacity(int cap) { dPrintf("(%d)", cap); pthread_mutex_lock(&mutex); if (p_data) delete[] p_data; p_data = new char[(capacity = cap)]; __reset(); pthread_mutex_unlock(&mutex); }
rbuf& rbuf::operator= (const rbuf& cSource) { dPrintf("(operator=)"); if (this == &cSource) return *this; p_data = NULL; capacity = 0; idx_read = 0; idx_write = 0; return *this; }
int output::add(void* priv, stream_callback callback, map_pidtype &pids) { if ((callback) && (priv)) { int search_id = search(priv, callback); if (search_id >= 0) { dPrintf("target callback already exists #%d", search_id); return search_id; } int target_id = num_targets; /* push data into output buffer */ int ret = output_streams[target_id].add(priv, callback, pids); if (ret == 0) num_targets++; else dPrintf("failed to add target #%d", target_id); dPrintf("~(%d->FUNC)", target_id); return (ret == 0) ? target_id : ret; } return -1; }
int output::add(output_stream_iface *iface, map_pidtype &pids) { if (iface) { int search_id = search(iface); if (search_id >= 0) { dPrintf("target interface already exists #%d", search_id); return search_id; } int target_id = num_targets; /* push data into output buffer */ int ret = output_streams[target_id].add(iface, pids); if (ret == 0) num_targets++; else dPrintf("failed to add target #%d", target_id); dPrintf("~(%d->INTF)", target_id); return (ret == 0) ? target_id : ret; } return -1; }
int output::add(int socket, unsigned int method, map_pidtype &pids) { if (socket >= 0) { int search_id = search(socket, method); if (search_id >= 0) { dPrintf("target socket already exists #%d", search_id); return search_id; } int target_id = num_targets; /* push data into output buffer */ int ret = output_streams[num_targets].add(socket, method, pids); if (ret == 0) num_targets++; else dPrintf("failed to add target #%d", target_id); dPrintf("~(%d->SOCKET[%d])", target_id, socket); return (ret == 0) ? target_id : ret; } return -1; }
void rbuf::dealloc() { dPrintf("()"); pthread_mutex_lock(&mutex); if (p_data) delete[] p_data; p_data = NULL; capacity = 0; __reset(); pthread_mutex_unlock(&mutex); }
int main(int argc, const char * argv[]) { LinkN *null = NULL; LinkN **head = &null; const size_t COUNT = 37; size_t *data = SafeMalloc(COUNT * sizeof(size_t)), i; LinkN *nodes = SafeMalloc(COUNT * sizeof(LinkN)); rb_red_blk_tree tree; RBTreeInit(&tree, &pointerDiff, NULL, &RBNodeAlloc); for(i = 0; i < COUNT; i++){ data[i] = i; nodes[i].data = data + i; linkFront(head, nodes + i); } dumpList(head); mergeSort(head, &csT); dumpList(head); qsort(data, 0, COUNT, &qsCompare); dumpArray(data, COUNT); for(i = 0; i < COUNT; i++){ RBSetAdd(&tree, data + i); } dumpSet(&tree); dPrintf(("%p - %p = " PDF " ?= (-1 * " PDF ")\n",(void*)&data[2],(void*)&data[3],(&data[2] - &data[3]),(&data[3] - &data[2]))); dPrintf(("\t ?= %d ?= (-1 * %d)\n",pointerDiff(&data[2], &data[3]),pointerDiff(&data[3], &data[2]))); free(nodes); free(data); return 0; }
bool desc::service(dvbpsi_descriptor_t* p_descriptor) { if (p_descriptor->i_tag != DT_Service) return false; dvbpsi_service_dr_t* dr = dvbpsi_DecodeServiceDr(p_descriptor); if (desc_dr_failed(dr)) return false; get_descriptor_text(dr->i_service_provider_name, dr->i_service_provider_name_length, provider_name); get_descriptor_text(dr->i_service_name, dr->i_service_name_length, service_name); dPrintf("%s, %s", provider_name, service_name); return true; }
bool desc::short_event(dvbpsi_descriptor_t* p_descriptor) { if (p_descriptor->i_tag != DT_ShortEvent) return false; dvbpsi_short_event_dr_t* dr = dvbpsi_DecodeShortEventDr(p_descriptor); if (desc_dr_failed(dr)) return false; memcpy(_4d.lang, dr->i_iso_639_code, 3); get_descriptor_text(dr->i_event_name, dr->i_event_name_length, _4d.name); get_descriptor_text(dr->i_text, dr->i_text_length, _4d.text); dPrintf("%s, %s, %s", _4d.lang, _4d.name, _4d.text); return true; }
void transformData(const Transformation *txForm, const Point *srcGeometry, Point *dstGeometry, size_t pointCount){ const TransformationF f = txForm->f; const void* state = txForm->state; size_t i; for(i = 0; i < pointCount; ++i){ f(srcGeometry + i, dstGeometry + i, state); dPrintf(("(%f, %f, %f) -> (%f, %f, %f))\n", srcGeometry[i].x, srcGeometry[i].y, srcGeometry[i].z, dstGeometry[i].x, dstGeometry[i].y, dstGeometry[i].z)); } }
void ClearOSDInfo(void) { BYTE dt; dt = DisplayedOSD; #ifdef DEBUG_OSD dPrintf("\r\nClearOSDInfo: DisplayedOSD:%2x",(WORD) DisplayedOSD); #endif if( (dt & FOSD_TVVOL) || ( dt & FOSD_TVCHN) ) ClearTVInfo(); if( dt & FOSD_MUTE ) ClearMuteInfo(); if( dt & FOSD_INPUTINFO ) FOsdClearInput(); if( dt & FOSD_MENU ) FOsdMenuClose(); if( dt & FOSD_PCINFO ) ClearPCInfo(); }
bool output_stream::drain() { dPrintf("(%d)", sock); if (!f_streaming) return false; while ((f_streaming) && (ringbuffer.get_capacity())) usleep(20*1000); #if !defined(_WIN32) fsync(sock); #endif return (!f_streaming); }
//-------------------------------------- bool PlatformAssert::processAssert(Type assertType, const char *filename, U32 lineNumber, const char *message) { if (platformAssert) return platformAssert->process(assertType, filename, lineNumber, message); else // when platAssert NULL (during _start/_exit) try direct output... dPrintf("\n%s: (%s @ %ld) %s\n", typeName[assertType], filename, lineNumber, message); // this could also be platform-specific: OutputDebugString on PC, DebugStr on Mac. // Will raw printfs do the job? In the worst case, it's a break-pointable line of code. // would have preferred Con but due to race conditions, it might not be around... // Log::errorf(LogEntry::Assert, "%s: (%s @ %ld) %s", typeName[assertType], filename, lineNumber, message); return true; }
output::output(const output&) { dPrintf("(copy)"); #if !defined(_WIN32) h_thread = (pthread_t)NULL; #endif f_kill_thread = false; f_streaming = false; num_targets = 0; options = OUTPUT_NONE; count_in = 0; count_out = 0; memset(&ringbuffer, 0, sizeof(ringbuffer)); output_streams.clear(); }
output::output() : #if !defined(_WIN32) h_thread((pthread_t)NULL) , #endif f_kill_thread(false) , f_streaming(false) , ringbuffer() , num_targets(0) , options(OUTPUT_NONE) , count_in(0) , count_out(0) { dPrintf("()"); output_streams.clear(); }
////////////////////////////////////////////////////////////////////////// // static // windows 的messagebox void CServerRoot::messageBoxOK(const char* pCaption,const char* pText,...) { char szStrint[2048] = {0}; if (pText) { va_list argptr; va_start(argptr,pText); dVsprintf(szStrint,sizeof(szStrint),pText,argptr); va_end(argptr); } CConsoleColor clColor(_BIT32(CConsoleColor::color_blue)|_BIT32(CConsoleColor::color_intensity)); dPrintf("message>%s:%s\n",pCaption ? pCaption : "",szStrint); #ifdef WIN32 ::ShowCursor(true); ::MessageBox(nullptr,szStrint,pCaption, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OK); #endif }
//----------------------------------------------------------------------------- static void SignalHandler(int sigtype) { if (sigtype == SIGSEGV || sigtype == SIGTRAP) { signal(SIGSEGV, SIG_DFL); signal(SIGTRAP, SIG_DFL); // restore the signal handling to default so that we don't get into // a crash loop with ImmediateShutdown ImmediateShutdown(-sigtype, sigtype); } else { signal(sigtype, SIG_DFL); dPrintf("Unknown signal caught by SignalHandler: %d\n", sigtype); // exit to be safe ImmediateShutdown(1); } }
void output::stop() { dPrintf("()"); stop_without_wait(); /* call stop_without_wait() on everybody first before we call stop() on everybody, which is a blocking function */ for (output_stream_map::iterator iter = output_streams.begin(); iter != output_streams.end(); ++iter) iter->second.stop_without_wait(); for (output_stream_map::iterator iter = output_streams.begin(); iter != output_streams.end(); ++iter) iter->second.stop(); while (f_streaming) usleep(20*1000); return; }
bool desc::_lcn(dvbpsi_descriptor_t* p_descriptor) { #if DVBPSI_SUPPORTS_DR_81_86_A0_A1 if (p_descriptor->i_tag != DT_LogicalChannelNumber) return false; dvbpsi_lcn_dr_t* dr = dvbpsi_DecodeLCNDr(p_descriptor); if (desc_dr_failed(dr)) return false; for (int i = 0; i < dr->i_number_of_entries; i ++) { #if 0 = lcn->p_entries[i].i_service_id; = lcn->p_entries[i].i_logical_channel_number; #else lcn[dr->p_entries[i].i_service_id] = dr->p_entries[i].i_logical_channel_number; dPrintf("%d, %d", dr->p_entries[i].i_service_id, lcn[dr->p_entries[i].i_service_id]); #endif }
bool desc::freq_list(dvbpsi_descriptor_t* p_descriptor) { #if DVBPSI_SUPPORTS_DR_81_86_A0_A1 if (p_descriptor->i_tag != DT_FrequencyList) return false; dvbpsi_frequency_list_dr_t* dr = dvbpsi_DecodeFrequencyListDr(p_descriptor); if (desc_dr_failed(dr)) return false; for (int i = 0; i < dr->i_number_of_frequencies; ++i) { #if 0 = dr->p_center_frequencies[i] #else dPrintf("%d", dr->p_center_frequencies[i]); #endif } #endif return true; }
output_stream::output_stream(const output_stream&) { dPrintf("(copy)"); #if !defined(_WIN32) h_thread = (pthread_t)NULL; #endif f_kill_thread = false; f_streaming = false; m_iface = NULL; stream_cb = NULL; stream_cb_priv = NULL; count_in = 0; count_out = 0; sock = -1; mimetype = MIMETYPE_OCTET_STREAM; stream_method = OUTPUT_STREAM_UDP; memset(&name, 0, sizeof(name)); priv = NULL; pids.clear(); have_pat = false; }
//code WORD LOGO_COLOR_8[16] = { // 0xFFFF,0x0020,0xDEDB,0xA534,0x6B6D,0xC826,0x4A49,0xDCD5, // 0xFFFF,0xC806,0xC98C,0xCB31,0xFE79,0xFCD9,0xCCD4,0xE71C //}; //------------------------------------------------------------------- // Display/Clear FOSD LOGO //------------------------------------------------------------------- void DisplayLogo(void) { #ifdef SUPPORT_8BIT_CHIP_ACCESS BYTE page; #endif BYTE i; ReadTW88Page(page); InitFOsdMenuWindow(Init_Osd_DisplayLogo); #ifdef ADD_ANALOGPANEL if(IsAnalogOn()) InitFOsdMenuWindow(Init_Osd_DisplayLogo_A); #endif InitFontRamByNum(FONT_NUM_LOGO, 0); //FOsdDownloadFont(2); FOsdSetPaletteColorArray(0, LOGO_COLOR_8, 16, 1); WriteTW88Page(PAGE4_CLOCK); dPrintf("\nDisplayLogo-Current MCU SPI Clock select : [0x4E0]=0x%02bx, [0x4E1]=0x%02bx", ReadTW88(REG4E0), ReadTW88(REG4E1)); WriteTW88Page(PAGE3_FOSD ); WriteTW88(REG304, ReadTW88(REG304)&0xFE); // OSD RAM Auto Access Enable WriteTW88(REG304, (ReadTW88(REG304)&0xF3)); // Normal for ( i=0; i<70; i++ ) { WriteTW88(REG306, i ); WriteTW88(REG307, i*3 ); WriteTW88(REG308, (i / 42)*2 ); } WriteTW88(REG30B, 0 ); // 2bit multi color start = 0 WriteTW88(REG_FOSD_MADD3, 0 ); // 3bit multi color start = 0 WriteTW88(REG_FOSD_MADD4, 0xff ); // 4bit multi color start = 0 FOsdWinEnable(TECHWELLOGO_OSDWIN,TRUE); FOsdWinEnable(TECHWELLOGO_OSDWIN+1,FALSE); FOsdWinEnable(TECHWELLOGO_OSDWIN+2,TRUE); }
/** * check detected decoder video input standard * * To get a stable the correct REG11C[6:4] value, * read REG101[6] and REG130[7:5] also. * I saw the following values(BK110303) * E7 E7 67 67 87 87 87 87 ..... 87 87 87 87 87 87 87 87 87 07 07 07 .... * B7 B7 B7 37 37 87 87 87 ..... 87 87 87 87 87 87 87 87 87 07 07 07 07 07 07 07 * * oldname: CheckDecoderSTD * * register * R11C[6:4]. * R101[6]. * R130[7:5]. * @return * 0x80: filed. * other: detected standard value. */ BYTE DecoderCheckSTD( BYTE n ) { volatile BYTE r11c,r101,r130; BYTE start=n; BYTE count; #ifdef DEBUG_DEC ePrintf("\n\rDecoderCheckSTD(%d) start",(WORD)n); #endif count=0; while (n--) { r11c = ReadTW88(REG11C); if (( r11c & 0x80 ) == 0 ) { r101 = ReadTW88(REG101); r130 = ReadTW88(REG130); #ifdef DEBUG_DEC dPrintf("\n\r%02bx:%02bx-%02bx-%02bx ",start-n, r11c, r101,r130); #endif if((r101 & 0x40) && ((r130 & 0xE0)==0)) { #ifdef DEBUG_DEC ePrintf("->success:%d",(WORD)start-n); #endif if(count > 4) return (r11c); count++; } } delay1ms(5); } #ifdef DEBUG_DEC ePrintf("->fail"); #endif //This is only for pattern generator. if((r101 & 0xC1) == 0x41) //PAL ? return (r11c); return ( 0x80 ); }
rb_red_blk_tree* bucketPrims(rb_red_blk_tree* buckets, int numLines, Primitive *geometry, size_t geomCount){ size_t i; if(!buckets){ buckets = SafeMalloc(numLines * sizeof(rb_red_blk_tree)); for(i = 0; i < numLines; RBTreeInit(buckets + (i++), pointerDiffF, NULL, &RBNodeAlloc)); } else { for(i = 0; i < numLines; RBTreeClear(buckets + (i++))); } qsort(geometry, geomCount, sizeof(Primitive), topToBottomF); for(i = 0; i < geomCount; ++i){ Primitive *prim = geometry + i; const int pScanLine = roundOwn(bottomMostPoint(prim)); if(pScanLine < numLines && (pScanLine >= 0 || topMostPoint(prim) >= 0)){ rb_red_blk_tree *const dstBucket = buckets + max(0, pScanLine); RBSetAdd(dstBucket, prim); dPrintf(("dstBucket " SZF " gets geometry with arity " SZF " begins on %f and ends on %f and now has size " SZF "\n", dstBucket - buckets, prim->arity, bottomMostPoint(prim), topMostPoint(prim), dstBucket->size)); } } return buckets; }
output& output::operator= (const output& cSource) { dPrintf("(operator=)"); if (this == &cSource) return *this; #if !defined(_WIN32) h_thread = (pthread_t)NULL; #endif f_kill_thread = false; f_streaming = false; num_targets = 0; options = OUTPUT_NONE; count_in = 0; count_out = 0; memset(&ringbuffer, 0, sizeof(ringbuffer)); output_streams.clear(); return *this; }