From 898a8985746efb429d721f42c0d380a59be98828 Mon Sep 17 00:00:00 2001 From: mrwastl Date: Sat, 1 Oct 2011 13:16:40 +0200 Subject: support added for audio track selection / audio channel display (new tokens: 'AudioTrackItem', 'AudioTrackCurrent', 'IsAudioTrackCurrent', 'AudioChannel'); skins: support for new display section 'audio'; default.skin: bug fixes, enhancements --- display.c | 38 +++++++++++++++++++++ display.h | 1 + graphlcd/skins/default/default.skin | 67 +++++++++++++++++++++++++++---------- skinconfig.c | 66 ++++++++++++++++++++++++++++++++++++ state.c | 46 +++++++++++++++++++++++++ state.h | 12 +++++++ 6 files changed, 213 insertions(+), 17 deletions(-) diff --git a/display.c b/display.c index 79cb236..ba96d9c 100644 --- a/display.c +++ b/display.c @@ -50,6 +50,7 @@ cGraphLCDDisplay::cGraphLCDDisplay() LastTimeDisplayMode = 0; mShowVolume = false; + mShowAudio = false; nCurrentBrightness = -1; LastTimeBrightness = 0; @@ -226,6 +227,35 @@ void cGraphLCDDisplay::Action(void) } } + if (GraphLCDSetup.ShowMenu) + { + tAudioState audio; + audio = mGraphLCDState->GetAudioState(); + + if (audio.tracks.size() == 0) { + mShowAudio = false; + } else + if (audio.lastChange > 0) + { + if (!mShowAudio) + { + if (currTimeMs - audio.lastChange < 5000) + { + mShowAudio = true; + mUpdate = true; + } + } + else + { + if (currTimeMs - audio.lastChange > 5000) + { + mShowAudio = false; + mUpdate = true; + } + } + } + } + /* display mode (normal or interactive): reset after 10 secs if not normal */ if ( (mDisplayMode != DisplayModeNormal) && ( (uint32_t)(currTimeMs - LastTimeDisplayMode) > (uint32_t)(10000)) ) { mDisplayMode = DisplayModeNormal; @@ -259,6 +289,7 @@ void cGraphLCDDisplay::Action(void) bool bActive = bBrightnessActive || (mState != StateNormal) || (GraphLCDSetup.ShowVolume && mShowVolume) + || (GraphLCDSetup.ShowMenu && mShowAudio) || (GraphLCDSetup.ShowMessages && mGraphLCDState->ShowMessage()) || (GraphLCDSetup.BrightnessDelay == 900); @@ -324,6 +355,12 @@ void cGraphLCDDisplay::Action(void) if (display) display->Render(mScreen); } + if (mShowAudio) + { + display = mSkin->GetDisplay("audio"); + if (display) + display->Render(mScreen); + } if (GraphLCDSetup.ShowMessages && mGraphLCDState->ShowMessage()) { display = mSkin->GetDisplay("message"); @@ -455,6 +492,7 @@ void cGraphLCDDisplay::SetBrightness() bool bActive = bBrightnessActive || (mState != StateNormal) || (GraphLCDSetup.ShowVolume && mShowVolume) + || (GraphLCDSetup.ShowMenu && mShowAudio) || (GraphLCDSetup.ShowMessages && mGraphLCDState->ShowMessage()) || (GraphLCDSetup.BrightnessDelay == 900); if (bActive) diff --git a/display.h b/display.h index 3c7d7dd..993c077 100644 --- a/display.h +++ b/display.h @@ -92,6 +92,7 @@ private: cGraphLCDState * mGraphLCDState; bool mShowVolume; + bool mShowAudio; void UpdateIn(uint64_t msec); diff --git a/graphlcd/skins/default/default.skin b/graphlcd/skins/default/default.skin index d04e8a8..9c7a335 100644 --- a/graphlcd/skins/default/default.skin +++ b/graphlcd/skins/default/default.skin @@ -24,7 +24,7 @@ - + @@ -63,6 +63,13 @@ + + + + + + + @@ -192,8 +199,8 @@ default="add(#LogoSymbY,#LogoSymbH,#PaddingH)" /> - - + + @@ -203,13 +210,17 @@ - - - - - - - + + + + + + + + + + + @@ -220,7 +231,7 @@ - + @@ -240,24 +251,24 @@ {PresentTitle} - + {PresentShortText} - + {FollowingStartDateTime:%H\:%M} - + {FollowingTitle} - + {FollowingShortText} - + - + {Recordings} @@ -280,6 +291,28 @@ + + + + + + + + + Audio + + + + + + {AudioTrackCurrent} + {AudioTrackItem} + + + + + + diff --git a/skinconfig.c b/skinconfig.c index 5f0f847..51ecc69 100644 --- a/skinconfig.c +++ b/skinconfig.c @@ -84,6 +84,14 @@ typedef enum _eTokenId tokVolumeIsMute, tokPrivateVolumeEnd, + // audio display + tokPrivateAudioStart, + tokAudioTrackItem, + tokAudioTrackCurrent, + tokIsAudioTrackCurrent, + tokAudioChannel, + tokPrivateAudioEnd, + tokPrivateReplayStart, tokReplayTitle, tokReplayPositionIndex, @@ -219,6 +227,13 @@ static const std::string Tokens[tokCountToken] = "VolumeIsMute", "privateVolumeEnd", + "privateAudioStart", + "AudioTrackItem", + "AudioTrackCurrent", + "IsAudioTrackCurrent", + "AudioChannel", + "privateAudioEnd", + "privateReplayStart", "ReplayTitle", "ReplayPositionIndex", @@ -498,6 +513,57 @@ GLCD::cType cGraphLCDSkinConfig::GetToken(const GLCD::tSkinToken & Token) break; } } + else if (Token.Id > tokPrivateAudioStart && Token.Id < tokPrivateAudioEnd) + { + tAudioState audio = mState->GetAudioState(); + switch (Token.Id) + { + case tokAudioTrackItem: + case tokAudioTrackCurrent: + case tokIsAudioTrackCurrent: + { + if (audio.tracks.size() == 0 + || audio.currentTrack == -1) + { + return false; + } + int maxItems = Token.MaxItems; + if (maxItems > (int) audio.tracks.size()) + maxItems = audio.tracks.size(); + int currentIndex = maxItems / 2; + if (audio.currentTrack < currentIndex) + currentIndex = audio.currentTrack; + int topIndex = audio.currentTrack - currentIndex; + if ((topIndex + maxItems) > (int) audio.tracks.size()) + { + currentIndex += (topIndex + maxItems) - audio.tracks.size(); + topIndex = audio.currentTrack - currentIndex; + } + if (Token.Id == tokAudioTrackItem) + { + if (Token.Index < maxItems && Token.Index != currentIndex) + return audio.tracks[topIndex + Token.Index]; + } + else if (Token.Id == tokAudioTrackCurrent) + { + if (Token.Index < maxItems && Token.Index == currentIndex) + return audio.tracks[topIndex + Token.Index]; + else if (Token.Index < 0) // outside of : return last MenuCurrent + return audio.tracks[topIndex]; + } + else if (Token.Id == tokIsAudioTrackCurrent) + { + if (Token.Index < maxItems && Token.Index == currentIndex) + return true; + } + return false; + } + case tokAudioChannel: + return audio.currentChannel; + default: + break; + } + } else if (Token.Id > tokPrivateReplayStart && Token.Id < tokPrivateReplayEnd) { tReplayState replay = mState->GetReplayState(); diff --git a/state.c b/state.c index b2adb37..a70f16c 100644 --- a/state.c +++ b/state.c @@ -79,6 +79,10 @@ cGraphLCDState::cGraphLCDState(cGraphLCDDisplay * Display) mVolume.value = -1; mVolume.lastChange = 0; + mAudio.currentTrack = -1; + mAudio.currentChannel = -1; + mAudio.lastChange = 0; + SetChannel(cDevice::CurrentChannel()); } @@ -359,6 +363,32 @@ void cGraphLCDState::SetVolume(int Volume, bool Absolute) } } +void cGraphLCDState::SetAudioTrack(int Index, const char * const *Tracks) { + if (GraphLCDSetup.PluginActive) { + mutex.Lock(); + mAudio.currentTrack = Index; + mAudio.tracks.clear(); + int i = 0; + while (Tracks[i]) { + mAudio.tracks.push_back(Tracks[i]); + i++; + } + mAudio.lastChange = cTimeMs::Now(); + mutex.Unlock(); + //mDisplay->Update(); -> will be done in SetAudioChannel + } +} + +void cGraphLCDState::SetAudioChannel(int AudioChannel) { + if (GraphLCDSetup.PluginActive) { + mutex.Lock(); + mAudio.currentChannel = AudioChannel; + mAudio.lastChange = cTimeMs::Now(); + mutex.Unlock(); + mDisplay->Update(); + } +} + void cGraphLCDState::Tick() { //printf("graphlcd plugin: cGraphLCDState::Tick\n"); @@ -410,6 +440,11 @@ void cGraphLCDState::OsdClear() mOsd.currentTextItemScroll = 0; mOsd.currentTextItemScrollReset = false; + mAudio.currentTrack = -1; + mAudio.currentChannel = -1; + mAudio.tracks.clear(); + mAudio.lastChange = 0; + mutex.Unlock(); mDisplay->SetMenuClear(); } @@ -892,6 +927,17 @@ tVolumeState cGraphLCDState::GetVolumeState() return ret; } +tAudioState cGraphLCDState::GetAudioState() +{ + tAudioState ret; + + mutex.Lock(); + ret = mAudio; + mutex.Unlock(); + + return ret; +} + bool cGraphLCDState::ShowMessage() { bool ret; diff --git a/state.h b/state.h index d2a8304..e8b9768 100644 --- a/state.h +++ b/state.h @@ -95,6 +95,14 @@ struct tVolumeState uint64_t lastChange; }; +struct tAudioState +{ + int currentTrack; + std::vector tracks; + int currentChannel; + uint64_t lastChange; +}; + class cGraphLCDDisplay; class cGraphLCDState : public cStatus @@ -113,6 +121,7 @@ private: std::vector mRecordings; tOsdState mOsd; tVolumeState mVolume; + tAudioState mAudio; void SetChannel(int ChannelNumber); void UpdateChannelInfo(void); @@ -123,6 +132,8 @@ protected: virtual void Recording(const cDevice *Device, const char *Name, const char *FileName, bool On); virtual void Replaying(const cControl *Control, const char *Name, const char *FileName, bool On); virtual void SetVolume(int Volume, bool Absolute); + virtual void SetAudioTrack(int Index, const char * const *Tracks); + virtual void SetAudioChannel(int AudioChannel); virtual void OsdClear(); virtual void OsdTitle(const char *Title); virtual void OsdStatusMessage(const char *Message); @@ -148,6 +159,7 @@ public: tOsdState GetOsdState(); void ResetOsdStateScroll(); tVolumeState GetVolumeState(); + tAudioState GetAudioState(); bool ShowMessage(); }; -- cgit v1.2.3