mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-06 13:38:56 +00:00
Make scePsmfPlayerSelect*() actually switch.
Don't have any games actually using this, so let's report too. Audio is falsely working when the stream isn't playable, not exactly sure the best way to detect that.
This commit is contained in:
parent
56673d3737
commit
891764d8ee
@ -63,6 +63,7 @@ enum PsmfPlayerError {
|
||||
ERROR_PSMF_INVALID_PSMF = 0x80615501,
|
||||
|
||||
ERROR_PSMFPLAYER_INVALID_STATUS = 0x80616001,
|
||||
ERROR_PSMFPLAYER_INVALID_STREAM = 0x80616003,
|
||||
ERROR_PSMFPLAYER_BUFFER_SIZE = 0x80616005,
|
||||
ERROR_PSMFPLAYER_INVALID_CONFIG = 0x80616006,
|
||||
ERROR_PSMFPLAYER_INVALID_PARAM = 0x80616008,
|
||||
@ -1545,17 +1546,24 @@ u32 scePsmfPlayerSelectAudio(u32 psmfPlayer)
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(ME, "scePsmfPlayerSelectAudio(%08x): invalid psmf player", psmfPlayer);
|
||||
return ERROR_PSMF_NOT_FOUND;
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
}
|
||||
|
||||
bool isInitialized = isInitializedStatus(psmfplayer->status);
|
||||
if (!isInitialized) {
|
||||
ERROR_LOG(ME, "scePsmfPlayerSelectAudio(%08x): not initialized", psmfPlayer);
|
||||
if (psmfplayer->status != PSMF_PLAYER_STATUS_PLAYING) {
|
||||
ERROR_LOG(ME, "scePsmfPlayerSelectAudio(%08x): not playing", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
}
|
||||
|
||||
ERROR_LOG(ME, "scePsmfPlayerSelectAudio(%08x)", psmfPlayer);
|
||||
psmfplayer->audioStreamNum++;
|
||||
int next = psmfplayer->audioStreamNum + 1;
|
||||
if (next >= psmfplayer->totalAudioStreams)
|
||||
next = 0;
|
||||
|
||||
if (next == psmfplayer->audioStreamNum || !psmfplayer->mediaengine->setAudioStream(next)) {
|
||||
ERROR_LOG_REPORT(ME, "scePsmfPlayerSelectAudio(%08x): no stream to switch to", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STREAM;
|
||||
}
|
||||
|
||||
WARN_LOG_REPORT(ME, "scePsmfPlayerSelectAudio(%08x)", psmfPlayer);
|
||||
psmfplayer->audioStreamNum = next;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1564,17 +1572,24 @@ u32 scePsmfPlayerSelectVideo(u32 psmfPlayer)
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(ME, "scePsmfPlayerSelectVideo(%08x): invalid psmf player", psmfPlayer);
|
||||
return ERROR_PSMF_NOT_FOUND;
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
}
|
||||
|
||||
bool isInitialized = isInitializedStatus(psmfplayer->status);
|
||||
if (!isInitialized) {
|
||||
ERROR_LOG(ME, "scePsmfPlayerSelectVideo(%08x): not initialized", psmfPlayer);
|
||||
if (psmfplayer->status != PSMF_PLAYER_STATUS_PLAYING) {
|
||||
ERROR_LOG(ME, "scePsmfPlayerSelectVideo(%08x): not playing", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
}
|
||||
|
||||
ERROR_LOG(ME, "scePsmfPlayerSelectVideo(%08x)", psmfPlayer);
|
||||
psmfplayer->videoStreamNum++;
|
||||
int next = psmfplayer->videoStreamNum + 1;
|
||||
if (next >= psmfplayer->totalVideoStreams)
|
||||
next = 0;
|
||||
|
||||
if (next == psmfplayer->videoStreamNum || !psmfplayer->mediaengine->setVideoStream(next)) {
|
||||
ERROR_LOG_REPORT(ME, "scePsmfPlayerSelectVideo(%08x): no stream to switch to", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STREAM;
|
||||
}
|
||||
|
||||
WARN_LOG_REPORT(ME, "scePsmfPlayerSelectVideo(%08x)", psmfPlayer);
|
||||
psmfplayer->videoStreamNum = next;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -367,11 +367,13 @@ bool MediaEngine::setVideoStream(int streamNum, bool force) {
|
||||
return true;
|
||||
}
|
||||
|
||||
m_videoStream = streamNum;
|
||||
#ifdef USE_FFMPEG
|
||||
if (m_pFormatCtx && m_pCodecCtxs.find(m_videoStream) == m_pCodecCtxs.end()) {
|
||||
if (m_pFormatCtx && m_pCodecCtxs.find(streamNum) == m_pCodecCtxs.end()) {
|
||||
// Get a pointer to the codec context for the video stream
|
||||
AVCodecContext *m_pCodecCtx = m_pFormatCtx->streams[m_videoStream]->codec;
|
||||
if ((u32)streamNum >= m_pFormatCtx->nb_streams) {
|
||||
return false;
|
||||
}
|
||||
AVCodecContext *m_pCodecCtx = m_pFormatCtx->streams[streamNum]->codec;
|
||||
|
||||
// Find the decoder for the video stream
|
||||
AVCodec *pCodec = avcodec_find_decoder(m_pCodecCtx->codec_id);
|
||||
@ -384,9 +386,10 @@ bool MediaEngine::setVideoStream(int streamNum, bool force) {
|
||||
if (avcodec_open2(m_pCodecCtx, pCodec, &optionsDict) < 0) {
|
||||
return false; // Could not open codec
|
||||
}
|
||||
m_pCodecCtxs[m_videoStream] = m_pCodecCtx;
|
||||
m_pCodecCtxs[streamNum] = m_pCodecCtx;
|
||||
}
|
||||
#endif
|
||||
m_videoStream = streamNum;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -68,7 +68,8 @@ public:
|
||||
int addStreamData(u8* buffer, int addSize);
|
||||
|
||||
bool setVideoStream(int streamNum, bool force = false);
|
||||
void setAudioStream(int streamNum) { m_audioStream = streamNum; }
|
||||
// TODO: Return false if the stream doesn't exist.
|
||||
bool setAudioStream(int streamNum) { m_audioStream = streamNum; return true; }
|
||||
|
||||
u8 *getFrameImage();
|
||||
int getRemainSize();
|
||||
|
Loading…
x
Reference in New Issue
Block a user