Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[mythtv] Added support for USB tuner playback through Live TV.

Ticket #11082. The database is polled prior to playback to see if a dummy CARDID has been set. If so, keep polling until the USB tuner has a lock and the correct Card ID is available. Then continue with starting the Live Stream. Thanks jm_maclaren for the patch.
  • Loading branch information...
commit afe18e73725c66bde621f4bd0643bd96ecac88b2 1 parent 93a569b
David Teirney authored
View
14 lib/cmyth/include/cmyth/cmyth.h
@@ -349,6 +349,9 @@ extern int cmyth_conn_get_protocol_version(cmyth_conn_t conn);
extern char * cmyth_conn_get_setting(cmyth_conn_t conn,
const char* hostname, const char* setting);
+char *
+cmyth_conn_get_setting_unlocked(cmyth_conn_t conn, const char* hostname, const char* setting);
+
/*
* -----------------------------------------------------------------
* Event Operations
@@ -534,12 +537,15 @@ extern int cmyth_livetv_chain_update(cmyth_recorder_t rec, char * chainid,
extern cmyth_recorder_t cmyth_spawn_live_tv(cmyth_recorder_t rec,
unsigned buflen,
int tcp_rcvbuf,
- void (*prog_update_callback)(cmyth_proginfo_t),
- char ** err, char * channame);
+ void (*prog_update_callback)(cmyth_proginfo_t),
+ char ** err,
+ char* channame,
+ cmyth_database_t db);
extern cmyth_recorder_t cmyth_livetv_chain_setup(cmyth_recorder_t old_rec,
int tcp_rcvbuf,
- void (*prog_update_callback)(cmyth_proginfo_t));
+ void (*prog_update_callback)(cmyth_proginfo_t),
+ cmyth_database_t db);
extern int cmyth_livetv_get_block(cmyth_recorder_t rec, char *buf,
unsigned long len);
@@ -559,6 +565,8 @@ extern int cmyth_livetv_keep_recording(cmyth_recorder_t rec, cmyth_database_t db
extern int mythtv_new_livetv(void);
+int cmyth_mysql_check_livetv_recorder_ready(cmyth_database_t db);
+
/*
* -----------------------------------------------------------------
* Database Operations
View
3  lib/cmyth/libcmyth/connection.c
@@ -43,7 +43,6 @@
#include <signal.h>
#include <cmyth_local.h>
-static char * cmyth_conn_get_setting_unlocked(cmyth_conn_t conn, const char* hostname, const char* setting);
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -1368,7 +1367,7 @@ cmyth_conn_get_setting(cmyth_conn_t conn, const char* hostname, const char* sett
return result;
}
-static char *
+char *
cmyth_conn_get_setting_unlocked(cmyth_conn_t conn, const char* hostname, const char* setting)
{
char msg[256];
View
19 lib/cmyth/libcmyth/livetv.c
@@ -517,7 +517,8 @@ cmyth_livetv_chain_update(cmyth_recorder_t rec, char * chainid,
*/
cmyth_recorder_t
cmyth_livetv_chain_setup(cmyth_recorder_t rec, int tcp_rcvbuf,
- void (*prog_update_callback)(cmyth_proginfo_t))
+ void (*prog_update_callback)(cmyth_proginfo_t),
+ cmyth_database_t db)
{
cmyth_recorder_t new_rec = NULL;
@@ -526,6 +527,8 @@ cmyth_livetv_chain_setup(cmyth_recorder_t rec, int tcp_rcvbuf,
cmyth_proginfo_t loc_prog, loc_prog2;
cmyth_file_t ft;
int i=0;
+ int tries = 0;
+ int res;
if (!rec) {
@@ -534,6 +537,12 @@ cmyth_livetv_chain_setup(cmyth_recorder_t rec, int tcp_rcvbuf,
return NULL;
}
+ /* Check that any USB based LiveTV recorder is ready. */
+ while ((res = cmyth_mysql_check_livetv_recorder_ready(db)) == 1 && tries < 20) {
+ tries++;
+ sleep(1);
+ }
+
control = rec->rec_conn;
/* Get the current recording information */
loc_prog = cmyth_recorder_get_cur_proginfo(rec);
@@ -891,12 +900,11 @@ cmyth_livetv_chain_seek(cmyth_recorder_t rec, long long offset, int whence)
offset -= fp->file_req;
}
- pthread_mutex_lock(&mutex);
-
ret = cmyth_file_seek(fp, offset, whence);
PRINTF("** SSDEBUG: new pos %lld after seek command\n", ret);
+ pthread_mutex_lock(&mutex);
cur -= rec->rec_livetv_chain->chain_current;
if (ret >= 0 && cur) {
cmyth_livetv_chain_switch(rec, cur);
@@ -1035,7 +1043,8 @@ cmyth_livetv_get_block(cmyth_recorder_t rec, char *buf, unsigned long len)
cmyth_recorder_t
cmyth_spawn_live_tv(cmyth_recorder_t rec, unsigned buflen, int tcp_rcvbuf,
void (*prog_update_callback)(cmyth_proginfo_t),
- char ** err, char* channame)
+ char ** err, char* channame,
+ cmyth_database_t db)
{
cmyth_recorder_t rtrn = NULL;
int i;
@@ -1048,7 +1057,7 @@ cmyth_spawn_live_tv(cmyth_recorder_t rec, unsigned buflen, int tcp_rcvbuf,
}
if ((rtrn = cmyth_livetv_chain_setup(rec, tcp_rcvbuf,
- prog_update_callback)) == NULL) {
+ prog_update_callback, db)) == NULL) {
*err = "Failed to setup livetv.";
goto err;
}
View
34 lib/cmyth/libcmyth/mythtv_mysql.c
@@ -1189,7 +1189,7 @@ int cmyth_livetv_keep_recording(cmyth_recorder_t rec, cmyth_database_t db, int k
if(keep) {
char* str;
- str = cmyth_conn_get_setting(rec->rec_conn, prog->proginfo_hostname, "AutoExpireDefault");
+ str = cmyth_conn_get_setting_unlocked(rec->rec_conn, prog->proginfo_hostname, "AutoExpireDefault");
if(!str) {
cmyth_dbg(CMYTH_DBG_ERROR, "%s: failed to get AutoExpireDefault\n", __FUNCTION__);
ref_release(prog);
@@ -1259,3 +1259,35 @@ int cmyth_livetv_keep_recording(cmyth_recorder_t rec, cmyth_database_t db, int k
return 1;
}
+int
+cmyth_mysql_check_livetv_recorder_ready(cmyth_database_t db)
+{
+ const char *query_str = "SELECT cardtype FROM tvchain ORDER by starttime DESC LIMIT 1";
+ cmyth_mysql_query_t * query;
+ MYSQL_RES *res = NULL;
+ MYSQL_ROW row;
+ char cardid[32];
+ int ret = 0;
+
+ query = cmyth_mysql_query_create(db, query_str);
+ res = cmyth_mysql_query_result(query);
+ ref_release(query);
+
+ if (res == NULL) {
+ cmyth_dbg(CMYTH_DBG_ERROR, "%s, finalisation/execution of query failed!\n", __FUNCTION__);
+ ret = -1;
+ }
+
+ row = mysql_fetch_row(res);
+ strcpy(cardid, row[0]);
+ if (strcmp(cardid, "DUMMY") == 0) {
+ ret = 1;
+ }
+
+ cmyth_dbg(CMYTH_DBG_DEBUG, "%s, cardtype = %s, strcmp = %d, ret = %d\n", __FUNCTION__,
+ cardid, strcmp(cardid, "DUMMY"), ret);
+
+ mysql_free_result(res);
+
+ return ret;
+}
View
4 xbmc/filesystem/DllLibCMyth.h
@@ -75,7 +75,7 @@ class DllLibCMythInterface
virtual int livetv_keep_recording (cmyth_recorder_t rec, cmyth_database_t db, int keep)=0;
virtual cmyth_recorder_t spawn_live_tv (cmyth_recorder_t rec, unsigned buflen, int tcp_rcvbuf,
void (*prog_update_callback)(cmyth_proginfo_t),
- char ** err, char * channame)=0;
+ char ** err, char * channame, cmyth_database_t db)=0;
virtual int file_get_block (cmyth_file_t file, char *buf, unsigned long len)=0;
virtual int file_select (cmyth_file_t file, struct timeval *timeout)=0;
@@ -175,7 +175,7 @@ class DllLibCMyth : public DllDynamic, DllLibCMythInterface
DEFINE_METHOD3(int, livetv_chain_update, (cmyth_recorder_t p1, char * p2, int p3))
DEFINE_METHOD1(int, livetv_chain_switch_last, (cmyth_recorder_t p1))
DEFINE_METHOD3(int, livetv_keep_recording, (cmyth_recorder_t p1, cmyth_database_t p2, int p3))
- DEFINE_METHOD6(cmyth_recorder_t, spawn_live_tv, (cmyth_recorder_t p1, unsigned p2, int p3, void (*p4)(cmyth_proginfo_t), char ** p5, char * p6))
+ DEFINE_METHOD7(cmyth_recorder_t, spawn_live_tv, (cmyth_recorder_t p1, unsigned p2, int p3, void (*p4)(cmyth_proginfo_t), char ** p5, char * p6, cmyth_database_t p7))
DEFINE_METHOD3(int, file_get_block, (cmyth_file_t p1, char *p2, unsigned long p3))
DEFINE_METHOD2(int, file_select, (cmyth_file_t p1, struct timeval *p2))
View
2  xbmc/filesystem/MythFile.cpp
@@ -249,7 +249,7 @@ bool CMythFile::SetupLiveTV(const CURL& url)
CLog::Log(LOGDEBUG, "%s - recorder isn't running, let's start it", __FUNCTION__);
char* msg = NULL;
- if(!(m_recorder = m_dll->spawn_live_tv(m_recorder, 16*1024, 4096, prog_update_callback, &msg, (char*)channel.c_str())))
+ if(!(m_recorder = m_dll->spawn_live_tv(m_recorder, 16*1024, 4096, prog_update_callback, &msg, (char*)channel.c_str(), m_database)))
{
CLog::Log(LOGERROR, "%s - unable to spawn live tv: %s", __FUNCTION__, msg ? msg : "");
return false;
Please sign in to comment.
Something went wrong with that request. Please try again.