BananaHemic / Mumble-Unity

Performant Mumble Client For Unity3D
MIT License
79 stars 30 forks source link

ManageAudioSendBuffer.ReleasePcmArray #16

Closed virusmarathe closed 6 years ago

virusmarathe commented 6 years ago

Question about the PCMArray in ManageAudioSendBuffer. I noticed that "GetAvailablePCMArray()" gets called every frame, and basically never has available arrays because the "ReleasePCMArray()" is not called anywhere. Do you have an idea where I should be calling this, as the iteration through a list that gets longer every frame is very expensive.

BananaHemic commented 6 years ago

On my machine, the pcmarray list nevers gets bigger than 3. This is because the AudioEncodingBuffer line 73 marks the pcm array as available after it's compressed. That being said, you're right that there shouldn't be a function in the source that's never called, so I'll refractor this at some point.

Let me know if the count of the pcmarray list grows larger than 3 on your machine.

virusmarathe commented 6 years ago

Hmm interesting. Something is different for me then. I've commented out the debug log in ManageAudioSendBuffer line 64 "New buffer length is: " + _pcmArrays.Count , and it pretty much just spams new PcmArray every frame and increments the buffer length by 1. I am using the amplitude setting, not even talking through the mic, just leaving it on constantly creates them

BananaHemic commented 6 years ago

Ok, then I think the issue is with the amplitude setting. I'll post a fix later today most likely.

virusmarathe commented 6 years ago

Hmm looks like the free-ing breakpoint is getting hit when I am actually talking, but when theres no audio going through theres the problem. something in the else clause in MumbleMicrophone.cs line 118 I guess needs to free it. Oh just saw your reply, thanks!

BananaHemic commented 6 years ago

Thanks for pointing this problem out! Hopefully my last commit fixed this issue for you, but if not feel free to re-open