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