static void* sio_thread(void *data){ if(h.print_meta && h.metaint) streamIO(write_pipe_parse_meta,data); else streamIO(write_pipe,data); return (void*)0; }
static void stream_plugin_meta(FILE *ffd, struct musicInfo *mi){ h.go=1; streamIO(parse_meta_mi,mi); if(!(*mi->title)) strncpy(mi->title,S_DEF_TITLE,MI_TITLE_SIZE); mi->length=-1; }
MatchOps& match(ValueStream& input, const ValueStream& expectedOutput) { if (ignore_) return *this; ValueStream output; ValueStreamIO streamIO(input, output); sl::vm::Environment env(1024, streamIO); env.execute(&bytecode_->front(), 0); if (output != expectedOutput) { reporter_->outputMismatch(boost::lexical_cast<std::string>(output), boost::lexical_cast<std::string>(expectedOutput)); } return *this; }
static int plugin_run(struct playerHandles *ph, char *key, int *totaltime){ int ret,temp=-1; struct pluginitem *plugin; struct streamInfo si; pthread_t threads; char buf[S_BUFSIZE+1]; fd_set fdset; struct timeval timeout; int rfd; int i; if(!(si.name=malloc((SI_NAME_SIZE+1)*sizeof(char))) || !(si.description=malloc((SI_DESCRIPTION_SIZE+1)*sizeof(char))) || !(si.genre=malloc((SI_GENRE_SIZE+1)*sizeof(char))) || !(si.type=malloc((SI_TYPE_SIZE+1)*sizeof(char)))){ fprintf(stderr,"Can't malloc for si\n"); return DEC_RET_ERROR; } memset(si.name,0,SI_NAME_SIZE); memset(si.genre,0,SI_GENRE_SIZE); memset(si.description,0,SI_DESCRIPTION_SIZE); memset(si.type,0,SI_TYPE_SIZE); si.bitrate=0; h.metaint=h.bytecount=0; h.go=1; streamIO(parse_meta_si,&si); print_stream_meta(&si); if(!(plugin=selectPlugin(ph->plugin_head,si.type))){ fprintf(stderr,"No plugin matches content-type. Trying first plugin.\n"); for(i=0;i<PLUGIN_NULL && ph->plugin_head[i]==NULL;i++) plugin=ph->plugin_head[i]; if(plugin==NULL) return -1; } ph->ffd=h.rfd; pthread_create(&threads,NULL,(void *)&sio_thread,(void *)ph); ret=plugin->modplay(ph,key,&temp); h.go=0; //#if defined(__APPLE__) || defined(Linux) rfd=fileno(h.rfd); do{ timeout.tv_sec=0; timeout.tv_usec=100000; FD_ZERO(&fdset); FD_SET(rfd,&fdset); if(select(1,&fdset,NULL,NULL,&timeout)<1) break; }while((temp=fread(buf,1,S_BUFSIZE,h.rfd))==S_BUFSIZE); // OSX seems to block when closing the write end unless the read end is first closed close(rfd); h.rfd=NULL; //#else #if 0 if(pthread_cancel(threads)!=0)fprintf(stderr,"Failed cancel.\n"); if(pthread_join(threads,NULL)!=0)fprintf(stderr,"Failed join\n"); #endif //usleep(100000); return ret; }