Beispiel #1
0
int main(int argc, char *argv[])
{
    ALCdevice *device;
    ALCcontext *context;

    if(argc > 1 && (strcmp(argv[1], "--help") == 0 ||
                    strcmp(argv[1], "-h") == 0))
    {
        printf("Usage: %s [playback device]\n", argv[0]);
        return 0;
    }

    printf("Available playback devices:\n");
    if(alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE)
        printDeviceList(alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER));
    else
        printDeviceList(alcGetString(NULL, ALC_DEVICE_SPECIFIER));
    printf("Available capture devices:\n");
    printDeviceList(alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER));

    if(alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE)
        printf("Default playback device: %s\n",
               alcGetString(NULL, ALC_DEFAULT_ALL_DEVICES_SPECIFIER));
    else
        printf("Default playback device: %s\n",
               alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER));
    printf("Default capture device: %s\n",
           alcGetString(NULL, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER));

    printALCInfo(NULL);

    device = alcOpenDevice((argc>1) ? argv[1] : NULL);
    if(!device)
    {
        printf("\n!!! Failed to open %s !!!\n\n", ((argc>1) ? argv[1] : "default device"));
        return 1;
    }
    printALCInfo(device);
    printHRTFInfo(device);

    context = alcCreateContext(device, NULL);
    if(!context || alcMakeContextCurrent(context) == ALC_FALSE)
    {
        if(context)
            alcDestroyContext(context);
        alcCloseDevice(device);
        printf("\n!!! Failed to set a context !!!\n\n");
        return 1;
    }

    printALInfo();
    printEFXInfo(device);

    alcMakeContextCurrent(NULL);
    alcDestroyContext(context);
    alcCloseDevice(device);

    return 0;
}
int TileStaticBandwidth<T>::setup()
{
    if(printDeviceList() != AMP_SUCCESS)
        return AMP_FAILURE;
    if(setDefaultAccelerator() != AMP_SUCCESS)
        return AMP_FAILURE;
    for(unsigned int i = 0; i<outputLength; i++)
    {
        output.push_back(T(0));
    }

    return AMP_SUCCESS;
}
static BOOL handleCommand(char line[])
{
    BOOL ret = TRUE;
    if (strcmp(line, "q") == 0)
        ret = FALSE;
    else if (strcmp(line, "o") == 0 &&
             gDeviceHandle == INVALID_HANDLE_VALUE)
        openDriver();
    else if (strcmp(line, "c") == 0 &&
             gDeviceHandle != INVALID_HANDLE_VALUE)
        closeDriver();
    else if (strcmp(line, "g") == 0 &&
             gDeviceHandle != INVALID_HANDLE_VALUE &&
             gDeviceListSize == 0)
        getDeviceList();
    else if (strcmp(line, "p") == 0 &&
             gDeviceHandle != INVALID_HANDLE_VALUE &&
             gDeviceListSize > 0)
        printDeviceList();
    else if (strcmp(line, "r") == 0 &&
             gDeviceHandle != INVALID_HANDLE_VALUE &&
             gDeviceListSize > 0)
        releaseDeviceList();
    else if (line[0] == 'm' &&
             gDeviceHandle != INVALID_HANDLE_VALUE &&
             gDeviceListSize > 0)
        sendControlRequest(line + 1);
    else if (line[0] == 'a' &&
             gDeviceHandle != INVALID_HANDLE_VALUE &&
             gDeviceListSize > 0)
        sendAapRequest(line + 1);
    else if (line[0] == 'c' &&
             gDeviceHandle != INVALID_HANDLE_VALUE &&
             gDeviceListSize > 0)
        requestConfigurationDescriptor(line + 1);
    else if (line[0] == 'o' &&
             gDeviceHandle != INVALID_HANDLE_VALUE &&
             gDeviceListSize > 0)
        getActiveConfigValue(line + 1);
    else if (line[0] == 's' &&
             gDeviceHandle != INVALID_HANDLE_VALUE &&
             gDeviceListSize > 0)
        setActiveConfigValue(line + 1);
    else if (line[0] == 'i' &&
             gDeviceHandle != INVALID_HANDLE_VALUE &&
             gDeviceListSize > 0)
        performInterfaceOperation(line + 1);
    else if (line[0] == 'r' &&
             gDeviceHandle != INVALID_HANDLE_VALUE &&
             gDeviceListSize > 0)
        resetDevice(line + 1);
    else if (line[0] == 'k' &&
             gDeviceHandle != INVALID_HANDLE_VALUE &&
             gDeviceListSize > 0)
        performKernelAttachOperation(line + 1);
    else if (line[0] == 'b' &&
             gDeviceHandle != INVALID_HANDLE_VALUE &&
             gDeviceListSize > 0)
        startAAPBulkTransfer(line + 1);
    else if (line[0] == 'h' &&
             gDeviceHandle != INVALID_HANDLE_VALUE &&
             gDeviceListSize > 0)
        performHaltOperation(line + 1);
    else
        printf("Unknown command '%s'\n", line);
    return ret;
}
Beispiel #4
0
void deviceSystemHandleRawData(char header, InputStream* inputStream, OutputStream* outputStream) {
    if (header == COMMAND_PING) {
        // data
        ackCommand(outputStream, SYSTEM_DEVICE_HEADER, COMMAND_PING);
        
        // Read and write in output the pingIndex (to control that it's the right which does the response)
        unsigned char pingIndex = readHex2(inputStream);
        appendHex2(outputStream, pingIndex);
    }
    // Last Error
    else if (header == COMMAND_GET_LAST_ERROR) {
        ackCommand(outputStream, SYSTEM_DEVICE_HEADER, COMMAND_GET_LAST_ERROR);
        unsigned int lastError = getLastError();
        appendHex4(outputStream, lastError);
    }
    else if (header == COMMAND_CLEAR_LAST_ERROR) {
        ackCommand(outputStream, SYSTEM_DEVICE_HEADER, COMMAND_CLEAR_LAST_ERROR);
        clearLastError();
    }
    // Device list
    else if (header == COMMAND_DEVICE_LIST) {
        ackCommand(outputStream, SYSTEM_DEVICE_HEADER, COMMAND_DEVICE_LIST);
        printDeviceList(getInfoOutputStreamLogger());
    // Usage
    } else if (header == COMMAND_USAGE) {
        ackCommand(outputStream, SYSTEM_DEVICE_HEADER, COMMAND_USAGE);
        printDeviceListUsage(getInfoOutputStreamLogger(), false);
    } else if (header == COMMAND_USAGE_PROBLEM) {
        ackCommand(outputStream, SYSTEM_DEVICE_HEADER, COMMAND_USAGE_PROBLEM);
        printDeviceListUsage(getInfoOutputStreamLogger(), true);
    }    
    else if (header == COMMAND_USAGE_SPECIFIC_DEVICE) {
         ackCommand(outputStream, SYSTEM_DEVICE_HEADER, COMMAND_USAGE_SPECIFIC_DEVICE);
         char deviceHeader = readBinaryChar(inputStream);
         int size = getDeviceCount();
         int i;
         for (i = 0; i < size; i++) {
             Device* device = getDevice(i);
             if (deviceHeader == device->deviceInterface->deviceHeader) {
                 println(getInfoOutputStreamLogger());
                 printDeviceUsage(getInfoOutputStreamLogger(), device, false);
                 return;
             }
         }
         appendString(getErrorOutputStreamLogger(), "Device Not Found ! ");
    }
	else if (header == COMMAND_CLS) {
		ackCommand(outputStream, SYSTEM_DEVICE_HEADER, COMMAND_CLS);
#ifdef PC_COMPILER
		system("cls");
#else
		appendString(outputStream, "Unsupported Operation");
#endif // PC_COMPILER
	}
	else if (header == COMMAND_RESET) {
		ackCommand(outputStream, SYSTEM_DEVICE_HEADER, COMMAND_RESET);
		#ifdef PC_COMPILER
			appendString(outputStream, "Unsupported Operation");
		#else
			// goto 0;
		#endif // PC_COMPILER
	}
    // Notifications
    else if (header == COMMAND_NOTIFICATION) {
        ackCommand(outputStream, SYSTEM_DEVICE_HEADER, COMMAND_NOTIFICATION);
        printDeviceListNotification(getInfoOutputStreamLogger(), false);
    } else if (header == COMMAND_WAIT) {
        appendAck(outputStream);
        int mSec = readHex4(inputStream);
        delaymSec(mSec);
        append(outputStream, SYSTEM_DEVICE_HEADER);
        append(outputStream, COMMAND_WAIT);
    } else if (header == COMMAND_BOARD_NAME) {
        appendString(getInfoOutputStreamLogger(), getBoardName());
        println(getInfoOutputStreamLogger());
        ackCommand(outputStream, SYSTEM_DEVICE_HEADER, COMMAND_BOARD_NAME);
    }
}