) -> ConfigEntry:
"""Create sample rates config entry based on player specific helpers."""
assert CONF_ENTRY_SAMPLE_RATES.options
- if supported_sample_rates is None:
- supported_sample_rates = []
- if supported_bit_depths is None:
- supported_bit_depths = []
+ final_supported_sample_rates = supported_sample_rates or []
+ final_supported_bit_depths = supported_bit_depths or []
conf_entry = ConfigEntry.from_dict(CONF_ENTRY_SAMPLE_RATES.to_dict())
conf_entry.hidden = hidden
options: list[ConfigValueOption] = []
bit_depth = int(bit_depth_str)
# if no supported sample rates are defined, we accept all within max_sample_rate
if not supported_sample_rates and max_sample_rate and sample_rate <= max_sample_rate:
- supported_sample_rates.append(sample_rate)
+ final_supported_sample_rates.append(sample_rate)
if not supported_bit_depths and max_bit_depth and bit_depth <= max_bit_depth:
- supported_bit_depths.append(bit_depth)
+ final_supported_bit_depths.append(bit_depth)
- if sample_rate not in supported_sample_rates:
+ if sample_rate not in final_supported_sample_rates:
continue
- if bit_depth not in supported_bit_depths:
+ if bit_depth not in final_supported_bit_depths:
continue
options.append(option)
if sample_rate <= safe_max_sample_rate and bit_depth <= safe_max_bit_depth:
streamdetails.prefer_album_loudness = prefer_album_loudness
player_settings = await mass.config.get_player_config(streamdetails.queue_id)
core_config = await mass.config.get_core_config("streams")
- streamdetails.target_loudness = player_settings.get_value(CONF_VOLUME_NORMALIZATION_TARGET)
+ streamdetails.target_loudness = float(
+ player_settings.get_value(CONF_VOLUME_NORMALIZATION_TARGET)
+ )
streamdetails.volume_normalization_mode = _get_normalization_mode(
core_config, player_settings, streamdetails
)
elif output_format.content_type == ContentType.WAV:
pcm_format = ContentType.from_bit_depth(output_format.bit_depth)
output_args = [
- # "-ar",
- # str(output_format.sample_rate),
+ "-ar",
+ str(output_format.sample_rate),
"-acodec",
pcm_format.name.lower(),
"-f",
elif output_format.content_type == ContentType.FLAC:
# use level 0 compression for fastest encoding
sample_fmt = "s32" if output_format.bit_depth > 16 else "s16"
- output_args += ["-sample_fmt", sample_fmt, "-f", "flac", "-compression_level", "0"]
+ output_args += [
+ "-sample_fmt",
+ sample_fmt,
+ "-ar",
+ str(output_format.sample_rate),
+ "-f",
+ "flac",
+ "-compression_level",
+ "0",
+ ]
elif output_format.content_type.is_pcm():
# use explicit format identifier for pcm formats
output_args += [
provider = cast(PluginProvider, self.mass.get_provider(media.custom_data["provider"]))
plugin_source = provider.get_source()
assert plugin_source.audio_format is not None # for type checking
- input_format = plugin_source.audio_format
- audio_source = (
- provider.get_audio_stream(player_id) # type: ignore[assignment]
- if plugin_source.stream_type == StreamType.CUSTOM
- else cast(str, plugin_source.path)
- )
+ if plugin_source.stream_type == StreamType.CUSTOM:
+ input_format = plugin_source.audio_format
+ audio_source = provider.get_audio_stream(player_id)
+ else:
+ input_format = AIRPLAY_PCM_FORMAT
+ audio_source = get_ffmpeg_stream(
+ audio_input=media.uri,
+ input_format=plugin_source.audio_format,
+ output_format=AIRPLAY_PCM_FORMAT,
+ )
elif media.queue_id and media.queue_id.startswith("ugp_"):
# special case: UGP stream
ugp_provider = cast(PlayerGroupProvider, self.mass.get_provider("player_group"))