[mythtv-users] Debian Pure64
Kyle Rose
krose+mythtv at krose.org
Sun Jan 30 10:39:52 EST 2005
Ed Murray <mail at avenuedesign.net> writes:
> Has anybody got mythtv running successfully on Debian Pure64?
>
> I am running a dual boot Debian i386 sid/ Pure64 setup. I can get myth
> running stably on i386 no trouble. However when running a recompiled
> version on pure64 I run into problems. The server tunes successfully and
> seems to be running correctly. When running the front end I get no
> display when watching TV.
Try this patch and tell me if it works.
Kyle
Index: libs/libmythtv/RingBuffer.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/RingBuffer.cpp,v
retrieving revision 1.105
diff -u -r1.105 RingBuffer.cpp
--- libs/libmythtv/RingBuffer.cpp 30 Sep 2004 10:22:56 -0000 1.105
+++ libs/libmythtv/RingBuffer.cpp 15 Oct 2004 00:47:51 -0000
@@ -486,14 +486,17 @@
numfailures = 0;
commserror = false;
- pthread_rwlock_init(&rwlock, NULL);
+ pthread_mutex_init(&hammerlock, NULL);
+ pthread_cond_init(&hammercond, NULL);
+ readers = 0;
+ writers = 0;
}
RingBuffer::~RingBuffer(void)
{
KillReadAheadThread();
- pthread_rwlock_wrlock(&rwlock);
+ write_lock_wait();
if (remotefile)
{
delete remotefile;
@@ -521,7 +524,7 @@
void RingBuffer::Reset(void)
{
wantseek = true;
- pthread_rwlock_wrlock(&rwlock);
+ write_lock_wait();
wantseek = false;
if (!normalfile)
@@ -548,7 +551,7 @@
numfailures = 0;
commserror = false;
- pthread_rwlock_unlock(&rwlock);
+ unlock();
}
int RingBuffer::safe_read(int fd, void *data, unsigned sz)
@@ -613,12 +616,41 @@
return ret;
}
+void RingBuffer::read_lock_wait()
+{
+ pthread_mutex_lock(&hammerlock);
+ while (writers > 0) {
+ pthread_cond_wait(&hammercond, &hammerlock);
+ }
+ readers++;
+ pthread_mutex_unlock(&hammerlock);
+}
+
+void RingBuffer::write_lock_wait()
+{
+ pthread_mutex_lock(&hammerlock);
+ while (readers > 0 || writers > 0) {
+ pthread_cond_wait(&hammercond, &hammerlock);
+ }
+ writers = 1;
+ pthread_mutex_unlock(&hammerlock);
+}
+
+void RingBuffer::unlock()
+{
+ pthread_mutex_lock(&hammerlock);
+ if (readers > 0) readers--;
+ else writers = 0;
+ pthread_cond_signal(&hammercond);
+ pthread_mutex_unlock(&hammerlock);
+}
+
#define READ_AHEAD_SIZE (10 * 256000)
void RingBuffer::CalcReadAheadThresh(int estbitrate)
{
wantseek = true;
- pthread_rwlock_wrlock(&rwlock);
+ write_lock_wait();
wantseek = false;
fill_threshold = 0;
@@ -650,7 +682,7 @@
if (fill_min == 0)
fill_min = -1;
- pthread_rwlock_unlock(&rwlock);
+ unlock();
}
int RingBuffer::ReadBufFree(void)
@@ -790,7 +822,7 @@
readaheadpaused = false;
- pthread_rwlock_rdlock(&rwlock);
+ read_lock_wait();
if (totfree > readblocksize && !commserror)
{
// limit the read size
@@ -898,7 +930,7 @@
}
availWaitMutex.unlock();
- pthread_rwlock_unlock(&rwlock);
+ unlock();
if ((used >= fill_threshold || wantseek) && !pausereadthread)
usleep(500);
@@ -1009,7 +1041,7 @@
int RingBuffer::Read(void *buf, int count)
{
- pthread_rwlock_rdlock(&rwlock);
+ read_lock_wait();
int ret = -1;
if (normalfile)
@@ -1065,7 +1097,7 @@
{
if (stopreads)
{
- pthread_rwlock_unlock(&rwlock);
+ unlock();
return 0;
}
@@ -1084,7 +1116,7 @@
if (stopreads)
{
availWaitMutex.unlock();
- pthread_rwlock_unlock(&rwlock);
+ unlock();
return 0;
}
}
@@ -1115,7 +1147,7 @@
}
}
- pthread_rwlock_unlock(&rwlock);
+ unlock();
return ret;
}
@@ -1123,11 +1155,11 @@
{
bool ret = false;
int used, free;
- pthread_rwlock_rdlock(&rwlock);
+ read_lock_wait();
if (!tfw)
{
- pthread_rwlock_unlock(&rwlock);
+ unlock();
return ret;
}
@@ -1136,7 +1168,7 @@
ret = (used * 5 > free);
- pthread_rwlock_unlock(&rwlock);
+ unlock();
return ret;
}
@@ -1144,11 +1176,11 @@
{
int ret = -1;
- pthread_rwlock_rdlock(&rwlock);
+ read_lock_wait();
if (!tfw)
{
- pthread_rwlock_unlock(&rwlock);
+ unlock();
return ret;
}
@@ -1197,7 +1229,7 @@
availWaitMutex.unlock();
}
- pthread_rwlock_unlock(&rwlock);
+ unlock();
return ret;
}
@@ -1214,7 +1246,7 @@
long long RingBuffer::Seek(long long pos, int whence)
{
wantseek = true;
- pthread_rwlock_wrlock(&rwlock);
+ write_lock_wait();
wantseek = false;
long long ret = -1;
@@ -1278,7 +1310,7 @@
if (readaheadrunning)
ResetReadAhead(readpos);
- pthread_rwlock_unlock(&rwlock);
+ unlock();
return ret;
}
Index: libs/libmythtv/RingBuffer.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/RingBuffer.h,v
retrieving revision 1.39
diff -u -r1.39 RingBuffer.h
--- libs/libmythtv/RingBuffer.h 6 Jul 2004 03:46:12 -0000 1.39
+++ libs/libmythtv/RingBuffer.h 15 Oct 2004 00:47:51 -0000
@@ -100,7 +100,13 @@
bool stopreads;
- pthread_rwlock_t rwlock;
+ pthread_mutex_t hammerlock;
+ pthread_cond_t hammercond;
+ int readers;
+ int writers;
+ void read_lock_wait();
+ void write_lock_wait();
+ void unlock();
int recorder_num;
RemoteEncoder *remoteencoder;
More information about the mythtv-users
mailing list