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

Constructor & Destructor Documentation

◆ PCMImportPlugin()

PCMImportPlugin::PCMImportPlugin ( )
inline

Definition at line 61 of file ImportPCM.cpp.

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

◆ ~PCMImportPlugin()

PCMImportPlugin::~PCMImportPlugin ( )
inline

Definition at line 66 of file ImportPCM.cpp.

66{ }

Member Function Documentation

◆ GetPluginFormatDescription()

TranslatableString PCMImportPlugin::GetPluginFormatDescription ( )
overridevirtual

Implements ImportPlugin.

Definition at line 106 of file ImportPCM.cpp.

107{
108 return DESC;
109}
#define DESC
Definition: ImportPCM.cpp:56

References DESC.

◆ GetPluginStringID()

wxString PCMImportPlugin::GetPluginStringID ( )
inlineoverridevirtual

Implements ImportPlugin.

Definition at line 68 of file ImportPCM.cpp.

68{ 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 111 of file ImportPCM.cpp.

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

References wxT().

Here is the call graph for this function:

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