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 64 of file ImportPCM.cpp.

Constructor & Destructor Documentation

◆ PCMImportPlugin()

PCMImportPlugin::PCMImportPlugin ( )
inline

Definition at line 67 of file ImportPCM.cpp.

69 {
70 }
FileExtensions sf_get_all_extensions()
ImportPlugin(FileExtensions supportedExtensions)

◆ ~PCMImportPlugin()

PCMImportPlugin::~PCMImportPlugin ( )
inline

Definition at line 72 of file ImportPCM.cpp.

72{ }

Member Function Documentation

◆ GetPluginFormatDescription()

TranslatableString PCMImportPlugin::GetPluginFormatDescription ( )
overridevirtual

Implements ImportPlugin.

Definition at line 110 of file ImportPCM.cpp.

111{
112 return DESC;
113}
#define DESC
Definition: ImportPCM.cpp:62

References DESC.

◆ GetPluginStringID()

wxString PCMImportPlugin::GetPluginStringID ( )
inlineoverridevirtual

Implements ImportPlugin.

Definition at line 74 of file ImportPCM.cpp.

74{ 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 115 of file ImportPCM.cpp.

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

References wxT().

Here is the call graph for this function:

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