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
86dc7929
Commit
86dc7929
authored
Jan 15, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flac: no CamelCase
Renamed types, functions, variables.
parent
a7461dc2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
117 additions
and
108 deletions
+117
-108
_flac_common.c
src/decoder/_flac_common.c
+44
-39
_flac_common.h
src/decoder/_flac_common.h
+16
-12
flac_plugin.c
src/decoder/flac_plugin.c
+0
-0
oggflac_plugin.c
src/decoder/oggflac_plugin.c
+53
-53
decoder_list.c
src/decoder_list.c
+4
-4
No files found.
src/decoder/_flac_common.c
View file @
86dc7929
...
@@ -26,20 +26,22 @@
...
@@ -26,20 +26,22 @@
#include <FLAC/format.h>
#include <FLAC/format.h>
#include <FLAC/metadata.h>
#include <FLAC/metadata.h>
void
init_FlacData
(
FlacData
*
data
,
struct
decoder
*
decoder
,
void
struct
input_stream
*
inStream
)
flac_data_init
(
struct
flac_data
*
data
,
struct
decoder
*
decoder
,
struct
input_stream
*
input_stream
)
{
{
data
->
time
=
0
;
data
->
time
=
0
;
data
->
position
=
0
;
data
->
position
=
0
;
data
->
bit
R
ate
=
0
;
data
->
bit
_r
ate
=
0
;
data
->
decoder
=
decoder
;
data
->
decoder
=
decoder
;
data
->
in
Stream
=
inS
tream
;
data
->
in
put_stream
=
input_s
tream
;
data
->
replay
GainI
nfo
=
NULL
;
data
->
replay
_gain_i
nfo
=
NULL
;
data
->
tag
=
NULL
;
data
->
tag
=
NULL
;
}
}
static
int
flacFindVorbisCommentFloat
(
const
FLAC__StreamMetadata
*
block
,
static
int
const
char
*
cmnt
,
float
*
fl
)
flac_find_float_comment
(
const
FLAC__StreamMetadata
*
block
,
const
char
*
cmnt
,
float
*
fl
)
{
{
int
offset
=
int
offset
=
FLAC__metadata_object_vorbiscomment_find_entry_from
(
block
,
0
,
cmnt
);
FLAC__metadata_object_vorbiscomment_find_entry_from
(
block
,
0
,
cmnt
);
...
@@ -65,28 +67,29 @@ static int flacFindVorbisCommentFloat(const FLAC__StreamMetadata * block,
...
@@ -65,28 +67,29 @@ static int flacFindVorbisCommentFloat(const FLAC__StreamMetadata * block,
}
}
/* replaygain stuff by AliasMrJones */
/* replaygain stuff by AliasMrJones */
static
void
flacParseReplayGain
(
const
FLAC__StreamMetadata
*
block
,
static
void
FlacData
*
data
)
flac_parse_replay_gain
(
const
FLAC__StreamMetadata
*
block
,
struct
flac_data
*
data
)
{
{
int
found
=
0
;
int
found
=
0
;
if
(
data
->
replay
GainI
nfo
)
if
(
data
->
replay
_gain_i
nfo
)
replay_gain_info_free
(
data
->
replay
GainI
nfo
);
replay_gain_info_free
(
data
->
replay
_gain_i
nfo
);
data
->
replay
GainI
nfo
=
replay_gain_info_new
();
data
->
replay
_gain_i
nfo
=
replay_gain_info_new
();
found
|=
flac
FindVorbisCommentFloa
t
(
block
,
"replaygain_album_gain"
,
found
|=
flac
_find_float_commen
t
(
block
,
"replaygain_album_gain"
,
&
data
->
replayGainI
nfo
->
tuples
[
REPLAY_GAIN_ALBUM
].
gain
);
&
data
->
replay_gain_i
nfo
->
tuples
[
REPLAY_GAIN_ALBUM
].
gain
);
found
|=
flac
FindVorbisCommentFloa
t
(
block
,
"replaygain_album_peak"
,
found
|=
flac
_find_float_commen
t
(
block
,
"replaygain_album_peak"
,
&
data
->
replayGainI
nfo
->
tuples
[
REPLAY_GAIN_ALBUM
].
peak
);
&
data
->
replay_gain_i
nfo
->
tuples
[
REPLAY_GAIN_ALBUM
].
peak
);
found
|=
flac
FindVorbisCommentFloa
t
(
block
,
"replaygain_track_gain"
,
found
|=
flac
_find_float_commen
t
(
block
,
"replaygain_track_gain"
,
&
data
->
replayGainI
nfo
->
tuples
[
REPLAY_GAIN_TRACK
].
gain
);
&
data
->
replay_gain_i
nfo
->
tuples
[
REPLAY_GAIN_TRACK
].
gain
);
found
|=
flac
FindVorbisCommentFloa
t
(
block
,
"replaygain_track_peak"
,
found
|=
flac
_find_float_commen
t
(
block
,
"replaygain_track_peak"
,
&
data
->
replayGainI
nfo
->
tuples
[
REPLAY_GAIN_TRACK
].
peak
);
&
data
->
replay_gain_i
nfo
->
tuples
[
REPLAY_GAIN_TRACK
].
peak
);
if
(
!
found
)
{
if
(
!
found
)
{
replay_gain_info_free
(
data
->
replay
GainI
nfo
);
replay_gain_info_free
(
data
->
replay
_gain_i
nfo
);
data
->
replay
GainI
nfo
=
NULL
;
data
->
replay
_gain_i
nfo
=
NULL
;
}
}
}
}
...
@@ -95,16 +98,17 @@ static void flacParseReplayGain(const FLAC__StreamMetadata * block,
...
@@ -95,16 +98,17 @@ static void flacParseReplayGain(const FLAC__StreamMetadata * block,
static
const
char
*
VORBIS_COMMENT_TRACK_KEY
=
"tracknumber"
;
static
const
char
*
VORBIS_COMMENT_TRACK_KEY
=
"tracknumber"
;
static
const
char
*
VORBIS_COMMENT_DISC_KEY
=
"discnumber"
;
static
const
char
*
VORBIS_COMMENT_DISC_KEY
=
"discnumber"
;
static
unsigned
int
commentMatchesAddToTag
(
const
static
unsigned
int
FLAC__StreamMetadata_VorbisComment_Entry
flac_copy_vorbis_comment
(
const
*
entry
,
unsigned
int
itemType
,
FLAC__StreamMetadata_VorbisComment_Entry
*
entry
,
struct
tag
**
tag
)
enum
tag_type
type
,
struct
tag
**
tag
)
{
{
const
char
*
str
;
const
char
*
str
;
size_t
slen
;
size_t
slen
;
int
vlen
;
int
vlen
;
switch
(
itemT
ype
)
{
switch
(
t
ype
)
{
case
TAG_ITEM_TRACK
:
case
TAG_ITEM_TRACK
:
str
=
VORBIS_COMMENT_TRACK_KEY
;
str
=
VORBIS_COMMENT_TRACK_KEY
;
break
;
break
;
...
@@ -112,7 +116,7 @@ static unsigned int commentMatchesAddToTag(const
...
@@ -112,7 +116,7 @@ static unsigned int commentMatchesAddToTag(const
str
=
VORBIS_COMMENT_DISC_KEY
;
str
=
VORBIS_COMMENT_DISC_KEY
;
break
;
break
;
default:
default:
str
=
mpdTagItemKeys
[
itemT
ype
];
str
=
mpdTagItemKeys
[
t
ype
];
}
}
slen
=
strlen
(
str
);
slen
=
strlen
(
str
);
vlen
=
entry
->
length
-
slen
-
1
;
vlen
=
entry
->
length
-
slen
-
1
;
...
@@ -122,7 +126,7 @@ static unsigned int commentMatchesAddToTag(const
...
@@ -122,7 +126,7 @@ static unsigned int commentMatchesAddToTag(const
if
(
!*
tag
)
if
(
!*
tag
)
*
tag
=
tag_new
();
*
tag
=
tag_new
();
tag_add_item_n
(
*
tag
,
itemT
ype
,
tag_add_item_n
(
*
tag
,
t
ype
,
(
char
*
)(
entry
->
entry
+
slen
+
1
),
vlen
);
(
char
*
)(
entry
->
entry
+
slen
+
1
),
vlen
);
return
1
;
return
1
;
...
@@ -131,8 +135,9 @@ static unsigned int commentMatchesAddToTag(const
...
@@ -131,8 +135,9 @@ static unsigned int commentMatchesAddToTag(const
return
0
;
return
0
;
}
}
struct
tag
*
copyVorbisCommentBlockToMpdTag
(
const
FLAC__StreamMetadata
*
block
,
struct
tag
*
struct
tag
*
tag
)
flac_vorbis_comments_to_tag
(
const
FLAC__StreamMetadata
*
block
,
struct
tag
*
tag
)
{
{
unsigned
int
i
,
j
;
unsigned
int
i
,
j
;
FLAC__StreamMetadata_VorbisComment_Entry
*
comments
;
FLAC__StreamMetadata_VorbisComment_Entry
*
comments
;
...
@@ -141,7 +146,7 @@ struct tag *copyVorbisCommentBlockToMpdTag(const FLAC__StreamMetadata * block,
...
@@ -141,7 +146,7 @@ struct tag *copyVorbisCommentBlockToMpdTag(const FLAC__StreamMetadata * block,
for
(
i
=
block
->
data
.
vorbis_comment
.
num_comments
;
i
!=
0
;
--
i
)
{
for
(
i
=
block
->
data
.
vorbis_comment
.
num_comments
;
i
!=
0
;
--
i
)
{
for
(
j
=
TAG_NUM_OF_ITEM_TYPES
;
j
--
;)
{
for
(
j
=
TAG_NUM_OF_ITEM_TYPES
;
j
--
;)
{
if
(
commentMatchesAddToTag
(
comments
,
j
,
&
tag
))
if
(
flac_copy_vorbis_comment
(
comments
,
j
,
&
tag
))
break
;
break
;
}
}
comments
++
;
comments
++
;
...
@@ -151,7 +156,7 @@ struct tag *copyVorbisCommentBlockToMpdTag(const FLAC__StreamMetadata * block,
...
@@ -151,7 +156,7 @@ struct tag *copyVorbisCommentBlockToMpdTag(const FLAC__StreamMetadata * block,
}
}
void
flac_metadata_common_cb
(
const
FLAC__StreamMetadata
*
block
,
void
flac_metadata_common_cb
(
const
FLAC__StreamMetadata
*
block
,
FlacData
*
data
)
struct
flac_data
*
data
)
{
{
const
FLAC__StreamMetadata_StreamInfo
*
si
=
&
(
block
->
data
.
stream_info
);
const
FLAC__StreamMetadata_StreamInfo
*
si
=
&
(
block
->
data
.
stream_info
);
...
@@ -163,7 +168,7 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
...
@@ -163,7 +168,7 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
data
->
total_time
=
((
float
)
si
->
total_samples
)
/
(
si
->
sample_rate
);
data
->
total_time
=
((
float
)
si
->
total_samples
)
/
(
si
->
sample_rate
);
break
;
break
;
case
FLAC__METADATA_TYPE_VORBIS_COMMENT
:
case
FLAC__METADATA_TYPE_VORBIS_COMMENT
:
flac
ParseReplayG
ain
(
block
,
data
);
flac
_parse_replay_g
ain
(
block
,
data
);
default:
default:
break
;
break
;
}
}
...
@@ -171,7 +176,7 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
...
@@ -171,7 +176,7 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
void
flac_error_common_cb
(
const
char
*
plugin
,
void
flac_error_common_cb
(
const
char
*
plugin
,
const
FLAC__StreamDecoderErrorStatus
status
,
const
FLAC__StreamDecoderErrorStatus
status
,
G_GNUC_UNUSED
FlacData
*
data
)
struct
flac_data
*
data
)
{
{
if
(
decoder_get_command
(
data
->
decoder
)
==
DECODE_COMMAND_STOP
)
if
(
decoder_get_command
(
data
->
decoder
)
==
DECODE_COMMAND_STOP
)
return
;
return
;
...
@@ -272,7 +277,7 @@ static void flac_convert(unsigned char *dest,
...
@@ -272,7 +277,7 @@ static void flac_convert(unsigned char *dest,
}
}
FLAC__StreamDecoderWriteStatus
FLAC__StreamDecoderWriteStatus
flac_common_write
(
FlacD
ata
*
data
,
const
FLAC__Frame
*
frame
,
flac_common_write
(
struct
flac_d
ata
*
data
,
const
FLAC__Frame
*
frame
,
const
FLAC__int32
*
const
buf
[])
const
FLAC__int32
*
const
buf
[])
{
{
unsigned
int
c_samp
;
unsigned
int
c_samp
;
...
@@ -300,11 +305,11 @@ flac_common_write(FlacData *data, const FLAC__Frame * frame,
...
@@ -300,11 +305,11 @@ flac_common_write(FlacData *data, const FLAC__Frame * frame,
num_channels
,
bytes_per_sample
,
buf
,
num_channels
,
bytes_per_sample
,
buf
,
c_samp
,
c_samp
+
num_samples
);
c_samp
,
c_samp
+
num_samples
);
cmd
=
decoder_data
(
data
->
decoder
,
data
->
in
S
tream
,
cmd
=
decoder_data
(
data
->
decoder
,
data
->
in
put_s
tream
,
data
->
chunk
,
data
->
chunk
,
num_samples
*
bytes_per_channel
,
num_samples
*
bytes_per_channel
,
data
->
time
,
data
->
bit
R
ate
,
data
->
time
,
data
->
bit
_r
ate
,
data
->
replay
GainI
nfo
);
data
->
replay
_gain_i
nfo
);
switch
(
cmd
)
{
switch
(
cmd
)
{
case
DECODE_COMMAND_NONE
:
case
DECODE_COMMAND_NONE
:
case
DECODE_COMMAND_START
:
case
DECODE_COMMAND_START
:
...
...
src/decoder/_flac_common.h
View file @
86dc7929
...
@@ -141,33 +141,37 @@ typedef size_t flac_read_status_size_t;
...
@@ -141,33 +141,37 @@ typedef size_t flac_read_status_size_t;
#define FLAC_CHUNK_SIZE 4080
#define FLAC_CHUNK_SIZE 4080
typedef
struct
{
struct
flac_data
{
unsigned
char
chunk
[
FLAC_CHUNK_SIZE
];
unsigned
char
chunk
[
FLAC_CHUNK_SIZE
];
float
time
;
float
time
;
unsigned
int
bit
R
ate
;
unsigned
int
bit
_r
ate
;
struct
audio_format
audio_format
;
struct
audio_format
audio_format
;
float
total_time
;
float
total_time
;
FLAC__uint64
position
;
FLAC__uint64
position
;
struct
decoder
*
decoder
;
struct
decoder
*
decoder
;
struct
input_stream
*
in
S
tream
;
struct
input_stream
*
in
put_s
tream
;
struct
replay_gain_info
*
replay
GainI
nfo
;
struct
replay_gain_info
*
replay
_gain_i
nfo
;
struct
tag
*
tag
;
struct
tag
*
tag
;
}
FlacData
;
};
/* initializes a given FlacData struct */
/* initializes a given FlacData struct */
void
init_FlacData
(
FlacData
*
data
,
struct
decoder
*
decoder
,
void
struct
input_stream
*
inStream
);
flac_data_init
(
struct
flac_data
*
data
,
struct
decoder
*
decoder
,
struct
input_stream
*
input_stream
);
void
flac_metadata_common_cb
(
const
FLAC__StreamMetadata
*
block
,
void
flac_metadata_common_cb
(
const
FLAC__StreamMetadata
*
block
,
FlacData
*
data
);
struct
flac_data
*
data
);
void
flac_error_common_cb
(
const
char
*
plugin
,
void
flac_error_common_cb
(
const
char
*
plugin
,
FLAC__StreamDecoderErrorStatus
status
,
FLAC__StreamDecoderErrorStatus
status
,
FlacData
*
data
);
struct
flac_data
*
data
);
struct
tag
*
copyVorbisCommentBlockToMpdTag
(
const
FLAC__StreamMetadata
*
block
,
struct
tag
*
struct
tag
*
tag
);
flac_vorbis_comments_to_tag
(
const
FLAC__StreamMetadata
*
block
,
struct
tag
*
tag
);
FLAC__StreamDecoderWriteStatus
FLAC__StreamDecoderWriteStatus
flac_common_write
(
FlacD
ata
*
data
,
const
FLAC__Frame
*
frame
,
flac_common_write
(
struct
flac_d
ata
*
data
,
const
FLAC__Frame
*
frame
,
const
FLAC__int32
*
const
buf
[]);
const
FLAC__int32
*
const
buf
[]);
#endif
/* _FLAC_COMMON_H */
#endif
/* _FLAC_COMMON_H */
src/decoder/flac_plugin.c
View file @
86dc7929
This diff is collapsed.
Click to expand it.
src/decoder/oggflac_plugin.c
View file @
86dc7929
...
@@ -26,11 +26,11 @@
...
@@ -26,11 +26,11 @@
#include <OggFLAC/seekable_stream_decoder.h>
#include <OggFLAC/seekable_stream_decoder.h>
#include <unistd.h>
#include <unistd.h>
static
void
oggflac_cleanup
(
FlacData
*
data
,
static
void
oggflac_cleanup
(
struct
flac_data
*
data
,
OggFLAC__SeekableStreamDecoder
*
decoder
)
OggFLAC__SeekableStreamDecoder
*
decoder
)
{
{
if
(
data
->
replay
GainI
nfo
)
if
(
data
->
replay
_gain_i
nfo
)
replay_gain_info_free
(
data
->
replay
GainI
nfo
);
replay_gain_info_free
(
data
->
replay
_gain_i
nfo
);
if
(
decoder
)
if
(
decoder
)
OggFLAC__seekable_stream_decoder_delete
(
decoder
);
OggFLAC__seekable_stream_decoder_delete
(
decoder
);
}
}
...
@@ -42,13 +42,14 @@ static OggFLAC__SeekableStreamDecoderReadStatus of_read_cb(G_GNUC_UNUSED const
...
@@ -42,13 +42,14 @@ static OggFLAC__SeekableStreamDecoderReadStatus of_read_cb(G_GNUC_UNUSED const
unsigned
*
bytes
,
unsigned
*
bytes
,
void
*
fdata
)
void
*
fdata
)
{
{
FlacData
*
data
=
(
FlacD
ata
*
)
fdata
;
struct
flac_data
*
data
=
(
struct
flac_d
ata
*
)
fdata
;
size_t
r
;
size_t
r
;
r
=
decoder_read
(
data
->
decoder
,
data
->
inStream
,
(
void
*
)
buf
,
*
bytes
);
r
=
decoder_read
(
data
->
decoder
,
data
->
input_stream
,
(
void
*
)
buf
,
*
bytes
);
*
bytes
=
r
;
*
bytes
=
r
;
if
(
r
==
0
&&
!
input_stream_eof
(
data
->
in
S
tream
)
&&
if
(
r
==
0
&&
!
input_stream_eof
(
data
->
in
put_s
tream
)
&&
decoder_get_command
(
data
->
decoder
)
==
DECODE_COMMAND_NONE
)
decoder_get_command
(
data
->
decoder
)
==
DECODE_COMMAND_NONE
)
return
OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR
;
return
OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR
;
...
@@ -61,9 +62,9 @@ static OggFLAC__SeekableStreamDecoderSeekStatus of_seek_cb(G_GNUC_UNUSED const
...
@@ -61,9 +62,9 @@ static OggFLAC__SeekableStreamDecoderSeekStatus of_seek_cb(G_GNUC_UNUSED const
FLAC__uint64
offset
,
FLAC__uint64
offset
,
void
*
fdata
)
void
*
fdata
)
{
{
FlacData
*
data
=
(
FlacD
ata
*
)
fdata
;
struct
flac_data
*
data
=
(
struct
flac_d
ata
*
)
fdata
;
if
(
!
input_stream_seek
(
data
->
in
S
tream
,
offset
,
SEEK_SET
))
if
(
!
input_stream_seek
(
data
->
in
put_s
tream
,
offset
,
SEEK_SET
))
return
OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR
;
return
OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR
;
return
OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK
;
return
OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK
;
...
@@ -75,9 +76,9 @@ static OggFLAC__SeekableStreamDecoderTellStatus of_tell_cb(G_GNUC_UNUSED const
...
@@ -75,9 +76,9 @@ static OggFLAC__SeekableStreamDecoderTellStatus of_tell_cb(G_GNUC_UNUSED const
FLAC__uint64
*
FLAC__uint64
*
offset
,
void
*
fdata
)
offset
,
void
*
fdata
)
{
{
FlacData
*
data
=
(
FlacD
ata
*
)
fdata
;
struct
flac_data
*
data
=
(
struct
flac_d
ata
*
)
fdata
;
*
offset
=
(
long
)(
data
->
in
S
tream
->
offset
);
*
offset
=
(
long
)(
data
->
in
put_s
tream
->
offset
);
return
OggFLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK
;
return
OggFLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK
;
}
}
...
@@ -89,12 +90,12 @@ static OggFLAC__SeekableStreamDecoderLengthStatus of_length_cb(G_GNUC_UNUSED con
...
@@ -89,12 +90,12 @@ static OggFLAC__SeekableStreamDecoderLengthStatus of_length_cb(G_GNUC_UNUSED con
length
,
length
,
void
*
fdata
)
void
*
fdata
)
{
{
FlacData
*
data
=
(
FlacD
ata
*
)
fdata
;
struct
flac_data
*
data
=
(
struct
flac_d
ata
*
)
fdata
;
if
(
data
->
in
S
tream
->
size
<
0
)
if
(
data
->
in
put_s
tream
->
size
<
0
)
return
OggFLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR
;
return
OggFLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR
;
*
length
=
(
size_t
)
(
data
->
in
S
tream
->
size
);
*
length
=
(
size_t
)
(
data
->
in
put_s
tream
->
size
);
return
OggFLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK
;
return
OggFLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK
;
}
}
...
@@ -102,17 +103,17 @@ static OggFLAC__SeekableStreamDecoderLengthStatus of_length_cb(G_GNUC_UNUSED con
...
@@ -102,17 +103,17 @@ static OggFLAC__SeekableStreamDecoderLengthStatus of_length_cb(G_GNUC_UNUSED con
static
FLAC__bool
of_EOF_cb
(
G_GNUC_UNUSED
const
OggFLAC__SeekableStreamDecoder
*
decoder
,
static
FLAC__bool
of_EOF_cb
(
G_GNUC_UNUSED
const
OggFLAC__SeekableStreamDecoder
*
decoder
,
void
*
fdata
)
void
*
fdata
)
{
{
FlacData
*
data
=
(
FlacD
ata
*
)
fdata
;
struct
flac_data
*
data
=
(
struct
flac_d
ata
*
)
fdata
;
return
(
decoder_get_command
(
data
->
decoder
)
!=
DECODE_COMMAND_NONE
&&
return
(
decoder_get_command
(
data
->
decoder
)
!=
DECODE_COMMAND_NONE
&&
decoder_get_command
(
data
->
decoder
)
!=
DECODE_COMMAND_SEEK
)
||
decoder_get_command
(
data
->
decoder
)
!=
DECODE_COMMAND_SEEK
)
||
input_stream_eof
(
data
->
in
S
tream
);
input_stream_eof
(
data
->
in
put_s
tream
);
}
}
static
void
of_error_cb
(
G_GNUC_UNUSED
const
OggFLAC__SeekableStreamDecoder
*
decoder
,
static
void
of_error_cb
(
G_GNUC_UNUSED
const
OggFLAC__SeekableStreamDecoder
*
decoder
,
FLAC__StreamDecoderErrorStatus
status
,
void
*
fdata
)
FLAC__StreamDecoderErrorStatus
status
,
void
*
fdata
)
{
{
flac_error_common_cb
(
"oggflac"
,
status
,
(
FlacD
ata
*
)
fdata
);
flac_error_common_cb
(
"oggflac"
,
status
,
(
struct
flac_d
ata
*
)
fdata
);
}
}
static
void
oggflacPrintErroredState
(
OggFLAC__SeekableStreamDecoderState
state
)
static
void
oggflacPrintErroredState
(
OggFLAC__SeekableStreamDecoderState
state
)
...
@@ -146,19 +147,17 @@ static void oggflacPrintErroredState(OggFLAC__SeekableStreamDecoderState state)
...
@@ -146,19 +147,17 @@ static void oggflacPrintErroredState(OggFLAC__SeekableStreamDecoderState state)
}
}
}
}
static
FLAC__StreamDecoderWriteStatus
oggflacWrite
(
G_GNUC_UNUSED
const
static
FLAC__StreamDecoderWriteStatus
OggFLAC__SeekableStreamDecoder
oggflac_write_cb
(
G_GNUC_UNUSED
const
OggFLAC__SeekableStreamDecoder
*
decoder
,
*
decoder
,
const
FLAC__Frame
*
frame
,
const
FLAC__int32
*
const
buf
[],
const
FLAC__Frame
*
frame
,
void
*
vdata
)
const
FLAC__int32
*
const
buf
[],
void
*
vdata
)
{
{
FlacData
*
data
=
(
FlacD
ata
*
)
vdata
;
struct
flac_data
*
data
=
(
struct
flac_d
ata
*
)
vdata
;
FLAC__uint32
samples
=
frame
->
header
.
blocksize
;
FLAC__uint32
samples
=
frame
->
header
.
blocksize
;
float
time
C
hange
;
float
time
_c
hange
;
time
C
hange
=
((
float
)
samples
)
/
frame
->
header
.
sample_rate
;
time
_c
hange
=
((
float
)
samples
)
/
frame
->
header
.
sample_rate
;
data
->
time
+=
time
C
hange
;
data
->
time
+=
time
_c
hange
;
return
flac_common_write
(
data
,
frame
,
buf
);
return
flac_common_write
(
data
,
frame
,
buf
);
}
}
...
@@ -167,7 +166,7 @@ static FLAC__StreamDecoderWriteStatus oggflacWrite(G_GNUC_UNUSED const
...
@@ -167,7 +166,7 @@ static FLAC__StreamDecoderWriteStatus oggflacWrite(G_GNUC_UNUSED const
static
void
of_metadata_dup_cb
(
G_GNUC_UNUSED
const
OggFLAC__SeekableStreamDecoder
*
decoder
,
static
void
of_metadata_dup_cb
(
G_GNUC_UNUSED
const
OggFLAC__SeekableStreamDecoder
*
decoder
,
const
FLAC__StreamMetadata
*
block
,
void
*
vdata
)
const
FLAC__StreamMetadata
*
block
,
void
*
vdata
)
{
{
FlacData
*
data
=
(
FlacD
ata
*
)
vdata
;
struct
flac_data
*
data
=
(
struct
flac_d
ata
*
)
vdata
;
switch
(
block
->
type
)
{
switch
(
block
->
type
)
{
case
FLAC__METADATA_TYPE_STREAMINFO
:
case
FLAC__METADATA_TYPE_STREAMINFO
:
...
@@ -178,7 +177,7 @@ static void of_metadata_dup_cb(G_GNUC_UNUSED const OggFLAC__SeekableStreamDecode
...
@@ -178,7 +177,7 @@ static void of_metadata_dup_cb(G_GNUC_UNUSED const OggFLAC__SeekableStreamDecode
block
->
data
.
stream_info
.
sample_rate
+
0
.
5
;
block
->
data
.
stream_info
.
sample_rate
+
0
.
5
;
return
;
return
;
case
FLAC__METADATA_TYPE_VORBIS_COMMENT
:
case
FLAC__METADATA_TYPE_VORBIS_COMMENT
:
copyVorbisCommentBlockToMpdT
ag
(
block
,
data
->
tag
);
flac_vorbis_comments_to_t
ag
(
block
,
data
->
tag
);
default:
default:
break
;
break
;
}
}
...
@@ -189,12 +188,12 @@ static void of_metadata_decode_cb(G_GNUC_UNUSED const OggFLAC__SeekableStreamDec
...
@@ -189,12 +188,12 @@ static void of_metadata_decode_cb(G_GNUC_UNUSED const OggFLAC__SeekableStreamDec
const
FLAC__StreamMetadata
*
block
,
const
FLAC__StreamMetadata
*
block
,
void
*
vdata
)
void
*
vdata
)
{
{
flac_metadata_common_cb
(
block
,
(
FlacD
ata
*
)
vdata
);
flac_metadata_common_cb
(
block
,
(
struct
flac_d
ata
*
)
vdata
);
}
}
static
OggFLAC__SeekableStreamDecoder
static
OggFLAC__SeekableStreamDecoder
*
*
full_decoder_init_and_read_metadata
(
FlacData
*
data
,
full_decoder_init_and_read_metadata
(
struct
flac_data
*
data
,
unsigned
int
metadata_only
)
unsigned
int
metadata_only
)
{
{
OggFLAC__SeekableStreamDecoder
*
decoder
=
NULL
;
OggFLAC__SeekableStreamDecoder
*
decoder
=
NULL
;
unsigned
int
s
=
1
;
unsigned
int
s
=
1
;
...
@@ -223,7 +222,7 @@ static OggFLAC__SeekableStreamDecoder
...
@@ -223,7 +222,7 @@ static OggFLAC__SeekableStreamDecoder
s
&=
OggFLAC__seekable_stream_decoder_set_eof_callback
(
decoder
,
s
&=
OggFLAC__seekable_stream_decoder_set_eof_callback
(
decoder
,
of_EOF_cb
);
of_EOF_cb
);
s
&=
OggFLAC__seekable_stream_decoder_set_write_callback
(
decoder
,
s
&=
OggFLAC__seekable_stream_decoder_set_write_callback
(
decoder
,
oggflac
Write
);
oggflac
_write_cb
);
s
&=
OggFLAC__seekable_stream_decoder_set_metadata_respond
(
decoder
,
s
&=
OggFLAC__seekable_stream_decoder_set_metadata_respond
(
decoder
,
FLAC__METADATA_TYPE_VORBIS_COMMENT
);
FLAC__METADATA_TYPE_VORBIS_COMMENT
);
s
&=
OggFLAC__seekable_stream_decoder_set_error_callback
(
decoder
,
s
&=
OggFLAC__seekable_stream_decoder_set_error_callback
(
decoder
,
...
@@ -256,41 +255,42 @@ fail:
...
@@ -256,41 +255,42 @@ fail:
}
}
/* public functions: */
/* public functions: */
static
struct
tag
*
oggflac_TagDup
(
const
char
*
file
)
static
struct
tag
*
oggflac_tag_dup
(
const
char
*
file
)
{
{
struct
input_stream
in
S
tream
;
struct
input_stream
in
put_s
tream
;
OggFLAC__SeekableStreamDecoder
*
decoder
;
OggFLAC__SeekableStreamDecoder
*
decoder
;
FlacD
ata
data
;
struct
flac_d
ata
data
;
if
(
!
input_stream_open
(
&
in
S
tream
,
file
))
if
(
!
input_stream_open
(
&
in
put_s
tream
,
file
))
return
NULL
;
return
NULL
;
if
(
ogg_stream_type_detect
(
&
in
S
tream
)
!=
FLAC
)
{
if
(
ogg_stream_type_detect
(
&
in
put_s
tream
)
!=
FLAC
)
{
input_stream_close
(
&
in
S
tream
);
input_stream_close
(
&
in
put_s
tream
);
return
NULL
;
return
NULL
;
}
}
init_FlacData
(
&
data
,
NULL
,
&
inS
tream
);
flac_data_init
(
&
data
,
NULL
,
&
input_s
tream
);
/* errors here won't matter,
/* errors here won't matter,
* data.tag will be set or unset, that's all we care about */
* data.tag will be set or unset, that's all we care about */
decoder
=
full_decoder_init_and_read_metadata
(
&
data
,
1
);
decoder
=
full_decoder_init_and_read_metadata
(
&
data
,
1
);
oggflac_cleanup
(
&
data
,
decoder
);
oggflac_cleanup
(
&
data
,
decoder
);
input_stream_close
(
&
in
S
tream
);
input_stream_close
(
&
in
put_s
tream
);
return
data
.
tag
;
return
data
.
tag
;
}
}
static
void
static
void
oggflac_decode
(
struct
decoder
*
mpd_decoder
,
struct
input_stream
*
in
S
tream
)
oggflac_decode
(
struct
decoder
*
mpd_decoder
,
struct
input_stream
*
in
put_s
tream
)
{
{
OggFLAC__SeekableStreamDecoder
*
decoder
=
NULL
;
OggFLAC__SeekableStreamDecoder
*
decoder
=
NULL
;
FlacD
ata
data
;
struct
flac_d
ata
data
;
if
(
ogg_stream_type_detect
(
in
S
tream
)
!=
FLAC
)
if
(
ogg_stream_type_detect
(
in
put_s
tream
)
!=
FLAC
)
return
;
return
;
init_FlacData
(
&
data
,
mpd_decoder
,
inS
tream
);
flac_data_init
(
&
data
,
mpd_decoder
,
input_s
tream
);
if
(
!
(
decoder
=
full_decoder_init_and_read_metadata
(
&
data
,
0
)))
{
if
(
!
(
decoder
=
full_decoder_init_and_read_metadata
(
&
data
,
0
)))
{
goto
fail
;
goto
fail
;
...
@@ -305,7 +305,7 @@ oggflac_decode(struct decoder * mpd_decoder, struct input_stream *inStream)
...
@@ -305,7 +305,7 @@ oggflac_decode(struct decoder * mpd_decoder, struct input_stream *inStream)
}
}
decoder_initialized
(
mpd_decoder
,
&
data
.
audio_format
,
decoder_initialized
(
mpd_decoder
,
&
data
.
audio_format
,
in
S
tream
->
seekable
,
data
.
total_time
);
in
put_s
tream
->
seekable
,
data
.
total_time
);
while
(
true
)
{
while
(
true
)
{
OggFLAC__seekable_stream_decoder_process_single
(
decoder
);
OggFLAC__seekable_stream_decoder_process_single
(
decoder
);
...
@@ -314,11 +314,11 @@ oggflac_decode(struct decoder * mpd_decoder, struct input_stream *inStream)
...
@@ -314,11 +314,11 @@ oggflac_decode(struct decoder * mpd_decoder, struct input_stream *inStream)
break
;
break
;
}
}
if
(
decoder_get_command
(
mpd_decoder
)
==
DECODE_COMMAND_SEEK
)
{
if
(
decoder_get_command
(
mpd_decoder
)
==
DECODE_COMMAND_SEEK
)
{
FLAC__uint64
s
ampleToSeek
=
decoder_seek_where
(
mpd_decoder
)
*
FLAC__uint64
s
eek_sample
=
decoder_seek_where
(
mpd_decoder
)
*
data
.
audio_format
.
sample_rate
+
0
.
5
;
data
.
audio_format
.
sample_rate
+
0
.
5
;
if
(
OggFLAC__seekable_stream_decoder_seek_absolute
if
(
OggFLAC__seekable_stream_decoder_seek_absolute
(
decoder
,
s
ampleToSeek
))
{
(
decoder
,
s
eek_sample
))
{
data
.
time
=
((
float
)
s
ampleToSeek
)
/
data
.
time
=
((
float
)
s
eek_sample
)
/
data
.
audio_format
.
sample_rate
;
data
.
audio_format
.
sample_rate
;
data
.
position
=
0
;
data
.
position
=
0
;
decoder_command_finished
(
mpd_decoder
);
decoder_command_finished
(
mpd_decoder
);
...
@@ -337,7 +337,7 @@ fail:
...
@@ -337,7 +337,7 @@ fail:
oggflac_cleanup
(
&
data
,
decoder
);
oggflac_cleanup
(
&
data
,
decoder
);
}
}
static
const
char
*
const
oggflac_
S
uffixes
[]
=
{
"ogg"
,
"oga"
,
NULL
};
static
const
char
*
const
oggflac_
s
uffixes
[]
=
{
"ogg"
,
"oga"
,
NULL
};
static
const
char
*
const
oggflac_mime_types
[]
=
{
static
const
char
*
const
oggflac_mime_types
[]
=
{
"audio/x-flac+ogg"
,
"audio/x-flac+ogg"
,
"application/ogg"
,
"application/ogg"
,
...
@@ -345,10 +345,10 @@ static const char *const oggflac_mime_types[] = {
...
@@ -345,10 +345,10 @@ static const char *const oggflac_mime_types[] = {
NULL
NULL
};
};
const
struct
decoder_plugin
oggflac
P
lugin
=
{
const
struct
decoder_plugin
oggflac
_decoder_p
lugin
=
{
.
name
=
"oggflac"
,
.
name
=
"oggflac"
,
.
stream_decode
=
oggflac_decode
,
.
stream_decode
=
oggflac_decode
,
.
tag_dup
=
oggflac_
TagD
up
,
.
tag_dup
=
oggflac_
tag_d
up
,
.
suffixes
=
oggflac_
S
uffixes
,
.
suffixes
=
oggflac_
s
uffixes
,
.
mime_types
=
oggflac_mime_types
.
mime_types
=
oggflac_mime_types
};
};
src/decoder_list.c
View file @
86dc7929
...
@@ -25,8 +25,8 @@
...
@@ -25,8 +25,8 @@
extern
const
struct
decoder_plugin
mp3Plugin
;
extern
const
struct
decoder_plugin
mp3Plugin
;
extern
const
struct
decoder_plugin
vorbis_decoder_plugin
;
extern
const
struct
decoder_plugin
vorbis_decoder_plugin
;
extern
const
struct
decoder_plugin
flac
P
lugin
;
extern
const
struct
decoder_plugin
flac
_decoder_p
lugin
;
extern
const
struct
decoder_plugin
oggflac
P
lugin
;
extern
const
struct
decoder_plugin
oggflac
_decoder_p
lugin
;
extern
const
struct
decoder_plugin
audiofilePlugin
;
extern
const
struct
decoder_plugin
audiofilePlugin
;
extern
const
struct
decoder_plugin
mp4_plugin
;
extern
const
struct
decoder_plugin
mp4_plugin
;
extern
const
struct
decoder_plugin
aacPlugin
;
extern
const
struct
decoder_plugin
aacPlugin
;
...
@@ -44,10 +44,10 @@ static const struct decoder_plugin *const decoder_plugins[] = {
...
@@ -44,10 +44,10 @@ static const struct decoder_plugin *const decoder_plugins[] = {
&
vorbis_decoder_plugin
,
&
vorbis_decoder_plugin
,
#endif
#endif
#if defined(HAVE_FLAC) || defined(HAVE_OGGFLAC)
#if defined(HAVE_FLAC) || defined(HAVE_OGGFLAC)
&
oggflac
P
lugin
,
&
oggflac
_decoder_p
lugin
,
#endif
#endif
#ifdef HAVE_FLAC
#ifdef HAVE_FLAC
&
flac
P
lugin
,
&
flac
_decoder_p
lugin
,
#endif
#endif
#ifdef HAVE_AUDIOFILE
#ifdef HAVE_AUDIOFILE
&
audiofilePlugin
,
&
audiofilePlugin
,
...
...
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