mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-11 00:56:33 +01:00
Made Export format compatibility checking a bit more robust
git-svn-id: svn://localhost/ardour2/branches/3.0@3829 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
400f8bb03d
commit
474f8bc376
3 changed files with 29 additions and 31 deletions
|
|
@ -26,11 +26,15 @@
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <boost/weak_ptr.hpp>
|
#include <boost/weak_ptr.hpp>
|
||||||
|
#include <pbd/failed_constructor.h>
|
||||||
|
|
||||||
namespace ARDOUR
|
namespace ARDOUR
|
||||||
{
|
{
|
||||||
|
|
||||||
class HasSampleFormat;
|
class ExportFormatIncompatible : public failed_constructor {
|
||||||
|
public:
|
||||||
|
virtual const char *what() const throw() { return "Export format constructor failed: Format incompatible with system"; }
|
||||||
|
};
|
||||||
|
|
||||||
/// Base class for formats
|
/// Base class for formats
|
||||||
class ExportFormat : public ExportFormatBase, public ExportFormatBase::SelectableCompatible {
|
class ExportFormat : public ExportFormatBase, public ExportFormatBase::SelectableCompatible {
|
||||||
|
|
@ -170,8 +174,6 @@ class ExportFormatOggVorbis : public ExportFormat {
|
||||||
ExportFormatOggVorbis ();
|
ExportFormatOggVorbis ();
|
||||||
~ExportFormatOggVorbis () {};
|
~ExportFormatOggVorbis () {};
|
||||||
|
|
||||||
static bool check_system_compatibility ();
|
|
||||||
|
|
||||||
bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
|
bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
|
||||||
Type get_type () const { return T_Sndfile; }
|
Type get_type () const { return T_Sndfile; }
|
||||||
SampleFormat get_explicit_sample_format () const { return SF_Vorbis; }
|
SampleFormat get_explicit_sample_format () const { return SF_Vorbis; }
|
||||||
|
|
@ -183,8 +185,6 @@ class ExportFormatFLAC : public ExportFormat, public HasSampleFormat {
|
||||||
ExportFormatFLAC ();
|
ExportFormatFLAC ();
|
||||||
~ExportFormatFLAC () {};
|
~ExportFormatFLAC () {};
|
||||||
|
|
||||||
static bool check_system_compatibility ();
|
|
||||||
|
|
||||||
bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
|
bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
|
||||||
Type get_type () const { return T_Sndfile; }
|
Type get_type () const { return T_Sndfile; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -185,15 +185,15 @@ ExportFormatManager::init_formats ()
|
||||||
fl_ptr->set_extension ("raw");
|
fl_ptr->set_extension ("raw");
|
||||||
add_format (f_ptr);
|
add_format (f_ptr);
|
||||||
|
|
||||||
if (ExportFormatOggVorbis::check_system_compatibility()) {
|
try {
|
||||||
f_ptr.reset (new ExportFormatOggVorbis ());
|
f_ptr.reset (new ExportFormatOggVorbis ());
|
||||||
add_format (f_ptr);
|
add_format (f_ptr);
|
||||||
}
|
} catch (ExportFormatIncompatible & e) {}
|
||||||
|
|
||||||
if (ExportFormatFLAC::check_system_compatibility()) {
|
try {
|
||||||
f_ptr.reset (new ExportFormatFLAC ());
|
f_ptr.reset (new ExportFormatFLAC ());
|
||||||
add_format (f_ptr);
|
add_format (f_ptr);
|
||||||
}
|
} catch (ExportFormatIncompatible & e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -234,6 +234,16 @@ ExportFormatLinear::set_compatibility_state (ExportFormatCompatibility const & c
|
||||||
|
|
||||||
ExportFormatOggVorbis::ExportFormatOggVorbis ()
|
ExportFormatOggVorbis::ExportFormatOggVorbis ()
|
||||||
{
|
{
|
||||||
|
/* Check system compatibility */
|
||||||
|
|
||||||
|
SF_INFO sf_info;
|
||||||
|
sf_info.channels = 2;
|
||||||
|
sf_info.samplerate = SR_44_1;
|
||||||
|
sf_info.format = F_Ogg | SF_Vorbis;
|
||||||
|
if (sf_format_check (&sf_info) != SF_TRUE) {
|
||||||
|
throw ExportFormatIncompatible();
|
||||||
|
}
|
||||||
|
|
||||||
set_name ("Ogg Vorbis");
|
set_name ("Ogg Vorbis");
|
||||||
set_format_id (F_Ogg);
|
set_format_id (F_Ogg);
|
||||||
sample_formats.insert (SF_Vorbis);
|
sample_formats.insert (SF_Vorbis);
|
||||||
|
|
@ -251,17 +261,6 @@ ExportFormatOggVorbis::ExportFormatOggVorbis ()
|
||||||
set_quality (Q_LossyCompression);
|
set_quality (Q_LossyCompression);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
ExportFormatOggVorbis::check_system_compatibility ()
|
|
||||||
{
|
|
||||||
SF_INFO sf_info;
|
|
||||||
sf_info.channels = 2;
|
|
||||||
sf_info.samplerate = SR_44_1;
|
|
||||||
sf_info.format = F_Ogg | SF_Vorbis;
|
|
||||||
|
|
||||||
return (sf_format_check (&sf_info) == SF_TRUE ? true : false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ExportFormatOggVorbis::set_compatibility_state (ExportFormatCompatibility const & compatibility)
|
ExportFormatOggVorbis::set_compatibility_state (ExportFormatCompatibility const & compatibility)
|
||||||
{
|
{
|
||||||
|
|
@ -275,6 +274,16 @@ ExportFormatOggVorbis::set_compatibility_state (ExportFormatCompatibility const
|
||||||
ExportFormatFLAC::ExportFormatFLAC () :
|
ExportFormatFLAC::ExportFormatFLAC () :
|
||||||
HasSampleFormat (sample_formats)
|
HasSampleFormat (sample_formats)
|
||||||
{
|
{
|
||||||
|
/* Check system compatibility */
|
||||||
|
|
||||||
|
SF_INFO sf_info;
|
||||||
|
sf_info.channels = 2;
|
||||||
|
sf_info.samplerate = SR_44_1;
|
||||||
|
sf_info.format = F_FLAC | SF_16;
|
||||||
|
if (sf_format_check (&sf_info) != SF_TRUE) {
|
||||||
|
throw ExportFormatIncompatible();
|
||||||
|
}
|
||||||
|
|
||||||
set_name ("FLAC");
|
set_name ("FLAC");
|
||||||
set_format_id (F_FLAC);
|
set_format_id (F_FLAC);
|
||||||
|
|
||||||
|
|
@ -295,17 +304,6 @@ ExportFormatFLAC::ExportFormatFLAC () :
|
||||||
set_quality (Q_LosslessCompression);
|
set_quality (Q_LosslessCompression);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
ExportFormatFLAC::check_system_compatibility ()
|
|
||||||
{
|
|
||||||
SF_INFO sf_info;
|
|
||||||
sf_info.channels = 2;
|
|
||||||
sf_info.samplerate = SR_44_1;
|
|
||||||
sf_info.format = F_FLAC | SF_16;
|
|
||||||
|
|
||||||
return (sf_format_check (&sf_info) == SF_TRUE ? true : false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ExportFormatFLAC::set_compatibility_state (ExportFormatCompatibility const & compatibility)
|
ExportFormatFLAC::set_compatibility_state (ExportFormatCompatibility const & compatibility)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue