Skip to content

Commit

Permalink
fix(cicadaPlayer): fix on error crash in travis env
Browse files Browse the repository at this point in the history
Signed-off-by: pingkai <pingkai010@gmail.com>
  • Loading branch information
pingkai committed Jan 31, 2020
1 parent e35bbeb commit da92089
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cmdline/cicadaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ using IEvent = IEventReceiver::IEvent;
struct cicadaCont {
MediaPlayer *player;
IEventReceiver *receiver;
bool error;
};

static void onVideoSize(int64_t width, int64_t height, void *userData)
Expand All @@ -36,7 +37,8 @@ static void onEOS(void *userData)
{
auto *cont = static_cast<cicadaCont *>(userData);
auto *event = new IEvent(IEvent::TYPE_EXIT);
cont->receiver->push(std::unique_ptr<IEvent>(event));
if (cont->receiver)
cont->receiver->push(std::unique_ptr<IEvent>(event));
}

static void onEvent(int64_t errorCode, const void *errorMsg, void *userData)
Expand Down Expand Up @@ -64,9 +66,12 @@ static void onError(int64_t errorCode, const void *errorMsg, void *userData)
if (errorMsg) {
AF_LOGE("%s\n", errorMsg);
}

auto *event = new IEvent(IEvent::TYPE_EXIT);
cont->receiver->push(std::unique_ptr<IEvent>(event));
if (cont->receiver) {
auto *event = new IEvent(IEvent::TYPE_EXIT);
cont->receiver->push(std::unique_ptr<IEvent>(event));
} else{
cont->error= true;
}
}

int main(int argc, const char **argv)
Expand Down Expand Up @@ -106,7 +111,7 @@ int main(int argc, const char **argv)
player->Prepare();
bool quite = false;

while (!quite) {
while (!quite && !cicada.error) {
#ifdef ENABLE_SDL
receiver.poll(quite);
#endif
Expand Down

0 comments on commit da92089

Please sign in to comment.