annotate src/cdaudio-ng/cdaudio-ng.c @ 2192:e5401b6c4665

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