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

Method Play

stream_audio/streamaudio.cpp:589–685  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// plays a stream

Source from the content-addressed store, hash-verified

587///////////////////////////////////////////////////////////////////////////////
588// plays a stream
589bool AudioStream::Play(bool start_on_frame) {
590 // call low level stream manager. - samir
591 int sflag = SIF_STREAMING_16_M, i;
592 bool looped = false;
593 if (m_state == STRM_INVALID) {
594#ifdef WIN32
595 Int3();
596#endif
597 return false;
598 }
599 // play stream if there's room to.
600 if (!ActivateStream(this))
601 return false;
602 switch (m_archive.StreamFormat()) {
603 case SAF_8BIT_M:
604 sflag = SIF_STREAMING_8_M;
605 break;
606 case SAF_8BIT_S:
607 sflag = SIF_STREAMING_8_S;
608 break;
609 case SAF_16BIT_M:
610 sflag = SIF_STREAMING_16_M;
611 break;
612 case SAF_16BIT_S:
613 sflag = SIF_STREAMING_16_S;
614 break;
615 default:
616 Int3();
617 return false;
618 }
619 // reset soft stopping.
620 m_stopnextmeasure = false;
621 m_curmeasure = 0;
622 m_stopflag = NULL;
623 if (m_state != STRM_STOPPED) {
624 AudioStream::Stop();
625 }
626 if (m_playcount > 0) {
627 AudioStream::Reset();
628 }
629 m_playcount++;
630 m_measure_timer = 0.0f;
631 m_last_frametime = timer_GetTime();
632 // check for terminal and if loopcount != 0 then specify terminal as looping
633 if (m_loopcount != 0) {
634 for (i = 0; i < STRM_BUFCOUNT; i++) {
635 if (CHECK_FLAG(m_buffer[i].flags, STRM_BUFF_USED)) {
636 if (CHECK_FLAG(m_buffer[i].flags, STRM_BUFF_TERMINAL)) {
637 if (m_loopcount == -1) {
638 m_buffer[m_fbufidx].flags |= STRM_BUFF_LOOPEND;
639 looped = true;
640 AudioStream::Reset();
641 } else if (m_loopcount > 0) {
642 m_buffer[m_fbufidx].flags |= STRM_BUFF_LOOPEND;
643 looped = true;
644 AudioStream::Reset();
645 m_loopcount--;
646 }

Callers 1

StreamPlayFunction · 0.45

Calls 2

StreamFormatMethod · 0.80
PlayStreamMethod · 0.45

Tested by

no test coverage detected