Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions src/bin/imgtools/rvio/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,14 +970,8 @@ int utf8Main(int argc, char* argv[])
setEnvVar("LC_ALL", "C");
TwkFB::ThreadPool::initialize();

//
// XXX dummyDev is leaking here. Best would be to pass it to the App so
// that it could delete it after startup, since it's no longer needed at
// that point.
//

#ifdef RVIO_HW
TwkGLF::FBOVideoDevice* dummyDev = new TwkGLF::FBOVideoDevice(0, 10, 10, false);
auto dummyDev = std::make_unique<TwkGLF::FBOVideoDevice>(nullptr, 10, 10, false);
#else
TwkGLF::OSMesaVideoDevice* dummyDev = new TwkGLF::OSMesaVideoDevice(0, 10, 10, true);
FrameBuffer* dummyFB = new FrameBuffer(10, 10, 4, FrameBuffer::FLOAT);
Expand Down Expand Up @@ -1646,7 +1640,7 @@ int utf8Main(int argc, char* argv[])
threadAPI.create = GC_pthread_create;
threadAPI.join = GC_pthread_join;
threadAPI.detach = GC_pthread_detach;
outmov = new ThreadedMovie(inputMovies, outFrames, 8, &threadAPI, threadedMovieInit);
outmov = new ThreadedMovie(inputMovies, outFrames, 8, &threadAPI, threadedMovieInit, MovieRV::uninit);
#endif
#endif

Expand Down Expand Up @@ -1739,10 +1733,6 @@ int utf8Main(int argc, char* argv[])

if (!writer->write(outmov, outfile, writeRequest))
exit(-2);

// clean up any frame buffers we allocated writing the movie
//
MovieRV::uninit();
}
catch (TwkExc::Exception& exc)
{
Expand Down
12 changes: 11 additions & 1 deletion src/lib/image/TwkMovie/ThreadedMovie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ namespace TwkMovie
mov->threadMain();
}

ThreadedMovie::ThreadedMovie(const Movies& movies, const Frames& frames, size_t stackMultiplier, ThreadAPI* api, InitializeFunc F)
ThreadedMovie::ThreadedMovie(const Movies& movies, const Frames& frames, size_t stackMultiplier, ThreadAPI* api, InitializeFunc F,
FinalizeFunc finalizeFunction)
: m_movies(movies)
, m_threadGroup(movies.size(), stackMultiplier, api)
, m_frames(frames)
, m_init(true)
, m_currentIndex(0)
, m_requestIndex(0)
, m_initialize(F)
, m_finalize(finalizeFunction)
{
// if (!m_movie->isThreadSafe()) throw runtime_exception();
m_info = movies.front()->info();
Expand Down Expand Up @@ -188,8 +190,16 @@ namespace TwkMovie

m_threadGroup.lock(m_runLock);
td->running = false;

bool allFramesDone = (m_currentIndex >= m_frames.size());

m_threadGroup.unlock(m_runLock);

if (allFramesDone && m_finalize != nullptr)
{
m_finalize();
}

// cout << "thread " << td->id << " no longer running" << endl;
}

Expand Down
5 changes: 4 additions & 1 deletion src/lib/image/TwkMovie/TwkMovie/ThreadedMovie.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ namespace TwkMovie
typedef std::vector<Movie*> Movies;
typedef stl_ext::thread_group::thread_api ThreadAPI;
typedef void (*InitializeFunc)();
using FinalizeFunc = void (*)();

ThreadedMovie(const Movies&, const Frames& frames, size_t stackMultiplier = 8, ThreadAPI* api = 0, InitializeFunc = NULL);
ThreadedMovie(const Movies&, const Frames& frames, size_t stackMultiplier = 8, ThreadAPI* api = nullptr, InitializeFunc = nullptr,
FinalizeFunc = nullptr);

virtual ~ThreadedMovie();

Expand Down Expand Up @@ -104,6 +106,7 @@ namespace TwkMovie
int m_requestIndex;
bool m_init;
InitializeFunc m_initialize;
FinalizeFunc m_finalize;
};

} // namespace TwkMovie
Expand Down
Loading