Author Topic: attempt at lowering lag in my bass.net project..  (Read 153 times)

gum

  • Posts: 22
Here's my situation...

Code: [Select]
public int LoopbackWasapiProc(
IntPtr buffer,
int length,
IntPtr user)
    {
        for(int x=0; x < outputs.Count(); x++)
        {
            if (outputs[x] != 0)
            {
                Bass.BASS_StreamPutData(outputs[x], buffer, length);
            }
        }
        return 1;
    }

I'd like this line

 Bass.BASS_StreamPutData(outputs
  • , buffer, length);

To be executed in sync with the rest of the outputs
  • in this loop.


I'm new to threading, but I'm sure threads are the answer.

Although, I don't know where to begin for this particular problem.

I figured in my LoopbackWasapiProc i'd just keep setting buffer and length to a global variable and then run a basic thread with outputs
  • as a paramter and just repeatedly grabbing data from the global variables and calling StreamPutData... makes a bunch of wierd static noise though =/


I tried this
Code: [Select]
   
            Parallel.ForEach(outputs, oneput =>
            {
                if(oneput > 0 )
                {
                Console.WriteLine("testt" + oneput);
                }
     

            });

with this error:
Managed Debugging Assistant 'CallbackOnCollectedDelegate' : 'A callback was made on a garbage collected delegate of type 'Bass.Net!Un4seen.BassWasapi.WASAPIPROC::Invoke'. This may cause application crashes, corruption and data loss. When passing delegates to unmanaged code, they must be kept alive by the managed application until it is guaranteed that they will never be called.'


 ** * * ** FIXED * ** * * *

« Last Edit: 26 Mar '17 - 05:46 by gum »