MCPcopy Create free account
hub / github.com/Warzone2100/warzone2100 / seq_Update

Function seq_Update

lib/sequence/sequence.cpp:854–1027  ·  view source on GitHub ↗

* Display the next frame and play the sound. * \return false if the end of the video is reached. */

Source from the content-addressed store, hash-verified

852 * \return false if the end of the video is reached.
853 */
854bool seq_Update()
855{
856 ogg_packet op;
857 int ret;
858 int i, j;
859 float **pcm;
860 int count, maxsamples;
861
862 /* we want a video and audio frame ready to go at all times. If
863 we have to buffer incoming, buffer the compressed data (ie, let
864 ogg do the buffering) */
865 if (!videoplaying)
866 {
867 debug(LOG_VIDEO, "no movie playing");
868 return false;
869 }
870
871 while (vorbis_p && !audiobuf_ready)
872 {
873 /* if there's pending, decoded audio, grab it */
874 if ((ret = vorbis_synthesis_pcmout(&videodata.vd, &pcm)) > 0)
875 {
876 // we now have float pcm data in pcm
877 // going to convert that to int pcm in audiobuf
878 count = audiodata.audiobuf_fill / 2;
879 maxsamples = (audiodata.audiofd_fragsize - audiodata.audiobuf_fill) / 2 / videodata.vi.channels;
880
881 for (i = 0; i < ret && i < maxsamples; i++)
882 {
883 for (j = 0; j < videodata.vi.channels; j++)
884 {
885 int val = static_cast<int>(nearbyint(pcm[j][i] * 32767.f));
886
887 if (val > 32767)
888 {
889 val = 32767;
890 }
891 else if (val < -32768)
892 {
893 val = -32768;
894 }
895 audiobuf[count++] = val;
896 }
897 }
898
899 vorbis_synthesis_read(&videodata.vd, i);
900 audiodata.audiobuf_fill += i * videodata.vi.channels * 2;
901
902 if (audiodata.audiobuf_fill == audiodata.audiofd_fragsize)
903 {
904 audiobuf_ready = true;
905 }
906
907 if (videodata.vd.granulepos >= 0)
908 {
909 audiobuf_granulepos = videodata.vd.granulepos - ret + i;
910 }
911 else

Callers 2

seq_RenderVideoToBufferFunction · 0.85

Calls 11

nearbyintFunction · 0.85
getRelativeTimeFunction · 0.85
seq_SetFrameNumberFunction · 0.85
seq_GetFrameNumberFunction · 0.85
audio_DisabledFunction · 0.85
video_writeFunction · 0.85
seq_ShutdownFunction · 0.85
queue_pageFunction · 0.85
audio_writeFunction · 0.85
end_of_dataMethod · 0.80
buffer_dataMethod · 0.80

Tested by

no test coverage detected