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
b5cadc9c
Commit
b5cadc9c
authored
Jan 14, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oggvorbis: no CamelCase
Renamed functions and variables.
parent
b8e06d41
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
61 deletions
+65
-61
oggvorbis_plugin.c
src/decoder/oggvorbis_plugin.c
+63
-59
decoder_list.c
src/decoder_list.c
+2
-2
No files found.
src/decoder/oggvorbis_plugin.c
View file @
b5cadc9c
...
...
@@ -48,8 +48,8 @@
#endif
typedef
struct
_OggCallbackData
{
struct
input_stream
*
inStream
;
struct
decoder
*
decoder
;
struct
input_stream
*
input_stream
;
}
OggCallbackData
;
static
size_t
ogg_read_cb
(
void
*
ptr
,
size_t
size
,
size_t
nmemb
,
void
*
vdata
)
...
...
@@ -57,10 +57,9 @@ static size_t ogg_read_cb(void *ptr, size_t size, size_t nmemb, void *vdata)
size_t
ret
;
OggCallbackData
*
data
=
(
OggCallbackData
*
)
vdata
;
ret
=
decoder_read
(
data
->
decoder
,
data
->
in
S
tream
,
ptr
,
size
*
nmemb
);
ret
=
decoder_read
(
data
->
decoder
,
data
->
in
put_s
tream
,
ptr
,
size
*
nmemb
);
errno
=
0
;
/*if(ret<0) errno = ((struct input_stream *)inStream)->error; */
return
ret
/
size
;
}
...
...
@@ -70,7 +69,7 @@ static int ogg_seek_cb(void *vdata, ogg_int64_t offset, int whence)
const
OggCallbackData
*
data
=
(
const
OggCallbackData
*
)
vdata
;
if
(
decoder_get_command
(
data
->
decoder
)
==
DECODE_COMMAND_STOP
)
return
-
1
;
return
input_stream_seek
(
data
->
in
S
tream
,
offset
,
whence
)
?
0
:
-
1
;
return
input_stream_seek
(
data
->
in
put_s
tream
,
offset
,
whence
)
?
0
:
-
1
;
}
/* TODO: check Ogg libraries API and see if we can just not have this func */
...
...
@@ -83,10 +82,11 @@ static long ogg_tell_cb(void *vdata)
{
const
OggCallbackData
*
data
=
(
const
OggCallbackData
*
)
vdata
;
return
(
long
)
(
data
->
inStream
->
offset
)
;
return
(
long
)
data
->
input_stream
->
offset
;
}
static
const
char
*
ogg_parseComment
(
const
char
*
comment
,
const
char
*
needle
)
static
const
char
*
vorbis_comment_value
(
const
char
*
comment
,
const
char
*
needle
)
{
int
len
=
strlen
(
needle
);
...
...
@@ -98,7 +98,7 @@ static const char *ogg_parseComment(const char *comment, const char *needle)
}
static
struct
replay_gain_info
*
ogg_getReplayGainInfo
(
char
**
comments
)
vorbis_comments_to_replay_gain
(
char
**
comments
)
{
struct
replay_gain_info
*
rgi
;
const
char
*
temp
;
...
...
@@ -108,19 +108,19 @@ ogg_getReplayGainInfo(char **comments)
while
(
*
comments
)
{
if
((
temp
=
ogg_parseComment
(
*
comments
,
"replaygain_track_gain"
)))
{
vorbis_comment_value
(
*
comments
,
"replaygain_track_gain"
)))
{
rgi
->
tuples
[
REPLAY_GAIN_TRACK
].
gain
=
atof
(
temp
);
found
=
true
;
}
else
if
((
temp
=
ogg_parseComment
(
*
comments
,
"replaygain_album_gain"
)))
{
}
else
if
((
temp
=
vorbis_comment_value
(
*
comments
,
"replaygain_album_gain"
)))
{
rgi
->
tuples
[
REPLAY_GAIN_ALBUM
].
gain
=
atof
(
temp
);
found
=
true
;
}
else
if
((
temp
=
ogg_parseComment
(
*
comments
,
"replaygain_track_peak"
)))
{
}
else
if
((
temp
=
vorbis_comment_value
(
*
comments
,
"replaygain_track_peak"
)))
{
rgi
->
tuples
[
REPLAY_GAIN_TRACK
].
peak
=
atof
(
temp
);
found
=
true
;
}
else
if
((
temp
=
ogg_parseComment
(
*
comments
,
"replaygain_album_peak"
)))
{
}
else
if
((
temp
=
vorbis_comment_value
(
*
comments
,
"replaygain_album_peak"
)))
{
rgi
->
tuples
[
REPLAY_GAIN_ALBUM
].
peak
=
atof
(
temp
);
found
=
true
;
}
...
...
@@ -140,12 +140,12 @@ static const char *VORBIS_COMMENT_TRACK_KEY = "tracknumber";
static
const
char
*
VORBIS_COMMENT_DISC_KEY
=
"discnumber"
;
static
bool
ogg_parseCommentAddToTag
(
char
*
comment
,
unsigned
int
itemT
ype
,
struct
tag
**
tag
)
vorbis_parse_comment
(
char
*
comment
,
enum
tag_type
tag_t
ype
,
struct
tag
**
tag
)
{
const
char
*
needle
;
unsigned
int
len
;
switch
(
itemT
ype
)
{
switch
(
tag_t
ype
)
{
case
TAG_ITEM_TRACK
:
needle
=
VORBIS_COMMENT_TRACK_KEY
;
break
;
...
...
@@ -153,7 +153,7 @@ ogg_parseCommentAddToTag(char *comment, unsigned int itemType,
needle
=
VORBIS_COMMENT_DISC_KEY
;
break
;
default:
needle
=
mpdTagItemKeys
[
itemT
ype
];
needle
=
mpdTagItemKeys
[
tag_t
ype
];
}
len
=
strlen
(
needle
);
...
...
@@ -161,7 +161,7 @@ ogg_parseCommentAddToTag(char *comment, unsigned int itemType,
if
(
!*
tag
)
*
tag
=
tag_new
();
tag_add_item
(
*
tag
,
itemT
ype
,
comment
+
len
+
1
);
tag_add_item
(
*
tag
,
tag_t
ype
,
comment
+
len
+
1
);
return
true
;
}
...
...
@@ -169,14 +169,15 @@ ogg_parseCommentAddToTag(char *comment, unsigned int itemType,
return
false
;
}
static
struct
tag
*
oggCommentsParse
(
char
**
comments
)
static
struct
tag
*
vorbis_comments_to_tag
(
char
**
comments
)
{
struct
tag
*
tag
=
NULL
;
while
(
*
comments
)
{
int
j
;
for
(
j
=
TAG_NUM_OF_ITEM_TYPES
;
--
j
>=
0
;)
{
if
(
ogg_parseCommentAddToTag
(
*
comments
,
j
,
&
tag
))
if
(
vorbis_parse_comment
(
*
comments
,
j
,
&
tag
))
break
;
}
comments
++
;
...
...
@@ -185,13 +186,13 @@ static struct tag *oggCommentsParse(char **comments)
return
tag
;
}
static
void
putOggCommentsIntoOutputBuffer
(
struct
decoder
*
decoder
,
struct
input_stream
*
is
,
char
**
comments
)
static
void
vorbis_send_comments
(
struct
decoder
*
decoder
,
struct
input_stream
*
is
,
char
**
comments
)
{
struct
tag
*
tag
;
tag
=
oggCommentsParse
(
comments
);
tag
=
vorbis_comments_to_tag
(
comments
);
if
(
!
tag
)
return
;
...
...
@@ -201,7 +202,8 @@ static void putOggCommentsIntoOutputBuffer(struct decoder *decoder,
/* public */
static
void
oggvorbis_decode
(
struct
decoder
*
decoder
,
struct
input_stream
*
inStream
)
vorbis_stream_decode
(
struct
decoder
*
decoder
,
struct
input_stream
*
input_stream
)
{
OggVorbis_File
vf
;
ov_callbacks
callbacks
;
...
...
@@ -214,19 +216,19 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
char
chunk
[
OGG_CHUNK_SIZE
];
long
bitRate
=
0
;
long
test
;
struct
replay_gain_info
*
replay
GainI
nfo
=
NULL
;
struct
replay_gain_info
*
replay
_gain_i
nfo
=
NULL
;
char
**
comments
;
bool
initialized
=
false
;
enum
decoder_command
cmd
=
DECODE_COMMAND_NONE
;
if
(
ogg_stream_type_detect
(
in
S
tream
)
!=
VORBIS
)
if
(
ogg_stream_type_detect
(
in
put_s
tream
)
!=
VORBIS
)
return
;
/* rewind the stream, because ogg_stream_type_detect() has
moved it */
input_stream_seek
(
in
S
tream
,
0
,
SEEK_SET
);
input_stream_seek
(
in
put_s
tream
,
0
,
SEEK_SET
);
data
.
in
Stream
=
inS
tream
;
data
.
in
put_stream
=
input_s
tream
;
data
.
decoder
=
decoder
;
callbacks
.
read_func
=
ogg_read_cb
;
...
...
@@ -234,34 +236,33 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
callbacks
.
close_func
=
ogg_close_cb
;
callbacks
.
tell_func
=
ogg_tell_cb
;
if
((
ret
=
ov_open_callbacks
(
&
data
,
&
vf
,
NULL
,
0
,
callbacks
))
<
0
)
{
const
char
*
error
Str
;
const
char
*
error
;
if
(
decoder_get_command
(
decoder
)
!=
DECODE_COMMAND_NONE
)
return
;
switch
(
ret
)
{
case
OV_EREAD
:
error
Str
=
"read error"
;
error
=
"read error"
;
break
;
case
OV_ENOTVORBIS
:
error
Str
=
"not vorbis stream"
;
error
=
"not vorbis stream"
;
break
;
case
OV_EVERSION
:
error
Str
=
"vorbis version mismatch"
;
error
=
"vorbis version mismatch"
;
break
;
case
OV_EBADHEADER
:
error
Str
=
"invalid vorbis header"
;
error
=
"invalid vorbis header"
;
break
;
case
OV_EFAULT
:
error
Str
=
"internal logic error"
;
error
=
"internal logic error"
;
break
;
default:
error
Str
=
"unknown error"
;
error
=
"unknown error"
;
break
;
}
g_warning
(
"Error decoding Ogg Vorbis stream: %s
\n
"
,
errorStr
);
g_warning
(
"Error decoding Ogg Vorbis stream: %s"
,
error
);
return
;
}
audio_format
.
bits
=
16
;
...
...
@@ -304,18 +305,17 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
if
(
total_time
<
0
)
total_time
=
0
;
decoder_initialized
(
decoder
,
&
audio_format
,
in
S
tream
->
seekable
,
in
put_s
tream
->
seekable
,
total_time
);
initialized
=
true
;
}
comments
=
ov_comment
(
&
vf
,
-
1
)
->
user_comments
;
putOggCommentsIntoOutputBuffer
(
decoder
,
inStream
,
comments
);
new_rgi
=
ogg_getReplayGainInfo
(
comments
);
vorbis_send_comments
(
decoder
,
input_stream
,
comments
);
new_rgi
=
vorbis_comments_to_replay_gain
(
comments
);
if
(
new_rgi
!=
NULL
)
{
if
(
replay
GainI
nfo
!=
NULL
)
replay_gain_info_free
(
replay
GainI
nfo
);
replay
GainI
nfo
=
new_rgi
;
if
(
replay
_gain_i
nfo
!=
NULL
)
replay_gain_info_free
(
replay
_gain_i
nfo
);
replay
_gain_i
nfo
=
new_rgi
;
}
}
...
...
@@ -324,19 +324,20 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
if
((
test
=
ov_bitrate_instant
(
&
vf
))
>
0
)
bitRate
=
test
/
1000
;
cmd
=
decoder_data
(
decoder
,
in
S
tream
,
cmd
=
decoder_data
(
decoder
,
in
put_s
tream
,
chunk
,
ret
,
ov_pcm_tell
(
&
vf
)
/
audio_format
.
sample_rate
,
bitRate
,
replay
GainI
nfo
);
bitRate
,
replay
_gain_i
nfo
);
}
while
(
cmd
!=
DECODE_COMMAND_STOP
);
if
(
replay
GainI
nfo
)
replay_gain_info_free
(
replay
GainI
nfo
);
if
(
replay
_gain_i
nfo
)
replay_gain_info_free
(
replay
_gain_i
nfo
);
ov_clear
(
&
vf
);
}
static
struct
tag
*
oggvorbis_TagDup
(
const
char
*
file
)
static
struct
tag
*
vorbis_tag_dup
(
const
char
*
file
)
{
struct
tag
*
ret
;
FILE
*
fp
;
...
...
@@ -352,7 +353,7 @@ static struct tag *oggvorbis_TagDup(const char *file)
return
NULL
;
}
ret
=
oggCommentsParse
(
ov_comment
(
&
vf
,
-
1
)
->
user_comments
);
ret
=
vorbis_comments_to_tag
(
ov_comment
(
&
vf
,
-
1
)
->
user_comments
);
if
(
!
ret
)
ret
=
tag_new
();
...
...
@@ -363,18 +364,21 @@ static struct tag *oggvorbis_TagDup(const char *file)
return
ret
;
}
static
const
char
*
const
oggvorbis_Suffixes
[]
=
{
"ogg"
,
"oga"
,
NULL
};
static
const
char
*
const
oggvorbis_MimeTypes
[]
=
{
static
const
char
*
const
vorbis_suffixes
[]
=
{
"ogg"
,
"oga"
,
NULL
};
static
const
char
*
const
vorbis_mime_types
[]
=
{
"application/ogg"
,
"audio/x-vorbis+ogg"
,
"application/x-ogg"
,
NULL
};
const
struct
decoder_plugin
oggvorbisP
lugin
=
{
const
struct
decoder_plugin
vorbis_decoder_p
lugin
=
{
.
name
=
"oggvorbis"
,
.
stream_decode
=
oggvorbis
_decode
,
.
tag_dup
=
oggvorbis_TagD
up
,
.
suffixes
=
oggvorbis_S
uffixes
,
.
mime_types
=
oggvorbis_MimeT
ypes
.
stream_decode
=
vorbis_stream
_decode
,
.
tag_dup
=
vorbis_tag_d
up
,
.
suffixes
=
vorbis_s
uffixes
,
.
mime_types
=
vorbis_mime_t
ypes
};
src/decoder_list.c
View file @
b5cadc9c
...
...
@@ -24,7 +24,7 @@
#include <glib.h>
extern
const
struct
decoder_plugin
mp3Plugin
;
extern
const
struct
decoder_plugin
oggvorbisP
lugin
;
extern
const
struct
decoder_plugin
vorbis_decoder_p
lugin
;
extern
const
struct
decoder_plugin
flacPlugin
;
extern
const
struct
decoder_plugin
oggflacPlugin
;
extern
const
struct
decoder_plugin
audiofilePlugin
;
...
...
@@ -41,7 +41,7 @@ static const struct decoder_plugin *const decoder_plugins[] = {
&
mp3Plugin
,
#endif
#ifdef HAVE_OGGVORBIS
&
oggvorbisP
lugin
,
&
vorbis_decoder_p
lugin
,
#endif
#if defined(HAVE_FLAC) || defined(HAVE_OGGFLAC)
&
oggflacPlugin
,
...
...
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