Some small changes to update list when track changes. Probably a lot

more could be done in terms of having multiple disc views.
This commit is contained in:
rocky
2005-03-21 09:00:20 +00:00
parent 800eef655f
commit 74dc895997

View File

@@ -1,5 +1,5 @@
/* /*
$Id: cdda-player.c,v 1.23 2005/03/19 23:47:53 rocky Exp $ $Id: cdda-player.c,v 1.24 2005/03/21 09:00:20 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -81,6 +81,7 @@ static void display_cdinfo(CdIo_t *p_cdio, track_t i_tracks,
static void get_cddb_track_info(track_t i_track); static void get_cddb_track_info(track_t i_track);
static void get_cdtext_track_info(track_t i_track); static void get_cdtext_track_info(track_t i_track);
static void get_track_info(track_t i_track); static void get_track_info(track_t i_track);
static void list_tracks(bool b_keypress_wait);
CdIo_t *p_cdio; /* libcdio handle */ CdIo_t *p_cdio; /* libcdio handle */
driver_id_t driver_id = DRIVER_DEVICE; driver_id_t driver_id = DRIVER_DEVICE;
@@ -169,6 +170,24 @@ const char key_bindings[][MAX_KEY_STR] = {
" a toggle auto-mode", " a toggle auto-mode",
}; };
typedef enum {
NO_OP=0,
PLAY_CD=1,
PLAY_TRACK=2,
STOP_PLAYING=3,
EJECT_CD=4,
CLOSE_CD=5,
SET_VOLUME=6,
LIST_SUBCHANNEL=7,
LIST_KEYS=8,
LIST_TRACKS=9,
PS_LIST_TRACKS=10,
TOGGLE_PAUSE=11,
EXIT_PROGRAM=12
} cd_operation_t;
cd_operation_t cd_op; /* operation to do in non-interactive mode */
const unsigned int i_key_bindings = sizeof(key_bindings) / MAX_KEY_STR; const unsigned int i_key_bindings = sizeof(key_bindings) / MAX_KEY_STR;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@@ -823,6 +842,8 @@ keypress_wait(CdIo_t *p_cdio)
while (1 != select_wait(b_cd ? 1 : 5)) { while (1 != select_wait(b_cd ? 1 : 5)) {
read_subchannel(p_cdio); read_subchannel(p_cdio);
display_status(true); display_status(true);
if (LIST_TRACKS == cd_op && i_last_display_track != sub.track)
list_tracks(false);
} }
key = getch(); key = getch();
clrtobot(); clrtobot();
@@ -843,7 +864,7 @@ list_keys()
} }
static void static void
list_tracks(void) list_tracks(bool b_keypress_wait)
{ {
track_t i; track_t i;
int i_line=0; int i_line=0;
@@ -871,7 +892,7 @@ list_tracks(void)
mvprintw(i_line++, 0, line); mvprintw(i_line++, 0, line);
clrtoeol(); clrtoeol();
} }
keypress_wait(p_cdio); if (b_keypress_wait) keypress_wait(p_cdio);
} }
} }
@@ -1192,19 +1213,6 @@ ps_list_tracks(void)
printf("showpage\n"); printf("showpage\n");
} }
typedef enum {
PLAY_CD=1,
PLAY_TRACK=2,
STOP_PLAYING=3,
EJECT_CD=4,
CLOSE_CD=5,
SET_VOLUME=6,
LIST_SUBCHANNEL=7,
LIST_KEYS=8,
LIST_TRACKS=9,
PS_LIST_TRACKS=10
} cd_operation_t;
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
@@ -1212,8 +1220,6 @@ main(int argc, char *argv[])
char *h; char *h;
int i_rc = 0; int i_rc = 0;
int i_volume_level = 0; int i_volume_level = 0;
cd_operation_t todo; /* operation to do in non-interactive mode */
psz_program = strrchr(argv[0],'/'); psz_program = strrchr(argv[0],'/');
psz_program = psz_program ? psz_program+1 : argv[0]; psz_program = psz_program ? psz_program+1 : argv[0];
@@ -1241,7 +1247,7 @@ main(int argc, char *argv[])
case 'L': case 'L':
if (NULL != (h = strchr(optarg,'-'))) { if (NULL != (h = strchr(optarg,'-'))) {
i_volume_level = atoi(optarg); i_volume_level = atoi(optarg);
todo = SET_VOLUME; cd_op = SET_VOLUME;
} }
case 't': case 't':
if (NULL != (h = strchr(optarg,'-'))) { if (NULL != (h = strchr(optarg,'-'))) {
@@ -1256,35 +1262,35 @@ main(int argc, char *argv[])
one_track = 1; one_track = 1;
} }
interactive = false; interactive = false;
todo = PLAY_TRACK; cd_op = PLAY_TRACK;
break; break;
case 'p': case 'p':
interactive = false; interactive = false;
todo = PLAY_CD; cd_op = PLAY_CD;
break; break;
case 'l': case 'l':
interactive = false; interactive = false;
todo = LIST_TRACKS; cd_op = LIST_TRACKS;
break; break;
case 'C': case 'C':
interactive = false; interactive = false;
todo = CLOSE_CD; cd_op = CLOSE_CD;
break; break;
case 'c': case 'c':
interactive = false; interactive = false;
todo = PS_LIST_TRACKS; cd_op = PS_LIST_TRACKS;
break; break;
case 's': case 's':
interactive = false; interactive = false;
todo = STOP_PLAYING; cd_op = STOP_PLAYING;
break; break;
case 'S': case 'S':
interactive = false; interactive = false;
todo = LIST_SUBCHANNEL; cd_op = LIST_SUBCHANNEL;
break; break;
case 'e': case 'e':
interactive = false; interactive = false;
todo = EJECT_CD; cd_op = EJECT_CD;
break; break;
case 'k': case 'k':
print_keys(); print_keys();
@@ -1329,7 +1335,7 @@ main(int argc, char *argv[])
fprintf(stderr,"open %s... ", psz_device); fprintf(stderr,"open %s... ", psz_device);
p_cdio = cdio_open (psz_device, driver_id); p_cdio = cdio_open (psz_device, driver_id);
if (!p_cdio && todo != EJECT_CD) { if (!p_cdio && cd_op != EJECT_CD) {
cd_close(psz_device); cd_close(psz_device);
p_cdio = cdio_open (psz_device, driver_id); p_cdio = cdio_open (psz_device, driver_id);
} }
@@ -1346,10 +1352,10 @@ main(int argc, char *argv[])
if (!interactive) { if (!interactive) {
b_sig = true; b_sig = true;
nostop=1; nostop=1;
if (EJECT_CD == todo) { if (EJECT_CD == cd_op) {
i_rc = cd_eject() ? 0 : 1; i_rc = cd_eject() ? 0 : 1;
} else { } else {
switch (todo) { switch (cd_op) {
case PS_LIST_TRACKS: case PS_LIST_TRACKS:
case PLAY_TRACK: case PLAY_TRACK:
read_toc(p_cdio); read_toc(p_cdio);
@@ -1357,7 +1363,7 @@ main(int argc, char *argv[])
break; break;
} }
if (p_cdio) if (p_cdio)
switch (todo) { switch (cd_op) {
case STOP_PLAYING: case STOP_PLAYING:
i_rc = cd_stop(p_cdio) ? 0 : 1; i_rc = cd_stop(p_cdio) ? 0 : 1;
break; break;
@@ -1412,6 +1418,9 @@ main(int argc, char *argv[])
break; break;
case LIST_KEYS: case LIST_KEYS:
case LIST_TRACKS: case LIST_TRACKS:
case TOGGLE_PAUSE:
case EXIT_PROGRAM:
case NO_OP:
break; break;
} }
else { else {
@@ -1438,28 +1447,34 @@ main(int argc, char *argv[])
/* fall through */ /* fall through */
case 'Q': case 'Q':
case 'q': case 'q':
cd_op = EXIT_PROGRAM;
b_sig = true; b_sig = true;
break; break;
case 'E': case 'E':
case 'e': case 'e':
cd_op = EJECT_CD;
cd_eject(); cd_eject();
break; break;
case 's': case 's':
cd_op = STOP_PLAYING;
cd_stop(p_cdio); cd_stop(p_cdio);
break; break;
case 'C': case 'C':
case 'c': case 'c':
cd_op = CLOSE_CD;
cd_close(psz_device); cd_close(psz_device);
break; break;
case 'L': case 'L':
case 'l': case 'l':
list_tracks(); cd_op = LIST_TRACKS;
list_tracks(true);
break; break;
case 'K': case 'K':
case 'k': case 'k':
case 'h': case 'h':
case 'H': case 'H':
case '?': case '?':
cd_op = LIST_KEYS;
list_keys(); list_keys();
break; break;
case ' ': case ' ':