static COMMAND_FUNC( do_read_obj ) { Data_Obj *dp; FILE *fp; const char *s; dp=PICK_OBJ(""); s=NAMEOF("input file"); if( dp == NO_OBJ ) return; #ifdef QUIP_DEBUG //if( debug ) dptrace(dp); #endif /* QUIP_DEBUG */ // reading is tricker for non-ram, because // we must create the copy, then read into // the copy, then xfer to the device... INSIST_RAM_OBJ(dp,"do_read_obj") if( strcmp(s,"-") && strcmp(s,"stdin") ){ fp=TRY_OPEN( s, "r" ); if( !fp ) return; read_ascii_data(QSP_ARG dp,fp,s,expect_exact_count); } else { /* read from stdin, no problem... */ read_obj(QSP_ARG dp); } }
static COMMAND_FUNC( do_rdplot ) { FILE *fp; fp=TRY_OPEN( NAMEOF("filename"), "r") ; if( !fp ) return; rdplot(QSP_ARG fp); }
static COMMAND_FUNC( do_prm_rd ) { FILE *fp; const char *s; s=NAMEOF(pfstr); fp=TRY_OPEN( s,"r" ); if( !fp ) return; rdprms(QSP_ARG theptbl,fp,s); }
static COMMAND_FUNC( do_read_data ) /** read a data file */ { FILE *fp; const char *filename; char num_str[16]; filename=NAMEOF("data file"); fp=TRY_OPEN( filename, "r" ); if( !fp ) return; /* We used to clear the data tables here, * but now they are dynamically allocated * and cleared at that time... */ /* clear old classes */ do_delete_all_classes(SINGLE_QSP_ARG); //curr_tcp=NULL; n_have_classes=0; if( read_exp_data(QSP_ARG fp) != 0 ){ fclose(fp); sprintf(ERROR_STRING,"do_read_data: error return from read_exp_data, file %s",filename); WARN(ERROR_STRING); return; } fclose(fp); n_have_classes = eltcount(class_list(SINGLE_QSP_ARG)); sprintf(num_str,"%d",n_have_classes); // BUG? buffer overflow // if n_have_classes too big??? ASSIGN_RESERVED_VAR( "n_classes" , num_str ); if( verbose ){ sprintf(ERROR_STRING,"File %s read, %d classes, %d x-values", filename,n_have_classes,_nvals); advise(ERROR_STRING); } }
int doAction(unsigned int action, const void *param) { GOC_BDEBUG("Call action %d", action); int old; switch ( action ) { case ACTION_AUMIX_PLUS: // Increase volume mixerChangeVolume(mixer, 1, NULL); break; case ACTION_AUMIX_MINUS: // Decrease volume mixerChangeVolume(mixer, -1, NULL); break; case ACTION_AUMIX_NEXTDEV: next_aumix_port(); break; case ACTION_AUMIX_PREVDEV: break; case ACTION_AUMIX_CURRDEV: { MixerElement* active = NULL; mixerGetSelectedElement(mixer, &active); *(int*)param = (int)active->volume; break; } case ACTION_AUMIX_CURRNAME: { MixerElement* active = NULL; mixerGetSelectedElement(mixer, &active); *(char**)param = active->name; break; } case ACTION_NEXT: old = mode; // zatrzymaj granie if ( mode == MODE_PLAY ) { mode = MODE_STOP; pthread_mutex_lock(&mutexPlay); } // zmieñ piosenkê TRY_OPEN( playlistNext ); mode = old; if ( filename ) { // pu¶æ granie dalej if ( mode == MODE_PLAY ) pthread_mutex_unlock(&mutexPlay); } else mode = MODE_STOP; return 0; case ACTION_PREV: old = mode; // zatrzymaj granie if ( mode == MODE_PLAY ) { mode = MODE_NEXT; pthread_mutex_lock(&mutexPlay); } // zmieñ piosenkê TRY_OPEN( playlistPrev ); mode = old; if ( filename ) { // pu¶æ granie dalej if ( mode == MODE_PLAY ) pthread_mutex_unlock(&mutexPlay); } else mode = MODE_STOP; return 0; case ACTION_PAUSE: if ( mode == MODE_PLAY ) { // zatrzymaj granie mode = MODE_PAUSE; pthread_mutex_lock(&mutexPlay); } else { // je¶li wcze¶niej nie wybrano piosenki, wybierz if ( filename == NULL ) TRY_OPEN( playlistNext ); if ( filename ) { // pu¶æ granie dalej mode = MODE_PLAY; pthread_mutex_unlock(&mutexPlay); } } return 0; case ACTION_PLAY: if ( mode == MODE_PLAY ) { // zatrzymaj granie mode = MODE_STOP; pthread_mutex_lock(&mutexPlay); } // zmieñ piosenkê if ( param != NULL ) { openAudioFile((const char*)param); //TODO: -1 } else { openAudioFile(filename); //TODO: -1 } if ( filename ) { mode = MODE_PLAY; // pu¶æ granie dalej pthread_mutex_unlock(&mutexPlay); } else { mode = MODE_STOP; } return 0; case ACTION_START: pthread_mutex_init(&threadMutex, NULL); pthread_mutex_init(&mutexPlay, NULL); pthread_mutex_lock(&mutexPlay); TRY_OPEN( playlistNext ); if ( filename ) { mode = MODE_PLAY; pthread_mutex_unlock(&mutexPlay); } else { mode = MODE_STOP; } pthread_create(&threadPlay, NULL, &playFile, NULL); return 0; case ACTION_QUIT: printf("Quit and clean thread.\n"); fflush( stdout ); // zatrzymaj granie if ( mode != MODE_STOP ) { mode = MODE_STOP; pthread_mutex_lock(&mutexPlay); mode = MODE_QUIT; pthread_mutex_unlock(&mutexPlay); } else { mode = MODE_QUIT; pthread_mutex_unlock(&mutexPlay); } pthread_mutex_destroy(&threadMutex); pthread_mutex_destroy(&mutexPlay); pthread_join( threadPlay, NULL ); return 0; case ACTION_STOP: if ( mode == MODE_PLAY ) { // zatrzymaj granie mode = MODE_STOP; pthread_mutex_lock(&mutexPlay); } else { if ( filename ) // odtwórz od pocz±tku openAudioFile(filename); // TODO: -1 else // znajd¼ plik do otworzenia TRY_OPEN(playlistNext); if ( filename ) { // pu¶æ granie dalej mode = MODE_PLAY; pthread_mutex_unlock(&mutexPlay); } else { mode = MODE_STOP; } } return 0; case ACTION_INFO: { FileInfo* fileInfo = (FileInfo*)param; fileInfo->filename = goc_stringCopy(fileInfo->filename, filename); finfoInfo(filename, fileInfo); return 0; } default: return ERR_UNKNOWN_ACTION; } return 0; }
/** * Try to open an architecture file searching in various directories */ ifstream* open_arch_stream(const char* filename) { char buffer[FAUST_PATH_MAX]; char* old = getcwd(buffer, FAUST_PATH_MAX); int err; TRY_OPEN(filename); char *envpath = getenv("FAUST_LIB_PATH"); if (envpath!=NULL) { if (chdir(envpath)==0) { TRY_OPEN(filename); } } if ( (chdir(gFaustDirectory.c_str())==0) && (chdir("architecture")==0) ) { //cout << "enrobage.cpp : 'architecture' directory found in gFaustDirectory" << endl; TRY_OPEN(filename); } if ((chdir(gFaustSuperDirectory.c_str())==0) && (chdir("architecture")==0) ) { //cout << "enrobage.cpp : 'architecture' directory found in gFaustSuperDirectory" << endl; TRY_OPEN(filename); } if ((chdir(gFaustSuperSuperDirectory.c_str())==0) && (chdir("architecture")==0) ) { //cout << "enrobage.cpp : 'architecture' directory found in gFaustSuperSuperDirectory" << endl; TRY_OPEN(filename); } #ifdef INSTALL_PREFIX if (chdir(INSTALL_PREFIX "/lib/faust")==0) { TRY_OPEN(filename); } if (chdir(INSTALL_PREFIX "/include")==0) { TRY_OPEN(filename); } #endif if (chdir("/usr/local/lib/faust")==0) { TRY_OPEN(filename); } if (chdir("/usr/lib/faust")==0) { TRY_OPEN(filename); } if (chdir("/usr/local/include")==0) { TRY_OPEN(filename); } if (chdir("/usr/include")==0) { TRY_OPEN(filename); } return 0; }