Switch to unified view

a/src/ohsndrcv.cxx b/src/ohsndrcv.cxx
...
...
23
#include "execmd.h"
23
#include "execmd.h"
24
#include "upmpd.hxx"
24
#include "upmpd.hxx"
25
#include "mpdcli.hxx"
25
#include "mpdcli.hxx"
26
#include "upmpdutils.hxx"
26
#include "upmpdutils.hxx"
27
#include "ohreceiver.hxx"
27
#include "ohreceiver.hxx"
28
#include "conftree.hxx"
28
29
29
using namespace std;
30
using namespace std;
30
using namespace std::placeholders;
31
using namespace std::placeholders;
31
using namespace UPnPP;
32
using namespace UPnPP;
32
33
...
...
42
    // driver input and managing a sender. Our local source or mpd are
43
    // driver input and managing a sender. Our local source or mpd are
43
    // uninvolved
44
    // uninvolved
44
    Internal(UpMpd *dv, const string& starterpath, int port)
45
    Internal(UpMpd *dv, const string& starterpath, int port)
45
        : dev(dv), mpd(0), origmpd(0), isender(0), ssender(0),
46
        : dev(dv), mpd(0), origmpd(0), isender(0), ssender(0),
46
          makeisendercmd(starterpath), mpdport(port) {
47
          makeisendercmd(starterpath), mpdport(port) {
48
        // Stream volume control ? This decides if the aux mpd has mixer
49
        // "software" or "none"
50
        scalestream = true;
51
        PTMutexLocker conflock(g_configlock);
52
        string value;
53
        if (g_config->get("scstreamscaled", value)) {
54
            scalestream = atoi(value.c_str()) != 0;
55
        }
47
    }
56
    }
48
    ~Internal() {
57
    ~Internal() {
49
        clear();
58
        clear();
50
    }
59
    }
51
    void clear() {
60
    void clear() {
...
...
67
    ExecCmd *ssender;
76
    ExecCmd *ssender;
68
    string iuri;
77
    string iuri;
69
    string imeta;
78
    string imeta;
70
    string makeisendercmd;
79
    string makeisendercmd;
71
    int mpdport;
80
    int mpdport;
81
    bool scalestream;
72
};
82
};
73
83
74
84
75
SenderReceiver::SenderReceiver(UpMpd *dev, const string& starterpath, int port)
85
SenderReceiver::SenderReceiver(UpMpd *dev, const string& starterpath, int port)
76
{
86
{
...
...
107
        return false;
117
        return false;
108
    }
118
    }
109
    
119
    
110
    // Stop MPD Play (normally already done)
120
    // Stop MPD Play (normally already done)
111
    m->dev->m_mpdcli->stop();
121
    m->dev->m_mpdcli->stop();
112
    // Retrieve status to check if external volume control is activated
122
113
    const MpdStatus& st = m->dev->m_mpdcli->getStatus();
114
    // sndcmd will non empty if we actually started a script instead
123
    // sndcmd will non empty if we actually started a script instead
115
    // of reusing an old one (then need to read the initial data).
124
    // of reusing an old one (then need to read the initial data).
116
    ExecCmd *sndcmd = 0;
125
    ExecCmd *sndcmd = 0;
126
117
    if (script.empty() && !m->isender) {
127
    if (script.empty() && !m->isender) {
118
        // Internal source, first time: Start fifo MPD and Sender
128
        // Internal source, first time: Start fifo MPD and Sender
119
        m->isender = sndcmd = new ExecCmd();
129
        m->isender = sndcmd = new ExecCmd();
120
        vector<string> args;
130
        vector<string> args;
121
        args.push_back("-p");
131
        args.push_back("-p");
122
        args.push_back(SoapHelp::i2s(m->mpdport));
132
        args.push_back(SoapHelp::i2s(m->mpdport));
123
        args.push_back("-f");
133
        args.push_back("-f");
124
        args.push_back(m->dev->m_friendlyname);
134
        args.push_back(m->dev->m_friendlyname);
125
  if (st.externalvolumecontrol)
135
  if (!m->scalestream)
126
            args.push_back("-e");
136
            args.push_back("-e");
127
        m->isender->startExec(m->makeisendercmd, args, false, true);
137
        m->isender->startExec(m->makeisendercmd, args, false, true);
128
    } else if (!script.empty()) {
138
    } else if (!script.empty()) {
129
        // External source. ssender should already be zero, we delete
139
        // External source. ssender should already be zero, we delete
130
        // it just in case
140
        // it just in case
131
        deleteZ(m->ssender);
141
        deleteZ(m->ssender);
132
        m->ssender = sndcmd = new ExecCmd();
142
        m->ssender = sndcmd = new ExecCmd();
133
        vector<string> args;
143
        vector<string> args;
134
        args.push_back("-f");
144
        args.push_back("-f");
135
        args.push_back(m->dev->m_friendlyname);
145
        args.push_back(m->dev->m_friendlyname);
136
        if (st.externalvolumecontrol)
146
        // This does nothing, just for consistence.
147
        if (!m->scalestream)
137
            args.push_back("-e");
148
            args.push_back("-e");
138
        m->ssender->startExec(script, args, false, true);
149
        m->ssender->startExec(script, args, false, true);
139
    }
150
    }
140
151
141
    string meta, uri;
152
    string meta, uri;
...
...
190
    }
201
    }
191
202
192
    if (script.empty()) {
203
    if (script.empty()) {
193
        // Internal source: copy mpd state
204
        // Internal source: copy mpd state
194
        copyMpd(m->dev->m_mpdcli, m->mpd, seekms);
205
        copyMpd(m->dev->m_mpdcli, m->mpd, seekms);
206
        if (m->scalestream)
207
            m->mpd->forceInternalVControl();
195
        m->origmpd = m->dev->m_mpdcli;
208
        m->origmpd = m->dev->m_mpdcli;
196
        m->dev->m_mpdcli = m->mpd;
209
        m->dev->m_mpdcli = m->mpd;
197
    } else {
210
    } else {
198
        m->origmpd = 0;
211
        m->origmpd = 0;
199
    }
212
    }