提交 018a8d20 编写于 作者: Z Zhang Rui

ijkplayer: remove unused msg_queue

上级 a2fbbce9
/*
* ff_error.h
* ff_fferror.h
*
* Copyright (c) 2003 Fabrice Bellard
* Copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
......@@ -21,8 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef IJKPLAYER__FF_ERROR_H
#define IJKPLAYER__FF_ERROR_H
#ifndef IJKPLAYER__FF_FFERROR_H
#define IJKPLAYER__FF_FFERROR_H
#define EIJK_FAILED -1
#define EIJK_OUT_OF_MEMORY -2
......
/*
* ff_ffmsg.h
* based on PacketQueue in ffplay.c
*
* Copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* ijkPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef IJKPLAYER__FF_FFMSG_H
#define IJKPLAYER__FF_FFMSG_H
#define IJKFF_MSG_FLUSH 0
#define IJKFF_MSG_ERROR 100 /* arg1 = error */
#define IJKFF_MSG_PREPARED 200
#define IJKFF_MSG_COMPLETED 300
#define IJKFF_MSG_VIDEO_SIZE_CHANGED 400 /* arg1 = width, arg2 = height */
#define IJKFF_MSG_SAR_CHANGED 401 /* arg1 = sar.num, arg2 = sar.den */
#define IJKFF_MSG_BUFFERING_START 500
#define IJKFF_MSG_BUFFERING_END 501
#define IJKFF_MSG_BUFFERING_FORWARD 502 /* arg1 = cached duration */
#define IJKFF_MSG_SEEK_COMPLETED 600
#endif
/*
* ff_ffmsg_queue.h
* based on PacketQueue in ffplay.c
*
* Copyright (c) 2000-2003 Fabrice Bellard
* Copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* ijkPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef IJKPLAYER__FF_FFMSG_QUEUE_H
#define IJKPLAYER__FF_FFMSG_QUEUE_H
#include "ff_ffinc.h"
typedef struct IjkMessage {
int what;
int arg1;
int arg2;
// optional
void *data;
void (*free_data)(void *data);
int serial;
struct IjkMessage *next;
} IjkMessage;
typedef struct IjkMessageQueue {
IjkMessage *first_msg, *last_msg;
int abort_request;
int serial;
SDL_mutex *mutex;
SDL_cond *cond;
} IjkMessageQueue;
extern IjkMessage flush_msg;
static void ijkmsg_init_msg(IjkMessage *msg) {
memset(msg, 0, sizeof(IjkMessage));
}
static void ijkmsg_free_msg(IjkMessage **pmsg) {
if (!pmsg || *pmsg)
return;
IjkMessage *msg = *pmsg;
if (msg->free_data && msg->data) {
msg->free_data(msg->data);
}
free(msg);
*pmsg = NULL;
}
static int ijkmsg_queue_put_private(IjkMessageQueue *q, IjkMessage *msg)
{
IjkMessage *msg1;
if (q->abort_request)
return -1;
msg1 = malloc(sizeof(IjkMessage));
if (!msg1)
return -1;
*msg1 = *msg;
msg1->next = NULL;
if (msg == &flush_msg)
q->serial++;
msg1->serial = q->serial;
if (!q->last_msg)
q->first_msg = msg1;
else
q->last_msg->next = msg1;
q->last_msg = msg1;
SDL_CondSignal(q->cond);
return 0;
}
static int ijkmsg_queue_put(IjkMessageQueue *q, IjkMessage *msg)
{
int ret;
SDL_LockMutex(q->mutex);
ret = ijkmsg_queue_put_private(q, msg);
SDL_UnlockMutex(q->mutex);
if (msg != &flush_msg && ret < 0)
ijkmsg_free_msg(&msg);
return ret;
}
static void ijkmsg_queue_init(IjkMessageQueue *q)
{
memset(q, 0, sizeof(IjkMessageQueue));
q->mutex = SDL_CreateMutex();
q->cond = SDL_CreateCond();
q->abort_request = 1;
}
static void ijkmsg_queue_flush(IjkMessageQueue *q)
{
IjkMessage *msg, *msg1;
SDL_LockMutex(q->mutex);
for (msg = q->first_msg; msg != NULL; msg = msg1) {
msg1 = msg->next;
ijkmsg_free_msg(&msg);
}
q->last_msg = NULL;
q->first_msg = NULL;
SDL_UnlockMutex(q->mutex);
}
static void ijkmsg_queue_destroy(IjkMessageQueue *q)
{
ijkmsg_queue_flush(q);
SDL_DestroyMutex(q->mutex);
SDL_DestroyCond(q->cond);
}
static void ijkmsg_queue_abort(IjkMessageQueue *q)
{
SDL_LockMutex(q->mutex);
q->abort_request = 1;
SDL_CondSignal(q->cond);
SDL_UnlockMutex(q->mutex);
}
static void ijkmsg_queue_start(IjkMessageQueue *q)
{
SDL_LockMutex(q->mutex);
q->abort_request = 0;
ijkmsg_queue_put_private(q, &flush_msg);
SDL_UnlockMutex(q->mutex);
}
/* return < 0 if aborted, 0 if no msg and > 0 if msg. */
static int ijkmsg_queue_get(IjkMessageQueue *q, IjkMessage *msg, int block, int *serial)
{
IjkMessage *msg1;
int ret;
SDL_LockMutex(q->mutex);
for (;;) {
if (q->abort_request) {
ret = -1;
break;
}
msg1 = q->first_msg;
if (msg1) {
q->first_msg = msg1->next;
if (!q->first_msg)
q->last_msg = NULL;
*msg = *msg1;
if (serial)
*serial = msg1->serial;
ijkmsg_free_msg(&msg1);
ret = 1;
break;
} else if (!block) {
ret = 0;
break;
} else {
SDL_CondWait(q->cond, q->mutex);
}
}
SDL_UnlockMutex(q->mutex);
return ret;
}
#endif
......@@ -23,7 +23,7 @@
#include "ff_ffplay.h"
#include "ff_cmdutils.h"
#include "ijkerror.h"
#include "ff_fferror.h"
static int packet_queue_put(PacketQueue *q, AVPacket *pkt);
......@@ -1995,7 +1995,6 @@ static int lockmgr(void **mtx, enum AVLockOp op)
****************************************************************************/
AVPacket flush_pkt;
IjkMessage flush_msg;
static bool g_ffmpeg_global_inited = false;
static void ijkff_log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
......@@ -2038,8 +2037,6 @@ void ijkff_global_init()
av_init_packet(&flush_pkt);
flush_pkt.data = (uint8_t *) &flush_pkt;
ijkmsg_init_msg(&flush_msg);
g_ffmpeg_global_inited = true;
/* test link begin */
......
......@@ -25,7 +25,8 @@
#define IJKPLAYER__FF_FFPLAY_H
#include "ff_ffplay_def.h"
#include "ff_error.h"
#include "ff_fferror.h"
#include "ff_ffmsg.h"
void ijkff_global_init();
void ijkff_global_uninit();
......
......@@ -26,7 +26,6 @@
#include "ff_ffinc.h"
#include "ff_ffplay_config.h"
#include "ff_ffmsg_queue.h"
#define MAX_QUEUE_SIZE (15 * 1024 * 1024)
#define MIN_FRAMES 5
......@@ -473,16 +472,6 @@ inline static void ijkff_reset_internal(FFPlayer *ffp)
ffp->msg_handler = NULL;
}
#define IJKFF_MSG_ERROR 100 /* arg1 = error */
#define IJKFF_MSG_PREPARED 200
#define IJKFF_MSG_COMPLETED 300
#define IJKFF_MSG_VIDEO_SIZE_CHANGED 400 /* arg1 = width, arg2 = height */
#define IJKFF_MSG_SAR_CHANGED 401 /* arg1 = sar.num, arg2 = sar.den */
#define IJKFF_MSG_BUFFERING_START 500
#define IJKFF_MSG_BUFFERING_END 501
#define IJKFF_MSG_BUFFERING_FORWARD 502 /* arg1 = cached duration */
#define IJKFF_MSG_SEEK_COMPLETED 600
inline static void ijkff_notify_msg(FFPlayer *ffp, int what, int arg1, int arg2, void* data) {
if (ffp->msg_handler)
ffp->msg_handler(ffp->msg_opaque, what, arg1, arg2, data);
......
......@@ -23,7 +23,7 @@
#include "ijkplayer_android.h"
#include <assert.h>
#include "ffplay/ijkerror.h"
#include "ffplay/ff_fferror.h"
#include "ffplay/ff_ffplay.h"
#define MPST_CHECK_NOT_RET_INT(real, expected, errcode) \
......@@ -39,7 +39,7 @@ typedef struct IjkMediaPlayer {
pthread_mutex_t mutex;
FFPlayer *ffplayer;
IjkMessageQueue msg_queue;
// FIXME: IjkMessageQueue msg_queue;
int mp_state;
char *data_source;
......@@ -61,7 +61,7 @@ inline static void destroy_mp(IjkMediaPlayer **pmp)
ijkff_destroy_ffplayer(&mp->ffplayer);
}
ijkmsg_queue_destroy(&mp->msg_queue);
// FIXME: ijkmsg_queue_destroy(&mp->msg_queue);
pthread_mutex_destroy(&mp->mutex);
free(mp->data_source);
......@@ -94,7 +94,8 @@ void ijkmp_setup_internal(IjkMediaPlayer *mp) {
ffp->msg_opaque = mp;
ffp->msg_handler = ijkmp_msg_handler;
ijkmsg_queue_start(&mp->msg_queue);
// FIXME: ijkmsg_queue_flush(&mp->msg_queue);
// FIXME: ijkmsg_queue_start(&mp->msg_queue);
}
IjkMediaPlayer *ijkmp_create()
......@@ -112,7 +113,7 @@ IjkMediaPlayer *ijkmp_create()
}
pthread_mutex_init(&mp->mutex, NULL);
ijkmsg_queue_init(&mp->msg_queue);
// FIXME: ijkmsg_queue_init(&mp->msg_queue);
ijkmp_inc_ref(mp);
......@@ -126,7 +127,7 @@ void ijkmp_shutdown_l(IjkMediaPlayer *mp)
{
assert(mp);
ijkmsg_queue_abort(&mp->msg_queue);
// FIXME: ijkmsg_queue_abort(&mp->msg_queue);
if (mp->ffplayer) {
ijkff_stop_l(mp->ffplayer);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册