summaryrefslogtreecommitdiff
path: root/audio.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2002-11-03 11:53:58 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2002-11-03 11:53:58 +0100
commit0a517afdf8c4824d2961c477bda753ca81e800db (patch)
tree6b65f2e9fb1adabc297e3d700608c1f915fc15cf /audio.c
parent2e26a1d607b45bff095e93649d830cf7146be5f1 (diff)
downloadvdr-0a517afdf8c4824d2961c477bda753ca81e800db.tar.gz
vdr-0a517afdf8c4824d2961c477bda753ca81e800db.tar.bz2
Implemented audio plugin interface
Diffstat (limited to 'audio.c')
-rw-r--r--audio.c89
1 files changed, 88 insertions, 1 deletions
diff --git a/audio.c b/audio.c
index 5e7bb73b..c958256d 100644
--- a/audio.c
+++ b/audio.c
@@ -4,8 +4,95 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: audio.c 1.1 2002/06/10 16:30:00 kls Exp $
+ * $Id: audio.c 1.2 2002/11/03 11:53:34 kls Exp $
*/
#include "audio.h"
+#include "stdlib.h"
+// --- cAudio ----------------------------------------------------------------
+
+cAudio::cAudio(void)
+{
+ Audios.Add(this);
+}
+
+cAudio::~cAudio()
+{
+}
+
+// --- cAudios ---------------------------------------------------------------
+
+cAudios Audios;
+
+void cAudios::PlayAudio(const uchar *Data, int Length)
+{
+ for (cAudio *audio = First(); audio; audio = Next(audio))
+ audio->Play(Data, Length);
+}
+
+void cAudios::MuteAudio(bool On)
+{
+ for (cAudio *audio = First(); audio; audio = Next(audio))
+ audio->Mute(On);
+}
+
+void cAudios::ClearAudio(void)
+{
+ for (cAudio *audio = First(); audio; audio = Next(audio))
+ audio->Clear();
+}
+
+// --- cExternalAudio --------------------------------------------------------
+
+cExternalAudio::cExternalAudio(const char *Command)
+{
+ command = strdup(Command);
+ mute = false;
+}
+
+cExternalAudio::~cExternalAudio()
+{
+ free(command);
+}
+
+void cExternalAudio::Play(const uchar *Data, int Length)
+{
+ if (command && !mute) {
+ if (pipe || pipe.Open(command, "w")) {
+ if (Data[0] == 0x00 && Data[1] == 0x00 && Data[2] == 0x01) {
+ if (Data[3] == 0xBD) { // dolby
+ //XXX??? int written = Data[8] + (skipAC3bytes ? 13 : 9); // skips the PES header
+ int written = Data[8] + 9; // skips the PES header
+ Length -= written;
+ while (Length > 0) {
+ int w = fwrite(Data + written, 1, Length, pipe);
+ if (w < 0) {
+ LOG_ERROR;
+ break;
+ }
+ Length -= w;
+ written += w;
+ }
+ }
+ }
+ }
+ else {
+ esyslog("ERROR: can't open pipe to audio command '%s'", command);
+ free(command);
+ command = NULL;
+ }
+ }
+}
+
+void cExternalAudio::Mute(bool On)
+{
+ mute = On;
+ if (mute)
+ Clear();
+}
+
+void cExternalAudio::Clear(void)
+{
+ pipe.Close();
+}