Starting streamer thread
This commit is contained in:
@@ -26,7 +26,7 @@ add_sources(KRDevice.cpp)
|
||||
add_sources(KRDeviceManager.cpp)
|
||||
add_sources(KRSurface.cpp)
|
||||
add_sources(KRSurfaceManager.cpp)
|
||||
add_sources(KRStreamer.cpp)
|
||||
add_sources(KRStreamerThread.cpp)
|
||||
IF(APPLE)
|
||||
add_sources(KREngine.mm)
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "KRAudioSample.h"
|
||||
#include "KRBundle.h"
|
||||
#include "KRPresentationThread.h"
|
||||
#include "KRStreamerThread.h"
|
||||
|
||||
#if defined(ANDROID)
|
||||
#include <chrono>
|
||||
@@ -82,10 +83,10 @@ KRContext::log_callback *KRContext::s_log_callback = NULL;
|
||||
void *KRContext::s_log_callback_user_data = NULL;
|
||||
|
||||
KRContext::KRContext(const KrInitializeInfo* initializeInfo)
|
||||
: m_streamer(*this)
|
||||
, m_resourceMapSize(initializeInfo->resourceMapSize)
|
||||
: m_resourceMapSize(initializeInfo->resourceMapSize)
|
||||
{
|
||||
m_presentationThread = std::make_unique<KRPresentationThread>(*this);
|
||||
m_streamerThread = std::make_unique<KRStreamerThread>(*this);
|
||||
m_resourceMap = (KRResource **)malloc(sizeof(KRResource*) * m_resourceMapSize);
|
||||
memset(m_resourceMap, 0, m_resourceMapSize * sizeof(KRResource*));
|
||||
m_streamingEnabled = false;
|
||||
@@ -133,10 +134,12 @@ KRContext::KRContext(const KrInitializeInfo* initializeInfo)
|
||||
m_deviceManager->initialize();
|
||||
|
||||
m_presentationThread->start();
|
||||
m_streamerThread->start();
|
||||
}
|
||||
|
||||
KRContext::~KRContext() {
|
||||
m_presentationThread->stop();
|
||||
m_streamerThread->stop();
|
||||
m_pSceneManager.reset();
|
||||
m_pMeshManager.reset();
|
||||
m_pMaterialManager.reset();
|
||||
@@ -570,7 +573,6 @@ KrResult KRContext::saveResource(const KrSaveResourceInfo* saveResourceInfo)
|
||||
|
||||
void KRContext::startFrame(float deltaTime)
|
||||
{
|
||||
m_streamer.startStreamer();
|
||||
m_pTextureManager->startFrame(deltaTime);
|
||||
m_pAnimationManager->startFrame(deltaTime);
|
||||
m_pSoundManager->startFrame(deltaTime);
|
||||
|
||||
@@ -46,12 +46,12 @@
|
||||
#include "KRSourceManager.h"
|
||||
#include "KRSurfaceManager.h"
|
||||
#include "KRDeviceManager.h"
|
||||
#include "KRStreamer.h"
|
||||
#include "KRDevice.h"
|
||||
#include "KRSurface.h"
|
||||
|
||||
class KRAudioManager;
|
||||
class KRPresentationThread;
|
||||
class KRStreamerThread;
|
||||
|
||||
class KRContext {
|
||||
public:
|
||||
@@ -198,11 +198,12 @@ private:
|
||||
static log_callback *s_log_callback;
|
||||
static void *s_log_callback_user_data;
|
||||
|
||||
KRStreamer m_streamer;
|
||||
|
||||
|
||||
unordered_multimap<std::string, KRResource*> m_resources;
|
||||
|
||||
|
||||
std::unique_ptr<KRStreamerThread> m_streamerThread;
|
||||
std::unique_ptr<KRPresentationThread> m_presentationThread;
|
||||
|
||||
unordered_map<KrSurfaceMapIndex, KrSurfaceHandle> m_surfaceHandleMap;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// KRStreamer.cpp
|
||||
// KRStreamerThread.cpp
|
||||
// Kraken Engine
|
||||
//
|
||||
// Copyright 2021 Kearwood Gilbert. All rights reserved.
|
||||
@@ -31,37 +31,42 @@
|
||||
|
||||
#include "KREngine-common.h"
|
||||
|
||||
#include "KRStreamer.h"
|
||||
#include "KRStreamerThread.h"
|
||||
#include "KRContext.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
|
||||
KRStreamer::KRStreamer(KRContext &context) : m_context(context)
|
||||
KRStreamerThread::KRStreamerThread(KRContext &context) : m_context(context)
|
||||
{
|
||||
m_running = false;
|
||||
m_stop = false;
|
||||
}
|
||||
|
||||
void KRStreamer::startStreamer()
|
||||
void KRStreamerThread::start()
|
||||
{
|
||||
if(!m_running) {
|
||||
m_running = true;
|
||||
|
||||
m_thread = std::thread(&KRStreamer::run, this);
|
||||
m_thread = std::thread(&KRStreamerThread::run, this);
|
||||
}
|
||||
}
|
||||
|
||||
KRStreamer::~KRStreamer()
|
||||
void KRStreamerThread::stop()
|
||||
{
|
||||
if(m_running) {
|
||||
m_stop = true;
|
||||
m_thread.join();
|
||||
m_running = false;
|
||||
}
|
||||
if (m_running) {
|
||||
m_stop = true;
|
||||
m_thread.join();
|
||||
m_running = false;
|
||||
}
|
||||
}
|
||||
|
||||
void KRStreamer::run()
|
||||
KRStreamerThread::~KRStreamerThread()
|
||||
{
|
||||
stop();
|
||||
}
|
||||
|
||||
void KRStreamerThread::run()
|
||||
{
|
||||
|
||||
#if defined(ANDROID)
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// KRStreamer.h
|
||||
// KRStreamerThread.h
|
||||
// Kraken Engine
|
||||
//
|
||||
// Copyright 2021 Kearwood Gilbert. All rights reserved.
|
||||
@@ -29,8 +29,8 @@
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
#ifndef KRSTREAMER_H
|
||||
#define KRSTREAMER_H
|
||||
#ifndef KRSTREAMERTHREAD_H
|
||||
#define KRSTREAMERTHREAD_H
|
||||
|
||||
#include "KREngine-common.h"
|
||||
|
||||
@@ -39,13 +39,14 @@
|
||||
|
||||
class KRContext;
|
||||
|
||||
class KRStreamer
|
||||
class KRStreamerThread
|
||||
{
|
||||
public:
|
||||
KRStreamer(KRContext &context);
|
||||
~KRStreamer();
|
||||
KRStreamerThread(KRContext &context);
|
||||
~KRStreamerThread();
|
||||
|
||||
void startStreamer();
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
private:
|
||||
KRContext &m_context;
|
||||
@@ -57,4 +58,4 @@ private:
|
||||
void run();
|
||||
};
|
||||
|
||||
#endif /* defined(KRSTREAMER_H) */
|
||||
#endif // KRSTREAMERTHREAD_H
|
||||
@@ -41,7 +41,7 @@
|
||||
#include "KREngine-common.h"
|
||||
#include "KRDataBlock.h"
|
||||
#include "KRContext.h"
|
||||
#include "KRStreamer.h"
|
||||
#include "KRStreamerThread.h"
|
||||
|
||||
class KRTextureManager : public KRResourceManager {
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user