2 * Copyright (c) 2006-2011 Ed Schouten <ed@80386.nl>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * @brief Application startup routine.
33 #include "audio_output.h"
38 #include "scrobbler.h"
42 * @brief Display the application version and compile-time options.
47 g_printerr(APP_NAME
" " APP_VERSION
48 " (Two-clause BSD license"
49 #if defined(BUILD_AO) || defined(BUILD_MP3) || defined(BUILD_SNDFILE)
50 ", using GNU GPL licensed libraries"
51 #endif /* BUILD_AO || BUILD_MP3 || BUILD_SNDFILE */
54 "%s: " AUDIO_OUTPUT
"\n"
62 #endif /* BUILD_VORBIS */
65 #endif /* BUILD_MP3 */
68 #endif /* BUILD_MODPLUG */
71 #endif /* BUILD_SNDFILE */
73 _("Global configuration file"),
75 _("Support for AudioScrobbler"),
76 #ifdef BUILD_SCROBBLER
78 #else /* !BUILD_SCROBBLER */
80 #endif /* BUILD_SCROBBLER */
81 _("Support for DBus integration"),
84 #else /* !BUILD_DBUS */
86 #endif /* BUILD_DBUS */
87 _("Support for HTTP streams"),
90 #else /* !BUILD_HTTP */
92 #endif /* BUILD_HTTP */
93 _("Support for XSPF playlists (`spiff')"),
96 #else /* !BUILD_XSPF */
98 #endif /* BUILD_XSPF */
99 _("Supported audio file formats"));
105 * @brief Display the command line usage flags.
110 g_printerr("%s: " APP_NAME
" [-pvx] [-c configfile] "
111 "[file ...]\n", _("usage"));
116 * @brief Startup routine for the application.
119 main(int argc
, char *argv
[])
121 int ch
, i
, show_version
= 0, autoplay
= 0, xmms
= 0;
127 #endif /* CLOSE_STDERR */
130 setlocale(LC_ALL
, "");
131 bindtextdomain(APP_NAME
, TRANSDIR
);
132 textdomain(APP_NAME
);
133 #endif /* BUILD_NLS */
135 /* Global and local configuration files */
136 config_load(CONFFILE
, 1);
137 config_load(CONFHOMEDIR
"config", 1);
139 while ((ch
= getopt(argc
, argv
, "c:pvx")) != -1) {
142 config_load(optarg
, 0);
165 if (audio_output_open() != 0)
168 /* Already initialize the GUI before chroot() */
172 devnull
= open("/dev/null", O_WRONLY
);
173 #endif /* CLOSE_STDERR */
174 if ((errmsg
= vfs_lockup()) != NULL
) {
175 gui_draw_init_abort();
176 g_printerr("%s", errmsg
);
182 /* Initialize the locks */
185 #endif /* BUILD_DBUS */
186 #ifdef BUILD_SCROBBLER
188 #endif /* BUILD_SCROBBLER */
189 playq_init(autoplay
, xmms
, (argc
== 0));
191 /* Draw all the windows */
192 gui_draw_init_post();
194 cwd
= g_get_current_dir();
195 for (i
= 0; i
< argc
; i
++) {
196 /* Shell will expand ~ */
197 if ((vr
= vfs_lookup(argv
[i
], NULL
, cwd
, 1)) != NULL
) {
198 playq_song_add_tail(vr
);
205 /* Close stderr before starting playback */
206 dup2(devnull
, STDERR_FILENO
);
208 #endif /* CLOSE_STDERR */
210 /* All set and done - spawn our threads */
214 #endif /* BUILD_DBUS */
215 #ifdef BUILD_SCROBBLER
217 #endif /* BUILD_SCROBBLER */
221 g_assert_not_reached();