コード例 #1
0
ファイル: MusicDecode.c プロジェクト: emoon/rocket
int Music_decode(text_t* path, MusicData* data)
{
    QWORD len;
    thrd_t id;

    if (thrd_busy == mtx_trylock(&s_mutex))
    {
	    Dialog_showError(TEXT("Decoding of stream already in-progress. Re-open after it's been completed."));
	    return 1;
    }

    // now this will break if we already have a thread running.

    free(data->fftData);
    data->fftData = 0;

	int flags = BASS_STREAM_DECODE | BASS_SAMPLE_MONO | BASS_POS_SCAN;

#ifdef _WIN32
	flags |= BASS_UNICODE;
#endif

	HSTREAM chan = BASS_StreamCreateFile(0, path, 0, 0, flags);

	if (!chan)
	{
	    Dialog_showError(TEXT("Unable to open stream for decode. No music data will be available."));
	    mtx_unlock(&s_mutex);
	    return 0;
	}

    len = BASS_ChannelGetLength(chan, BASS_POS_BYTE);

    if (len == -1)
    {
	    Dialog_showError(TEXT("Stream has no length. No music data will be available."));
        BASS_StreamFree(chan);
        mtx_unlock(&s_mutex);
        return 0;
    }

    ThreadFuncData* threadData = malloc(sizeof(ThreadFuncData));
    threadData->stream = chan;
    threadData->data = data;

    data->percentDone = 1;
    data->fftData = 0;

    // So there is a race-condition here as the mutex is unclocked while the thread is crated but in practice
    // this won't be a problem
    mtx_unlock(&s_mutex);

    if (thrd_create(&id, decodeFunc, threadData) != thrd_success)
    {
        printf("Unable to create decode thread. Stalling main thread and running...\n");
        decodeFunc(threadData);
    }

    return 1;
}
コード例 #2
0
ファイル: Editor.c プロジェクト: pixelmager/rocket
void Editor_create()
{
	int id;
	Emgui_create();
	id = Emgui_loadFontBitmap(g_minecraftiaFont, g_minecraftiaFontSize, EMGUI_LOCATION_MEMORY, 32, 128, g_minecraftiaFontLayout);

	if (!RemoteConnection_createListner())
	{
	#if defined(_WIN32)
		Dialog_showError(L"Unable to create listener. Make sure no other program is using port 1338");
	#else
		Dialog_showError("Unable to create listener. Make sure no other program is using port 1338");
	#endif
	}

	s_editorData.trackViewInfo.smallFontId = id;
	s_editorData.trackData.startRow = 0;
	s_editorData.trackData.endRow = 10000;
	s_editorData.trackData.highlightRowStep = 8;
	s_editorData.trackData.isPlaying = false;

	Emgui_setDefaultFont();
}