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
c645b906
Commit
c645b906
authored
Oct 02, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/flac: add C++ libFLAC wrappers
Not using libFLAC++ because this library adds a lot of overhead due to virtual method calls. This new class library is zero-overhead.
parent
9c1d1ef2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
14 deletions
+71
-14
FLACDecoderPlugin.cxx
src/decoder/FLACDecoderPlugin.cxx
+8
-13
FLACMetaData.hxx
src/decoder/FLACMetaData.hxx
+63
-1
No files found.
src/decoder/FLACDecoderPlugin.cxx
View file @
c645b906
...
...
@@ -366,27 +366,22 @@ static bool
oggflac_scan_file
(
const
char
*
file
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
FLAC__Metadata_Iterator
*
it
;
FLAC__StreamMetadata
*
block
;
FLAC__Metadata_Chain
*
chain
=
FLAC__metadata_chain_new
();
if
(
!
(
FLAC__metadata_chain_read_ogg
(
chain
,
file
)))
{
FLAC__metadata_chain_delete
(
chain
);
FLACMetadataChain
chain
;
if
(
!
chain
.
ReadOgg
(
file
))
{
g_debug
(
"Failed to read OggFLAC tags: %s"
,
chain
.
GetStatusString
());
return
false
;
}
it
=
FLAC__metadata_iterator_new
();
FLAC__metadata_iterator_init
(
it
,
chain
);
FLACMetadataIterator
iterator
(
chain
);
do
{
if
(
!
(
block
=
FLAC__metadata_iterator_get_block
(
it
)))
FLAC__StreamMetadata
*
block
=
iterator
.
GetBlock
();
if
(
block
==
nullptr
)
break
;
flac_scan_metadata
(
block
,
handler
,
handler_ctx
);
}
while
(
FLAC__metadata_iterator_next
(
it
));
FLAC__metadata_iterator_delete
(
it
);
}
while
(
iterator
.
Next
());
FLAC__metadata_chain_delete
(
chain
);
return
true
;
}
...
...
src/decoder/FLACMetaData.hxx
View file @
c645b906
...
...
@@ -20,9 +20,71 @@
#ifndef MPD_FLAC_METADATA_H
#define MPD_FLAC_METADATA_H
#include "gcc.h"
#include <FLAC/metadata.h>
#include <assert.h>
#include <stdbool.h>
#include <FLAC/metadata.h>
class
FLACMetadataChain
{
FLAC__Metadata_Chain
*
chain
;
public
:
FLACMetadataChain
()
:
chain
(
::
FLAC__metadata_chain_new
())
{}
~
FLACMetadataChain
()
{
::
FLAC__metadata_chain_delete
(
chain
);
}
explicit
operator
FLAC__Metadata_Chain
*
()
{
return
chain
;
}
bool
Read
(
const
char
*
path
)
{
return
::
FLAC__metadata_chain_read
(
chain
,
path
);
}
bool
ReadOgg
(
const
char
*
path
)
{
return
::
FLAC__metadata_chain_read_ogg
(
chain
,
path
);
}
gcc_pure
FLAC__Metadata_ChainStatus
GetStatus
()
const
{
return
::
FLAC__metadata_chain_status
(
chain
);
}
gcc_pure
const
char
*
GetStatusString
()
const
{
return
FLAC__Metadata_ChainStatusString
[
GetStatus
()];
}
};
class
FLACMetadataIterator
{
FLAC__Metadata_Iterator
*
iterator
;
public
:
FLACMetadataIterator
()
:
iterator
(
::
FLAC__metadata_iterator_new
())
{}
FLACMetadataIterator
(
FLACMetadataChain
&
chain
)
:
iterator
(
::
FLAC__metadata_iterator_new
())
{
::
FLAC__metadata_iterator_init
(
iterator
,
(
FLAC__Metadata_Chain
*
)
chain
);
}
~
FLACMetadataIterator
()
{
::
FLAC__metadata_iterator_delete
(
iterator
);
}
bool
Next
()
{
return
::
FLAC__metadata_iterator_next
(
iterator
);
}
gcc_pure
FLAC__StreamMetadata
*
GetBlock
()
{
return
::
FLAC__metadata_iterator_get_block
(
iterator
);
}
};
struct
tag_handler
;
struct
tag
;
...
...
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