mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-13 09:39:33 +01:00
Add support for initPts in scePsmfPlayerStart().
It won't be super speedy though, could more ideally do it on the calls to Update()...
This commit is contained in:
1 parent
5a04fc23a3
commit
9c0bc32f52
4 files changed
+46
-9
No files matched your search
@@ -1232,6 +1232,13 @@ int scePsmfPlayerStart(u32 psmfPlayer, u32 psmfPlayerData, int initPts)
|
||||
psmfplayer->status = PSMF_PLAYER_STATUS_PLAYING;
|
||||
|
||||
psmfplayer->mediaengine->openContext();
|
||||
// TODO: It would be better to spread this out into the Update() calls.
|
||||
while (!psmfplayer->mediaengine->seekTo(initPts, videoPixelMode)) {
|
||||
_PsmfPlayerFillRingbuffer(psmfplayer);
|
||||
if (psmfplayer->mediaengine->IsVideoEnd()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1555,7 +1562,7 @@ u32 scePsmfPlayerGetCurrentAudioStream(u32 psmfPlayer, u32 audioCodecAddr, u32 a
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(ME, "scePsmfPlayerGetCurrentAudioStream(%08x, %08x, %08x): invalid psmf player", psmfPlayer, audioCodecAddr, audioStreamNumAddr);
|
||||
return ERROR_PSMF_NOT_FOUND;
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
}
|
||||
if (psmfplayer->status == PSMF_PLAYER_STATUS_INIT) {
|
||||
ERROR_LOG(ME, "scePsmfPlayerGetCurrentVideoStream(%08x): psmf not yet set", psmfPlayer);
|
||||
|
||||
+33
-7
@@ -359,6 +359,28 @@ int MediaEngine::addStreamData(u8* buffer, int addSize) {
|
||||
return size;
|
||||
}
|
||||
|
||||
bool MediaEngine::seekTo(s64 timestamp, int videoPixelMode) {
|
||||
if (timestamp <= 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Just doing it the not so great way to be sure audio is in sync.
|
||||
int timeout = 1000;
|
||||
while (getVideoTimeStamp() < timestamp - 3003) {
|
||||
if (getAudioTimeStamp() < getVideoTimeStamp()) {
|
||||
getNextAudioFrame(NULL, NULL, NULL);
|
||||
}
|
||||
if (!stepVideo(videoPixelMode)) {
|
||||
return false;
|
||||
}
|
||||
if (--timeout <= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MediaEngine::setVideoStream(int streamNum, bool force) {
|
||||
if (m_videoStream == streamNum && !force) {
|
||||
// Yay, nothing to do.
|
||||
@@ -733,6 +755,16 @@ int MediaEngine::getAudioRemainSize() {
|
||||
return m_demux->getRemainSize();
|
||||
}
|
||||
|
||||
int MediaEngine::getNextAudioFrame(u8 **buf, int *headerCode1, int *headerCode2) {
|
||||
// When getting a frame, increment pts
|
||||
m_audiopts += 4180;
|
||||
|
||||
// Demux now (rather than on add data) so that we select the right stream.
|
||||
m_demux->demux(m_audioStream);
|
||||
|
||||
return m_demux->getNextAudioFrame(buf, headerCode1, headerCode2);
|
||||
}
|
||||
|
||||
int MediaEngine::getAudioSamples(u32 bufferPtr) {
|
||||
if (!Memory::IsValidAddress(bufferPtr)) {
|
||||
ERROR_LOG_REPORT(ME, "Ignoring bad audio decode address %08x during video playback", bufferPtr);
|
||||
@@ -743,15 +775,9 @@ int MediaEngine::getAudioSamples(u32 bufferPtr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// When getting a frame, increment pts
|
||||
m_audiopts += 4180;
|
||||
|
||||
// Demux now (rather than on add data) so that we select the right stream.
|
||||
m_demux->demux(m_audioStream);
|
||||
|
||||
u8 *audioFrame = 0;
|
||||
int headerCode1, headerCode2;
|
||||
int frameSize = m_demux->getNextAudioFrame(&audioFrame, &headerCode1, &headerCode2);
|
||||
int frameSize = getNextAudioFrame(&audioFrame, &headerCode1, &headerCode2);
|
||||
if (frameSize == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ public:
|
||||
|
||||
// Returns number of packets actually added. I guess the buffer might be full.
|
||||
int addStreamData(u8* buffer, int addSize);
|
||||
bool seekTo(s64 timestamp, int videoPixelMode);
|
||||
|
||||
bool setVideoStream(int streamNum, bool force = false);
|
||||
// TODO: Return false if the stream doesn't exist.
|
||||
@@ -93,6 +94,7 @@ public:
|
||||
|
||||
private:
|
||||
void updateSwsFormat(int videoPixelMode);
|
||||
int getNextAudioFrame(u8 **buf, int *headerCode1, int *headerCode2);
|
||||
|
||||
public: // TODO: Very little of this below should be public.
|
||||
|
||||
|
||||
@@ -248,7 +248,9 @@ int MpegDemux::getNextAudioFrame(u8 **buf, int *headerCode1, int *headerCode2)
|
||||
audioPos = gotsize;
|
||||
}
|
||||
m_audioStream.pop_front(0, audioPos);
|
||||
*buf = m_audioFrame + 8;
|
||||
if (buf) {
|
||||
*buf = m_audioFrame + 8;
|
||||
}
|
||||
return frameSize - 8;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user