Skip to content

Commit b2daf47

Browse files
committed
Merge branch '2.5' into '2.6'
2 parents 869300c + 97013db commit b2daf47

1 file changed

Lines changed: 33 additions & 7 deletions

File tree

src/engine/sidechain/shoutconnection.cpp

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
#include "util/compatibility/qatomic.h"
2828
#include "util/logger.h"
2929

30+
// SHOUT_ATTR_F_DEPRECATED was first introduced in libshout-idjc 2.4.6.
31+
// Since libshout-idjc provides no version macro, we probe for that symbol to
32+
// detect the 2.4.6+ API.
33+
#ifdef SHOUT_ATTR_F_DEPRECATED
34+
#define MIXXX_USE_SHOUT_API_246
35+
#endif
36+
3037
namespace {
3138

3239
constexpr int kConnectRetries = 30;
@@ -315,22 +322,24 @@ void ShoutConnection::updateFromPreferences() {
315322
return;
316323
}
317324

318-
if (shout_set_name(m_pShout, baStreamName.constData()) != SHOUTERR_SUCCESS) {
325+
if (shout_set_meta(m_pShout, SHOUT_META_NAME, baStreamName.constData()) != SHOUTERR_SUCCESS) {
319326
errorDialog(tr("Error setting stream name!"), shout_get_error(m_pShout));
320327
return;
321328
}
322329

323-
if (shout_set_description(m_pShout, baStreamDesc.constData()) != SHOUTERR_SUCCESS) {
330+
if (shout_set_meta(m_pShout,
331+
SHOUT_META_DESCRIPTION,
332+
baStreamDesc.constData()) != SHOUTERR_SUCCESS) {
324333
errorDialog(tr("Error setting stream description!"), shout_get_error(m_pShout));
325334
return;
326335
}
327336

328-
if (shout_set_genre(m_pShout, baStreamGenre.constData()) != SHOUTERR_SUCCESS) {
337+
if (shout_set_meta(m_pShout, SHOUT_META_GENRE, baStreamGenre.constData()) != SHOUTERR_SUCCESS) {
329338
errorDialog(tr("Error setting stream genre!"), shout_get_error(m_pShout));
330339
return;
331340
}
332341

333-
if (shout_set_url(m_pShout, baStreamWebsite.constData()) != SHOUTERR_SUCCESS) {
342+
if (shout_set_meta(m_pShout, SHOUT_META_URL, baStreamWebsite.constData()) != SHOUTERR_SUCCESS) {
334343
errorDialog(tr("Error setting stream url!"), shout_get_error(m_pShout));
335344
return;
336345
}
@@ -383,7 +392,13 @@ void ShoutConnection::updateFromPreferences() {
383392
return;
384393
}
385394

395+
#ifdef MIXXX_USE_SHOUT_API_246
396+
if (shout_set_content_format(
397+
m_pShout, format, 0 /* SHOUT_USAGE_UNKNOWN */, nullptr) !=
398+
SHOUTERR_SUCCESS) {
399+
#else
386400
if (shout_set_format(m_pShout, format) != SHOUTERR_SUCCESS) {
401+
#endif
387402
errorDialog(tr("Error setting stream encoding format!"), shout_get_error(m_pShout));
388403
return;
389404
}
@@ -702,14 +717,14 @@ int ShoutConnection::filelen() {
702717

703718
bool ShoutConnection::writeSingle(const unsigned char* data, std::size_t len) {
704719
setFunctionCode(8);
705-
int ret = shout_send_raw(m_pShout, data, len);
720+
ssize_t ret = shout_send_raw(m_pShout, data, len);
706721
if (ret == SHOUTERR_BUSY) {
707722
// in case of busy, frames are queued
708723
// try to flush queue after a short sleep
709724
kLogger.warning() << "writeSingle() SHOUTERR_BUSY, trying again";
710725
usleep(10000); // wait 10 ms until "busy" is over. TODO() tweak for an optimum.
711726
// if this fails, the queue is transmitted after the next regular shout_send_raw()
712-
(void)shout_send_raw(m_pShout, nullptr, 0);
727+
ret = shout_send_raw(m_pShout, nullptr, 0);
713728
} else if (ret < SHOUTERR_SUCCESS) {
714729
m_lastErrorStr = shout_get_error(m_pShout);
715730
kLogger.warning()
@@ -867,7 +882,11 @@ void ShoutConnection::updateMetaData() {
867882
insertMetaData("song", baSong.constData());
868883
}
869884
setFunctionCode(11);
885+
#ifdef MIXXX_USE_SHOUT_API_246
886+
int ret = shout_set_metadata_utf8(m_pShout, m_pShoutMetaData);
887+
#else
870888
int ret = shout_set_metadata(m_pShout, m_pShoutMetaData);
889+
#endif
871890
if (ret != SHOUTERR_SUCCESS) {
872891
kLogger.warning() << "shout_set_metadata fails with error code" << ret;
873892
}
@@ -888,7 +907,14 @@ void ShoutConnection::updateMetaData() {
888907
}
889908

890909
setFunctionCode(13);
891-
shout_set_metadata(m_pShout, m_pShoutMetaData);
910+
#ifdef MIXXX_USE_SHOUT_API_246
911+
int metaRet = shout_set_metadata_utf8(m_pShout, m_pShoutMetaData);
912+
#else
913+
int metaRet = shout_set_metadata(m_pShout, m_pShoutMetaData);
914+
#endif
915+
if (metaRet != SHOUTERR_SUCCESS) {
916+
kLogger.warning() << "shout_set_metadata fails with error code" << metaRet;
917+
}
892918
m_firstCall = true;
893919
}
894920
}

0 commit comments

Comments
 (0)