Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vdr] Re: bistreamout, SB live and 2.6?
On Thu, Oct 02, 2003 at 09:21:19PM +0200, Gregoire Favre wrote:
> Hello,
>
> I have a problem with bitstreamout under 2.6 with channels that don't
> boradcast in ac3: my decoder goes in Dolby Digital and I don't hear
> anything at all (the spdif out of the DVB isn't connected to the SPDIF
> in of my SBlive). Under 2.4 the receiver stays in Prologic and I can
> hear the sound, it only goes to Dolby Digital with Dolby Digital
> channels.
>
> (I have to use a soundcard because my receiver don't recognize the SPDIF
> out of the DVB card)
>
> Could someone explains me what to change to have the behaviour of the
> 2.4 kernel?
>
> Should I connect the SPDIF of the soundcard o the DVB card, which
> advantage?
... IMHO the problem is within the thread handling of VDR.
Threads with 2.6 do not have a own pid but only a unique thread
id. An you need an uptodate thread lib to have the correct
interface to the new linux thread interface.
Maybe the attached patch helps a bit (untested!!)
Werner
--- thread.c
+++ thread.c Fri Oct 3 20:05:57 2003
@@ -30,7 +30,7 @@
void cCondVar::Wait(cMutex &Mutex)
{
- if (Mutex.locked && Mutex.lockingPid == getpid()) {
+ if (Mutex.locked && Mutex.lockingThread == pthread_self()) {
int locked = Mutex.locked;
Mutex.locked = 0; // have to clear the locked count here, as pthread_cond_wait
// does an implizit unlock of the mutex
@@ -43,7 +43,7 @@
{
bool r = true; // true = condition signaled false = timeout
- if (Mutex.locked && Mutex.lockingPid == getpid()) {
+ if (Mutex.locked && Mutex.lockingThread == pthread_self()) {
struct timeval now; // unfortunately timedwait needs the absolute time, not the delta :-(
if (gettimeofday(&now, NULL) == 0) { // get current time
now.tv_usec += TimeoutMs * 1000; // add the timeout
@@ -61,7 +61,7 @@
if (pthread_cond_timedwait(&cond, &Mutex.mutex, &abstime) == ETIMEDOUT)
r = false;
Mutex.locked = locked;
- Mutex.lockingPid = getpid();
+ Mutex.lockingThread = pthread_self();
}
}
return r;
@@ -83,7 +83,7 @@
cMutex::cMutex(void)
{
- lockingPid = 0;
+ lockingThread = (pthread_t)0;
locked = 0;
pthread_mutex_init(&mutex, NULL);
}
@@ -95,9 +95,9 @@
void cMutex::Lock(void)
{
- if (getpid() != lockingPid || !locked) {
+ if (pthread_self() != lockingThread || !locked) {
pthread_mutex_lock(&mutex);
- lockingPid = getpid();
+ lockingThread = pthread_self();
}
locked++;
}
@@ -105,11 +105,18 @@
void cMutex::Unlock(void)
{
if (!--locked) {
- lockingPid = 0;
+ lockingThread = (pthread_t)0;
pthread_mutex_unlock(&mutex);
}
}
+cMutexLock::IsLocked()
+{
+ if (locked)
+ return true;
+ return false;
+}
+
// --- cThread ---------------------------------------------------------------
// The signal handler is necessary to be able to use SIGIO to wake up any
@@ -125,7 +132,7 @@
signalHandlerInstalled = true;
}
running = false;
- parentPid = threadPid = 0;
+ parentThread = childThread = (pthread_t)0;
}
cThread::~cThread()
@@ -139,7 +146,7 @@
void *cThread::StartThread(cThread *Thread)
{
- Thread->threadPid = getpid();
+ Thread->childThread = pthread_self();
Thread->Action();
return NULL;
}
@@ -148,7 +155,7 @@
{
if (!running) {
running = true;
- parentPid = getpid();
+ parentThread = pthread_self();
pthread_create(&thread, NULL, (void *(*) (void *))&StartThread, (void *)this);
pthread_setschedparam(thread, SCHED_RR, 0);
usleep(10000); // otherwise calling Active() immediately after Start() causes a "pure virtual method called" error
@@ -158,10 +165,10 @@
bool cThread::Active(void)
{
- if (threadPid) {
- if (kill(threadPid, SIGIO) < 0) { // couldn't find another way of checking whether the thread is still running - any ideas?
+ if (childThread) {
+ if (pthread_kill(childThread, SIGIO) < 0) { // couldn't find another way of checking whether the thread is still running - any ideas?
if (errno == ESRCH)
- threadPid = 0;
+ childThread = (pthread_t)0;
else
LOG_ERROR;
}
@@ -180,14 +187,14 @@
return;
usleep(10000);
}
- esyslog("ERROR: thread %d won't end (waited %d seconds) - cancelling it...", threadPid, WaitSeconds);
+ esyslog("ERROR: thread %d won't end (waited %d seconds) - cancelling it...", (int)childThread, WaitSeconds);
}
pthread_cancel(thread);
}
void cThread::WakeUp(void)
{
- kill(parentPid, SIGIO); // makes any waiting 'select()' call return immediately
+ pthread_kill(parentThread, SIGIO); // makes any waiting 'select()' call return immediately
}
bool cThread::EmergencyExit(bool Request)
--- thread.h
+++ thread.h. Fri Oct 3 20:03:42 2003
@@ -32,13 +32,14 @@
friend class cCondVar;
private:
pthread_mutex_t mutex;
- pid_t lockingPid;
+ pthread_t lockingThread;
int locked;
public:
cMutex(void);
~cMutex();
void Lock(void);
void Unlock(void);
+ bool IsLocked(void);
};
class cThread {
@@ -46,7 +47,7 @@
private:
pthread_t thread;
cMutex mutex;
- pid_t parentPid, threadPid;
+ pthread_t parentThread, childThread;
bool running;
static bool emergencyExitRequested;
static bool signalHandlerInstalled;
Home |
Main Index |
Thread Index