summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorscop <scop>2008-10-25 07:29:20 +0000
committerscop <scop>2008-10-25 07:29:20 +0000
commit4c05f756f80136b5f2e8fcccb97e3fe64eee02bc (patch)
tree5d7a29274dbc8df2aca6d84ba5fa7825752a02f3
parent77b5e865ebd83601d731a11808f7ee329400fc2c (diff)
downloadvdr-plugin-dxr3-4c05f756f80136b5f2e8fcccb97e3fe64eee02bc.tar.gz
vdr-plugin-dxr3-4c05f756f80136b5f2e8fcccb97e3fe64eee02bc.tar.bz2
Error handling improvements; set internal variables only when operations succeed.
-rw-r--r--HISTORY1
-rw-r--r--dxr3interface.c96
2 files changed, 60 insertions, 37 deletions
diff --git a/HISTORY b/HISTORY
index 55dd1ca..e766258 100644
--- a/HISTORY
+++ b/HISTORY
@@ -344,3 +344,4 @@ NOTE: I havent found time to include all of the languages, will be done in pre2
200x-xx-xx: Version x.x.x
- Update Italian translation (Diego Pierotto)
+- Error handling improvements (Ville Skyttä)
diff --git a/dxr3interface.c b/dxr3interface.c
index b1e2441..f42b5b7 100644
--- a/dxr3interface.c
+++ b/dxr3interface.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2002-2004 Kai Möller
* Copyright (C) 2004 Christian Gmeiner
+ * Copyright (C) 2005-2008 Ville Skyttä
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -89,18 +90,23 @@ void cDxr3Interface::Stop()
//! set audio output to analog
void cDxr3Interface::SetAudioAnalog()
{
- int ioval = 0;
+ int ioval = EM8300_AUDIOMODE_ANALOG;
+
Lock();
- if (!m_ExternalReleased && m_audioMode != EM8300_AUDIOMODE_ANALOG)
+ if (!m_ExternalReleased && m_audioMode != ioval)
{
int prevMode = m_audioMode;
- m_audioMode = ioval = EM8300_AUDIOMODE_ANALOG;
isyslog("dxr3: setting analog audio mode");
if (ioctl(m_fdControl, EM8300_IOCTL_SET_AUDIOMODE, &ioval) < 0)
{
esyslog("dxr3: unable to set analog audio mode: %m");
}
+ else
+ {
+ m_audioMode = ioval;
+ }
+
if (prevMode == EM8300_AUDIOMODE_DIGITALAC3)
{
ReOpenAudio();
@@ -114,18 +120,23 @@ void cDxr3Interface::SetAudioAnalog()
//! set audio output to digital pcm
void cDxr3Interface::SetAudioDigitalPCM()
{
- int ioval = 0;
+ int ioval = EM8300_AUDIOMODE_DIGITALPCM;
+
Lock();
- if (!m_ExternalReleased && m_audioMode != EM8300_AUDIOMODE_DIGITALPCM)
+ if (!m_ExternalReleased && m_audioMode != ioval)
{
int prevMode = m_audioMode;
- m_audioMode = ioval = EM8300_AUDIOMODE_DIGITALPCM;
isyslog("dxr3: setting digital PCM audio mode");
if (ioctl(m_fdControl, EM8300_IOCTL_SET_AUDIOMODE, &ioval) < 0)
{
esyslog("dxr3: unable to set digital PCM audio mode: %m");
}
+ else
+ {
+ m_audioMode = ioval;
+ }
+
if (prevMode == EM8300_AUDIOMODE_DIGITALAC3)
{
ReOpenAudio();
@@ -139,17 +150,22 @@ void cDxr3Interface::SetAudioDigitalPCM()
//! set audio output to digital ac3
void cDxr3Interface::SetAudioDigitalAC3()
{
- int ioval = 0;
+ int ioval = EM8300_AUDIOMODE_DIGITALAC3;
+
Lock();
- if (!m_ExternalReleased && m_audioMode != EM8300_AUDIOMODE_DIGITALAC3)
+ if (!m_ExternalReleased && m_audioMode != ioval)
{
- m_audioMode = ioval = EM8300_AUDIOMODE_DIGITALAC3;
isyslog("dxr3: setting digital AC3 audio mode");
if (ioctl(m_fdControl, EM8300_IOCTL_SET_AUDIOMODE, &ioval) < 0)
{
esyslog("dxr3: unable to set AC3 audio mode: %m");
}
+ else
+ {
+ m_audioMode = ioval;
+ }
+
ReOpenAudio();
}
@@ -173,19 +189,17 @@ int cDxr3Interface::GetAudioMode()
//! set audio speed
void cDxr3Interface::SetAudioSpeed(uint32_t speed)
{
- if (m_audioDataRate != speed && speed != UNKNOWN_DATA_RATE)
+ if (!m_ExternalReleased && m_audioMode != EM8300_AUDIOMODE_DIGITALAC3 &&
+ m_audioDataRate != speed && speed != UNKNOWN_DATA_RATE)
{
- if (!m_ExternalReleased)
+ if (ioctl(m_fdAudio, SNDCTL_DSP_SPEED, &speed) < 0)
{
- if (m_audioMode != EM8300_AUDIOMODE_DIGITALAC3)
- {
- if (ioctl(m_fdAudio, SNDCTL_DSP_SPEED, &speed) < 0)
- {
- esyslog("dxr3: unable to set DSP speed to %d: %m", speed);
- }
- }
+ esyslog("dxr3: unable to set DSP speed to %d: %m", speed);
+ }
+ else
+ {
+ m_audioDataRate = speed;
}
- m_audioDataRate = speed;
}
}
@@ -193,20 +207,17 @@ void cDxr3Interface::SetAudioSpeed(uint32_t speed)
//! set number of channels
void cDxr3Interface::SetChannelCount(uint32_t count)
{
- if (m_audioChannelCount != count && count != UNKNOWN_CHANNEL_COUNT)
+ if (!m_ExternalReleased && m_audioMode != EM8300_AUDIOMODE_DIGITALAC3 &&
+ m_audioChannelCount != count && count != UNKNOWN_CHANNEL_COUNT)
{
- if (!m_ExternalReleased)
+ if (ioctl(m_fdAudio, SNDCTL_DSP_STEREO, &count) < 0)
{
- if (m_audioMode != EM8300_AUDIOMODE_DIGITALAC3)
- {
- if (ioctl(m_fdAudio, SNDCTL_DSP_STEREO, &count) < 0)
- {
- esyslog("dxr3: unable to set channel count to %d: %m",
- count);
- }
- }
+ esyslog("dxr3: unable to set channel count to %d: %m", count);
+ }
+ else
+ {
+ m_audioChannelCount = count;
}
- m_audioChannelCount = count;
}
}
@@ -221,8 +232,11 @@ void cDxr3Interface::SetAudioSampleSize(uint32_t sampleSize)
esyslog("dxr3: unable to set audio sample size to %d: %m",
sampleSize);
}
+ else
+ {
+ m_audioSampleSize = sampleSize;
+ }
}
- m_audioSampleSize = sampleSize;
}
// clock
@@ -280,16 +294,20 @@ void cDxr3Interface::SetSpuPts(uint32_t pts)
//! enable subpicture processing of the dxr3
void cDxr3Interface::EnableSPU()
{
- int ioval = 0;
+ int ioval = EM8300_SPUMODE_ON;
+
Lock();
- if (!m_ExternalReleased && m_spuMode != EM8300_SPUMODE_ON)
+ if (!m_ExternalReleased && m_spuMode != ioval)
{
- m_spuMode = ioval = EM8300_SPUMODE_ON;
if (ioctl(m_fdControl, EM8300_IOCTL_SET_SPUMODE, &ioval) < 0)
{
esyslog("dxr3: unable to enable subpicture mode: %m");
}
+ else
+ {
+ m_spuMode = ioval;
+ }
}
Unlock();
@@ -299,16 +317,20 @@ void cDxr3Interface::EnableSPU()
//! disable subpicture proeccesing of the dxr3
void cDxr3Interface::DisableSPU()
{
- int ioval = 0;
+ int ioval = EM8300_SPUMODE_OFF;
+
Lock();
- if (!m_ExternalReleased && m_spuMode != EM8300_SPUMODE_OFF)
+ if (!m_ExternalReleased && m_spuMode != ioval)
{
- m_spuMode = ioval = EM8300_SPUMODE_OFF;
if (ioctl(m_fdControl, EM8300_IOCTL_SET_SPUMODE, &ioval) < 0)
{
esyslog("dxr3: unable to disable subpicture mode: %m");
}
+ else
+ {
+ m_spuMode = ioval;
+ }
}
Unlock();