Audacity 3.2.0
Public Member Functions | List of all members
PCMImportPlugin Class Referencefinal

An ImportPlugin for PCM data. More...

Inheritance diagram for PCMImportPlugin:
[legend]
Collaboration diagram for PCMImportPlugin:
[legend]

Public Member Functions

 PCMImportPlugin ()
 
 ~PCMImportPlugin ()
 
wxString GetPluginStringID () override
 
TranslatableString GetPluginFormatDescription () override
 
std::unique_ptr< ImportFileHandleOpen (const FilePath &Filename, AudacityProject *) override
 
- Public Member Functions inherited from ImportPlugin
virtual wxString GetPluginStringID ()=0
 
virtual TranslatableString GetPluginFormatDescription ()=0
 
virtual FileExtensions GetSupportedExtensions ()
 
virtual TranslatableString FailureHint () const
 User visible message suggesting what to do when a file type isn't recognized; default empty string. More...
 
bool SupportsExtension (const FileExtension &extension)
 
virtual std::unique_ptr< ImportFileHandleOpen (const FilePath &Filename, AudacityProject *)=0
 
virtual ~ImportPlugin ()
 

Additional Inherited Members

- Protected Member Functions inherited from ImportPlugin
 ImportPlugin (FileExtensions supportedExtensions)
 
- Protected Attributes inherited from ImportPlugin
const FileExtensions mExtensions
 

Detailed Description

An ImportPlugin for PCM data.

Definition at line 59 of file ImportPCM.cpp.

Constructor & Destructor Documentation

◆ PCMImportPlugin()

PCMImportPlugin::PCMImportPlugin ( )
inline

Definition at line 62 of file ImportPCM.cpp.

64 {
65 }
FileExtensions sf_get_all_extensions()
ImportPlugin(FileExtensions supportedExtensions)

◆ ~PCMImportPlugin()

PCMImportPlugin::~PCMImportPlugin ( )
inline

Definition at line 67 of file ImportPCM.cpp.

67{ }

Member Function Documentation

◆ GetPluginFormatDescription()

TranslatableString PCMImportPlugin::GetPluginFormatDescription ( )
overridevirtual

Implements ImportPlugin.

Definition at line 107 of file ImportPCM.cpp.

108{
109 return DESC;
110}
#define DESC
Definition: ImportPCM.cpp:57

References DESC.

◆ GetPluginStringID()

wxString PCMImportPlugin::GetPluginStringID ( )
inlineoverridevirtual

Implements ImportPlugin.

Definition at line 69 of file ImportPCM.cpp.

69{ return wxT("libsndfile"); }
wxT("CloseDown"))

References wxT().

Here is the call graph for this function:

◆ Open()

std::unique_ptr< ImportFileHandle > PCMImportPlugin::Open ( const FilePath Filename,
AudacityProject  
)
overridevirtual

Implements ImportPlugin.

Definition at line 112 of file ImportPCM.cpp.

114{
115 SF_INFO info;
116 wxFile f; // will be closed when it goes out of scope
117 SFFile file;
118
119 memset(&info, 0, sizeof(info));
120
121
122#ifdef __WXGTK__
123 if (filename.Lower().EndsWith(wxT("mp3"))) {
124 // There is a bug in libsndfile where mp3s with duplicated metadata tags
125 // will crash libsndfile and thus audacity.
126 // We have patched the lib-src version of libsndfile, but
127 // for linux the user can build against the system libsndfile which
128 // still has this bug.
129 // This happens in sf_open_fd, which is the very first point of
130 // interaction with libsndfile, so the only workaround is to hardcode
131 // ImportPCM to not handle .mp3. Of course, this will still fail for mp3s
132 // that are mislabeled with a .wav or other extension.
133 // So, in the future we may want to write a simple parser to detect mp3s here.
134 return NULL;
135 }
136#endif
137
138
139 if (f.Open(filename)) {
140 // Even though there is an sf_open() that takes a filename, use the one that
141 // takes a file descriptor since wxWidgets can open a file with a Unicode name and
142 // libsndfile can't (under Windows).
143 file.reset(SFCall<SNDFILE*>(sf_open_fd, f.fd(), SFM_READ, &info, TRUE));
144 }
145
146 // The file descriptor is now owned by "file", so we must tell "f" to leave
147 // it alone. The file descriptor is closed by the destructor of file even if an error
148 // occurs.
149 f.Detach();
150
151 if (!file) {
152 // TODO: Handle error
153 //char str[1000];
154 //sf_error_str((SNDFILE *)NULL, str, 1000);
155
156 return nullptr;
157 } else if (file &&
158 (info.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_OGG) {
159 // mchinen 15.1.2012 - disallowing libsndfile to handle
160 // ogg files because seeking is broken at this date (very slow,
161 // seeks from beginning of file each seek).
162 // This was said by Erik (libsndfile maintainer).
163 // Note that this won't apply to our local libsndfile, so only
164 // linux builds that use --with-libsndfile=system are affected,
165 // as our local libsndfile doesn't do OGG.
166 // In particular ubuntu 10.10 and 11.04 are known to be affected
167 // When the bug is fixed, we can check version to avoid only
168 // the broken builds.
169
170 return nullptr;
171 }
172
173 // Success, so now transfer the duty to close the file from "file".
174 return std::make_unique<PCMImportFileHandle>(filename, std::move(file), info);
175}

References wxT().

Here is the call graph for this function:

The documentation for this class was generated from the following file: