ffmpeg threadsafety critical bug fixed, display gif time and status / views added, 0.9.18

This commit is contained in:
John Preston 2016-01-05 14:59:57 +08:00
parent f2824f79f6
commit afb40b8289
5 changed files with 51 additions and 29 deletions

View File

@ -97,11 +97,6 @@ bool _checkALError() {
Q_DECLARE_METATYPE(AudioMsgId);
Q_DECLARE_METATYPE(SongMsgId);
void audioInit() {
if (!audioDevice) {
av_register_all();
avcodec_register_all();
}
if (!capture) {
capture = new AudioCapture();
cSetHasAudioCapture(capture->check());

View File

@ -4596,18 +4596,15 @@ void HistoryGif::draw(Painter &p, const HistoryItem *parent, const QRect &r, boo
p.setFont(st::normalFont);
p.setPen(st::white);
p.drawTextLeft(statusX, statusY, _width, _statusText, statusW - 2 * st::msgDateImgPadding.x());
// date
if (_caption.isEmpty() && parent->getMedia() == this) {
int32 fullRight = skipx + width, fullBottom = skipy + height;
parent->drawInfo(p, fullRight, fullBottom, 2 * skipx + width, selected, InfoDisplayOverImage);
}
}
}
if (!_caption.isEmpty()) {
p.setPen(st::black);
_caption.draw(p, st::msgPadding.left(), skipy + height + st::mediaPadding.bottom() + st::mediaCaptionSkip, captionw);
} else if (parent->getMedia() == this) {
int32 fullRight = skipx + width, fullBottom = skipy + height;
parent->drawInfo(p, fullRight, fullBottom, 2 * skipx + width, selected, InfoDisplayOverImage);
}
}

View File

@ -32,7 +32,7 @@ int main(int argc, char *argv[]) {
//signal(SIGSEGV, _sigsegvHandler);
#endif
InitOpenSSL _init;
LibrariesInitializer _init;
settingsParseArgs(argc, argv);
for (int32 i = 0; i < argc; ++i) {

View File

@ -187,6 +187,32 @@ namespace {
delete l;
}
int _ffmpegLockManager(void **mutex, AVLockOp op) {
switch (op) {
case AV_LOCK_CREATE: {
t_assert(*mutex == 0);
*mutex = reinterpret_cast<void*>(new QMutex());
} break;
case AV_LOCK_OBTAIN: {
t_assert(*mutex != 0);
reinterpret_cast<QMutex*>(*mutex)->lock();
} break;
case AV_LOCK_RELEASE: {
t_assert(*mutex != 0);
reinterpret_cast<QMutex*>(*mutex)->unlock();
}; break;
case AV_LOCK_DESTROY: {
t_assert(*mutex != 0);
delete reinterpret_cast<QMutex*>(*mutex);
*mutex = 0;
} break;
}
return 0;
}
float64 _msFreq;
float64 _msgIdCoef;
int64 _msStart = 0, _msAddToMsStart = 0, _msAddToUnixtime = 0;
@ -238,7 +264,7 @@ namespace {
_MsStarter _msStarter;
}
InitOpenSSL::InitOpenSSL() {
LibrariesInitializer::LibrariesInitializer() {
if (!RAND_status()) { // should be always inited in all modern OS
char buf[16];
memcpy(buf, &_msStart, 8);
@ -262,10 +288,17 @@ InitOpenSSL::InitOpenSSL() {
CRYPTO_set_dynlock_lock_callback(_sslLockFunction);
CRYPTO_set_dynlock_destroy_callback(_sslDestroyFunction);
av_register_all();
avcodec_register_all();
av_lockmgr_register(_ffmpegLockManager);
_sslInited = true;
}
InitOpenSSL::~InitOpenSSL() {
LibrariesInitializer::~LibrariesInitializer() {
av_lockmgr_register(0);
delete[] _sslLocks;
_sslLocks = 0;
}
@ -640,10 +673,7 @@ char *hashMd5Hex(const int32 *hashmd5, void *dest) {
}
void memset_rand(void *data, uint32 len) {
if (!_sslInited) {
LOG(("Critical Error: memset_rand() called before OpenSSL init!"));
exit(-1);
}
t_assert(_sslInited);
RAND_bytes((uchar*)data, len);
}

View File

@ -133,10 +133,10 @@ inline void mylocaltime(struct tm * _Tm, const time_t * _Time) {
#endif
}
class InitOpenSSL {
class LibrariesInitializer {
public:
InitOpenSSL();
~InitOpenSSL();
LibrariesInitializer();
~LibrariesInitializer();
};
bool checkms(); // returns true if time has changed