Comments (11)
Proposed Patch:
+ int player_create_callback(struct Player *player) {
+ static const AVIOInterruptCB int_cb = {interrupt_cb, NULL};
+ player->input_format_ctx->interrupt_callback = int_cb;
+ player->input_format_ctx->interrupt_callback.opaque = player;
+ //Some verification here
+ return 0;
+ }
+ static int interrupt_cb (void *p)
+ {
+ struct Player *player = (struct Player*) p;
+ if(player->exit_called){
+ return 1;
+ }
+ return 0;
+ }
struct Player {
.....
int caputre_streams_no;
+ int exit_called;
int video_stream_no;
....
}
void player_stop(struct State * state) {
int ret;
+ state->player->exit_called = 1;
pthread_mutex_lock(&state->player->mutex_operation);
player_stop_without_lock(state);
pthread_mutex_unlock(&state->player->mutex_operation);
}
int player_set_data_source(struct State *state, const char *file_path,
AVDictionary *dictionary, int video_stream_no, int audio_stream_no,
int subtitle_stream_no) {
....
+ if ((err = player_create_callback(player)) < 0)
+ goto error;
...
}
from androidffmpeg.
This looks god - but there should be added some synchronization mechanism - some mutex to prevent read/write exit_called from different threads, and to ensure that this variable is pushed between two cpu's units. Probably I will try to fis this tomorrow. But I do not have testing environment - we use ffmpeg only via wifi. But you will be able to check.
from androidffmpeg.
Perfect, if there's anything I can help just let me know
from androidffmpeg.
Sorry for late answer.. I have a lot to do in other project.
This is fix, try it please because I do not have time to test it. https://review.appunite.com/3993
from androidffmpeg.
(Please Ignore my last messages)
After heavy testing the problem was a simple pthread_mutex_unlock(&player->mutex_interrupt); before returning 1 :)
static int player_ctx_interrupt_callback(void *p) {
struct Player *player = (struct Player*) p;
pthread_mutex_lock(&player->mutex_interrupt);
if (player->interrupt) {
//Don't forget to unlock
pthread_mutex_unlock(&player->mutex_interrupt);
return 1;
}
pthread_mutex_unlock(&player->mutex_interrupt);
return 0;
}
from androidffmpeg.
sorry for ugly bug.
Last time I wrote to much code with java "synchronize (obj) {}", "try {} finally {}" style ;)
Fixed https://review.appunite.com/#/c/3993/
from androidffmpeg.
The most obvious bugs are always the most difficult to spot :)
Beware that patch set 2 is the same as patch set 1 don't forget to add the pthread_mutex_unlock(&player->mutex_interrupt);
from androidffmpeg.
It is quite different
int player_ctx_interrupt_callback(void *p) {
int ret = 0;
struct Player *player = (struct Player*) p;
pthread_mutex_lock(&player->mutex_interrupt);
if (player->interrupt) {
// method is interrupt
ret = 1; // <- no return just assign variable
}
pthread_mutex_unlock(&player->mutex_interrupt);
return ret;
}
"The most obvious bugs are always the most difficult to spot :)" - true
from androidffmpeg.
Ooops I didn't notice the subtle change :)
from androidffmpeg.
Another hang occurs if we call player_stop() while player_open_input() is running as AVIOInterrupt doesn't handle callbacks on avformat_open_input()
The hang happens because of:
void player_stop_without_lock(struct State * state) {
....
//playing false so we return and don't execute closing procedure
if (!player->playing)
return;
....
}
Maybe adding another check:
if (!player->playing && !player->setting_data_source)
return;
What do you think jacek?
from androidffmpeg.
A possible solution:
void player_stop(struct State * state) {
int ret;
struct Player * player = state->player;
pthread_mutex_lock(&player->mutex_interrupt);
player->interrupt = TRUE;
pthread_mutex_unlock(&player->mutex_interrupt);
+ if(!player->input_inited){
+ //If locking thread a minimal block occurs but exits, not sure what to do
+ //pthread_mutex_lock(&player->mutex_operation);
+ player_open_input_free(player);
+ //pthread_mutex_unlock(&player->mutex_operation);
+ }
else{
pthread_mutex_lock(&player->mutex_operation);
player_stop_without_lock(state);
pthread_mutex_unlock(&player->mutex_operation);
}
}
int player_set_data_source(){
....
if ((err = player_open_input(player, file_path, dictionary)) < 0)
goto error;
+ else if (player->interrupt && !player->input_inited)
+ goto error;
...
}
from androidffmpeg.
Related Issues (20)
- It compiles but doesn't work
- 'Could not find compilator' HOT 3
- seekNative() doesn't return any frame
- app was crashed HOT 1
- I want joinning, thanks
- I play tcp stream from camera,there is about 0.5 seconds delay,is there some buffer resulted in? HOT 1
- automake: error: 'configure.ac' is required HOT 1
- could somebody send me the compiled library?
- build_android.sh "C compiler cannot create executables" HOT 3
- library:processReleaseResources FAILED
- mp4 video player system crash
- Can I use this library to play h264 over rtsp? HOT 2
- Fatal signal SIGSEGV after playing 4-5 videos one after the another
- Cannot build project HOT 1
- can't update submodule with libyuv HOT 5
- Why libavfilter is disabled in ffmpeg configuration? HOT 3
- extracting subtitles using this project HOT 1
- Higher versions Support HOT 3
- Repo
- crash on app
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from androidffmpeg.