int MP3ME_Load(char *fileName){ MP3ME_filePos = 0; MP3ME_playingSpeed = 0; MP3ME_isPlaying = 0; getcwd(audioCurrentDir, 256); //initFileInfo(&MP3ME_info); strcpy(MP3ME_fileName, fileName); if (MP3MEgetInfo() != 0){ strcpy(MP3ME_fileName, ""); return ERROR_OPENING; } releaseAudio(); if (setAudioFrequency(OUTPUT_BUFFER_SIZE/4, MP3ME_info.hz, 2) < 0){ MP3ME_End(); return ERROR_INVALID_SAMPLE_RATE; } MP3ME_thid = -1; MP3ME_eof = 0; MP3ME_thid = sceKernelCreateThread("decodeThread", decodeThread, THREAD_PRIORITY, DEFAULT_THREAD_STACK_SIZE, PSP_THREAD_ATTR_USER, NULL); if(MP3ME_thid < 0) return ERROR_CREATE_THREAD; sceKernelStartThread(MP3ME_thid, 0, NULL); return OPENING_OK; }
void TalkbackCore::talkbackCoreThreadStep_deinit_audioData() { //fix me if(m_pAudioDataContext!=NULL){ releaseAudio(m_pAudioDataContext); delete m_pAudioDataContext; m_pAudioDataContext=NULL; m_tEventCallbackState.state=false; m_tEventCallbackState.bExistError=false; if(NULL!=m_tEventCallbackState.pMessage){ delete m_tEventCallbackState.pMessage; m_tEventCallbackState.pMessage=NULL; } if(NULL!=m_pEventCallbackStateLock){ delete m_pEventCallbackStateLock; m_pEventCallbackStateLock=NULL; } } #ifdef TEST_G711 if(NULL!=m_pRtspInfo->file){ fclose(m_pRtspInfo->file); m_pRtspInfo->file=NULL; } #endif }
/*! \internal */ void QBluetoothHeadsetService::stateChanged(QBluetoothAbstractSocket::SocketState socketState) { qLog(Bluetooth) << "QBluetoothHeadsetService::stateChanged..."; switch (socketState) { case QBluetoothRfcommSocket::ConnectingState: qLog(Bluetooth) << "Headset socket now in connecting state..."; break; case QBluetoothRfcommSocket::ConnectedState: QTimer::singleShot(0, this, SLOT(sendRings())); break; case QBluetoothRfcommSocket::ClosingState: qLog(Bluetooth) << "Headset socket now in closing state..."; break; case QBluetoothRfcommSocket::UnconnectedState: { bool emitDisconnected = true; qLog(Bluetooth) << "Client socket is now in disconnected state."; if (m_data->m_connectInProgress) { qLog(Bluetooth) << "Connect was in progress, connection failed."; m_data->m_connectInProgress = false; emitDisconnected = false; emit connectResult(false, "Connection failed."); } else if (m_data->m_disconnectInProgress) { qLog(Bluetooth) << "Disconnect was in progress, connection failed."; m_data->m_disconnectInProgress = false; } else { releaseAudio(); qWarning("Headset unexpectedly closed rfcomm connection"); } m_data->m_client->deleteLater(); m_data->m_client = 0; m_data->m_interface->setValue("IsConnected", false); m_data->m_interface->setValue("RemotePeer", QVariant::fromValue(QBluetoothAddress::invalid)); qLog(Bluetooth) << "Deleting session for headset"; m_data->m_session->endSession(); if (emitDisconnected) emit disconnected(); break; } default: break; }; }
/*! This method is the concrete implementation of the QBluetoothAudioGateway interface method of the same name. It is called from the QBluetoothHandsfreeAudioGatewayServer class, which acts as a forwarding agent. \sa QBluetoothHandsfreeAudioGatewayServer */ void QBluetoothHeadsetService::disconnect() { releaseAudio(); if (!m_data->m_client) return; if (m_data->m_client->state() == QBluetoothRfcommSocket::ConnectedState || m_data->m_client->state() == QBluetoothRfcommSocket::ConnectingState) { m_data->m_connectInProgress = false; m_data->m_disconnectInProgress = true; m_data->m_client->disconnect(); } }
int MP3ME_Load(char * path){ MP3ME_filePos = 0; MP3ME_isPlaying = 0; MP3ME_playingTime = 0; strcpy(MP3ME_Name, path); // Needed for decode thread releaseAudio(); if (setAudioFrequency(OUTPUT_BUFFER_SIZE/4, 44100, 2) < 0){ MP3ME_Stop(); return ERROR_INVALID_SAMPLE_RATE; } MP3ME_eof = 0; MP3ME_thid = sceKernelCreateThread("decodeThread", decodeThread, THREAD_PRIORITY, 0x10000, PSP_THREAD_ATTR_USER, NULL); if(MP3ME_thid < 0) return ERROR_CREATE_THREAD; sceKernelStartThread(MP3ME_thid, 0, NULL); return OPENING_OK; }
void MP3Play(char * path) { struct ID3Tag ID3; nowplaying = oslLoadImageFilePNG(nowplayingBgPath, OSL_IN_RAM, OSL_PF_8888); mp3Play = oslLoadImageFilePNG("system/app/apollo/play.png", OSL_IN_RAM, OSL_PF_8888); mp3Pause = oslLoadImageFilePNG("system/app/apollo/pause.png", OSL_IN_RAM, OSL_PF_8888); if (!nowplaying) debugDisplay(); scePowerSetClockFrequency(333, 333, 166); pspAudioInit(); int i, mp3Min = 0; MP3ME_Init(1); ParseID3(path, &ID3); MP3ME_Load(path); MP3ME_Play(); isPlaying = 1; while (!osl_quit) { LowMemExit(); oslStartDrawing(); oslClearScreen(RGB(0,0,0)); oslReadKeys(); oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, 0); if (MP3ME_playingTime > 59) { mp3Min += 1; MP3ME_playingTime = 0; } oslDrawImageXY(nowplaying, 0, 0); oslDrawStringf(240,76, "Playing: %.19s", folderIcons[current].name); oslDrawStringf(240,96, "Title: %.21s", ID3.ID3Title); oslDrawStringf(240,116, "Artist: %.20s", ID3.ID3Artist); oslDrawStringf(240,136, "Album: %.21s", ID3.ID3Album); oslDrawStringf(240,156, "Year: %.22s", ID3.ID3Year); oslDrawStringf(240,176, "Genre: %.21s", ID3.ID3GenreText); oslDrawStringf(435,206, "0%d:%.f", mp3Min, MP3ME_playingTime); if (MP3ME_isPlaying == 1) oslDrawImageXY(mp3Play, 230, 224); if (MP3ME_isPlaying == 0) oslDrawImageXY(mp3Pause, 230, 224); battery(370,2,1); digitaltime(420,4,0,hrTime); volumeController(); if(osl_keys->pressed.select) { oslDeleteImage(nowplaying); oslDeleteImage(mp3Play); oslDeleteImage(mp3Pause); return; } if(MP3ME_isPlaying == 1 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); MP3ME_Pause(); for(i=0; i<10; i++) { sceDisplayWaitVblankStart(); } } else if (MP3ME_isPlaying == 0 && osl_keys->pressed.cross) { MP3ME_Play(); } if (MP3ME_EndOfStream() == 1) { isPlaying = 0; endAudioLib(); MP3ME_Stop(); releaseAudio(); MP3ME_Play(); } if(osl_keys->pressed.circle) { endAudioLib(); MP3ME_Stop(); releaseAudio(); oslDeleteImage(nowplaying); oslDeleteImage(mp3Play); oslDeleteImage(mp3Pause); isPlaying = 0; setCpuBoot(); //Restore previous CPU state return; } if (osl_keys->pressed.square) { powermenu(); } if (osl_keys->pressed.L) { oslPlaySound(Lock, 1); lockscreen(); } captureScreenshot(); oslEndDrawing(); oslEndFrame(); oslSyncFrame(); } }
void mp3Controls() //Controls { oslReadKeys(); if (pad.Buttons != oldpad.Buttons) { if (osl_keys->pressed.down) { mp3Down(); timer = 0; } else if (osl_keys->pressed.up) { mp3Up(); timer = 0; } if (osl_keys->pressed.right) { mp3Downx5(); timer = 0; } else if (osl_keys->pressed.left) { mp3Upx5(); timer = 0; } if (osl_keys->pressed.triangle) { curScroll = 1; current = 1; } if (osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); openDir(folderIcons[current].filePath, folderIcons[current].fileType); } } volumeController(); char * ext = strrchr(folderIcons[current].filePath, '.'); if (osl_keys->pressed.circle) { if((strcmp("ms0:/MUSIC", curDir)==0) || (strcmp("ms0:/PSP/MUSIC", curDir)==0) || (strcmp("ms0:/PSP/GAME/CyanogenPSP/downloads", curDir)==0) || (strcmp("ms0:/", curDir)==0)) { oslDeleteImage(mp3bg); oslDeleteImage(mp3_select); mp3player(); } else if((strcmp("ms0:/MUSIC", curDir)!=0)) { dirBack(3); } else if((strcmp("ms0:/PSP/MUSIC", curDir)!=0)) { dirBack(4); } else if((strcmp("ms0:/PSP/GAME/CyanogenPSP/downloads", curDir)!=0)) { dirBack(5); } } if (((ext) != NULL) && ((strcmp(ext ,".mp3") == 0) || ((strcmp(ext ,".MP3") == 0))) && (osl_keys->pressed.cross)) { if (isPlaying == 1) { endAudioLib(); MP3ME_Stop(); releaseAudio(); MP3Play(folderIcons[current].filePath); } else { oslPlaySound(KeypressStandard, 1); MP3Play(folderIcons[current].filePath); } } if (osl_keys->pressed.square) { powermenu(); } if (osl_keys->pressed.L) { oslPlaySound(Lock, 1); lockscreen(); } captureScreenshot(); timer++; if ((timer > 30) && (pad.Buttons & PSP_CTRL_UP)) { mp3Up(); timer = 25; } else if ((timer > 30) && (pad.Buttons & PSP_CTRL_DOWN)) { mp3Down(); timer = 25; } if (current < 1) current = 1; if (current > MAX_FILES) current = MAX_FILES; }
/*! \internal */ void QBluetoothHeadsetService::readyRead() { char buf[512]; int size = m_data->m_client->read(buf, 512); buf[size] = '\0'; int volume = 0; if (m_data->m_connectInProgress) { if (!strncmp("AT+CKPD=200\r", buf, 512)) { m_data->m_client->write("\r\nOK\r\n"); emit connectResult(true, QString()); m_data->m_connectInProgress = false; m_data->m_interface->setValue("IsConnected", true); m_data->m_interface->setValue("RemotePeer", QVariant::fromValue(m_data->m_client->remoteAddress())); } else { m_data->m_client->write("\r\nERROR\r\n"); } return; } if (!strncmp("AT+CKPD=200\r", buf, 512)) { qLog(Bluetooth) << "QBluetoothHeadsetService::readyRead: Got an AT+CKPD=200"; // Audio not connected if (m_data->m_scofd == -1) { qLog(Bluetooth) << "QBluetoothHeadsetService::readyRead: No audio."; if (doConnectAudio()) { m_data->m_client->write("\r\nOK\r\n"); } else { m_data->m_client->write("\r\nERROR\r\n"); } } else { qLog(Bluetooth) << "QBluetoothHeadsetService::readyRead: Releasing audio."; releaseAudio(); m_data->m_client->write("\r\nOK\r\n"); } } else if (sscanf(buf, "AT+VGS=%d", &volume) == 1) { qLog(Bluetooth) << "QBluetoothHeadsetService::readyRead: Got a SpeakerVolume change."; if (m_data->m_speakerVolume != volume) { m_data->m_speakerVolume = volume; m_data->m_interface->setValue("SpeakerVolume", volume); emit speakerVolumeChanged(); } m_data->m_client->write("\r\nOK\r\n"); } else if (sscanf(buf, "AT+VGM=%d", &volume) == 1) { qLog(Bluetooth) << "QBluetoothHeadsetService::readyRead: Got a MicrophoneVolume change."; if (m_data->m_microphoneVolume != volume) { m_data->m_microphoneVolume = volume; m_data->m_interface->setValue("MicrophoneVolume", volume); emit microphoneVolumeChanged(); } m_data->m_client->write("\r\nOK\r\n"); } }
/*! Asks the Audio Gateway to release the SCO audio data connection. No audio should be routed through the associated audio device. \sa connectAudio() */ void QBluetoothAudioGateway::releaseAudio() { invoke( SLOT(releaseAudio()) ); }