Author Topic: Remove the buffered data?  (Read 385 times)

doka

  • Posts: 7
Remove the buffered data?
« on: 19 Jul '22 - 10:19 »
I am playing OPUS data via websocket with BASS_StreamCreateFileUser.
When I stop playback and resume playback again, BASS plays the buffered data (about 3 seconds) and then plays the new data.
How can I remove the buffered data?
Code: [Select]
void Init_BASS()
{
Bass.BASS_Init(-1, 48000, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero)
int stream = Bass.BASS_StreamCreateFileUser(BASSStreamSystem.STREAMFILE_BUFFERPUSH, BASSFlag.BASS_DEFAULT, _myStreamCreateUser, IntPtr.Zero);
}

void OnRecieveSocket()
{
websocket.DataReceived += (s, e) =>
{
Bass.BASS_StreamPutFileData(stream, e.Data, e.Data.Length);
}
websocket.Open();
}

void ButtonClick(object sender, EventArgs e)
{
if (flag)
Bass.BASS_ChannelStop(stream);
else
Bass.BASS_ChannelPlay(stream, false);
}

Ian @ un4seen

  • Administrator
  • Posts: 24589
Re: Remove the buffered data?
« Reply #1 on: 19 Jul '22 - 16:34 »
That should be possible by calling BASS_ChannelSetPosition with mode=BASS_POS_RESET, so long as you set the BASS_STREAM_BLOCK flag on the stream or return 0 in your FILELENPROC callback, and you're using the latest BASSOPUS version (2.4.2.1).

doka

  • Posts: 7
Re: Remove the buffered data?
« Reply #2 on: 20 Jul '22 - 14:24 »
I had already returned 0 with 'FILELENPROC', so only setting 'BASS_ChannelSetPosition(mode=BASS_POS_RESET)' solved the problem.
Thanks for the great Library!

Code: [Select]
Bass.BASS_ChannelSetPosition(stream, 0L, BASSMode.BASS_POS_RESET);

Ian @ un4seen

  • Administrator
  • Posts: 24589
Re: Remove the buffered data?
« Reply #3 on: 21 Jul '22 - 13:50 »
Good to hear that it's working well.

I notice the BASS_POS_RESET support wasn't mentioned in the BASSOPUS documentation, so a mention of that has now been added.