MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / Frame

Method Frame

stream_audio/streamaudio.cpp:230–279  ·  view source on GitHub ↗

called by application to allow stream playback

Source from the content-addressed store, hash-verified

228}
229// called by application to allow stream playback
230void AudioStream::Frame() {
231 int t;
232 float time = timer_GetTime();
233 if (!m_ll_sndsys)
234 return;
235 for (t = 0; t < STRM_LIMIT; t++) {
236 if (AudioStream::m_streams[t]) {
237 AudioStream *strm = AudioStream::m_streams[t];
238 if (strm->m_laststate != strm->m_state) {
239 LOGFILE((_logfp, "STRM[%d]:frame_state=%d\n", strm->m_curid, strm->m_state));
240 }
241 if (strm->m_state == STRM_PLAYING) {
242 // see if the sound is still playing if it isn't then kill it (also if no more loops)
243 strm->m_measure_timer += (time - strm->m_last_frametime);
244 if (strm->m_measure_timer >= strm->m_measure_time) {
245 strm->m_curmeasure++;
246 }
247 strm->m_last_frametime = time;
248 if (strm->m_state == STRM_PLAYING)
249 strm->UpdateData();
250 } else if (strm->m_state == STRM_STOPPING) {
251 if (!AudioStream::m_ll_sndsys->IsSoundInstancePlaying(strm->m_llshandle)) {
252 strm->Stop();
253 // mprintf(0, "STRM[%d]: Stopped!\n", strm->m_curid);
254 LOGFILE((_logfp, "STRM[%d]: Stopped!\n", strm->m_curid));
255 if (CHECK_FLAG(strm->m_flags, STRM_OPNF_ONETIME)) {
256 strm->Close();
257 }
258 strm->m_readahead = false;
259 }
260 } else if (strm->m_state == STRM_INVALID) {
261 strm->DeactivateStream(strm);
262 } else if (strm->m_start_on_frame) {
263 strm->m_llshandle = m_ll_sndsys->PlayStream(&strm->m_playinfo);
264 if (strm->m_llshandle > -1) {
265 // for one buffer samples, prepare to stop now so that the one and only one buffer gets called.
266 // looped one buffer samples dont do this though...
267 if (strm->m_nbufs == 1 && !strm->m_start_on_frame_looped) {
268 strm->m_state = STRM_STOPPING;
269 } else {
270 strm->m_state = STRM_PLAYING;
271 }
272 }
273 strm->m_start_on_frame = false;
274 strm->m_start_on_frame_looped = false;
275 }
276 strm->m_laststate = strm->m_state;
277 }
278 }
279}
280// called to pause all streams.
281void AudioStream::PauseAll() {
282 int t;

Callers

nothing calls this directly

Calls 6

UpdateDataMethod · 0.80
DeactivateStreamMethod · 0.80
StopMethod · 0.45
CloseMethod · 0.45
PlayStreamMethod · 0.45

Tested by

no test coverage detected