diff options
author | Paul Gevers <elbrus@debian.org> | 2014-06-19 20:53:07 +0200 |
---|---|---|
committer | Paul Gevers <elbrus@debian.org> | 2014-06-19 20:53:07 +0200 |
commit | e83ec173e9845f5efaa6607d42b04d364e190fe6 (patch) | |
tree | 8036d08999f9e9f882723efae6b1c98825430c21 /src/audiocd.c | |
parent | 37ea6181c7e79b247275bc63ab1ca32f2d473d31 (diff) |
Imported Upstream version 8.6.1
Diffstat (limited to 'src/audiocd.c')
-rw-r--r-- | src/audiocd.c | 108 |
1 files changed, 59 insertions, 49 deletions
diff --git a/src/audiocd.c b/src/audiocd.c index 9eb319d..0286eee 100644 --- a/src/audiocd.c +++ b/src/audiocd.c @@ -18,20 +18,15 @@ */ #include "src/daisy.h" - -extern daisy_t daisy[]; -extern misc_t misc; -extern int get_tag_or_label (xmlTextReaderPtr); - -void get_cddb_info (misc_t misc) +void get_cddb_info (misc_t *misc, daisy_t *daisy) { FILE *r; size_t len = MAX_STR; char *str = NULL, cd[MAX_STR + 1]; int i; - snprintf (cd, MAX_STR, "cddbget -c %s -I -d 2> /dev/null", misc.cd_dev); + snprintf (cd, MAX_STR, "cddbget -c %s -I -d 2> /dev/null", misc->cd_dev); r = popen (cd, "r"); str = malloc (len + 1); i = 0; @@ -41,18 +36,18 @@ void get_cddb_info (misc_t misc) break; if (strcasestr (str, "DTITLE")) { - strncpy (misc.bookmark_title, strchr (str, '=') + 1, MAX_STR - 1); - if (strchr (misc.bookmark_title, '\n')) - *strchr (misc.bookmark_title, '\n') = 0; - if (strchr (misc.bookmark_title, '\r')) - *strchr (misc.bookmark_title, '\r') = 0; - if (strchr (misc.bookmark_title, '/')) - *strchr (misc.bookmark_title, '/') = '-'; - strncpy (misc.daisy_title, strchr (str, '=') + 1, MAX_STR - 1); - if (strchr (misc.daisy_title, '\n')) - *strchr (misc.daisy_title, '\n') = 0; - if (strchr (misc.daisy_title, '\r')) - *strchr (misc.daisy_title, '\r') = 0; + strncpy (misc->bookmark_title, strchr (str, '=') + 1, MAX_STR - 1); + if (strchr (misc->bookmark_title, '\n')) + *strchr (misc->bookmark_title, '\n') = 0; + if (strchr (misc->bookmark_title, '\r')) + *strchr (misc->bookmark_title, '\r') = 0; + if (strchr (misc->bookmark_title, '/')) + *strchr (misc->bookmark_title, '/') = '-'; + strncpy (misc->daisy_title, strchr (str, '=') + 1, MAX_STR - 1); + if (strchr (misc->daisy_title, '\n')) + *strchr (misc->daisy_title, '\n') = 0; + if (strchr (misc->daisy_title, '\r')) + *strchr (misc->daisy_title, '\r') = 0; } // if if (strcasestr (str, "TTITLE")) { @@ -62,7 +57,7 @@ void get_cddb_info (misc_t misc) // some titles are spanned over more lines if (strstr (str, l) == NULL) continue; - strncpy (daisy[i].label, strchr (str, '=') + 1, max_phrase_len - 1); + strncpy (daisy[i].label, strchr (str, '=') + 1, MAX_PHRASE_LEN - 1); if (strchr (daisy[i].label, '\n')) *strchr (daisy[i].label, '\n') = 0; if (strchr (daisy[i].label, '\r')) @@ -74,53 +69,68 @@ void get_cddb_info (misc_t misc) fclose (r); } // get_cddb_info -void get_toc_audiocd (char *dev) +daisy_t *get_number_of_tracks (misc_t *misc) +{ + CdIo_t *cd; + + misc->current = misc->displaying = 0; + if ((cd = cdio_open (misc->cd_dev, DRIVER_UNKNOWN)) == NULL) + { + endwin (); + beep (); + _exit (0); + } // if + misc->total_items = cdio_get_num_tracks (cd); + return (daisy_t *) malloc (misc->total_items * sizeof (daisy_t)); +} // get_number_of_tracks + +void get_toc_audiocd (misc_t *misc, daisy_t *daisy) { char *dir; CdIo_t *cd; track_t first_track; - misc.current = misc.displaying = 0; + misc->current = misc->displaying = 0; dir = ""; - if ((cd = cdio_open (dev, DRIVER_UNKNOWN)) == NULL) + if ((cd = cdio_open (misc->cd_dev, DRIVER_UNKNOWN)) == NULL) { endwin (); beep (); _exit (0); } // if - misc.total_items = cdio_get_num_tracks (cd); + misc->total_items = cdio_get_num_tracks (cd); first_track = cdio_get_first_track_num (cd); - for (misc.current = 0; misc.current < misc.total_items; misc.current++) + for (misc->current = 0; misc->current < misc->total_items; misc->current++) { - snprintf (daisy[misc.current].label, 15, "Track %2d", misc.current + 1); - snprintf (daisy[misc.current].filename, MAX_STR - 1, - "%s/Track %d.wav", dir, misc.current + 1); - daisy[misc.current].first_lsn = cdio_get_track_lsn (cd, - first_track + misc.current); - if (misc.displaying == misc.max_y) - misc.displaying = 1; - daisy[misc.current].x = 1; - daisy[misc.current].screen = misc.current / misc.max_y; - daisy[misc.current].y = - misc.current - daisy[misc.current].screen * misc.max_y; - misc.displaying++; + snprintf (daisy[misc->current].label, 15, "Track %2d", misc->current + 1); + snprintf (daisy[misc->current].filename, MAX_STR - 1, + "%s/Track %d.wav", dir, misc->current + 1); + daisy[misc->current].first_lsn = cdio_get_track_lsn (cd, + first_track + misc->current); + if (misc->displaying == misc->max_y) + misc->displaying = 1; + daisy[misc->current].x = 1; + daisy[misc->current].screen = misc->current / misc->max_y; + daisy[misc->current].y = + misc->current - daisy[misc->current].screen * misc->max_y; + misc->displaying++; } // for - for (misc.current = 0; misc.current < misc.total_items; misc.current++) + for (misc->current = 0; misc->current < misc->total_items; misc->current++) { - daisy[misc.current].last_lsn = daisy[misc.current + 1].first_lsn; - daisy[misc.current].duration = - (daisy[misc.current].last_lsn - daisy[misc.current].first_lsn) / 75; + daisy[misc->current].last_lsn = daisy[misc->current + 1].first_lsn; + daisy[misc->current].duration = + (daisy[misc->current].last_lsn - daisy[misc->current].first_lsn) / 75; } // for - daisy[--misc.current].last_lsn = cdio_get_track_lsn (cd, CDIO_CDROM_LEADOUT_TRACK); - daisy[misc.current].duration = - (daisy[misc.current].last_lsn - daisy[misc.current].first_lsn) / 75; - misc.total_time = (daisy[misc.current].last_lsn - daisy[0].first_lsn) / 75; + daisy[--misc->current].last_lsn = cdio_get_track_lsn (cd, CDIO_CDROM_LEADOUT_TRACK); + daisy[misc->current].duration = + (daisy[misc->current].last_lsn - daisy[misc->current].first_lsn) / 75; + misc->total_time = (daisy[misc->current].last_lsn - daisy[0].first_lsn) / 75; cdio_destroy (cd); - if (misc.cddb_flag != 'n') - get_cddb_info (misc); + if (misc->cddb_flag != 'n') + get_cddb_info (misc, daisy); } // get_toc_audiocd -void set_drive_speed (int drive_speed) +void set_drive_speed (misc_t *misc, int drive_speed) { - cdio_set_speed (misc.p_cdio, drive_speed); + cdio_set_speed (misc->p_cdio, drive_speed); } // set_drive_speed |