aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teirney <david@teirney.net>2012-06-24 13:43:53 +1200
committerDavid Teirney <david@teirney.net>2012-07-09 23:27:24 +1200
commit9c2df1f8f1076905533d4c75a4422f89aa973b99 (patch)
treed48650428bfdd558213049dc9afcfc2a763fe83a
parente60e3ba98a9ba85291b79bad21a0b66e621282ca (diff)
[libcmyth] Pull across changes for cmyth_get_bookmark_mark from upstream.
-rw-r--r--lib/cmyth/include/cmyth/cmyth.h2
-rw-r--r--lib/cmyth/libcmyth/mythtv_mysql.c24
2 files changed, 20 insertions, 6 deletions
diff --git a/lib/cmyth/include/cmyth/cmyth.h b/lib/cmyth/include/cmyth/cmyth.h
index 235c4d5ab1..9f048c0fa4 100644
--- a/lib/cmyth/include/cmyth/cmyth.h
+++ b/lib/cmyth/include/cmyth/cmyth.h
@@ -1058,7 +1058,7 @@ extern cmyth_freespace_t cmyth_freespace_create(void);
extern long long cmyth_get_bookmark(cmyth_conn_t conn, cmyth_proginfo_t prog);
extern int cmyth_get_bookmark_offset(cmyth_database_t db, long chanid, long long mark);
extern int cmyth_update_bookmark_setting(cmyth_database_t, cmyth_proginfo_t);
-extern int cmyth_get_bookmark_mark(cmyth_database_t, cmyth_proginfo_t, long long);
+extern long long cmyth_get_bookmark_mark(cmyth_database_t, cmyth_proginfo_t, long long, int);
extern int cmyth_set_bookmark(cmyth_conn_t conn, cmyth_proginfo_t prog,
long long bookmark);
extern cmyth_commbreaklist_t cmyth_commbreaklist_create(void);
diff --git a/lib/cmyth/libcmyth/mythtv_mysql.c b/lib/cmyth/libcmyth/mythtv_mysql.c
index 3179fad112..14eea2b345 100644
--- a/lib/cmyth/libcmyth/mythtv_mysql.c
+++ b/lib/cmyth/libcmyth/mythtv_mysql.c
@@ -669,20 +669,23 @@ cmyth_update_bookmark_setting(cmyth_database_t db, cmyth_proginfo_t prog)
return (1);
}
-int
-cmyth_get_bookmark_mark(cmyth_database_t db, cmyth_proginfo_t prog, long long bk)
+long long
+cmyth_get_bookmark_mark(cmyth_database_t db, cmyth_proginfo_t prog, long long bk, int mode)
{
MYSQL_RES *res = NULL;
MYSQL_ROW row;
- const char *query_str = "SELECT mark FROM recordedseek WHERE chanid = ? AND offset>= ? AND type = 6 ORDER by MARK ASC LIMIT 0,1;";
+ const char *query_str = "SELECT mark, type FROM recordedseek WHERE chanid = ? AND offset < ? AND (type = 6 or type = 9 ) AND starttime = ? ORDER by MARK DESC LIMIT 0, 1;";
int rows = 0;
- int mark=0;
+ long long mark=0;
+ int rectype = 0;
char start_ts_dt[CMYTH_TIMESTAMP_LEN + 1];
cmyth_mysql_query_t * query;
- cmyth_datetime_to_string(start_ts_dt, prog->proginfo_rec_start_ts);
+ cmyth_timestamp_to_string(start_ts_dt, prog->proginfo_rec_start_ts);
query = cmyth_mysql_query_create(db,query_str);
+
if (cmyth_mysql_query_param_long(query, prog->proginfo_chanId) < 0
|| cmyth_mysql_query_param_long(query, bk) < 0
+ || cmyth_mysql_query_param_str(query, start_ts_dt) < 0
) {
cmyth_dbg(CMYTH_DBG_ERROR,"%s, binding of query parameters failed! Maybe we're out of memory?\n", __FUNCTION__);
ref_release(query);
@@ -696,9 +699,20 @@ cmyth_get_bookmark_mark(cmyth_database_t db, cmyth_proginfo_t prog, long long bk
}
while ((row = mysql_fetch_row(res))) {
mark = safe_atoi(row[0]);
+ rectype = safe_atoi(row[1]);
rows++;
}
mysql_free_result(res);
+
+ if (rectype == 6) {
+ if (mode == 0) {
+ mark=(mark-1)*15;
+ }
+ else if (mode == 1) {
+ mark=(mark-1)*12;
+ }
+ }
+
return mark;
}