Switch to unified view

a/src/ohvolume.cxx b/src/ohvolume.cxx
...
...
39
static const string millidbperstep("500");
39
static const string millidbperstep("500");
40
40
41
static const string sTpProduct("urn:av-openhome-org:service:Volume:1");
41
static const string sTpProduct("urn:av-openhome-org:service:Volume:1");
42
static const string sIdProduct("urn:av-openhome-org:serviceId:Volume");
42
static const string sIdProduct("urn:av-openhome-org:serviceId:Volume");
43
43
44
OHVolume::OHVolume(UpMpd *dev, UpMpdRenderCtl *ctl)
44
OHVolume::OHVolume(UpMpd *dev)
45
    : UpnpService(sTpProduct, sIdProduct, dev), m_dev(dev), m_ctl(ctl)
45
    : UpnpService(sTpProduct, sIdProduct, dev), m_dev(dev)
46
{
46
{
47
    dev->addActionMapping(this,"Characteristics", 
47
    dev->addActionMapping(this,"Characteristics", 
48
                          bind(&OHVolume::characteristics, this, _1, _2));
48
                          bind(&OHVolume::characteristics, this, _1, _2));
49
    dev->addActionMapping(this,"SetVolume", 
49
    dev->addActionMapping(this,"SetVolume", 
50
                          bind(&OHVolume::setVolume, this, _1, _2));
50
                          bind(&OHVolume::setVolume, this, _1, _2));
...
...
73
    st["VolumeMilliDbPerSteps"] = millidbperstep;
73
    st["VolumeMilliDbPerSteps"] = millidbperstep;
74
    st["Balance"] = "0";
74
    st["Balance"] = "0";
75
    st["BalanceMax"] = "0";
75
    st["BalanceMax"] = "0";
76
    st["Fade"] = "0";
76
    st["Fade"] = "0";
77
    st["FadeMax"] = "0";
77
    st["FadeMax"] = "0";
78
    int volume = m_ctl->getvolume_i();
78
    int volume = m_dev->m_rdctl->getvolume_i();
79
    st["Volume"] = SoapHelp::i2s(volume);
79
    st["Volume"] = SoapHelp::i2s(volume);
80
    st["Mute"] = volume == 0 ? "1" : "0";
80
    st["Mute"] = volume == 0 ? "1" : "0";
81
    return true;
81
    return true;
82
}
82
}
83
83
...
...
120
    LOGDEB("OHVolume::setVolume" << endl);
120
    LOGDEB("OHVolume::setVolume" << endl);
121
    int volume;
121
    int volume;
122
    if (!sc.get("Value", &volume)) {
122
    if (!sc.get("Value", &volume)) {
123
        return UPNP_E_INVALID_PARAM;
123
        return UPNP_E_INVALID_PARAM;
124
    }
124
    }
125
    m_ctl->setvolume_i(volume);
125
    m_dev->m_rdctl->setvolume_i(volume);
126
    m_dev->loopWakeup();
126
    m_dev->loopWakeup();
127
    return UPNP_E_SUCCESS;
127
    return UPNP_E_SUCCESS;
128
}
128
}
129
129
130
int OHVolume::setMute(const SoapIncoming& sc, SoapOutgoing& data)
130
int OHVolume::setMute(const SoapIncoming& sc, SoapOutgoing& data)
...
...
132
    LOGDEB("OHVolume::setMute" << endl);
132
    LOGDEB("OHVolume::setMute" << endl);
133
    bool mute;
133
    bool mute;
134
    if (!sc.get("Value", &mute)) {
134
    if (!sc.get("Value", &mute)) {
135
        return UPNP_E_INVALID_PARAM;
135
        return UPNP_E_INVALID_PARAM;
136
    }
136
    }
137
    m_ctl->setmute_i(mute);
137
    m_dev->m_rdctl->setmute_i(mute);
138
    return UPNP_E_SUCCESS;
138
    return UPNP_E_SUCCESS;
139
}
139
}
140
140
141
int OHVolume::volumeInc(const SoapIncoming& sc, SoapOutgoing& data)
141
int OHVolume::volumeInc(const SoapIncoming& sc, SoapOutgoing& data)
142
{
142
{
143
    LOGDEB("OHVolume::volumeInc" << endl);
143
    LOGDEB("OHVolume::volumeInc" << endl);
144
    int newvol = m_ctl->getvolume_i() + 1;
144
    int newvol = m_dev->m_rdctl->getvolume_i() + 1;
145
    if (newvol > 100)
145
    if (newvol > 100)
146
        newvol = 100;
146
        newvol = 100;
147
    m_ctl->setvolume_i(newvol);
147
    m_dev->m_rdctl->setvolume_i(newvol);
148
    m_dev->loopWakeup();
148
    m_dev->loopWakeup();
149
    return UPNP_E_SUCCESS;
149
    return UPNP_E_SUCCESS;
150
}
150
}
151
151
152
int OHVolume::volumeDec(const SoapIncoming& sc, SoapOutgoing& data)
152
int OHVolume::volumeDec(const SoapIncoming& sc, SoapOutgoing& data)
153
{
153
{
154
    LOGDEB("OHVolume::volumeDec" << endl);
154
    LOGDEB("OHVolume::volumeDec" << endl);
155
    int newvol = m_ctl->getvolume_i() - 1;
155
    int newvol = m_dev->m_rdctl->getvolume_i() - 1;
156
    if (newvol < 0)
156
    if (newvol < 0)
157
        newvol = 0;
157
        newvol = 0;
158
    m_ctl->setvolume_i(newvol);
158
    m_dev->m_rdctl->setvolume_i(newvol);
159
    m_dev->loopWakeup();
159
    m_dev->loopWakeup();
160
    return UPNP_E_SUCCESS;
160
    return UPNP_E_SUCCESS;
161
}
161
}
162
162
163
int OHVolume::volume(const SoapIncoming& sc, SoapOutgoing& data)
163
int OHVolume::volume(const SoapIncoming& sc, SoapOutgoing& data)
164
{
164
{
165
    LOGDEB("OHVolume::volume" << endl);
165
    LOGDEB("OHVolume::volume" << endl);
166
    data.addarg("Value", SoapHelp::i2s(m_ctl->getvolume_i()));
166
    data.addarg("Value", SoapHelp::i2s(m_dev->m_rdctl->getvolume_i()));
167
    return UPNP_E_SUCCESS;
167
    return UPNP_E_SUCCESS;
168
}
168
}
169
169
170
int OHVolume::mute(const SoapIncoming& sc, SoapOutgoing& data)
170
int OHVolume::mute(const SoapIncoming& sc, SoapOutgoing& data)
171
{
171
{
172
    LOGDEB("OHVolume::mute" << endl);
172
    LOGDEB("OHVolume::mute" << endl);
173
    bool mute = m_ctl->getvolume_i() == 0;
173
    bool mute = m_dev->m_rdctl->getvolume_i() == 0;
174
    data.addarg("Value", mute ? "1" : "0");
174
    data.addarg("Value", mute ? "1" : "0");
175
    return UPNP_E_SUCCESS;
175
    return UPNP_E_SUCCESS;
176
}
176
}
177
177
178
int OHVolume::volumeLimit(const SoapIncoming& sc, SoapOutgoing& data)
178
int OHVolume::volumeLimit(const SoapIncoming& sc, SoapOutgoing& data)