From a23a5c71b9f7b81573581d986b6b4dbc46883cee Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Wed, 7 Dec 2005 17:44:01 +0000 Subject: [PATCH] Send MAC in login packet, volume read from hw at startup --- Makefile | 9 +++------ audio.cc | 9 +++++++++ command.cc | 2 ++ player.h | 1 + playervideo.cc | 11 +++++++++++ playervideo.h | 1 + tcp.cc | 8 ++++++++ tcp.h | 4 ++++ vdr.cc | 11 +++++++---- vvideolive.cc | 5 +++++ 10 files changed, 51 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 5757f5a..67e569b 100644 --- a/Makefile +++ b/Makefile @@ -13,22 +13,19 @@ 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 playervideo.o playerradio.o messagequeue.o \ + recording.o channel.o message.o playervideo.o messagequeue.o \ view.o vinfo.o vwallpaper.o vvolume.o vrecordinglist.o vlivebanner.o vmute.o \ - vrecordingmenu.o vquestion.o vchannellist.o vwelcome.o vvideolive.o vvideorec.o vradiolive.o \ + vrecordingmenu.o vquestion.o vchannellist.o vwelcome.o vvideolive.o vvideorec.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 +# playerradio.o vradiolive.o .PHONY: clean fresh all install strip default: dev fresh: clean default -temp: - $(CC) -E $(CXXFLAGS_DEV) -c i18n.cc - - vompclient: $(OBJECTS) $(CC) $(LDFLAGS) $(LIBPATHS) $(RELEASE) -o vompclient $(OBJECTS) $(CROSSLIBS) $(LIBS) diff --git a/audio.cc b/audio.cc index 01e53e1..013357f 100644 --- a/audio.cc +++ b/audio.cc @@ -63,6 +63,15 @@ int Audio::init(UCHAR tstreamType) 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; } diff --git a/command.cc b/command.cc index 16f98ec..b44106d 100644 --- a/command.cc +++ b/command.cc @@ -334,6 +334,8 @@ void Command::doJustConnected(VConnect* vconnect) { firstBoot = 0; + logger->log("Command", Log::DEBUG, "Load power after boot"); + config = vdr->configLoad("General", "Power After Boot"); if (config) diff --git a/player.h b/player.h index e0ac06c..0b4f990 100644 --- a/player.h +++ b/player.h @@ -44,6 +44,7 @@ class Player : public Thread, public Callback virtual void skipBackward(int seconds)=0; virtual void setPosition(ULLONG position)=0; virtual void setLength(ULLONG length)=0; + virtual void resyncAudio()=0; #ifdef DEV virtual void test1()=0; virtual void test2()=0; diff --git a/playervideo.cc b/playervideo.cc index 0a326e8..5ef741e 100644 --- a/playervideo.cc +++ b/playervideo.cc @@ -104,6 +104,17 @@ int PlayerVideo::shutdown() return 1; } +void PlayerVideo::resyncAudio() +{ + // Temp hopefully + + if (!initted) return; + + audio->pause(); + usleep(500000); // SYNC + audio->unPause(); +} + int PlayerVideo::play() { if (!initted) return 0; diff --git a/playervideo.h b/playervideo.h index ce8bff7..e9aa4b9 100644 --- a/playervideo.h +++ b/playervideo.h @@ -56,6 +56,7 @@ class PlayerVideo : public Player void call(void*); // for callback interface void setPosition(ULLONG position); void setLength(ULLONG length); + void resyncAudio(); #ifdef DEV void test1(); void test2(); diff --git a/tcp.cc b/tcp.cc index a9939e9..fd5444f 100644 --- a/tcp.cc +++ b/tcp.cc @@ -42,6 +42,14 @@ void TCP::disableTimeout() timeoutEnabled = 0; } +void TCP::getMAC(char* dest) +{ + struct ifreq ifr; + strcpy(ifr.ifr_name, "eth0"); + ioctl(sock, SIOCGIFHWADDR, &ifr); + memcpy(dest, ifr.ifr_hwaddr.sa_data, 6); +} + int TCP::connectTo(char* host, unsigned short port) { sock = socket(PF_INET, SOCK_STREAM, 0); diff --git a/tcp.h b/tcp.h index 5eeed6b..4a024c7 100644 --- a/tcp.h +++ b/tcp.h @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include "defines.h" #include "log.h" @@ -57,6 +59,8 @@ class TCP static void dump(unsigned char* data, ULONG size); + void getMAC(char* dest); // copies 6 MAC bytes to dest + private: int sock; int connected; diff --git a/vdr.cc b/vdr.cc index 6eb863a..b5d1fac 100644 --- a/vdr.cc +++ b/vdr.cc @@ -206,14 +206,17 @@ int VDR::doLogin() { if (!connected) return 0; - UCHAR buffer[8]; + UCHAR buffer[14]; - *(unsigned long*)&buffer[0] = htonl(4); + *(unsigned long*)&buffer[0] = htonl(10); *(unsigned long*)&buffer[4] = htonl(VDR_LOGIN); + tcp->getMAC((char*)&buffer[8]); + + pthread_mutex_lock(&mutex); - int a = tcp->sendPacket(buffer, 8); - if (a != 8) + int a = tcp->sendPacket(buffer, 14); + if (a != 14) { pthread_mutex_unlock(&mutex); return 0; diff --git a/vvideolive.cc b/vvideolive.cc index 5bc2cdb..1b87978 100644 --- a/vvideolive.cc +++ b/vvideolive.cc @@ -72,6 +72,11 @@ int VVideoLive::handleCommand(int command) if (!unavailable) player->play(); // do resync return 2; } + case Remote::PAUSE: + { + if (!unavailable) player->resyncAudio(); // do resync2 + return 2; + } case Remote::STOP: case Remote::BACK: -- 2.39.2