Consolidate Export Format/Spec comparision

This commit is contained in:
Robin Gareus 2022-12-07 17:56:07 +01:00
parent 1005fc5716
commit e28e079c9f
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 15 additions and 6 deletions

View File

@ -79,6 +79,7 @@ class LIBARDOUR_API ExportFormatSpecification : public ExportFormatBase {
/* Modifying functions */
void set_format (boost::shared_ptr<ExportFormat> format);
bool is_format (boost::shared_ptr<ExportFormat> format) const;
void set_name (std::string const & name) { _name = name; }

View File

@ -480,11 +480,7 @@ ExportFormatManager::change_format_selection (bool select, WeakExportFormatPtr c
if (select) {
select_format (ptr);
} else if (ptr->get_format_id() == current_selection->format_id() &&
// BWF has the same format id with wav, so we need to check this.
ptr->has_broadcast_info () == current_selection->has_broadcast_info () &&
// Ogg can be Vorbis or OPUS
(ptr->get_format_id () != ExportFormatBase::F_Ogg || (ptr->get_explicit_sample_format () == current_selection->sample_format ()))) {
} else if (current_selection->is_format (ptr)) {
ptr.reset();
select_format (ptr);
}

View File

@ -581,12 +581,24 @@ ExportFormatSpecification::is_complete () const
return true;
}
bool
ExportFormatSpecification::is_format (boost::shared_ptr<ExportFormat> format) const
{
assert (format);
return (format_id () == format->get_format_id () &&
/* BWF has the same format id with wav, so we need to check this. */
has_broadcast_info () == format->has_broadcast_info () &&
/* F_Ogg can be Vorbis or OPUS */
(format_id () != ExportFormatBase::F_Ogg || (format->get_explicit_sample_format () == sample_format ())));
}
void
ExportFormatSpecification::set_format (boost::shared_ptr<ExportFormat> format)
{
if (format) {
FormatId new_fmt = format->get_format_id ();
bool fmt_changed = format_id() != new_fmt;
bool fmt_changed = !is_format (format);
set_format_id (new_fmt);
set_type (format->get_type());