Fixed cmake and warnings

This commit is contained in:
TheFloW 2018-08-27 17:16:07 +02:00
parent aa777fe1ad
commit f067de203a
4 changed files with 454 additions and 445 deletions

View File

@ -57,10 +57,6 @@ ENDFUNCTION()
file(GLOB res_files RELATIVE
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/modules/kernel/kernel.skprx
${CMAKE_CURRENT_BINARY_DIR}/modules/user/user.suprx
${CMAKE_CURRENT_BINARY_DIR}/modules/patch/patch.skprx
${CMAKE_CURRENT_BINARY_DIR}/modules/usbdevice/usbdevice.skprx
resources/umass.skprx
resources/default/*.png
resources/default/*.txt
@ -70,7 +66,13 @@ file(GLOB res_files RELATIVE
resources/*.txt
resources/*.bin
)
add_resources(vitashell_res ${res_files})
add_resources(vitashell_res
${res_files}
build/modules/kernel/kernel.skprx
build/modules/user/user.suprx
build/modules/patch/patch.skprx
build/modules/usbdevice/usbdevice.skprx
)
add_executable(VitaShell
${vitashell_res}
@ -134,6 +136,10 @@ add_executable(VitaShell
)
add_dependencies(VitaShell vitashell_user_stubs)
add_dependencies(VitaShell kernel.skprx)
add_dependencies(VitaShell user.suprx)
add_dependencies(VitaShell patch.skprx)
add_dependencies(VitaShell usbdevice.skprx)
target_link_libraries(VitaShell
${CMAKE_CURRENT_BINARY_DIR}/modules/user/vitashell_user_stubs/libVitaShellUser_stub_weak.a
@ -196,9 +202,9 @@ vita_create_vpk(VitaShell.vpk ${VITA_TITLEID} eboot.bin
VERSION ${VITA_VERSION}
NAME ${VITA_APP_NAME}
FILE pkg/sce_sys/icon0.png sce_sys/icon0.png
pkg/sce_sys/livearea/contents/bg.png sce_sys/livearea/contents/bg.png
pkg/sce_sys/livearea/contents/startup.png sce_sys/livearea/contents/startup.png
pkg/sce_sys/livearea/contents/template.xml sce_sys/livearea/contents/template.xml
pkg/sce_sys/livearea/contents/bg.png sce_sys/livearea/contents/bg.png
pkg/sce_sys/livearea/contents/startup.png sce_sys/livearea/contents/startup.png
pkg/sce_sys/livearea/contents/template.xml sce_sys/livearea/contents/template.xml
)
add_custom_target(release

View File

@ -57,13 +57,13 @@ static int MP3_channels = 0;
static int MP3_tagRead = 0;
// The following variables are maintained and updated by the tracker during playback
static int MP3_isPlaying; // Set to true when a mod is being played
static int MP3_isPlaying; // Set to true when a mod is being played
static long MP3_suspendPosition = -1;
static long MP3_suspendIsPlaying = 0;
typedef struct {
short left;
short right;
short left;
short right;
} Sample;
//////////////////////////////////////////////////////////////////////
@ -106,15 +106,15 @@ static void ApplyFilter(struct mad_frame *Frame){
*/
Samples = MAD_NSBSAMPLES(&Frame->header);
if (Frame->header.mode != MAD_MODE_SINGLE_CHANNEL)
for (Channel = 0; Channel < 2; Channel++)
for (Sample = 0; Sample < Samples; Sample++)
for (SubBand = 0; SubBand < 32; SubBand++)
Frame->sbsample[Channel][Sample][SubBand] =
mad_f_mul(Frame->sbsample[Channel][Sample][SubBand], Filter[SubBand]);
for (Channel = 0; Channel < 2; Channel++)
for (Sample = 0; Sample < Samples; Sample++)
for (SubBand = 0; SubBand < 32; SubBand++)
Frame->sbsample[Channel][Sample][SubBand] =
mad_f_mul(Frame->sbsample[Channel][Sample][SubBand], Filter[SubBand]);
else
for (Sample = 0; Sample < Samples; Sample++)
for (SubBand = 0; SubBand < 32; SubBand++)
Frame->sbsample[0][Sample][SubBand] = mad_f_mul(Frame->sbsample[0][Sample][SubBand], Filter[SubBand]);
for (Sample = 0; Sample < Samples; Sample++)
for (SubBand = 0; SubBand < 32; SubBand++)
Frame->sbsample[0][Sample][SubBand] = mad_f_mul(Frame->sbsample[0][Sample][SubBand], Filter[SubBand]);
}
@ -123,17 +123,17 @@ static void ApplyFilter(struct mad_frame *Frame){
// short (16 bits).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
short convertSample(mad_fixed_t sample) {
// round
sample += (1L << (MAD_F_FRACBITS - 16));
// round
sample += (1L << (MAD_F_FRACBITS - 16));
// clip
if (sample >= MAD_F_ONE)
sample = MAD_F_ONE - 1;
else if (sample < -MAD_F_ONE)
sample = -MAD_F_ONE;
// clip
if (sample >= MAD_F_ONE)
sample = MAD_F_ONE - 1;
else if (sample < -MAD_F_ONE)
sample = -MAD_F_ONE;
// quantize
return sample >> (MAD_F_FRACBITS + 1 - 16);
// quantize
return sample >> (MAD_F_FRACBITS + 1 - 16);
}
@ -141,60 +141,60 @@ short convertSample(mad_fixed_t sample) {
//Streaming functions (adapted from Ghoti's MusiceEngine.c):
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int fillFileBuffer() {
// Find out how much to keep and how much to fill.
const unsigned int bytesToKeep = Stream.bufend - Stream.next_frame;
unsigned int bytesToFill = sizeof(fileBuffer) - bytesToKeep;
// Find out how much to keep and how much to fill.
const unsigned int bytesToKeep = Stream.bufend - Stream.next_frame;
unsigned int bytesToFill = sizeof(fileBuffer) - bytesToKeep;
// Want to keep any bytes?
if (bytesToKeep)
memmove(fileBuffer, fileBuffer + sizeof(fileBuffer) - bytesToKeep, bytesToKeep);
// Want to keep any bytes?
if (bytesToKeep)
memmove(fileBuffer, fileBuffer + sizeof(fileBuffer) - bytesToKeep, bytesToKeep);
// Read into the rest of the file buffer.
unsigned char* bufferPos = fileBuffer + bytesToKeep;
while (bytesToFill > 0){
int bytesRead = sceIoRead(MP3_fd, bufferPos, bytesToFill);
// Read into the rest of the file buffer.
unsigned char* bufferPos = fileBuffer + bytesToKeep;
while (bytesToFill > 0){
int bytesRead = sceIoRead(MP3_fd, bufferPos, bytesToFill);
if (bytesRead == 0x80010013) {
MP3_fd = sceIoOpen(MP3_fileName, SCE_O_RDONLY, 0777);
if (MP3_fd >= 0) {
sceIoLseek32(MP3_fd, MP3_filePos, SCE_SEEK_SET);
}
if (bytesRead == 0x80010013) {
MP3_fd = sceIoOpen(MP3_fileName, SCE_O_RDONLY, 0777);
if (MP3_fd >= 0) {
sceIoLseek32(MP3_fd, MP3_filePos, SCE_SEEK_SET);
}
bytesRead = sceIoRead(MP3_fd, bufferPos, bytesToFill);
}
bytesRead = sceIoRead(MP3_fd, bufferPos, bytesToFill);
}
// EOF?
if (bytesRead <= 0)
return 2;
// EOF?
if (bytesRead <= 0)
return 2;
// Adjust where we're writing to.
bytesToFill -= bytesRead;
bufferPos += bytesRead;
MP3_filePos += bytesRead;
}
return 0;
// Adjust where we're writing to.
bytesToFill -= bytesRead;
bufferPos += bytesRead;
MP3_filePos += bytesRead;
}
return 0;
}
void decode() {
while ((mad_frame_decode(&Frame, &Stream) == -1) && ((Stream.error == MAD_ERROR_BUFLEN) || (Stream.error == MAD_ERROR_BUFPTR))){
int tmp;
tmp = fillFileBuffer();
if (tmp==2)
while ((mad_frame_decode(&Frame, &Stream) == -1) && ((Stream.error == MAD_ERROR_BUFLEN) || (Stream.error == MAD_ERROR_BUFPTR))){
int tmp;
tmp = fillFileBuffer();
if (tmp==2)
eos = 1;
mad_stream_buffer(&Stream, fileBuffer, sizeof(fileBuffer));
}
mad_stream_buffer(&Stream, fileBuffer, sizeof(fileBuffer));
}
//Equalizers and volume boost (NEW METHOD):
if (DoFilter || MP3_volume_boost)
ApplyFilter(&Frame);
mad_timer_add(&Timer, Frame.header.duration);
mad_synth_frame(&Synth, &Frame);
mad_synth_frame(&Synth, &Frame);
}
void convertLeftSamples(Sample* first, Sample* last, const mad_fixed_t* src) {
Sample* dst;
for (dst = first; dst != last; ++dst){
dst->left = convertSample(*src++);
Sample* dst;
for (dst = first; dst != last; ++dst){
dst->left = convertSample(*src++);
//Volume Boost (OLD METHOD):
if (MP3_volume_boost_old)
dst->left = volume_boost(&dst->left, &MP3_volume_boost_old);
@ -202,9 +202,9 @@ void convertLeftSamples(Sample* first, Sample* last, const mad_fixed_t* src) {
}
void convertRightSamples(Sample* first, Sample* last, const mad_fixed_t* src) {
Sample* dst;
for (dst = first; dst != last; ++dst){
dst->right = convertSample(*src++);
Sample* dst;
for (dst = first; dst != last; ++dst){
dst->right = convertSample(*src++);
//Volume Boost (OLD METHOD):
if (MP3_volume_boost_old)
dst->right = volume_boost(&dst->right, &MP3_volume_boost_old);
@ -217,16 +217,16 @@ void convertRightSamples(Sample* first, Sample* last, const mad_fixed_t* src) {
static void MP3Callback(void *buffer, unsigned int samplesToWrite, void *pdata){
Sample *destination = (Sample*)buffer;
if (MP3_isPlaying == TRUE) { // Playing , so mix up a buffer
if (MP3_isPlaying == TRUE) { // Playing , so mix up a buffer
MP3_outputInProgress = 1;
while (samplesToWrite > 0) {
while (samplesToWrite > 0) {
const unsigned int samplesAvailable = Synth.pcm.length - samplesRead;
if (samplesAvailable > samplesToWrite) {
convertLeftSamples(destination, destination + samplesToWrite, &Synth.pcm.samples[0][samplesRead]);
if (MP3_channels == 2)
convertRightSamples(destination, destination + samplesToWrite, &Synth.pcm.samples[1][samplesRead]);
else
convertRightSamples(destination, destination + samplesToWrite, &Synth.pcm.samples[0][samplesRead]);
if (MP3_channels == 2)
convertRightSamples(destination, destination + samplesToWrite, &Synth.pcm.samples[1][samplesRead]);
else
convertRightSamples(destination, destination + samplesToWrite, &Synth.pcm.samples[0][samplesRead]);
samplesRead += samplesToWrite;
samplesToWrite = 0;
@ -236,15 +236,15 @@ static void MP3Callback(void *buffer, unsigned int samplesToWrite, void *pdata){
if (!MP3_newFilePos)
MP3_newFilePos = ID3v2TagSize(MP3_fileName);
int res = sceIoLseek32(MP3_fd, MP3_newFilePos, SCE_SEEK_SET);
if (res == 0x80010013) {
MP3_fd = sceIoOpen(MP3_fileName, SCE_O_RDONLY, 0777);
if (MP3_fd >= 0) {
sceIoLseek32(MP3_fd, MP3_filePos, SCE_SEEK_SET);
}
int res = sceIoLseek32(MP3_fd, MP3_newFilePos, SCE_SEEK_SET);
if (res == 0x80010013) {
MP3_fd = sceIoOpen(MP3_fileName, SCE_O_RDONLY, 0777);
if (MP3_fd >= 0) {
sceIoLseek32(MP3_fd, MP3_filePos, SCE_SEEK_SET);
}
res = sceIoLseek32(MP3_fd, MP3_newFilePos, SCE_SEEK_SET);
}
res = sceIoLseek32(MP3_fd, MP3_newFilePos, SCE_SEEK_SET);
}
if (res != MP3_filePos){
MP3_filePos = MP3_newFilePos;
@ -253,17 +253,17 @@ static void MP3Callback(void *buffer, unsigned int samplesToWrite, void *pdata){
MP3_newFilePos = -1;
}
//Check for playing speed:
//Check for playing speed:
if (MP3_playingSpeed){
int res = sceIoLseek32(MP3_fd, 2 * INPUT_BUFFER_SIZE * MP3_playingSpeed, SCE_SEEK_CUR);
if (res == 0x80010013) {
MP3_fd = sceIoOpen(MP3_fileName, SCE_O_RDONLY, 0777);
if (MP3_fd >= 0) {
sceIoLseek32(MP3_fd, MP3_filePos, SCE_SEEK_SET);
}
int res = sceIoLseek32(MP3_fd, 2 * INPUT_BUFFER_SIZE * MP3_playingSpeed, SCE_SEEK_CUR);
if (res == 0x80010013) {
MP3_fd = sceIoOpen(MP3_fileName, SCE_O_RDONLY, 0777);
if (MP3_fd >= 0) {
sceIoLseek32(MP3_fd, MP3_filePos, SCE_SEEK_SET);
}
res = sceIoLseek32(MP3_fd, 2 * INPUT_BUFFER_SIZE * MP3_playingSpeed, SCE_SEEK_CUR);
}
res = sceIoLseek32(MP3_fd, 2 * INPUT_BUFFER_SIZE * MP3_playingSpeed, SCE_SEEK_CUR);
}
if (res != MP3_filePos){
MP3_filePos += 2 * INPUT_BUFFER_SIZE * MP3_playingSpeed;
@ -273,10 +273,10 @@ static void MP3Callback(void *buffer, unsigned int samplesToWrite, void *pdata){
}
}else{
convertLeftSamples(destination, destination + samplesAvailable, &Synth.pcm.samples[0][samplesRead]);
if (MP3_channels == 2)
convertRightSamples(destination, destination + samplesAvailable, &Synth.pcm.samples[1][samplesRead]);
else
convertRightSamples(destination, destination + samplesAvailable, &Synth.pcm.samples[0][samplesRead]);
if (MP3_channels == 2)
convertRightSamples(destination, destination + samplesAvailable, &Synth.pcm.samples[1][samplesRead]);
else
convertRightSamples(destination, destination + samplesAvailable, &Synth.pcm.samples[0][samplesRead]);
samplesRead = 0;
decode();
@ -286,11 +286,11 @@ static void MP3Callback(void *buffer, unsigned int samplesToWrite, void *pdata){
}
}
MP3_outputInProgress = 0;
} else { // Not Playing , so clear buffer
int count;
for (count = 0; count < samplesToWrite; count++){
destination[count].left = 0;
destination[count].right = 0;
} else { // Not Playing , so clear buffer
int count;
for (count = 0; count < samplesToWrite; count++){
destination[count].left = 0;
destination[count].right = 0;
}
}
}
@ -303,8 +303,8 @@ void MP3_Init(int channel){
initAudioLib();
myChannel = channel;
MP3_isPlaying = FALSE;
MP3_playingSpeed = 0;
MP3_volume_boost = 0;
MP3_playingSpeed = 0;
MP3_volume_boost = 0;
MP3_volume_boost_old = 0;
initFileInfo(&MP3_info);
@ -317,7 +317,7 @@ void MP3_Init(int channel){
/* First the structures used by libmad must be initialized. */
mad_stream_init(&Stream);
mad_header_init(&Header);
mad_header_init(&Header);
mad_frame_init(&Frame);
mad_synth_init(&Synth);
mad_timer_reset(&Timer);
@ -354,7 +354,7 @@ void getMP3TagInfo(char *filename, struct fileInfo *targetInfo){
strcpy(targetInfo->year, ID3.ID3Year);
strcpy(targetInfo->genre, ID3.ID3GenreText);
strcpy(targetInfo->trackNumber, ID3.ID3TrackText);
targetInfo->length = ID3.ID3Length;
targetInfo->length = ID3.ID3Length;
targetInfo->encapsulatedPictureType = ID3.ID3EncapsulatedPictureType;
targetInfo->encapsulatedPictureOffset = ID3.ID3EncapsulatedPictureOffset;
targetInfo->encapsulatedPictureLength = ID3.ID3EncapsulatedPictureLength;
@ -365,40 +365,40 @@ void getMP3TagInfo(char *filename, struct fileInfo *targetInfo){
}
int MP3getInfo(){
unsigned long FrameCount = 0;
unsigned long FrameCount = 0;
int fd;
int bufferSize = 1024*496;
uint8_t *localBuffer;
int has_xing = 0;
struct xing xing;
memset(&xing, 0, sizeof xing);
memset(&xing, 0, sizeof xing);
long singleDataRed = 0;
struct mad_stream stream;
struct mad_header header;
struct mad_stream stream;
struct mad_header header;
int timeFromID3 = 0;
float mediumBitrate = 0.0f;
if (!MP3_tagRead)
getMP3TagInfo(MP3_fileName, &MP3_info);
mad_stream_init (&stream);
mad_header_init (&header);
mad_stream_init (&stream);
mad_header_init (&header);
fd = sceIoOpen(MP3_fileName, SCE_O_RDONLY, 0777);
if (fd < 0)
return -1;
long size = sceIoLseek(fd, 0, SCE_SEEK_END);
long size = sceIoLseek(fd, 0, SCE_SEEK_END);
sceIoLseek(fd, 0, SCE_SEEK_SET);
double startPos = ID3v2TagSize(MP3_fileName);
double startPos = ID3v2TagSize(MP3_fileName);
//Check for xing frame:
unsigned char *xing_buffer;
xing_buffer = (unsigned char *)malloc(XING_BUFFER_SIZE);
if (xing_buffer != NULL)
{
unsigned char *xing_buffer;
xing_buffer = (unsigned char *)malloc(XING_BUFFER_SIZE);
if (xing_buffer != NULL)
{
sceIoRead(fd, xing_buffer, XING_BUFFER_SIZE);
if(parse_xing(xing_buffer, 0, &xing))
{
@ -410,7 +410,7 @@ int MP3getInfo(){
free(xing_buffer);
}
sceIoLseek32(fd, startPos, SCE_SEEK_SET);
sceIoLseek32(fd, startPos, SCE_SEEK_SET);
startPos = SeekNextFrameMP3(fd);
size -= startPos;
@ -419,91 +419,91 @@ int MP3getInfo(){
localBuffer = (unsigned char *) malloc(sizeof(unsigned char) * bufferSize);
unsigned char *buff = localBuffer;
MP3_channels = 2;
MP3_info.fileType = MP3_TYPE;
MP3_channels = 2;
MP3_info.fileType = MP3_TYPE;
MP3_info.defaultCPUClock = MP3_defaultCPUClock;
MP3_info.needsME = 0;
MP3_info.fileSize = size;
MP3_info.fileSize = size;
MP3_info.framesDecoded = 0;
double totalBitrate = 0;
int i = 0;
for (i=0; i<3; i++){
for (i=0; i<3; i++){
memset(localBuffer, 0, bufferSize);
singleDataRed = sceIoRead(fd, localBuffer, bufferSize);
mad_stream_buffer (&stream, localBuffer, singleDataRed);
mad_stream_buffer (&stream, localBuffer, singleDataRed);
while (1){
if (mad_header_decode (&header, &stream) == -1){
if (mad_header_decode (&header, &stream) == -1){
if (stream.buffer == NULL || stream.error == MAD_ERROR_BUFLEN)
break;
else if (MAD_RECOVERABLE(stream.error)){
continue;
}else{
break;
}
}
//Informazioni solo dal primo frame:
if (FrameCount++ == 0){
switch (header.layer) {
case MAD_LAYER_I:
strcpy(MP3_info.layer,"I");
break;
case MAD_LAYER_II:
strcpy(MP3_info.layer,"II");
break;
case MAD_LAYER_III:
strcpy(MP3_info.layer,"III");
break;
default:
strcpy(MP3_info.layer,"unknown");
break;
}
else if (MAD_RECOVERABLE(stream.error)){
continue;
}else{
break;
}
}
//Informazioni solo dal primo frame:
if (FrameCount++ == 0){
switch (header.layer) {
case MAD_LAYER_I:
strcpy(MP3_info.layer,"I");
break;
case MAD_LAYER_II:
strcpy(MP3_info.layer,"II");
break;
case MAD_LAYER_III:
strcpy(MP3_info.layer,"III");
break;
default:
strcpy(MP3_info.layer,"unknown");
break;
}
MP3_info.kbit = header.bitrate / 1000;
MP3_info.instantBitrate = header.bitrate;
MP3_info.hz = header.samplerate;
switch (header.mode) {
case MAD_MODE_SINGLE_CHANNEL:
strcpy(MP3_info.mode, "single channel");
MP3_channels = 1;
break;
case MAD_MODE_DUAL_CHANNEL:
strcpy(MP3_info.mode, "dual channel");
MP3_channels = 2;
break;
case MAD_MODE_JOINT_STEREO:
strcpy(MP3_info.mode, "joint (MS/intensity) stereo");
MP3_channels = 2;
break;
case MAD_MODE_STEREO:
strcpy(MP3_info.mode, "normal LR stereo");
MP3_channels = 2;
break;
default:
strcpy(MP3_info.mode, "unknown");
MP3_channels = 2;
break;
}
MP3_info.kbit = header.bitrate / 1000;
MP3_info.instantBitrate = header.bitrate;
MP3_info.hz = header.samplerate;
switch (header.mode) {
case MAD_MODE_SINGLE_CHANNEL:
strcpy(MP3_info.mode, "single channel");
MP3_channels = 1;
break;
case MAD_MODE_DUAL_CHANNEL:
strcpy(MP3_info.mode, "dual channel");
MP3_channels = 2;
break;
case MAD_MODE_JOINT_STEREO:
strcpy(MP3_info.mode, "joint (MS/intensity) stereo");
MP3_channels = 2;
break;
case MAD_MODE_STEREO:
strcpy(MP3_info.mode, "normal LR stereo");
MP3_channels = 2;
break;
default:
strcpy(MP3_info.mode, "unknown");
MP3_channels = 2;
break;
}
switch (header.emphasis) {
case MAD_EMPHASIS_NONE:
strcpy(MP3_info.emphasis,"no");
break;
case MAD_EMPHASIS_50_15_US:
strcpy(MP3_info.emphasis,"50/15 us");
break;
case MAD_EMPHASIS_CCITT_J_17:
strcpy(MP3_info.emphasis,"CCITT J.17");
break;
case MAD_EMPHASIS_RESERVED:
strcpy(MP3_info.emphasis,"reserved(!)");
break;
default:
strcpy(MP3_info.emphasis,"unknown");
break;
}
switch (header.emphasis) {
case MAD_EMPHASIS_NONE:
strcpy(MP3_info.emphasis,"no");
break;
case MAD_EMPHASIS_50_15_US:
strcpy(MP3_info.emphasis,"50/15 us");
break;
case MAD_EMPHASIS_CCITT_J_17:
strcpy(MP3_info.emphasis,"CCITT J.17");
break;
case MAD_EMPHASIS_RESERVED:
strcpy(MP3_info.emphasis,"reserved(!)");
break;
default:
strcpy(MP3_info.emphasis,"unknown");
break;
}
//Check if lenght found in tag info:
if (MP3_info.length > 0){
@ -515,7 +515,7 @@ int MP3getInfo(){
}
totalBitrate += header.bitrate;
}
}
if (size == bufferSize)
break;
else if (i==0)
@ -525,11 +525,11 @@ int MP3getInfo(){
if (timeFromID3 || has_xing)
break;
}
mad_header_finish (&header);
mad_stream_finish (&stream);
}
mad_header_finish (&header);
mad_stream_finish (&stream);
if (buff)
free(buff);
free(buff);
sceIoClose(fd);
int secs = 0;
@ -538,21 +538,21 @@ int MP3getInfo(){
/* modify header.duration since we don't need it anymore */
mad_timer_multiply(&header.duration, xing.frames);
secs = mad_timer_count(header.duration, MAD_UNITS_SECONDS);
MP3_info.length = secs;
}
MP3_info.length = secs;
}
else if (!MP3_info.length){
mediumBitrate = totalBitrate / (float)FrameCount;
secs = size * 8 / mediumBitrate;
mediumBitrate = totalBitrate / (float)FrameCount;
secs = size * 8 / mediumBitrate;
MP3_info.length = secs;
}else{
secs = MP3_info.length;
}
//Formatto in stringa la durata totale:
int h = secs / 3600;
int m = (secs - h * 3600) / 60;
int s = secs - h * 3600 - m * 60;
snprintf(MP3_info.strLength, sizeof(MP3_info.strLength), "%2.2i:%2.2i:%2.2i", h, m, s);
//Formatto in stringa la durata totale:
int h = secs / 3600;
int m = (secs - h * 3600) / 60;
int s = secs - h * 3600 - m * 60;
snprintf(MP3_info.strLength, sizeof(MP3_info.strLength), "%2.2i:%2.2i:%2.2i", h, m, s);
return 0;
}
@ -574,7 +574,7 @@ void MP3_End(){
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int MP3_Load(char *filename){
eos = 0;
MP3_outputInProgress = 0;
MP3_outputInProgress = 0;
MP3_filePos = 0;
fileSize = 0;
samplesRead = 0;
@ -582,9 +582,9 @@ int MP3_Load(char *filename){
if (MP3_fd < 0)
return ERROR_OPENING;
fileSize = sceIoLseek32(MP3_fd, 0, SCE_SEEK_END);
sceIoLseek32(MP3_fd, 0, SCE_SEEK_SET);
tagsize = ID3v2TagSize(filename);
sceIoLseek32(MP3_fd, tagsize, SCE_SEEK_SET);
sceIoLseek32(MP3_fd, 0, SCE_SEEK_SET);
tagsize = ID3v2TagSize(filename);
sceIoLseek32(MP3_fd, tagsize, SCE_SEEK_SET);
SeekNextFrameMP3(MP3_fd);
MP3_isPlaying = FALSE;
@ -604,25 +604,25 @@ int MP3_Load(char *filename){
}
int MP3_IsPlaying() {
return MP3_isPlaying;
return MP3_isPlaying;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This function initialises for playing, and starts
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int MP3_Play(){
//Azzero il timer:
//Azzero il timer:
if (eos == 1){
mad_timer_reset(&Timer);
}
mad_timer_reset(&Timer);
}
// See if I'm already playing
// See if I'm already playing
if (MP3_isPlaying)
return FALSE;
return FALSE;
MP3_isPlaying = TRUE;
return TRUE;
return TRUE;
}
@ -659,8 +659,8 @@ void MP3_GetTimeString(char *dest){
// Get Percentage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
float MP3_GetPercentage(){
//Calcolo posizione in %:
float perc = 0.0f;
//Calcolo posizione in %:
float perc = 0.0f;
if (fileSize > 0){
perc = ((float)MP3_filePos) / ((float)fileSize - (float)tagsize) * 100.0;
@ -676,7 +676,7 @@ float MP3_GetPercentage(){
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int MP3_EndOfStream(){
if (eos == 1)
return 1;
return 1;
return 0;
}
@ -685,7 +685,7 @@ int MP3_EndOfStream(){
//Get info on file:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct fileInfo *MP3_GetInfo(){
return &MP3_info;
return &MP3_info;
}
@ -696,7 +696,7 @@ struct fileInfo MP3_GetTagInfoOnly(char *filename){
struct fileInfo tempInfo;
initFileInfo(&tempInfo);
getMP3TagInfo(filename, &tempInfo);
return tempInfo;
return tempInfo;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -739,7 +739,7 @@ void MP3_setVolumeBoost(int boost){
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int MP3_getVolumeBoost(){
if (MP3_volume_boost_type == BOOST_NEW){
return(MP3_volume_boost);
return(MP3_volume_boost);
}else{
return(MP3_volume_boost_old);
}
@ -750,41 +750,41 @@ int MP3_getVolumeBoost(){
//Set Filter:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int MP3_setFilter(double tFilter[32], int copyFilter){
//Converto i db:
double AmpFactor;
int i;
//Converto i db:
double AmpFactor;
int i;
for (i = 0; i < 32; i++){
//Check for volume boost:
if (MP3_volume_boost){
AmpFactor=pow(10.,(tFilter[i] + MP3_volume_boost * DB_forBoost)/20);
}else{
AmpFactor=pow(10.,tFilter[i]/20);
}
if(AmpFactor>mad_f_todouble(MAD_F_MAX))
{
DoFilter = 0;
return(0);
}else{
Filter[i]=mad_f_tofixed(AmpFactor);
}
if (copyFilter){
filterDouble[i] = tFilter[i];
}
}
return(1);
for (i = 0; i < 32; i++){
//Check for volume boost:
if (MP3_volume_boost){
AmpFactor=pow(10.,(tFilter[i] + MP3_volume_boost * DB_forBoost)/20);
}else{
AmpFactor=pow(10.,tFilter[i]/20);
}
if(AmpFactor>mad_f_todouble(MAD_F_MAX))
{
DoFilter = 0;
return(0);
}else{
Filter[i]=mad_f_tofixed(AmpFactor);
}
if (copyFilter){
filterDouble[i] = tFilter[i];
}
}
return(1);
}
int MP3_isFilterSupported(){
return 1;
return 1;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Check if filter is enabled:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int MP3_isFilterEnabled(){
return DoFilter;
return DoFilter;
}
@ -792,7 +792,7 @@ int MP3_isFilterEnabled(){
//Enable filter:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void MP3_enableFilter(){
DoFilter = 1;
DoFilter = 1;
}
@ -800,30 +800,30 @@ void MP3_enableFilter(){
//Disable filter:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void MP3_disableFilter(){
DoFilter = 0;
DoFilter = 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Get playing speed:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int MP3_getPlayingSpeed(){
return MP3_playingSpeed;
return MP3_playingSpeed;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Set playing speed:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int MP3_setPlayingSpeed(int playingSpeed){
if (playingSpeed >= MIN_PLAYING_SPEED && playingSpeed <= MAX_PLAYING_SPEED){
MP3_playingSpeed = playingSpeed;
if (playingSpeed == 0)
if (playingSpeed >= MIN_PLAYING_SPEED && playingSpeed <= MAX_PLAYING_SPEED){
MP3_playingSpeed = playingSpeed;
if (playingSpeed == 0)
setVolume(myChannel, 0x8000);
else
setVolume(myChannel, FASTFORWARD_VOLUME);
return 0;
}else{
return -1;
}
else
setVolume(myChannel, FASTFORWARD_VOLUME);
return 0;
}else{
return -1;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -846,36 +846,36 @@ void MP3_fadeOut(float seconds){
int MP3_suspend(){
MP3_suspendPosition = MP3_filePos;
MP3_suspendIsPlaying = MP3_isPlaying;
/*MP3_Stop();
/*MP3_Stop();
MP3_FreeTune();*/
MP3_isPlaying = FALSE;
MP3_isPlaying = FALSE;
mad_synth_finish(&Synth);
mad_header_finish(&Header);
mad_frame_finish(&Frame);
mad_stream_finish(&Stream);
sceIoClose(MP3_fd);
MP3_fd = -1;
MP3_fd = -1;
return 0;
}
int MP3_resume(){
if (MP3_suspendPosition >= 0){
mad_stream_init(&Stream);
mad_header_init(&Header);
mad_frame_init(&Frame);
mad_synth_init(&Synth);
mad_timer_reset(&Timer);
MP3_fd = sceIoOpen(MP3_fileName, SCE_O_RDONLY, 0777);
if (MP3_fd >= 0){
MP3_filePos = MP3_suspendPosition;
sceIoLseek32(MP3_fd, MP3_filePos, SCE_SEEK_SET);
mad_timer_set(&Timer, (int)((float)MP3_info.length / 100.0 * MP3_GetPercentage()), 1, 1);
MP3_isPlaying = MP3_suspendIsPlaying;
}
}
MP3_suspendPosition = -1;
if (MP3_suspendPosition >= 0){
mad_stream_init(&Stream);
mad_header_init(&Header);
mad_frame_init(&Frame);
mad_synth_init(&Synth);
mad_timer_reset(&Timer);
MP3_fd = sceIoOpen(MP3_fileName, SCE_O_RDONLY, 0777);
if (MP3_fd >= 0){
MP3_filePos = MP3_suspendPosition;
sceIoLseek32(MP3_fd, MP3_filePos, SCE_SEEK_SET);
mad_timer_set(&Timer, (int)((float)MP3_info.length / 100.0 * MP3_GetPercentage()), 1, 1);
MP3_isPlaying = MP3_suspendIsPlaying;
}
}
MP3_suspendPosition = -1;
return 0;
}

View File

@ -57,31 +57,31 @@ static void oggDecodeThread(void *_buf2, unsigned int numSamples, void *pdata){
short *_buf = (short *)_buf2;
//static short OGG_mixBuffer[VITA_NUM_AUDIO_SAMPLES * 2 * 2]__attribute__ ((aligned(64)));
//static unsigned long OGG_tempmixleft = 0;
int current_section;
int current_section;
if (OGG_isPlaying) { // Playing , so mix up a buffer
if (OGG_isPlaying) { // Playing , so mix up a buffer
outputInProgress = 1;
while (OGG_tempmixleft < numSamples) { // Not enough in buffer, so we must mix more
unsigned long bytesRequired = (numSamples - OGG_tempmixleft) * 4; // 2channels, 16bit = 4 bytes per sample
//unsigned long ret = ov_read(&OGG_VorbisFile, (char *) &OGG_mixBuffer[OGG_tempmixleft * 2], bytesRequired, &current_section); //libtremor
while (OGG_tempmixleft < numSamples) { // Not enough in buffer, so we must mix more
unsigned long bytesRequired = (numSamples - OGG_tempmixleft) * 4; // 2channels, 16bit = 4 bytes per sample
//unsigned long ret = ov_read(&OGG_VorbisFile, (char *) &OGG_mixBuffer[OGG_tempmixleft * 2], bytesRequired, &current_section); //libtremor
unsigned long ret = ov_read(&OGG_VorbisFile, (char *) &OGG_mixBuffer[OGG_tempmixleft * 2], bytesRequired, 0, 2, 1, &current_section); //ogg-vorbis
if (!ret) { //EOF
if (!ret) { //EOF
OGG_isPlaying = 0;
OGG_eos = 1;
OGG_eos = 1;
outputInProgress = 0;
return;
} else if (ret < 0) {
if (ret == OV_HOLE)
continue;
return;
} else if (ret < 0) {
if (ret == OV_HOLE)
continue;
OGG_isPlaying = 0;
OGG_eos = 1;
OGG_eos = 1;
outputInProgress = 0;
return;
}
OGG_tempmixleft += ret / 4; // back down to sample num
}
return;
}
OGG_tempmixleft += ret / 4; // back down to sample num
}
OGG_info.instantBitrate = ov_bitrate_instant(&OGG_VorbisFile);
OGG_milliSeconds = ov_time_tell(&OGG_VorbisFile);
OGG_milliSeconds = ov_time_tell(&OGG_VorbisFile);
if (OGG_newFilePos >= 0)
{
@ -95,9 +95,9 @@ static void oggDecodeThread(void *_buf2, unsigned int numSamples, void *pdata){
OGG_setPlayingSpeed(0);
}
if (OGG_tempmixleft >= numSamples) { // Buffer has enough, so copy across
int count, count2;
short *_buf2;
if (OGG_tempmixleft >= numSamples) { // Buffer has enough, so copy across
int count, count2;
short *_buf2;
//Volume boost:
if (!OGG_volume_boost){
for (count = 0; count < VITA_NUM_AUDIO_SAMPLES; count++) {
@ -114,18 +114,18 @@ static void oggDecodeThread(void *_buf2, unsigned int numSamples, void *pdata){
*(_buf2 + 1) = volume_boost(&OGG_mixBuffer[count2 + 1], &OGG_volume_boost);
}
}
// Move the pointers
OGG_tempmixleft -= numSamples;
// Now shuffle the buffer along
for (count = 0; count < OGG_tempmixleft * 2; count++)
OGG_mixBuffer[count] = OGG_mixBuffer[numSamples * 2 + count];
}
// Move the pointers
OGG_tempmixleft -= numSamples;
// Now shuffle the buffer along
for (count = 0; count < OGG_tempmixleft * 2; count++)
OGG_mixBuffer[count] = OGG_mixBuffer[numSamples * 2 + count];
}
outputInProgress = 0;
} else { // Not Playing , so clear buffer
} else { // Not Playing , so clear buffer
int count;
for (count = 0; count < numSamples * 2; count++)
*(_buf + count) = 0;
}
}
}
@ -135,54 +135,54 @@ static void oggDecodeThread(void *_buf2, unsigned int numSamples, void *pdata){
size_t ogg_callback_read(void *ptr, size_t size, size_t nmemb, void *datasource)
{
int res = sceIoRead(*(int *) datasource, ptr, size * nmemb);
if (res == 0x80010013) {
OGG_file = sceIoOpen(OGG_fileName, SCE_O_RDONLY, 0777);
if (OGG_file >= 0) {
sceIoLseek32(OGG_file, (uint32_t)OGG_getFilePosition(), SCE_SEEK_SET);
}
if (res == 0x80010013) {
OGG_file = sceIoOpen(OGG_fileName, SCE_O_RDONLY, 0777);
if (OGG_file >= 0) {
sceIoLseek32(OGG_file, (uint32_t)OGG_getFilePosition(), SCE_SEEK_SET);
}
res = sceIoRead(*(int *) datasource, ptr, size * nmemb);
}
return res;
res = sceIoRead(*(int *) datasource, ptr, size * nmemb);
}
return res;
}
int ogg_callback_seek(void *datasource, ogg_int64_t offset, int whence)
{
int res = sceIoLseek32(*(int *) datasource, (unsigned int) offset, whence);
if (res == 0x80010013) {
OGG_file = sceIoOpen(OGG_fileName, SCE_O_RDONLY, 0777);
if (OGG_file >= 0) {
sceIoLseek32(OGG_file, (uint32_t)OGG_getFilePosition(), SCE_SEEK_SET);
}
if (res == 0x80010013) {
OGG_file = sceIoOpen(OGG_fileName, SCE_O_RDONLY, 0777);
if (OGG_file >= 0) {
sceIoLseek32(OGG_file, (uint32_t)OGG_getFilePosition(), SCE_SEEK_SET);
}
res = sceIoLseek32(*(int *) datasource, (unsigned int) offset, whence);
}
return res;
res = sceIoLseek32(*(int *) datasource, (unsigned int) offset, whence);
}
return res;
}
long ogg_callback_tell(void *datasource)
{
int res = sceIoLseek32(*(int *) datasource, 0, SEEK_CUR);
if (res == 0x80010013) {
OGG_file = sceIoOpen(OGG_fileName, SCE_O_RDONLY, 0777);
if (OGG_file >= 0) {
sceIoLseek32(OGG_file, (uint32_t)OGG_getFilePosition(), SCE_SEEK_SET);
}
if (res == 0x80010013) {
OGG_file = sceIoOpen(OGG_fileName, SCE_O_RDONLY, 0777);
if (OGG_file >= 0) {
sceIoLseek32(OGG_file, (uint32_t)OGG_getFilePosition(), SCE_SEEK_SET);
}
res = sceIoLseek32(*(int *) datasource, 0, SEEK_CUR);
}
return (long)res;
res = sceIoLseek32(*(int *) datasource, 0, SEEK_CUR);
}
return (long)res;
}
int ogg_callback_close(void *datasource)
{
int res = sceIoClose(*(int *) datasource);
if (res == 0x80010013) {
OGG_file = sceIoOpen(OGG_fileName, SCE_O_RDONLY, 0777);
if (OGG_file >= 0) {
sceIoLseek32(OGG_file, (uint32_t)OGG_getFilePosition(), SCE_SEEK_SET);
}
if (res == 0x80010013) {
OGG_file = sceIoOpen(OGG_fileName, SCE_O_RDONLY, 0777);
if (OGG_file >= 0) {
sceIoLseek32(OGG_file, (uint32_t)OGG_getFilePosition(), SCE_SEEK_SET);
}
res = sceIoClose(*(int *) datasource);
}
return res;
res = sceIoClose(*(int *) datasource);
}
return res;
}
void readOggTagData(char *source, char *dest){
@ -201,52 +201,52 @@ void readOggTagData(char *source, char *dest){
}
void splitComment(char *comment, char *name, char *value){
char *result = NULL;
result = strtok(comment, "=");
int count = 0;
char *result = NULL;
result = strtok(comment, "=");
int count = 0;
while(result != NULL && count < 2){
if (strlen(result) > 0){
switch (count){
case 0:
strncpy(name, result, 30);
name[30] = '\0';
break;
case 1:
readOggTagData(result, value);
value[256] = '\0';
break;
}
count++;
}
result = strtok(NULL, "=");
}
while(result != NULL && count < 2){
if (strlen(result) > 0){
switch (count){
case 0:
strncpy(name, result, 30);
name[30] = '\0';
break;
case 1:
readOggTagData(result, value);
value[256] = '\0';
break;
}
count++;
}
result = strtok(NULL, "=");
}
}
void getOGGTagInfo(OggVorbis_File *inVorbisFile, struct fileInfo *targetInfo){
int i;
char name[31];
char value[257];
int i;
char name[31];
char value[257];
vorbis_comment *comment = ov_comment(inVorbisFile, -1);
for (i=0;i<comment->comments; i++){
splitComment(comment->user_comments[i], name, value);
if (!strcasecmp(name, "TITLE"))
strcpy(targetInfo->title, value);
else if(!strcasecmp(name, "ALBUM"))
strcpy(targetInfo->album, value);
else if(!strcasecmp(name, "ARTIST"))
strcpy(targetInfo->artist, value);
else if(!strcasecmp(name, "GENRE"))
strcpy(targetInfo->genre, value);
else if(!strcasecmp(name, "DATE") || !strcasecmp(name, "YEAR")){
vorbis_comment *comment = ov_comment(inVorbisFile, -1);
for (i=0;i<comment->comments; i++){
splitComment(comment->user_comments[i], name, value);
if (!strcasecmp(name, "TITLE"))
strcpy(targetInfo->title, value);
else if(!strcasecmp(name, "ALBUM"))
strcpy(targetInfo->album, value);
else if(!strcasecmp(name, "ARTIST"))
strcpy(targetInfo->artist, value);
else if(!strcasecmp(name, "GENRE"))
strcpy(targetInfo->genre, value);
else if(!strcasecmp(name, "DATE") || !strcasecmp(name, "YEAR")){
strncpy(targetInfo->year, value, 4);
targetInfo->year[4] = '\0';
}else if(!strcasecmp(name, "TRACKNUMBER")){
}else if(!strcasecmp(name, "TRACKNUMBER")){
strncpy(targetInfo->trackNumber, value, 7);
targetInfo->trackNumber[7] = '\0';
}
/*else if(!strcmp(name, "COVERART_UUENCODED")){
targetInfo->trackNumber[7] = '\0';
}
/*else if(!strcmp(name, "COVERART_UUENCODED")){
FILE *out = fopen("ms0:/coverart.jpg", "wb");
FILE *outEnc = fopen("ms0:/coverart.txt", "wb");
unsigned char base64Buffer[MAX_IMAGE_DIMENSION];
@ -256,7 +256,7 @@ void getOGGTagInfo(OggVorbis_File *inVorbisFile, struct fileInfo *targetInfo){
fclose(outEnc);
fclose(out);
}*/
}
}
OGG_info = *targetInfo;
OGG_tagRead = 1;
@ -269,27 +269,27 @@ void OGGgetInfo(){
OGG_info.needsME = 0;
vorbis_info *vi = ov_info(&OGG_VorbisFile, -1);
OGG_info.kbit = vi->bitrate_nominal/1000;
OGG_info.kbit = vi->bitrate_nominal/1000;
OGG_info.instantBitrate = vi->bitrate_nominal;
OGG_info.hz = vi->rate;
OGG_info.length = (long)ov_time_total(&OGG_VorbisFile, -1)/1000;
OGG_info.hz = vi->rate;
OGG_info.length = (long)ov_time_total(&OGG_VorbisFile, -1)/1000;
if (vi->channels == 1){
strcpy(OGG_info.mode, "single channel");
OGG_channels = 1;
OGG_channels = 1;
}else if (vi->channels == 2){
strcpy(OGG_info.mode, "normal LR stereo");
OGG_channels = 2;
}
OGG_channels = 2;
}
strcpy(OGG_info.emphasis, "no");
int h = 0;
int m = 0;
int s = 0;
long secs = OGG_info.length;
h = secs / 3600;
m = (secs - h * 3600) / 60;
s = secs - h * 3600 - m * 60;
snprintf(OGG_info.strLength, sizeof(OGG_info.strLength), "%2.2i:%2.2i:%2.2i", h, m, s);
int h = 0;
int m = 0;
int s = 0;
long secs = OGG_info.length;
h = secs / 3600;
m = (secs - h * 3600) / 60;
s = secs - h * 3600 - m * 60;
snprintf(OGG_info.strLength, sizeof(OGG_info.strLength), "%2.2i:%2.2i:%2.2i", h, m, s);
if (!OGG_tagRead)
getOGGTagInfo(&OGG_VorbisFile, &OGG_info);
@ -311,16 +311,16 @@ void OGG_Init(int channel){
int OGG_Load(char *filename){
outputInProgress = 0;
OGG_isPlaying = 0;
OGG_milliSeconds = 0;
OGG_eos = 0;
outputInProgress = 0;
OGG_isPlaying = 0;
OGG_milliSeconds = 0;
OGG_eos = 0;
OGG_playingSpeed = 0;
OGG_playingDelta = 0;
strcpy(OGG_fileName, filename);
//Apro il file OGG:
strcpy(OGG_fileName, filename);
//Apro il file OGG:
OGG_file = sceIoOpen(OGG_fileName, SCE_O_RDONLY, 0777);
if (OGG_file >= 0) {
if (OGG_file >= 0) {
OGG_info.fileSize = sceIoLseek(OGG_file, 0, SCE_SEEK_END);
sceIoLseek(OGG_file, 0, SCE_SEEK_SET);
ov_callbacks ogg_callbacks;
@ -329,47 +329,47 @@ int OGG_Load(char *filename){
ogg_callbacks.seek_func = ogg_callback_seek;
ogg_callbacks.close_func = ogg_callback_close;
ogg_callbacks.tell_func = ogg_callback_tell;
if (ov_open_callbacks(&OGG_file, &OGG_VorbisFile, NULL, 0, ogg_callbacks) < 0){
if (ov_open_callbacks(&OGG_file, &OGG_VorbisFile, NULL, 0, ogg_callbacks) < 0){
sceIoClose(OGG_file);
OGG_file = -1;
return ERROR_OPENING;
}
}else{
return ERROR_OPENING;
}
}else{
return ERROR_OPENING;
}
OGGgetInfo();
OGGgetInfo();
//Controllo il sample rate:
if (vitaAudioSetFrequency(OGG_audio_channel, OGG_info.hz) < 0){
OGG_FreeTune();
return ERROR_INVALID_SAMPLE_RATE;
}
return OPENING_OK;
return OPENING_OK;
}
int OGG_IsPlaying() {
return OGG_isPlaying;
return OGG_isPlaying;
}
int OGG_Play(){
OGG_isPlaying = 1;
return 0;
OGG_isPlaying = 1;
return 0;
}
void OGG_Pause(){
OGG_isPlaying = !OGG_isPlaying;
OGG_isPlaying = !OGG_isPlaying;
}
int OGG_Stop(){
OGG_isPlaying = 0;
OGG_isPlaying = 0;
//This is to be sure that oggDecodeThread isn't messing with &OGG_VorbisFile
while (outputInProgress == 1)
sceKernelDelayThread(100000);
return 0;
return 0;
}
void OGG_FreeTune(){
ov_clear(&OGG_VorbisFile);
ov_clear(&OGG_VorbisFile);
if (OGG_file >= 0)
sceIoClose(OGG_file);
OGG_file = -1;
@ -378,22 +378,22 @@ void OGG_FreeTune(){
}
void OGG_GetTimeString(char *dest){
char timeString[9];
long secs = (long)OGG_milliSeconds/1000;
int h = secs / 3600;
int m = (secs - h * 3600) / 60;
int s = secs - h * 3600 - m * 60;
snprintf(timeString, sizeof(timeString), "%2.2i:%2.2i:%2.2i", h, m, s);
strcpy(dest, timeString);
char timeString[9];
long secs = (long)OGG_milliSeconds/1000;
int h = secs / 3600;
int m = (secs - h * 3600) / 60;
int s = secs - h * 3600 - m * 60;
snprintf(timeString, sizeof(timeString), "%2.2i:%2.2i:%2.2i", h, m, s);
strcpy(dest, timeString);
}
int OGG_EndOfStream(){
return OGG_eos;
return OGG_eos;
}
struct fileInfo *OGG_GetInfo(){
return &OGG_info;
return &OGG_info;
}
@ -404,9 +404,9 @@ struct fileInfo OGG_GetTagInfoOnly(char *filename){
strcpy(OGG_fileName, filename);
initFileInfo(&tempInfo);
//Apro il file OGG:
tempFile = sceIoOpen(filename, SCE_O_RDONLY, 0777);
if (tempFile >= 0) {
//Apro il file OGG:
tempFile = sceIoOpen(filename, SCE_O_RDONLY, 0777);
if (tempFile >= 0) {
//sceIoLseek(tempFile, 0, SCE_SEEK_SET);
ov_callbacks ogg_callbacks;
@ -415,7 +415,7 @@ struct fileInfo OGG_GetTagInfoOnly(char *filename){
ogg_callbacks.close_func = ogg_callback_close;
ogg_callbacks.tell_func = ogg_callback_tell;
if (ov_open_callbacks(&tempFile, &vf, NULL, 0, ogg_callbacks) < 0){
if (ov_open_callbacks(&tempFile, &vf, NULL, 0, ogg_callbacks) < 0){
sceIoClose(tempFile);
return tempInfo;
}
@ -423,7 +423,7 @@ struct fileInfo OGG_GetTagInfoOnly(char *filename){
ov_clear(&vf);
if (tempFile >= 0)
sceIoClose(tempFile);
}
}
return tempInfo;
}
@ -436,14 +436,14 @@ float OGG_GetPercentage(){
if (perc > 100)
perc = 100;
}
return perc;
return perc;
}
void OGG_End(){
OGG_Stop();
vitaAudioSetChannelCallback(OGG_audio_channel, 0,0);
OGG_FreeTune();
endAudioLib();
vitaAudioSetChannelCallback(OGG_audio_channel, 0,0);
OGG_FreeTune();
endAudioLib();
}
int OGG_setMute(int onOff){
@ -463,30 +463,30 @@ void OGG_setVolumeBoost(int boost){
}
int OGG_getVolumeBoost(){
return OGG_volume_boost;
return OGG_volume_boost;
}
int OGG_setPlayingSpeed(int playingSpeed){
if (playingSpeed >= MIN_PLAYING_SPEED && playingSpeed <= MAX_PLAYING_SPEED){
OGG_playingSpeed = playingSpeed;
if (playingSpeed == 0)
setVolume(OGG_audio_channel, 0x8000);
else
setVolume(OGG_audio_channel, FASTFORWARD_VOLUME);
if (playingSpeed >= MIN_PLAYING_SPEED && playingSpeed <= MAX_PLAYING_SPEED){
OGG_playingSpeed = playingSpeed;
if (playingSpeed == 0)
setVolume(OGG_audio_channel, 0x8000);
else
setVolume(OGG_audio_channel, FASTFORWARD_VOLUME);
OGG_playingDelta = VITA_NUM_AUDIO_SAMPLES * (int)(OGG_playingSpeed/2);
return 0;
}else{
return -1;
}
return 0;
}else{
return -1;
}
}
int OGG_getPlayingSpeed(){
return OGG_playingSpeed;
return OGG_playingSpeed;
}
int OGG_GetStatus(){
return 0;
return 0;
}
void OGG_setVolumeBoostType(char *boostType){
@ -498,7 +498,7 @@ void OGG_setVolumeBoostType(char *boostType){
//Functions for filter (equalizer):
int OGG_setFilter(double tFilter[32], int copyFilter){
return 0;
return 0;
}
void OGG_enableFilter(){}
@ -506,11 +506,11 @@ void OGG_enableFilter(){}
void OGG_disableFilter(){}
int OGG_isFilterSupported(){
return 0;
return 0;
}
int OGG_isFilterEnabled(){
return 0;
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -34,6 +34,9 @@
int module_get_export_func(SceUID pid, const char *modname, uint32_t libnid, uint32_t funcnid, uintptr_t *func);
int module_get_offset(SceUID pid, SceUID modid, int segidx, size_t offset, uintptr_t *addr);
int ksceNpDrmGetRifVitaKey(void *license_buf, uint8_t *klicensee, uint32_t *flags,
uint32_t *sku_flag, uint64_t *start_time, uint64_t *expiration_time);
typedef struct {
const char *dev;
const char *dev2;
@ -91,8 +94,8 @@ int shellKernelIsUx0Redirected(const char *blkdev, const char *blkdev2) {
return 0;
}
ksceKernelStrncpyUserToKernel(k_blkdev, blkdev, sizeof(k_blkdev)-1);
ksceKernelStrncpyUserToKernel(k_blkdev2, blkdev2, sizeof(k_blkdev2)-1);
ksceKernelStrncpyUserToKernel(k_blkdev, (uintptr_t)blkdev, sizeof(k_blkdev)-1);
ksceKernelStrncpyUserToKernel(k_blkdev2, (uintptr_t)blkdev2, sizeof(k_blkdev2)-1);
if (mount && mount->dev && mount->dev->blkdev && strcmp(mount->dev->blkdev, k_blkdev) == 0) {
EXIT_SYSCALL(state);
@ -113,8 +116,8 @@ int shellKernelRedirectUx0(const char *blkdev, const char *blkdev2) {
return -1;
}
ksceKernelStrncpyUserToKernel(ux0_blkdev, blkdev, sizeof(ux0_blkdev)-1);
ksceKernelStrncpyUserToKernel(ux0_blkdev2, blkdev2, sizeof(ux0_blkdev2)-1);
ksceKernelStrncpyUserToKernel(ux0_blkdev, (uintptr_t)blkdev, sizeof(ux0_blkdev)-1);
ksceKernelStrncpyUserToKernel(ux0_blkdev2, (uintptr_t)blkdev2, sizeof(ux0_blkdev2)-1);
mount->dev = &ux0_dev;
mount->dev2 = &ux0_dev;
@ -230,12 +233,12 @@ int shellKernelGetRifVitaKey(const void *license_buf, void *klicensee) {
memset(k_klicensee, 0, sizeof(k_klicensee));
if (license_buf)
ksceKernelMemcpyUserToKernel(k_license_buf, license_buf, sizeof(k_license_buf));
ksceKernelMemcpyUserToKernel(k_license_buf, (uintptr_t)license_buf, sizeof(k_license_buf));
int res = ksceNpDrmGetRifVitaKey(k_license_buf, k_klicensee, NULL, NULL, NULL, NULL);
int res = ksceNpDrmGetRifVitaKey(k_license_buf, (uint8_t *)k_klicensee, NULL, NULL, NULL, NULL);
if (klicensee)
ksceKernelMemcpyKernelToUser(klicensee, k_klicensee, sizeof(k_klicensee));
ksceKernelMemcpyKernelToUser((uintptr_t)klicensee, k_klicensee, sizeof(k_klicensee));
return res;
}