From 4dd8f098ac1509dabfb9952b1812d06ef9d31414 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sat, 14 Jul 2007 11:15:57 +0000 Subject: [PATCH] New API function burn_drive_get_best_speed() --- cdrskin/cdrskin_timestamp.h | 2 +- libburn/drive.c | 43 +++++++++++++++++++++++++++++++++++++ libburn/libburn.h | 18 ++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/cdrskin/cdrskin_timestamp.h b/cdrskin/cdrskin_timestamp.h index 27fc1c3..db977aa 100644 --- a/cdrskin/cdrskin_timestamp.h +++ b/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2007.07.12.171832" +#define Cdrskin_timestamP "2007.07.14.111614" diff --git a/libburn/drive.c b/libburn/drive.c index 7a63c7c..0d6bcff 100644 --- a/libburn/drive.c +++ b/libburn/drive.c @@ -1614,6 +1614,49 @@ int burn_drive_get_speedlist(struct burn_drive *d, } +/* ts A70713 : API function */ +int burn_drive_get_best_speed(struct burn_drive *d, int speed_goal, + struct burn_speed_descriptor **best_descr, int flag) +{ + struct burn_speed_descriptor *sd; + int best_speed = 0, best_lba = 0, source= 2, speed; + + if (flag & 2) + source = -1; + + *best_descr = NULL; + for (sd = d->mdata->speed_descriptors; sd != NULL; sd = sd->next) { + if ((source >= 0 && sd->source != source) || + sd->write_speed <= 0) + continue; + if (flag & 1) + speed = sd->read_speed; + else + speed = sd->write_speed; + if (speed_goal <= 0) { + if ((source == 2 && sd->end_lba > best_lba) || + ((source !=2 || sd->end_lba == best_lba) && + speed > best_speed)) { + best_lba = sd->end_lba; + best_speed = speed; + *best_descr = sd; + } + } else if (speed <= speed_goal) { + if (speed > best_speed) { + best_speed = speed; + *best_descr = sd; + } + } + } + if (d->current_is_cd_profile && *best_descr == NULL && ! (flag & 2)) + /* Mode page 2Ah is deprecated in MMC-5 although all known + burners still support it with CD media. */ + return burn_drive_get_best_speed(d, speed_goal, best_descr, + flag | 2); + return (*best_descr != NULL); +} + + /* ts A61226 : API function */ int burn_drive_free_speedlist(struct burn_speed_descriptor **speed_list) { diff --git a/libburn/libburn.h b/libburn/libburn.h index cbe56ed..a207cba 100644 --- a/libburn/libburn.h +++ b/libburn/libburn.h @@ -1555,6 +1555,24 @@ int burn_drive_get_read_speed(struct burn_drive *d); int burn_drive_get_speedlist(struct burn_drive *d, struct burn_speed_descriptor **speed_list); +/* ts A70713 */ +/** Look up the fastest speed descriptor which is not faster than the given + speed_goal. If it is 0, then the fastest one is chosen among the + descriptors with the highest end_lba. Parameter flag decides wether the + speed goal means write speed or read speed. + @param d Drive to query + @param speed_goal Upper limit for speed, 0=search for maximum speed + @param best_descr Result of the search, NULL if no match + @param flag Bitfield for control purposes + bit0= look for best read speed rather than write speed + bit1= look for any source type (else look for source==2 first + and for any other source type only with CD media) + @return >0 indicates a valid best_descr, 0 = no valid best_descr +*/ +int burn_drive_get_best_speed(struct burn_drive *d, int speed_goal, + struct burn_speed_descriptor **best_descr, int flag); + + /* ts A61226 */ /** Dispose a speed descriptor list copy which was obtained by burn_drive_get_speedlist().