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
21d3d300
Commit
21d3d300
authored
Sep 29, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder: renamed plugin methods
Why have a "_func" prefix on all method names? Also don't typedef the methods, there is no advantage in that.
parent
a7651b9d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
62 deletions
+67
-62
decoder_api.h
src/decoder_api.h
+40
-35
decoder_list.c
src/decoder_list.c
+3
-3
decoder_thread.c
src/decoder_thread.c
+19
-19
flac_plugin.c
src/inputPlugins/flac_plugin.c
+3
-3
song.c
src/song.c
+2
-2
No files found.
src/decoder_api.h
View file @
21d3d300
...
...
@@ -49,44 +49,49 @@ enum decoder_command {
struct
decoder
;
/* optional, set this to NULL if the InputPlugin doesn't have/need one
* this must return < 0 if there is an error and >= 0 otherwise */
typedef
int
(
*
decoder_init_func
)
(
void
);
/* optional, set this to NULL if the InputPlugin doesn't have/need one */
typedef
void
(
*
decoder_finish_func
)
(
void
);
/* boolean return value, returns 1 if the InputStream is decodable by
* the InputPlugin, 0 if not */
typedef
unsigned
int
(
*
decoder_try_decode_func
)
(
InputStream
*
);
/* this will be used to decode InputStreams, and is recommended for files
* and networked (HTTP) connections.
*
* returns -1 on error, 0 on success */
typedef
int
(
*
decoder_stream_decode_func
)
(
struct
decoder
*
,
InputStream
*
);
/* use this if and only if your InputPlugin can only be passed a filename or
* handle as input, and will not allow callbacks to be set (like Ogg-Vorbis
* and FLAC libraries allow)
*
* returns -1 on error, 0 on success */
typedef
int
(
*
decoder_file_decode_func
)
(
struct
decoder
*
,
char
*
path
);
/* file should be the full path! Returns NULL if a tag cannot be found
* or read */
typedef
struct
tag
*
(
*
decoder_tag_dup_func
)
(
char
*
file
);
struct
decoder_plugin
{
const
char
*
name
;
decoder_init_func
init_func
;
decoder_finish_func
finish_func
;
decoder_try_decode_func
try_decode_func
;
decoder_stream_decode_func
stream_decode_func
;
decoder_file_decode_func
file_decode_func
;
decoder_tag_dup_func
tag_dup_func
;
/**
* optional, set this to NULL if the InputPlugin doesn't
* have/need one this must return < 0 if there is an error and
* >= 0 otherwise
*/
int
(
*
init
)(
void
);
/**
* optional, set this to NULL if the InputPlugin doesn't have/need one
*/
void
(
*
finish
)(
void
);
/**
* boolean return value, returns 1 if the InputStream is
* decodable by the InputPlugin, 0 if not
*/
unsigned
int
(
*
try_decode
)(
InputStream
*
);
/**
* this will be used to decode InputStreams, and is
* recommended for files and networked (HTTP) connections.
*
* returns -1 on error, 0 on success
*/
int
(
*
stream_decode
)(
struct
decoder
*
,
InputStream
*
);
/**
* use this if and only if your InputPlugin can only be passed
* a filename or handle as input, and will not allow callbacks
* to be set (like Ogg-Vorbis and FLAC libraries allow)
*
* returns -1 on error, 0 on success
*/
int
(
*
file_decode
)(
struct
decoder
*
,
char
*
path
);
/**
* file should be the full path! Returns NULL if a tag cannot
* be found or read
*/
struct
tag
*
(
*
tag_dup
)(
char
*
file
);
/* one or more of the INPUT_PLUGIN_STREAM_* values OR'd together */
unsigned
char
stream_types
;
...
...
src/decoder_list.c
View file @
21d3d300
...
...
@@ -40,7 +40,7 @@ void decoder_plugin_load(struct decoder_plugin * inputPlugin)
if
(
!
inputPlugin
->
name
)
return
;
if
(
inputPlugin
->
init
_func
&&
inputPlugin
->
init_func
()
<
0
)
if
(
inputPlugin
->
init
!=
NULL
&&
inputPlugin
->
init
()
<
0
)
return
;
insertInList
(
inputPlugin_list
,
inputPlugin
->
name
,
(
void
*
)
inputPlugin
);
...
...
@@ -48,8 +48,8 @@ void decoder_plugin_load(struct decoder_plugin * inputPlugin)
void
decoder_plugin_unload
(
struct
decoder_plugin
*
inputPlugin
)
{
if
(
inputPlugin
->
finish
_func
)
inputPlugin
->
finish
_func
();
if
(
inputPlugin
->
finish
!=
NULL
)
inputPlugin
->
finish
();
deleteFromList
(
inputPlugin_list
,
inputPlugin
->
name
);
}
...
...
src/decoder_thread.c
View file @
21d3d300
...
...
@@ -81,14 +81,14 @@ static void decodeStart(void)
/* first we try mime types: */
while
(
ret
&&
(
plugin
=
decoder_plugin_from_mime_type
(
inStream
.
mime
,
next
++
)))
{
if
(
!
plugin
->
stream_decode_func
)
if
(
plugin
->
stream_decode
==
NULL
)
continue
;
if
(
!
(
plugin
->
stream_types
&
INPUT_PLUGIN_STREAM_URL
))
continue
;
if
(
plugin
->
try_decode
_func
&&
!
plugin
->
try_decode
_func
(
&
inStream
))
if
(
plugin
->
try_decode
!=
NULL
&&
!
plugin
->
try_decode
(
&
inStream
))
continue
;
ret
=
plugin
->
stream_decode
_func
(
&
decoder
,
&
inStream
);
ret
=
plugin
->
stream_decode
(
&
decoder
,
&
inStream
);
break
;
}
...
...
@@ -97,17 +97,17 @@ static void decodeStart(void)
const
char
*
s
=
getSuffix
(
path_max_utf8
);
next
=
0
;
while
(
ret
&&
(
plugin
=
decoder_plugin_from_suffix
(
s
,
next
++
)))
{
if
(
!
plugin
->
stream_decode_func
)
if
(
plugin
->
stream_decode
==
NULL
)
continue
;
if
(
!
(
plugin
->
stream_types
&
INPUT_PLUGIN_STREAM_URL
))
continue
;
if
(
plugin
->
try_decode
_func
&&
!
plugin
->
try_decode
_func
(
&
inStream
))
if
(
plugin
->
try_decode
!=
NULL
&&
!
plugin
->
try_decode
(
&
inStream
))
continue
;
decoder
.
plugin
=
plugin
;
ret
=
plugin
->
stream_decode
_func
(
&
decoder
,
&
inStream
);
ret
=
plugin
->
stream_decode
(
&
decoder
,
&
inStream
);
break
;
}
}
...
...
@@ -119,8 +119,8 @@ static void decodeStart(void)
* need to check for stream{Types,DecodeFunc} */
if
((
plugin
=
decoder_plugin_from_name
(
"mp3"
)))
{
decoder
.
plugin
=
plugin
;
ret
=
plugin
->
stream_decode
_func
(
&
decoder
,
&
inStream
);
ret
=
plugin
->
stream_decode
(
&
decoder
,
&
inStream
);
}
}
}
else
{
...
...
@@ -130,21 +130,21 @@ static void decodeStart(void)
if
(
!
plugin
->
stream_types
&
INPUT_PLUGIN_STREAM_FILE
)
continue
;
if
(
plugin
->
try_decode
_func
&&
!
plugin
->
try_decode
_func
(
&
inStream
))
if
(
plugin
->
try_decode
!=
NULL
&&
!
plugin
->
try_decode
(
&
inStream
))
continue
;
if
(
plugin
->
file_decode
_func
)
{
if
(
plugin
->
file_decode
!=
NULL
)
{
closeInputStream
(
&
inStream
);
close_instream
=
0
;
decoder
.
plugin
=
plugin
;
ret
=
plugin
->
file_decode
_func
(
&
decoder
,
path_max_fs
);
ret
=
plugin
->
file_decode
(
&
decoder
,
path_max_fs
);
break
;
}
else
if
(
plugin
->
stream_decode
_func
)
{
}
else
if
(
plugin
->
stream_decode
!=
NULL
)
{
decoder
.
plugin
=
plugin
;
ret
=
plugin
->
stream_decode
_func
(
&
decoder
,
&
inStream
);
ret
=
plugin
->
stream_decode
(
&
decoder
,
&
inStream
);
break
;
}
}
...
...
src/inputPlugins/flac_plugin.c
View file @
21d3d300
...
...
@@ -445,9 +445,9 @@ static int flac_plugin_init(void)
DEBUG
(
"libFLAC supports OggFLAC, initializing OggFLAC support
\n
"
);
assert
(
oggflacPlugin
.
name
==
NULL
);
oggflacPlugin
.
name
=
"oggflac"
;
oggflacPlugin
.
try_decode
_func
=
oggflac_try_decode
;
oggflacPlugin
.
stream_decode
_func
=
oggflac_decode
;
oggflacPlugin
.
tag_dup
_func
=
oggflac_tag_dup
;
oggflacPlugin
.
try_decode
=
oggflac_try_decode
;
oggflacPlugin
.
stream_decode
=
oggflac_decode
;
oggflacPlugin
.
tag_dup
=
oggflac_tag_dup
;
oggflacPlugin
.
stream_types
=
INPUT_PLUGIN_STREAM_URL
|
INPUT_PLUGIN_STREAM_FILE
;
oggflacPlugin
.
suffixes
=
oggflac_suffixes
;
...
...
src/song.c
View file @
21d3d300
...
...
@@ -67,7 +67,7 @@ Song *newSong(const char *url, enum song_type type, Directory * parentDir)
while
(
!
song
->
tag
&&
(
plugin
=
isMusic
(
abs_path
,
&
(
song
->
mtime
),
next
++
)))
{
song
->
tag
=
plugin
->
tag_dup
_func
(
abs_path
);
song
->
tag
=
plugin
->
tag_dup
(
abs_path
);
}
if
(
!
song
->
tag
||
song
->
tag
->
time
<
0
)
{
freeSong
(
song
);
...
...
@@ -111,7 +111,7 @@ int updateSongInfo(Song * song)
while
(
!
song
->
tag
&&
(
plugin
=
isMusic
(
abs_path
,
&
(
song
->
mtime
),
next
++
)))
{
song
->
tag
=
plugin
->
tag_dup
_func
(
abs_path
);
song
->
tag
=
plugin
->
tag_dup
(
abs_path
);
}
if
(
!
song
->
tag
||
song
->
tag
->
time
<
0
)
return
-
1
;
...
...
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