Mercurial > audlegacy-plugins
changeset 2384:0824c92b6132
- fixed a bug which writes TRUE as the default port number.
- fixed a bug that a discid had been stored in signed int. (should be uint.)
- fixed a potential memory leak.
- cddb cache has been enabled.
- code for processing config values has been cleaned up.
- removed unnecessary create_tuple_from_trackinfo().
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Wed, 13 Feb 2008 01:29:20 +0900 |
parents | fd19014c3254 |
children | 1a6fc0bdcfe6 |
files | src/cdaudio-ng/cdaudio-ng.c src/cdaudio-ng/cdaudio-ng.h src/cdaudio-ng/configure.c src/cdaudio-ng/configure.h |
diffstat | 4 files changed, 46 insertions(+), 78 deletions(-) [+] |
line wrap: on
line diff
--- a/src/cdaudio-ng/cdaudio-ng.c Tue Feb 12 02:25:03 2008 -0600 +++ b/src/cdaudio-ng/cdaudio-ng.c Wed Feb 13 01:29:20 2008 +0900 @@ -48,15 +48,15 @@ #include "configure.h" -struct cdng_cfg_t cdng_cfg; -static gint firsttrackno = -1; -static gint lasttrackno = -1; +cdng_cfg_t cdng_cfg; +static gint firsttrackno = -1; +static gint lasttrackno = -1; static CdIo_t *pcdio = NULL; static trackinfo_t *trackinfo = NULL; static gboolean is_paused = FALSE; -static gint playing_track = -1; +static gint playing_track = -1; static dae_params_t *pdae_params = NULL; -static InputPlayback *pglobalinputplayback = NULL; +static InputPlayback *pglobalinputplayback = NULL; static GtkWidget *main_menu_item, *playlist_menu_item; static GThread *scan_cd_thread = NULL; @@ -73,11 +73,10 @@ static gint cdaudio_set_volume(gint l, gint r); static void cdaudio_cleanup(void); static void cdaudio_get_song_info(gchar *filename, gchar **title, gint *length); -static Tuple *cdaudio_get_song_tuple(gchar *filename); +static Tuple *cdaudio_get_song_tuple(gchar *filename); static void menu_click(void); -static Tuple *create_tuple_from_trackinfo_and_filename(gchar *filename); -static Tuple *create_tuple_from_trackinfo(int trackno); +static Tuple *create_tuple_from_trackinfo_and_filename(gchar *filename); static void dae_play_loop(dae_params_t *pdae_params); static void *scan_cd(void *nothing); static void scan_cd_threaded(); @@ -139,7 +138,20 @@ debug("cdaudio_init()\n"); - memset(&cdng_cfg, 0, sizeof(cdng_cfg)); + cdng_cfg.use_dae = TRUE; + cdng_cfg.use_cdtext = TRUE; + cdng_cfg.use_cddb = TRUE; + cdng_cfg.debug = FALSE; + cdng_cfg.device = g_strdup(""); + cdng_cfg.cddb_server = g_strdup(CDDA_DEFAULT_CDDB_SERVER); + cdng_cfg.cddb_port = CDDA_DEFAULT_CDDB_PORT; + cdng_cfg.cddb_http = FALSE; + cdng_cfg.limitspeed = CDDA_DEFAULT_LIMIT_SPEED; + cdng_cfg.use_proxy = FALSE; + cdng_cfg.proxy_host = g_strdup(""); + cdng_cfg.proxy_port = CDDA_DEFAULT_PROXY_PORT; + cdng_cfg.proxy_username = g_strdup(""); + cdng_cfg.proxy_password = g_strdup(""); if ((db = aud_cfg_db_open()) == NULL) { cdaudio_error("Failed to read configuration.\n"); @@ -150,42 +162,26 @@ if (!cdio_init()) { cdaudio_error("Failed to initialize cdio subsystem.\n"); cleanup_on_error(); + aud_cfg_db_close(db); return; } libcddb_init(); - /* - if (!aud_cfg_db_get_bool(db, "CDDA", "use_dae", &cdng_cfg.use_dae)) - */ - cdng_cfg.use_dae = TRUE; - - if (!aud_cfg_db_get_int(db, "CDDA", "limitspeed", &cdng_cfg.limitspeed)) - cdng_cfg.limitspeed = 1; - if (!aud_cfg_db_get_bool(db, "CDDA", "use_cdtext", &cdng_cfg.use_cdtext)) - cdng_cfg.use_cdtext = TRUE; - if (!aud_cfg_db_get_bool(db, "CDDA", "use_cddb", &cdng_cfg.use_cddb)) - cdng_cfg.use_cddb = TRUE; - if (!aud_cfg_db_get_string(db, "CDDA", "cddbserver", &cdng_cfg.cddb_server)) - cdng_cfg.cddb_server = g_strdup(CDDA_DEFAULT_CDDB_SERVER); - if (!aud_cfg_db_get_int(db, "CDDA", "cddbport", &cdng_cfg.cddb_port)) - cdng_cfg.cddb_port = CDDA_DEFAULT_CDDB_PORT; - if (!aud_cfg_db_get_bool(db, "CDDA", "cddbhttp", &cdng_cfg.cddb_http)) - cdng_cfg.cddb_port = FALSE; - if (!aud_cfg_db_get_string(db, "CDDA", "device", &cdng_cfg.device)) - cdng_cfg.device = g_strdup(""); - if (!aud_cfg_db_get_bool(db, "CDDA", "debug", &cdng_cfg.debug)) - cdng_cfg.debug = FALSE; - if (!aud_cfg_db_get_bool(db, "audacious", "use_proxy", &cdng_cfg.use_proxy)) - cdng_cfg.use_proxy = FALSE; - if (!aud_cfg_db_get_string(db, "audacious", "proxy_host", &cdng_cfg.proxy_host)) - cdng_cfg.proxy_host = g_strdup(""); - if (!aud_cfg_db_get_int(db, "audacious", "proxy_port", &cdng_cfg.proxy_port)) - cdng_cfg.proxy_port = 8080; - if (!aud_cfg_db_get_string(db, "audacious", "proxy_user", &cdng_cfg.proxy_username)) - cdng_cfg.proxy_username = g_strdup(""); - if (!aud_cfg_db_get_string(db, "audacious", "proxy_pass", &cdng_cfg.proxy_password)) - cdng_cfg.proxy_password = g_strdup(""); + aud_cfg_db_get_bool(db, "CDDA", "use_dae", &cdng_cfg.use_dae); + aud_cfg_db_get_bool(db, "CDDA", "use_cdtext", &cdng_cfg.use_cdtext); + aud_cfg_db_get_bool(db, "CDDA", "use_cddb", &cdng_cfg.use_cddb); + aud_cfg_db_get_bool(db, "CDDA", "debug", &cdng_cfg.debug); + aud_cfg_db_get_string(db, "CDDA", "device", &cdng_cfg.device); + aud_cfg_db_get_string(db, "CDDA", "cddbserver", &cdng_cfg.cddb_server); + aud_cfg_db_get_int(db, "CDDA", "cddbport", &cdng_cfg.cddb_port); + aud_cfg_db_get_bool(db, "CDDA", "cddbhttp", &cdng_cfg.cddb_http); + aud_cfg_db_get_int(db, "CDDA", "limitspeed", &cdng_cfg.limitspeed); + aud_cfg_db_get_bool(db, "audacious", "use_proxy", &cdng_cfg.use_proxy); + aud_cfg_db_get_string(db, "audacious", "proxy_host", &cdng_cfg.proxy_host); + aud_cfg_db_get_int(db, "audacious", "proxy_port", &cdng_cfg.proxy_port); + aud_cfg_db_get_string(db, "audacious", "proxy_user", &cdng_cfg.proxy_username); + aud_cfg_db_get_string(db, "audacious", "proxy_pass", &cdng_cfg.proxy_password); aud_cfg_db_close(db); @@ -565,7 +561,7 @@ // todo: destroy the gui ConfigDb *db = aud_cfg_db_open(); - /*aud_cfg_db_set_bool(db, "CDDA", "use_dae", cdng_cfg.use_dae);*/ + aud_cfg_db_set_bool(db, "CDDA", "use_dae", cdng_cfg.use_dae); aud_cfg_db_set_int(db, "CDDA", "limitspeed", cdng_cfg.limitspeed); aud_cfg_db_set_bool(db, "CDDA", "use_cdtext", cdng_cfg.use_cdtext); aud_cfg_db_set_bool(db, "CDDA", "use_cddb", cdng_cfg.use_cddb); @@ -646,40 +642,6 @@ } } -static Tuple *create_tuple_from_trackinfo(int trackno) -{ - Tuple *tuple = aud_tuple_new(); - - if (trackinfo == NULL) - return tuple; - - if (trackno < firsttrackno || trackno > lasttrackno) - return tuple; - - if(strlen(trackinfo[trackno].performer)) { - aud_tuple_associate_string(tuple, FIELD_ARTIST, NULL, trackinfo[trackno].performer); - } - if(strlen(trackinfo[0].name)) { - aud_tuple_associate_string(tuple, FIELD_ALBUM, NULL, trackinfo[0].name); - } - if(strlen(trackinfo[trackno].name)) { - aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, trackinfo[trackno].name); - } - - aud_tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, trackno); - aud_tuple_associate_string(tuple, -1, "ext", "cda"); //XXX should do? --yaz - - aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, - calculate_track_length(trackinfo[trackno].startlsn, trackinfo[trackno].endlsn)); - - if(strlen(trackinfo[trackno].genre)) { - aud_tuple_associate_string(tuple, FIELD_GENRE, NULL, trackinfo[trackno].genre); - } - //tuple->year = 0; todo: set the year - - return tuple; -} - static Tuple *create_tuple_from_trackinfo_and_filename(gchar *filename) { Tuple *tuple = aud_tuple_new_from_filename(filename); @@ -955,6 +917,9 @@ else { debug("getting CDDB info\n"); + cddb_cache_enable(pcddb_conn); + //cddb_cache_set_dir(pcddb_conn, "~/.cddbslave"); + if (cdng_cfg.use_proxy) { cddb_http_proxy_enable(pcddb_conn); cddb_set_http_proxy_server_name(pcddb_conn, cdng_cfg.proxy_host); @@ -988,7 +953,7 @@ cddb_disc_set_length(pcddb_disc, cdio_audio_get_msf_seconds(&endmsf) - cdio_audio_get_msf_seconds(&startmsf)); cddb_disc_calc_discid(pcddb_disc); - int discid = cddb_disc_get_discid(pcddb_disc); + unsigned int discid = cddb_disc_get_discid(pcddb_disc); debug("CDDB disc id = %x\n", discid); gint matches;
--- a/src/cdaudio-ng/cdaudio-ng.h Tue Feb 12 02:25:03 2008 -0600 +++ b/src/cdaudio-ng/cdaudio-ng.h Wed Feb 13 01:29:20 2008 +0900 @@ -24,8 +24,10 @@ #define DEF_STRING_LEN 256 #define CDDA_DEFAULT "cdda://default" #define CDDA_DAE_FRAMES 8 +#define CDDA_DEFAULT_LIMIT_SPEED 1 #define CDDA_DEFAULT_CDDB_SERVER "freedb.org" #define CDDA_DEFAULT_CDDB_PORT 8880 +#define CDDA_DEFAULT_PROXY_PORT 8080 typedef struct {
--- a/src/cdaudio-ng/configure.c Tue Feb 12 02:25:03 2008 -0600 +++ b/src/cdaudio-ng/configure.c Wed Feb 13 01:29:20 2008 +0900 @@ -7,6 +7,7 @@ #include "configure.h" +extern cdng_cfg_t cdng_cfg; static GtkWidget *configwindow, *okbutton,
--- a/src/cdaudio-ng/configure.h Tue Feb 12 02:25:03 2008 -0600 +++ b/src/cdaudio-ng/configure.h Wed Feb 13 01:29:20 2008 +0900 @@ -2,7 +2,7 @@ #define _CDNG_CONFIGURE_H #include <glib.h> -extern struct cdng_cfg_t { +typedef struct cdng_cfg_t { gboolean use_dae; gboolean use_cdtext; @@ -19,7 +19,7 @@ gchar *proxy_username; gchar *proxy_password; -} cdng_cfg; +} cdng_cfg_t; void configure_create_gui(void);