Mercurial > audlegacy-plugins
annotate src/cdaudio-ng/cdaudio-ng.c @ 2256:dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
author | Calin Crisan ccrisan@gmail.com |
---|---|
date | Thu, 20 Dec 2007 21:44:59 +0200 |
parents | e5401b6c4665 |
children | 854b5fae995e |
rev | line source |
---|---|
1508
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
1 /* |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
2 * Audacious CD Digital Audio plugin |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
3 * |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
4 * Copyright (c) 2007 Calin Crisan <ccrisan@gmail.com> |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
5 * |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
8 * the Free Software Foundation; under version 3 of the License. |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
9 * |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
13 * GNU General Public License for more details. |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
14 * |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
15 * You should have received a copy of the GNU General Public License |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
16 * along with this program. If not, see <http://www.gnu.org/licenses>. |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
17 */ |
1490
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
18 |
2049
9550e809dc12
Added a short TODO comment section.
Matti Hamalainen <ccr@tnsp.org>
parents:
2048
diff
changeset
|
19 /* TODO (added by ccr) |
9550e809dc12
Added a short TODO comment section.
Matti Hamalainen <ccr@tnsp.org>
parents:
2048
diff
changeset
|
20 * - maybe make CDDB lib optional? |
9550e809dc12
Added a short TODO comment section.
Matti Hamalainen <ccr@tnsp.org>
parents:
2048
diff
changeset
|
21 * - use_cddb/use_cdtext don't seem to be checked in all necessary places. why? |
9550e809dc12
Added a short TODO comment section.
Matti Hamalainen <ccr@tnsp.org>
parents:
2048
diff
changeset
|
22 */ |
9550e809dc12
Added a short TODO comment section.
Matti Hamalainen <ccr@tnsp.org>
parents:
2048
diff
changeset
|
23 |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
24 #include "config.h" |
1048 | 25 |
26 #include <string.h> | |
27 #include <stdlib.h> | |
28 #include <unistd.h> | |
29 #include <errno.h> | |
30 #include <libgen.h> | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
31 #include <stdarg.h> |
1048 | 32 |
33 #include <cdio/cdio.h> | |
34 #include <cdio/cdtext.h> | |
35 #include <cdio/track.h> | |
36 #include <cdio/cdda.h> | |
37 #include <cdio/audio.h> | |
38 #include <cdio/sector.h> | |
39 #include <cdio/cd_types.h> | |
1282 | 40 #include <cddb/cddb.h> |
1048 | 41 |
42 #include <glib.h> | |
43 | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
44 #include <audacious/plugin.h> |
1048 | 45 #include <audacious/i18n.h> |
1529 | 46 #include <audacious/output.h> |
47 #include <audacious/playlist.h> | |
48 #include <audacious/ui_plugin_menu.h> | |
1048 | 49 #include <audacious/util.h> |
50 | |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
51 #include "cdaudio-ng.h" |
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
52 #include "configure.h" |
1123 | 53 |
2046 | 54 struct cdng_cfg_t cdng_cfg; |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
55 static gint firsttrackno = -1; |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
56 static gint lasttrackno = -1; |
1123 | 57 static CdIo_t *pcdio = NULL; |
1048 | 58 static trackinfo_t *trackinfo = NULL; |
59 static gboolean is_paused = FALSE; | |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
60 static gint playing_track = -1; |
1123 | 61 static dae_params_t *pdae_params = NULL; |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
62 static InputPlayback *pglobalinputplayback = NULL; |
1490
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
63 static GtkWidget *main_menu_item, *playlist_menu_item; |
1048 | 64 |
2047 | 65 static void cdaudio_init(void); |
66 static void cdaudio_about(void); | |
67 static void cdaudio_configure(void); | |
68 static gint cdaudio_is_our_file(gchar *filename); | |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
69 static GList *cdaudio_scan_dir(gchar *dirname); |
2047 | 70 static void cdaudio_play_file(InputPlayback *pinputplayback); |
71 static void cdaudio_stop(InputPlayback *pinputplayback); | |
72 static void cdaudio_pause(InputPlayback *pinputplayback, gshort paused); | |
73 static void cdaudio_seek(InputPlayback *pinputplayback, gint time); | |
74 static gint cdaudio_get_time(InputPlayback *pinputplayback); | |
75 static gint cdaudio_get_volume(gint *l, gint *r); | |
76 static gint cdaudio_set_volume(gint l, gint r); | |
77 static void cdaudio_cleanup(void); | |
78 static void cdaudio_get_song_info(gchar *filename, gchar **title, gint *length); | |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
79 static Tuple *cdaudio_get_song_tuple(gchar *filename); |
1048 | 80 |
2047 | 81 static void menu_click(void); |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
82 static Tuple *create_tuple_from_trackinfo(gchar *filename); |
2047 | 83 static void dae_play_loop(dae_params_t *pdae_params); |
84 static gint calculate_track_length(gint startlsn, gint endlsn); | |
85 static gint find_trackno_from_filename(gchar *filename); | |
86 static void cleanup_on_error(void); | |
1048 | 87 |
88 | |
89 static InputPlugin inputplugin = { | |
1624
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
90 .description = "CD Audio Plugin NG", |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
91 .init = cdaudio_init, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
92 .about = cdaudio_about, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
93 .configure = cdaudio_configure, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
94 .is_our_file = cdaudio_is_our_file, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
95 .scan_dir = cdaudio_scan_dir, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
96 .play_file = cdaudio_play_file, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
97 .stop = cdaudio_stop, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
98 .pause = cdaudio_pause, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
99 .seek = cdaudio_seek, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
100 .get_time = cdaudio_get_time, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
101 .get_volume = cdaudio_get_volume, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
102 .set_volume = cdaudio_set_volume, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
103 .cleanup = cdaudio_cleanup, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
104 .get_song_info = cdaudio_get_song_info, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
105 .get_song_tuple = cdaudio_get_song_tuple |
1048 | 106 }; |
107 | |
1098
334afe46961c
[svn] - cdaudio-ng (aka Zither's CD Audio Plugin): convert to plugin API v2
nenolod
parents:
1048
diff
changeset
|
108 InputPlugin *cdaudio_iplist[] = { &inputplugin, NULL }; |
1048 | 109 |
1395
761e17b23e0c
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
1389
diff
changeset
|
110 DECLARE_PLUGIN(cdaudio, NULL, NULL, cdaudio_iplist, NULL, NULL, NULL, NULL, NULL); |
1048 | 111 |
1123 | 112 |
2047 | 113 static void cdaudio_error(const char *fmt, ...) |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
114 { |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
115 va_list ap; |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
116 fprintf(stderr, "cdaudio-ng: "); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
117 va_start(ap, fmt); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
118 vfprintf(stderr, fmt, ap); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
119 va_end(ap); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
120 } |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
121 |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
122 |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
123 static void debug(const char *fmt, ...) |
1048 | 124 { |
2046 | 125 if (cdng_cfg.debug) { |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
126 va_list ap; |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
127 fprintf(stderr, "cdaudio-ng: "); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
128 va_start(ap, fmt); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
129 vfprintf(stderr, fmt, ap); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
130 va_end(ap); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
131 } |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
132 } |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
133 |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
134 |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
135 static void cdaudio_init() |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
136 { |
2037 | 137 ConfigDb *db; |
138 gchar *menu_item_text; | |
139 | |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
140 debug("cdaudio_init()\n"); |
2046 | 141 |
142 memset(&cdng_cfg, 0, sizeof(cdng_cfg)); | |
1125 | 143 |
2044 | 144 if ((db = aud_cfg_db_open()) == NULL) { |
2037 | 145 cdaudio_error("Failed to read configuration.\n"); |
146 cleanup_on_error(); | |
147 return; | |
148 } | |
149 | |
1123 | 150 if (!cdio_init()) { |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
151 cdaudio_error("Failed to initialize cdio subsystem.\n"); |
1123 | 152 cleanup_on_error(); |
153 return; | |
154 } | |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
155 |
1282 | 156 libcddb_init(); |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
157 |
1339
83cbc6968a0b
Set DAE the default and non-optional play method; Configuring the plugin no longer stops the playback;
Calin Crisan ccrisan@gmail.com
parents:
1314
diff
changeset
|
158 /* |
2046 | 159 if (!aud_cfg_db_get_bool(db, "CDDA", "use_dae", &cdng_cfg.use_dae)) |
1339
83cbc6968a0b
Set DAE the default and non-optional play method; Configuring the plugin no longer stops the playback;
Calin Crisan ccrisan@gmail.com
parents:
1314
diff
changeset
|
160 */ |
2048 | 161 cdng_cfg.use_dae = TRUE; |
162 | |
2046 | 163 if (!aud_cfg_db_get_int(db, "CDDA", "limitspeed", &cdng_cfg.limitspeed)) |
164 cdng_cfg.limitspeed = 1; | |
165 if (!aud_cfg_db_get_bool(db, "CDDA", "use_cdtext", &cdng_cfg.use_cdtext)) | |
166 cdng_cfg.use_cdtext = TRUE; | |
167 if (!aud_cfg_db_get_bool(db, "CDDA", "use_cddb", &cdng_cfg.use_cddb)) | |
168 cdng_cfg.use_cddb = TRUE; | |
169 if (!aud_cfg_db_get_string(db, "CDDA", "cddbserver", &cdng_cfg.cddb_server)) | |
170 cdng_cfg.cddb_server = g_strdup(CDDA_DEFAULT_CDDB_SERVER); | |
171 if (!aud_cfg_db_get_int(db, "CDDA", "cddbport", &cdng_cfg.cddb_port)) | |
172 cdng_cfg.cddb_port = CDDA_DEFAULT_CDDB_PORT; | |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
173 if (!aud_cfg_db_get_bool(db, "CDDA", "cddbhttp", &cdng_cfg.cddb_http)) |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
174 cdng_cfg.cddb_port = FALSE; |
2046 | 175 if (!aud_cfg_db_get_string(db, "CDDA", "device", &cdng_cfg.device)) |
176 cdng_cfg.device = g_strdup(""); | |
177 if (!aud_cfg_db_get_bool(db, "CDDA", "debug", &cdng_cfg.debug)) | |
178 cdng_cfg.debug = FALSE; | |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
179 if (!aud_cfg_db_get_bool(db, "audacious", "use_proxy", &cdng_cfg.use_proxy)) |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
180 cdng_cfg.debug = FALSE; |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
181 if (!aud_cfg_db_get_string(db, "audacious", "proxy_host", &cdng_cfg.proxy_host)) |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
182 cdng_cfg.proxy_host = g_strdup(""); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
183 if (!aud_cfg_db_get_int(db, "audacious", "proxy_port", &cdng_cfg.proxy_port)) |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
184 cdng_cfg.proxy_port = 8080; |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
185 if (!aud_cfg_db_get_string(db, "audacious", "proxy_user", &cdng_cfg.proxy_username)) |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
186 cdng_cfg.proxy_username = g_strdup(""); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
187 if (!aud_cfg_db_get_string(db, "audacious", "proxy_pass", &cdng_cfg.proxy_password)) |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
188 cdng_cfg.proxy_password = g_strdup(""); |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
189 |
2044 | 190 aud_cfg_db_close(db); |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
191 |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
192 debug("use_dae = %d, limitspeed = %d, use_cdtext = %d, use_cddb = %d, cddbserver = \"%s\", cddbport = %d, cddbhttp = %d, device = \"%s\", debug = %d\n", |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
193 cdng_cfg.use_dae, cdng_cfg.limitspeed, cdng_cfg.use_cdtext, cdng_cfg.use_cddb, |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
194 cdng_cfg.cddb_server, cdng_cfg.cddb_port, cdng_cfg.cddb_http, cdng_cfg.device, cdng_cfg.debug); |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
195 |
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
196 configure_create_gui(); |
1490
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
197 |
2037 | 198 menu_item_text = _("Add CD"); |
1529 | 199 main_menu_item = gtk_image_menu_item_new_with_label(menu_item_text); |
1490
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
200 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(main_menu_item), gtk_image_new_from_stock(GTK_STOCK_CDROM, GTK_ICON_SIZE_MENU)); |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
201 gtk_widget_show(main_menu_item); |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
202 audacious_menu_plugin_item_add(AUDACIOUS_MENU_MAIN, main_menu_item); |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
203 g_signal_connect(G_OBJECT(main_menu_item), "button_press_event", G_CALLBACK(menu_click), NULL); |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
204 |
1529 | 205 playlist_menu_item = gtk_image_menu_item_new_with_label(menu_item_text); |
1490
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
206 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(playlist_menu_item), gtk_image_new_from_stock(GTK_STOCK_CDROM, GTK_ICON_SIZE_MENU)); |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
207 gtk_widget_show(playlist_menu_item); |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
208 audacious_menu_plugin_item_add(AUDACIOUS_MENU_PLAYLIST, playlist_menu_item); |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
209 g_signal_connect(G_OBJECT(playlist_menu_item), "button_press_event", G_CALLBACK(menu_click), NULL); |
1482
3b2a302fe43f
Register cdda:// with uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
1473
diff
changeset
|
210 |
1997 | 211 aud_uri_set_plugin("cdda://", &inputplugin); |
1048 | 212 } |
213 | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
214 static void cdaudio_about() |
1048 | 215 { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
216 debug("cdaudio_about()\n"); |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
217 |
1377
4eb2bacab83a
Added an information box to cdaudio-ng
Calin Crisan ccrisan@gmail.com
parents:
1349
diff
changeset
|
218 static GtkWidget* about_window = NULL; |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
219 |
2047 | 220 if (about_window) { |
2192
e5401b6c4665
the same thing in many plugins
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2150
diff
changeset
|
221 gtk_window_present(GTK_WINDOW(about_window)); |
e5401b6c4665
the same thing in many plugins
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2150
diff
changeset
|
222 } else { |
e5401b6c4665
the same thing in many plugins
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2150
diff
changeset
|
223 about_window = audacious_info_dialog(_("About CD Audio Plugin NG"), |
e5401b6c4665
the same thing in many plugins
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2150
diff
changeset
|
224 _("Copyright (c) 2007, by Calin Crisan <ccrisan@gmail.com> and The Audacious Team.\n\n" |
e5401b6c4665
the same thing in many plugins
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2150
diff
changeset
|
225 "Many thanks to libcdio developers <http://www.gnu.org/software/libcdio/>\n" |
e5401b6c4665
the same thing in many plugins
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2150
diff
changeset
|
226 "\tand to libcddb developers <http://libcddb.sourceforge.net/>.\n\n" |
e5401b6c4665
the same thing in many plugins
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2150
diff
changeset
|
227 "Also thank you Tony Vroon for mentoring & guiding me.\n\n" |
e5401b6c4665
the same thing in many plugins
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2150
diff
changeset
|
228 "This was a Google Summer of Code 2007 project."), _("OK"), FALSE, NULL, NULL); |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
229 |
2192
e5401b6c4665
the same thing in many plugins
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2150
diff
changeset
|
230 g_signal_connect(G_OBJECT(about_window), "destroy", G_CALLBACK(gtk_widget_destroyed), &about_window); |
e5401b6c4665
the same thing in many plugins
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2150
diff
changeset
|
231 } |
1048 | 232 } |
233 | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
234 static void cdaudio_configure() |
1048 | 235 { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
236 debug("cdaudio_configure()\n"); |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
237 |
1339
83cbc6968a0b
Set DAE the default and non-optional play method; Configuring the plugin no longer stops the playback;
Calin Crisan ccrisan@gmail.com
parents:
1314
diff
changeset
|
238 /* |
1303 | 239 if (playing_track != -1) |
240 playback_stop(); | |
1339
83cbc6968a0b
Set DAE the default and non-optional play method; Configuring the plugin no longer stops the playback;
Calin Crisan ccrisan@gmail.com
parents:
1314
diff
changeset
|
241 */ |
1303 | 242 |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
243 configure_show_gui(); |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
244 |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
245 debug("use_dae = %d, limitspeed = %d, use_cdtext = %d, use_cddb = %d, cddbserver = \"%s\", cddbport = %d, cddbhttp = %d, device = \"%s\", debug = %d\n", |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
246 cdng_cfg.use_dae, cdng_cfg.limitspeed, cdng_cfg.use_cdtext, cdng_cfg.use_cddb, |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
247 cdng_cfg.cddb_server, cdng_cfg.cddb_port, cdng_cfg.cddb_http, cdng_cfg.device, cdng_cfg.debug); |
1048 | 248 } |
249 | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
250 static gint cdaudio_is_our_file(gchar *filename) |
1048 | 251 { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
252 debug("cdaudio_is_our_file(\"%s\")\n", filename); |
1125 | 253 |
1048 | 254 if ((filename != NULL) && strlen(filename) > 4 && (!strcasecmp(filename + strlen(filename) - 4, ".cda"))) { |
2047 | 255 /* no CD information yet */ |
1123 | 256 if (pcdio == NULL) { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
257 debug("no CD information, scanning\n"); |
1125 | 258 cdaudio_scan_dir(CDDA_DEFAULT); |
1048 | 259 } |
1123 | 260 |
2047 | 261 /* reload the cd information if the media has changed */ |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
262 if (cdio_get_media_changed(pcdio) && pcdio != NULL) { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
263 debug("CD changed, rescanning\n"); |
1389
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
264 if (cdaudio_scan_dir(CDDA_DEFAULT) == NULL) |
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
265 pcdio = NULL; |
1048 | 266 } |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
267 |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
268 if (pcdio == NULL) { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
269 debug("\"%s\" is not our file\n", filename); |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
270 return FALSE; |
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
271 } |
1123 | 272 |
2047 | 273 /* check if the requested track actually exists on the current audio cd */ |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
274 gint trackno = find_trackno_from_filename(filename); |
1125 | 275 if (trackno < firsttrackno || trackno > lasttrackno) { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
276 debug("\"%s\" is not our file\n", filename); |
1123 | 277 return FALSE; |
1125 | 278 } |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
279 |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
280 debug("\"%s\" is our file\n", filename); |
1123 | 281 return TRUE; |
1048 | 282 } |
1125 | 283 else { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
284 debug("\"%s\" is not our file\n", filename); |
1123 | 285 return FALSE; |
1125 | 286 } |
1048 | 287 } |
288 | |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
289 |
2046 | 290 static void cdaudio_set_strinfo(trackinfo_t *t, |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
291 const gchar *performer, const gchar *name, const gchar *genre) |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
292 { |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
293 g_strlcpy(t->performer, performer, DEF_STRING_LEN); |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
294 g_strlcpy(t->name, name, DEF_STRING_LEN); |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
295 g_strlcpy(t->genre, genre, DEF_STRING_LEN); |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
296 } |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
297 |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
298 |
2046 | 299 static void cdaudio_set_fullinfo(trackinfo_t *t, |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
300 const lsn_t startlsn, const lsn_t endlsn, |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
301 const gchar *performer, const gchar *name, const gchar *genre) |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
302 { |
2046 | 303 t->startlsn = startlsn; |
304 t->endlsn = endlsn; | |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
305 cdaudio_set_strinfo(t, performer, name, genre); |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
306 } |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
307 |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
308 |
2047 | 309 static GList *cdaudio_scan_dir(gchar *dirname) |
1048 | 310 { |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
311 gint trackno; |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
312 |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
313 debug("cdaudio_scan_dir(\"%s\")\n", dirname); |
1125 | 314 |
2047 | 315 /* if the given dirname does not belong to us, we return NULL */ |
1125 | 316 if (strstr(dirname, CDDA_DEFAULT) == NULL) { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
317 debug("\"%s\" directory does not belong to us\n", dirname); |
1048 | 318 return NULL; |
1125 | 319 } |
1123 | 320 |
2047 | 321 /* find an available, audio capable, cd drive */ |
2046 | 322 if (cdng_cfg.device != NULL && strlen(cdng_cfg.device) > 0) { |
323 pcdio = cdio_open(cdng_cfg.device, DRIVER_UNKNOWN); | |
1282 | 324 if (pcdio == NULL) { |
2046 | 325 cdaudio_error("Failed to open CD device \"%s\".\n", cdng_cfg.device); |
1282 | 326 return NULL; |
327 } | |
328 } | |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
329 else { |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
330 gchar **ppcd_drives = cdio_get_devices_with_cap(NULL, CDIO_FS_AUDIO, false); |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
331 pcdio = NULL; |
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
332 if (ppcd_drives != NULL && *ppcd_drives != NULL) { /* we have at least one audio capable cd drive */ |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
333 pcdio = cdio_open(*ppcd_drives, DRIVER_UNKNOWN); |
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
334 if (pcdio == NULL) { |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
335 cdaudio_error("Failed to open CD.\n"); |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
336 cleanup_on_error(); |
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
337 return NULL; |
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
338 } |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
339 debug("found cd drive \"%s\" with audio capable media\n", *ppcd_drives); |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
340 } |
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
341 else { |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
342 cdaudio_error("Unable to find or access a CDDA capable drive.\n"); |
1123 | 343 cleanup_on_error(); |
344 return NULL; | |
345 } | |
1389
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
346 if (ppcd_drives != NULL && *ppcd_drives != NULL) |
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
347 cdio_free_device_list(ppcd_drives); |
1048 | 348 } |
349 | |
2047 | 350 /* limit read speed */ |
2046 | 351 if (cdng_cfg.limitspeed > 0 && cdng_cfg.use_dae) { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
352 debug("setting drive speed limit to %dx\n", cdng_cfg.limitspeed); |
2046 | 353 if (cdio_set_speed(pcdio, cdng_cfg.limitspeed) != DRIVER_OP_SUCCESS) |
354 cdaudio_error("Failed to set drive speed to %dx.\n", cdng_cfg.limitspeed); | |
1193 | 355 } |
1282 | 356 |
2047 | 357 /* get general track initialization */ |
1194 | 358 cdrom_drive_t *pcdrom_drive = cdio_cddap_identify_cdio(pcdio, 1, NULL); // todo : check return / NULL |
1048 | 359 firsttrackno = cdio_get_first_track_num(pcdrom_drive->p_cdio); |
360 lasttrackno = cdio_get_last_track_num(pcdrom_drive->p_cdio); | |
1123 | 361 if (firsttrackno == CDIO_INVALID_TRACK || lasttrackno == CDIO_INVALID_TRACK) { |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
362 cdaudio_error("Failed to retrieve first/last track number.\n"); |
1123 | 363 cleanup_on_error(); |
364 return NULL; | |
365 } | |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
366 debug("first track is %d and last track is %d\n", firsttrackno, lasttrackno); |
1048 | 367 |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
368 g_free(trackinfo); |
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
369 trackinfo = (trackinfo_t *) g_new(trackinfo_t, (lasttrackno + 1)); |
1282 | 370 |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
371 cdaudio_set_fullinfo(&trackinfo[0], |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
372 cdio_get_track_lsn(pcdrom_drive->p_cdio, 0), |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
373 cdio_get_track_last_lsn(pcdrom_drive->p_cdio, CDIO_CDROM_LEADOUT_TRACK), |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
374 "", "", ""); |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
375 |
1282 | 376 for (trackno = firsttrackno; trackno <= lasttrackno; trackno++) { |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
377 cdaudio_set_fullinfo(&trackinfo[trackno], |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
378 cdio_get_track_lsn(pcdrom_drive->p_cdio, trackno), |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
379 cdio_get_track_last_lsn(pcdrom_drive->p_cdio, trackno), |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
380 "", "", ""); |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
381 |
1282 | 382 if (trackinfo[trackno].startlsn == CDIO_INVALID_LSN || trackinfo[trackno].endlsn == CDIO_INVALID_LSN) { |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
383 cdaudio_error("Failed to retrieve stard/end lsn for track %d.\n", trackno); |
1282 | 384 cleanup_on_error(); |
385 return NULL; | |
386 } | |
387 } | |
388 | |
2047 | 389 /* initialize de cddb subsystem */ |
1282 | 390 cddb_conn_t *pcddb_conn = NULL; |
391 cddb_disc_t *pcddb_disc = NULL; | |
392 cddb_track_t *pcddb_track = NULL; | |
393 | |
2046 | 394 if (cdng_cfg.use_cddb) { |
1282 | 395 pcddb_conn = cddb_new(); |
396 if (pcddb_conn == NULL) | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
397 cdaudio_error("Failed to create the cddb connection.\n"); |
1282 | 398 else { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
399 debug("getting CDDB info\n"); |
1282 | 400 |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
401 if (cdng_cfg.use_proxy) { |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
402 cddb_http_proxy_enable(pcddb_conn); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
403 cddb_set_http_proxy_server_name(pcddb_conn, cdng_cfg.proxy_host); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
404 cddb_set_http_proxy_server_port(pcddb_conn, cdng_cfg.proxy_port); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
405 cddb_set_http_proxy_username(pcddb_conn, cdng_cfg.proxy_username); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
406 cddb_set_http_proxy_password(pcddb_conn, cdng_cfg.proxy_password); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
407 cddb_set_server_name(pcddb_conn, cdng_cfg.cddb_server); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
408 cddb_set_server_port(pcddb_conn, cdng_cfg.cddb_port); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
409 } |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
410 else |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
411 if (cdng_cfg.cddb_http) { |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
412 cddb_http_enable(pcddb_conn); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
413 cddb_set_server_name(pcddb_conn, cdng_cfg.cddb_server); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
414 cddb_set_server_port(pcddb_conn, cdng_cfg.cddb_port); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
415 } |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
416 else { |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
417 cddb_set_server_name(pcddb_conn, cdng_cfg.cddb_server); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
418 cddb_set_server_port(pcddb_conn, cdng_cfg.cddb_port); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
419 } |
1282 | 420 |
421 pcddb_disc = cddb_disc_new(); | |
422 for (trackno = firsttrackno; trackno <= lasttrackno; trackno++) { | |
423 pcddb_track = cddb_track_new(); | |
424 cddb_track_set_frame_offset(pcddb_track, trackinfo[trackno].startlsn); | |
425 cddb_disc_add_track(pcddb_disc, pcddb_track); | |
426 } | |
427 | |
428 msf_t startmsf, endmsf; | |
429 cdio_get_track_msf(pcdio, 1, &startmsf); | |
430 cdio_get_track_msf(pcdio, CDIO_CDROM_LEADOUT_TRACK, &endmsf); | |
431 cddb_disc_set_length(pcddb_disc, cdio_audio_get_msf_seconds(&endmsf) - cdio_audio_get_msf_seconds(&startmsf)); | |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
432 |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
433 cddb_disc_calc_discid(pcddb_disc); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
434 int discid = cddb_disc_get_discid(pcddb_disc); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
435 debug("CDDB disc id = %x\n", discid); |
1282 | 436 |
2042 | 437 gint matches; |
1282 | 438 if ((matches = cddb_query(pcddb_conn, pcddb_disc)) == -1) { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
439 if (cddb_errno(pcddb_conn) == CDDB_ERR_OK) |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
440 cdaudio_error("Failed to query the CDDB server\n"); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
441 else |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
442 cdaudio_error("Failed to query the CDDB server: %s\n", cddb_error_str(cddb_errno(pcddb_conn))); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
443 |
1282 | 444 cddb_disc_destroy(pcddb_disc); |
445 pcddb_disc = NULL; | |
446 } | |
447 else { | |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
448 if (matches == 0) { |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
449 debug("no cddb info available for this disc\n"); |
2150
04421592e6a3
Fixed an unexpected cddb error messaje when no cddb info is available
Calin Crisan ccrisan@gmail.com
parents:
2057
diff
changeset
|
450 |
1282 | 451 cddb_disc_destroy(pcddb_disc); |
452 pcddb_disc = NULL; | |
453 } | |
454 else { | |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
455 debug("CDDB disc category = \"%s\"\n", cddb_disc_get_category_str(pcddb_disc)); |
2150
04421592e6a3
Fixed an unexpected cddb error messaje when no cddb info is available
Calin Crisan ccrisan@gmail.com
parents:
2057
diff
changeset
|
456 |
04421592e6a3
Fixed an unexpected cddb error messaje when no cddb info is available
Calin Crisan ccrisan@gmail.com
parents:
2057
diff
changeset
|
457 cddb_read(pcddb_conn, pcddb_disc); |
04421592e6a3
Fixed an unexpected cddb error messaje when no cddb info is available
Calin Crisan ccrisan@gmail.com
parents:
2057
diff
changeset
|
458 if (cddb_errno(pcddb_conn) != CDDB_ERR_OK) { |
04421592e6a3
Fixed an unexpected cddb error messaje when no cddb info is available
Calin Crisan ccrisan@gmail.com
parents:
2057
diff
changeset
|
459 cdaudio_error("failed to read the cddb info: %s\n", cddb_error_str(cddb_errno(pcddb_conn))); |
04421592e6a3
Fixed an unexpected cddb error messaje when no cddb info is available
Calin Crisan ccrisan@gmail.com
parents:
2057
diff
changeset
|
460 cddb_disc_destroy(pcddb_disc); |
04421592e6a3
Fixed an unexpected cddb error messaje when no cddb info is available
Calin Crisan ccrisan@gmail.com
parents:
2057
diff
changeset
|
461 pcddb_disc = NULL; |
04421592e6a3
Fixed an unexpected cddb error messaje when no cddb info is available
Calin Crisan ccrisan@gmail.com
parents:
2057
diff
changeset
|
462 } |
04421592e6a3
Fixed an unexpected cddb error messaje when no cddb info is available
Calin Crisan ccrisan@gmail.com
parents:
2057
diff
changeset
|
463 else { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
464 debug("we have got the cddb info\n"); |
2150
04421592e6a3
Fixed an unexpected cddb error messaje when no cddb info is available
Calin Crisan ccrisan@gmail.com
parents:
2057
diff
changeset
|
465 cdaudio_set_strinfo(&trackinfo[0], |
04421592e6a3
Fixed an unexpected cddb error messaje when no cddb info is available
Calin Crisan ccrisan@gmail.com
parents:
2057
diff
changeset
|
466 cddb_disc_get_artist(pcddb_disc), |
04421592e6a3
Fixed an unexpected cddb error messaje when no cddb info is available
Calin Crisan ccrisan@gmail.com
parents:
2057
diff
changeset
|
467 cddb_disc_get_title(pcddb_disc), |
04421592e6a3
Fixed an unexpected cddb error messaje when no cddb info is available
Calin Crisan ccrisan@gmail.com
parents:
2057
diff
changeset
|
468 cddb_disc_get_genre(pcddb_disc)); |
04421592e6a3
Fixed an unexpected cddb error messaje when no cddb info is available
Calin Crisan ccrisan@gmail.com
parents:
2057
diff
changeset
|
469 } |
1282 | 470 } |
471 } | |
472 } | |
473 } | |
474 | |
2047 | 475 /* adding trackinfo[0] information (the disc) */ |
2046 | 476 if (cdng_cfg.use_cdtext) { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
477 debug("getting cd-text information for disc\n"); |
1282 | 478 cdtext_t *pcdtext = cdio_get_cdtext(pcdrom_drive->p_cdio, 0); |
479 if (pcdtext == NULL || pcdtext->field[CDTEXT_TITLE] == NULL) { | |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
480 debug("no cd-text available for disc\n"); |
1282 | 481 } |
482 else { | |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
483 cdaudio_set_strinfo(&trackinfo[0], |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
484 pcdtext->field[CDTEXT_PERFORMER] ? pcdtext->field[CDTEXT_PERFORMER] : "", |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
485 pcdtext->field[CDTEXT_TITLE] ? pcdtext->field[CDTEXT_TITLE] : "", |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
486 pcdtext->field[CDTEXT_GENRE] ? pcdtext->field[CDTEXT_GENRE] : ""); |
1282 | 487 } |
488 } | |
489 | |
2047 | 490 /* add track "file" names to the list */ |
1282 | 491 GList *list = NULL; |
1048 | 492 for (trackno = firsttrackno; trackno <= lasttrackno; trackno++) { |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
493 list = g_list_append(list, g_strdup_printf("track%02u.cda", trackno)); |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
494 cdtext_t *pcdtext = NULL; |
2046 | 495 if (cdng_cfg.use_cdtext) { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
496 debug("getting cd-text information for track %d\n", trackno); |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
497 pcdtext = cdio_get_cdtext(pcdrom_drive->p_cdio, trackno); |
1282 | 498 if (pcdtext == NULL || pcdtext->field[CDTEXT_PERFORMER] == NULL) { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
499 debug("no cd-text available for track %d\n", trackno); |
1282 | 500 pcdtext = NULL; |
501 } | |
502 } | |
1048 | 503 |
504 if (pcdtext != NULL) { | |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
505 cdaudio_set_strinfo(&trackinfo[trackno], |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
506 pcdtext->field[CDTEXT_PERFORMER] ? pcdtext->field[CDTEXT_PERFORMER] : "", |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
507 pcdtext->field[CDTEXT_TITLE] ? pcdtext->field[CDTEXT_TITLE] : "", |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
508 pcdtext->field[CDTEXT_GENRE] ? pcdtext->field[CDTEXT_GENRE] : ""); |
1048 | 509 } |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
510 else |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
511 if (pcddb_disc != NULL) { |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
512 cddb_track_t *pcddb_track = cddb_disc_get_track(pcddb_disc, trackno - 1); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
513 cdaudio_set_strinfo(&trackinfo[trackno], |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
514 cddb_track_get_artist(pcddb_track), |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
515 cddb_track_get_title(pcddb_track), |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
516 cddb_disc_get_genre(pcddb_disc)); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
517 } |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
518 else { |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
519 cdaudio_set_strinfo(&trackinfo[trackno], "", "", ""); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
520 g_snprintf(trackinfo[trackno].name, DEF_STRING_LEN, "CD Audio Track %02u", trackno); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
521 } |
1282 | 522 } |
523 | |
2046 | 524 if (cdng_cfg.debug) { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
525 debug("disc has : performer = \"%s\", name = \"%s\", genre = \"%s\"\n", |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
526 trackinfo[0].performer, trackinfo[0].name, trackinfo[0].genre); |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
527 |
1282 | 528 for (trackno = firsttrackno; trackno <= lasttrackno; trackno++) { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
529 debug("track %d has : performer = \"%s\", name = \"%s\", genre = \"%s\", startlsn = %d, endlsn = %d\n", |
1282 | 530 trackno, trackinfo[trackno].performer, trackinfo[trackno].name, trackinfo[trackno].genre, trackinfo[trackno].startlsn, trackinfo[trackno].endlsn); |
1123 | 531 } |
1282 | 532 } |
1125 | 533 |
1282 | 534 if (pcddb_disc != NULL) |
535 cddb_disc_destroy(pcddb_disc); | |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
536 |
1282 | 537 if (pcddb_conn != NULL) |
538 cddb_destroy(pcddb_conn); | |
1048 | 539 |
540 return list; | |
541 } | |
542 | |
2047 | 543 static void cdaudio_play_file(InputPlayback *pinputplayback) |
1125 | 544 { |
1466 | 545 Tuple *tuple; |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
546 gchar *title; |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
547 |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
548 debug("cdaudio_play_file(\"%s\")\n", pinputplayback->filename); |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
549 |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
550 pglobalinputplayback = pinputplayback; |
1125 | 551 |
1048 | 552 if (trackinfo == NULL) { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
553 debug("no CD information, scanning\n"); |
1125 | 554 cdaudio_scan_dir(CDDA_DEFAULT); |
1048 | 555 } |
556 | |
1123 | 557 if (cdio_get_media_changed(pcdio)) { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
558 debug("CD changed, rescanning\n"); |
1125 | 559 cdaudio_scan_dir(CDDA_DEFAULT); |
1048 | 560 } |
1123 | 561 |
1389
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
562 if (trackinfo == NULL) { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
563 debug("no CD information can be retrieved, aborting\n"); |
1389
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
564 pinputplayback->playing = FALSE; |
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
565 return; |
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
566 } |
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
567 |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
568 gint trackno = find_trackno_from_filename(pinputplayback->filename); |
1123 | 569 if (trackno < firsttrackno || trackno > lasttrackno) { |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
570 cdaudio_error("Track #%d is out of range [%d..%d]\n", trackno, firsttrackno, lasttrackno); |
1123 | 571 cleanup_on_error(); |
1048 | 572 return; |
1123 | 573 } |
1048 | 574 |
575 pinputplayback->playing = TRUE; | |
576 playing_track = trackno; | |
1123 | 577 is_paused = FALSE; |
578 | |
2047 | 579 tuple = create_tuple_from_trackinfo(pinputplayback->filename); |
2055 | 580 title = aud_tuple_formatter_make_title_string(tuple, aud_get_gentitle_format()); |
1387
20c6caad7e03
Fixed the play/stop indication; added a temporary workaround for including the last 3 seconds in playback
Calin Crisan ccrisan@gmail.com
parents:
1382
diff
changeset
|
581 |
1984
489e32a8e106
change some places to use set_params() instead of set_info() directly
William Pitcock <nenolod@atheme.org>
parents:
1976
diff
changeset
|
582 pinputplayback->set_params(pinputplayback, title, calculate_track_length(trackinfo[trackno].startlsn, trackinfo[trackno].endlsn), 1411200, 44100, 2); |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
583 g_free(title); |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
584 aud_tuple_free(tuple); |
1387
20c6caad7e03
Fixed the play/stop indication; added a temporary workaround for including the last 3 seconds in playback
Calin Crisan ccrisan@gmail.com
parents:
1382
diff
changeset
|
585 |
2046 | 586 if (cdng_cfg.use_dae) { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
587 debug("using digital audio extraction\n"); |
1125 | 588 |
1123 | 589 if (pdae_params != NULL) { |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
590 cdaudio_error("DAE playback seems to be already started.\n"); |
1123 | 591 return; |
592 } | |
593 | |
594 if (pinputplayback->output->open_audio(FMT_S16_LE, 44100, 2) == 0) { | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
595 cdaudio_error("Failed to open audio output.\n"); |
1123 | 596 cleanup_on_error(); |
597 return; | |
598 } | |
599 | |
1349
ab387ad5b88e
Converted to new threading model
Calin Crisan ccrisan@gmail.com
parents:
1341
diff
changeset
|
600 /* |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
601 debug("starting dae thread...\n"); |
1349
ab387ad5b88e
Converted to new threading model
Calin Crisan ccrisan@gmail.com
parents:
1341
diff
changeset
|
602 */ |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
603 pdae_params = (dae_params_t *) g_new(dae_params_t, 1); |
1123 | 604 pdae_params->startlsn = trackinfo[trackno].startlsn; |
605 pdae_params->endlsn = trackinfo[trackno].endlsn; | |
606 pdae_params->pplayback = pinputplayback; | |
607 pdae_params->seektime = -1; | |
608 pdae_params->currlsn = trackinfo[trackno].startlsn; | |
1349
ab387ad5b88e
Converted to new threading model
Calin Crisan ccrisan@gmail.com
parents:
1341
diff
changeset
|
609 pdae_params->thread = g_thread_self(); |
1447
195b5657303e
updated input plugins to use set_pb_ready to signal to the core that they're ready for playback
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
610 pinputplayback->set_pb_ready(pinputplayback); |
1349
ab387ad5b88e
Converted to new threading model
Calin Crisan ccrisan@gmail.com
parents:
1341
diff
changeset
|
611 dae_play_loop(pdae_params); |
1123 | 612 } |
613 else { | |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
614 debug("not using digital audio extraction\n"); |
1125 | 615 |
1123 | 616 msf_t startmsf, endmsf; |
617 cdio_lsn_to_msf(trackinfo[trackno].startlsn, &startmsf); | |
618 cdio_lsn_to_msf(trackinfo[trackno].endlsn, &endmsf); | |
619 if (cdio_audio_play_msf(pcdio, &startmsf, &endmsf) != DRIVER_OP_SUCCESS) { | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
620 cdaudio_error("Failed to play analog audio CD.\n"); |
1123 | 621 cleanup_on_error(); |
622 return; | |
623 } | |
624 } | |
1048 | 625 } |
626 | |
2047 | 627 static void cdaudio_stop(InputPlayback *pinputplayback) |
1125 | 628 { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
629 debug("cdaudio_stop(\"%s\")\n", pinputplayback != NULL ? pinputplayback->filename : "N/A"); |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
630 |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
631 pglobalinputplayback = NULL; |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
632 |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
633 if (playing_track == -1) |
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
634 return; |
1125 | 635 |
1303 | 636 if (pinputplayback != NULL) |
637 pinputplayback->playing = FALSE; | |
1048 | 638 playing_track = -1; |
1123 | 639 is_paused = FALSE; |
640 | |
2046 | 641 if (cdng_cfg.use_dae) { |
1123 | 642 if (pdae_params != NULL) { |
643 g_thread_join(pdae_params->thread); | |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
644 g_free(pdae_params); |
1123 | 645 pdae_params = NULL; |
646 } | |
647 } | |
648 else { | |
649 if (cdio_audio_stop(pcdio) != DRIVER_OP_SUCCESS) { | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
650 cdaudio_error("Failed to stop analog CD.\n"); |
1123 | 651 return; |
652 } | |
653 } | |
1048 | 654 } |
655 | |
2047 | 656 static void cdaudio_pause(InputPlayback *pinputplayback, gshort paused) |
1048 | 657 { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
658 debug("cdaudio_pause(\"%s\", %d)\n", pinputplayback->filename, paused); |
1125 | 659 |
1048 | 660 if (!is_paused) { |
661 is_paused = TRUE; | |
2046 | 662 if (!cdng_cfg.use_dae) |
1123 | 663 if (cdio_audio_pause(pcdio) != DRIVER_OP_SUCCESS) { |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
664 cdaudio_error("Failed to pause analog CD!\n"); |
1123 | 665 cleanup_on_error(); |
666 return; | |
667 } | |
1048 | 668 } |
669 else { | |
670 is_paused = FALSE; | |
2046 | 671 if (!cdng_cfg.use_dae) |
1123 | 672 if (cdio_audio_resume(pcdio) != DRIVER_OP_SUCCESS) { |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
673 cdaudio_error("Failed to resume analog CD!\n"); |
1123 | 674 cleanup_on_error(); |
675 return; | |
676 } | |
1048 | 677 } |
678 } | |
679 | |
2047 | 680 static void cdaudio_seek(InputPlayback *pinputplayback, gint time) |
1048 | 681 { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
682 debug("cdaudio_seek(\"%s\", %d)\n", pinputplayback->filename, time); |
1125 | 683 |
1048 | 684 if (playing_track == -1) |
685 return; | |
686 | |
2046 | 687 if (cdng_cfg.use_dae) { |
1123 | 688 if (pdae_params != NULL) { |
689 pdae_params->seektime = time * 1000; | |
690 } | |
691 } | |
692 else { | |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
693 gint newstartlsn = trackinfo[playing_track].startlsn + time * 75; |
1123 | 694 msf_t startmsf, endmsf; |
695 cdio_lsn_to_msf(newstartlsn, &startmsf); | |
696 cdio_lsn_to_msf(trackinfo[playing_track].endlsn, &endmsf); | |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
697 |
1123 | 698 if (cdio_audio_play_msf(pcdio, &startmsf, &endmsf) != DRIVER_OP_SUCCESS) { |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
699 cdaudio_error("Failed to play analog CD\n"); |
1123 | 700 cleanup_on_error(); |
701 return; | |
702 } | |
703 } | |
1048 | 704 } |
705 | |
2047 | 706 static gint cdaudio_get_time(InputPlayback *pinputplayback) |
1048 | 707 { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
708 //debug("cdaudio_get_time(\"%s\")\n", pinputplayback->filename); // annoying! |
1125 | 709 |
1048 | 710 if (playing_track == -1) |
711 return -1; | |
712 | |
2046 | 713 if (!cdng_cfg.use_dae) { |
1123 | 714 cdio_subchannel_t subchannel; |
715 if (cdio_audio_read_subchannel(pcdio, &subchannel) != DRIVER_OP_SUCCESS) { | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
716 cdaudio_error("Failed to read analog CD subchannel.\n"); |
1123 | 717 cleanup_on_error(); |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
718 return 0; |
1123 | 719 } |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
720 gint currlsn = cdio_msf_to_lsn(&subchannel.abs_addr); |
1048 | 721 |
2047 | 722 /* check to see if we have reached the end of the song */ |
1314
b93270e2b7e4
Continuous playing in DAE mode works again
Calin Crisan ccrisan@gmail.com
parents:
1313
diff
changeset
|
723 if (currlsn == trackinfo[playing_track].endlsn) |
1123 | 724 return -1; |
725 | |
726 return calculate_track_length(trackinfo[playing_track].startlsn, currlsn); | |
1048 | 727 } |
1123 | 728 else { |
729 if (pdae_params != NULL) | |
1314
b93270e2b7e4
Continuous playing in DAE mode works again
Calin Crisan ccrisan@gmail.com
parents:
1313
diff
changeset
|
730 if (pdae_params->pplayback->playing) |
b93270e2b7e4
Continuous playing in DAE mode works again
Calin Crisan ccrisan@gmail.com
parents:
1313
diff
changeset
|
731 return pinputplayback->output->output_time(); |
b93270e2b7e4
Continuous playing in DAE mode works again
Calin Crisan ccrisan@gmail.com
parents:
1313
diff
changeset
|
732 else |
b93270e2b7e4
Continuous playing in DAE mode works again
Calin Crisan ccrisan@gmail.com
parents:
1313
diff
changeset
|
733 return -1; |
1123 | 734 else |
735 return -1; | |
736 } | |
1048 | 737 } |
738 | |
2047 | 739 static gint cdaudio_get_volume(gint *l, gint *r) |
1048 | 740 { |
1125 | 741 //printf("cdaudio-ng: cdaudio_get_volume()\n"); // annoying! |
742 | |
2046 | 743 if (cdng_cfg.use_dae) { |
1123 | 744 *l = *r = 0; |
745 return FALSE; | |
746 } | |
747 else { | |
748 cdio_audio_volume_t volume; | |
749 if (cdio_audio_get_volume(pcdio, &volume) != DRIVER_OP_SUCCESS) { | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
750 cdaudio_error("Failed to retrieve analog CD volume.\n"); |
1123 | 751 cleanup_on_error(); |
752 *l = *r = 0; | |
753 return FALSE; | |
754 } | |
755 *l = volume.level[0]; | |
756 *r = volume.level[1]; | |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
757 |
1123 | 758 return TRUE; |
759 } | |
1048 | 760 } |
761 | |
2047 | 762 static gint cdaudio_set_volume(gint l, gint r) |
1048 | 763 { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
764 debug("cdaudio_set_volume(%d, %d)\n", l, r); |
1125 | 765 |
2046 | 766 if (cdng_cfg.use_dae) { |
1123 | 767 return FALSE; |
768 } | |
769 else { | |
770 cdio_audio_volume_t volume = {{l, r, 0, 0}}; | |
771 if (cdio_audio_set_volume(pcdio, &volume) != DRIVER_OP_SUCCESS) { | |
2150
04421592e6a3
Fixed an unexpected cddb error messaje when no cddb info is available
Calin Crisan ccrisan@gmail.com
parents:
2057
diff
changeset
|
772 cdaudio_error("cdaudio-ng: failed to set analog cd volume\n"); |
1123 | 773 cleanup_on_error(); |
774 return FALSE; | |
775 } | |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
776 |
1123 | 777 return TRUE; |
778 } | |
1048 | 779 } |
780 | |
2047 | 781 static void cdaudio_cleanup(void) |
1048 | 782 { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
783 debug("cdaudio_cleanup()\n"); |
1125 | 784 |
1282 | 785 libcddb_shutdown(); |
786 | |
2046 | 787 if (pcdio != NULL) { |
788 if (playing_track != -1 && !cdng_cfg.use_dae) | |
1123 | 789 cdio_audio_stop(pcdio); |
790 cdio_destroy(pcdio); | |
791 pcdio = NULL; | |
792 } | |
793 if (trackinfo != NULL) { | |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
794 g_free(trackinfo); |
1123 | 795 trackinfo = NULL; |
796 } | |
797 playing_track = -1; | |
1282 | 798 |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
799 // todo: destroy the gui |
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
800 |
2044 | 801 ConfigDb *db = aud_cfg_db_open(); |
2046 | 802 /*aud_cfg_db_set_bool(db, "CDDA", "use_dae", cdng_cfg.use_dae);*/ |
803 aud_cfg_db_set_int(db, "CDDA", "limitspeed", cdng_cfg.limitspeed); | |
804 aud_cfg_db_set_bool(db, "CDDA", "use_cdtext", cdng_cfg.use_cdtext); | |
805 aud_cfg_db_set_bool(db, "CDDA", "use_cddb", cdng_cfg.use_cddb); | |
806 aud_cfg_db_set_string(db, "CDDA", "cddbserver", cdng_cfg.cddb_server); | |
807 aud_cfg_db_set_int(db, "CDDA", "cddbport", cdng_cfg.cddb_port); | |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
808 aud_cfg_db_set_bool(db, "CDDA", "cddbhttp", cdng_cfg.cddb_http); |
2046 | 809 aud_cfg_db_set_string(db, "CDDA", "device", cdng_cfg.device); |
810 aud_cfg_db_set_bool(db, "CDDA", "debug", cdng_cfg.debug); | |
2044 | 811 aud_cfg_db_close(db); |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
812 |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
813 audacious_menu_plugin_item_remove(AUDACIOUS_MENU_MAIN, main_menu_item); |
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
814 audacious_menu_plugin_item_remove(AUDACIOUS_MENU_PLAYLIST, playlist_menu_item); |
1048 | 815 } |
816 | |
2047 | 817 static void cdaudio_get_song_info(gchar *filename, gchar **title, gint *length) |
1048 | 818 { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
819 debug("cdaudio_get_song_info(\"%s\")\n", filename); |
1125 | 820 |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
821 gint trackno = find_trackno_from_filename(filename); |
2047 | 822 Tuple *tuple = create_tuple_from_trackinfo(filename); |
1125 | 823 |
2046 | 824 if (tuple) { |
2055 | 825 *title = aud_tuple_formatter_process_string(tuple, aud_get_gentitle_format()); |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
826 aud_tuple_free(tuple); |
1466 | 827 tuple = NULL; |
828 } | |
1125 | 829 *length = calculate_track_length(trackinfo[trackno].startlsn, trackinfo[trackno].endlsn); |
1048 | 830 } |
831 | |
2047 | 832 static Tuple *cdaudio_get_song_tuple(gchar *filename) |
1048 | 833 { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
834 debug("cdaudio_get_song_tuple(\"%s\")\n", filename); |
1125 | 835 |
2047 | 836 return create_tuple_from_trackinfo(filename); |
1341
4ca99d2be90e
Titles are now built using tuples, with the preferred format
Calin Crisan ccrisan@gmail.com
parents:
1340
diff
changeset
|
837 } |
4ca99d2be90e
Titles are now built using tuples, with the preferred format
Calin Crisan ccrisan@gmail.com
parents:
1340
diff
changeset
|
838 |
4ca99d2be90e
Titles are now built using tuples, with the preferred format
Calin Crisan ccrisan@gmail.com
parents:
1340
diff
changeset
|
839 |
2047 | 840 /* |
841 * auxiliar functions | |
842 */ | |
843 static void menu_click() | |
1490
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
844 { |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
845 GList *list, *node; |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
846 gchar *filename; |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
847 |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
848 if (!(list = cdaudio_scan_dir(CDDA_DEFAULT))) { |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
849 const gchar *markup = |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
850 N_("<b><big>No playable CD found.</big></b>\n\n" |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
851 "No CD inserted, or inserted CD is not an audio CD.\n"); |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
852 |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
853 GtkWidget *dialog = |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
854 gtk_message_dialog_new_with_markup(NULL, |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
855 GTK_DIALOG_DESTROY_WITH_PARENT, |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
856 GTK_MESSAGE_ERROR, |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
857 GTK_BUTTONS_OK, |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
858 _(markup)); |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
859 gtk_dialog_run(GTK_DIALOG(dialog)); |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
860 gtk_widget_destroy(dialog); |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
861 return; |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
862 } |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
863 |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
864 for (node = list; node; node = g_list_next(node)) { |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
865 filename = g_build_filename(CDDA_DEFAULT, node->data, NULL); |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2055
diff
changeset
|
866 aud_playlist_add(aud_playlist_get_active(), filename); |
1490
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
867 g_free(filename); |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
868 g_free(node->data); |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
869 } |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
870 |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
871 g_list_free(list); |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
872 } |
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
diff
changeset
|
873 |
2047 | 874 static Tuple *create_tuple_from_trackinfo(gchar *filename) |
1341
4ca99d2be90e
Titles are now built using tuples, with the preferred format
Calin Crisan ccrisan@gmail.com
parents:
1340
diff
changeset
|
875 { |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
876 Tuple *tuple = aud_tuple_new_from_filename(filename); |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
877 |
1389
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
878 if (trackinfo == NULL) |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
879 return tuple; |
1389
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
880 |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
881 gint trackno = find_trackno_from_filename(filename); |
1341
4ca99d2be90e
Titles are now built using tuples, with the preferred format
Calin Crisan ccrisan@gmail.com
parents:
1340
diff
changeset
|
882 |
1048 | 883 if (trackno < firsttrackno || trackno > lasttrackno) |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
884 return tuple; |
1048 | 885 |
1466 | 886 if(strlen(trackinfo[trackno].performer)) { |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
887 aud_tuple_associate_string(tuple, FIELD_ARTIST, NULL, trackinfo[trackno].performer); |
1466 | 888 } |
889 if(strlen(trackinfo[0].name)) { | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
890 aud_tuple_associate_string(tuple, FIELD_ALBUM, NULL, trackinfo[0].name); |
1466 | 891 } |
892 if(strlen(trackinfo[trackno].name)) { | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
893 aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, trackinfo[trackno].name); |
1466 | 894 } |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
895 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
896 aud_tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, trackno); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
897 aud_tuple_associate_string(tuple, -1, "ext", "cda"); //XXX should do? --yaz |
1466 | 898 |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
899 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
900 calculate_track_length(trackinfo[trackno].startlsn, trackinfo[trackno].endlsn)); |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
901 |
1466 | 902 if(strlen(trackinfo[trackno].genre)) { |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
903 aud_tuple_associate_string(tuple, FIELD_GENRE, NULL, trackinfo[trackno].genre); |
1466 | 904 } |
1048 | 905 //tuple->year = 0; todo: set the year |
906 | |
907 return tuple; | |
908 } | |
909 | |
2047 | 910 static void dae_play_loop(dae_params_t *pdae_params) |
1123 | 911 { |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
912 guchar *buffer = g_new(guchar, CDDA_DAE_FRAMES * CDIO_CD_FRAMESIZE_RAW); |
1123 | 913 |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
914 debug("dae started\n"); |
1123 | 915 cdio_lseek(pcdio, pdae_params->startlsn * CDIO_CD_FRAMESIZE_RAW, SEEK_SET); |
916 | |
917 gboolean output_paused = FALSE; | |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
918 gint read_error_counter = 0; |
1125 | 919 |
1387
20c6caad7e03
Fixed the play/stop indication; added a temporary workaround for including the last 3 seconds in playback
Calin Crisan ccrisan@gmail.com
parents:
1382
diff
changeset
|
920 //pdae_params->endlsn += 75 * 3; |
20c6caad7e03
Fixed the play/stop indication; added a temporary workaround for including the last 3 seconds in playback
Calin Crisan ccrisan@gmail.com
parents:
1382
diff
changeset
|
921 |
1123 | 922 while (pdae_params->pplayback->playing) { |
2047 | 923 /* handle pause status */ |
1123 | 924 if (is_paused) { |
925 if (!output_paused) { | |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
926 debug("playback was not paused, pausing\n"); |
1123 | 927 pdae_params->pplayback->output->pause(TRUE); |
928 output_paused = TRUE; | |
929 } | |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
930 g_usleep(1000); |
1123 | 931 continue; |
932 } | |
1125 | 933 else { |
1123 | 934 if (output_paused) { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
935 debug("playback was paused, resuming\n"); |
1123 | 936 pdae_params->pplayback->output->pause(FALSE); |
937 output_paused = FALSE; | |
938 } | |
1125 | 939 } |
1123 | 940 |
2047 | 941 /* check if we have to seek */ |
1123 | 942 if (pdae_params->seektime != -1) { |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
943 debug("requested seek to %d ms\n", pdae_params->seektime); |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
944 gint newlsn = pdae_params->startlsn + ((pdae_params->seektime * 75) / 1000); |
1123 | 945 cdio_lseek(pcdio, newlsn * CDIO_CD_FRAMESIZE_RAW, SEEK_SET); |
946 pdae_params->pplayback->output->flush(pdae_params->seektime); | |
947 pdae_params->currlsn = newlsn; | |
948 pdae_params->seektime = -1; | |
949 } | |
950 | |
2047 | 951 /* compute the actual number of sectors to read */ |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
952 gint lsncount = CDDA_DAE_FRAMES <= (pdae_params->endlsn - pdae_params->currlsn + 1) ? CDDA_DAE_FRAMES : (pdae_params->endlsn - pdae_params->currlsn + 1); |
2047 | 953 |
954 /* check too see if we have reached the end of the song */ | |
1387
20c6caad7e03
Fixed the play/stop indication; added a temporary workaround for including the last 3 seconds in playback
Calin Crisan ccrisan@gmail.com
parents:
1382
diff
changeset
|
955 if (lsncount <= 0) { |
20c6caad7e03
Fixed the play/stop indication; added a temporary workaround for including the last 3 seconds in playback
Calin Crisan ccrisan@gmail.com
parents:
1382
diff
changeset
|
956 sleep(3); |
1123 | 957 break; |
1387
20c6caad7e03
Fixed the play/stop indication; added a temporary workaround for including the last 3 seconds in playback
Calin Crisan ccrisan@gmail.com
parents:
1382
diff
changeset
|
958 } |
1123 | 959 |
960 if (cdio_read_audio_sectors(pcdio, buffer, pdae_params->currlsn, lsncount) != DRIVER_OP_SUCCESS) { | |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
961 debug("failed to read audio sector\n"); |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
962 read_error_counter++; |
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
963 if (read_error_counter >= 2) { |
1387
20c6caad7e03
Fixed the play/stop indication; added a temporary workaround for including the last 3 seconds in playback
Calin Crisan ccrisan@gmail.com
parents:
1382
diff
changeset
|
964 read_error_counter = 0; |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
965 cdaudio_error("This CD can no longer be played, stopping.\n"); |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
966 break; |
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
967 } |
1123 | 968 } |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
969 else |
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
970 read_error_counter = 0; |
1123 | 971 |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
972 gint remainingbytes = lsncount * CDIO_CD_FRAMESIZE_RAW; |
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
973 guchar *bytebuff = buffer; |
1123 | 974 while (pdae_params->pplayback->playing && remainingbytes > 0 && pdae_params->seektime == -1) { |
2047 | 975 /* compute the actual number of bytes to play */ |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
976 gint bytecount = CDIO_CD_FRAMESIZE_RAW <= remainingbytes ? CDIO_CD_FRAMESIZE_RAW : remainingbytes; |
2047 | 977 |
978 /* wait until the output buffer has enough room */ | |
1123 | 979 while (pdae_params->pplayback->playing && pdae_params->pplayback->output->buffer_free() < bytecount && pdae_params->seektime == -1) |
2041 | 980 g_usleep(1000); |
2047 | 981 |
982 /* play the sound :) */ | |
1123 | 983 if (pdae_params->pplayback->playing && pdae_params->seektime == -1) |
1998
8f3188746b64
chase last changeset in aud
William Pitcock <nenolod@atheme.org>
parents:
1997
diff
changeset
|
984 pdae_params->pplayback->pass_audio(pdae_params->pplayback, FMT_S16_LE, 2, |
8f3188746b64
chase last changeset in aud
William Pitcock <nenolod@atheme.org>
parents:
1997
diff
changeset
|
985 bytecount, bytebuff, &pdae_params->pplayback->playing); |
1123 | 986 remainingbytes -= bytecount; |
987 bytebuff += bytecount; | |
988 } | |
989 pdae_params->currlsn += lsncount; | |
990 } | |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
991 debug("dae ended\n"); |
1123 | 992 |
993 pdae_params->pplayback->playing = FALSE; | |
1314
b93270e2b7e4
Continuous playing in DAE mode works again
Calin Crisan ccrisan@gmail.com
parents:
1313
diff
changeset
|
994 pdae_params->pplayback->output->close_audio(); |
1123 | 995 is_paused = FALSE; |
996 | |
997 pdae_params->pplayback->output->close_audio(); | |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
998 g_free(buffer); |
1123 | 999 } |
1000 | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
1001 static gint calculate_track_length(gint startlsn, gint endlsn) |
1048 | 1002 { |
1003 return ((endlsn - startlsn + 1) * 1000) / 75; | |
1004 } | |
1005 | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
1006 static gint find_trackno_from_filename(gchar *filename) |
1048 | 1007 { |
2040
997c71881e5b
No need for that long buffer.
Matti Hamalainen <ccr@tnsp.org>
parents:
2038
diff
changeset
|
1008 gchar tracknostr[3]; |
1048 | 1009 if ((filename == NULL) || strlen(filename) <= 6) |
1010 return -1; | |
1011 | |
1012 strncpy(tracknostr, filename + strlen(filename) - 6, 2); | |
1013 tracknostr[2] = '\0'; | |
1014 return strtol(tracknostr, NULL, 10); | |
1015 } | |
1123 | 1016 |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
1017 static void cleanup_on_error() |
1123 | 1018 { |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
1019 if (playing_track != -1) { |
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
1020 playing_track = -1; |
1123 | 1021 } |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
1022 |
1123 | 1023 if (trackinfo != NULL) { |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
1024 g_free(trackinfo); |
1123 | 1025 trackinfo = NULL; |
1026 } | |
1027 } | |
1193 | 1028 |