fix country code in cspot

This commit is contained in:
philippe44
2023-03-29 12:06:20 -07:00
parent 236cfef05d
commit a9a9018794
3 changed files with 8 additions and 9 deletions

View File

@@ -120,9 +120,9 @@ void MercurySession::handlePacket() {
switch (static_cast<RequestType>(packet.command)) { switch (static_cast<RequestType>(packet.command)) {
case RequestType::COUNTRY_CODE_RESPONSE: { case RequestType::COUNTRY_CODE_RESPONSE: {
this->countryCode = std::string(); this->countryCode = std::string();
this->countryCode.reserve(2); this->countryCode.resize(2);
memcpy(this->countryCode.data(), packet.data.data(), 2); memcpy(this->countryCode.data(), packet.data.data(), 2);
CSPOT_LOG(debug, "Received country code"); CSPOT_LOG(debug, "Received country code %s", this->countryCode.c_str());
break; break;
} }
case RequestType::AUDIO_KEY_FAILURE_RESPONSE: case RequestType::AUDIO_KEY_FAILURE_RESPONSE:

View File

@@ -77,12 +77,11 @@ void TrackProvider::onMetadataResponse(MercurySession::Response& res) {
std::vector<uint8_t> trackId; std::vector<uint8_t> trackId;
std::vector<uint8_t> fileId; std::vector<uint8_t> fileId;
AudioFormat format = AudioFormat_OGG_VORBIS_160;
if (altIndex < 0) { if (altIndex < 0) {
trackId = pbArrayToVector(trackInfo.gid); trackId = pbArrayToVector(trackInfo.gid);
for (int x = 0; x < trackInfo.file_count; x++) { for (int x = 0; x < trackInfo.file_count; x++) {
if (trackInfo.file[x].format == format) { if (trackInfo.file[x].format == ctx->config.audioFormat) {
fileId = pbArrayToVector(trackInfo.file[x].file_id); fileId = pbArrayToVector(trackInfo.file[x].file_id);
break; // If file found stop searching break; // If file found stop searching
} }
@@ -90,7 +89,7 @@ void TrackProvider::onMetadataResponse(MercurySession::Response& res) {
} else { } else {
trackId = pbArrayToVector(trackInfo.alternative[altIndex].gid); trackId = pbArrayToVector(trackInfo.alternative[altIndex].gid);
for (int x = 0; x < trackInfo.alternative[altIndex].file_count; x++) { for (int x = 0; x < trackInfo.alternative[altIndex].file_count; x++) {
if (trackInfo.alternative[altIndex].file[x].format == format) { if (trackInfo.alternative[altIndex].file[x].format == ctx->config.audioFormat) {
fileId = fileId =
pbArrayToVector(trackInfo.alternative[altIndex].file[x].file_id); pbArrayToVector(trackInfo.alternative[altIndex].file[x].file_id);
break; // If file found stop searching break; // If file found stop searching

View File

@@ -123,7 +123,7 @@ static bool bt_sink_cmd_handler(bt_sink_cmd_t cmd, va_list args)
{ {
// don't LOCK_O as there is always a chance that LMS takes control later anyway // don't LOCK_O as there is always a chance that LMS takes control later anyway
if (output.external != DECODE_BT && output.state > OUTPUT_STOPPED) { if (output.external != DECODE_BT && output.state > OUTPUT_STOPPED) {
LOG_WARN("Cannot use BT sink while LMS/AirPlay/CSpot are controlling player"); LOG_WARN("Cannot use BT sink while LMS/AirPlay/CSpot are controlling player %d", output.external);
return false; return false;
} }
@@ -205,7 +205,7 @@ static bool raop_sink_cmd_handler(raop_event_t event, va_list args)
{ {
// don't LOCK_O as there is always a chance that LMS takes control later anyway // don't LOCK_O as there is always a chance that LMS takes control later anyway
if (output.external != DECODE_RAOP && output.state > OUTPUT_STOPPED) { if (output.external != DECODE_RAOP && output.state > OUTPUT_STOPPED) {
LOG_WARN("Cannot use Airplay sink while LMS/BT/CSpot are controlling player"); LOG_WARN("Cannot use Airplay sink while LMS/BT/CSpot are controlling player %d", output.external);
return false; return false;
} }
@@ -338,7 +338,7 @@ static bool cspot_cmd_handler(cspot_event_t cmd, va_list args)
{ {
// don't LOCK_O as there is always a chance that LMS takes control later anyway // don't LOCK_O as there is always a chance that LMS takes control later anyway
if (output.external != DECODE_CSPOT && output.state > OUTPUT_STOPPED) { if (output.external != DECODE_CSPOT && output.state > OUTPUT_STOPPED) {
LOG_WARN("Cannot use CSpot sink while LMS/BT/Airplay are controlling player"); LOG_WARN("Cannot use CSpot sink while LMS/BT/Airplay are controlling player %d", output.external);
return false; return false;
} }