c# - naudio waveProvider.AddSamples causing a crash -
private unsafe static void audiostreamcallback(intptr buff, int32 size) { byte[] samples = new byte[size]; marshal.copy(buff, samples, 0, size); waveprovider.addsamples(samples, 0, size); bytes_played += size; }
in above code, buff
returned native dll written in c
. logging, have printed number of bytes added sample. based on log, getting below mentioned error after playing 2.4 mb samples.
unhandled exception: system.invalidoperationexception: buffer full @ naudio.wave.bufferedwaveprovider.addsamples(byte[] buffer, int32 offset, int32 count)
do need free buffer or make sure flush old entries before adding new samples? looked @ source code, didn't find related buffer size. missing thing.
thanks help.
bufferedwaveprovider
backed fixed size circular buffer. once full throws exception (newer versions of naudio allow configure whether exception thrown or whether audio silently discarded). latest code allows set bufferduration
before first call addsamples
increase buffer size default of 5 seconds worth of audio.
Comments
Post a Comment