int streamFilePrimitive(char *filename, int sanitize UNUSED, struct osmdata_t *osmdata) { struct Input *i; char buffer[65536]; int bufsz = 0; int offset = 0; char *nl; i = inputOpen(filename); if (i != NULL) { while(1) { bufsz = bufsz + readFile(i, buffer + bufsz, sizeof(buffer) - bufsz - 1); buffer[bufsz] = 0; nl = strchr(buffer, '\n'); if (nl == 0) break; *nl=0; while (nl && nl < buffer + bufsz) { *nl = 0; process(buffer + offset, osmdata); offset = nl - buffer + 1; nl = strchr(buffer + offset, '\n'); } memcpy(buffer, buffer + offset, bufsz - offset); bufsz = bufsz - offset; offset = 0; } } else { fprintf(stderr, "Unable to open %s\n", filename); return 1; } inputClose(i); return 0; }
//------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------ AsioSample::AsioSample (LPUNKNOWN pUnk, HRESULT *phr) : CUnknown("ASIOSAMPLE", pUnk, phr) //------------------------------------------------------------------------------------------ #else // when not on windows, we derive from AsioDriver AsioSample::AsioSample () : AsioDriver () #endif { long i; blockFrames = kBlockFrames; inputLatency = blockFrames; // typically outputLatency = blockFrames * 2; // typically blockFrames * 2; try to get 1 by offering direct buffer // access, and using asioPostOutput for lower latency samplePosition = 0; sampleRate = 44100.; milliSeconds = (long)((double)(kBlockFrames * 1000) / sampleRate); active = false; started = false; timeInfoMode = false; tcRead = false; for (i = 0; i < kNumInputs; i++) { inputBuffers[i] = 0; inMap[i] = 0; } #if TESTWAVES sawTooth = sineWave = 0; #endif for (i = 0; i < kNumOutputs; i++) { outputBuffers[i] = 0; outMap[i] = 0; } callbacks = 0; activeInputs = activeOutputs = 0; toggle = 0; } //------------------------------------------------------------------------------------------ AsioSample::~AsioSample () { stop (); outputClose (); inputClose (); disposeBuffers (); } //------------------------------------------------------------------------------------------ void AsioSample::getDriverName (char *name) { strcpy (name, "Sample ASIO"); }
int sanitizerClose(void *context) { struct Context *ctx = (struct Context *)context; int r = inputClose(ctx->file); if (ctx->verbose) { fprintf(stderr, "Summary:\n"); fprintf(stderr, "chars1: %lld\n", ctx->chars1); fprintf(stderr, "chars2: %lld\n", ctx->chars2); fprintf(stderr, "chars3: %lld\n", ctx->chars3); fprintf(stderr, "chars4: %lld\n", ctx->chars4); fprintf(stderr, "chars5: %lld\n", ctx->chars5); fprintf(stderr, "chars6: %lld\n", ctx->chars6); fprintf(stderr, "lines : %lld\n", ctx->line); } free(ctx); return r; }
//------------------------------------------------------------------------------------------ ASIOBool AsioSample::init (void* sysRef) { sysRef = sysRef; if (active) return true; strcpy (errorMessage, "ASIO Driver open Failure!"); if (inputOpen ()) { if (outputOpen ()) { active = true; return true; } } timerOff (); // de-activate 'hardware' outputClose (); inputClose (); return false; }
static int inputCloseXML(void *context) { return inputClose((struct Input *)context); }