diff options
| author | Johns <johns98@gmx.net> | 2013-02-16 19:23:51 +0100 |
|---|---|---|
| committer | Johns <johns98@gmx.net> | 2013-02-16 19:23:51 +0100 |
| commit | 9500e98d5da3e406ad77d8a898b5bc8632046740 (patch) | |
| tree | 9602704acf550a74fe5df165e137321c14179e33 | |
| parent | 6ae4d0f8da38960f05d7327e808236adbc827679 (diff) | |
| download | vdr-plugin-play-9500e98d5da3e406ad77d8a898b5bc8632046740.tar.gz vdr-plugin-play-9500e98d5da3e406ad77d8a898b5bc8632046740.tar.bz2 | |
Add support to change the player volume.
| -rw-r--r-- | play.cpp | 33 | ||||
| -rw-r--r-- | player.c | 20 | ||||
| -rw-r--r-- | player.h | 3 |
3 files changed, 35 insertions, 21 deletions
@@ -187,13 +187,11 @@ extern "C" void DrawText(int x, int y, const char *s, uint32_t fg, uint32_t bg, ////////////////////////////////////////////////////////////////////////////// static char DvdNav; ///< dvdnav active -static int PlayerVolume = -1; ///< volume 0 - 100 static char PlayerPaused; ///< player paused static char PlayerSpeed; ///< player playback speed #define PlayerSendQuit() #define PlayerSendPause() -#define PlayerSendVolume() #define PlayerSendSetSpeed(x) #define PlayerSendSeek(x) #define SendCommand(x) @@ -228,8 +226,8 @@ cMyPlayer::cMyPlayer(const char *filename) { dsyslog("[play]%s: '%s'\n", __FUNCTION__, filename); - PlayerVolume = cDevice::CurrentVolume(); - dsyslog("{play]: initial volume %d\n", PlayerVolume); + PlayerSetVolume(cDevice::CurrentVolume()); + dsyslog("[play]: initial volume %d\n", cDevice::CurrentVolume()); FileName = strdup(filename); if (ConfigDisableRemote) { @@ -242,7 +240,7 @@ cMyPlayer::cMyPlayer(const char *filename) */ cMyPlayer::~cMyPlayer() { - dsyslog("{play]%s: end\n", __FUNCTION__); + dsyslog("[play]%s: end\n", __FUNCTION__); PlayerStop(); free(FileName); @@ -280,18 +278,23 @@ bool cMyPlayer::GetReplayMode(bool & play, bool & forward, int &speed) // cStatus ////////////////////////////////////////////////////////////////////////////// +/** +** Status class. +** +** To get volume changes. +*/ class cMyStatus:public cStatus { + private: + int Volume; ///< current volume + public: - cMyStatus(void); + cMyStatus(void); ///< my status constructor protected: virtual void SetVolume(int, bool); ///< volume changed - - //bool GetVolume(int &, bool &); }; -static int Volume; ///< current volume cMyStatus *Status; ///< status monitor for volume /** @@ -315,18 +318,8 @@ void cMyStatus::SetVolume(int volume, bool absolute) Volume += volume; } - if (Volume != PlayerVolume) { - PlayerVolume = Volume; - PlayerSendVolume(); - } -} - -/** -** Get volume. -bool cMyStatus::GetVolume(int &volume, bool &mute) -{ + PlayerSetVolume(Volume); } -*/ ////////////////////////////////////////////////////////////////////////////// // cControl @@ -141,7 +141,7 @@ static char PlayerSpeed; ///< player playback speed /** ** Parse player output. ** -** @param data line pointer +** @param data line pointer (\0 terminated) ** @param size line length */ static void PlayerParseLine(const char *data, int size) @@ -416,6 +416,7 @@ static void PlayerForkAndExec(const char *filename) return; } PlayerPid = pid; // parent + setpgid(pid, 0); if (ConfigUseSlave) { close(PlayerPipeIn[0]); @@ -651,6 +652,23 @@ int PlayerIsRunning(void) return 0; } +/** +** Set player volume. +** +** @param volume new volume (0..255) +*/ +void PlayerSetVolume(int volume) +{ + Debug(3, "player: set volume=%d\n", volume); + + if (PlayerVolume != volume) { + PlayerVolume = volume; + if (PlayerPid) { + PlayerSendVolume(); + } + } +} + ////////////////////////////////////////////////////////////////////////////// // Device/Plugin C part ////////////////////////////////////////////////////////////////////////////// @@ -108,6 +108,9 @@ extern "C" /// Is external player still running extern int PlayerIsRunning(void); + /// Set player volume + extern void PlayerSetVolume(int); + #ifdef __cplusplus } #endif |
