diff --git a/src/driver/volume.cpp b/src/driver/volume.cpp index a5534d80d..c0049d514 100644 --- a/src/driver/volume.cpp +++ b/src/driver/volume.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #if HAVE_COOL_HARDWARE #include @@ -62,6 +63,8 @@ CVolume::CVolume() ShadowOffset = 4; mute_ay = 0; m_mode = CNeutrinoApp::getInstance()->getMode(); + channel_id = 0; + apid = 0; Init(); } @@ -212,7 +215,8 @@ void CVolume::AudioMute(int newValue, bool isEvent) void CVolume::setvol(int vol) { - audioDecoder->setVolume(vol, vol); + //audioDecoder->setVolume(vol, vol); + CZapit::getInstance()->SetVolume(vol); } void CVolume::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool nowait) @@ -366,3 +370,21 @@ void CVolume::refreshVolumebar(int current_volume) g_Font[VolumeFont]->RenderString(digit_x, digit_y, digit_w, buff, colContent); } } + +bool CVolume::changeNotify(const neutrino_locale_t OptionName, void * data) +{ + bool ret = false; + if (ARE_LOCALES_EQUAL(OptionName, NONEXISTANT_LOCALE)) { + int percent = *(int *) data; + int vol = CZapit::getInstance()->GetVolume(); + /* keep resulting volume = (vol * percent)/100 not more than 115 */ + if (vol * percent > 11500) + percent = 11500 / vol; + + printf("CVolume::changeNotify: percent %d\n", percent); + CZapit::getInstance()->SetPidVolume(channel_id, apid, percent); + CZapit::getInstance()->SetVolumePercent(percent); + *(int *) data = percent; + } + return ret; +} diff --git a/src/driver/volume.h b/src/driver/volume.h index 797d9ccb1..fe10a2ea7 100644 --- a/src/driver/volume.h +++ b/src/driver/volume.h @@ -30,7 +30,7 @@ #define ROUNDED g_settings.rounded_corners ? vbar_h/2 : 0 -class CVolume +class CVolume : public CChangeObserver { private: void refreshVolumebar(int current_volume); @@ -47,6 +47,9 @@ class CVolume int rounded; int m_mode; bool paintShadow, paintDigits, MuteIconFrame; + /* volume adjustment variables */ + t_channel_id channel_id; + int apid; public: CVolume(); @@ -60,7 +63,10 @@ class CVolume void setVolume(const neutrino_msg_t key, const bool bDoPaint = true, bool nowait = false); int getStartPosTop(){ return sy; } int getEndPosRight(){ return sw; } + + void SetCurrentPid(int pid) { apid = pid; } + void SetCurrentChannel(t_channel_id id) { channel_id = id; } + bool changeNotify(const neutrino_locale_t OptionName, void *); }; - #endif // __CVOLUME__