本文整理汇总了C++中scprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ scprintf函数的具体用法?C++ scprintf怎么用?C++ scprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scprintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scprintf
int SCProcess::findNextFreeUdpPort(int startNum) {
int server_socket = -1;
struct sockaddr_in mBindSockAddr;
int numberOfTries=50;
int port = startNum;
if ((server_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
scprintf("failed to create udp socket\n");
return -1;
}
bzero((char *)&mBindSockAddr, sizeof(mBindSockAddr));
mBindSockAddr.sin_family = AF_INET;
mBindSockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
mBindSockAddr.sin_port = htons(port);
const int on = 1;
setsockopt( server_socket, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
while (bind(server_socket, (struct sockaddr *)&mBindSockAddr, sizeof(mBindSockAddr)) < 0) {
if(--numberOfTries <0 || (errno != EADDRINUSE)) {
scprintf("unable to bind udp socket\n");
return -1;
}
port++;
mBindSockAddr.sin_port = htons(port);
}
close(server_socket);
return port;
}
示例2: dumpOSC
void dumpOSC(int mode, int size, char* inData)
{
if (mode & 1)
{
if (strcmp(inData, "#bundle") == 0)
{
char* data = inData + 8;
scprintf("[ \"#bundle\", %lld, ", OSCtime(data));
data += 8;
char* dataEnd = inData + size;
while (data < dataEnd) {
int32 msgSize = OSCint(data);
data += sizeof(int32);
scprintf("\n ");
dumpOSCmsg(msgSize, data);
data += msgSize;
if (data < dataEnd) scprintf(",");
}
scprintf("\n]\n");
}
else
{
dumpOSCmsg(size, inData);
scprintf("\n");
}
}
if (mode & 2) hexdump(size, inData);
}
示例3: PlugIn_Load
static bool PlugIn_Load(const char *filename)
{
#ifdef _WIN32
HINSTANCE hinstance = LoadLibrary( filename );
if (!hinstance) {
char *s;
DWORD lastErr = GetLastError();
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
0, lastErr , 0, (char*)&s, 1, 0 );
scprintf("*** ERROR: LoadLibrary '%s' err '%s'\n", filename, s);
LocalFree( s );
return false;
}
void *ptr = (void *)GetProcAddress( hinstance, SC_PLUGIN_LOAD_SYM );
if (!ptr) {
char *s;
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
0, GetLastError(), 0, (char*)&s, 1, 0 );
scprintf("*** ERROR: GetProcAddress %s err '%s'\n", SC_PLUGIN_LOAD_SYM, s);
LocalFree( s );
FreeLibrary(hinstance);
return false;
}
LoadPlugInFunc loadFunc = (LoadPlugInFunc)ptr;
(*loadFunc)(&gInterfaceTable);
// FIXME: at the moment we never call FreeLibrary() on a loaded plugin
return true;
#else
void* handle = dlopen(filename, RTLD_NOW);
if (!handle) {
scprintf("*** ERROR: dlopen '%s' err '%s'\n", filename, dlerror());
dlclose(handle);
return false;
}
void *ptr;
ptr = dlsym(handle, SC_PLUGIN_LOAD_SYM);
if (!ptr) {
scprintf("*** ERROR: dlsym %s err '%s'\n", SC_PLUGIN_LOAD_SYM, dlerror());
dlclose(handle);
return false;
}
LoadPlugInFunc loadFunc = (LoadPlugInFunc)ptr;
(*loadFunc)(&gInterfaceTable);
return true;
#endif
}
示例4: PublishPortToRendezvous
void PublishPortToRendezvous(SCRendezvousProtocol protocol, short portNum)
{
scprintf("PublishPortToRendezvous %d %hu\n", protocol, portNum);
CFStringRef serviceType = 0;
switch (protocol)
{
case kSCRendezvous_UDP:
serviceType = CFSTR("_osc._udp.");
break;
case kSCRendezvous_TCP:
serviceType = CFSTR("_osc._tcp.");
break;
}
CFNetServiceRef netServiceRef =
CFNetServiceCreate(NULL, // use default allocator
CFSTR(""), // use default domain
serviceType,
CFSTR("SuperCollider"),
portNum);
// DEBUG
if (!netServiceRef)
{
scprintf("Couldn't create a Rendezvous net service.\n");
return;
}
CFNetServiceRegisterWithOptions(netServiceRef, 0, NULL); // don't care about the error
CFRelease( netServiceRef );
}
示例5: World_LoadGraphDefs
void World_LoadGraphDefs(World* world)
{
GraphDef *list = 0;
if(getenv("SC_SYNTHDEF_PATH")){
if(world->mVerbosity > 0)
scprintf("Loading synthdefs from path: %s\n", getenv("SC_SYNTHDEF_PATH"));
SC_StringParser sp(getenv("SC_SYNTHDEF_PATH"), SC_STRPARSE_PATHDELIMITER);
while (!sp.AtEnd()) {
GraphDef *list = 0;
char *path = const_cast<char *>(sp.NextToken());
list = GraphDef_LoadDir(world, path, list);
GraphDef_Define(world, list);
}
}else{
char resourceDir[MAXPATHLEN];
if(sc_IsStandAlone())
sc_GetResourceDirectory(resourceDir, MAXPATHLEN);
else
sc_GetUserAppSupportDirectory(resourceDir, MAXPATHLEN);
sc_AppendToPath(resourceDir, MAXPATHLEN, "synthdefs");
if(world->mVerbosity > 0)
scprintf("Loading synthdefs from default path: %s\n", resourceDir);
list = GraphDef_LoadDir(world, resourceDir, list);
GraphDef_Define(world, list);
}
}
示例6: mPoll
AvahiSession::AvahiSession()
: mPoll(0),
mClient(0),
mGroup(0),
mEntries(0),
mServiceName(0)
{
int err;
mServiceName = avahi_strdup(kSCRendezvousServiceName);
mPoll = avahi_threaded_poll_new();
if (!mPoll) {
scprintf("Zeroconf: failed to create poll API\n");
return;
}
mClient = avahi_client_new(
avahi_threaded_poll_get(mPoll),
(AvahiClientFlags)0, client_cb, this, &err);
if (!mClient) {
scprintf("Zeroconf: failed to create client: %s\n", avahi_strerror(err));
avahi_threaded_poll_free(mPoll);
mPoll = 0;
return;
}
avahi_threaded_poll_start(mPoll);
}
示例7: ReleaseInputBuffers
static void ReleaseInputBuffers(GraphDef *inGraphDef, UnitSpec *unitSpec, BufColorAllocator& bufColor)
{
for (int64 i=(int64)(unitSpec->mNumInputs)-1; i>=0; --i) {
InputSpec *inputSpec = unitSpec->mInputSpec + i;
if (inputSpec->mFromUnitIndex >= 0) {
UnitSpec *outUnit = inGraphDef->mUnitSpecs + inputSpec->mFromUnitIndex;
OutputSpec *outputSpec = outUnit->mOutputSpec + inputSpec->mFromOutputIndex;
inputSpec->mWireIndex = outputSpec->mWireIndex;
if (outputSpec->mCalcRate == calc_FullRate) {
if (unitSpec->mCalcRate == calc_DemandRate)
// we never release any input buffers of demand-rate ugens
continue;
if (!bufColor.release(outputSpec->mBufferIndex)) {
scprintf("buffer coloring error: tried to release output with zero count\n");
scprintf("output: %d %s %d\n", inputSpec->mFromUnitIndex,
outUnit->mUnitDef->mUnitDefName, inputSpec->mFromOutputIndex);
scprintf("input: %s %d\n", unitSpec->mUnitDef->mUnitDefName, i);
throw std::runtime_error("buffer coloring error.");
}
}
} else {
inputSpec->mWireIndex = inputSpec->mFromOutputIndex;
}
}
}
示例8: CFStringGetCString
CFPropertyListRef Resources::getPropertyList(const char* filename)
{
CFDataRef xmlCFDataRef;
CFStringRef error;
char cerror[10240];
CFPropertyListRef myCFPropertyListRef = NULL;
Boolean readOK;
char filePathBuf[PATH_MAX];
CFStringRef filePath = this->getResourcePath(filename);
CFStringGetCString(filePath, filePathBuf, sizeof(filePathBuf), kCFStringEncodingUTF8);
CFURLRef fileURL = CFURLCreateFromFileSystemRepresentation (kCFAllocatorDefault, (const unsigned char*)filePathBuf, strlen (filePathBuf), false);
if (fileURL!=NULL) {
readOK = CFURLCreateDataAndPropertiesFromResource( kCFAllocatorDefault, fileURL, &xmlCFDataRef, NULL, NULL, NULL);
if (readOK)
{
myCFPropertyListRef = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, xmlCFDataRef, kCFPropertyListImmutable, &error);
if (error != NULL){
CFStringGetCString(error, cerror, sizeof(cerror), kCFStringEncodingUTF8);
scprintf("getPropertyList error: %s\n", cerror);
}
CFRelease(xmlCFDataRef);
}
else{
scprintf("Couldn't read Plist File %s\n", filePathBuf);
}
}
return myCFPropertyListRef;
}
示例9: scsynth_android_initlogging
extern "C" void scsynth_android_initlogging() {
SetPrintFunc((PrintFunc) *scvprintf_android);
#ifndef NDEBUG
scprintf("SCSYNTH->ANDROID logging active (no debug)\n");
#else
scprintf("SCSYNTH->ANDROID logging active (debug)\n");
#endif
}
示例10: main
int main(int argc, char *argv[])
{
setbuf(stdout, NULL);
if (argc < 2) {
scprintf(_SC("SQDBG error : no file specified"));
return -1;
}
HSQUIRRELVM v = sq_open(1024);
sqstd_seterrorhandlers(v);
//!! INITIALIZES THE DEBUGGER ON THE TCP PORT 1234
//!! ENABLES AUTOUPDATE
HSQREMOTEDBG rdbg = sq_rdbg_init(v, 1234, SQTrue);
if (rdbg) {
//!! ENABLES DEBUG INFO GENERATION(for the compiler)
sq_enabledebuginfo(v, SQTrue);
sq_setprintfunc(v, printfunc, errorfunc);
//!! SUSPENDS THE APP UNTIL THE DEBUGGER CLIENT CONNECTS
if (SQ_SUCCEEDED(sq_rdbg_waitforconnections(rdbg))) {
scprintf(_SC("connected\n"));
const SQChar *fname = NULL;
#ifdef _UNICODE
SQChar sTemp[256];
mbstowcs(sTemp,argv[1],(int)strlen(argv[1])+1);
fname=sTemp;
#else
fname = argv[1];
#endif
//!!REGISTERS STANDARDS LIBS
sq_pushroottable(v);
sqstd_register_bloblib(v);
sqstd_register_iolib(v);
//!!EXECUTE A SCTIPT
if (SQ_FAILED(sqstd_dofile(v, fname, SQFalse, SQTrue))) {
PrintError(v);
#if defined(_WIN32) || defined(_WIN64)
_getch();
#else
getch();
#endif
}
}
//!! CLEANUP
sq_rdbg_shutdown(rdbg);
}
else {
PrintError(v);
}
sq_close(v);
return 0;
}
示例11: SendFailure
bool BufReadCmd::Stage2()
{
#ifdef NO_LIBSNDFILE
SendFailure(&mReplyAddress, "/b_read", "scsynth compiled without libsndfile\n");
scprintf("scsynth compiled without libsndfile\n");
return false;
#else
SF_INFO fileinfo;
SndBuf *buf = World_GetNRTBuf(mWorld, mBufIndex);
int framesToEnd = buf->frames - mBufOffset;
if (framesToEnd <= 0) return true;
SNDFILE* sf = sf_open(mFilename, SFM_READ, &fileinfo);
if (!sf) {
char str[512];
sprintf(str, "File '%s' could not be opened: %s\n", mFilename, sf_strerror(NULL));
SendFailureWithIntValue(&mReplyAddress, "/b_read", str, mBufIndex); //SendFailure(&mReplyAddress, "/b_read", str);
scprintf(str);
return false;
}
if (fileinfo.channels != buf->channels) {
char str[512];
sf_close(sf);
sprintf(str, "Channel mismatch. File '%s' has %d channels. Buffer has %d channels.\n", mFilename, fileinfo.channels, buf->channels);
SendFailureWithIntValue(&mReplyAddress, "/b_read", str, mBufIndex); //SendFailure(&mReplyAddress, "/b_read", str);
scprintf(str);
return false;
}
if (mFileOffset < 0) mFileOffset = 0;
else if (mFileOffset > fileinfo.frames) mFileOffset = fileinfo.frames;
if (mNumFrames < 0 || mNumFrames + mFileOffset > fileinfo.frames) mNumFrames = fileinfo.frames - mFileOffset;
if (mNumFrames > framesToEnd) mNumFrames = framesToEnd;
sf_seek(sf, mFileOffset, SEEK_SET);
if (mNumFrames > 0) {
sf_readf_float(sf, buf->data + (mBufOffset * buf->channels), mNumFrames);
}
if(buf->sndfile)
sf_close(buf->sndfile);
if (mLeaveFileOpen) {
buf->sndfile = sf;
} else {
sf_close(sf);
buf->sndfile = 0;
}
mSampleRate = (double)fileinfo.samplerate;
return true;
#endif
}
示例12: DumpLiteral
void DumpLiteral(SQObjectPtr &o)
{
switch(type(o)){
case OT_STRING: scprintf(_SC("\"%s\""),_stringval(o));break;
case OT_FLOAT: scprintf(_SC("{%f}"),_float(o));break;
case OT_INTEGER: scprintf(_SC("{") _PRINT_INT_FMT _SC("}"),_integer(o));break;
case OT_BOOL: scprintf(_SC("%s"),_integer(o)?_SC("true"):_SC("false"));break;
default: scprintf(_SC("(%s %p)"),GetTypeName(o),(void*)_rawval(o));break; break; //shut up compiler
}
}
示例13: scsynth_android_open_udp
/*
* this is like World_OpenUDP() except it stores a static reference to the object
* TODO: maybe we could destatickify by pass a reference to the object back to java, to be passed to the closer?
*/
extern "C" void scsynth_android_open_udp(JNIEnv* env, jobject obj, jint port) {
scprintf("scsynth_android_open_udp\n");
try {
udpInPort = new SC_UdpInPort(world, port);
} catch (std::exception& exc) {
scprintf("Exception in scsynth_android_open_udp: %s\n", exc.what());
udpInPort = NULL;
} catch (...) {
}
}
示例14: PrintError
void PrintError(HSQUIRRELVM v)
{
const SQChar *err;
sq_getlasterror(v);
if(SQ_SUCCEEDED(sq_getstring(v,-1,&err))) {
scprintf(_SC("SQDBG error : %s"),err);
}else {
scprintf(_SC("SQDBG error"),err);
}
sq_pop(v,1);
}
示例15: Group_CalcTrace
void Group_CalcTrace(Group *inGroup)
{
scprintf("TRACE Group %d\n", inGroup->mNode.mID);
Node *child = inGroup->mHead;
while (child) {
Node *next = child->mNext;
scprintf(" %d %s\n", child->mID, (char*)child->mDef->mName);
(*child->mCalcFunc)(child);
child = next;
}
inGroup->mNode.mCalcFunc = (NodeCalcFunc)&Group_Calc;
}