This project has moved and is read-only. For the latest updates, please go here.

BufferedWaveProvider Buffer Full

Oct 14, 2015 at 6:49 AM
Edited Oct 14, 2015 at 8:46 AM
Hi all,

I am receiving some audio data via http and now want to play the data received. But I am always getting an exception which says that the buffer is full. I know that the problem is normally caused by not playing the buffer, but I am playing it...
And with the data receiving everything should be correct (I checked that several times), so the problem has to be somewhere in the part that cares about playing.

This is my code:
class Program
    static BufferedWaveProvider bufferedWaveProvider;
    static WaveOut player;
    static WebClient client = new WebClient();

    static void Main(string[] args)
        bufferedWaveProvider = new BufferedWaveProvider(new WaveFormat(48000, 2) { });
        player = new WaveOut();

             using (client)
                 byte[] response = 
                 client.UploadValues("http://localhost:8080/test", new NameValueCollection());

                 bufferedWaveProvider.AddSamples(response, 0, response.GetLength(0));

Due to make it better for reading, I left out some code that is responsible for checking whether the received data is already stored in the WaveProvider. Only when something new is coming, it is written to the Wave Provider. That means the exception is not caused by the endless-loop running too fast for the playback.

Anyone knows what is going wrong?
Oct 15, 2015 at 9:42 AM
I have found the problem now.

The problem was the WaveFormat used to create the bufferd wave provider. I only checkd that sample rate and channels are the same because I did not know that there is a difference between PCM and Ieee. So I changed that and everything is fine :)
Oct 15, 2015 at 9:46 AM
great, glad you found the problem