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
d7893a3e
Commit
d7893a3e
authored
May 30, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish implementing inputPlugin interface
git-svn-id:
https://svn.musicpd.org/mpd/trunk@1244
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
bd41addd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
20 deletions
+96
-20
Makefile.am
src/Makefile.am
+4
-2
inputPlugin.c
src/inputPlugin.c
+83
-11
inputPlugin.h
src/inputPlugin.h
+9
-7
No files found.
src/Makefile.am
View file @
d7893a3e
...
...
@@ -6,14 +6,16 @@ mpd_headers = buffer2array.h interface.h command.h playlist.h ls.h \
audio.h playerData.h stats.h myfprintf.h sig_handlers.h decode.h log.h
\
audiofile_decode.h charConv.h permission.h mpd_types.h pcm_utils.h
\
mp4_decode.h aac_decode.h signal_check.h utf8.h inputStream.h
\
outputBuffer.h replayGain.h inputStream_file.h inputStream_http.h
outputBuffer.h replayGain.h inputStream_file.h inputStream_http.h
\
inputPlugin.h
mpd_SOURCES
=
main.c buffer2array.c interface.c command.c playlist.c ls.c
\
song.c list.c directory.c tables.c utils.c path.c mp3_decode.c
\
tag.c player.c listen.c conf.c ogg_decode.c volume.c flac_decode.c
\
audio.c playerData.c stats.c myfprintf.c sig_handlers.c decode.c log.c
\
audiofile_decode.c charConv.c permission.c pcm_utils.c mp4_decode.c
\
aac_decode.c signal_check.c utf8.c inputStream.c outputBuffer.c
\
replayGain.c inputStream_file.c inputStream_http.c
$(mpd_headers)
replayGain.c inputStream_file.c inputStream_http.c inputPlugin.c
\
$(mpd_headers)
mpd_CFLAGS
=
$(MPD_CFLAGS)
mpd_LDADD
=
$(MPD_LIBS)
$(ID3_LIB)
$(MAD_LIB)
$(MP4FF_LIB)
...
...
src/inputPlugin.c
View file @
d7893a3e
#include "input_plugin.h"
#include "inputPlugin.h"
#include "list.h"
#include <stdlib.h>
#include <string.h>
static
List
*
inputPlugin_list
=
NULL
;
InputPlugin
*
newInputPlugin
()
{
InputPlugin
*
newInputPlugin
(
char
*
name
,
InputPlugin_streamDecodeFunc
streamDecodeFunc
,
InputPlugin_fileDecodeFunc
fileDecodeFunc
,
InputPlugin_tagDupFunc
tagDupFunc
,
unsigned
char
streamTypes
)
{
InputPlugin
*
ret
=
malloc
(
sizeof
(
InputPlugin
));
memset
(
ret
->
name
,
0
,
INPUT_PLUGIN_NAME_LENGTH
);
strncpy
(
ret
->
name
,
name
,
INPUT_PLUGIN_NAME_LENGTH
-
1
);
ret
->
suffixes
=
NULL
;
ret
->
mimeTypes
=
NULL
;
ret
->
streamTypes
=
0
;
ret
->
streamDecodeFunc
=
NULL
;
ret
->
fileDeocdeFunc
=
NULL
;
ret
->
tagDupFunc
=
NULL
;
ret
->
streamTypes
=
streamTypes
;
ret
->
streamDecodeFunc
=
streamDecodeFunc
;
ret
->
fileDecodeFunc
=
fileDecodeFunc
;
ret
->
tagDupFunc
=
tagDupFunc
;
return
ret
;
}
...
...
@@ -32,8 +42,6 @@ static void freeStringArray(char ** ptr) {
}
void
freeInputPlugin
(
InputPlugin
*
inPlugin
)
{
char
*
temp
;
freeStringArray
(
inPlugin
->
suffixes
);
freeStringArray
(
inPlugin
->
mimeTypes
);
...
...
@@ -45,15 +53,16 @@ static char ** AddStringToArray(char ** array, char * string) {
if
(
array
)
{
char
**
tmp
=
array
;
while
(
*
array
)
{
while
(
*
tmp
)
{
arraySize
++
;
array
++
;
tmp
++
;
}
}
array
=
realloc
(
array
,
arraySize
*
sizeof
(
char
*
));
array
=
realloc
(
array
,
(
arraySize
+
1
)
*
sizeof
(
char
*
));
array
[
arraySize
-
1
]
=
strdup
(
string
);
array
[
arraySize
]
=
NULL
;
return
array
;
}
...
...
@@ -65,3 +74,66 @@ void addSuffixToInputPlugin(InputPlugin * inPlugin, char * suffix) {
void
addMimeTypeToInputPlugin
(
InputPlugin
*
inPlugin
,
char
*
mimeType
)
{
inPlugin
->
mimeTypes
=
AddStringToArray
(
inPlugin
->
mimeTypes
,
mimeType
);
}
void
loadInputPlugin
(
InputPlugin
*
inputPlugin
)
{
insertInList
(
inputPlugin_list
,
inputPlugin
->
name
,
(
void
*
)
inputPlugin
);
}
void
unloadInputPlugin
(
InputPlugin
*
inputPlugin
)
{
deleteFromList
(
inputPlugin_list
,
inputPlugin
->
name
);
}
static
int
stringFoundInStringArray
(
char
**
array
,
char
*
suffix
)
{
while
(
array
&&
*
array
)
{
if
(
strcmp
(
*
array
,
suffix
)
==
0
)
return
1
;
array
++
;
}
return
0
;
}
InputPlugin
*
getInputPluginFromSuffix
(
char
*
suffix
)
{
ListNode
*
node
=
inputPlugin_list
->
firstNode
;
InputPlugin
*
plugin
=
NULL
;
while
(
node
!=
NULL
)
{
plugin
=
node
->
data
;
if
(
stringFoundInStringArray
(
plugin
->
suffixes
,
suffix
))
{
return
plugin
;
}
}
return
NULL
;
}
InputPlugin
*
getInputPluginFromMimeType
(
char
*
mimeType
)
{
ListNode
*
node
=
inputPlugin_list
->
firstNode
;
InputPlugin
*
plugin
=
NULL
;
while
(
node
!=
NULL
)
{
plugin
=
node
->
data
;
if
(
stringFoundInStringArray
(
plugin
->
mimeTypes
,
mimeType
))
{
return
plugin
;
}
}
return
NULL
;
}
InputPlugin
*
getInputPluginFromName
(
char
*
name
)
{
void
*
plugin
=
NULL
;
findInList
(
inputPlugin_list
,
name
,
&
plugin
);
return
(
InputPlugin
*
)
plugin
;
}
void
initInputPlugins
()
{
inputPlugin_list
=
makeList
((
ListFreeDataFunc
*
)
freeInputPlugin
);
/* load plugins here */
}
void
finishInputPlugins
()
{
freeList
(
inputPlugin_list
);
}
src/inputPlugin.h
View file @
d7893a3e
...
...
@@ -28,16 +28,20 @@ typedef struct _InputPlugin {
char
**
mimeTypes
;
}
InputPlugin
;
/* interface for adding and removing plugins */
InputPlugin
*
newInputPlugin
();
/* interface for constructing a plugin */
InputPlugin
*
newInputPlugin
(
char
*
name
,
InputPlugin_streamDecodeFunc
streamDecodeFunc
,
InputPlugin_fileDecodeFunc
fileDecodeFunc
,
InputPlugin_tagDupFunc
tagDupFunc
,
unsigned
char
streamTypes
);
void
addSuffixToInputPlugin
(
InputPlugin
*
inPlugin
,
char
*
suffix
);
void
addMimeTypeToInputPlugin
(
InputPlugin
*
inPlugin
,
char
*
suffix
);
void
freeInputPlugin
(
InputPlugin
*
inputPlugin
);
/* individual functions to load/unload plugins */
void
loadInputPlugin
(
InputPlugin
*
inputPlugin
);
/* this free's inputPlugin as well! */
void
unloadInputPlugin
(
InputPlugin
*
inputPlugin
);
/* interface for using plugins */
InputPlugin
*
getInputPluginFromSuffix
(
char
*
suffix
);
...
...
@@ -56,6 +60,4 @@ void initInputPlugins();
/* this is where we "unload" all the "plugins" */
void
finishInputPlugins
();
void
unloadInputPlugin
(
InputPlugin
*
inputPlugin
);
#endif
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