| 96 | //----------------------------------------------------------------------------- |
| 97 | |
| 98 | bool SFXBuffer::update() |
| 99 | { |
| 100 | using namespace SFXInternal; |
| 101 | |
| 102 | if( isDead() ) |
| 103 | { |
| 104 | // Buffer requested to finish its async operations. |
| 105 | // Kill our async state and put us on the dead buffer list. |
| 106 | |
| 107 | mAsyncState->mStream->stop(); |
| 108 | mAsyncState = NULL; |
| 109 | gDeadBufferList.pushFront( this ); |
| 110 | return false; |
| 111 | } |
| 112 | else if( isAtEnd() && isStreaming() ) |
| 113 | { |
| 114 | // Streaming buffers remain in the update loop even if they |
| 115 | // have played in full to allow for stream seeks. |
| 116 | return true; |
| 117 | } |
| 118 | |
| 119 | AssertFatal( mAsyncState != NULL, "SFXBuffer::update() - async state has already been released" ); |
| 120 | |
| 121 | bool needFurtherUpdates = true; |
| 122 | if( !isStreaming() ) |
| 123 | { |
| 124 | // Not a streaming buffer. If the async stream has its data |
| 125 | // ready, we load it and finish up on our async work. |
| 126 | |
| 127 | SFXStreamPacket* packet; |
| 128 | while( mAsyncState->mStream->read( &packet, 1 ) ) |
| 129 | { |
| 130 | bool isLast = packet->mIsLast; |
| 131 | |
| 132 | // Write packet data into buffer. |
| 133 | write( &packet, 1 ); |
| 134 | packet = NULL; |
| 135 | |
| 136 | if( isLast ) |
| 137 | { |
| 138 | // Release async state. |
| 139 | mAsyncState = NULL; |
| 140 | |
| 141 | // Once loaded, non-streaming buffers disappear from the SFX |
| 142 | // update thread. |
| 143 | needFurtherUpdates = false; |
| 144 | |
| 145 | // Signal that we are ready. |
| 146 | _setStatus( STATUS_Ready ); |
| 147 | |
| 148 | #ifdef DEBUG_SPEW |
| 149 | Platform::outputDebugString( "[SFXBuffer] Buffer ready" ); |
| 150 | #endif |
| 151 | |
| 152 | break; |
| 153 | } |
| 154 | } |
| 155 | } |
nothing calls this directly
no test coverage detected