Mercurial > audlegacy-plugins
annotate src/cdaudio-ng/cdaudio-ng.c @ 2433:60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
author | Calin Crisan ccrisan@gmail.com |
---|---|
date | Fri, 07 Mar 2008 18:45:36 +0200 |
parents | 944a510f5200 |
children | 32d4d5f7020b |
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> |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
5 * |
1508
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 |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
20 #include "config.h" |
1048 | 21 |
22 #include <string.h> | |
23 #include <stdlib.h> | |
24 #include <unistd.h> | |
25 #include <errno.h> | |
26 #include <libgen.h> | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
27 #include <stdarg.h> |
1048 | 28 |
29 #include <cdio/cdio.h> | |
30 #include <cdio/cdtext.h> | |
31 #include <cdio/track.h> | |
32 #include <cdio/cdda.h> | |
33 #include <cdio/audio.h> | |
34 #include <cdio/sector.h> | |
35 #include <cdio/cd_types.h> | |
1282 | 36 #include <cddb/cddb.h> |
1048 | 37 |
38 #include <glib.h> | |
39 | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
40 #include <audacious/plugin.h> |
1048 | 41 #include <audacious/i18n.h> |
1529 | 42 #include <audacious/output.h> |
43 #include <audacious/playlist.h> | |
44 #include <audacious/ui_plugin_menu.h> | |
1048 | 45 #include <audacious/util.h> |
46 | |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
47 #include "cdaudio-ng.h" |
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
48 #include "configure.h" |
1123 | 49 |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
50 |
2384
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
51 cdng_cfg_t cdng_cfg; |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
52 static gint firsttrackno = -1; |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
53 static gint lasttrackno = -1; |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
54 static CdIo_t *pcdio = NULL; |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
55 static trackinfo_t *trackinfo = NULL; |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
56 static gboolean is_paused = FALSE; |
2384
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
57 static gint playing_track = -1; |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
58 static dae_params_t *pdae_params = NULL; |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
59 static InputPlayback *pglobalinputplayback = NULL; |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
60 static GtkWidget *main_menu_item, *playlist_menu_item; |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
61 static GThread *scan_cd_thread = NULL; |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
62 static int first_trackno_to_add_after_scan = -1; |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
63 static int last_trackno_to_add_after_scan = -1; |
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); | |
69 static void cdaudio_play_file(InputPlayback *pinputplayback); | |
70 static void cdaudio_stop(InputPlayback *pinputplayback); | |
71 static void cdaudio_pause(InputPlayback *pinputplayback, gshort paused); | |
72 static void cdaudio_seek(InputPlayback *pinputplayback, gint time); | |
73 static gint cdaudio_get_time(InputPlayback *pinputplayback); | |
74 static gint cdaudio_get_volume(gint *l, gint *r); | |
75 static gint cdaudio_set_volume(gint l, gint r); | |
76 static void cdaudio_cleanup(void); | |
77 static void cdaudio_get_song_info(gchar *filename, gchar **title, gint *length); | |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
78 static Tuple *cdaudio_get_song_tuple(gchar *filename); |
1048 | 79 |
2047 | 80 static void menu_click(void); |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
81 static Tuple *create_tuple_from_trackinfo_and_filename(gchar *filename); |
2047 | 82 static void dae_play_loop(dae_params_t *pdae_params); |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
83 static void *scan_cd(void *nothing); |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
84 static void scan_cd_threaded(int firsttrackno, int lasttrackno); |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
85 static void append_track_to_playlist(int trackno); |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
86 static gboolean show_noaudiocd_info(gpointer data); |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
87 static void show_noaudiocd_info_safe(); |
2047 | 88 static gint calculate_track_length(gint startlsn, gint endlsn); |
89 static gint find_trackno_from_filename(gchar *filename); | |
90 static void cleanup_on_error(void); | |
1048 | 91 |
92 | |
93 static InputPlugin inputplugin = { | |
1624
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
94 .description = "CD Audio Plugin NG", |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
95 .init = cdaudio_init, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
96 .about = cdaudio_about, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
97 .configure = cdaudio_configure, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
98 .is_our_file = cdaudio_is_our_file, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
99 .play_file = cdaudio_play_file, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
100 .stop = cdaudio_stop, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
101 .pause = cdaudio_pause, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
102 .seek = cdaudio_seek, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
103 .get_time = cdaudio_get_time, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
104 .get_volume = cdaudio_get_volume, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
105 .set_volume = cdaudio_set_volume, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
106 .cleanup = cdaudio_cleanup, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
107 .get_song_info = cdaudio_get_song_info, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
108 .get_song_tuple = cdaudio_get_song_tuple |
1048 | 109 }; |
110 | |
1098
334afe46961c
[svn] - cdaudio-ng (aka Zither's CD Audio Plugin): convert to plugin API v2
nenolod
parents:
1048
diff
changeset
|
111 InputPlugin *cdaudio_iplist[] = { &inputplugin, NULL }; |
1048 | 112 |
1395
761e17b23e0c
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
1389
diff
changeset
|
113 DECLARE_PLUGIN(cdaudio, NULL, NULL, cdaudio_iplist, NULL, NULL, NULL, NULL, NULL); |
1048 | 114 |
1123 | 115 |
2047 | 116 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
|
117 { |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
118 va_list ap; |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
119 fprintf(stderr, "cdaudio-ng: "); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
120 va_start(ap, fmt); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
121 vfprintf(stderr, fmt, ap); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
122 va_end(ap); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
123 } |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
124 |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
125 |
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
|
126 static void debug(const char *fmt, ...) |
1048 | 127 { |
2046 | 128 if (cdng_cfg.debug) { |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
129 va_list ap; |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
130 fprintf(stderr, "cdaudio-ng: "); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
131 va_start(ap, fmt); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
132 vfprintf(stderr, fmt, ap); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
133 va_end(ap); |
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 } |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
136 |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
137 |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
138 static void cdaudio_init() |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
139 { |
2037 | 140 ConfigDb *db; |
141 gchar *menu_item_text; | |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
142 |
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
|
143 debug("cdaudio_init()\n"); |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
144 |
2384
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
145 cdng_cfg.use_dae = TRUE; |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
146 cdng_cfg.use_cdtext = TRUE; |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
147 cdng_cfg.use_cddb = TRUE; |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
148 cdng_cfg.debug = FALSE; |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
149 cdng_cfg.device = g_strdup(""); |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
150 cdng_cfg.cddb_server = g_strdup(CDDA_DEFAULT_CDDB_SERVER); |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
151 cdng_cfg.cddb_port = CDDA_DEFAULT_CDDB_PORT; |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
152 cdng_cfg.cddb_http = FALSE; |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
153 cdng_cfg.limitspeed = CDDA_DEFAULT_LIMIT_SPEED; |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
154 cdng_cfg.use_proxy = FALSE; |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
155 cdng_cfg.proxy_host = g_strdup(""); |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
156 cdng_cfg.proxy_port = CDDA_DEFAULT_PROXY_PORT; |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
157 cdng_cfg.proxy_username = g_strdup(""); |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
158 cdng_cfg.proxy_password = g_strdup(""); |
1125 | 159 |
2044 | 160 if ((db = aud_cfg_db_open()) == NULL) { |
2037 | 161 cdaudio_error("Failed to read configuration.\n"); |
162 cleanup_on_error(); | |
163 return; | |
164 } | |
165 | |
1123 | 166 if (!cdio_init()) { |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
167 cdaudio_error("Failed to initialize cdio subsystem.\n"); |
1123 | 168 cleanup_on_error(); |
2384
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
169 aud_cfg_db_close(db); |
1123 | 170 return; |
171 } | |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
172 |
1282 | 173 libcddb_init(); |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
174 |
2384
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
175 aud_cfg_db_get_bool(db, "CDDA", "use_dae", &cdng_cfg.use_dae); |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
176 aud_cfg_db_get_bool(db, "CDDA", "use_cdtext", &cdng_cfg.use_cdtext); |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
177 aud_cfg_db_get_bool(db, "CDDA", "use_cddb", &cdng_cfg.use_cddb); |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
178 aud_cfg_db_get_bool(db, "CDDA", "debug", &cdng_cfg.debug); |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
179 aud_cfg_db_get_string(db, "CDDA", "device", &cdng_cfg.device); |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
180 aud_cfg_db_get_string(db, "CDDA", "cddbserver", &cdng_cfg.cddb_server); |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
181 aud_cfg_db_get_int(db, "CDDA", "cddbport", &cdng_cfg.cddb_port); |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
182 aud_cfg_db_get_bool(db, "CDDA", "cddbhttp", &cdng_cfg.cddb_http); |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
183 aud_cfg_db_get_int(db, "CDDA", "limitspeed", &cdng_cfg.limitspeed); |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
184 aud_cfg_db_get_bool(db, "audacious", "use_proxy", &cdng_cfg.use_proxy); |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
185 aud_cfg_db_get_string(db, "audacious", "proxy_host", &cdng_cfg.proxy_host); |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
186 aud_cfg_db_get_int(db, "audacious", "proxy_port", &cdng_cfg.proxy_port); |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
187 aud_cfg_db_get_string(db, "audacious", "proxy_user", &cdng_cfg.proxy_username); |
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
188 aud_cfg_db_get_string(db, "audacious", "proxy_pass", &cdng_cfg.proxy_password); |
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); |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
203 g_signal_connect(G_OBJECT(main_menu_item), "activate", G_CALLBACK(menu_click), NULL); |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
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); |
2419
944a510f5200
- now cdaudio-ng calculates discid correctly. closes #165
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2384
diff
changeset
|
208 audacious_menu_plugin_item_add(AUDACIOUS_MENU_PLAYLIST_RCLICK, playlist_menu_item); |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
209 g_signal_connect(G_OBJECT(playlist_menu_item), "activate", G_CALLBACK(menu_click), NULL); |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
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 |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
254 if (filename != NULL && !strcmp(filename, CDDA_DUMMYPATH)) { |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
255 debug("\"%s\" will add the whole audio cd\n", filename); |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
256 menu_click(); |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
257 return FALSE; |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
258 } |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
259 |
1048 | 260 if ((filename != NULL) && strlen(filename) > 4 && (!strcasecmp(filename + strlen(filename) - 4, ".cda"))) { |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
261 gint trackno = find_trackno_from_filename(filename); |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
262 |
2047 | 263 /* no CD information yet */ |
1123 | 264 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
|
265 debug("no CD information, scanning\n"); |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
266 scan_cd_threaded(0, 0); |
1048 | 267 } |
1123 | 268 |
2047 | 269 /* reload the cd information if the media has changed */ |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
270 if (pcdio != NULL && 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
|
271 debug("CD changed, rescanning\n"); |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
272 scan_cd_threaded(0, 0); |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
273 } |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
274 |
2047 | 275 /* check if the requested track actually exists on the current audio cd */ |
1125 | 276 if (trackno < firsttrackno || trackno > lasttrackno) { |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
277 debug("\"%s\" is not our file (track number is out of the valid range)\n", filename); |
1123 | 278 return FALSE; |
1125 | 279 } |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
280 |
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
|
281 debug("\"%s\" is our file\n", filename); |
1123 | 282 return TRUE; |
1048 | 283 } |
1125 | 284 else { |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
285 debug("\"%s\" is not our file (unrecognized file name)\n", filename); |
1123 | 286 return FALSE; |
1125 | 287 } |
1048 | 288 } |
289 | |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
290 |
2046 | 291 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
|
292 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
|
293 { |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
294 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
|
295 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
|
296 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
|
297 } |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
298 |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
299 |
2046 | 300 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
|
301 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
|
302 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
|
303 { |
2046 | 304 t->startlsn = startlsn; |
305 t->endlsn = endlsn; | |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
306 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
|
307 } |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
308 |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
309 |
2047 | 310 static void cdaudio_play_file(InputPlayback *pinputplayback) |
1125 | 311 { |
1466 | 312 Tuple *tuple; |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
313 gchar *title; |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
314 |
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
|
315 debug("cdaudio_play_file(\"%s\")\n", pinputplayback->filename); |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
316 |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
317 pglobalinputplayback = pinputplayback; |
1125 | 318 |
1048 | 319 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
|
320 debug("no CD information, scanning\n"); |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
321 if (scan_cd_thread != NULL) |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
322 g_thread_join(scan_cd_thread); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
323 else |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
324 scan_cd(pinputplayback); |
1048 | 325 } |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
326 else |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
327 if (cdio_get_media_changed(pcdio)) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
328 debug("CD changed, rescanning\n"); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
329 if (scan_cd_thread != NULL) |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
330 g_thread_join(scan_cd_thread); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
331 else |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
332 scan_cd(pinputplayback); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
333 } |
1123 | 334 |
1389
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
335 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
|
336 debug("no CD information can be retrieved, aborting\n"); |
1389
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
337 pinputplayback->playing = FALSE; |
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
338 return; |
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
339 } |
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
340 |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
341 gint trackno = find_trackno_from_filename(pinputplayback->filename); |
1123 | 342 if (trackno < firsttrackno || trackno > lasttrackno) { |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
343 cdaudio_error("Track #%d is out of range [%d..%d]\n", trackno, firsttrackno, lasttrackno); |
1123 | 344 cleanup_on_error(); |
1048 | 345 return; |
1123 | 346 } |
1048 | 347 |
348 pinputplayback->playing = TRUE; | |
349 playing_track = trackno; | |
1123 | 350 is_paused = FALSE; |
351 | |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
352 tuple = create_tuple_from_trackinfo_and_filename(pinputplayback->filename); |
2055 | 353 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
|
354 |
1984
489e32a8e106
change some places to use set_params() instead of set_info() directly
William Pitcock <nenolod@atheme.org>
parents:
1976
diff
changeset
|
355 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
|
356 g_free(title); |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
357 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
|
358 |
2046 | 359 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
|
360 debug("using digital audio extraction\n"); |
1125 | 361 |
1123 | 362 if (pdae_params != NULL) { |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
363 cdaudio_error("DAE playback seems to be already started.\n"); |
1123 | 364 return; |
365 } | |
366 | |
367 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
|
368 cdaudio_error("Failed to open audio output.\n"); |
1123 | 369 cleanup_on_error(); |
370 return; | |
371 } | |
372 | |
1349
ab387ad5b88e
Converted to new threading model
Calin Crisan ccrisan@gmail.com
parents:
1341
diff
changeset
|
373 /* |
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
|
374 debug("starting dae thread...\n"); |
1349
ab387ad5b88e
Converted to new threading model
Calin Crisan ccrisan@gmail.com
parents:
1341
diff
changeset
|
375 */ |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
376 pdae_params = (dae_params_t *) g_new(dae_params_t, 1); |
1123 | 377 pdae_params->startlsn = trackinfo[trackno].startlsn; |
378 pdae_params->endlsn = trackinfo[trackno].endlsn; | |
379 pdae_params->pplayback = pinputplayback; | |
380 pdae_params->seektime = -1; | |
381 pdae_params->currlsn = trackinfo[trackno].startlsn; | |
1349
ab387ad5b88e
Converted to new threading model
Calin Crisan ccrisan@gmail.com
parents:
1341
diff
changeset
|
382 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
|
383 pinputplayback->set_pb_ready(pinputplayback); |
1349
ab387ad5b88e
Converted to new threading model
Calin Crisan ccrisan@gmail.com
parents:
1341
diff
changeset
|
384 dae_play_loop(pdae_params); |
1123 | 385 } |
386 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
|
387 debug("not using digital audio extraction\n"); |
1125 | 388 |
1123 | 389 msf_t startmsf, endmsf; |
390 cdio_lsn_to_msf(trackinfo[trackno].startlsn, &startmsf); | |
391 cdio_lsn_to_msf(trackinfo[trackno].endlsn, &endmsf); | |
392 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
|
393 cdaudio_error("Failed to play analog audio CD.\n"); |
1123 | 394 cleanup_on_error(); |
395 return; | |
396 } | |
397 } | |
1048 | 398 } |
399 | |
2047 | 400 static void cdaudio_stop(InputPlayback *pinputplayback) |
1125 | 401 { |
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
|
402 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
|
403 |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
404 pglobalinputplayback = NULL; |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
405 |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
406 if (playing_track == -1) |
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
407 return; |
1125 | 408 |
1303 | 409 if (pinputplayback != NULL) |
410 pinputplayback->playing = FALSE; | |
1048 | 411 playing_track = -1; |
1123 | 412 is_paused = FALSE; |
413 | |
2046 | 414 if (cdng_cfg.use_dae) { |
1123 | 415 if (pdae_params != NULL) { |
416 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
|
417 g_free(pdae_params); |
1123 | 418 pdae_params = NULL; |
419 } | |
420 } | |
421 else { | |
422 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
|
423 cdaudio_error("Failed to stop analog CD.\n"); |
1123 | 424 return; |
425 } | |
426 } | |
1048 | 427 } |
428 | |
2047 | 429 static void cdaudio_pause(InputPlayback *pinputplayback, gshort paused) |
1048 | 430 { |
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
|
431 debug("cdaudio_pause(\"%s\", %d)\n", pinputplayback->filename, paused); |
1125 | 432 |
1048 | 433 if (!is_paused) { |
434 is_paused = TRUE; | |
2046 | 435 if (!cdng_cfg.use_dae) |
1123 | 436 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
|
437 cdaudio_error("Failed to pause analog CD!\n"); |
1123 | 438 cleanup_on_error(); |
439 return; | |
440 } | |
1048 | 441 } |
442 else { | |
443 is_paused = FALSE; | |
2046 | 444 if (!cdng_cfg.use_dae) |
1123 | 445 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
|
446 cdaudio_error("Failed to resume analog CD!\n"); |
1123 | 447 cleanup_on_error(); |
448 return; | |
449 } | |
1048 | 450 } |
451 } | |
452 | |
2047 | 453 static void cdaudio_seek(InputPlayback *pinputplayback, gint time) |
1048 | 454 { |
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("cdaudio_seek(\"%s\", %d)\n", pinputplayback->filename, time); |
1125 | 456 |
1048 | 457 if (playing_track == -1) |
458 return; | |
459 | |
2046 | 460 if (cdng_cfg.use_dae) { |
1123 | 461 if (pdae_params != NULL) { |
462 pdae_params->seektime = time * 1000; | |
463 } | |
464 } | |
465 else { | |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
466 gint newstartlsn = trackinfo[playing_track].startlsn + time * 75; |
1123 | 467 msf_t startmsf, endmsf; |
468 cdio_lsn_to_msf(newstartlsn, &startmsf); | |
469 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
|
470 |
1123 | 471 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
|
472 cdaudio_error("Failed to play analog CD\n"); |
1123 | 473 cleanup_on_error(); |
474 return; | |
475 } | |
476 } | |
1048 | 477 } |
478 | |
2047 | 479 static gint cdaudio_get_time(InputPlayback *pinputplayback) |
1048 | 480 { |
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
|
481 //debug("cdaudio_get_time(\"%s\")\n", pinputplayback->filename); // annoying! |
1125 | 482 |
1048 | 483 if (playing_track == -1) |
484 return -1; | |
485 | |
2046 | 486 if (!cdng_cfg.use_dae) { |
1123 | 487 cdio_subchannel_t subchannel; |
488 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
|
489 cdaudio_error("Failed to read analog CD subchannel.\n"); |
1123 | 490 cleanup_on_error(); |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
491 return 0; |
1123 | 492 } |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
493 gint currlsn = cdio_msf_to_lsn(&subchannel.abs_addr); |
1048 | 494 |
2047 | 495 /* 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
|
496 if (currlsn == trackinfo[playing_track].endlsn) |
1123 | 497 return -1; |
498 | |
499 return calculate_track_length(trackinfo[playing_track].startlsn, currlsn); | |
1048 | 500 } |
1123 | 501 else { |
502 if (pdae_params != NULL) | |
1314
b93270e2b7e4
Continuous playing in DAE mode works again
Calin Crisan ccrisan@gmail.com
parents:
1313
diff
changeset
|
503 if (pdae_params->pplayback->playing) |
b93270e2b7e4
Continuous playing in DAE mode works again
Calin Crisan ccrisan@gmail.com
parents:
1313
diff
changeset
|
504 return pinputplayback->output->output_time(); |
b93270e2b7e4
Continuous playing in DAE mode works again
Calin Crisan ccrisan@gmail.com
parents:
1313
diff
changeset
|
505 else |
b93270e2b7e4
Continuous playing in DAE mode works again
Calin Crisan ccrisan@gmail.com
parents:
1313
diff
changeset
|
506 return -1; |
1123 | 507 else |
508 return -1; | |
509 } | |
1048 | 510 } |
511 | |
2047 | 512 static gint cdaudio_get_volume(gint *l, gint *r) |
1048 | 513 { |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
514 // debug("cdaudio-ng: cdaudio_get_volume()\n"); // annoying! |
1125 | 515 |
2046 | 516 if (cdng_cfg.use_dae) { |
1123 | 517 *l = *r = 0; |
518 return FALSE; | |
519 } | |
520 else { | |
521 cdio_audio_volume_t volume; | |
522 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
|
523 cdaudio_error("Failed to retrieve analog CD volume.\n"); |
1123 | 524 cleanup_on_error(); |
525 *l = *r = 0; | |
526 return FALSE; | |
527 } | |
528 *l = volume.level[0]; | |
529 *r = volume.level[1]; | |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
530 |
1123 | 531 return TRUE; |
532 } | |
1048 | 533 } |
534 | |
2047 | 535 static gint cdaudio_set_volume(gint l, gint r) |
1048 | 536 { |
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
|
537 debug("cdaudio_set_volume(%d, %d)\n", l, r); |
1125 | 538 |
2046 | 539 if (cdng_cfg.use_dae) { |
1123 | 540 return FALSE; |
541 } | |
542 else { | |
543 cdio_audio_volume_t volume = {{l, r, 0, 0}}; | |
544 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
|
545 cdaudio_error("cdaudio-ng: failed to set analog cd volume\n"); |
1123 | 546 cleanup_on_error(); |
547 return FALSE; | |
548 } | |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
549 |
1123 | 550 return TRUE; |
551 } | |
1048 | 552 } |
553 | |
2047 | 554 static void cdaudio_cleanup(void) |
1048 | 555 { |
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
|
556 debug("cdaudio_cleanup()\n"); |
1125 | 557 |
1282 | 558 libcddb_shutdown(); |
559 | |
2046 | 560 if (pcdio != NULL) { |
561 if (playing_track != -1 && !cdng_cfg.use_dae) | |
1123 | 562 cdio_audio_stop(pcdio); |
563 cdio_destroy(pcdio); | |
564 pcdio = NULL; | |
565 } | |
566 if (trackinfo != NULL) { | |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
567 g_free(trackinfo); |
1123 | 568 trackinfo = NULL; |
569 } | |
570 playing_track = -1; | |
1282 | 571 |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
572 // todo: destroy the gui |
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
573 |
2044 | 574 ConfigDb *db = aud_cfg_db_open(); |
2384
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
575 aud_cfg_db_set_bool(db, "CDDA", "use_dae", cdng_cfg.use_dae); |
2046 | 576 aud_cfg_db_set_int(db, "CDDA", "limitspeed", cdng_cfg.limitspeed); |
577 aud_cfg_db_set_bool(db, "CDDA", "use_cdtext", cdng_cfg.use_cdtext); | |
578 aud_cfg_db_set_bool(db, "CDDA", "use_cddb", cdng_cfg.use_cddb); | |
579 aud_cfg_db_set_string(db, "CDDA", "cddbserver", cdng_cfg.cddb_server); | |
580 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
|
581 aud_cfg_db_set_bool(db, "CDDA", "cddbhttp", cdng_cfg.cddb_http); |
2046 | 582 aud_cfg_db_set_string(db, "CDDA", "device", cdng_cfg.device); |
583 aud_cfg_db_set_bool(db, "CDDA", "debug", cdng_cfg.debug); | |
2044 | 584 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
|
585 |
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
|
586 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
|
587 audacious_menu_plugin_item_remove(AUDACIOUS_MENU_PLAYLIST, playlist_menu_item); |
1048 | 588 } |
589 | |
2047 | 590 static void cdaudio_get_song_info(gchar *filename, gchar **title, gint *length) |
1048 | 591 { |
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
|
592 debug("cdaudio_get_song_info(\"%s\")\n", filename); |
1125 | 593 |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
594 Tuple *tuple = create_tuple_from_trackinfo_and_filename(filename); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
595 int trackno = find_trackno_from_filename(filename); |
1125 | 596 |
2046 | 597 if (tuple) { |
2055 | 598 *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
|
599 aud_tuple_free(tuple); |
1466 | 600 tuple = NULL; |
601 } | |
1125 | 602 *length = calculate_track_length(trackinfo[trackno].startlsn, trackinfo[trackno].endlsn); |
1048 | 603 } |
604 | |
2047 | 605 static Tuple *cdaudio_get_song_tuple(gchar *filename) |
1048 | 606 { |
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
|
607 debug("cdaudio_get_song_tuple(\"%s\")\n", filename); |
1125 | 608 |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
609 return create_tuple_from_trackinfo_and_filename(filename); |
1341
4ca99d2be90e
Titles are now built using tuples, with the preferred format
Calin Crisan ccrisan@gmail.com
parents:
1340
diff
changeset
|
610 } |
4ca99d2be90e
Titles are now built using tuples, with the preferred format
Calin Crisan ccrisan@gmail.com
parents:
1340
diff
changeset
|
611 |
4ca99d2be90e
Titles are now built using tuples, with the preferred format
Calin Crisan ccrisan@gmail.com
parents:
1340
diff
changeset
|
612 |
2047 | 613 /* |
614 * auxiliar functions | |
615 */ | |
616 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
|
617 { |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
618 debug("plugin services menu option selected\n"); |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
619 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
620 /* reload the cd information if the media has changed, or no track information is available */ |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
621 if (pcdio == NULL || cdio_get_media_changed(pcdio)) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
622 if (scan_cd_thread != NULL) |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
623 return; |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
624 else { |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
625 scan_cd_threaded(-1, -1); |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
626 debug("CD changed, rescanning\n"); |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
627 } |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
628 } |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
629 else { |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
630 int trackno; |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
631 for (trackno = firsttrackno; trackno <= lasttrackno; trackno++) |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
632 append_track_to_playlist(trackno); |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
633 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
634 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
635 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
636 static Tuple *create_tuple_from_trackinfo_and_filename(gchar *filename) |
1341
4ca99d2be90e
Titles are now built using tuples, with the preferred format
Calin Crisan ccrisan@gmail.com
parents:
1340
diff
changeset
|
637 { |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
638 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
|
639 |
1389
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
640 if (trackinfo == NULL) |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
641 return tuple; |
1389
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
642 |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
643 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
|
644 |
1048 | 645 if (trackno < firsttrackno || trackno > lasttrackno) |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
646 return tuple; |
1048 | 647 |
1466 | 648 if(strlen(trackinfo[trackno].performer)) { |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
649 aud_tuple_associate_string(tuple, FIELD_ARTIST, NULL, trackinfo[trackno].performer); |
1466 | 650 } |
651 if(strlen(trackinfo[0].name)) { | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
652 aud_tuple_associate_string(tuple, FIELD_ALBUM, NULL, trackinfo[0].name); |
1466 | 653 } |
654 if(strlen(trackinfo[trackno].name)) { | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
655 aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, trackinfo[trackno].name); |
1466 | 656 } |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
657 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
658 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
|
659 aud_tuple_associate_string(tuple, -1, "ext", "cda"); //XXX should do? --yaz |
1466 | 660 |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
661 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
|
662 calculate_track_length(trackinfo[trackno].startlsn, trackinfo[trackno].endlsn)); |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
663 |
1466 | 664 if(strlen(trackinfo[trackno].genre)) { |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
665 aud_tuple_associate_string(tuple, FIELD_GENRE, NULL, trackinfo[trackno].genre); |
1466 | 666 } |
1048 | 667 //tuple->year = 0; todo: set the year |
668 | |
669 return tuple; | |
670 } | |
671 | |
2047 | 672 static void dae_play_loop(dae_params_t *pdae_params) |
1123 | 673 { |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
674 guchar *buffer = g_new(guchar, CDDA_DAE_FRAMES * CDIO_CD_FRAMESIZE_RAW); |
1123 | 675 |
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
|
676 debug("dae started\n"); |
1123 | 677 cdio_lseek(pcdio, pdae_params->startlsn * CDIO_CD_FRAMESIZE_RAW, SEEK_SET); |
678 | |
679 gboolean output_paused = FALSE; | |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
680 gint read_error_counter = 0; |
1125 | 681 |
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
|
682 //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
|
683 |
1123 | 684 while (pdae_params->pplayback->playing) { |
2047 | 685 /* handle pause status */ |
1123 | 686 if (is_paused) { |
687 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
|
688 debug("playback was not paused, pausing\n"); |
1123 | 689 pdae_params->pplayback->output->pause(TRUE); |
690 output_paused = TRUE; | |
691 } | |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
692 g_usleep(1000); |
1123 | 693 continue; |
694 } | |
1125 | 695 else { |
1123 | 696 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
|
697 debug("playback was paused, resuming\n"); |
1123 | 698 pdae_params->pplayback->output->pause(FALSE); |
699 output_paused = FALSE; | |
700 } | |
1125 | 701 } |
1123 | 702 |
2047 | 703 /* check if we have to seek */ |
1123 | 704 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
|
705 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
|
706 gint newlsn = pdae_params->startlsn + ((pdae_params->seektime * 75) / 1000); |
1123 | 707 cdio_lseek(pcdio, newlsn * CDIO_CD_FRAMESIZE_RAW, SEEK_SET); |
708 pdae_params->pplayback->output->flush(pdae_params->seektime); | |
709 pdae_params->currlsn = newlsn; | |
710 pdae_params->seektime = -1; | |
711 } | |
712 | |
2047 | 713 /* 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
|
714 gint lsncount = CDDA_DAE_FRAMES <= (pdae_params->endlsn - pdae_params->currlsn + 1) ? CDDA_DAE_FRAMES : (pdae_params->endlsn - pdae_params->currlsn + 1); |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
715 |
2047 | 716 /* 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
|
717 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
|
718 sleep(3); |
1123 | 719 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
|
720 } |
1123 | 721 |
722 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
|
723 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
|
724 read_error_counter++; |
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
725 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
|
726 read_error_counter = 0; |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
727 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
|
728 break; |
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
729 } |
1123 | 730 } |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
731 else |
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
732 read_error_counter = 0; |
1123 | 733 |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
734 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
|
735 guchar *bytebuff = buffer; |
1123 | 736 while (pdae_params->pplayback->playing && remainingbytes > 0 && pdae_params->seektime == -1) { |
2047 | 737 /* 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
|
738 gint bytecount = CDIO_CD_FRAMESIZE_RAW <= remainingbytes ? CDIO_CD_FRAMESIZE_RAW : remainingbytes; |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
739 |
2047 | 740 /* wait until the output buffer has enough room */ |
1123 | 741 while (pdae_params->pplayback->playing && pdae_params->pplayback->output->buffer_free() < bytecount && pdae_params->seektime == -1) |
2041 | 742 g_usleep(1000); |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
743 |
2047 | 744 /* play the sound :) */ |
1123 | 745 if (pdae_params->pplayback->playing && pdae_params->seektime == -1) |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
746 pdae_params->pplayback->pass_audio(pdae_params->pplayback, FMT_S16_LE, 2, |
1998
8f3188746b64
chase last changeset in aud
William Pitcock <nenolod@atheme.org>
parents:
1997
diff
changeset
|
747 bytecount, bytebuff, &pdae_params->pplayback->playing); |
1123 | 748 remainingbytes -= bytecount; |
749 bytebuff += bytecount; | |
750 } | |
751 pdae_params->currlsn += lsncount; | |
752 } | |
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
|
753 debug("dae ended\n"); |
1123 | 754 |
755 pdae_params->pplayback->playing = FALSE; | |
1314
b93270e2b7e4
Continuous playing in DAE mode works again
Calin Crisan ccrisan@gmail.com
parents:
1313
diff
changeset
|
756 pdae_params->pplayback->output->close_audio(); |
1123 | 757 is_paused = FALSE; |
758 | |
759 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
|
760 g_free(buffer); |
1123 | 761 } |
762 | |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
763 static void scan_cd_threaded(int firsttrackno, int lasttrackno) |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
764 { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
765 if (scan_cd_thread != NULL) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
766 debug("A scan_cd thread is already running.\n"); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
767 return; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
768 } |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
769 |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
770 first_trackno_to_add_after_scan = firsttrackno; |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
771 last_trackno_to_add_after_scan = lasttrackno; |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
772 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
773 scan_cd_thread = g_thread_create((GThreadFunc)scan_cd, NULL, TRUE, NULL); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
774 if (scan_cd_thread == NULL) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
775 cdaudio_error("Failed to create the thread for retrieving song information.\n"); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
776 return; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
777 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
778 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
779 |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
780 static void append_track_to_playlist(int trackno) |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
781 { |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
782 gchar pathname[DEF_STRING_LEN]; |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
783 |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
784 g_snprintf(pathname, DEF_STRING_LEN, "%strack%02u.cda", CDDA_DUMMYPATH, trackno); |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
785 aud_playlist_add(aud_playlist_get_active(), pathname); |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
786 |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
787 debug("added track \"%s\" to the playlist\n", pathname); |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
788 } |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
789 |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
790 static gboolean show_noaudiocd_info(gpointer data) |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
791 { |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
792 const gchar *markup = |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
793 N_("<b><big>No playable CD found.</big></b>\n\n" |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
794 "No CD inserted, or inserted CD is not an audio CD.\n"); |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
795 |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
796 GtkWidget *dialog = |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
797 gtk_message_dialog_new_with_markup(NULL, |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
798 GTK_DIALOG_DESTROY_WITH_PARENT, |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
799 GTK_MESSAGE_ERROR, |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
800 GTK_BUTTONS_OK, |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
801 _(markup)); |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
802 gtk_dialog_run(GTK_DIALOG(dialog)); |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
803 gtk_widget_destroy(dialog); |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
804 |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
805 return TRUE; |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
806 } |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
807 |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
808 static void show_noaudiocd_info_safe() |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
809 { |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
810 g_idle_add_full(G_PRIORITY_HIGH_IDLE, show_noaudiocd_info, NULL, NULL); |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
811 } |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
812 |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
813 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
814 static void *scan_cd(void *nothing) |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
815 { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
816 debug("scan_cd started\n"); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
817 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
818 gint trackno; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
819 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
820 /* find an available, audio capable, cd drive */ |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
821 if (cdng_cfg.device != NULL && strlen(cdng_cfg.device) > 0) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
822 pcdio = cdio_open(cdng_cfg.device, DRIVER_UNKNOWN); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
823 if (pcdio == NULL) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
824 cdaudio_error("Failed to open CD device \"%s\".\n", cdng_cfg.device); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
825 scan_cd_thread = NULL; |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
826 show_noaudiocd_info_safe(); |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
827 return NULL; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
828 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
829 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
830 else { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
831 gchar **ppcd_drives = cdio_get_devices_with_cap(NULL, CDIO_FS_AUDIO, false); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
832 pcdio = NULL; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
833 if (ppcd_drives != NULL && *ppcd_drives != NULL) { /* we have at least one audio capable cd drive */ |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
834 pcdio = cdio_open(*ppcd_drives, DRIVER_UNKNOWN); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
835 if (pcdio == NULL) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
836 cdaudio_error("Failed to open CD.\n"); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
837 cleanup_on_error(); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
838 scan_cd_thread = NULL; |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
839 show_noaudiocd_info_safe(); |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
840 return NULL; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
841 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
842 debug("found cd drive \"%s\" with audio capable media\n", *ppcd_drives); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
843 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
844 else { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
845 cdaudio_error("Unable to find or access a CDDA capable drive.\n"); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
846 cleanup_on_error(); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
847 scan_cd_thread = NULL; |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
848 show_noaudiocd_info_safe(); |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
849 return NULL; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
850 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
851 if (ppcd_drives != NULL && *ppcd_drives != NULL) |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
852 cdio_free_device_list(ppcd_drives); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
853 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
854 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
855 /* limit read speed */ |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
856 if (cdng_cfg.limitspeed > 0 && cdng_cfg.use_dae) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
857 debug("setting drive speed limit to %dx\n", cdng_cfg.limitspeed); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
858 if (cdio_set_speed(pcdio, cdng_cfg.limitspeed) != DRIVER_OP_SUCCESS) |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
859 cdaudio_error("Failed to set drive speed to %dx.\n", cdng_cfg.limitspeed); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
860 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
861 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
862 /* general track initialization */ |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
863 cdrom_drive_t *pcdrom_drive = cdio_cddap_identify_cdio(pcdio, 1, NULL); // todo : check return / NULL |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
864 firsttrackno = cdio_get_first_track_num(pcdrom_drive->p_cdio); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
865 lasttrackno = cdio_get_last_track_num(pcdrom_drive->p_cdio); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
866 if (firsttrackno == CDIO_INVALID_TRACK || lasttrackno == CDIO_INVALID_TRACK) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
867 cdaudio_error("Failed to retrieve first/last track number.\n"); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
868 cleanup_on_error(); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
869 scan_cd_thread = NULL; |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
870 show_noaudiocd_info_safe(); |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
871 return NULL; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
872 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
873 debug("first track is %d and last track is %d\n", firsttrackno, lasttrackno); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
874 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
875 g_free(trackinfo); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
876 trackinfo = (trackinfo_t *) g_new(trackinfo_t, (lasttrackno + 1)); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
877 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
878 cdaudio_set_fullinfo(&trackinfo[0], |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
879 cdio_get_track_lsn(pcdrom_drive->p_cdio, 0), |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
880 cdio_get_track_last_lsn(pcdrom_drive->p_cdio, CDIO_CDROM_LEADOUT_TRACK), |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
881 "", "", ""); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
882 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
883 for (trackno = firsttrackno; trackno <= lasttrackno; trackno++) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
884 cdaudio_set_fullinfo(&trackinfo[trackno], |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
885 cdio_get_track_lsn(pcdrom_drive->p_cdio, trackno), |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
886 cdio_get_track_last_lsn(pcdrom_drive->p_cdio, trackno), |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
887 "", "", ""); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
888 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
889 if (trackinfo[trackno].startlsn == CDIO_INVALID_LSN || trackinfo[trackno].endlsn == CDIO_INVALID_LSN) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
890 cdaudio_error("Failed to retrieve stard/end lsn for track %d.\n", trackno); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
891 cleanup_on_error(); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
892 scan_cd_thread = NULL; |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
893 show_noaudiocd_info_safe(); |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
894 return NULL; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
895 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
896 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
897 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
898 /* get trackinfo[0] cdtext information (the disc) */ |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
899 if (cdng_cfg.use_cdtext) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
900 debug("getting cd-text information for disc\n"); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
901 cdtext_t *pcdtext = cdio_get_cdtext(pcdrom_drive->p_cdio, 0); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
902 if (pcdtext == NULL || pcdtext->field[CDTEXT_TITLE] == NULL) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
903 debug("no cd-text available for disc\n"); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
904 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
905 else { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
906 cdaudio_set_strinfo(&trackinfo[0], |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
907 pcdtext->field[CDTEXT_PERFORMER] ? pcdtext->field[CDTEXT_PERFORMER] : "", |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
908 pcdtext->field[CDTEXT_TITLE] ? pcdtext->field[CDTEXT_TITLE] : "", |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
909 pcdtext->field[CDTEXT_GENRE] ? pcdtext->field[CDTEXT_GENRE] : ""); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
910 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
911 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
912 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
913 /* get track information from cdtext */ |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
914 gboolean cdtext_was_available = FALSE; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
915 for (trackno = firsttrackno; trackno <= lasttrackno; trackno++) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
916 cdtext_t *pcdtext = NULL; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
917 if (cdng_cfg.use_cdtext) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
918 debug("getting cd-text information for track %d\n", trackno); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
919 pcdtext = cdio_get_cdtext(pcdrom_drive->p_cdio, trackno); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
920 if (pcdtext == NULL || pcdtext->field[CDTEXT_PERFORMER] == NULL) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
921 debug("no cd-text available for track %d\n", trackno); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
922 pcdtext = NULL; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
923 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
924 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
925 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
926 if (pcdtext != NULL) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
927 cdaudio_set_strinfo(&trackinfo[trackno], |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
928 pcdtext->field[CDTEXT_PERFORMER] ? pcdtext->field[CDTEXT_PERFORMER] : "", |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
929 pcdtext->field[CDTEXT_TITLE] ? pcdtext->field[CDTEXT_TITLE] : "", |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
930 pcdtext->field[CDTEXT_GENRE] ? pcdtext->field[CDTEXT_GENRE] : ""); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
931 cdtext_was_available = TRUE; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
932 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
933 else { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
934 cdaudio_set_strinfo(&trackinfo[trackno], "", "", ""); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
935 g_snprintf(trackinfo[trackno].name, DEF_STRING_LEN, "CD Audio Track %02u", trackno); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
936 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
937 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
938 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
939 if (!cdtext_was_available) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
940 /* initialize de cddb subsystem */ |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
941 cddb_conn_t *pcddb_conn = NULL; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
942 cddb_disc_t *pcddb_disc = NULL; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
943 cddb_track_t *pcddb_track = NULL; |
2419
944a510f5200
- now cdaudio-ng calculates discid correctly. closes #165
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2384
diff
changeset
|
944 lba_t lba; /* Logical Block Address */ |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
945 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
946 if (cdng_cfg.use_cddb) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
947 pcddb_conn = cddb_new(); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
948 if (pcddb_conn == NULL) |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
949 cdaudio_error("Failed to create the cddb connection.\n"); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
950 else { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
951 debug("getting CDDB info\n"); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
952 |
2384
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
953 cddb_cache_enable(pcddb_conn); |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
954 // cddb_cache_set_dir(pcddb_conn, "~/.cddbslave"); |
2384
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
955 |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
956 if (cdng_cfg.use_proxy) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
957 cddb_http_proxy_enable(pcddb_conn); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
958 cddb_set_http_proxy_server_name(pcddb_conn, cdng_cfg.proxy_host); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
959 cddb_set_http_proxy_server_port(pcddb_conn, cdng_cfg.proxy_port); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
960 cddb_set_http_proxy_username(pcddb_conn, cdng_cfg.proxy_username); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
961 cddb_set_http_proxy_password(pcddb_conn, cdng_cfg.proxy_password); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
962 cddb_set_server_name(pcddb_conn, cdng_cfg.cddb_server); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
963 cddb_set_server_port(pcddb_conn, cdng_cfg.cddb_port); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
964 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
965 else |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
966 if (cdng_cfg.cddb_http) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
967 cddb_http_enable(pcddb_conn); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
968 cddb_set_server_name(pcddb_conn, cdng_cfg.cddb_server); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
969 cddb_set_server_port(pcddb_conn, cdng_cfg.cddb_port); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
970 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
971 else { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
972 cddb_set_server_name(pcddb_conn, cdng_cfg.cddb_server); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
973 cddb_set_server_port(pcddb_conn, cdng_cfg.cddb_port); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
974 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
975 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
976 pcddb_disc = cddb_disc_new(); |
2419
944a510f5200
- now cdaudio-ng calculates discid correctly. closes #165
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2384
diff
changeset
|
977 |
944a510f5200
- now cdaudio-ng calculates discid correctly. closes #165
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2384
diff
changeset
|
978 lba = cdio_get_track_lba(pcdio, CDIO_CDROM_LEADOUT_TRACK); |
944a510f5200
- now cdaudio-ng calculates discid correctly. closes #165
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2384
diff
changeset
|
979 cddb_disc_set_length(pcddb_disc, FRAMES_TO_SECONDS(lba)); |
944a510f5200
- now cdaudio-ng calculates discid correctly. closes #165
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2384
diff
changeset
|
980 |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
981 for (trackno = firsttrackno; trackno <= lasttrackno; trackno++) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
982 pcddb_track = cddb_track_new(); |
2419
944a510f5200
- now cdaudio-ng calculates discid correctly. closes #165
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2384
diff
changeset
|
983 cddb_track_set_frame_offset(pcddb_track, cdio_get_track_lba(pcdio, trackno)); |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
984 cddb_disc_add_track(pcddb_disc, pcddb_track); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
985 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
986 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
987 cddb_disc_calc_discid(pcddb_disc); |
2384
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
988 unsigned int discid = cddb_disc_get_discid(pcddb_disc); |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
989 debug("CDDB disc id = %x\n", discid); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
990 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
991 gint matches; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
992 if ((matches = cddb_query(pcddb_conn, pcddb_disc)) == -1) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
993 if (cddb_errno(pcddb_conn) == CDDB_ERR_OK) |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
994 cdaudio_error("Failed to query the CDDB server\n"); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
995 else |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
996 cdaudio_error("Failed to query the CDDB server: %s\n", cddb_error_str(cddb_errno(pcddb_conn))); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
997 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
998 cddb_disc_destroy(pcddb_disc); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
999 pcddb_disc = NULL; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1000 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1001 else { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1002 if (matches == 0) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1003 debug("no cddb info available for this disc\n"); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1004 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1005 cddb_disc_destroy(pcddb_disc); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1006 pcddb_disc = NULL; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1007 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1008 else { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1009 debug("CDDB disc category = \"%s\"\n", cddb_disc_get_category_str(pcddb_disc)); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1010 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1011 cddb_read(pcddb_conn, pcddb_disc); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1012 if (cddb_errno(pcddb_conn) != CDDB_ERR_OK) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1013 cdaudio_error("failed to read the cddb info: %s\n", cddb_error_str(cddb_errno(pcddb_conn))); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1014 cddb_disc_destroy(pcddb_disc); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1015 pcddb_disc = NULL; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1016 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1017 else { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1018 debug("we have got the cddb info\n"); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1019 cdaudio_set_strinfo(&trackinfo[0], |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1020 cddb_disc_get_artist(pcddb_disc), |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1021 cddb_disc_get_title(pcddb_disc), |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1022 cddb_disc_get_genre(pcddb_disc)); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1023 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1024 int trackno; |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1025 for (trackno = firsttrackno; trackno <= lasttrackno; trackno++) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1026 cddb_track_t *pcddb_track = cddb_disc_get_track(pcddb_disc, trackno - 1); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1027 cdaudio_set_strinfo(&trackinfo[trackno], |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1028 cddb_track_get_artist(pcddb_track), |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1029 cddb_track_get_title(pcddb_track), |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1030 cddb_disc_get_genre(pcddb_disc)); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1031 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1032 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1033 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1034 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1035 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1036 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1037 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1038 if (pcddb_disc != NULL) |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1039 cddb_disc_destroy(pcddb_disc); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1040 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1041 if (pcddb_conn != NULL) |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1042 cddb_destroy(pcddb_conn); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1043 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1044 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1045 if (cdng_cfg.debug) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1046 debug("disc has : performer = \"%s\", name = \"%s\", genre = \"%s\"\n", |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1047 trackinfo[0].performer, trackinfo[0].name, trackinfo[0].genre); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1048 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1049 for (trackno = firsttrackno; trackno <= lasttrackno; trackno++) { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1050 debug("track %d has : performer = \"%s\", name = \"%s\", genre = \"%s\", startlsn = %d, endlsn = %d\n", |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1051 trackno, trackinfo[trackno].performer, trackinfo[trackno].name, trackinfo[trackno].genre, trackinfo[trackno].startlsn, trackinfo[trackno].endlsn); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1052 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1053 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1054 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1055 debug("scan_cd ended\n"); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1056 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1057 scan_cd_thread = NULL; |
2433
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
1058 |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
1059 |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
1060 /* add the requested entries to the current playlist */ |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
1061 |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
1062 if (first_trackno_to_add_after_scan == 0 || last_trackno_to_add_after_scan == 0) |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
1063 return NULL; |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
1064 |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
1065 if (first_trackno_to_add_after_scan == -1) |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
1066 first_trackno_to_add_after_scan = firsttrackno; |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
1067 if (last_trackno_to_add_after_scan == -1) |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
1068 last_trackno_to_add_after_scan = lasttrackno; |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
1069 |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
1070 for (trackno = first_trackno_to_add_after_scan; trackno <= last_trackno_to_add_after_scan; trackno++) |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
1071 append_track_to_playlist(trackno); |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
1072 |
60936e29c803
reworked cdaudio-ng to avoid gui blockings as much as possible; the plugin now handles cdda:// URL by adding the whole cd to the playlist - to be used with -e argument from command line; the 'no cd' dialog may be broken
Calin Crisan ccrisan@gmail.com
parents:
2419
diff
changeset
|
1073 return NULL; |
2326
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1074 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
1075 |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
1076 static gint calculate_track_length(gint startlsn, gint endlsn) |
1048 | 1077 { |
1078 return ((endlsn - startlsn + 1) * 1000) / 75; | |
1079 } | |
1080 | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
1081 static gint find_trackno_from_filename(gchar *filename) |
1048 | 1082 { |
2040
997c71881e5b
No need for that long buffer.
Matti Hamalainen <ccr@tnsp.org>
parents:
2038
diff
changeset
|
1083 gchar tracknostr[3]; |
1048 | 1084 if ((filename == NULL) || strlen(filename) <= 6) |
1085 return -1; | |
1086 | |
1087 strncpy(tracknostr, filename + strlen(filename) - 6, 2); | |
1088 tracknostr[2] = '\0'; | |
1089 return strtol(tracknostr, NULL, 10); | |
1090 } | |
1123 | 1091 |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
1092 static void cleanup_on_error() |
1123 | 1093 { |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
1094 if (playing_track != -1) { |
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
1095 playing_track = -1; |
1123 | 1096 } |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
1097 |
1123 | 1098 if (trackinfo != NULL) { |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
1099 g_free(trackinfo); |
1123 | 1100 trackinfo = NULL; |
1101 } | |
1102 } | |
1193 | 1103 |