コード例 #1
0
ファイル: MediaEngine.cpp プロジェクト: BBCbbb/ppsspp
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() - 4180 * 2) {
			getNextAudioFrame(NULL, NULL, NULL);
		}
		if (!stepVideo(videoPixelMode, true)) {
			return false;
		}
		if (--timeout <= 0) {
			return true;
		}
	}

	while (getAudioTimeStamp() < getVideoTimeStamp() - 4180 * 2) {
		if (getNextAudioFrame(NULL, NULL, NULL) == 0) {
			return false;
		}
		if (--timeout <= 0) {
			return true;
		}
	}

	return true;
}
コード例 #2
0
ファイル: MediaEngine.cpp プロジェクト: Alceris/ppsspp
int MediaEngine::getAudioSamples(u32 bufferPtr) {
	if (!Memory::IsValidAddress(bufferPtr)) {
		ERROR_LOG_REPORT(ME, "Ignoring bad audio decode address %08x during video playback", bufferPtr);
	}

	u8 *buffer = Memory::GetPointer(bufferPtr);
	if (!m_demux) {
		return 0;
	}

	u8 *audioFrame = 0;
	int headerCode1, headerCode2;
	int frameSize = getNextAudioFrame(&audioFrame, &headerCode1, &headerCode2);
	if (frameSize == 0) {
		return 0;
	}
	int outbytes = 0;

	if (m_audioContext != nullptr) {
		if (headerCode1 == 0x24) {
			// This means mono audio - tell the decoder to expect it before the first frame.
			// Note that it will always send us back stereo audio.
			m_audioContext->SetChannels(1);
		}

		if (!m_audioContext->Decode(audioFrame, frameSize, buffer, &outbytes)) {
			ERROR_LOG(ME, "Audio (%s) decode failed during video playback", GetCodecName(m_audioType));
		}
#ifndef MOBILE_DEVICE
		CBreakPoints::ExecMemCheck(bufferPtr, true, outbytes, currentMIPS->pc);
#endif
	}

	return 0x2000;
}
コード例 #3
0
bool Composer::renderAudioFrame( Frame *dst, int nSamples )
{
	int i = 0;
	Frame *f;
	FrameSample *sample;
	
	Profile profile = sampler->getProfile();
	int bps = profile.getAudioChannels() * profile.bytesPerChannel( &profile );

	sampler->getAudioTracks( dst, nSamples );
	if ( !getNextAudioFrame( dst, i ) ) {
		// make silence
		dst->setAudioFrame( profile.getAudioChannels(), profile.getAudioSampleRate(), profile.bytesPerChannel( &profile ), nSamples, sampler->currentPTSAudio() );
		memset( dst->data(), 0, nSamples * bps );
		return true;
	}
	
	// process first frame
	sample = dst->sample->frames[i - 1];
	// copy in dst
	AudioCopy ac;
	f = sample->frame;
	if ( !f )
		f = sample->transitionFrame.frame;
	nSamples = f->audioSamples();
	Buffer *buf = processAudioFrame( sample, nSamples, bps, &profile );
	dst->setAudioFrame( f->profile.getAudioChannels(), f->profile.getAudioSampleRate(), f->profile.bytesPerChannel( &f->profile ), nSamples, f->pts() );
	ac.process( f, buf, dst->getBuffer(), &profile );
	BufferPool::globalInstance()->releaseBuffer( buf );

	// process remaining frames
	AudioMix am;
	while ( getNextAudioFrame( dst, i ) ) {
		sample = dst->sample->frames[i - 1];
		buf = processAudioFrame( sample, nSamples, bps, &profile );
		// mix
		f = sample->frame;
		if ( !f )
			f = sample->transitionFrame.frame;
		am.process( f, buf, dst, dst->getBuffer(), dst->getBuffer(), &profile );
		BufferPool::globalInstance()->releaseBuffer( buf );
	}

	return true;
}
コード例 #4
0
ファイル: madaudiofile.C プロジェクト: aalto-cbir/PicSOM
  audiodata madaudiofile::getNextAudioSlice(int duration, bool enablefft) {
    if (outputLength==0)
      getNextAudioFrame();

    audiodata aud((double)duration, samplerate, getNChannels(), 16, enablefft);
    int currentDuration = 0;

    /*      while(currentDuration < duration && outputLength != 0) {
    // Adds data until end_pos or until end of the frame has been reached.
    // Returns the last added pos+1*/
    currentDuration = aud.pushData(OutputBuffer, &outputPosition, 
				   outputLength, duration); 

    if (currentDuration < duration && outputPosition >= outputLength)
      getNextAudioFrame();

    //}
    current_pos += currentDuration;

    return aud;
  }
コード例 #5
0
ファイル: MediaEngine.cpp プロジェクト: BBCbbb/ppsspp
int MediaEngine::getAudioSamples(u32 bufferPtr) {
	if (!Memory::IsValidAddress(bufferPtr)) {
		ERROR_LOG_REPORT(ME, "Ignoring bad audio decode address %08x during video playback", bufferPtr);
	}

	u8 *buffer = Memory::GetPointer(bufferPtr);
	if (!m_demux) {
		return 0;
	}

	u8 *audioFrame = 0;
	int headerCode1, headerCode2;
	int frameSize = getNextAudioFrame(&audioFrame, &headerCode1, &headerCode2);
	if (frameSize == 0) {
		return 0;
	}
	int outbytes = 0;

	if (m_audioContext != NULL) {
		if (!m_audioContext->Decode(audioFrame, frameSize, buffer, &outbytes)) {
			ERROR_LOG(ME, "Audio (%s) decode failed during video playback", GetCodecName(m_audioType));
		}
#ifndef MOBILE_DEVICE
		CBreakPoints::ExecMemCheck(bufferPtr, true, outbytes, currentMIPS->pc);
#endif
	}

	if (headerCode1 == 0x24) {
		// it a mono atrac3plus, convert it to stereo
		s16 *outbuf = (s16*)buffer;
		s16 *inbuf = (s16*)buffer;
		for (int i = 0x800 - 1; i >= 0; i--) {
			s16 sample = inbuf[i];
			outbuf[i * 2] = sample;
			outbuf[i * 2 + 1] = sample;
		}
	}

	return 0x2000;
}