Esempio n. 1
0
// ---------------------------------------------------------------------
FskErr FskNetInterfaceDescribe(int idx, FskNetInterfaceRecord **iface)
{
	int i = 0;
	FskErr ret = kFskErrNone;
	FskNetInterfaceRecord *nir;

	FskMutexAcquire(gNetworkInterfaceList->mutex);
	nir = (FskNetInterfaceRecord *)gNetworkInterfaceList->list;

	while (nir) {
		if (i == idx)
			break;
		nir = nir->next;
		i++;
	}

	if (nir) {
		FskNetInterfaceRecord *dup;
		if (kFskErrNone == FskMemPtrNewFromData(sizeof(FskNetInterfaceRecord), nir, &dup)) {
			dup->next = NULL;
			dup->name = FskStrDoCopy(nir->name);
		}
		*iface = dup;
	}
	else {
		*iface = NULL;
		ret = kFskErrNetworkInterfaceNotFound;
	}

	FskMutexRelease(gNetworkInterfaceList->mutex);
	return ret;
}
Esempio n. 2
0
// ---------------------------------------------------------------------
void sNotifyInterfaceNotifiers(FskNetInterfaceRecord *iface, UInt32 status) {
	FskNetInterfaceNotifier callback = NULL, next;
	FskThread thread = FskThreadGetCurrent();

	callback = (FskNetInterfaceNotifier)FskListMutexGetNext(interfaceChangeCBList, NULL);
	while (callback) {
		next = (FskNetInterfaceNotifier)FskListMutexGetNext(interfaceChangeCBList, callback);
#if 0 && SUPPORT_INSTRUMENTATION
		if (FskInstrumentedItemHasListeners(callback)) {
			FskNetInterfaceRecord *iface = (FskNetInterfaceRecord *)FskNetInterfaceFindByName(ifcName);
			FskInterfaceInstrData data;
			data.notf = callback;
			data.ifc = iface;
			data.status = status;
			FskInstrumentedItemSendMessage(callback, kFskNetInstrMsgInterfaceNotify, &data);
		}
#endif /* SUPPORT_INSTRUMENTATION */
		if (callback->thread != thread) {
			FskNetInterfaceRecord *interFace;
			if (kFskErrNone == FskMemPtrNewFromData(sizeof(FskNetInterfaceRecord), iface, &interFace)) {
				interFace->next = NULL;
				interFace->name = FskStrDoCopy(iface->name);

				// POST notify
				FskInstrumentedTypePrintfDebug(&gNetInterfaceNotifierTypeInstrumentation, " - posting callback to thread %s for interface %s", callback->thread->name, iface->name);
				FskThreadPostCallback(callback->thread, doNetIfcCallback, (void*)callback->callback, (void*)interFace, (void*)status, (void*)callback->param);
			}
		}
		else {
			FskInstrumentedTypePrintfDebug(&gNetInterfaceNotifierTypeInstrumentation, "callback->thread %s - call", callback->thread->name);
			(callback->callback)(iface, status, callback->param);
		}
		callback = next;
	}
}
Esempio n. 3
0
static FskErr
newSSLVM(FskECMAScript *vmp)
{
	FskECMAScript vm;
	FskErr err;

#ifdef KPR_CONFIG
	if ((err = FskMemPtrNewClear(sizeof(FskECMAScriptRecord), &vm)) != kFskErrNone)
		return err;
	if ((vm->the = xsAliasMachine(&anAllocation, gShell->root, "SSL", vm)) == NULL) {
		FskMemPtrDispose(vm);
		return kFskErrMemFull;
	}
#else
	if (gSSLVM == NULL)
		return kFskErrUnimplemented;

	if ((err = FskMemPtrNewFromData(sizeof(FskECMAScriptRecord), gSSLVM, &vm)) != kFskErrNone)
		return err;
	vm->the = NULL;
	vm->context = NULL;
	vm->refcon = NULL;
	vm->libraries = NULL;
	vm->name = FskStrDoCopy("SSL");
	vm->thread = FskThreadGetCurrent();
	vm->id = (UInt32)vm;

	if ((vm->the = xsAliasMachine(&anAllocation, gSSLVM->the, vm->name, vm)) == NULL) {
		FskMemPtrDispose(vm);
		return kFskErrMemFull;
	}
#endif
	*vmp = vm;
	return err;
}
Esempio n. 4
0
FskErr mp3ReaderTrackGetFormatInfo(void *readerState, void *track, UInt32 propertyID, FskMediaPropertyValue property)
{
	mp3Reader state = readerState;
	UInt8 esds[] = {	0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x80, 0x80, 0x22, 0x00, 0x00, 0x00, 0x04, 0x80, 0x80, 0x80,
						0x14, 0x40, 0x15, 0x00, 0x18, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x05, 0x80,
						0x80, 0x80, 0x02, 0x10, 0x00, 0x06, 0x80, 0x80, 0x80, 0x01, 0x02};
	const UInt32 kESDSPatchOffset = 35;
	const UInt32 sampleRates[] = {96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000};
	UInt32 sampleRateIndex = 0;

	if (kFskAudioFormatAACADTS != state->mi.codec)
		return kFskErrUnimplemented;

	for (sampleRateIndex = 0; sampleRateIndex < 12; sampleRateIndex++) {
		if (sampleRates[sampleRateIndex] == state->mi.frequency)
			break;
	}
	if (sampleRateIndex > 11)
		return state->mi.frequency;

	esds[kESDSPatchOffset] |= (UInt8)(sampleRateIndex >> 1);
	esds[kESDSPatchOffset + 1] |= (UInt8)((sampleRateIndex & 1) << 7);
	if (1 == state->mi.channelCount)
		esds[kESDSPatchOffset + 1] |= 0x08;
	else if (2 == state->mi.channelCount)
		esds[kESDSPatchOffset + 1] |= 0x10;

	property->type = kFskMediaPropertyTypeData;
	property->value.data.dataSize = sizeof(esds);
	return FskMemPtrNewFromData(sizeof(esds), esds, (FskMemPtr*)(void*)(&property->value.data.data));
}
Esempio n. 5
0
FskErr FskAudioCompressGetDescription(FskAudioCompress comp, void **desc, UInt32 *descSize)
{
    if (comp->desc) {
        *descSize = comp->descSize;
        return FskMemPtrNewFromData(comp->descSize, comp->desc, (FskMemPtr *)desc);
    }
    *desc = NULL;
    *descSize = 0;
    return kFskErrNone;
}
Esempio n. 6
0
FskErr FskFSFileResolveLink(const char *fullPath, char **resolved)
{
	FskErr	err = kFskErrNone;
	char 	linkPath[PATH_MAX];

	if (realpath(fullPath, linkPath) == NULL)
		BAIL(kFskErrOperationFailed);

	err = FskMemPtrNewFromData(FskStrLen(linkPath) + 1, linkPath, (FskMemPtr *)resolved);

bail:
	return err;
}
Esempio n. 7
0
FskErr FskAudioDecompressNew(FskAudioDecompress *decoOut, UInt32 audioFormat, const char *mimeType, UInt32 sampleRate, UInt32 channelCount, void *formatInfo, UInt32 formatInfoSize)
{
    FskErr err;
    FskAudioDecompressor decoder;
    FskAudioDecompress deco;
    UInt32 i = 0;

    while (true) {
        Boolean canHandle = false;
        decoder = (FskAudioDecompressor)FskExtensionGetByIndex(kFskExtensionAudioDecompressor, i++);
        if (NULL == decoder) {
            if (decoOut)
                *decoOut = NULL;
            return kFskErrExtensionNotFound;
        }

        if ((kFskErrNone == decoder->doCanHandle(audioFormat, mimeType, &canHandle)) && canHandle)
            break;
    }

    if (NULL == decoOut)
        return kFskErrNone;			// can handler

    err = FskMemPtrNewClear(sizeof(FskAudioDecompressRecord), &deco);
    BAIL_IF_ERR(err);

    deco->inputSampleRate = sampleRate;
    deco->inputChannelCount = channelCount;
    deco->outputChannelCount = channelCount;

    deco->formatInfoSize = formatInfoSize;
    err = FskMemPtrNewFromData(formatInfoSize, formatInfo, (FskMemPtr*)(void*)&deco->formatInfo);
    BAIL_IF_ERR(err);

    deco->decoder = decoder;
    FskInstrumentedItemNew(deco, FskStrDoCopy_Untracked(mimeType), &gAudioDecompressTypeInstrumentation);
    err = deco->decoder->doNew(deco, audioFormat, mimeType);
    BAIL_IF_ERR(err);

bail:
    if (err) {
        FskAudioDecompressDispose(deco);
        deco = NULL;
    }
    *decoOut = deco;

    return err;
}
Esempio n. 8
0
// ---------------------------------------------------------------------
FskNetInterfaceRecord *FskNetInterfaceFindByName(char *name)
{
	FskNetInterfaceRecord	*ret = NULL, *found;

	FskInstrumentedTypePrintfDebug(&gNetInterfaceNotifierTypeInstrumentation, "FskNetInterfaceFindByName: %s", (name == NULL) ? "NULL" : name);
	FskMutexAcquire(gNetworkInterfaceList->mutex);
	found = (FskNetInterfaceRecord *)sFskNetInterfaceFindByName(name, (FskNetInterfaceRecord  *)gNetworkInterfaceList->list);
	if (found) {
		if (kFskErrNone == FskMemPtrNewFromData(sizeof(FskNetInterfaceRecord), found, &ret)) {
			ret->next = NULL;
			ret->name = FskStrDoCopy(found->name);
		}
	}
	FskMutexRelease(gNetworkInterfaceList->mutex);

	return ret;
}
Esempio n. 9
0
FskErr FskSetAndroidCallbacks(FskAndroidCallbacks callbacks) {
// this is too early, if we call instrumentation here we will crash
// --	FskHardwarePrintfDebug("set android callbacks\n");
    FskMemPtrDisposeAt(&gAndroidCallbacks);
    return FskMemPtrNewFromData(sizeof(FskAndroidCallbacksRecord), callbacks, &gAndroidCallbacks);
}
Esempio n. 10
0
FskErr KprMemoryBufferCopyBuffer(KprMemoryBuffer self, FskMemPtr *it)
{
	return FskMemPtrNewFromData(self->size, self->buffer, it);
}