|
a/mpd2src/mpd2sc.cpp |
|
b/mpd2src/mpd2sc.cpp |
|
... |
|
... |
199 |
if (num_bytes == -1) {
|
199 |
if (num_bytes == -1) {
|
200 |
LOGERR("Error: Failed to receive from socket: " << strerror(errno) << endl);
|
200 |
LOGERR("Error: Failed to receive from socket: " << strerror(errno) << endl);
|
201 |
continue; // Ignore failed request
|
201 |
continue; // Ignore failed request
|
202 |
}
|
202 |
}
|
203 |
if (num_bytes > 0) {
|
203 |
if (num_bytes > 0) {
|
|
|
204 |
string response("OK");
|
|
|
205 |
|
204 |
if (strncmp("play", buf, num_bytes) == 0)
|
206 |
if (strncmp("play", buf, num_bytes) == 0)
|
205 |
pcmsender->Play();
|
207 |
pcmsender->Play();
|
206 |
else if (strncmp("stop", buf, num_bytes) == 0)
|
208 |
else if (strncmp("stop", buf, num_bytes) == 0)
|
207 |
pcmsender->Stop();
|
209 |
pcmsender->Stop();
|
208 |
else if (strncmp("playpause", buf, num_bytes) == 0)
|
210 |
else if (strncmp("playpause", buf, num_bytes) == 0)
|
|
... |
|
... |
215 |
sender->SetEnabled(false);
|
217 |
sender->SetEnabled(false);
|
216 |
else if (strncmp("multicast", buf, num_bytes) == 0)
|
218 |
else if (strncmp("multicast", buf, num_bytes) == 0)
|
217 |
sender->SetMulticast(true);
|
219 |
sender->SetMulticast(true);
|
218 |
else if (strncmp("unicast", buf, num_bytes) == 0)
|
220 |
else if (strncmp("unicast", buf, num_bytes) == 0)
|
219 |
sender->SetMulticast(false);
|
221 |
sender->SetMulticast(false);
|
|
|
222 |
|
|
|
223 |
ssize_t bytes_sent = sendto(g_sockfd, (const void *)response.c_str(),
|
|
|
224 |
response.length(), 0, (struct sockaddr *)&client_addr, len);
|
|
|
225 |
if (bytes_sent == -1) {
|
|
|
226 |
LOGERR("Error: Cannot write to socket: " <<
|
|
|
227 |
strerror(errno) << endl);
|
|
|
228 |
}
|
220 |
}
|
229 |
}
|
221 |
} while (!g_quitrequest);
|
230 |
} while (!g_quitrequest);
|
222 |
|
231 |
|
223 |
_close_socket:
|
232 |
_close_socket:
|
224 |
if (g_sockfd > 0)
|
233 |
if (g_sockfd > 0)
|