Пример #1
0
// Otwiera plik, ustala dla jego format oraz kodek, jaki bêdzie u¿yty
// Zwraca -1 jesli blad
static int openAudioFile(const char *cfilename)
{
	GOC_BDEBUG("-> openAudioFile: %s", cfilename);

	// wstepne inicjowanie i sprzatanie
	closeAudioFile();

	// czy wskazano jaki¶ plik
	if ( cfilename == NULL )
		return -1;
	// czy plik istnieje
	if ( ! goc_isFileExists( cfilename ) )
		return -1;
	if ( goc_isFolder( cfilename ) )
		return -1;
	// ustawienie nowego pliku odtwarzanego
	filename = cfilename;
	// otworz plik
	GOC_CHEOP(decoderOpen( filename, N_SAMPLES * N_CHANNELS ) == DECODER_CODE_OK, filename = NULL; return -1);
	GOC_BDEBUG("<- openAudioFile: %s", cfilename);
	eventChangeSongPlaying();
	if ( playerOpenOutput() == PLAYER_CODE_OK ) {
		return 0;
	} else {
		return -1;
	}
}
Пример #2
0
int main(int argc, char **argv)
{
    if ( argc == 2 )
    {
        const char *filename = argv[1];
        xmlDoc *doc = NULL;
        xmlNode *root = NULL;
        // zaladowanie pliku
        if ( !filename )
        {
            GOC_ERROR("Podano wartosn NULL");
            return -1;
        }
        if ( !goc_isFileExists(filename) )
        {
            GOC_BERROR("Plik [%s] nie istnieje", filename);
            return -1;
        }

        doc = xmlReadFile( filename, NULL, 0 );
        if ( !doc )
        {
            GOC_BERROR("Nieudane parsowanie pliku [%s]", filename);
            return -1;
        }
        root = xmlDocGetRootElement( doc );
        if ( !root )
        {
            GOC_ERROR("Nieudane pozyskanie galezi root");
            return -1;
        }


        {
            StKlasa* k = fobDeserialize( (fobElement*)root );
            fobSerialize( (fobElement*)k, stdout );
        }
    }
    else
    {
        StKlasa* k = fobAlloc(cn_Klasa);
        k->name = goc_stringCopy(k->name, "Nazwa");
        k->plist = goc_tableAdd(k->plist, &k->nlist, sizeof(char*));
        k->plist[k->nlist-1] = goc_stringCopy(NULL, "alfa");
        k->plist = goc_tableAdd(k->plist, &k->nlist, sizeof(char*));
        k->plist[k->nlist-1] = goc_stringCopy(NULL, "beta");
        fobSerialize( (fobElement*)k, stdout );
    }
    return 0;
}
Пример #3
0
static int hotKeySelectFolder(
	GOC_HANDLER uchwyt, GOC_MSG wiesc, void *pBuf, unsigned int nBuf)
{
	char *element = goc_stringCopy(NULL, goc_filelistGetFolder(uchwyt));
	element = goc_stringAdd(element, "/");
	element = goc_stringAdd(element, goc_listGetUnderCursor(uchwyt));
	if ( goc_isFileExists( element ) )
	{
		if ( goc_isFolder( element ) )
		{
			listAddFolder( element );
		}
		else
		{ // a wiec to plik
			checkAddFile( element );
		}
		char *tmp = goc_stringAdd(goc_stringCopy(NULL, "Dodano: "), element);
		goc_labelSetText(nStatus, tmp, 0);
		tmp = goc_stringFree(tmp);
		goc_systemSendMsg(nStatus, GOC_MSG_PAINT, 0, 0);
	}
}
Пример #4
0
int controlInit(int (*fun)(unsigned int, void*))
{
	if ( fun == NULL )
	{
		fprintf(stderr, "Nie podano funkcji kontrolnej.\n%s:%d\n",
				__FILE__, __LINE__);
		exit(1);
	}
	doAction = fun;
	// zainicjowanie systemu okienkoc
	goc_systemSetListenerFunc( &nasluch );
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'n', GOC_EFLAGA_ENABLE, hotKeyNext);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'N', GOC_EFLAGA_ENABLE, hotKeyNext);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'b', GOC_EFLAGA_ENABLE, hotKeyPrev);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'B', GOC_EFLAGA_ENABLE, hotKeyPrev);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'i', GOC_EFLAGA_ENABLE, hotKeyInfo);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'I', GOC_EFLAGA_ENABLE, hotKeyInfo);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'p', GOC_EFLAGA_ENABLE, hotKeyPause);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'P', GOC_EFLAGA_ENABLE, hotKeyPause);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'h', GOC_EFLAGA_ENABLE, hotKeyHelp);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'H', GOC_EFLAGA_ENABLE, hotKeyHelp);
	goc_hkAdd(GOC_HANDLER_SYSTEM, '?', GOC_EFLAGA_ENABLE, hotKeyHelp);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'q', GOC_EFLAGA_ENABLE, hotKeyQuit);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'Q', GOC_EFLAGA_ENABLE, hotKeyQuit);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 's', GOC_EFLAGA_ENABLE, hotKeyStop);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'S', GOC_EFLAGA_ENABLE, hotKeyStop);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 0x114, GOC_EFLAGA_ENABLE, hotKeyHome);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 0x120, GOC_EFLAGA_ENABLE, hotKeyAumixPlus);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 0x11f, GOC_EFLAGA_ENABLE, hotKeyAumixMinus);
	goc_hkAdd(GOC_HANDLER_SYSTEM, '+', GOC_EFLAGA_ENABLE, hotKeyAumixPlus);
	goc_hkAdd(GOC_HANDLER_SYSTEM, '-', GOC_EFLAGA_ENABLE, hotKeyAumixMinus);
	goc_hkAdd(GOC_HANDLER_SYSTEM, '*', GOC_EFLAGA_ENABLE, hotKeyAumixNext);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'r', GOC_EFLAGA_ENABLE, hotKeyShuffleOn);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'R', GOC_EFLAGA_ENABLE, hotKeyShuffleOff);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'l', GOC_EFLAGA_ENABLE, hotKeyShowList);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'L', GOC_EFLAGA_ENABLE, hotKeyShowList);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'a', GOC_EFLAGA_ENABLE, hotKeyAddFolder);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'A', GOC_EFLAGA_ENABLE, hotKeyAddFolder);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'x', GOC_EFLAGA_ENABLE, hotKeyQueue);
	goc_hkAdd(GOC_HANDLER_SYSTEM, 'X', GOC_EFLAGA_ENABLE, hotKeyQueue);
	
	nTytul = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 1, 0, 1,
		GOC_EFLAGA_PAINTED | GOC_EFLAGA_CENTER, GOC_WHITE, GOC_HANDLER_SYSTEM);
	goc_labelSetText(nTytul, "Rojkowy kontroler muzyki. Wersja 0.2 :+)",GOC_FALSE);
	nMixer = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 8, 8, 1,
		GOC_EFLAGA_PAINTED | GOC_EFLAGA_LEFT, GOC_WHITE, GOC_HANDLER_SYSTEM);
	pMixer = goc_elementCreate(GOC_ELEMENT_PRECENT, 9, 8, 0, 1,
		GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM);
	goc_precentSetMin(pMixer, 0);
	goc_precentSetMax(pMixer, 100);
	nPlik = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 3, 0, 2,
		GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM);
	nTitle = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 5, 0, 1,
		GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM);
	nArtist = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 6, goc_screenGetWidth()>>1, 1,
		GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM);
	nAlbum = goc_elementCreate(GOC_ELEMENT_LABEL, (goc_screenGetWidth()>>1) + 1, 6, 0, 1,
		GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM);
	nComment = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 7, goc_screenGetWidth()>>1, 1,
		GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM);
	nStatus = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 0, 0, 1,
		GOC_EFLAGA_PAINTED, GOC_GREEN, GOC_HANDLER_SYSTEM);
	nYear = goc_elementCreate(GOC_ELEMENT_LABEL, (goc_screenGetWidth()>>1) + 1, 7, 20, 1,
		GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM);
	lLista = goc_elementCreate(GOC_ELEMENT_SELLIST, 1, 10, 0, -1,
		0, GOC_WHITE, GOC_HANDLER_SYSTEM);
	pLista = goc_elementCreate(GOC_ELEMENT_FILELIST, 1, 10, 0, -1,
		0, GOC_WHITE, GOC_HANDLER_SYSTEM);
	if ( goc_isFileExists(LOGO_FILE) )
	{
		char *line = NULL;
		nLogo = goc_elementCreate(GOC_ELEMENT_LABEL, -20, -10, 20, 8,
			GOC_EFLAGA_PAINTED | GOC_EFLAGA_CENTER, GOC_CYAN, GOC_HANDLER_SYSTEM);
		GOC_IStream* streamLogo = goc_fileIStreamOpen(LOGO_FILE);
		while ( (line = goc_isReadLine( streamLogo )) )
		{
			goc_labelAddLine(nLogo, line);
			line = goc_stringFree( line );
		}
		goc_isClose( streamLogo );
	}
	goc_filelistSetFolder(pLista, ".");
	goc_hkAdd(pLista, ' ', GOC_EFLAGA_ENABLE, hotKeySelectFolder);
	goc_elementSetFunc(lLista, GOC_FUNID_LISTENER, nasluch);

	printMixer();
	return 0;
}