Skip to content

Commit

Permalink
Unset LD_PRELOAD for future forks (like ffmpeg encoding)
Browse files Browse the repository at this point in the history
  • Loading branch information
clementgallet committed Aug 13, 2018
1 parent 0c8cd2c commit 881c48d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/libTAS/ScreenCapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@ const char* ScreenCapture::getPixelFormat()
MYASSERT(inited)

if (game_info.video & GameInfo::OPENGL) {
return "BGRA";
return "RGBA";
}

if (game_info.video & GameInfo::SDL1) {
// SDL1::SDL_Surface *surf = orig::SDL_GetVideoSurface();
debuglog(LCF_DUMP | LCF_SDL | LCF_TODO, "We assumed pixel format is RGBA");
return "BGRA"; // TODO
return "RGBA"; // TODO
}

if (game_info.video & GameInfo::SDL2) {
Expand Down Expand Up @@ -296,7 +296,7 @@ const char* ScreenCapture::getPixelFormat()
}
}

return "BGRA";
return "RGBA";
}

int ScreenCapture::getPixels(uint8_t **pixels)
Expand Down
2 changes: 1 addition & 1 deletion src/libTAS/encoding/AVEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ AVEncoder::AVEncoder(SDL_Window* window) {

// ASSERT_RETURN_VOID(shared_config.framerate_num > 0, "Not supporting non deterministic timer");

std::string commandline = "ffmpeg -hide_banner -y -v 56 -f nut -i - ";
std::string commandline = "ffmpeg -hide_banner -y -f nut -i - ";
commandline += ffmpeg_options;
commandline += " \"";
commandline += dumpfile;
Expand Down
18 changes: 12 additions & 6 deletions src/libTAS/libTAS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,24 @@
#include "encoding/AVEncoder.h"
#include <unistd.h> // getpid()

extern char**environ;

namespace libtas {

void __attribute__((constructor)) init(void)
{
/* Hacking `environ` to disable LD_PRELOAD for future processes */
/* Taken from <https://stackoverflow.com/a/3275799> */
for (int i=0; environ[i]; i++) {
if ( strstr(environ[i], "LD_PRELOAD=") ) {
// printf("hacking out LD_PRELOAD from environ[%d]\n",i);
environ[i][0] = 'D';
}
}

ThreadManager::init();

bool didConnect = initSocketGame();
/* Sometimes the game starts a process that is not a thread, so that this constructor is called again
* In this case, we must detect it and do not run this again
*/
if (! didConnect)
return;
initSocketGame();

/* Send information to the program */

Expand Down

0 comments on commit 881c48d

Please sign in to comment.