processes current command on stream, return false to end processing.
| 169 | |
| 170 | // processes current command on stream, return false to end processing. |
| 171 | bool oms_stream::processCommand() { |
| 172 | switch (m_status.cmd) { |
| 173 | case OMS_STRM_FADEIN: |
| 174 | // timed fadein to dest volume |
| 175 | if (m_timer <= 0.0f) { |
| 176 | m_stream.SetVolume(m_maxvol); |
| 177 | STREAM_COMMANDI(OMS_STRM_PLAY); |
| 178 | } else { |
| 179 | m_stream.SetVolume(m_maxvol * (m_timer_init - m_timer) / m_timer_init); |
| 180 | } |
| 181 | return false; |
| 182 | |
| 183 | case OMS_STRM_FADEOUT: |
| 184 | // timed fadeout to dest volume |
| 185 | if (m_timer <= 0.0f) { |
| 186 | m_stream.SetVolume(0.0f); |
| 187 | STREAM_COMMANDI(OMS_STRM_PLAY); |
| 188 | } else { |
| 189 | m_stream.SetVolume(m_maxvol * m_timer / m_timer_init); |
| 190 | } |
| 191 | return false; |
| 192 | |
| 193 | case OMS_STRM_SWITCH: |
| 194 | // if current measure is greater than initial measure at switch, then we will stop |
| 195 | // this stream and send a play command to the current dominant stream. |
| 196 | // mprintf(0, "%d-%d ",m_data.i, m_stream.State()); |
| 197 | if (m_data.i || m_stream.State() == STRM_STOPPED || m_stream.State() == STRM_INVALID) { |
| 198 | bool *still_playing = (bool *)m_status.parm.p; |
| 199 | *still_playing = false; |
| 200 | if (m_status.cmd != OMS_STRM_STOP) { |
| 201 | STREAM_COMMANDI(OMS_STRM_STOP); |
| 202 | m_valid_result = true; |
| 203 | m_result.cmd = OMS_STRM_STOP; |
| 204 | } |
| 205 | } |
| 206 | return false; |
| 207 | |
| 208 | case OMS_STRM_PLAY: |
| 209 | // check if stream is still playing. if not, then set current stream status and signal |
| 210 | // a normal song end. |
| 211 | if (m_stream.State() == STRM_STOPPED) { |
| 212 | if (m_status.cmd != OMS_STRM_STOP) { |
| 213 | STREAM_COMMANDI(OMS_STRM_STOP); |
| 214 | m_valid_result = true; |
| 215 | m_result.cmd = OMS_STRM_STOP; |
| 216 | return false; |
| 217 | } |
| 218 | } |
| 219 | break; |
| 220 | |
| 221 | case OMS_STRM_NEXT: |
| 222 | // if (m_stream.HasNextStarted()) { |
| 223 | // *(bool *)(m_status.parm.p) = false; |
| 224 | // m_stream.SetLoopCount(m_data2.i); |
| 225 | // m_stream.SetVolume(m_data.f); |
| 226 | // STREAM_COMMANDI(OMS_STRM_PLAY, m_data2.i); |
| 227 | // return false; |
| 228 | // } |