Audacity 3.2.0
Classes | Functions | Variables
anonymous_namespace{ImportMP3_MPG123.cpp} Namespace Reference

Classes

class  MP3ImportFileHandle
 
class  MP3ImportPlugin
 

Functions

wxString GetId3v2Genre (Tags &tags, const char *genre)
 
wxSeekMode GetWXSeekMode (int whence)
 

Variables

const auto exts = { wxT("mp3"), wxT("mp2"), wxT("mpa") }
 
static Importer::RegisteredImportPlugin registered
 

Function Documentation

◆ GetId3v2Genre()

wxString anonymous_namespace{ImportMP3_MPG123.cpp}::GetId3v2Genre ( Tags tags,
const char *  genre 
)

Definition at line 50 of file ImportMP3_MPG123.cpp.

51{
52 if (genre == nullptr)
53 return {};
54
55 // It was observed, however, that Genre can use a different format
56 if (genre[0] != '(')
57 // We consider the string to be a genre name
58 return audacity::ToWXString(genre);
59
60 auto it = genre;
61 auto end = it + std::strlen(it);
62
63 while (*it == '(')
64 {
65 int tagValue;
66 auto result = FromChars(++it, end, tagValue);
67
68 // Parsing failed, consider it to be the genre
69 if (result.ec != std::errc {})
70 break;
71
72 const auto parsedGenre = tags.GetGenre(tagValue);
73
74 if (!parsedGenre.empty())
75 return parsedGenre;
76
77 it = result.ptr;
78
79 // Nothing left to parse
80 if (it == end)
81 break;
82
83 // Unexpected symbol in the tag
84 if (*it != ')')
85 break;
86
87 ++it;
88 }
89
90 if (it != end)
91 return audacity::ToWXString(it);
92
93 return audacity::ToWXString(genre);
94}
FromCharsResult FromChars(const char *buffer, const char *last, float &value) noexcept
Parse a string into a single precision floating point value, always uses the dot as decimal.
Definition: FromChars.cpp:153
wxString GetGenre(int value)
Definition: Tags.cpp:373
wxString ToWXString(const std::string &str)
const char * end(const char *str) noexcept
Definition: StringUtils.h:106

References details::end(), FromChars(), Tags::GetGenre(), and audacity::ToWXString().

Referenced by anonymous_namespace{ImportMP3_MPG123.cpp}::MP3ImportFileHandle::ReadTags().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetWXSeekMode()

wxSeekMode anonymous_namespace{ImportMP3_MPG123.cpp}::GetWXSeekMode ( int  whence)

Definition at line 507 of file ImportMP3_MPG123.cpp.

508{
509 switch (whence)
510 {
511 case SEEK_SET:
512 return wxFromStart;
513 case SEEK_CUR:
514 return wxFromCurrent;
515 case SEEK_END:
516 return wxFromEnd;
517 default:
518 // We have covered all the lseek whence modes defined by POSIX
519 // so this branch should not be reachable
520 assert(false);
521 return wxFromStart;
522 }
523}

Referenced by anonymous_namespace{ImportMP3_MPG123.cpp}::MP3ImportFileHandle::SeekCallback().

Here is the caller graph for this function:

Variable Documentation

◆ exts

const auto anonymous_namespace{ImportMP3_MPG123.cpp}::exts = { wxT("mp3"), wxT("mp2"), wxT("mpa") }

Definition at line 40 of file ImportMP3_MPG123.cpp.

◆ registered

Importer::RegisteredImportPlugin anonymous_namespace{ImportMP3_MPG123.cpp}::registered
static
Initial value:
{
"MP3",
std::make_unique<MP3ImportPlugin>()
}

Definition at line 176 of file ImportMP3_MPG123.cpp.