Hi all, 1st, sorry ab. my english, hehe, not too much english on school.
I'm actually trying to make a pro cd like seek, the thing is.. you press the seek (fwd|bwd) button and the stream start a loop playing on that pos until you stop the seek by play/cue.
You also can change the pos by 0.01 seconds units by pressing seek (fwd|bwd).
I hope i'm explaining well.
Well, that's not working, and when i exit the seek loop sometimes the stream is corrupted.. like (ghsasj ajhsg AJS....)
The code i use it something like:
UINT ChannelSeekThreadProc(LPVOID n)
{
return ((CMyMixerChannel*)n)->SeekThreadProc();
}
class CMyMixerChannel
{
m_Stream; //The stream
m_CuePos; //Curr cue pos (only one, not interested in multiple cue positions)
m_Length; //Length in bytes.
CWinThread* m_SeekThread //thread to do the seek loop.
CMyMixerChannel(const int nChannelIndex)
{
// Each channel can have a diferent device, so:
// Copy bass.dll and bass_fx.dll to a temp destination
// loads libraries into there hinstances
// loads functions by there procaddress of there instances
// In other words, same as multi c++ sample.
// InitBass..
}
public void SeekFwd() { Seek(1); }
public void SeekBwd() { Seek(-1); }
private void Seek(const int nSeekDirection)
{
if (!m_bImSeeking)
{
m_CuePos = BASS_ChannelGetPosition[nChannelIndex]( m_Stream );
m_bImSeeking = true;
BASS_ChannelPause[nChannelIndex]( m_Stream );
m_SeekThread = AfxBeginThread(ChannelSeekThreadProc,this);
}
else
{
float ActualPosTempo, NewPosTempo;
QWORD NewPos;
ActualPosTempo = BASS_StreamBy2Sec..[nChannelIndex]( m_Stream , m_CuePos );
NewPosTempo = ActualPosTempo + nSeekDirection*((float)0.01); //increase or decrease by 0.01 sec based on direction.
NewPos = BASS_StreamSec2Bytes[nChannelIndex]( m_Stream , NewPosTempo );
if ((NewPos > 0) && (NewPos < m_Length))
m_CuePos = NewPos;
}
}
public UINT SeekThreadProc()
{
while(m_bImSeeking)
{
BASS_ChanResume[nChannelIndex]( m_Stream );
Sleep(250); // ~ 4 loops x seg.
BASS_ChanPause[nChannelIndex]( m_Stream );
BASS_ChanSetPos[nChannelIndex]( m_Stream , m_CuePos);
}
return 0;
}
}
Ah.. it also doesnt change the seek pos each time i call seek(1|-1). say, the loop is allways in the same position.
Txs, Martín.