Mercurial > audlegacy-plugins
annotate src/cdaudio-ng/cdaudio-ng.c @ 3116:b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
author | John Lindgren <john.lindgren@tds.net> |
---|---|
date | Sun, 03 May 2009 20:53:48 -0400 |
parents | 7c27b8612b7e |
children | e0b95157aa33 |
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> |
3116
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
5 * Portions copyright (c) 2009 John Lindgren <john.lindgren@tds.net> |
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
|
6 * |
1508
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
7 * 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
|
8 * 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
|
9 * 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
|
10 * |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
11 * 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
|
12 * 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
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
14 * GNU General Public License for more details. |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
15 * |
a99d8f3b3e7c
Fixed some dos/windows eols
Calin Crisan ccrisan@gmail.com
parents:
1490
diff
changeset
|
16 * 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
|
17 * 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
|
18 */ |
1490
032053ca08ab
Add CD menu entry is now created with the ui_plugin_menu functions
Calin Crisan ccrisan@gmail.com
parents:
1482
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 | |
2971
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2576
diff
changeset
|
40 #include <audlegacy/plugin.h> |
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2576
diff
changeset
|
41 #include <audlegacy/i18n.h> |
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2576
diff
changeset
|
42 #include <audlegacy/output.h> |
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2576
diff
changeset
|
43 #include <audlegacy/ui_plugin_menu.h> |
1048 | 44 |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
45 #include "cdaudio-ng.h" |
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
46 #include "configure.h" |
1123 | 47 |
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
|
48 |
2443
32d4d5f7020b
Fixed the nocd-dialog; however it may still crash when starting audacious with cdda:// argument
Calin Crisan ccrisan@gmail.com
parents:
2433
diff
changeset
|
49 cdng_cfg_t cdng_cfg; |
32d4d5f7020b
Fixed the nocd-dialog; however it may still crash when starting audacious with cdda:// argument
Calin Crisan ccrisan@gmail.com
parents:
2433
diff
changeset
|
50 static gint firsttrackno = -1; |
32d4d5f7020b
Fixed the nocd-dialog; however it may still crash when starting audacious with cdda:// argument
Calin Crisan ccrisan@gmail.com
parents:
2433
diff
changeset
|
51 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
|
52 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
|
53 static trackinfo_t *trackinfo = NULL; |
3058
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
54 static volatile gboolean is_paused = FALSE; |
2443
32d4d5f7020b
Fixed the nocd-dialog; however it may still crash when starting audacious with cdda:// argument
Calin Crisan ccrisan@gmail.com
parents:
2433
diff
changeset
|
55 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
|
56 static dae_params_t *pdae_params = NULL; |
2443
32d4d5f7020b
Fixed the nocd-dialog; however it may still crash when starting audacious with cdda:// argument
Calin Crisan ccrisan@gmail.com
parents:
2433
diff
changeset
|
57 static InputPlayback *pglobalinputplayback = NULL; |
3111
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
58 |
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
59 #define N_MENUS 3 |
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
60 static const int menus [N_MENUS] = {AUDACIOUS_MENU_MAIN, |
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
61 AUDACIOUS_MENU_PLAYLIST_ADD, AUDACIOUS_MENU_PLAYLIST_RCLICK}; |
3116
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
62 static GtkWidget * menu_items [N_MENUS]; |
1048 | 63 |
2047 | 64 static void cdaudio_init(void); |
65 static void cdaudio_about(void); | |
66 static void cdaudio_configure(void); | |
67 static gint cdaudio_is_our_file(gchar *filename); | |
68 static void cdaudio_play_file(InputPlayback *pinputplayback); | |
69 static void cdaudio_stop(InputPlayback *pinputplayback); | |
70 static void cdaudio_pause(InputPlayback *pinputplayback, gshort paused); | |
71 static void cdaudio_seek(InputPlayback *pinputplayback, gint time); | |
72 static gint cdaudio_get_time(InputPlayback *pinputplayback); | |
73 static gint cdaudio_get_volume(gint *l, gint *r); | |
74 static gint cdaudio_set_volume(gint l, gint r); | |
75 static void cdaudio_cleanup(void); | |
76 static void cdaudio_get_song_info(gchar *filename, gchar **title, gint *length); | |
2443
32d4d5f7020b
Fixed the nocd-dialog; however it may still crash when starting audacious with cdda:// argument
Calin Crisan ccrisan@gmail.com
parents:
2433
diff
changeset
|
77 static Tuple *cdaudio_get_song_tuple(gchar *filename); |
1048 | 78 |
2443
32d4d5f7020b
Fixed the nocd-dialog; however it may still crash when starting audacious with cdda:// argument
Calin Crisan ccrisan@gmail.com
parents:
2433
diff
changeset
|
79 static Tuple *create_tuple_from_trackinfo_and_filename(gchar *filename); |
2047 | 80 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
|
81 static void *scan_cd(void *nothing); |
3058
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
82 static void refresh_trackinfo(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
|
83 static void append_track_to_playlist(int trackno); |
2443
32d4d5f7020b
Fixed the nocd-dialog; however it may still crash when starting audacious with cdda:// argument
Calin Crisan ccrisan@gmail.com
parents:
2433
diff
changeset
|
84 static gboolean show_noaudiocd_info(); |
2047 | 85 static gint calculate_track_length(gint startlsn, gint endlsn); |
86 static gint find_trackno_from_filename(gchar *filename); | |
87 static void cleanup_on_error(void); | |
1048 | 88 |
89 | |
90 static InputPlugin inputplugin = { | |
1624
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
91 .description = "CD Audio Plugin NG", |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
92 .init = cdaudio_init, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
93 .about = cdaudio_about, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
94 .configure = cdaudio_configure, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
95 .is_our_file = cdaudio_is_our_file, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
96 .play_file = cdaudio_play_file, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
97 .stop = cdaudio_stop, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
98 .pause = cdaudio_pause, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
99 .seek = cdaudio_seek, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
100 .get_time = cdaudio_get_time, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
101 .get_volume = cdaudio_get_volume, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
102 .set_volume = cdaudio_set_volume, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
103 .cleanup = cdaudio_cleanup, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
104 .get_song_info = cdaudio_get_song_info, |
db87d84ed8f3
cdaudio-ng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1529
diff
changeset
|
105 .get_song_tuple = cdaudio_get_song_tuple |
1048 | 106 }; |
107 | |
1098
334afe46961c
[svn] - cdaudio-ng (aka Zither's CD Audio Plugin): convert to plugin API v2
nenolod
parents:
1048
diff
changeset
|
108 InputPlugin *cdaudio_iplist[] = { &inputplugin, NULL }; |
1048 | 109 |
1395
761e17b23e0c
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
1389
diff
changeset
|
110 DECLARE_PLUGIN(cdaudio, NULL, NULL, cdaudio_iplist, NULL, NULL, NULL, NULL, NULL); |
1048 | 111 |
1123 | 112 |
2047 | 113 static void cdaudio_error(const char *fmt, ...) |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
114 { |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
115 va_list ap; |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
116 fprintf(stderr, "cdaudio-ng: "); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
117 va_start(ap, fmt); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
118 vfprintf(stderr, fmt, ap); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
119 va_end(ap); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
120 } |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
121 |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
122 |
2256
dc92a550179e
cddb may use http instead of cddbp now; the global proxy settings are used if enabled
Calin Crisan ccrisan@gmail.com
parents:
2192
diff
changeset
|
123 static void debug(const char *fmt, ...) |
1048 | 124 { |
2046 | 125 if (cdng_cfg.debug) { |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
126 va_list ap; |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
127 fprintf(stderr, "cdaudio-ng: "); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
128 va_start(ap, fmt); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
129 vfprintf(stderr, fmt, ap); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
130 va_end(ap); |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
131 } |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
132 } |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
133 |
3116
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
134 static void remove_tracks (void) |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
135 { |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
136 int pos, length; |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
137 |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
138 length = audacious_drct_pl_get_length (); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
139 |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
140 for (pos = 0; pos < length; ) |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
141 { |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
142 if (cdaudio_is_our_file (audacious_drct_pl_get_file (pos))) |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
143 { |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
144 audacious_drct_pl_delete (pos); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
145 length --; |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
146 } |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
147 else |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
148 pos ++; |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
149 } |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
150 } |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
151 |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
152 static gboolean monitor (void) |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
153 { |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
154 static guint source = 0; |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
155 |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
156 refresh_trackinfo (); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
157 |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
158 if (trackinfo) |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
159 { |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
160 if (! source) |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
161 source = g_timeout_add_seconds (3, (GSourceFunc) monitor, 0); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
162 } |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
163 else |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
164 { |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
165 remove_tracks (); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
166 |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
167 if (source) |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
168 { |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
169 g_source_remove (source); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
170 source = 0; |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
171 } |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
172 } |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
173 |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
174 return 1; |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
175 } |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
176 |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
177 static void add_tracks (void) |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
178 { |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
179 int track; |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
180 |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
181 for (track = firsttrackno; track < lasttrackno; track ++) |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
182 append_track_to_playlist (track); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
183 } |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
184 |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
185 static void start_playback (void) |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
186 { |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
187 int pos, length; |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
188 |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
189 length = audacious_drct_pl_get_length (); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
190 |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
191 for (pos = 0; pos < length; pos ++) |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
192 { |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
193 if (cdaudio_is_our_file (audacious_drct_pl_get_file (pos))) |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
194 { |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
195 audacious_drct_pl_set_pos (pos); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
196 audacious_drct_play (); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
197 break; |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
198 } |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
199 } |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
200 } |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
201 |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
202 static void play_cd (void) |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
203 { |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
204 audacious_drct_stop (); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
205 remove_tracks (); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
206 monitor (); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
207 |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
208 if (trackinfo) |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
209 { |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
210 add_tracks (); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
211 start_playback (); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
212 } |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
213 else |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
214 show_noaudiocd_info (); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
215 } |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
216 |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
217 static void start_monitor (void) |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
218 { |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
219 static char started = 0; |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
220 |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
221 if (! started) |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
222 { |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
223 monitor (); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
224 started = 1; |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
225 } |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
226 } |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
227 |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
228 static void cdaudio_init() |
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
229 { |
2523
769e17da93dd
Replaced s/ConfigDb/mcs_handle_t/g, as per changes in the core.
Matti Hamalainen <ccr@tnsp.org>
parents:
2501
diff
changeset
|
230 mcs_handle_t *db; |
3111
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
231 int count; |
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
232 GtkWidget * item; |
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
|
233 |
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
|
234 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
|
235 |
2384
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
236 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
|
237 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
|
238 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
|
239 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
|
240 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
|
241 cdng_cfg.cddb_server = g_strdup(CDDA_DEFAULT_CDDB_SERVER); |
2558
fb2856249629
now path can be specified for cddb lookup via http.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2523
diff
changeset
|
242 cdng_cfg.cddb_path = g_strdup(""); |
2384
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
243 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
|
244 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
|
245 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
|
246 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
|
247 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
|
248 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
|
249 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
|
250 cdng_cfg.proxy_password = g_strdup(""); |
1125 | 251 |
2044 | 252 if ((db = aud_cfg_db_open()) == NULL) { |
2037 | 253 cdaudio_error("Failed to read configuration.\n"); |
254 cleanup_on_error(); | |
255 return; | |
256 } | |
257 | |
2384
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
258 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
|
259 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
|
260 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
|
261 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
|
262 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
|
263 aud_cfg_db_get_string(db, "CDDA", "cddbserver", &cdng_cfg.cddb_server); |
2558
fb2856249629
now path can be specified for cddb lookup via http.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2523
diff
changeset
|
264 aud_cfg_db_get_string(db, "CDDA", "cddbpath", &cdng_cfg.cddb_path); |
2384
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
265 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
|
266 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
|
267 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
|
268 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
|
269 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
|
270 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
|
271 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
|
272 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
|
273 |
2044 | 274 aud_cfg_db_close(db); |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
275 |
2558
fb2856249629
now path can be specified for cddb lookup via http.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2523
diff
changeset
|
276 debug("use_dae = %d, limitspeed = %d, use_cdtext = %d, use_cddb = %d, cddbserver = \"%s\", cddbpath = \"%s\", cddbport = %d, cddbhttp = %d, device = \"%s\", debug = %d\n", |
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
|
277 cdng_cfg.use_dae, cdng_cfg.limitspeed, cdng_cfg.use_cdtext, cdng_cfg.use_cddb, |
2558
fb2856249629
now path can be specified for cddb lookup via http.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2523
diff
changeset
|
278 cdng_cfg.cddb_server, cdng_cfg.cddb_path, 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
|
279 |
3058
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
280 if (!cdio_init()) { |
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
281 cdaudio_error("Failed to initialize cdio subsystem.\n"); |
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
282 cleanup_on_error(); |
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
283 return; |
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
284 } |
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
285 |
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
286 libcddb_init(); |
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
287 |
3111
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
288 for (count = 0; count < N_MENUS; count ++) |
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
289 { |
3116
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
290 item = gtk_image_menu_item_new_with_label (_ ("Play CD")); |
3111
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
291 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), |
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
292 gtk_image_new_from_stock (GTK_STOCK_CDROM, GTK_ICON_SIZE_MENU)); |
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
293 gtk_widget_show (item); |
3116
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
294 menu_items [count] = item; |
3111
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
295 audacious_menu_plugin_item_add (menus [count], item); |
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
296 g_signal_connect (G_OBJECT (item), "activate", |
3116
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
297 G_CALLBACK (play_cd), NULL); |
3111
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
298 } |
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
|
299 |
1997 | 300 aud_uri_set_plugin("cdda://", &inputplugin); |
1048 | 301 } |
302 | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
303 static void cdaudio_about() |
1048 | 304 { |
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
|
305 debug("cdaudio_about()\n"); |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
306 |
1377
4eb2bacab83a
Added an information box to cdaudio-ng
Calin Crisan ccrisan@gmail.com
parents:
1349
diff
changeset
|
307 static GtkWidget* about_window = NULL; |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
308 |
2047 | 309 if (about_window) { |
2192
e5401b6c4665
the same thing in many plugins
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2150
diff
changeset
|
310 gtk_window_present(GTK_WINDOW(about_window)); |
e5401b6c4665
the same thing in many plugins
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2150
diff
changeset
|
311 } else { |
e5401b6c4665
the same thing in many plugins
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2150
diff
changeset
|
312 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
|
313 _("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
|
314 "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
|
315 "\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
|
316 "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
|
317 "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
|
318 |
2192
e5401b6c4665
the same thing in many plugins
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2150
diff
changeset
|
319 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
|
320 } |
1048 | 321 } |
322 | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
323 static void cdaudio_configure() |
1048 | 324 { |
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
|
325 debug("cdaudio_configure()\n"); |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
326 |
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
327 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
|
328 |
2558
fb2856249629
now path can be specified for cddb lookup via http.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2523
diff
changeset
|
329 debug("use_dae = %d, limitspeed = %d, use_cdtext = %d, use_cddb = %d, cddbserver = \"%s\", cddbpath = \"%s\", cddbport = %d, cddbhttp = %d, device = \"%s\", debug = %d\n", |
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
|
330 cdng_cfg.use_dae, cdng_cfg.limitspeed, cdng_cfg.use_cdtext, cdng_cfg.use_cddb, |
2558
fb2856249629
now path can be specified for cddb lookup via http.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2523
diff
changeset
|
331 cdng_cfg.cddb_server, cdng_cfg.cddb_path, cdng_cfg.cddb_port, cdng_cfg.cddb_http, cdng_cfg.device, cdng_cfg.debug); |
1048 | 332 } |
333 | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
334 static gint cdaudio_is_our_file(gchar *filename) |
1048 | 335 { |
3116
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
336 return ! strncmp (filename, "cdda://", 7); |
1048 | 337 } |
338 | |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
339 |
2046 | 340 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
|
341 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
|
342 { |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
343 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
|
344 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
|
345 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
|
346 } |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
347 |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
348 |
2046 | 349 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
|
350 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
|
351 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
|
352 { |
2046 | 353 t->startlsn = startlsn; |
354 t->endlsn = endlsn; | |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
355 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
|
356 } |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
357 |
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
358 |
2047 | 359 static void cdaudio_play_file(InputPlayback *pinputplayback) |
1125 | 360 { |
1466 | 361 Tuple *tuple; |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
362 gchar *title; |
3111
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
363 |
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
|
364 debug("cdaudio_play_file(\"%s\")\n", pinputplayback->filename); |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
365 |
3116
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
366 start_monitor (); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
367 |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
368 pglobalinputplayback = pinputplayback; |
1125 | 369 |
3058
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
370 gint trackno = find_trackno_from_filename(pinputplayback->filename); |
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
371 |
1389
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
372 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
|
373 debug("no CD information can be retrieved, aborting\n"); |
1389
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
374 pinputplayback->playing = FALSE; |
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
375 return; |
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
376 } |
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
377 |
1123 | 378 if (trackno < firsttrackno || trackno > lasttrackno) { |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
379 cdaudio_error("Track #%d is out of range [%d..%d]\n", trackno, firsttrackno, lasttrackno); |
1123 | 380 cleanup_on_error(); |
1048 | 381 return; |
1123 | 382 } |
1048 | 383 |
384 pinputplayback->playing = TRUE; | |
385 playing_track = trackno; | |
1123 | 386 is_paused = FALSE; |
387 | |
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
|
388 tuple = create_tuple_from_trackinfo_and_filename(pinputplayback->filename); |
2055 | 389 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
|
390 |
1984
489e32a8e106
change some places to use set_params() instead of set_info() directly
William Pitcock <nenolod@atheme.org>
parents:
1976
diff
changeset
|
391 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
|
392 g_free(title); |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
393 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
|
394 |
2046 | 395 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
|
396 debug("using digital audio extraction\n"); |
1125 | 397 |
1123 | 398 if (pdae_params != NULL) { |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
399 cdaudio_error("DAE playback seems to be already started.\n"); |
1123 | 400 return; |
401 } | |
402 | |
403 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
|
404 cdaudio_error("Failed to open audio output.\n"); |
1123 | 405 cleanup_on_error(); |
406 return; | |
407 } | |
408 | |
1349
ab387ad5b88e
Converted to new threading model
Calin Crisan ccrisan@gmail.com
parents:
1341
diff
changeset
|
409 /* |
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
|
410 debug("starting dae thread...\n"); |
1349
ab387ad5b88e
Converted to new threading model
Calin Crisan ccrisan@gmail.com
parents:
1341
diff
changeset
|
411 */ |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
412 pdae_params = (dae_params_t *) g_new(dae_params_t, 1); |
1123 | 413 pdae_params->startlsn = trackinfo[trackno].startlsn; |
414 pdae_params->endlsn = trackinfo[trackno].endlsn; | |
415 pdae_params->pplayback = pinputplayback; | |
416 pdae_params->seektime = -1; | |
417 pdae_params->currlsn = trackinfo[trackno].startlsn; | |
1349
ab387ad5b88e
Converted to new threading model
Calin Crisan ccrisan@gmail.com
parents:
1341
diff
changeset
|
418 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
|
419 pinputplayback->set_pb_ready(pinputplayback); |
1349
ab387ad5b88e
Converted to new threading model
Calin Crisan ccrisan@gmail.com
parents:
1341
diff
changeset
|
420 dae_play_loop(pdae_params); |
1123 | 421 } |
422 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
|
423 debug("not using digital audio extraction\n"); |
1125 | 424 |
1123 | 425 msf_t startmsf, endmsf; |
426 cdio_lsn_to_msf(trackinfo[trackno].startlsn, &startmsf); | |
427 cdio_lsn_to_msf(trackinfo[trackno].endlsn, &endmsf); | |
428 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
|
429 cdaudio_error("Failed to play analog audio CD.\n"); |
1123 | 430 cleanup_on_error(); |
431 return; | |
432 } | |
433 } | |
1048 | 434 } |
435 | |
2047 | 436 static void cdaudio_stop(InputPlayback *pinputplayback) |
1125 | 437 { |
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
|
438 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
|
439 |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
440 pglobalinputplayback = NULL; |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
441 |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
442 if (playing_track == -1) |
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
443 return; |
1125 | 444 |
1303 | 445 if (pinputplayback != NULL) |
446 pinputplayback->playing = FALSE; | |
1048 | 447 playing_track = -1; |
1123 | 448 is_paused = FALSE; |
449 | |
2046 | 450 if (cdng_cfg.use_dae) { |
1123 | 451 if (pdae_params != NULL) { |
452 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
|
453 g_free(pdae_params); |
1123 | 454 pdae_params = NULL; |
455 } | |
456 } | |
457 else { | |
458 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
|
459 cdaudio_error("Failed to stop analog CD.\n"); |
1123 | 460 return; |
461 } | |
462 } | |
1048 | 463 } |
464 | |
2047 | 465 static void cdaudio_pause(InputPlayback *pinputplayback, gshort paused) |
1048 | 466 { |
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
|
467 debug("cdaudio_pause(\"%s\", %d)\n", pinputplayback->filename, paused); |
1125 | 468 |
1048 | 469 if (!is_paused) { |
470 is_paused = TRUE; | |
2046 | 471 if (!cdng_cfg.use_dae) |
1123 | 472 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
|
473 cdaudio_error("Failed to pause analog CD!\n"); |
1123 | 474 cleanup_on_error(); |
475 return; | |
476 } | |
1048 | 477 } |
478 else { | |
479 is_paused = FALSE; | |
2046 | 480 if (!cdng_cfg.use_dae) |
1123 | 481 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
|
482 cdaudio_error("Failed to resume analog CD!\n"); |
1123 | 483 cleanup_on_error(); |
484 return; | |
485 } | |
1048 | 486 } |
487 } | |
488 | |
2047 | 489 static void cdaudio_seek(InputPlayback *pinputplayback, gint time) |
1048 | 490 { |
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
|
491 debug("cdaudio_seek(\"%s\", %d)\n", pinputplayback->filename, time); |
1125 | 492 |
1048 | 493 if (playing_track == -1) |
494 return; | |
495 | |
2046 | 496 if (cdng_cfg.use_dae) { |
1123 | 497 if (pdae_params != NULL) { |
498 pdae_params->seektime = time * 1000; | |
499 } | |
500 } | |
501 else { | |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
502 gint newstartlsn = trackinfo[playing_track].startlsn + time * 75; |
1123 | 503 msf_t startmsf, endmsf; |
504 cdio_lsn_to_msf(newstartlsn, &startmsf); | |
505 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
|
506 |
1123 | 507 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
|
508 cdaudio_error("Failed to play analog CD\n"); |
1123 | 509 cleanup_on_error(); |
510 return; | |
511 } | |
512 } | |
1048 | 513 } |
514 | |
2047 | 515 static gint cdaudio_get_time(InputPlayback *pinputplayback) |
1048 | 516 { |
517 if (playing_track == -1) | |
518 return -1; | |
519 | |
2046 | 520 if (!cdng_cfg.use_dae) { |
1123 | 521 cdio_subchannel_t subchannel; |
522 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
|
523 cdaudio_error("Failed to read analog CD subchannel.\n"); |
1123 | 524 cleanup_on_error(); |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
525 return 0; |
1123 | 526 } |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
527 gint currlsn = cdio_msf_to_lsn(&subchannel.abs_addr); |
1048 | 528 |
2047 | 529 /* 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
|
530 if (currlsn == trackinfo[playing_track].endlsn) |
1123 | 531 return -1; |
532 | |
533 return calculate_track_length(trackinfo[playing_track].startlsn, currlsn); | |
1048 | 534 } |
1123 | 535 else { |
536 if (pdae_params != NULL) | |
1314
b93270e2b7e4
Continuous playing in DAE mode works again
Calin Crisan ccrisan@gmail.com
parents:
1313
diff
changeset
|
537 if (pdae_params->pplayback->playing) |
b93270e2b7e4
Continuous playing in DAE mode works again
Calin Crisan ccrisan@gmail.com
parents:
1313
diff
changeset
|
538 return pinputplayback->output->output_time(); |
b93270e2b7e4
Continuous playing in DAE mode works again
Calin Crisan ccrisan@gmail.com
parents:
1313
diff
changeset
|
539 else |
b93270e2b7e4
Continuous playing in DAE mode works again
Calin Crisan ccrisan@gmail.com
parents:
1313
diff
changeset
|
540 return -1; |
1123 | 541 else |
542 return -1; | |
543 } | |
1048 | 544 } |
545 | |
2047 | 546 static gint cdaudio_get_volume(gint *l, gint *r) |
1048 | 547 { |
2046 | 548 if (cdng_cfg.use_dae) { |
1123 | 549 *l = *r = 0; |
550 return FALSE; | |
551 } | |
552 else { | |
553 cdio_audio_volume_t volume; | |
554 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
|
555 cdaudio_error("Failed to retrieve analog CD volume.\n"); |
1123 | 556 cleanup_on_error(); |
557 *l = *r = 0; | |
558 return FALSE; | |
559 } | |
560 *l = volume.level[0]; | |
561 *r = volume.level[1]; | |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
562 |
1123 | 563 return TRUE; |
564 } | |
1048 | 565 } |
566 | |
2047 | 567 static gint cdaudio_set_volume(gint l, gint r) |
1048 | 568 { |
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
|
569 debug("cdaudio_set_volume(%d, %d)\n", l, r); |
1125 | 570 |
2046 | 571 if (cdng_cfg.use_dae) { |
1123 | 572 return FALSE; |
573 } | |
574 else { | |
575 cdio_audio_volume_t volume = {{l, r, 0, 0}}; | |
576 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
|
577 cdaudio_error("cdaudio-ng: failed to set analog cd volume\n"); |
1123 | 578 cleanup_on_error(); |
579 return FALSE; | |
580 } | |
1382
28766475ca0a
More and more translatable strings... ;-)
Stany HENRY <StrassBoy@gmail.com>
parents:
1378
diff
changeset
|
581 |
1123 | 582 return TRUE; |
583 } | |
1048 | 584 } |
585 | |
2047 | 586 static void cdaudio_cleanup(void) |
1048 | 587 { |
3111
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
588 int count; |
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
589 |
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
|
590 debug("cdaudio_cleanup()\n"); |
1125 | 591 |
3111
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
592 for (count = 0; count < N_MENUS; count ++) |
3116
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
593 audacious_menu_plugin_item_remove (menus [count], menu_items [count]); |
3111
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
594 |
2046 | 595 if (pcdio != NULL) { |
596 if (playing_track != -1 && !cdng_cfg.use_dae) | |
1123 | 597 cdio_audio_stop(pcdio); |
598 cdio_destroy(pcdio); | |
599 pcdio = NULL; | |
600 } | |
601 if (trackinfo != NULL) { | |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
602 g_free(trackinfo); |
1123 | 603 trackinfo = NULL; |
604 } | |
605 playing_track = -1; | |
1282 | 606 |
3058
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
607 libcddb_shutdown(); |
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
608 |
1189
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
609 // todo: destroy the gui |
af5bd4592100
Added cdaudio-ng.h; added a configure dialog
zither@litestep.network
parents:
1125
diff
changeset
|
610 |
2523
769e17da93dd
Replaced s/ConfigDb/mcs_handle_t/g, as per changes in the core.
Matti Hamalainen <ccr@tnsp.org>
parents:
2501
diff
changeset
|
611 mcs_handle_t *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
|
612 aud_cfg_db_set_bool(db, "CDDA", "use_dae", cdng_cfg.use_dae); |
2046 | 613 aud_cfg_db_set_int(db, "CDDA", "limitspeed", cdng_cfg.limitspeed); |
614 aud_cfg_db_set_bool(db, "CDDA", "use_cdtext", cdng_cfg.use_cdtext); | |
615 aud_cfg_db_set_bool(db, "CDDA", "use_cddb", cdng_cfg.use_cddb); | |
616 aud_cfg_db_set_string(db, "CDDA", "cddbserver", cdng_cfg.cddb_server); | |
2558
fb2856249629
now path can be specified for cddb lookup via http.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2523
diff
changeset
|
617 aud_cfg_db_set_string(db, "CDDA", "cddbpath", cdng_cfg.cddb_path); |
2046 | 618 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
|
619 aud_cfg_db_set_bool(db, "CDDA", "cddbhttp", cdng_cfg.cddb_http); |
2046 | 620 aud_cfg_db_set_string(db, "CDDA", "device", cdng_cfg.device); |
621 aud_cfg_db_set_bool(db, "CDDA", "debug", cdng_cfg.debug); | |
2044 | 622 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
|
623 |
1048 | 624 } |
625 | |
2047 | 626 static void cdaudio_get_song_info(gchar *filename, gchar **title, gint *length) |
1048 | 627 { |
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
|
628 debug("cdaudio_get_song_info(\"%s\")\n", filename); |
1125 | 629 |
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
|
630 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
|
631 int trackno = find_trackno_from_filename(filename); |
1125 | 632 |
2046 | 633 if (tuple) { |
2055 | 634 *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
|
635 aud_tuple_free(tuple); |
1466 | 636 tuple = NULL; |
637 } | |
1125 | 638 *length = calculate_track_length(trackinfo[trackno].startlsn, trackinfo[trackno].endlsn); |
1048 | 639 } |
640 | |
2047 | 641 static Tuple *cdaudio_get_song_tuple(gchar *filename) |
1048 | 642 { |
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
|
643 debug("cdaudio_get_song_tuple(\"%s\")\n", filename); |
1125 | 644 |
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
|
645 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
|
646 } |
4ca99d2be90e
Titles are now built using tuples, with the preferred format
Calin Crisan ccrisan@gmail.com
parents:
1340
diff
changeset
|
647 |
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
|
648 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
|
649 { |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
650 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
|
651 |
3116
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
652 start_monitor (); |
3058
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
653 |
1389
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
654 if (trackinfo == NULL) |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
655 return tuple; |
1389
e2754a023ae0
Fixed surprise eject segfault
Calin Crisan ccrisan@gmail.com
parents:
1388
diff
changeset
|
656 |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
657 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
|
658 |
1048 | 659 if (trackno < firsttrackno || trackno > lasttrackno) |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
660 return tuple; |
1048 | 661 |
1466 | 662 if(strlen(trackinfo[trackno].performer)) { |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
663 aud_tuple_associate_string(tuple, FIELD_ARTIST, NULL, trackinfo[trackno].performer); |
1466 | 664 } |
665 if(strlen(trackinfo[0].name)) { | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
666 aud_tuple_associate_string(tuple, FIELD_ALBUM, NULL, trackinfo[0].name); |
1466 | 667 } |
668 if(strlen(trackinfo[trackno].name)) { | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
669 aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, trackinfo[trackno].name); |
1466 | 670 } |
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
|
671 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
672 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
|
673 aud_tuple_associate_string(tuple, -1, "ext", "cda"); //XXX should do? --yaz |
1466 | 674 |
2043
624effc5a687
Clean up the str(n)cpy mess somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
675 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
|
676 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
|
677 |
1466 | 678 if(strlen(trackinfo[trackno].genre)) { |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1967
diff
changeset
|
679 aud_tuple_associate_string(tuple, FIELD_GENRE, NULL, trackinfo[trackno].genre); |
1466 | 680 } |
1048 | 681 //tuple->year = 0; todo: set the year |
682 | |
683 return tuple; | |
684 } | |
685 | |
2995
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
686 static void do_seek (dae_params_t * pdae_params) { |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
687 pdae_params->pplayback->output->flush(pdae_params->seektime); |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
688 pdae_params->currlsn = pdae_params->startlsn + (pdae_params->seektime * 75 / 1000); |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
689 cdio_lseek(pcdio, pdae_params->currlsn * CDIO_CD_FRAMESIZE_RAW, SEEK_SET); |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
690 pdae_params->seektime = -1; |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
691 } |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
692 |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
693 static void do_pause (dae_params_t * pdae_params) { |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
694 pdae_params->pplayback->output->pause (1); |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
695 while (is_paused) { |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
696 if (pdae_params->seektime != -1) |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
697 do_seek (pdae_params); |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
698 g_usleep(50000); |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
699 } |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
700 pdae_params->pplayback->output->pause (0); |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
701 } |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
702 |
2047 | 703 static void dae_play_loop(dae_params_t *pdae_params) |
1123 | 704 { |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
705 guchar *buffer = g_new(guchar, CDDA_DAE_FRAMES * CDIO_CD_FRAMESIZE_RAW); |
1123 | 706 |
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
|
707 debug("dae started\n"); |
1123 | 708 cdio_lseek(pcdio, pdae_params->startlsn * CDIO_CD_FRAMESIZE_RAW, SEEK_SET); |
709 | |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
710 gint read_error_counter = 0; |
1125 | 711 |
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
|
712 //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
|
713 |
1123 | 714 while (pdae_params->pplayback->playing) { |
2995
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
715 if (pdae_params->seektime != -1) |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
716 do_seek (pdae_params); |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
717 if (is_paused) |
1192140d9e3f
Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents:
2971
diff
changeset
|
718 do_pause (pdae_params); |
1123 | 719 |
2047 | 720 /* 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
|
721 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
|
722 |
2047 | 723 /* 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
|
724 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
|
725 sleep(3); |
1123 | 726 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
|
727 } |
1123 | 728 |
729 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
|
730 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
|
731 read_error_counter++; |
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
732 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
|
733 read_error_counter = 0; |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
734 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
|
735 break; |
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
736 } |
1123 | 737 } |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
738 else |
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
739 read_error_counter = 0; |
1123 | 740 |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
741 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
|
742 guchar *bytebuff = buffer; |
1123 | 743 while (pdae_params->pplayback->playing && remainingbytes > 0 && pdae_params->seektime == -1) { |
2047 | 744 /* 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
|
745 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
|
746 |
2047 | 747 /* wait until the output buffer has enough room */ |
1123 | 748 while (pdae_params->pplayback->playing && pdae_params->pplayback->output->buffer_free() < bytecount && pdae_params->seektime == -1) |
2041 | 749 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
|
750 |
2047 | 751 /* play the sound :) */ |
1123 | 752 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
|
753 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
|
754 bytecount, bytebuff, &pdae_params->pplayback->playing); |
1123 | 755 remainingbytes -= bytecount; |
756 bytebuff += bytecount; | |
757 } | |
758 pdae_params->currlsn += lsncount; | |
759 } | |
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
|
760 debug("dae ended\n"); |
1123 | 761 |
762 pdae_params->pplayback->playing = FALSE; | |
1314
b93270e2b7e4
Continuous playing in DAE mode works again
Calin Crisan ccrisan@gmail.com
parents:
1313
diff
changeset
|
763 pdae_params->pplayback->output->close_audio(); |
1123 | 764 is_paused = FALSE; |
765 | |
766 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
|
767 g_free(buffer); |
1123 | 768 } |
769 | |
3111
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
770 static void append_track_to_playlist(int trackno) |
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
|
771 { |
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
|
772 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
|
773 |
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
|
774 g_snprintf(pathname, DEF_STRING_LEN, "%strack%02u.cda", CDDA_DUMMYPATH, trackno); |
3058
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
775 audacious_drct_pl_add_url_string(pathname); |
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
|
776 |
3111
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
777 debug("added track \"%s\" to the playlist\n", pathname); |
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
|
778 } |
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
|
779 |
3116
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
780 static void destroy_dialog (GtkWidget * dialog, gint response, |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
781 GtkWidget * * reference) |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
782 { |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
783 gtk_widget_destroy (dialog); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
784 * reference = 0; |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
785 } |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
786 |
2443
32d4d5f7020b
Fixed the nocd-dialog; however it may still crash when starting audacious with cdda:// argument
Calin Crisan ccrisan@gmail.com
parents:
2433
diff
changeset
|
787 static gboolean show_noaudiocd_info() |
3111
7c27b8612b7e
Show "Add CD" command on playlist "Add" menu (closes #41)
John Lindgren <john.lindgren@tds.net>
parents:
3058
diff
changeset
|
788 { |
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
|
789 const gchar *markup = |
2443
32d4d5f7020b
Fixed the nocd-dialog; however it may still crash when starting audacious with cdda:// argument
Calin Crisan ccrisan@gmail.com
parents:
2433
diff
changeset
|
790 N_("<b><big>No playable CD found.</big></b>\n\n" |
32d4d5f7020b
Fixed the nocd-dialog; however it may still crash when starting audacious with cdda:// argument
Calin Crisan ccrisan@gmail.com
parents:
2433
diff
changeset
|
791 "No CD inserted, or inserted CD is not an audio CD.\n"); |
3116
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
792 static GtkWidget * dialog = 0; |
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
|
793 |
3116
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
794 if (dialog) |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
795 gtk_window_present (GTK_WINDOW (dialog)); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
796 else |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
797 { |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
798 dialog = gtk_message_dialog_new_with_markup (NULL, |
2443
32d4d5f7020b
Fixed the nocd-dialog; however it may still crash when starting audacious with cdda:// argument
Calin Crisan ccrisan@gmail.com
parents:
2433
diff
changeset
|
799 GTK_DIALOG_DESTROY_WITH_PARENT, |
32d4d5f7020b
Fixed the nocd-dialog; however it may still crash when starting audacious with cdda:// argument
Calin Crisan ccrisan@gmail.com
parents:
2433
diff
changeset
|
800 GTK_MESSAGE_ERROR, |
32d4d5f7020b
Fixed the nocd-dialog; however it may still crash when starting audacious with cdda:// argument
Calin Crisan ccrisan@gmail.com
parents:
2433
diff
changeset
|
801 GTK_BUTTONS_OK, |
32d4d5f7020b
Fixed the nocd-dialog; however it may still crash when starting audacious with cdda:// argument
Calin Crisan ccrisan@gmail.com
parents:
2433
diff
changeset
|
802 _(markup)); |
3116
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
803 gtk_widget_show (dialog); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
804 g_signal_connect (G_OBJECT (dialog), "response", |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
805 G_CALLBACK (destroy_dialog), & dialog); |
b09c922c9f34
Finish fixing hang-ups; remove confusing and broken "rescan"; handle no-disk more gracefully.
John Lindgren <john.lindgren@tds.net>
parents:
3111
diff
changeset
|
806 } |
2443
32d4d5f7020b
Fixed the nocd-dialog; however it may still crash when starting audacious with cdda:// argument
Calin Crisan ccrisan@gmail.com
parents:
2433
diff
changeset
|
807 |
32d4d5f7020b
Fixed the nocd-dialog; however it may still crash when starting audacious with cdda:// argument
Calin Crisan ccrisan@gmail.com
parents:
2433
diff
changeset
|
808 return TRUE; |
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
|
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 |
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
|
811 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
|
812 { |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
814 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
816 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 /* 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
|
818 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
|
819 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
|
820 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
|
821 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
|
822 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
|
823 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
826 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
|
827 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
|
828 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
|
829 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
|
830 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
|
831 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
|
832 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
|
833 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
|
834 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
836 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
838 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
|
839 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
|
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 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
|
843 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
|
844 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 /* 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
|
847 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
|
848 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
|
849 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
|
850 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
|
851 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 /* 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
|
854 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
|
855 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
|
856 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
|
857 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
|
858 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
|
859 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
|
860 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
|
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 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
|
863 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
865 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
|
866 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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_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
|
868 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
|
869 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
|
870 "", "", ""); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
873 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
|
874 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
|
875 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
|
876 "", "", ""); |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
879 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
|
880 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
|
881 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
|
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 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 /* 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
|
886 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
|
887 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
|
888 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
|
889 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
|
890 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
|
891 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
893 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
|
894 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
|
895 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
|
896 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
|
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 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 /* 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
|
901 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
|
902 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
|
903 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
|
904 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
|
905 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
|
906 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
|
907 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
|
908 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
|
909 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
|
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 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
|
914 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
|
915 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
|
916 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
|
917 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
|
918 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
|
919 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
921 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
|
922 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
|
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 (!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
|
927 /* 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
|
928 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
|
929 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
|
930 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
|
931 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
|
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 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
|
934 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
|
935 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
|
936 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
|
937 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
|
938 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
|
939 |
2384
0824c92b6132
- fixed a bug which writes TRUE as the default port number.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2326
diff
changeset
|
940 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
|
941 // 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
|
942 |
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
|
943 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
|
944 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
|
945 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
|
946 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
|
947 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
|
948 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
|
949 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
|
950 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
|
951 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
953 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
|
954 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
|
955 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
|
956 cddb_set_server_port(pcddb_conn, cdng_cfg.cddb_port); |
2558
fb2856249629
now path can be specified for cddb lookup via http.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2523
diff
changeset
|
957 cddb_set_http_path_query(pcddb_conn, cdng_cfg.cddb_path); |
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
|
958 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
960 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
|
961 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
|
962 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
965 |
944a510f5200
- now cdaudio-ng calculates discid correctly. closes #165
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2384
diff
changeset
|
966 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
|
967 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
|
968 |
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
|
969 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
|
970 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
|
971 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
|
972 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
|
973 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 cddb_disc_calc_discid(pcddb_disc); |
2453
e3225b9b3e59
Use glib types consistently.
Matti Hamalainen <ccr@tnsp.org>
parents:
2443
diff
changeset
|
976 guint 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
|
977 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
|
978 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a background thread, and 2) cdaudio-ng no longer queries the cddb if cdtext is available
Calin Crisan ccrisan@gmail.com
parents:
2256
diff
changeset
|
979 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
|
980 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
|
981 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
|
982 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
|
983 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
|
984 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
|
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 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
|
987 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
|
988 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
990 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
|
991 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
|
992 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
994 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
|
995 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
997 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
|
998 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
1000 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
|
1001 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
|
1002 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
|
1003 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
|
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 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
|
1006 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
|
1007 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
|
1008 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
|
1009 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
|
1010 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
|
1011 |
2453
e3225b9b3e59
Use glib types consistently.
Matti Hamalainen <ccr@tnsp.org>
parents:
2443
diff
changeset
|
1012 gint 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
|
1013 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
|
1014 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
|
1015 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
|
1016 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
|
1017 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
|
1018 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
|
1019 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
1027 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
|
1028 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
1030 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
|
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 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
|
1034 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
|
1035 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
|
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 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
|
1038 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
|
1039 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
|
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 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 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
|
1044 |
3058
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
1045 return NULL; |
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
1046 } |
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
1047 |
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
1048 static void refresh_trackinfo (void) |
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
1049 { |
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
1050 if (pcdio == NULL || cdio_get_media_changed(pcdio) || ! trackinfo) { |
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
1051 debug(pcdio ? "CD changed, rescanning\n" |
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
1052 : "no CD information, scanning\n"); |
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
1053 scan_cd(NULL); |
2e649bf16ebc
Robust media change handling written by John Wehle, closes bug #46.
Tony Vroon <chainsaw@gentoo.org>
parents:
2995
diff
changeset
|
1054 } |
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
|
1055 } |
854b5fae995e
1) cdaudio-ng tries to fetch cd information in a 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 |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
1057 static gint calculate_track_length(gint startlsn, gint endlsn) |
1048 | 1058 { |
1059 return ((endlsn - startlsn + 1) * 1000) / 75; | |
1060 } | |
1061 | |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
1062 static gint find_trackno_from_filename(gchar *filename) |
1048 | 1063 { |
2040
997c71881e5b
No need for that long buffer.
Matti Hamalainen <ccr@tnsp.org>
parents:
2038
diff
changeset
|
1064 gchar tracknostr[3]; |
1048 | 1065 if ((filename == NULL) || strlen(filename) <= 6) |
1066 return -1; | |
1067 | |
1068 strncpy(tracknostr, filename + strlen(filename) - 6, 2); | |
1069 tracknostr[2] = '\0'; | |
1070 return strtol(tracknostr, NULL, 10); | |
1071 } | |
1123 | 1072 |
1959
3fef1171cd6c
Basic start of cleanup of cdaudio-ng.
Matti Hamalainen <ccr@tnsp.org>
parents:
1958
diff
changeset
|
1073 static void cleanup_on_error() |
1123 | 1074 { |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
1075 if (playing_track != -1) { |
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
1076 playing_track = -1; |
1123 | 1077 } |
1313
28df54b3eaea
Ejecting the cd while playing no longer crashes the player.
Calin Crisan ccrisan@gmail.com
parents:
1303
diff
changeset
|
1078 |
1123 | 1079 if (trackinfo != NULL) { |
1958
2db72dd92ee3
Use glib types and functions in some places.
Matti Hamalainen <ccr@tnsp.org>
parents:
1708
diff
changeset
|
1080 g_free(trackinfo); |
1123 | 1081 trackinfo = NULL; |
1082 } | |
1083 } | |
1193 | 1084 |