LIBS = -lpthread -lrt
CROSSLIBS = ../jpeg-6b/libjpeg.a
-OBJECTS = main.o command.o log.o remote.o led.o mtd.o video.o audio.o tcp.o directory.o thread.o event.o \
- player.o demuxer.o stream.o vfeed.o afeed.o afeedr.o osd.o surface.o viewman.o vdr.o dsock.o box.o \
- recording.o channel.o message.o messagequeue.o rectimer.o vtimeredit.o voptionsmenu.o \
- view.o vinfo.o vwallpaper.o vvolume.o vrecordinglist.o vlivebanner.o vmute.o vtimerlist.o \
- vrecordingmenu.o vquestion.o vchannellist.o vwelcome.o vvideolive.o vvideorec.o vepgsettimer.o \
- vchannelselect.o vserverselect.o colour.o vconnect.o voptions.o vepg.o region.o \
- widget.o wselectlist.o wjpeg.o wsymbol.o wbutton.o woptionbox.o wtextbox.o i18n.o timers.o \
- fonts/helvB24.o fonts/helvB18.o
+OBJECTS1 = main.o command.o log.o tcp.o dsock.o thread.o timers.o i18n.o \
+ message.o messagequeue.o \
+ vdr.o recording.o channel.o rectimer.o event.o directory.o \
+ player.o demuxer.o stream.o vfeed.o afeed.o afeedr.o \
+ viewman.o box.o region.o colour.o view.o \
+ vinfo.o vwallpaper.o vvolume.o vrecordinglist.o vlivebanner.o vmute.o \
+ vtimerlist.o vtimeredit.o voptionsmenu.o vrecordingmenu.o vquestion.o \
+ vchannellist.o vwelcome.o vvideolive.o vvideorec.o vepgsettimer.o \
+ vchannelselect.o vserverselect.o vconnect.o voptions.o vepg.o \
+ widget.o wselectlist.o wjpeg.o wsymbol.o wbutton.o woptionbox.o wtextbox.o \
+ fonts/helvB24.o fonts/helvB18.o
+
+OBJECTS2 = remote.o led.o mtd.o video.o audio.o osd.o surface.o \
+ audiomvp.o audiowin.o
+
+OBJECTS = $(OBJECTS1) $(OBJECTS2)
.PHONY: clean fresh all install strip
{
if (instance) return;
instance = this;
- initted = 0;
- fdAudio = 0;
- streamType = 0;
- volume = 20;
- muted = 0;
- userMute = 0;
- systemMute = 0;
}
Audio::~Audio()
return instance;
}
-int Audio::init(UCHAR tstreamType)
-{
- if (initted) return 0;
- initted = 1;
-
-// if ((fdAudio = open("/dev/adec_mpg", O_RDWR | O_NONBLOCK)) < 0) return 0;
- if ((fdAudio = open("/dev/adec_mpg", O_WRONLY)) < 0) return 0;
-
- streamType = tstreamType;
-
- if (!initAllParams())
- {
- shutdown();
- return 0;
- }
-
- unMute();
-
- // Set the volume variable to what the hardware is set at now
- int hwvol = -1;
- int hwvolFail = ioctl(fdAudio, AV_GET_AUD_VOLUME, &hwvol);
- if (!hwvolFail)
- {
- volume = 20 - ((hwvol >> 16) & 0xFF);
- if ((volume < 0) || (volume > 20)) volume = 20;
- }
-
- return 1;
-}
-
-int Audio::initAllParams()
-{
- return (setStreamType(streamType) && setChannel() && setSource());
-}
-
-int Audio::shutdown()
-{
- if (!initted) return 0;
- initted = 0;
- close(fdAudio);
- return 1;
-}
-
-int Audio::getFD()
-{
- if (!initted) return 0;
-
- return fdAudio;
-}
-
-int Audio::write(char *buf, int len)
-{
- return 0; //write(fdAudio, buf, len);
-}
-
-int Audio::setStreamType(UCHAR type)
-{
- if (!initted) return 0;
-
- if (ioctl(fdAudio, AV_SET_AUD_STREAMTYPE, type) != 0) return 0;
- return 1;
-}
-
-int Audio::setChannel()
-{
- if (!initted) return 0;
-
- if (ioctl(fdAudio, AV_SET_AUD_CHANNEL, 0) != 0) return 0;
- return 1;
-}
-
-int Audio::setSource()
-{
- if (!initted) return 0;
-
- if (ioctl(fdAudio, AV_SET_AUD_SRC, 1) != 0) return 0;
- return 1;
-}
-
-int Audio::sync()
-{
- if (!initted) return 0;
-
- if (ioctl(fdAudio, AV_SET_AUD_SYNC, 2) != 0) return 0;
- return 1;
-}
-
-int Audio::play()
-{
- if (!initted) return 0;
-
- if (ioctl(fdAudio, AV_SET_AUD_PLAY, 0) != 0) return 0;
- return 1;
-}
-
-int Audio::stop()
-{
- if (!initted) return 0;
-
- if (ioctl(fdAudio, AV_SET_AUD_RESET, 0x11) != 0) return 0;
- return 1;
-}
-
-int Audio::mute()
-{
- if (!initted) return 0;
-
- if (ioctl(fdAudio, AV_SET_AUD_MUTE, 1) != 0) return 0;
- Log::getInstance()->log("Audio", Log::DEBUG, "MUTE MUTE MUTE");
-
- muted = 1;
- return 1;
-}
-
-int Audio::unMute()
-{
- if (!initted) return 0;
-
- if (ioctl(fdAudio, AV_SET_AUD_MUTE, 0) != 0) return 0;
- Log::getInstance()->log("Audio", Log::DEBUG, "MUTE OFF OFF OFF");
-
- muted = 0;
- return 1;
-}
-
-int Audio::pause()
-{
- if (!initted) return 0;
-
- if (ioctl(fdAudio, AV_SET_AUD_PAUSE, 1) != 0) return 0;
- return 1;
-}
-
-int Audio::unPause()
-{
- if (!initted) return 0;
-
- if (ioctl(fdAudio, AV_SET_AUD_UNPAUSE, 1) != 0) return 0;
- return 1;
-}
-
-int Audio::reset()
-{
- if (!initted) return 0;
-//test();
- if (ioctl(fdAudio, AV_SET_AUD_RESET, 0x11) != 0) return 0;
- if (ioctl(fdAudio, AV_SET_AUD_PLAY, 0) != 0) return 0;
-
- doMuting();
- return 1;
-}
-
-int Audio::setVolume(int tvolume)
-{
- // parameter: 0 for silence, 20 for full
- if ((tvolume < 0) || (tvolume > 20)) return 0;
-
-// volume = 2 * (20 - volume);
-// Right, that one was rubbish... 0-10 were almost
-// inaudible, 11-20 did what should have been done
-// over the whole 0-20 range
-
- tvolume = 20 - tvolume;
-
- unsigned long vol = (tvolume << 24) | (tvolume << 16);
-
- Log::getInstance()->log("Audio", Log::DEBUG, "%lx", vol);
- Log::getInstance()->log("Audio", Log::DEBUG, "%i", tvolume);
-
- if (ioctl(fdAudio, AV_SET_AUD_VOLUME, &vol) != 0) return 0;
- return 1;
-}
-
-#ifdef DEV
-int Audio::test()
-{
-// ULLONG stc = 0;
-// return ioctl(fdAudio, AV_SET_AUD_STC, &stc);
-
- aud_sync_parms_t a;
- a.parm1 = 0;
- a.parm2 = 0;
-
- int b = ioctl(fdAudio, AV_SET_AUD_DISABLE_SYNC, &a);
-
-
- printf("Audio sync disable = %i\n", b); // is in a DEV block
-
- return 1;
-
-
-}
-#endif
-
int Audio::volumeUp()
{
if (!initted) return 0;
#define AUDIO_H
#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-
#include "defines.h"
#include "log.h"
-#include "stb.h"
class Audio
{
public:
Audio();
- ~Audio();
+ virtual ~Audio();
static Audio* getInstance();
- int init(UCHAR streamType);
- int shutdown();
+ virtual int init(UCHAR streamType)=0;
+ virtual int shutdown()=0;
+ virtual int setStreamType(UCHAR streamType)=0;
+ virtual int setChannel()=0;
+ virtual int setSource()=0;
+ virtual int sync()=0;
+ virtual int play()=0;
+ virtual int stop()=0;
+ virtual int pause()=0;
+ virtual int unPause()=0;
+ virtual int reset()=0;
+ virtual int setVolume(int volume)=0;
+ virtual int mute()=0;
+ virtual int unMute()=0;
+ virtual int write(char *buf, int len)=0;
+ virtual int getFD()=0; // FIXME MVP specific
- // Audio stream type
- const static UCHAR MPEG2_PES = 2;
- const static UCHAR MPEG1_PES = 3; // unused
-
- int setStreamType(UCHAR streamType);
- int setChannel();
- int setSource();
- int sync();
- int play();
- int stop();
- int pause();
- int unPause();
- int reset();
- int setVolume(int volume);
int volumeUp();
int volumeDown();
int getVolume();
int toggleUserMute();
int systemMuteOn();
int systemMuteOff();
-#ifdef DEV
- int test();
-#endif
+ int doMuting();
- int write(char *buf, int len);
+ // Audio stream type // FIXME these are MVP specific (probably!)
+ const static UCHAR MPEG2_PES = 2;
+ const static UCHAR MPEG1_PES = 3; // unused
- int getFD();
+#ifdef DEV
+ virtual int test()=0;
+#endif
- int doMuting();
- private:
+ protected:
static Audio* instance;
int initted;
- int volume;
- UCHAR muted;
UCHAR userMute;
UCHAR systemMute;
-
- int mute();
- int unMute();
- int initAllParams();
-
- UCHAR streamType;
-
- int fdAudio;
+ UCHAR muted;
+ int volume;
};
#endif
--- /dev/null
+/*
+ Copyright 2004-2005 Chris Tallon
+
+ This file is part of VOMP.
+
+ VOMP is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ VOMP is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with VOMP; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "audiomvp.h"
+
+AudioMVP::AudioMVP()
+{
+ if (instance) return;
+ initted = 0;
+ fdAudio = 0;
+ streamType = 0;
+ volume = 20;
+ muted = 0;
+ userMute = 0;
+ systemMute = 0;
+}
+
+AudioMVP::~AudioMVP()
+{
+}
+
+int AudioMVP::init(UCHAR tstreamType)
+{
+ if (initted) return 0;
+ initted = 1;
+
+// if ((fdAudio = open("/dev/adec_mpg", O_RDWR | O_NONBLOCK)) < 0) return 0;
+ if ((fdAudio = open("/dev/adec_mpg", O_WRONLY)) < 0) return 0;
+
+ streamType = tstreamType;
+
+ if (!initAllParams())
+ {
+ shutdown();
+ return 0;
+ }
+
+ unMute();
+
+ // Set the volume variable to what the hardware is set at now
+ int hwvol = -1;
+ int hwvolFail = ioctl(fdAudio, AV_GET_AUD_VOLUME, &hwvol);
+ if (!hwvolFail)
+ {
+ volume = 20 - ((hwvol >> 16) & 0xFF);
+ if ((volume < 0) || (volume > 20)) volume = 20;
+ }
+
+ return 1;
+}
+
+int AudioMVP::initAllParams()
+{
+ return (setStreamType(streamType) && setChannel() && setSource());
+}
+
+int AudioMVP::shutdown()
+{
+ if (!initted) return 0;
+ initted = 0;
+ close(fdAudio);
+ return 1;
+}
+
+int AudioMVP::getFD()
+{
+ if (!initted) return 0;
+
+ return fdAudio;
+}
+
+int AudioMVP::write(char *buf, int len)
+{
+ return 0; //write(fdAudio, buf, len);
+}
+
+int AudioMVP::setStreamType(UCHAR type)
+{
+ if (!initted) return 0;
+
+ if (ioctl(fdAudio, AV_SET_AUD_STREAMTYPE, type) != 0) return 0;
+ return 1;
+}
+
+int AudioMVP::setChannel()
+{
+ if (!initted) return 0;
+
+ if (ioctl(fdAudio, AV_SET_AUD_CHANNEL, 0) != 0) return 0;
+ return 1;
+}
+
+int AudioMVP::setSource()
+{
+ if (!initted) return 0;
+
+ if (ioctl(fdAudio, AV_SET_AUD_SRC, 1) != 0) return 0;
+ return 1;
+}
+
+int AudioMVP::sync()
+{
+ if (!initted) return 0;
+
+ if (ioctl(fdAudio, AV_SET_AUD_SYNC, 2) != 0) return 0;
+ return 1;
+}
+
+int AudioMVP::play()
+{
+ if (!initted) return 0;
+
+ if (ioctl(fdAudio, AV_SET_AUD_PLAY, 0) != 0) return 0;
+ return 1;
+}
+
+int AudioMVP::stop()
+{
+ if (!initted) return 0;
+
+ if (ioctl(fdAudio, AV_SET_AUD_RESET, 0x11) != 0) return 0;
+ return 1;
+}
+
+int AudioMVP::mute()
+{
+ if (!initted) return 0;
+
+ if (ioctl(fdAudio, AV_SET_AUD_MUTE, 1) != 0) return 0;
+ Log::getInstance()->log("Audio", Log::DEBUG, "MUTE MUTE MUTE");
+
+ muted = 1;
+ return 1;
+}
+
+int AudioMVP::unMute()
+{
+ if (!initted) return 0;
+
+ if (ioctl(fdAudio, AV_SET_AUD_MUTE, 0) != 0) return 0;
+ Log::getInstance()->log("Audio", Log::DEBUG, "MUTE OFF OFF OFF");
+
+ muted = 0;
+ return 1;
+}
+
+int AudioMVP::pause()
+{
+ if (!initted) return 0;
+
+ if (ioctl(fdAudio, AV_SET_AUD_PAUSE, 1) != 0) return 0;
+ return 1;
+}
+
+int AudioMVP::unPause()
+{
+ if (!initted) return 0;
+
+ if (ioctl(fdAudio, AV_SET_AUD_UNPAUSE, 1) != 0) return 0;
+ return 1;
+}
+
+int AudioMVP::reset()
+{
+ if (!initted) return 0;
+//test();
+ if (ioctl(fdAudio, AV_SET_AUD_RESET, 0x11) != 0) return 0;
+ if (ioctl(fdAudio, AV_SET_AUD_PLAY, 0) != 0) return 0;
+
+ doMuting();
+ return 1;
+}
+
+int AudioMVP::setVolume(int tvolume)
+{
+ // parameter: 0 for silence, 20 for full
+ if ((tvolume < 0) || (tvolume > 20)) return 0;
+
+// volume = 2 * (20 - volume);
+// Right, that one was rubbish... 0-10 were almost
+// inaudible, 11-20 did what should have been done
+// over the whole 0-20 range
+
+ tvolume = 20 - tvolume;
+
+ unsigned long vol = (tvolume << 24) | (tvolume << 16);
+
+ Log::getInstance()->log("Audio", Log::DEBUG, "%lx", vol);
+ Log::getInstance()->log("Audio", Log::DEBUG, "%i", tvolume);
+
+ if (ioctl(fdAudio, AV_SET_AUD_VOLUME, &vol) != 0) return 0;
+ return 1;
+}
+
+#ifdef DEV
+int AudioMVP::test()
+{
+// ULLONG stc = 0;
+// return ioctl(fdAudio, AV_SET_AUD_STC, &stc);
+
+ aud_sync_parms_t a;
+ a.parm1 = 0;
+ a.parm2 = 0;
+
+ int b = ioctl(fdAudio, AV_SET_AUD_DISABLE_SYNC, &a);
+
+
+ printf("Audio sync disable = %i\n", b); // is in a DEV block
+
+ return 1;
+
+
+}
+#endif
--- /dev/null
+/*
+ Copyright 2004-2005 Chris Tallon
+
+ This file is part of VOMP.
+
+ VOMP is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ VOMP is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with VOMP; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+// Thanks to Jon Gettler and BtB for all the ioctl information
+
+#ifndef AUDIOMVP_H
+#define AUDIOMVP_H
+
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+#include "defines.h"
+#include "log.h"
+#include "stb.h"
+#include "audio.h"
+
+class AudioMVP : public Audio
+{
+ public:
+ AudioMVP();
+ ~AudioMVP();
+
+ int init(UCHAR streamType);
+ int shutdown();
+
+ int setStreamType(UCHAR streamType);
+ int setChannel();
+ int setSource();
+ int sync();
+ int play();
+ int stop();
+ int pause();
+ int unPause();
+ int reset();
+ int setVolume(int volume);
+ int mute();
+ int unMute();
+ int write(char *buf, int len);
+ int getFD();
+
+#ifdef DEV
+ int test();
+#endif
+
+ private:
+ int initAllParams();
+ UCHAR streamType;
+ int fdAudio;
+};
+
+#endif
--- /dev/null
+/*
+ Copyright 2004-2005 Chris Tallon
+
+ This file is part of VOMP.
+
+ VOMP is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ VOMP is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with VOMP; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "audiowin.h"
+
+AudioWin::AudioWin()
+{
+ if (instance) return;
+ initted = 0;
+}
+
+AudioWin::~AudioWin()
+{
+}
+
+int AudioWin::init(UCHAR tstreamType)
+{
+ if (initted) return 0;
+ initted = 1;
+ return 1;
+}
+
+int AudioWin::shutdown()
+{
+ if (!initted) return 0;
+ initted = 0;
+ return 1;
+}
+
+int AudioWin::getFD()
+{
+ return 0;
+}
+
+int AudioWin::write(char *buf, int len)
+{
+ return 0; //write(fdAudio, buf, len);
+}
+
+int AudioWin::setStreamType(UCHAR type)
+{
+ if (!initted) return 0;
+ return 1;
+}
+
+int AudioWin::setChannel()
+{
+ if (!initted) return 0;
+ return 1;
+}
+
+int AudioWin::setSource()
+{
+ if (!initted) return 0;
+ return 1;
+}
+
+int AudioWin::sync()
+{
+ if (!initted) return 0;
+ return 1;
+}
+
+int AudioWin::play()
+{
+ if (!initted) return 0;
+ return 1;
+}
+
+int AudioWin::stop()
+{
+ if (!initted) return 0;
+ return 1;
+}
+
+int AudioWin::pause()
+{
+ if (!initted) return 0;
+ return 1;
+}
+
+int AudioWin::unPause()
+{
+ if (!initted) return 0;
+ return 1;
+}
+
+int AudioWin::reset()
+{
+ if (!initted) return 0;
+ return 1;
+}
+
+int AudioWin::setVolume(int tvolume)
+{
+ // parameter: 0 for silence, 20 for full
+ if ((tvolume < 0) || (tvolume > 20)) return 0;
+ return 1;
+}
+
+int AudioWin::mute()
+{
+ if (!initted) return 0;
+ return 1;
+}
+
+int AudioWin::unMute()
+{
+ if (!initted) return 0;
+ return 1;
+}
+
+#ifdef DEV
+int AudioWin::test()
+{
+ return 0;
+}
+#endif
--- /dev/null
+/*
+ Copyright 2004-2005 Chris Tallon
+
+ This file is part of VOMP.
+
+ VOMP is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ VOMP is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with VOMP; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+// Thanks to Jon Gettler and BtB for all the ioctl information
+
+#ifndef AUDIOWIN_H
+#define AUDIOWIN_H
+
+#include "defines.h"
+#include "log.h"
+#include "audio.h"
+
+class AudioWin : public Audio
+{
+ public:
+ AudioWin();
+ ~AudioWin();
+
+ int init(UCHAR streamType);
+ int shutdown();
+
+ int setStreamType(UCHAR streamType);
+ int setChannel();
+ int setSource();
+ int sync();
+ int play();
+ int stop();
+ int pause();
+ int unPause();
+ int reset();
+ int setVolume(int volume);
+ int mute();
+ int unMute();
+ int write(char *buf, int len);
+ int getFD();
+
+#ifdef DEV
+ int test();
+#endif
+};
+
+#endif
#include "mtd.h"
#include "timers.h"
#include "video.h"
-#include "audio.h"
#include "vdr.h"
#include "osd.h"
#include "viewman.h"
#include "command.h"
+#ifndef WIN32
+ #include "audiomvp.h"
+#else
+ #include "audiowin.h"
+#endif
+
void sighandler(int signalReceived);
void shutdown(int code);
osd = new Osd();
vdr = new VDR();
video = new Video();
- audio = new Audio();
+#ifndef WIN32
+ audio = new AudioMVP();
+#else
+ audio = new AudioWin();
+#endif
viewman = new ViewMan();
command = new Command();