46#define DESC XO("Ogg Vorbis files")
57 std::make_unique<UnusableImportPlugin>
71#include <vorbis/vorbisfile.h>
90 std::unique_ptr<ImportFileHandle>
Open(
99 std::unique_ptr<wxFFile> &&file,
100 std::unique_ptr<OggVorbis_File> &&vorbisFile)
108 auto strinfo =
XO(
"Index[%02x] Version[%d], Channels[%d], Rate[%ld]")
124 Tags *tags)
override;
143 if (StreamID < mVorbisFile->links)
167 wxUnusedVar(OV_CALLBACKS_DEFAULT);
168 wxUnusedVar(OV_CALLBACKS_NOCLOSE);
169 wxUnusedVar(OV_CALLBACKS_STREAMONLY);
170 wxUnusedVar(OV_CALLBACKS_STREAMONLY_NOCLOSE);
172 auto vorbisFile = std::make_unique<OggVorbis_File>();
173 auto file = std::make_unique<wxFFile>(filename,
wxT(
"rb"));
175 if (!file->IsOpened()) {
180 int err = ov_open(file->fp(), vorbisFile.get(), NULL, 0);
187 message =
XO(
"Media read error");
190 message =
XO(
"Not an Ogg Vorbis file");
193 message =
XO(
"Vorbis version mismatch");
196 message =
XO(
"Invalid Vorbis bitstream header");
199 message =
XO(
"Internal logic fault");
207 return std::make_unique<OggImportFileHandle>(filename, std::move(file), std::move(vorbisFile));
211 std::make_unique< OggImportPlugin >()
231 wxASSERT(
mFile->IsOpened());
254 link.resize(vi->channels);
256 for (
auto &channel : link)
262#define CODEC_TRANSFER_SIZE 4096u
266#define SAMPLES_PER_CALLBACK 100000
275 int testvar = 1, endian;
276 if (*(
char *)&testvar)
282 long samplesRead = 0;
284 int samplesSinceLastCallback = 0;
295 bytesRead = ov_read(
mVorbisFile.get(), (
char *)mainBuffer.get(),
302 if (bytesRead == OV_HOLE) {
304 wxLogError(
wxT(
"Ogg Vorbis importer: file %s is malformed, ov_read() reported a hole"),
312 else if (bytesRead < 0) {
315 wxLogError(
wxT(
"Ogg Vorbis importer: ov_read() returned error %i"),
320 samplesRead = bytesRead /
mVorbisFile->vi[bitstream].channels /
sizeof(short);
324 std::advance(iter, bitstream);
327 auto iter2 = iter->begin();
328 for (
int c = 0; c <
mVorbisFile->vi[bitstream].channels; ++iter2, ++c)
329 iter2->get()->Append((
char *)(mainBuffer.get() + c),
336 samplesSinceLastCallback += samplesRead;
345 auto res = updateResult;
347 res = ProgressResult::Failed;
355 for (
auto &channel : link)
357 outTracks.push_back(std::move(link));
363 for (
int c = 0; c <
mVorbisFile->vc[0].comments; c++) {
365 wxString
name = comment.BeforeFirst(
wxT(
'='));
366 wxString value = comment.AfterFirst(
wxT(
'='));
369 if (value.length() == 4 && value.ToLong(&val)) {
const TranslatableString name
wxArrayStringEx FileExtensions
std::vector< std::shared_ptr< WaveTrack > > NewChannelGroup
std::vector< std::vector< std::shared_ptr< WaveTrack > > > TrackHolders
static Importer::RegisteredImportPlugin registered
#define SAMPLES_PER_CALLBACK
#define CODEC_TRANSFER_SIZE
The interface that all file import "plugins" (if you want to call them that) must implement....
std::vector< TranslatableString > TranslatableStrings
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
An ImportFileHandle for data.
unsigned long long ByteCount
std::unique_ptr< ProgressDialog > mProgress
std::shared_ptr< WaveTrack > NewWaveTrack(WaveTrackFactory &trackFactory, sampleFormat effectiveFormat, double rate)
Build a wave track with appropriate format, which will not be narrower than the specified one.
Base class for FlacImportPlugin, LOFImportPlugin, MP3ImportPlugin, OggImportPlugin and PCMImportPlugi...
wxInt32 GetStreamCount() override
std::unique_ptr< wxFFile > mFile
TranslatableString GetFileDescription() override
ArrayOf< int > mStreamUsage
OggImportFileHandle(const FilePath &filename, std::unique_ptr< wxFFile > &&file, std::unique_ptr< OggVorbis_File > &&vorbisFile)
ByteCount GetFileUncompressedBytes() override
ProgressResult Import(WaveTrackFactory *trackFactory, TrackHolders &outTracks, Tags *tags) override
const TranslatableStrings & GetStreamInfo() override
TranslatableStrings mStreamInfo
void SetStreamUsage(wxInt32 StreamID, bool Use) override
std::unique_ptr< OggVorbis_File > mVorbisFile
std::list< NewChannelGroup > mChannels
wxString GetPluginStringID() override
std::unique_ptr< ImportFileHandle > Open(const FilePath &Filename, AudacityProject *) override
TranslatableString GetPluginFormatDescription() override
Holds a msgid for the translation catalog; may also bind format arguments.
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.