static void test_rb(void) { //rbtree *tr = rb_cnew( 0, 0, 0, 0, 0, 0); rbtree *tr = rb_new(); char keybuf[100]; size_t valuebuf[] = { 1 }; size_t *vp; // while (fscanf(stdin, "%s", keybuf) == 1) { // vp = rb_get(tr, keybuf); // if (vp) // *vp += 1; // else // rb_add(tr, keybuf, valuebuf); // } // this is another faster version while (fscanf(stdin, "%s", keybuf) == 1) { vp = rb_fget(tr, keybuf); *vp += 1; } rb_set(tr, "a", valuebuf); *valuebuf = 123456789; rb_add(tr, "b", valuebuf); *valuebuf = 2; rb_set(tr, "c", valuebuf); rb_set(tr, "d", valuebuf); *valuebuf = 987654321; rb_update(tr,"a",valuebuf); rb_set(tr, "e", valuebuf); rb_print(tr); rb_clear(tr); rb_clear(tr); //just for test rb_free(tr); }
void GizWits_init(uint8_t P0_Len) { Pro_HeadPartP0CmdTypeDef *Pro_D2W_ReportStatusStruct = (Pro_HeadPartP0CmdTypeDef *)g_DevStatus; Serial1.begin(9600); #if(GetFrame==1) //自定义引脚通信SoftwareSerial初始 Serial.begin(9600); #endif //定时中断初始 // MsTimer2::set(1, gokit_timer); // 1ms period // MsTimer2::start(); Timer2.setChannel1Mode(TIMER_OUTPUTCOMPARE); Timer2.setPeriod(1000); // in 1000 microseconds = 1ms Timer2.setCompare1(1); // overflow might be small Timer2.attachCompare1Interrupt(gokit_timer); // handler function // Timer2.pause(); // Timer2.resume(); if(P0_Len > MAX_P0_LEN) { Serial.println("Warning P0_Len out of range"); while(1); } //RingBuffer rb_new(&u_ring_buff); memset((uint8_t *)&g_DevStatus, 0, 128); memset(&Pro_M2W_ReturnInfoStruct, 0, sizeof(Pro_M2W_ReturnInfoStruct)); Pro_M2W_ReturnInfoStruct.Pro_HeadPart.Head[0] = 0xFF; Pro_M2W_ReturnInfoStruct.Pro_HeadPart.Head[1] = 0xFF; Pro_M2W_ReturnInfoStruct.Pro_HeadPart.Len = exchangeBytes(sizeof(Pro_M2W_ReturnInfoStruct) - 4); Pro_M2W_ReturnInfoStruct.Pro_HeadPart.Cmd = Pro_D2W__GetDeviceInfo_Ack_Cmd; memcpy(Pro_M2W_ReturnInfoStruct.Pro_ver, PRO_VER, strlen(PRO_VER)); memcpy(Pro_M2W_ReturnInfoStruct.P0_ver, P0_VER, strlen(P0_VER)); memcpy(Pro_M2W_ReturnInfoStruct.Hard_ver, HARD_VER, strlen(HARD_VER)); memcpy(Pro_M2W_ReturnInfoStruct.Soft_ver, SOFT_VER, strlen(SOFT_VER)); memcpy(Pro_M2W_ReturnInfoStruct.Product_Key, PRODUCT_KEY, strlen(PRODUCT_KEY)); Pro_M2W_ReturnInfoStruct.Binable_Time = exchangeBytes(0); g_P0DataLen = P0_Len; Pro_D2W_ReportStatusStruct->Pro_HeadPart.Head[0] = 0xFF; Pro_D2W_ReportStatusStruct->Pro_HeadPart.Head[1] = 0xFF; Pro_D2W_ReportStatusStruct->Pro_HeadPart.Len = exchangeBytes(sizeof(Pro_HeadPartP0CmdTypeDef) - 4); Pro_D2W_ReportStatusStruct->Pro_HeadPart.Cmd = 0x0; Pro_D2W_ReportStatusStruct->Pro_HeadPart.SN = 0; Pro_D2W_ReportStatusStruct->Pro_HeadPart.Flags[0] = 0x0; Pro_D2W_ReportStatusStruct->Pro_HeadPart.Flags[1] = 0x0; //Pro_D2W_ReportStatusStruct->Action = 0x0; }
void GizWits_init(uint8_t P0_Len) { Pro_HeadPartP0CmdTypeDef *Pro_D2W_ReportStatusStruct = (Pro_HeadPartP0CmdTypeDef *)g_DevStatus; #ifdef M5_VERSION Serial1.begin(9600); #else Serial.begin(9600); #endif #if(GetFrame==1) //自定义引脚通信SoftwareSerial初始 mySerial.begin(9600); #endif //定时中断初始 MsTimer2::set(1, gokit_timer); // 1ms period MsTimer2::start(); if(P0_Len > MAX_P0_LEN) { mySerial.println("Warning P0_Len out of range"); while(1); } //RingBuffer rb_new(&u_ring_buff); memset((uint8_t *)&g_DevStatus, 0, 128); memset(&Pro_M2W_ReturnInfoStruct, 0, sizeof(Pro_M2W_ReturnInfoStruct)); Pro_M2W_ReturnInfoStruct.Pro_HeadPart.Head[0] = 0xFF; Pro_M2W_ReturnInfoStruct.Pro_HeadPart.Head[1] = 0xFF; Pro_M2W_ReturnInfoStruct.Pro_HeadPart.Len = exchangeBytes(sizeof(Pro_M2W_ReturnInfoStruct) - 4); Pro_M2W_ReturnInfoStruct.Pro_HeadPart.Cmd = Pro_D2W__GetDeviceInfo_Ack_Cmd; memcpy(Pro_M2W_ReturnInfoStruct.Pro_ver, PRO_VER, strlen(PRO_VER)); memcpy(Pro_M2W_ReturnInfoStruct.P0_ver, P0_VER, strlen(P0_VER)); memcpy(Pro_M2W_ReturnInfoStruct.Hard_ver, HARD_VER, strlen(HARD_VER)); memcpy(Pro_M2W_ReturnInfoStruct.Soft_ver, SOFT_VER, strlen(SOFT_VER)); memcpy(Pro_M2W_ReturnInfoStruct.Product_Key, PRODUCT_KEY, strlen(PRODUCT_KEY)); Pro_M2W_ReturnInfoStruct.Binable_Time = exchangeBytes(0); g_P0DataLen = P0_Len; Pro_D2W_ReportStatusStruct->Pro_HeadPart.Head[0] = 0xFF; Pro_D2W_ReportStatusStruct->Pro_HeadPart.Head[1] = 0xFF; Pro_D2W_ReportStatusStruct->Pro_HeadPart.Len = exchangeBytes(sizeof(Pro_HeadPartP0CmdTypeDef) - 4); Pro_D2W_ReportStatusStruct->Pro_HeadPart.Cmd = 0x0; Pro_D2W_ReportStatusStruct->Pro_HeadPart.SN = 0; Pro_D2W_ReportStatusStruct->Pro_HeadPart.Flags[0] = 0x0; Pro_D2W_ReportStatusStruct->Pro_HeadPart.Flags[1] = 0x0; //Pro_D2W_ReportStatusStruct->Action = 0x0; }
/* This function is invoked by the main CAmkES thread in this component. */ int run(void) { int error = camkes_io_port_ops(&io_port_ops); assert(!error); /* Use the dataport address */ void *bga_ptr = (void *)mock_hdmi; bga = bga_init(bga_ptr, out16, in16); bga_set_mode(bga, 1024, 768, 24); /* 1024x768 resolution at 24 BPP */ ringbuffer_t *low = rb_new((void *)low_input, sizeof(*low_input)); if (low == NULL) { abort(); } ringbuffer_t *high = rb_new((void *)high_input, sizeof(*high_input)); if (high == NULL) { abort(); } borders(); /* Check both inputs for data and pass it to the relevant framebuffer. */ while (true) { char c; if ((c = (char)rb_poll_byte(low)) != 0) { write_low(c); } if ((c = (char)rb_poll_byte(high)) != 0) { write_high(c); } } return 0; }
int main(int argc, char **argv) { char *filename = argv[1]; int tok; rb = rb_new(); if (!yylex_push_file(filename)) return 1; while ((tok = yylex()) != 0) { fprintf(stderr, "%s:%d:%s:%s\n", yylocation.filename, yylocation.lineno, describe_token(tok), describe_yylval(tok)); } return 0; }
//============================================================================= int main() { rb_t *rb=rb_new(FLOAT_COUNT*sizeof(float)); if(rb==NULL) {return 1;} rb_debug(rb); float floats[FLOAT_COUNT]={0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8}; int wrote=rb_write(rb,(char*)floats,FLOAT_COUNT*sizeof(float)); fprintf(stderr,"wrote %d bytes (%zu floats)\n",wrote,wrote/sizeof(float)); rb_debug(rb); rb_print_regions(rb); float f1; int read=rb_read_float(rb,&f1); fprintf(stderr,"read %d bytes (%zu float) %f\n",read,read/sizeof(float),f1); int peeked=rb_peek_float(rb,&f1); fprintf(stderr,"peeked %d bytes (%zu float) %f\n",peeked,peeked/sizeof(float),f1); float f2=0.99; wrote=rb_write_float(rb,&f2); fprintf(stderr,"wrote %d bytes (%zu float) %f\n",wrote,wrote/sizeof(float),f2); int skipped=rb_skip_float(rb); fprintf(stderr,"skipped %d bytes (%zu float)\n",skipped,skipped/sizeof(float)); int peek_at=rb_can_read(rb)-sizeof(float); peeked=rb_peek_float_at(rb,&f1,peek_at); fprintf(stderr,"peeked %d bytes (%zu float) at %d %f\n",peeked,peeked/sizeof(float),peek_at,f1); rb_debug(rb); rb_print_regions(rb); rb_free(rb); return 0; }
int main (int argc, char *argv[]) { ////////////////////////////////////////////// //will be removed // sample_rate=44100; sample_rate=48000; // period_size=2048; period_size=4096; // period_size=256; //period_size=128; bytes_per_sample=4; //osc const char *listenPort; //command line options parsing //http://www.gnu.org/software/libc/manual/html_node/Using-Getopt.html static struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'v'}, {"loinfo", no_argument, 0, 'x'}, {"out", required_argument, 0, 'o'}, {"offset", required_argument, 0, 'f'}, {"16", no_argument, 0, 'y'}, {"max", required_argument, 0, 'm'},//max (allocate) buffer {"update", required_argument, 0, 'u'},//screen info update every nth cycle {"limit", required_argument, 0, 'l'},//test, stop after n processed {0, 0, 0, 0} }; //print program header if(argc>1 && strcmp(argv[1],"--version")) { print_header("audio_post_send"); } if (argc - optind < 1) { fprintf (stderr, "Missing arguments, see --help.\n\n"); exit(1); } int opt; //do until command line options parsed while (1) { /* getopt_long stores the option index here. */ int option_index = 0; opt = getopt_long (argc, argv, "", long_options, &option_index); /* Detect the end of the options. */ if (opt == -1) { break; } switch (opt) { case 0: /* If this option set a flag, do nothing else now. */ if (long_options[option_index].flag != 0) { break; } case 'h': print_help(); break; case 'v': print_version(); break; case 'x': check_lo_props(1); return 1; case 'o': output_port_count=atoi(optarg); if(output_port_count>max_channel_count) { fprintf(stderr,"*** limiting playback ports to %d, sry\n",max_channel_count); output_port_count=max_channel_count; } port_count=fmin(input_port_count,output_port_count); break; case 'f': channel_offset=atoi(optarg); break; case 'm': //min 1 MB max_buffer_size=fmax(1,(uint64_t)atoll(optarg)*1000*1000); break; case 'u': update_display_every_nth_cycle=fmax(1,(uint64_t)atoll(optarg)); break; case 'l': receive_max=fmax(1,(uint64_t)atoll(optarg)); test_mode=1; fprintf(stderr,"*** limiting number of messages: %" PRId64 "\n",receive_max); break; case '?': //invalid commands /* getopt_long already printed an error message. */ fprintf (stderr, "Wrong arguments, see --help.\n\n"); exit(1); break; default: break; } //end switch op }//end while(1) //remaining non optional parameters listening port, remote host, remote port if(argc-optind != 3) { fprintf (stderr, "Wrong arguments, see --help.\n\n"); exit(1); } if(check_lo_props(0)>0) { return 1; } if(have_libjack()!=0) { fprintf(stderr,"/!\\ libjack not found (JACK not installed?). this is fatal: audio_post_send needs JACK to run.\n"); //io_quit("nolibjack"); exit(1); } listenPort=argv[optind]; //tcp target remote_tcp_host=argv[optind+1]; remote_tcp_port=argv[optind+2]; loa_tcp = lo_address_new_with_proto(LO_TCP, remote_tcp_host, remote_tcp_port); //initialize time gettimeofday(&tv, NULL); tt_prev.sec=tv.tv_sec; tt_prev.frac=tv.tv_usec; //print startup info fprintf(stderr,"listening on UDP port: %s\n",listenPort); //udp/tcp use the same port for now fprintf(stderr,"started TCP server on port: %s\n",listenPort); fprintf(stderr,"channels (forward): %d\n",output_port_count); fprintf(stderr,"channel offset: %d\n",channel_offset); fprintf(stderr, "TCP target: %s:%s\n",remote_tcp_host,remote_tcp_port); fprintf(stderr, "period size (TCP forward): %d samples\n",period_size); fprintf(stderr, "delay between TCP sends: %d ms\n",delay_between_tcp_sends); fprintf(stderr, "delay between TCP retries on broken connection: %d ms\n",delay_between_tcp_retries); //ringbuffer size bytes uint64_t rb_size; //use as given via param --max or: if(max_buffer_size==0) { //default //10 MB . . max_buffer_size=10000000; } // rb_size=max_buffer_size; fprintf(stderr,"allocated buffer size: %" PRId64 " bytes (%.2f MB)\n",max_buffer_size,(float)max_buffer_size/1000/1000); //==================================== //main ringbuffer osc blobs -> jack output rb = rb_new (rb_size); //helper ringbuffer: used when remote period size < local period size rb_helper = rb_new (rb_size); if(rb==NULL) { fprintf(stderr,"could not create a ringbuffer with that size.\n"); fprintf(stderr,"try --max <smaller size>.\n"); exit(1); } /* install a signal handler to properly quits jack client */ #ifndef _WIN signal(SIGQUIT, signal_handler); signal(SIGHUP, signal_handler); #endif signal(SIGTERM, signal_handler); signal(SIGINT, signal_handler); //add osc hooks & start UDP server registerOSCMessagePatterns(listenPort); lo_server_thread_start(lo_st); //start TCP server, for forwarding to final receiver lo_st_tcp = lo_server_thread_new_with_proto(listenPort, LO_TCP, error); lo_server_thread_start(lo_st_tcp); fflush(stderr); /* keep running until the Ctrl+C */ while(1) { //possibly clean shutdown without any glitches if(shutdown_in_progress==1) { signal_handler(42); } //if tcp message could not be sent if(process()<0) { //wait x and update info int i; for(i=0;i<delay_between_tcp_retries;i++) { usleep(1000); print_info(); } } else { //wait y and update info int i; for(i=0;i<delay_between_tcp_sends;i++) { usleep(1000); print_info(); } } } exit (0); }
int main(int argc, char **argv) { SDL_AudioSpec fmt; rb_data = rb_new(256); rb_audio = rb_new(48000); //int fd = sound_open("/dev/dsp"); SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER); fmt.freq = SRATE; fmt.format = AUDIO_S16; fmt.channels = 1; fmt.samples = 256; fmt.callback = gen_audio; if ( SDL_OpenAudio(&fmt, NULL) < 0 ) { fprintf(stderr, "Can't open audio: %s\n", SDL_GetError()); exit(1); } SDL_Event ev; screen = SDL_SetVideoMode(16, 16, 32, SDL_HWSURFACE | SDL_RESIZABLE) ; screen = SDL_SetVideoMode(16, 16, 32, SDL_HWSURFACE | SDL_RESIZABLE) ; draw(); SDL_PauseAudio(0); for(;;) { while(SDL_WaitEvent(&ev)) { if(ev.type == SDL_KEYDOWN) { switch(ev.key.keysym.sym) { case 27: exit(0); break; default: { char buf[16]; snprintf(buf, sizeof buf, "d%c\n", ev.key.keysym.sym); send(buf, strlen(buf)); } break; } } if(ev.type == SDL_MOUSEBUTTONDOWN) { update_color(); run = 1; } if(ev.type == SDL_VIDEORESIZE) { screen = SDL_SetVideoMode(ev.resize.w, ev.resize.h, 32, SDL_HWSURFACE | SDL_RESIZABLE) ; draw(); update_color(); } if(ev.type == SDL_MOUSEMOTION) { run = 0; mx = ev.motion.x; my = ev.motion.y; update_color(); } } } return 0; }
VCSession *vc_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t friend_number, toxav_video_receive_frame_cb *cb, void *cb_data) { VCSession *vc = (VCSession *)calloc(sizeof(VCSession), 1); vpx_codec_err_t rc; if (!vc) { LOGGER_WARNING(log, "Allocation failed! Application might misbehave!"); return nullptr; } if (create_recursive_mutex(vc->queue_mutex) != 0) { LOGGER_WARNING(log, "Failed to create recursive mutex!"); free(vc); return nullptr; } int cpu_used_value = VP8E_SET_CPUUSED_VALUE; vc->vbuf_raw = rb_new(VIDEO_DECODE_BUFFER_SIZE); if (!vc->vbuf_raw) { goto BASE_CLEANUP; } /* * VPX_CODEC_USE_FRAME_THREADING * Enable frame-based multi-threading * * VPX_CODEC_USE_ERROR_CONCEALMENT * Conceal errors in decoded frames */ vpx_codec_dec_cfg_t dec_cfg; dec_cfg.threads = VPX_MAX_DECODER_THREADS; // Maximum number of threads to use dec_cfg.w = VIDEO_CODEC_DECODER_MAX_WIDTH; dec_cfg.h = VIDEO_CODEC_DECODER_MAX_HEIGHT; LOGGER_DEBUG(log, "Using VP8 codec for decoder (0)"); rc = vpx_codec_dec_init(vc->decoder, video_codec_decoder_interface(), &dec_cfg, VPX_CODEC_USE_FRAME_THREADING | VPX_CODEC_USE_POSTPROC); if (rc == VPX_CODEC_INCAPABLE) { LOGGER_WARNING(log, "Postproc not supported by this decoder (0)"); rc = vpx_codec_dec_init(vc->decoder, video_codec_decoder_interface(), &dec_cfg, VPX_CODEC_USE_FRAME_THREADING); } if (rc != VPX_CODEC_OK) { LOGGER_ERROR(log, "Init video_decoder failed: %s", vpx_codec_err_to_string(rc)); goto BASE_CLEANUP; } if (VIDEO_VP8_DECODER_POST_PROCESSING_ENABLED == 1) { vp8_postproc_cfg_t pp = {VP8_DEBLOCK, 1, 0}; vpx_codec_err_t cc_res = vpx_codec_control(vc->decoder, VP8_SET_POSTPROC, &pp); if (cc_res != VPX_CODEC_OK) { LOGGER_WARNING(log, "Failed to turn on postproc"); } else { LOGGER_DEBUG(log, "turn on postproc: OK"); } } else { vp8_postproc_cfg_t pp = {0, 0, 0}; vpx_codec_err_t cc_res = vpx_codec_control(vc->decoder, VP8_SET_POSTPROC, &pp); if (cc_res != VPX_CODEC_OK) { LOGGER_WARNING(log, "Failed to turn OFF postproc"); } else { LOGGER_DEBUG(log, "Disable postproc: OK"); } } /* Set encoder to some initial values */ vpx_codec_enc_cfg_t cfg; vc_init_encoder_cfg(log, &cfg, 1); LOGGER_DEBUG(log, "Using VP8 codec for encoder (0.1)"); rc = vpx_codec_enc_init(vc->encoder, video_codec_encoder_interface(), &cfg, VPX_CODEC_USE_FRAME_THREADING); if (rc != VPX_CODEC_OK) { LOGGER_ERROR(log, "Failed to initialize encoder: %s", vpx_codec_err_to_string(rc)); goto BASE_CLEANUP_1; } rc = vpx_codec_control(vc->encoder, VP8E_SET_CPUUSED, cpu_used_value); if (rc != VPX_CODEC_OK) { LOGGER_ERROR(log, "Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc)); vpx_codec_destroy(vc->encoder); goto BASE_CLEANUP_1; } /* VPX_CTRL_USE_TYPE(VP8E_SET_NOISE_SENSITIVITY, unsigned int) control function to set noise sensitivity 0: off, 1: OnYOnly, 2: OnYUV, 3: OnYUVAggressive, 4: Adaptive */ /* rc = vpx_codec_control(vc->encoder, VP8E_SET_NOISE_SENSITIVITY, 2); if (rc != VPX_CODEC_OK) { LOGGER_ERROR(log, "Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc)); vpx_codec_destroy(vc->encoder); goto BASE_CLEANUP_1; } */ vc->linfts = current_time_monotonic(mono_time); vc->lcfd = 60; vc->vcb = cb; vc->vcb_user_data = cb_data; vc->friend_number = friend_number; vc->av = av; vc->log = log; return vc; BASE_CLEANUP_1: vpx_codec_destroy(vc->decoder); BASE_CLEANUP: pthread_mutex_destroy(vc->queue_mutex); rb_kill(vc->vbuf_raw); free(vc); return nullptr; }
//============================================================================= int main(int argc, char *argv[]) { if(argc<2) { fprintf(stderr,"need number\n"); exit(1); } int rb_size_request=atoi(argv[1]); fprintf(stderr,"\n==creating new ringbuffer of size %d\n",rb_size_request); rb_t *rb=rb_new(rb_size_request); if(rb==NULL) { fprintf(stderr,"ringbuffer with size 0?\n"); exit(1); } rb_debug(rb); fprintf(stderr,"\n==write full + 1\n"); int i; for(i=0;i<rb_size_request+1;i++) { char put[1]={i}; int wrote=rb_write(rb,put,1); rb_debug(rb); } fprintf(stderr,"\n==peek full + 1\n"); char pull[rb_size_request]; int peeked=rb_peek(rb,pull,rb_size_request+1); rb_debug(rb); fprintf(stderr,"\n==read full + 1\n"); for(i=0;i<rb_size_request+1;i++) { char pull[1]; int read=rb_read(rb,pull,1); rb_debug(rb); } fprintf(stderr,"\n==write full\n"); for(i=0;i<rb_size_request;i++) { char put[1]={i}; int wrote=rb_write(rb,put,1); rb_debug(rb); } rb_print_regions(rb); fprintf(stderr,"\n==advance read pointer 1\n"); rb_advance_read_index(rb,1); rb_debug(rb); fprintf(stderr,"\n==drop\n"); rb_drop(rb); rb_debug(rb); rb_print_regions(rb); fprintf(stderr,"\n==write 1\n"); char put[1]={'a'}; int wrote=rb_write(rb,put,1); rb_debug(rb); rb_print_regions(rb); fprintf(stderr,"\n==read 1\n"); char put2[1]; int read=rb_read(rb,put2,1); rb_debug(rb); rb_print_regions(rb); fprintf(stderr,"\n==write 4\n"); char put3[4]={'a','b','c','d'}; wrote=rb_write(rb,put3,4); rb_debug(rb); rb_print_regions(rb); int advanced; int k; for(k=0;k<20;k++) { fprintf(stderr,"\n==advance write 3\n"); advanced=rb_advance_write_index(rb,3); rb_debug(rb); rb_print_regions(rb); fprintf(stderr,"\n==advance read 2\n"); advanced=rb_advance_read_index(rb,2); rb_debug(rb); rb_print_regions(rb); } for(k=0;k<20;k++) { fprintf(stderr,"\n==advance read 3\n"); advanced=rb_advance_read_index(rb,2); rb_debug(rb); rb_print_regions(rb); fprintf(stderr,"\n==advance write 2\n"); advanced=rb_advance_write_index(rb,3); rb_debug(rb); rb_print_regions(rb); } rb_region_t d; rb_get_next_write_region(rb,&d); fprintf(stderr,"\n==got next write buffer, can write %" PRId64 "\n",d.size); fprintf(stderr,"\n==drop\n"); rb_drop(rb); rb_debug(rb); rb_print_regions(rb); rb_get_next_write_region(rb,&d); fprintf(stderr,"\n==got next write buffer, can write %" PRId64 "\n",d.size); d.buffer[0]='x'; fprintf(stderr,"\n==advance write 4\n"); advanced=rb_advance_write_index(rb,4); rb_debug(rb); rb_print_regions(rb); rb_get_next_read_region(rb,&d); fprintf(stderr,"\n==got next read buffer, can read %" PRId64 "\n",d.size); fprintf(stderr,"\n==advance read 4\n"); rb_advance_read_index(rb,4); rb_debug(rb); rb_print_regions(rb); rb_get_next_read_region(rb,&d); fprintf(stderr,"\n==got next read buffer, can read %" PRId64 "\n",d.size); d.buffer[0]='x'; fprintf(stderr,"\n==advance read 1\n"); advanced=rb_advance_read_index(rb,1); rb_debug(rb); rb_print_regions(rb); fprintf(stderr,"\n==reset\n"); rb_reset(rb); rb_debug(rb); fprintf(stderr,"\n==free\n"); rb_free(rb); rb_debug(rb); return 0; }//end main