Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
e152e843
Commit
e152e843
authored
Jul 05, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag/Handler: add method OnAudioFormat()
parent
9ff1ff75
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
0 deletions
+36
-0
Handler.cxx
src/tag/Handler.cxx
+6
-0
Handler.hxx
src/tag/Handler.hxx
+24
-0
read_tags.cxx
test/read_tags.cxx
+6
-0
No files found.
src/tag/Handler.cxx
View file @
e152e843
...
...
@@ -20,12 +20,18 @@
#include "config.h"
#include "Handler.hxx"
#include "Builder.hxx"
#include "AudioFormat.hxx"
#include "util/ASCII.hxx"
#include "util/StringFormat.hxx"
#include <stdlib.h>
void
NullTagHandler
::
OnAudioFormat
(
gcc_unused
AudioFormat
af
)
noexcept
{
}
void
AddTagHandler
::
OnDuration
(
SongTime
duration
)
noexcept
{
tag
.
SetDuration
(
duration
);
...
...
src/tag/Handler.hxx
View file @
e152e843
...
...
@@ -25,6 +25,7 @@
#include "Chrono.hxx"
#include "Compiler.h"
struct
AudioFormat
;
class
TagBuilder
;
/**
...
...
@@ -37,6 +38,7 @@ public:
static
constexpr
unsigned
WANT_DURATION
=
0x1
;
static
constexpr
unsigned
WANT_TAG
=
0x2
;
static
constexpr
unsigned
WANT_PAIR
=
0x4
;
static
constexpr
unsigned
WANT_AUDIO_FORMAT
=
0x8
;
explicit
TagHandler
(
unsigned
_want_mask
)
noexcept
:
want_mask
(
_want_mask
)
{}
...
...
@@ -56,6 +58,10 @@ public:
return
want_mask
&
WANT_PAIR
;
}
bool
WantAudioFormat
()
const
noexcept
{
return
want_mask
&
WANT_AUDIO_FORMAT
;
}
/**
* Declare the duration of a song. Do not call
* this when the duration could not be determined, because
...
...
@@ -76,6 +82,23 @@ public:
* representation of tags.
*/
virtual
void
OnPair
(
const
char
*
key
,
const
char
*
value
)
noexcept
=
0
;
/**
* Declare the audio format of a song.
*
* Because the #AudioFormat type is limited to formats
* supported by MPD, the value passed to this method may be an
* approximation (should be the one passed to
* DecoderClient::Ready()). For example, some codecs such as
* MP3 are bit depth agnostic, so the decoder plugin chooses a
* bit depth depending on what the codec library emits.
*
* This method is only called by those decoder plugins which
* implement it. Some may not have any code for calling it,
* and others may decide that determining the audio format is
* too expensive.
*/
virtual
void
OnAudioFormat
(
AudioFormat
af
)
noexcept
=
0
;
};
class
NullTagHandler
:
public
TagHandler
{
...
...
@@ -88,6 +111,7 @@ public:
gcc_unused
const
char
*
value
)
noexcept
override
{}
void
OnPair
(
gcc_unused
const
char
*
key
,
gcc_unused
const
char
*
value
)
noexcept
override
{}
void
OnAudioFormat
(
AudioFormat
af
)
noexcept
override
;
};
/**
...
...
test/read_tags.cxx
View file @
e152e843
...
...
@@ -26,8 +26,10 @@
#include "tag/Handler.hxx"
#include "tag/Generic.hxx"
#include "fs/Path.hxx"
#include "AudioFormat.hxx"
#include "Log.hxx"
#include "util/ScopeExit.hxx"
#include "util/StringBuffer.hxx"
#include <stdexcept>
...
...
@@ -63,6 +65,10 @@ public:
void
OnPair
(
const
char
*
key
,
const
char
*
value
)
noexcept
override
{
printf
(
"
\"
%s
\"
=%s
\n
"
,
key
,
value
);
}
void
OnAudioFormat
(
AudioFormat
af
)
noexcept
override
{
printf
(
"%s
\n
"
,
ToString
(
af
).
c_str
());
}
};
int
main
(
int
argc
,
char
**
argv
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment