Added ClearAll() for voice
This commit is contained in:
parent
6bb7d5d0fd
commit
2ef0060037
@ -91,10 +91,6 @@ namespace RageCoop.Client
|
||||
#if !NON_INTERACTIVE
|
||||
#endif
|
||||
MainChat = new Chat();
|
||||
if (Settings.Voice && !Sync.Voice.WasInitialized())
|
||||
{
|
||||
Sync.Voice.InitRecording();
|
||||
}
|
||||
Tick += OnTick;
|
||||
Tick += (s, e) => { Scripting.API.Events.InvokeTick(); };
|
||||
KeyDown += OnKeyDown;
|
||||
@ -309,7 +305,7 @@ namespace RageCoop.Client
|
||||
public static void CleanUp()
|
||||
{
|
||||
MainChat.Clear();
|
||||
Sync.Voice.ClearBuffer();
|
||||
Sync.Voice.ClearAll();
|
||||
EntityPool.Cleanup();
|
||||
PlayerList.Cleanup();
|
||||
Main.LocalPlayerID=default;
|
||||
|
@ -50,6 +50,8 @@ namespace RageCoop.Client.Menus
|
||||
if (_disableVoice.Checked && !Sync.Voice.WasInitialized())
|
||||
{
|
||||
Sync.Voice.InitRecording();
|
||||
} else {
|
||||
Sync.Voice.ClearAll();
|
||||
}
|
||||
|
||||
Main.Settings.Voice = _disableVoice.Checked;
|
||||
|
@ -64,6 +64,10 @@ namespace RageCoop.Client
|
||||
{
|
||||
CoopMenu.ConnectedMenuSetting();
|
||||
Main.MainChat.Init();
|
||||
if (Main.Settings.Voice && !Sync.Voice.WasInitialized())
|
||||
{
|
||||
Sync.Voice.InitRecording();
|
||||
}
|
||||
GTA.UI.Notification.Show("~g~Connected!");
|
||||
});
|
||||
|
||||
|
@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading;
|
||||
|
||||
using NAudio.Wave;
|
||||
|
||||
@ -18,19 +15,31 @@ namespace RageCoop.Client.Sync
|
||||
private static Thread _thread;
|
||||
|
||||
public static bool WasInitialized() => _initialized;
|
||||
public static void ClearBuffer() => _waveProvider.ClearBuffer();
|
||||
public static void ClearAll()
|
||||
{
|
||||
_waveProvider.ClearBuffer();
|
||||
|
||||
StopRecording();
|
||||
|
||||
if (_thread != null && _thread.IsAlive)
|
||||
{
|
||||
_thread.Abort();
|
||||
_thread = null;
|
||||
}
|
||||
|
||||
_initialized = false;
|
||||
}
|
||||
|
||||
public static void StopRecording()
|
||||
{
|
||||
if (!IsRecording || _waveIn == null)
|
||||
return;
|
||||
|
||||
_waveIn.StopRecording();
|
||||
_waveIn.Dispose();
|
||||
_waveIn = null;
|
||||
if (_waveIn != null)
|
||||
{
|
||||
_waveIn.StopRecording();
|
||||
_waveIn.Dispose();
|
||||
_waveIn = null;
|
||||
}
|
||||
|
||||
IsRecording = false;
|
||||
GTA.UI.Notification.Show("STOPPED");
|
||||
}
|
||||
|
||||
public static void InitRecording()
|
||||
@ -77,7 +86,6 @@ namespace RageCoop.Client.Sync
|
||||
_waveIn.DataAvailable += WaveInDataAvailable;
|
||||
|
||||
_waveIn.StartRecording();
|
||||
GTA.UI.Notification.Show("STARTED");
|
||||
}
|
||||
|
||||
public static void AddVoiceData(byte[] buffer, int recorded)
|
||||
|
Loading…
x
Reference in New Issue
Block a user