static int MP3Thread(SceSize args, void *argp) { while (mp3_active) { sceKernelSleepThread(); if (mp3_newfile) { mp3_newfile = 0; mp3_running = 1; MP3Update(); mp3_running = 0; } } return 0; }
void play( const char *fileE, int ) { if ( Type != 0 && Type != 2 ) return ERROR2( "Wtyczka obsługuje tylko odczyt plików i strumienia internetowego!" ); if ( Type == 2 ) { QString tmp = loadCURL(); if ( !CURLloaded ) return ERROR2( "Nie można załadować biblioteki: "+QMPInternetf+libExt+"\n"+tmp ); } if ( fileE != curF ) clrPos(); clrSet(); QString BLAD; if ( Type == 0 ) BLAD = "Błąd odczytu pliku!"; else if ( Type == 2 ) BLAD = "Nie można otworzyć strumienia internetowego!"; musicfile = mpg123_new(NULL, NULL); if ( Type == 0 ) { fd = qmp_open( fileE, O_RDONLY|O_BINARY ); mpg123_open_fd( musicfile, fd ); } if ( Type == 2 ) { title = "Czekaj, trwa otwieranie..."; mpg123_open_feed( musicfile ); f = url_fopen(fileE,0,1); if ( !f ) return ERROR(BLAD); if ( !getDataBuff( f, url_fread, _DATA_BUFF, &data, &bolStop ) ) return ERROR(BLAD); url_fread(data+10, 1, _DATA_BUFF-10, f); if ( getNetInfo( f, FILE_SIZE ) > 0.0 ) knownSize = true; mpg123_decode( musicfile, (const unsigned char*)data, _DATA_BUFF, 0,0,0 ); } if ( !musicfile ) return ERROR(BLAD); curF = fileE; if ( !MP3Update() ) return ERROR(BLAD); if ( Type == 2 && title.isEmpty() ) title = fileE; if ( Type == 2 || ( Type == 0 && fileE[0] == '/' && fileE[1] == '/' ) ) QOut->useQMPBuffer(); QOut->Init( AudioInfo( rate, 16, chn ), true, 0, fileE, /*title*/Title ); if ( *QOut->PlErr ) { *QOut->PlErr = false; return ERROR("Błąd zwraca wtyczka wyjściowa!"); } IsPlaying = true; size_t bDecoded = 0; audio_buffer = new char[BUF_SIZE]; TMPint = 0; int musErr = 0; for(;;) { if ( bolStop ) break; if ( !IsPaused ) { if ( !*QOut->mustReset ) { if ( doSeek ) { mpg123_seek( musicfile, doSeek, SEEK_SET ); QOut->control( QOUT_NEXT_READ ); doSeek = 0; } musErr = mpg123_read( musicfile, (unsigned char*)audio_buffer, BUF_SIZE, &bDecoded ); if ( musErr == MPG123_DONE ) break; if ( musErr == MPG123_ERR && !searchParts ) break; QOut->Play( audio_buffer, bDecoded, pltime, false ); MP3Update2( bDecoded ); if ( musErr == MPG123_NEED_MORE && Type != 0 ) { int bread = url_fread( data, 1, _DATA_BUFF, f ); if ( ( !bread && !wait4Data ) || ( !bread && url_feof(f) ) ) break; else if ( !bread ) MYsleep( 25 ); mpg123_decode( musicfile, (const unsigned char*)data, bread, NULL, 0, NULL ); } } else QOut->Play(0,0,pltime,true); } else QOut->Play(0,0,pltime,true); } STOP(); }