summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Gmeiner <christian.gmeiner@gmail.com>2010-02-05 18:52:03 +0100
committerChristian Gmeiner <christian.gmeiner@gmail.com>2010-02-05 18:52:03 +0100
commit0265b061dc0706a450b1037e5c89da50d8dbcb44 (patch)
tree9537352a801ed36183598b40f4b449616717f10c
parentca07a1f8834137c9573c2ceabf0805e900ecbd05 (diff)
downloadvdr-plugin-dxr3-0265b061dc0706a450b1037e5c89da50d8dbcb44.tar.gz
vdr-plugin-dxr3-0265b061dc0706a450b1037e5c89da50d8dbcb44.tar.bz2
there is no need to store SampleContext in pesframe
-rw-r--r--dxr3audio-alsa.c20
-rw-r--r--dxr3audio-alsa.h2
-rw-r--r--dxr3audio-oss.c18
-rw-r--r--dxr3audio-oss.h2
-rw-r--r--dxr3audio.h6
-rw-r--r--dxr3audiodecoder.c6
-rw-r--r--dxr3pesframe.h3
7 files changed, 27 insertions, 30 deletions
diff --git a/dxr3audio-alsa.c b/dxr3audio-alsa.c
index 46e5332..bb06eeb 100644
--- a/dxr3audio-alsa.c
+++ b/dxr3audio-alsa.c
@@ -63,18 +63,18 @@ void cAudioAlsa::releaseDevice()
open = false;
}
-void cAudioAlsa::setup(const SampleContext& ctx)
+void cAudioAlsa::setup(int channels, int samplerate)
{
if (!open)
return;
// look if ctx is different
- if (curContext.channels == ctx.channels && curContext.samplerate == ctx.samplerate) {
+ if (curContext.channels == channels && curContext.samplerate == samplerate) {
return;
}
- dsyslog("[dxr3-audio-alsa] changing samplerate to %d (old %d) ", ctx.samplerate, curContext.samplerate);
- dsyslog("[dxr3-audio-alsa] changing num of channels to %d (old %d)", ctx.channels, curContext.channels);
+ dsyslog("[dxr3-audio-alsa] changing samplerate to %d (old %d) ", samplerate, curContext.samplerate);
+ dsyslog("[dxr3-audio-alsa] changing num of channels to %d (old %d)", channels, curContext.channels);
snd_pcm_hw_params_t* alsa_hwparams;
snd_pcm_sw_params_t* alsa_swparams;
@@ -104,17 +104,17 @@ void cAudioAlsa::setup(const SampleContext& ctx)
}
// set channels
- err = snd_pcm_hw_params_set_channels(handle, alsa_hwparams, ctx.channels);
+ err = snd_pcm_hw_params_set_channels(handle, alsa_hwparams, channels);
if (err < 0) {
- esyslog("[dxr3-audio-alsa] Unable to set channels %d: %s", ctx.channels, snd_strerror(err));
+ esyslog("[dxr3-audio-alsa] Unable to set channels %d: %s", channels, snd_strerror(err));
}
- unsigned int sr = ctx.samplerate;
+ unsigned int sr = samplerate;
// set samplerate
err = snd_pcm_hw_params_set_rate_near(handle, alsa_hwparams, &sr, NULL);
if (err < 0) {
- esyslog("[dxr3-audio-alsa] Unable to set samplerate %d: %s", ctx.samplerate, snd_strerror(err));
+ esyslog("[dxr3-audio-alsa] Unable to set samplerate %d: %s", samplerate, snd_strerror(err));
}
if (snd_pcm_state(handle) == SND_PCM_STATE_RUNNING) {
@@ -180,8 +180,8 @@ void cAudioAlsa::setup(const SampleContext& ctx)
esyslog("[dxr3-audio-alsa] Failed to set sw params: %s", snd_strerror(err));
}
- curContext.channels = ctx.channels;
- curContext.samplerate = ctx.samplerate;
+ curContext.channels = channels;
+ curContext.samplerate = samplerate;
bytesFrame = snd_pcm_format_physical_width(SND_PCM_FORMAT_S16_LE) / 8;
bytesFrame *= curContext.channels;
diff --git a/dxr3audio-alsa.h b/dxr3audio-alsa.h
index 31e4f95..1d6ec59 100644
--- a/dxr3audio-alsa.h
+++ b/dxr3audio-alsa.h
@@ -34,7 +34,7 @@ public:
virtual void openDevice();
virtual void releaseDevice();
- virtual void setup(const SampleContext& ctx);
+ virtual void setup(int channels, int samplerate);
virtual void write(uchar* data, size_t size);
virtual void setDigitalAudio(bool on) {}
diff --git a/dxr3audio-oss.c b/dxr3audio-oss.c
index 6b1e2ad..c13e91d 100644
--- a/dxr3audio-oss.c
+++ b/dxr3audio-oss.c
@@ -52,23 +52,23 @@ void cAudioOss::releaseDevice()
open = false;
}
-void cAudioOss::setup(const SampleContext& ctx)
+void cAudioOss::setup(int channels, int samplerate)
{
if (!open)
return;
// set sample rate
- if (curContext.samplerate != ctx.samplerate) {
- dsyslog("[dxr3-audio-oss] changing samplerate to %d (old %d) ", ctx.samplerate, curContext.samplerate);
- curContext.samplerate = ctx.samplerate;
- CHECK( ioctl(fd, SNDCTL_DSP_SAMPLESIZE, &ctx.samplerate));
+ if (curContext.samplerate != samplerate) {
+ dsyslog("[dxr3-audio-oss] changing samplerate to %d (old %d) ", samplerate, curContext.samplerate);
+ curContext.samplerate = samplerate;
+ CHECK( ioctl(fd, SNDCTL_DSP_SAMPLESIZE, &samplerate));
}
// set channels
- if (curContext.channels != ctx.channels) {
- dsyslog("[dxr3-audio-oss] changing num of channels to %d (old %d)", ctx.channels, curContext.channels);
- curContext.channels = ctx.channels;
- CHECK( ioctl(fd, SNDCTL_DSP_CHANNELS, &ctx.channels));
+ if (curContext.channels != channels) {
+ dsyslog("[dxr3-audio-oss] changing num of channels to %d (old %d)", channels, curContext.channels);
+ curContext.channels = channels;
+ CHECK( ioctl(fd, SNDCTL_DSP_CHANNELS, &channels));
}
}
diff --git a/dxr3audio-oss.h b/dxr3audio-oss.h
index b8ac01e..162d91e 100644
--- a/dxr3audio-oss.h
+++ b/dxr3audio-oss.h
@@ -30,7 +30,7 @@ public:
virtual void openDevice();
virtual void releaseDevice();
- virtual void setup(const SampleContext& ctx);
+ virtual void setup(int channels, int samplerate);
virtual void write(uchar* data, size_t size);
virtual void poll(cPoller &poller);
virtual void setDigitalAudio(bool on);
diff --git a/dxr3audio.h b/dxr3audio.h
index d0617f7..8631d62 100644
--- a/dxr3audio.h
+++ b/dxr3audio.h
@@ -25,8 +25,8 @@
#include <vdr/tools.h> // for uchar
struct SampleContext {
- unsigned int channels;
- unsigned int samplerate;
+ int channels;
+ int samplerate;
};
class iAudio {
@@ -36,7 +36,7 @@ public:
virtual void openDevice() = 0;
virtual void releaseDevice() = 0;
- virtual void setup(const SampleContext& ctx) = 0;
+ virtual void setup(int channels, int samplerate) = 0;
virtual void write(uchar* data, size_t size) = 0;
virtual void poll(cPoller &poller) { (void)poller; }
diff --git a/dxr3audiodecoder.c b/dxr3audiodecoder.c
index 3d15dda..e338ce3 100644
--- a/dxr3audiodecoder.c
+++ b/dxr3audiodecoder.c
@@ -29,6 +29,7 @@
#include <algorithm>
#include "dxr3audiodecoder.h"
#include "dxr3pesframe.h"
+#include "dxr3audio.h"
// ==================================
const int LPCM_HEADER_LENGTH = 7;
@@ -131,10 +132,7 @@ void cDxr3AudioDecoder::decode(cDxr3PesFrame *frame, iAudio *audio)
}
if (out_size) {
- frame->ctx.channels = contextAudio->channels;
- frame->ctx.samplerate = contextAudio->sample_rate;
-
- audio->setup(frame->ctx);
+ audio->setup(contextAudio->channels, contextAudio->sample_rate);
audio->changeVolume((short *)pcmbuf, out_size);
audio->write(pcmbuf, out_size);
}
diff --git a/dxr3pesframe.h b/dxr3pesframe.h
index 6eddd68..5faa175 100644
--- a/dxr3pesframe.h
+++ b/dxr3pesframe.h
@@ -23,7 +23,7 @@
#define _DXR3PESFRAME_H_
#include <assert.h>
-#include "dxr3audio.h"
+#include <stdint.h>
#include "uncopyable.h"
// ==================================
@@ -117,7 +117,6 @@ public:
// needed for audio
uint32_t decodedSize;
int16_t *decoded;
- SampleContext ctx;
private:
ePesDataType m_pesDataType;