rem: if (sample->decoder->error == SOUNDDECODER_EOF && sample->read_chain_ptr->next)
add: if (sample->decoder->error == SOUNDDECODER_EOF && sample->read_chain_ptr && sample->read_chain_ptr->next)
context: PlayStream (TFB_SoundSample *sample, uint32 source, bool looping, bool scope, bool rewind){		uint32 i, pos = 0;	sint32 offset = 0;	if (!sample || (!sample->read_chain_ptr && !sample->decoder))		return;	StopStream (source);	if (sample->read_chain_ptr)	{		sample->decoder = sample->read_chain_ptr->decoder;		offset = (sint32) (sample->read_chain_ptr->start_time * (float)ONE_SECOND);	}	else		offset= 0;	if (rewind)		SoundDecoder_Rewind (sample->decoder);	else		offset += (sint32)(SoundDecoder_GetTime (sample->decoder) * (float)ONE_SECOND);	soundSource[source].sample = sample;	soundSource[source].sample->play_chain_ptr = sample->read_chain_ptr;	soundSource[source].sample->decoder->looping = looping;	TFBSound_Sourcei (soundSource[source].handle, TFBSOUND_LOOPING, false);	if (scope)	{		soundSource[source].sbuffer = HMalloc (PAD_SCOPE_BYTES);	}	if (sample->read_chain_ptr && sample->read_chain_ptr->tag.type)	{		DoTrackTag(&sample->read_chain_ptr->tag);	}	for (i = 0; i < sample->num_buffers; ++i)	{		uint32 decoded_bytes;		if (sample->buffer_tag)			sample->buffer_tag[i] = 0;		decoded_bytes = SoundDecoder_Decode (sample->decoder);		//fprintf (stderr, "PlayStream(): source %d filename:%s start: %d position:%d bytes %d\n", source, 		//		sample->decoder->filename, sample->decoder->start_sample, 		//		sample->decoder->pos, decoded_bytes);		if (decoded_bytes == 0)			break;		TFBSound_BufferData (sample->buffer[i], sample->decoder->format, sample->decoder->buffer, 			decoded_bytes, sample->decoder->frequency);		TFBSound_SourceQueueBuffers (soundSource[source].handle, 1, &sample->buffer[i]);		if (scope)		{			UBYTE *p;			soundSource[source].sbuffer = HRealloc (soundSource[source].sbuffer, 					pos + decoded_bytes + PAD_SCOPE_BYTES);			p = (UBYTE *)soundSource[source].sbuffer;			memcpy (&p[pos], sample->decoder->buffer, decoded_bytes);			pos += decoded_bytes;		}		if (sample->decoder->error)		{			if (sample->decoder->error == SOUNDDECODER_EOF && sample->read_chain_ptr->next)			{				sample->read_chain_ptr = sample->read_chain_ptr->next;				sample->decoder = sample->read_chain_ptr->decoder;				SoundDecoder_Rewind (sample->decoder);				fprintf (stderr, "Switching to stream %s at pos %d\n",						sample->decoder->filename, sample->decoder->start_sample);				if (sample->buffer_tag && sample->read_chain_ptr->tag.type)				{					sample->buffer_tag[i] = &sample->read_chain_ptr->tag;					sample->read_chain_ptr->tag.buf_name = sample->buffer[i];				}			}			else				break;		}	}	if (sample->buffer_tag)		for ( ; i <sample->num_buffers; ++i)			sample->buffer_tag[i] = 0;	soundSource[source].sbuf_size = pos + PAD_SCOPE_BYTES;	soundSource[source].sbuf_start = pos;	soundSource[source].sbuf_lasttime = GetTimeCounter ();	soundSource[source].start_time = (sint32)GetTimeCounter () - offset;	soundSource[source].stream_should_be_playing = TRUE;	TFBSound_SourcePlay (soundSource[source].handle);}