Move NetworkStream and FileStream to std::unique_ptr
This commit is contained in:
parent
e7804fcef0
commit
858991b506
@ -2146,17 +2146,14 @@ NetworkStream* CreateNullNetwork();
|
||||
|
||||
void OBS::RestartNetwork()
|
||||
{
|
||||
NetworkStream *tmp;
|
||||
OSEnterMutex(App->hStartupShutdownMutex);
|
||||
|
||||
//delete the old one
|
||||
tmp = App->network;
|
||||
App->network = nullptr;
|
||||
delete tmp;
|
||||
App->network.reset();
|
||||
|
||||
//start up a new one
|
||||
App->bSentHeaders = false;
|
||||
App->network = CreateRTMPPublisher();
|
||||
App->network.reset(CreateRTMPPublisher());
|
||||
|
||||
OSLeaveMutex(App->hStartupShutdownMutex);
|
||||
}
|
||||
|
@ -629,7 +629,7 @@ class OBS
|
||||
|
||||
//---------------------------------------------------
|
||||
|
||||
NetworkStream *network;
|
||||
std::unique_ptr<NetworkStream> network;
|
||||
|
||||
//---------------------------------------------------
|
||||
// audio sources/encoder
|
||||
@ -828,7 +828,7 @@ private:
|
||||
bool bUseCFR;
|
||||
|
||||
bool bWriteToFile;
|
||||
VideoFileStream *fileStream;
|
||||
std::unique_ptr<VideoFileStream> fileStream;
|
||||
|
||||
std::unique_ptr<VideoFileStream> replayBufferStream;
|
||||
ReplayBuffer *replayBuffer;
|
||||
|
@ -265,7 +265,7 @@ bool OBS::StartRecording(bool force)
|
||||
bool success = true;
|
||||
if(!bTestStream && bWriteToFile && strOutputFile.IsValid())
|
||||
{
|
||||
fileStream = CreateFileStream(strOutputFile);
|
||||
fileStream.reset(CreateFileStream(strOutputFile));
|
||||
|
||||
if(!fileStream)
|
||||
{
|
||||
@ -290,15 +290,9 @@ void OBS::StopRecording()
|
||||
|
||||
if(!bRecording) return;
|
||||
|
||||
VideoFileStream *tempStream = NULL;
|
||||
|
||||
tempStream = fileStream;
|
||||
// Prevent the encoder thread from trying to write to fileStream while it's closing
|
||||
fileStream = NULL;
|
||||
|
||||
delete tempStream;
|
||||
tempStream = NULL;
|
||||
bRecording = false;
|
||||
auto stream = move(fileStream);
|
||||
|
||||
ReportStopRecordingTrigger();
|
||||
|
||||
@ -317,13 +311,7 @@ void OBS::Start(bool recordingOnly, bool replayBufferOnly)
|
||||
if((bRecording || bRecordingReplayBuffer) && networkMode == 0 && delayTime == 0 && !recordingOnly && !replayBufferOnly) {
|
||||
bFirstConnect = !bReconnecting;
|
||||
|
||||
if (network)
|
||||
{
|
||||
NetworkStream *net = network;
|
||||
network = nullptr;
|
||||
delete net;
|
||||
}
|
||||
network = CreateRTMPPublisher();
|
||||
network.reset(CreateRTMPPublisher());
|
||||
|
||||
Log(TEXT("=====Stream Start (while recording): %s============================="), CurrentDateTimeString().Array());
|
||||
|
||||
@ -444,13 +432,13 @@ retryHookTest:
|
||||
bFirstConnect = !bReconnecting;
|
||||
|
||||
if(bTestStream || recordingOnly || replayBufferOnly)
|
||||
network = CreateNullNetwork();
|
||||
network.reset(CreateNullNetwork());
|
||||
else
|
||||
{
|
||||
switch(networkMode)
|
||||
{
|
||||
case 0: network = (delayTime > 0) ? CreateDelayedPublisher(delayTime) : CreateRTMPPublisher(); break;
|
||||
case 1: network = CreateNullNetwork(); break;
|
||||
case 0: network.reset((delayTime > 0) ? CreateDelayedPublisher(delayTime) : CreateRTMPPublisher()); break;
|
||||
case 1: network.reset(CreateNullNetwork()); break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -529,7 +517,7 @@ retryHookTestV2:
|
||||
if (ret == IDABORT)
|
||||
{
|
||||
//FIXME: really need a better way to abort startup than this...
|
||||
delete network;
|
||||
network.reset();
|
||||
delete GS;
|
||||
|
||||
DisableMenusWhileStreaming(false);
|
||||
@ -899,15 +887,11 @@ void OBS::Stop(bool overrideKeepRecording)
|
||||
int networkMode = AppConfig->GetInt(TEXT("Publish"), TEXT("Mode"), 2);
|
||||
|
||||
if(((!overrideKeepRecording && bRecording && bKeepRecording) || bRecordingReplayBuffer) && networkMode == 0) {
|
||||
NetworkStream *tempStream = NULL;
|
||||
|
||||
videoEncoder->RequestKeyframe();
|
||||
tempStream = network;
|
||||
network = NULL;
|
||||
|
||||
Log(TEXT("=====Stream End (recording continues): %s========================="), CurrentDateTimeString().Array());
|
||||
network.reset();
|
||||
|
||||
delete tempStream;
|
||||
|
||||
bStreaming = false;
|
||||
bSentHeaders = false;
|
||||
@ -978,8 +962,7 @@ void OBS::Stop(bool overrideKeepRecording)
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
delete network;
|
||||
network = NULL;
|
||||
network.reset();
|
||||
if (bStreaming) ReportStopStreamingTrigger();
|
||||
bStreaming = false;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user