Hi,
So i've been having a problem using BASS for android in conjunction with BASS.net and Unity3D. We are using BASS for audio recording and playback however the recording component seems to cause a crash every time the recording is stopped. The same code works fine on Windows without an issue, we have a temporary work around in place however it's not good for the memory.
public override bool Initialise() {
if (!init) {
DebugTools.Log("\n" + BassNet.InternalName, true, false);
DebugTools.Log("Bass.NET registered", true);
_myRecProc = new RECORDPROC(MyRecording);
Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, 2);
Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 10);
Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_BUFFER, 5000);
Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_SRC, 0);
Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_REC_BUFFER, 2000);
bool bassInit = Bass.BASS_RecordInit(-1);
if (handle == 0) handle = Bass.BASS_RecordStart(recordFrequency, 1, BASSFlag.BASS_RECORD_PAUSE | BASSFlag.BASS_SAMPLE_MONO | BASSFlag.BASS_STREAM_AUTOFREE, 10, _myRecProc, IntPtr.Zero);
startedInput = false;
if (handle != 0 && bassInit && _myRecProc != null) {
init = true;
return true;
}
}
return false;
}
public override bool StartInput() {
if (handle == 0) {
DebugTools.Log(Bass.BASS_ErrorGetCode(), true, true);
return false;
} else {
_recbuffer = null;
continueRecording = true;
DebugTools.Log(handle + " : Recording", true);
bool start = Bass.BASS_ChannelPlay(handle, true);
DebugTools.Log("Start Recording: " + start, true);
return start;
}
}
public override bool StopInput() {
if (handle != 0) {
continueRecording = false; // **** <-------------------- Crash Happens Here!!!!!!!!!!!!!!!!!!!!!!!
DebugTools.Log("Record Continue: " + continueRecording, true, true);
handle = 0;
Bass.BASS_RecordFree();
startedInput = false;
}
return true;
}
private bool MyRecording(int handle, IntPtr buffer, int length, IntPtr user) {
DebugTools.Track("Rec Time", (Bass.BASS_ChannelGetPosition(handle) / 100000f).ToString("#.##"));
if (length > 0 && continueRecording) {
_recbuffer = new byte[length];
if (!muted) Marshal.Copy(buffer, _recbuffer, 0, length);
if (LevelManager.instance != null)
LevelManager.instance.localAvatar.mainLoopCallback(_recbuffer);
}
return continueRecording;
}
Any help as to why the application is crashing everytime the continueRecording is set to false would be much appreciated.
-AW