ao: fix crash after ao init failure (from recent 3a5fd15fa2)
[mplayer/greg.git] / stream / open.c
blobce0a415ceb4014a1253acc2186470f78f343ae56
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include <ctype.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <unistd.h>
24 #include <fcntl.h>
25 #include <string.h>
27 #include "config.h"
28 #include "mp_msg.h"
30 #ifdef __FreeBSD__
31 #include <sys/cdrio.h>
32 #endif
34 #include "m_option.h"
35 #include "stream.h"
36 #include "libmpdemux/demuxer.h"
39 /// We keep these 2 for the gui atm, but they will be removed.
40 int vcd_track=0;
41 char* cdrom_device=NULL;
42 char* dvd_device=NULL;
43 int dvd_title=0;
45 // Open a new stream (stdin/file/vcd/url)
47 stream_t* open_stream(const char *filename, struct MPOpts *options,
48 int *file_format)
50 if (!file_format)
51 file_format = &(int){DEMUXER_TYPE_UNKNOWN};
52 // Check if playlist or unknown
53 if (*file_format != DEMUXER_TYPE_PLAYLIST){
54 *file_format=DEMUXER_TYPE_UNKNOWN;
57 if(!filename) {
58 mp_msg(MSGT_OPEN,MSGL_ERR,"NULL filename, report this bug\n");
59 return NULL;
62 //============ Open STDIN or plain FILE ============
64 return open_stream_full(filename,STREAM_READ,options,file_format);