Skip to content

Commit

Permalink
[xcode] Go back to wav as default format for RSP/DAAP transcoding
Browse files Browse the repository at this point in the history
But add "prefer_format" config option for mp3, incl. a check for an encoder.
The config option is currently not added to owntone.conf.in, so is undocumented
until decided what to do about possible alac support.
  • Loading branch information
ejurgensen committed Jan 1, 2024
1 parent 2871a03 commit b6ad73e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/conffile.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ static cfg_opt_t sec_library[] =
CFG_BOOL("itunes_smartpl", cfg_false, CFGF_NONE),
CFG_STR_LIST("no_decode", NULL, CFGF_NONE),
CFG_STR_LIST("force_decode", NULL, CFGF_NONE),
CFG_STR("prefer_format", NULL, CFGF_NONE),
CFG_BOOL("pipe_autostart", cfg_true, CFGF_NONE),
CFG_INT("pipe_sample_rate", 44100, CFGF_NONE),
CFG_INT("pipe_bits_per_sample", 16, CFGF_NONE),
Expand Down
26 changes: 22 additions & 4 deletions src/transcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1804,9 +1804,12 @@ transcode_decode_setup_raw(enum transcode_profile profile, struct media_quality
enum transcode_profile
transcode_needed(const char *user_agent, const char *client_codecs, char *file_codectype)
{
char *codectype;
const char *codectype;
const char *prefer_format;
cfg_t *lib;
bool force_xcode;
bool supports_mpeg;
bool supports_wav;
int count;
int i;

Expand Down Expand Up @@ -1862,10 +1865,25 @@ transcode_needed(const char *user_agent, const char *client_codecs, char *file_c

if (!force_xcode && strstr(client_codecs, file_codectype))
return XCODE_NONE;
else if (strstr(client_codecs, "mpeg"))
return XCODE_MP3;
else if (strstr(client_codecs, "wav"))

supports_mpeg = strstr(client_codecs, "mpeg") && avcodec_find_encoder(AV_CODEC_ID_MP3);
supports_wav = strstr(client_codecs, "wav");

prefer_format = cfg_getstr(lib, "prefer_format");
if (prefer_format)
{
if (strcmp(prefer_format, "wav") == 0 && supports_wav)
return XCODE_WAV;
else if (strcmp(prefer_format, "mpeg") == 0 && supports_mpeg)
return XCODE_MP3;
}

// This order determines the default if user didn't configure a preference.
// The lossless formats are given highest preference.
if (supports_wav)
return XCODE_WAV;
else if (supports_mpeg)
return XCODE_MP3;
else
return XCODE_UNKNOWN;
}
Expand Down

0 comments on commit b6ad73e

Please sign in to comment.