kolyvan / kxmovie

movie player for iOS using ffmpeg
2.83k stars 917 forks source link

Problem with dealloc'ing and creating new instance of KxMovieViewController (threadsafe?) #38

Open bezigon opened 11 years ago

bezigon commented 11 years ago

2013-03-19 16:32:43.884 Example[44174:c07] <KxMovieViewController: 0xb459ae0> dealloc [aac @ 0xab31600] Insufficient thread locking around avcodec_open/close() [h264 @ 0xab18200] Insufficient thread locking around avcodec_open/close() 2013-03-19 16:32:47.413 Example[44174:c07] loadView Assertion ff_avcodec_locked failed at libavcodec/utils.c:2750

Solution? I've used this commit 294812348bab7f33d400dd016e1948cdeadae52b

Seems I'm solved problem by adding in KxMovieDecoder.m

int lock_call_back(void ** mutex, enum AVLockOp op) {
    switch(op) {
        case AV_LOCK_CREATE:
            *mutex = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));
            pthread_mutex_init((pthread_mutex_t *)(*mutex), NULL);
            break;
        case AV_LOCK_OBTAIN:
            pthread_mutex_lock((pthread_mutex_t *)(*mutex));
            break;
        case AV_LOCK_RELEASE:
            pthread_mutex_unlock((pthread_mutex_t *)(*mutex));
            break;
        case AV_LOCK_DESTROY:
            pthread_mutex_destroy((pthread_mutex_t *)(*mutex));
            free(*mutex);
            break;
    }

   return 0;
}

in + (id)initialize() av_lockmgr_register(&lock_call_back);

in - (void)dealloc() av_lockmgr_register(NULL);

It's okay solution?

BUT I have problem with EXC_BAD_ACCESS (_videoFrame->interlaced_frame in - (BOOL) setupVideoFrameFormat: (KxVideoFrameFormat) format)

AND The code above (int lock_call_back(void \ mutex, enum AVLockOp op)) not working with latest commit 36c3f080b1

2013-03-19 18:55:24.658 Example[50975:c07] /Users/bezigon/Library/Application Support/iPhone Simulator/6.1/Applications/CD84470A-4EBE-48F4-A0A6-1F7623694AEC/Documents/50 Common Misconceptions - mental_floss on YouTube (Ep.1).mp4 2013-03-19 18:55:24.658 Example[50975:c07] <KxMovieViewController: 0xa510540> dealloc 2013-03-19 18:55:24.663 Example[50975:c07] <KxMovieDecoder: 0xa510040> dealloc [NULL @ 0xd34d600] Insufficient thread locking around avcodec_open/close() [NULL @ 0xd34de00] Insufficient thread locking around avcodec_open/close() [NULL @ 0xd34d600] Insufficient thread locking around avcodec_open/close() [NULL @ 0xd34de00] Insufficient thread locking around avcodec_open/close() [NULL @ 0xd34d600] Insufficient thread locking around avcodec_open/close() [NULL @ 0xd34de00] Insufficient thread locking around avcodec_open/close() Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '50 Common Misconceptions - mental_floss on YouTube (Ep.1).mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2013-03-09 20:30:31 Duration: 00:06:10.13, start: 0.000000, bitrate: 602 kb/s Stream #0:0(und): Video: h264 (avc1 / 0x31637661), 640x360, 503 kb/s, 24 fps, 24 tbr, 48 tbn, 48 tbc Metadata: creation_time : 1970-01-01 00:00:00 handler_name : VideoHandler Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, 2 channels, 95 kb/s Metadata: creation_time : 2013-03-09 20:30:32 handler_name : IsoMedia File Produced by Google, 5-11-2011 [NULL @ 0xd34d600] Insufficient thread locking around avcodec_open/close() [NULL @ 0xd34de00] Insufficient thread locking around avcodec_open/close() 2013-03-19 18:55:24.665 Example[50975:c31b] Unable to open codec, 50 Common Misconceptions - mental_floss on YouTube (Ep.1).mp4 Assertion ff_avcodec_locked failed at libavcodec/utils.c:2750

kolyvan commented 11 years ago

Never saw such messages and have no idea about problem with locking.

How do you use KxMovieViewController?

bezigon commented 11 years ago

kxmovie.zip (224.2 MB) https://mega.co.nz/#!b15G3RiI!AR2fBHb2hIj2bum_4wR4WShmoQ9MRbbrrQYYqbunZ7M

this is an example of stress testing project, please check it out!

erema commented 11 years ago

I have the same problem!

alacom commented 10 years ago

I have the same problem!

2002sergey commented 10 years ago

I have the same problem!