Starting streamer thread

This commit is contained in:
2021-08-17 01:49:30 -07:00
parent e046c1638a
commit 42717276b5
6 changed files with 36 additions and 27 deletions

View File

@@ -26,7 +26,7 @@ add_sources(KRDevice.cpp)
add_sources(KRDeviceManager.cpp) add_sources(KRDeviceManager.cpp)
add_sources(KRSurface.cpp) add_sources(KRSurface.cpp)
add_sources(KRSurfaceManager.cpp) add_sources(KRSurfaceManager.cpp)
add_sources(KRStreamer.cpp) add_sources(KRStreamerThread.cpp)
IF(APPLE) IF(APPLE)
add_sources(KREngine.mm) add_sources(KREngine.mm)

View File

@@ -37,6 +37,7 @@
#include "KRAudioSample.h" #include "KRAudioSample.h"
#include "KRBundle.h" #include "KRBundle.h"
#include "KRPresentationThread.h" #include "KRPresentationThread.h"
#include "KRStreamerThread.h"
#if defined(ANDROID) #if defined(ANDROID)
#include <chrono> #include <chrono>
@@ -82,10 +83,10 @@ KRContext::log_callback *KRContext::s_log_callback = NULL;
void *KRContext::s_log_callback_user_data = NULL; void *KRContext::s_log_callback_user_data = NULL;
KRContext::KRContext(const KrInitializeInfo* initializeInfo) KRContext::KRContext(const KrInitializeInfo* initializeInfo)
: m_streamer(*this) : m_resourceMapSize(initializeInfo->resourceMapSize)
, m_resourceMapSize(initializeInfo->resourceMapSize)
{ {
m_presentationThread = std::make_unique<KRPresentationThread>(*this); m_presentationThread = std::make_unique<KRPresentationThread>(*this);
m_streamerThread = std::make_unique<KRStreamerThread>(*this);
m_resourceMap = (KRResource **)malloc(sizeof(KRResource*) * m_resourceMapSize); m_resourceMap = (KRResource **)malloc(sizeof(KRResource*) * m_resourceMapSize);
memset(m_resourceMap, 0, m_resourceMapSize * sizeof(KRResource*)); memset(m_resourceMap, 0, m_resourceMapSize * sizeof(KRResource*));
m_streamingEnabled = false; m_streamingEnabled = false;
@@ -133,10 +134,12 @@ KRContext::KRContext(const KrInitializeInfo* initializeInfo)
m_deviceManager->initialize(); m_deviceManager->initialize();
m_presentationThread->start(); m_presentationThread->start();
m_streamerThread->start();
} }
KRContext::~KRContext() { KRContext::~KRContext() {
m_presentationThread->stop(); m_presentationThread->stop();
m_streamerThread->stop();
m_pSceneManager.reset(); m_pSceneManager.reset();
m_pMeshManager.reset(); m_pMeshManager.reset();
m_pMaterialManager.reset(); m_pMaterialManager.reset();
@@ -570,7 +573,6 @@ KrResult KRContext::saveResource(const KrSaveResourceInfo* saveResourceInfo)
void KRContext::startFrame(float deltaTime) void KRContext::startFrame(float deltaTime)
{ {
m_streamer.startStreamer();
m_pTextureManager->startFrame(deltaTime); m_pTextureManager->startFrame(deltaTime);
m_pAnimationManager->startFrame(deltaTime); m_pAnimationManager->startFrame(deltaTime);
m_pSoundManager->startFrame(deltaTime); m_pSoundManager->startFrame(deltaTime);

View File

@@ -46,12 +46,12 @@
#include "KRSourceManager.h" #include "KRSourceManager.h"
#include "KRSurfaceManager.h" #include "KRSurfaceManager.h"
#include "KRDeviceManager.h" #include "KRDeviceManager.h"
#include "KRStreamer.h"
#include "KRDevice.h" #include "KRDevice.h"
#include "KRSurface.h" #include "KRSurface.h"
class KRAudioManager; class KRAudioManager;
class KRPresentationThread; class KRPresentationThread;
class KRStreamerThread;
class KRContext { class KRContext {
public: public:
@@ -198,11 +198,12 @@ private:
static log_callback *s_log_callback; static log_callback *s_log_callback;
static void *s_log_callback_user_data; static void *s_log_callback_user_data;
KRStreamer m_streamer;
unordered_multimap<std::string, KRResource*> m_resources; unordered_multimap<std::string, KRResource*> m_resources;
std::unique_ptr<KRStreamerThread> m_streamerThread;
std::unique_ptr<KRPresentationThread> m_presentationThread; std::unique_ptr<KRPresentationThread> m_presentationThread;
unordered_map<KrSurfaceMapIndex, KrSurfaceHandle> m_surfaceHandleMap; unordered_map<KrSurfaceMapIndex, KrSurfaceHandle> m_surfaceHandleMap;

View File

@@ -1,5 +1,5 @@
// //
// KRStreamer.cpp // KRStreamerThread.cpp
// Kraken Engine // Kraken Engine
// //
// Copyright 2021 Kearwood Gilbert. All rights reserved. // Copyright 2021 Kearwood Gilbert. All rights reserved.
@@ -31,28 +31,28 @@
#include "KREngine-common.h" #include "KREngine-common.h"
#include "KRStreamer.h" #include "KRStreamerThread.h"
#include "KRContext.h" #include "KRContext.h"
#include <chrono> #include <chrono>
KRStreamer::KRStreamer(KRContext &context) : m_context(context) KRStreamerThread::KRStreamerThread(KRContext &context) : m_context(context)
{ {
m_running = false; m_running = false;
m_stop = false; m_stop = false;
} }
void KRStreamer::startStreamer() void KRStreamerThread::start()
{ {
if(!m_running) { if(!m_running) {
m_running = true; 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) { if (m_running) {
m_stop = true; m_stop = true;
@@ -61,7 +61,12 @@ KRStreamer::~KRStreamer()
} }
} }
void KRStreamer::run() KRStreamerThread::~KRStreamerThread()
{
stop();
}
void KRStreamerThread::run()
{ {
#if defined(ANDROID) #if defined(ANDROID)

View File

@@ -1,5 +1,5 @@
// //
// KRStreamer.h // KRStreamerThread.h
// Kraken Engine // Kraken Engine
// //
// Copyright 2021 Kearwood Gilbert. All rights reserved. // Copyright 2021 Kearwood Gilbert. All rights reserved.
@@ -29,8 +29,8 @@
// or implied, of Kearwood Gilbert. // or implied, of Kearwood Gilbert.
// //
#ifndef KRSTREAMER_H #ifndef KRSTREAMERTHREAD_H
#define KRSTREAMER_H #define KRSTREAMERTHREAD_H
#include "KREngine-common.h" #include "KREngine-common.h"
@@ -39,13 +39,14 @@
class KRContext; class KRContext;
class KRStreamer class KRStreamerThread
{ {
public: public:
KRStreamer(KRContext &context); KRStreamerThread(KRContext &context);
~KRStreamer(); ~KRStreamerThread();
void startStreamer(); void start();
void stop();
private: private:
KRContext &m_context; KRContext &m_context;
@@ -57,4 +58,4 @@ private:
void run(); void run();
}; };
#endif /* defined(KRSTREAMER_H) */ #endif // KRSTREAMERTHREAD_H

View File

@@ -41,7 +41,7 @@
#include "KREngine-common.h" #include "KREngine-common.h"
#include "KRDataBlock.h" #include "KRDataBlock.h"
#include "KRContext.h" #include "KRContext.h"
#include "KRStreamer.h" #include "KRStreamerThread.h"
class KRTextureManager : public KRResourceManager { class KRTextureManager : public KRResourceManager {
public: public: