* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _XOPEN_SOURCE 600
-
#include "config.h"
#include <inttypes.h>
#include <math.h>
#include "libavutil/colorspace.h"
#include "libavutil/pixdesc.h"
#include "libavutil/imgutils.h"
+#include "libavutil/dict.h"
#include "libavutil/parseutils.h"
#include "libavutil/samplefmt.h"
#include "libavutil/avassert.h"
# include "libavfilter/avcodec.h"
# include "libavfilter/avfilter.h"
# include "libavfilter/avfiltergraph.h"
+# include "libavfilter/vsink_buffer.h"
#endif
-#include "cmdutils.h"
-
#include <SDL.h>
#include <SDL_thread.h>
-#ifdef __MINGW32__
-#undef main /* We don't want SDL to override our main() */
-#endif
+#include "cmdutils.h"
#include <unistd.h>
#include <assert.h>
const char program_name[] = "ffplay";
const int program_birth_year = 2003;
-//#define DEBUG
-//#define DEBUG_SYNC
-
#define MAX_QUEUE_SIZE (15 * 1024 * 1024)
#define MIN_AUDIOQ_SIZE (20 * 16 * 1024)
#define MIN_FRAMES 5
static int av_sync_type = AV_SYNC_AUDIO_MASTER;
static int64_t start_time = AV_NOPTS_VALUE;
static int64_t duration = AV_NOPTS_VALUE;
-static int debug = 0;
-static int debug_mv = 0;
static int step = 0;
static int thread_count = 1;
static int workaround_bugs = 1;
static int exit_on_keydown;
static int exit_on_mousedown;
static int loop=1;
-static int framedrop=1;
+static int framedrop=-1;
static enum ShowMode show_mode = SHOW_MODE_NONE;
static int rdftspeed=20;
SDL_FillRect(screen, &rect, color);
}
-#if 0
-/* draw only the border of a rectangle */
-void fill_border(VideoState *s, int x, int y, int w, int h, int color)
-{
- int w1, w2, h1, h2;
-
- /* fill the background */
- w1 = x;
- if (w1 < 0)
- w1 = 0;
- w2 = s->width - (x + w);
- if (w2 < 0)
- w2 = 0;
- h1 = y;
- if (h1 < 0)
- h1 = 0;
- h2 = s->height - (y + h);
- if (h2 < 0)
- h2 = 0;
- fill_rectangle(screen,
- s->xleft, s->ytop,
- w1, s->height,
- color);
- fill_rectangle(screen,
- s->xleft + s->width - w2, s->ytop,
- w2, s->height,
- color);
- fill_rectangle(screen,
- s->xleft + w1, s->ytop,
- s->width - w1 - w2, h1,
- color);
- fill_rectangle(screen,
- s->xleft + w1, s->ytop + s->height - h2,
- s->width - w1 - w2, h2,
- color);
-}
-#endif
-
#define ALPHA_BLEND(a, oldp, newp, s)\
((((oldp << s) * (255 - (a))) + (newp * (a))) / (255 << s))
}
x = (is->width - width) / 2;
y = (is->height - height) / 2;
- if (!is->no_background) {
- /* fill the background */
- // fill_border(is, x, y, width, height, QERGB(0x00, 0x00, 0x00));
- } else {
- is->no_background = 0;
- }
+ is->no_background = 0;
rect.x = is->xleft + x;
rect.y = is->ytop + y;
rect.w = FFMAX(width, 1);
rect.h = FFMAX(height, 1);
SDL_DisplayYUVOverlay(vp->bmp, &rect);
- } else {
-#if 0
- fill_rectangle(screen,
- is->xleft, is->ytop, is->width, is->height,
- QERGB(0x00, 0x00, 0x00));
-#endif
}
}
}
}
+static void stream_close(VideoState *is)
+{
+ VideoPicture *vp;
+ int i;
+ /* XXX: use a special url_shutdown call to abort parse cleanly */
+ is->abort_request = 1;
+ SDL_WaitThread(is->read_tid, NULL);
+ SDL_WaitThread(is->refresh_tid, NULL);
+
+ /* free all pictures */
+ for(i=0;i<VIDEO_PICTURE_QUEUE_SIZE; i++) {
+ vp = &is->pictq[i];
+#if CONFIG_AVFILTER
+ if (vp->picref) {
+ avfilter_unref_buffer(vp->picref);
+ vp->picref = NULL;
+ }
+#endif
+ if (vp->bmp) {
+ SDL_FreeYUVOverlay(vp->bmp);
+ vp->bmp = NULL;
+ }
+ }
+ SDL_DestroyMutex(is->pictq_mutex);
+ SDL_DestroyCond(is->pictq_cond);
+ SDL_DestroyMutex(is->subpq_mutex);
+ SDL_DestroyCond(is->subpq_cond);
+#if !CONFIG_AVFILTER
+ if (is->img_convert_ctx)
+ sws_freeContext(is->img_convert_ctx);
+#endif
+ av_free(is);
+}
+
+static void do_exit(void)
+{
+ if (cur_stream) {
+ stream_close(cur_stream);
+ cur_stream = NULL;
+ }
+ uninit_opts();
+#if CONFIG_AVFILTER
+ avfilter_uninit();
+#endif
+ if (show_status)
+ printf("\n");
+ SDL_Quit();
+ av_log(NULL, AV_LOG_QUIET, "%s", "");
+ exit(0);
+}
+
static int video_open(VideoState *is){
int flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL;
int w,h;
#endif
if (!screen) {
fprintf(stderr, "SDL: could not set video mode - exiting\n");
- return -1;
+ do_exit();
}
if (!window_title)
window_title = input_filename;
}
}
is->frame_timer += delay;
-#if defined(DEBUG_SYNC)
- printf("video: delay=%0.3f actual_delay=%0.3f pts=%0.3f A-V=%f\n",
- delay, actual_delay, frame_current_pts, -diff);
-#endif
+
+ av_dlog(NULL, "video: delay=%0.3f pts=%0.3f A-V=%f\n",
+ delay, frame_current_pts, -diff);
return is->frame_timer;
}
}else{
next_target= vp->target_clock + is->video_clock - vp->pts; //FIXME pass durations cleanly
}
- if(framedrop && time > next_target){
+ if((framedrop>0 || (framedrop && is->audio_st)) && time > next_target){
is->skip_frames *= 1.0 + FRAME_SKIP_FACTOR;
if(is->pictq_size > 1 || time > next_target + 0.5){
/* update queue size and signal for next picture */
}
}
-static void stream_close(VideoState *is)
-{
- VideoPicture *vp;
- int i;
- /* XXX: use a special url_shutdown call to abort parse cleanly */
- is->abort_request = 1;
- SDL_WaitThread(is->read_tid, NULL);
- SDL_WaitThread(is->refresh_tid, NULL);
-
- /* free all pictures */
- for(i=0;i<VIDEO_PICTURE_QUEUE_SIZE; i++) {
- vp = &is->pictq[i];
-#if CONFIG_AVFILTER
- if (vp->picref) {
- avfilter_unref_buffer(vp->picref);
- vp->picref = NULL;
- }
-#endif
- if (vp->bmp) {
- SDL_FreeYUVOverlay(vp->bmp);
- vp->bmp = NULL;
- }
- }
- SDL_DestroyMutex(is->pictq_mutex);
- SDL_DestroyCond(is->pictq_cond);
- SDL_DestroyMutex(is->subpq_mutex);
- SDL_DestroyCond(is->subpq_cond);
-#if !CONFIG_AVFILTER
- if (is->img_convert_ctx)
- sws_freeContext(is->img_convert_ctx);
-#endif
- av_free(is);
-}
-
-static void do_exit(void)
-{
- if (cur_stream) {
- stream_close(cur_stream);
- cur_stream = NULL;
- }
- uninit_opts();
-#if CONFIG_AVFILTER
- avfilter_uninit();
-#endif
- if (show_status)
- printf("\n");
- SDL_Quit();
- av_log(NULL, AV_LOG_QUIET, "");
- exit(0);
-}
-
/* allocate a picture (needs to do that in main thread to avoid
potential locking problems */
static void alloc_picture(void *opaque)
static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacket *pkt)
{
- int len1, got_picture, i;
+ int len1 av_unused, got_picture, i;
if (packet_queue_get(&is->videoq, pkt, 1) < 0)
return -1;
if (ret < 0)
return -1;
- if(priv->use_dr1) {
+ if(priv->use_dr1 && priv->frame->opaque) {
picref = avfilter_ref_buffer(priv->frame->opaque, ~0);
} else {
picref = avfilter_get_video_buffer(link, AV_PERM_WRITE, link->w, link->h);
priv->is->video_st->codec->pix_fmt, PIX_FMT_NONE
};
- avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts));
+ avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts));
return 0;
}
{
char sws_flags_str[128];
int ret;
- FFSinkContext ffsink_ctx = { .pix_fmt = PIX_FMT_YUV420P };
+ enum PixelFormat pix_fmts[] = { PIX_FMT_YUV420P, PIX_FMT_NONE };
AVFilterContext *filt_src = NULL, *filt_out = NULL;
snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags);
graph->scale_sws_opts = av_strdup(sws_flags_str);
if ((ret = avfilter_graph_create_filter(&filt_src, &input_filter, "src",
NULL, is, graph)) < 0)
goto the_end;
- if ((ret = avfilter_graph_create_filter(&filt_out, &ffsink, "out",
- NULL, &ffsink_ctx, graph)) < 0)
+ if ((ret = avfilter_graph_create_filter(&filt_out, avfilter_get_by_name("buffersink"), "out",
+ NULL, pix_fmts, graph)) < 0)
goto the_end;
if(vfilters) {
- AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut));
- AVFilterInOut *inputs = av_malloc(sizeof(AVFilterInOut));
+ AVFilterInOut *outputs = avfilter_inout_alloc();
+ AVFilterInOut *inputs = avfilter_inout_alloc();
outputs->name = av_strdup("in");
outputs->filter_ctx = filt_src;
inputs->pad_idx = 0;
inputs->next = NULL;
- if ((ret = avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL)) < 0)
+ if ((ret = avfilter_graph_parse(graph, vfilters, &inputs, &outputs, NULL)) < 0)
goto the_end;
av_freep(&vfilters);
} else {
{
VideoState *is = arg;
AVFrame *frame= avcodec_alloc_frame();
- int64_t pts_int, pos;
+ int64_t pts_int = AV_NOPTS_VALUE, pos = -1;
double pts;
int ret;
AVPacket pkt;
#else
AVFilterBufferRef *picref;
- AVRational tb;
+ AVRational tb = filt_out->inputs[0]->time_base;
#endif
while (is->paused && !is->videoq.abort_request)
SDL_Delay(10);
#if CONFIG_AVFILTER
- ret = get_filtered_video_frame(filt_out, frame, &picref, &tb);
+ ret = av_vsink_buffer_get_video_buffer_ref(filt_out, &picref, 0);
if (picref) {
+ avfilter_fill_frame_from_video_buffer_ref(frame, picref);
pts_int = picref->pts;
pos = picref->pos;
frame->opaque = picref;
if (ret < 0) goto the_end;
- if (!ret)
+ if (!picref)
continue;
pts = pts_int*av_q2d(is->video_st->time_base);
VideoState *is = arg;
SubPicture *sp;
AVPacket pkt1, *pkt = &pkt1;
- int len1, got_subtitle;
+ int len1 av_unused, got_subtitle;
double pts;
int i, j;
int r, g, b, y, u, v, a;
len1 = avcodec_decode_subtitle2(is->subtitle_st->codec,
&sp->sub, &got_subtitle,
pkt);
-// if (len1 < 0)
-// break;
if (got_subtitle && sp->sub.format == 0) {
sp->pts = pts;
SDL_UnlockMutex(is->subpq_mutex);
}
av_free_packet(pkt);
-// if (step)
-// if (cur_stream)
-// stream_toggle_pause(cur_stream);
}
the_end:
return 0;
if (is->reformat_ctx) {
const void *ibuf[6]= {is->audio_buf1};
void *obuf[6]= {is->audio_buf2};
- int istride[6]= {av_get_bits_per_sample_fmt(dec->sample_fmt)/8};
+ int istride[6]= {av_get_bytes_per_sample(dec->sample_fmt)};
int ostride[6]= {2};
int len= data_size/istride[0];
if (av_audio_convert(is->reformat_ctx, obuf, ostride, ibuf, istride, len)<0) {
n = 2 * dec->channels;
is->audio_clock += (double)data_size /
(double)(n * dec->sample_rate);
-#if defined(DEBUG_SYNC)
+#ifdef DEBUG
{
static double last_clock;
printf("audio: delay=%0.3f clock=%0.3f pts=%0.3f\n",
if (!codec)
return -1;
- avctx->debug_mv = debug_mv;
- avctx->debug = debug;
avctx->workaround_bugs = workaround_bugs;
avctx->lowres = lowres;
if(lowres) avctx->flags |= CODEC_FLAG_EMU_EDGE;
/* prepare audio output */
if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if(avctx->sample_rate <= 0 || avctx->channels <= 0){
+ fprintf(stderr, "Invalid sample rate or channel count\n");
+ return -1;
+ }
wanted_spec.freq = avctx->sample_rate;
wanted_spec.format = AUDIO_S16SYS;
wanted_spec.channels = avctx->channels;
is->video_stream = stream_index;
is->video_st = ic->streams[stream_index];
-// is->video_current_pts_time = av_gettime();
-
packet_queue_init(&is->videoq);
is->video_tid = SDL_CreateThread(video_thread, is);
break;
static int read_thread(void *arg)
{
VideoState *is = arg;
- AVFormatContext *ic;
+ AVFormatContext *ic = NULL;
int err, i, ret;
int st_index[AVMEDIA_TYPE_NB];
AVPacket pkt1, *pkt = &pkt1;
- AVFormatParameters params, *ap = ¶ms;
int eof=0;
int pkt_in_play_range = 0;
-
- ic = avformat_alloc_context();
+ AVDictionaryEntry *t;
memset(st_index, -1, sizeof(st_index));
is->video_stream = -1;
global_video_state = is;
avio_set_interrupt_cb(decode_interrupt_cb);
- memset(ap, 0, sizeof(*ap));
-
- ap->prealloced_context = 1;
- ap->width = frame_width;
- ap->height= frame_height;
- ap->time_base= (AVRational){1, 25};
- ap->pix_fmt = frame_pix_fmt;
- ic->flags |= AVFMT_FLAG_PRIV_OPT;
-
-
- err = av_open_input_file(&ic, is->filename, is->iformat, 0, ap);
- if (err >= 0) {
- set_context_opts(ic, avformat_opts, AV_OPT_FLAG_DECODING_PARAM, NULL);
- err = av_demuxer_open(ic, ap);
- if(err < 0){
- avformat_free_context(ic);
- ic= NULL;
- }
- }
+ err = avformat_open_input(&ic, is->filename, is->iformat, &format_opts);
if (err < 0) {
print_error(is->filename, err);
ret = -1;
goto fail;
}
+ if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
+ av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
+ ret = AVERROR_OPTION_NOT_FOUND;
+ goto fail;
+ }
is->ic = ic;
if(genpts)
static void toggle_full_screen(void)
{
is_full_screen = !is_full_screen;
- if (!fs_screen_width) {
- /* use default SDL method */
-// SDL_WM_ToggleFullScreen(screen);
- }
video_open(cur_stream);
}
}
}
-static void opt_frame_size(const char *arg)
+static int opt_frame_size(const char *opt, const char *arg)
{
if (av_parse_video_size(&frame_width, &frame_height, arg) < 0) {
fprintf(stderr, "Incorrect frame size\n");
- exit(1);
+ return AVERROR(EINVAL);
}
if ((frame_width % 2) != 0 || (frame_height % 2) != 0) {
fprintf(stderr, "Frame size must be a multiple of 2\n");
- exit(1);
+ return AVERROR(EINVAL);
}
+ return 0;
}
static int opt_width(const char *opt, const char *arg)
return 0;
}
-static void opt_format(const char *arg)
+static int opt_format(const char *opt, const char *arg)
{
file_iformat = av_find_input_format(arg);
if (!file_iformat) {
fprintf(stderr, "Unknown input format: %s\n", arg);
- exit(1);
+ return AVERROR(EINVAL);
}
+ return 0;
}
-static void opt_frame_pix_fmt(const char *arg)
+static int opt_frame_pix_fmt(const char *opt, const char *arg)
{
frame_pix_fmt = av_get_pix_fmt(arg);
+ return 0;
}
static int opt_sync(const char *opt, const char *arg)
return 0;
}
-static int opt_debug(const char *opt, const char *arg)
-{
- av_log_set_level(99);
- debug = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
- return 0;
-}
-
-static int opt_vismv(const char *opt, const char *arg)
-{
- debug_mv = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX);
- return 0;
-}
-
static int opt_thread_count(const char *opt, const char *arg)
{
thread_count= parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
return 0;
}
+static int opt_input_file(const char *opt, const char *filename)
+{
+ if (input_filename) {
+ fprintf(stderr, "Argument '%s' provided as input filename, but '%s' was already specified.\n",
+ filename, input_filename);
+ exit(1);
+ }
+ if (!strcmp(filename, "-"))
+ filename = "pipe:";
+ input_filename = filename;
+ return 0;
+}
+
static const OptionDef options[] = {
#include "cmdutils_common_opts.h"
- { "x", HAS_ARG | OPT_FUNC2, {(void*)opt_width}, "force displayed width", "width" },
- { "y", HAS_ARG | OPT_FUNC2, {(void*)opt_height}, "force displayed height", "height" },
+ { "x", HAS_ARG, {(void*)opt_width}, "force displayed width", "width" },
+ { "y", HAS_ARG, {(void*)opt_height}, "force displayed height", "height" },
{ "s", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_size}, "set frame size (WxH or abbreviation)", "size" },
{ "fs", OPT_BOOL, {(void*)&is_full_screen}, "force full screen" },
{ "an", OPT_BOOL, {(void*)&audio_disable}, "disable audio" },
{ "ast", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&wanted_stream[AVMEDIA_TYPE_AUDIO]}, "select desired audio stream", "stream_number" },
{ "vst", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&wanted_stream[AVMEDIA_TYPE_VIDEO]}, "select desired video stream", "stream_number" },
{ "sst", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&wanted_stream[AVMEDIA_TYPE_SUBTITLE]}, "select desired subtitle stream", "stream_number" },
- { "ss", HAS_ARG | OPT_FUNC2, {(void*)&opt_seek}, "seek to a given position in seconds", "pos" },
- { "t", HAS_ARG | OPT_FUNC2, {(void*)&opt_duration}, "play \"duration\" seconds of audio/video", "duration" },
+ { "ss", HAS_ARG, {(void*)&opt_seek}, "seek to a given position in seconds", "pos" },
+ { "t", HAS_ARG, {(void*)&opt_duration}, "play \"duration\" seconds of audio/video", "duration" },
{ "bytes", OPT_INT | HAS_ARG, {(void*)&seek_by_bytes}, "seek by bytes 0=off 1=on -1=auto", "val" },
{ "nodisp", OPT_BOOL, {(void*)&display_disable}, "disable graphical display" },
{ "f", HAS_ARG, {(void*)opt_format}, "force format", "fmt" },
{ "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_frame_pix_fmt}, "set pixel format", "format" },
{ "stats", OPT_BOOL | OPT_EXPERT, {(void*)&show_status}, "show status", "" },
- { "debug", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_debug}, "print specific debug info", "" },
{ "bug", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&workaround_bugs}, "workaround bugs", "" },
- { "vismv", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_vismv}, "visualize motion vectors", "" },
{ "fast", OPT_BOOL | OPT_EXPERT, {(void*)&fast}, "non spec compliant optimizations", "" },
{ "genpts", OPT_BOOL | OPT_EXPERT, {(void*)&genpts}, "generate pts", "" },
{ "drp", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&decoder_reorder_pts}, "let decoder reorder pts 0=off 1=on -1=auto", ""},
{ "idct", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&idct}, "set idct algo", "algo" },
{ "er", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&error_recognition}, "set error detection threshold (0-4)", "threshold" },
{ "ec", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&error_concealment}, "set error concealment options", "bit_mask" },
- { "sync", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_sync}, "set audio-video sync. type (type=audio/video/ext)", "type" },
- { "threads", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
+ { "sync", HAS_ARG | OPT_EXPERT, {(void*)opt_sync}, "set audio-video sync. type (type=audio/video/ext)", "type" },
+ { "threads", HAS_ARG | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
{ "autoexit", OPT_BOOL | OPT_EXPERT, {(void*)&autoexit}, "exit at the end", "" },
{ "exitonkeydown", OPT_BOOL | OPT_EXPERT, {(void*)&exit_on_keydown}, "exit on key down", "" },
{ "exitonmousedown", OPT_BOOL | OPT_EXPERT, {(void*)&exit_on_mousedown}, "exit on mouse down", "" },
{ "vf", OPT_STRING | HAS_ARG, {(void*)&vfilters}, "video filters", "filter list" },
#endif
{ "rdftspeed", OPT_INT | HAS_ARG| OPT_AUDIO | OPT_EXPERT, {(void*)&rdftspeed}, "rdft speed", "msecs" },
- { "showmode", HAS_ARG | OPT_FUNC2, {(void*)opt_show_mode}, "select show mode (0 = video, 1 = waves, 2 = RDFT)", "mode" },
- { "default", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
- { "i", OPT_DUMMY, {NULL}, "ffmpeg compatibility dummy option", ""},
+ { "showmode", HAS_ARG, {(void*)opt_show_mode}, "select show mode (0 = video, 1 = waves, 2 = RDFT)", "mode" },
+ { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
+ { "i", HAS_ARG, {(void *)opt_input_file}, "read specified file", "input_file"},
{ NULL, },
};
);
}
-static void opt_input_file(const char *filename)
-{
- if (input_filename) {
- fprintf(stderr, "Argument '%s' provided as input filename, but '%s' was already specified.\n",
- filename, input_filename);
- exit(1);
- }
- if (!strcmp(filename, "-"))
- filename = "pipe:";
- input_filename = filename;
-}
-
/* Called from the main */
int main(int argc, char **argv)
{
video_disable = 1;
}
flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER;
+ if (audio_disable)
+ flags &= ~SDL_INIT_AUDIO;
#if !defined(__MINGW32__) && !defined(__APPLE__)
flags |= SDL_INIT_EVENTTHREAD; /* Not supported on Windows or Mac OS X */
#endif