mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
driver/volume.cpp: inherit from CChangeObserver;
add changeNotify() for adjusting volume percent
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
#include <daemonc/remotecontrol.h>
|
#include <daemonc/remotecontrol.h>
|
||||||
#include <driver/framebuffer.h>
|
#include <driver/framebuffer.h>
|
||||||
#include <driver/volume.h>
|
#include <driver/volume.h>
|
||||||
|
#include <zapit/zapit.h>
|
||||||
|
|
||||||
#if HAVE_COOL_HARDWARE
|
#if HAVE_COOL_HARDWARE
|
||||||
#include <gui/widget/progressbar.h>
|
#include <gui/widget/progressbar.h>
|
||||||
@@ -62,6 +63,8 @@ CVolume::CVolume()
|
|||||||
ShadowOffset = 4;
|
ShadowOffset = 4;
|
||||||
mute_ay = 0;
|
mute_ay = 0;
|
||||||
m_mode = CNeutrinoApp::getInstance()->getMode();
|
m_mode = CNeutrinoApp::getInstance()->getMode();
|
||||||
|
channel_id = 0;
|
||||||
|
apid = 0;
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
@@ -212,7 +215,8 @@ void CVolume::AudioMute(int newValue, bool isEvent)
|
|||||||
|
|
||||||
void CVolume::setvol(int vol)
|
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)
|
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);
|
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;
|
||||||
|
}
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#define ROUNDED g_settings.rounded_corners ? vbar_h/2 : 0
|
#define ROUNDED g_settings.rounded_corners ? vbar_h/2 : 0
|
||||||
|
|
||||||
class CVolume
|
class CVolume : public CChangeObserver
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
void refreshVolumebar(int current_volume);
|
void refreshVolumebar(int current_volume);
|
||||||
@@ -47,6 +47,9 @@ class CVolume
|
|||||||
int rounded;
|
int rounded;
|
||||||
int m_mode;
|
int m_mode;
|
||||||
bool paintShadow, paintDigits, MuteIconFrame;
|
bool paintShadow, paintDigits, MuteIconFrame;
|
||||||
|
/* volume adjustment variables */
|
||||||
|
t_channel_id channel_id;
|
||||||
|
int apid;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CVolume();
|
CVolume();
|
||||||
@@ -60,7 +63,10 @@ class CVolume
|
|||||||
void setVolume(const neutrino_msg_t key, const bool bDoPaint = true, bool nowait = false);
|
void setVolume(const neutrino_msg_t key, const bool bDoPaint = true, bool nowait = false);
|
||||||
int getStartPosTop(){ return sy; }
|
int getStartPosTop(){ return sy; }
|
||||||
int getEndPosRight(){ return sw; }
|
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__
|
#endif // __CVOLUME__
|
||||||
|
Reference in New Issue
Block a user