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
1a4a3e1f
Commit
1a4a3e1f
authored
Nov 01, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder: manage decoder list in a static array
Currently, there is no way to dynamically load decoder plugins, thus we don't need a dynamic list to manage them.
parent
5036368f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
109 deletions
+78
-109
decoder_api.c
src/decoder_api.c
+0
-11
decoder_api.h
src/decoder_api.h
+0
-4
decoder_list.c
src/decoder_list.c
+78
-90
decoder_list.h
src/decoder_list.h
+0
-4
No files found.
src/decoder_api.c
View file @
1a4a3e1f
...
@@ -18,7 +18,6 @@
...
@@ -18,7 +18,6 @@
*/
*/
#include "decoder_internal.h"
#include "decoder_internal.h"
#include "decoder_list.h"
#include "decoder_control.h"
#include "decoder_control.h"
#include "player_control.h"
#include "player_control.h"
#include "audio.h"
#include "audio.h"
...
@@ -31,16 +30,6 @@
...
@@ -31,16 +30,6 @@
#include <assert.h>
#include <assert.h>
void
decoder_plugin_register
(
struct
decoder_plugin
*
plugin
)
{
decoder_plugin_load
(
plugin
);
}
void
decoder_plugin_unregister
(
struct
decoder_plugin
*
plugin
)
{
decoder_plugin_unload
(
plugin
);
}
void
decoder_initialized
(
struct
decoder
*
decoder
,
void
decoder_initialized
(
struct
decoder
*
decoder
,
const
struct
audio_format
*
audio_format
,
const
struct
audio_format
*
audio_format
,
float
total_time
)
float
total_time
)
...
...
src/decoder_api.h
View file @
1a4a3e1f
...
@@ -103,10 +103,6 @@ struct decoder_plugin {
...
@@ -103,10 +103,6 @@ struct decoder_plugin {
};
};
void
decoder_plugin_register
(
struct
decoder_plugin
*
plugin
);
void
decoder_plugin_unregister
(
struct
decoder_plugin
*
plugin
);
/**
/**
* Opaque handle which the decoder plugin passes to the functions in
* Opaque handle which the decoder plugin passes to the functions in
* this header.
* this header.
...
...
src/decoder_list.c
View file @
1a4a3e1f
...
@@ -18,7 +18,8 @@
...
@@ -18,7 +18,8 @@
#include "decoder_list.h"
#include "decoder_list.h"
#include "decoder_api.h"
#include "decoder_api.h"
#include "list.h"
#include <glib.h>
extern
struct
decoder_plugin
mp3Plugin
;
extern
struct
decoder_plugin
mp3Plugin
;
extern
struct
decoder_plugin
oggvorbisPlugin
;
extern
struct
decoder_plugin
oggvorbisPlugin
;
...
@@ -32,27 +33,46 @@ extern struct decoder_plugin wavpackPlugin;
...
@@ -32,27 +33,46 @@ extern struct decoder_plugin wavpackPlugin;
extern
struct
decoder_plugin
modPlugin
;
extern
struct
decoder_plugin
modPlugin
;
extern
struct
decoder_plugin
ffmpegPlugin
;
extern
struct
decoder_plugin
ffmpegPlugin
;
static
List
*
inputPlugin_list
;
static
const
struct
decoder_plugin
*
const
decoder_plugins
[]
=
{
#ifdef HAVE_MAD
void
decoder_plugin_load
(
struct
decoder_plugin
*
inputPlugin
)
&
mp3Plugin
,
{
#endif
if
(
!
inputPlugin
)
#ifdef HAVE_OGGVORBIS
return
;
&
oggvorbisPlugin
,
if
(
!
inputPlugin
->
name
)
#endif
return
;
#ifdef HAVE_FLAC_COMMON
&
oggflacPlugin
,
if
(
inputPlugin
->
init
!=
NULL
&&
!
inputPlugin
->
init
())
#endif
return
;
#ifdef HAVE_FLAC
&
flacPlugin
,
#endif
#ifdef HAVE_AUDIOFILE
&
audiofilePlugin
,
#endif
#ifdef HAVE_FAAD
&
mp4Plugin
,
&
aacPlugin
,
#endif
#ifdef HAVE_MPCDEC
&
mpcPlugin
,
#endif
#ifdef HAVE_WAVPACK
&
wavpackPlugin
,
#endif
#ifdef HAVE_MIKMOD
&
modPlugin
,
#endif
#ifdef HAVE_FFMPEG
&
ffmpegPlugin
,
#endif
};
insertInList
(
inputPlugin_list
,
inputPlugin
->
name
,
(
void
*
)
inputPlugin
);
enum
{
}
num_decoder_plugins
=
G_N_ELEMENTS
(
decoder_plugins
),
};
void
decoder_plugin_unload
(
struct
decoder_plugin
*
inputPlugin
)
/** which plugins have been initialized successfully? */
{
static
bool
decoder_plugins_enabled
[
num_decoder_plugins
];
if
(
inputPlugin
->
finish
!=
NULL
)
inputPlugin
->
finish
();
deleteFromList
(
inputPlugin_list
,
inputPlugin
->
name
);
}
static
int
stringFoundInStringArray
(
const
char
*
const
*
array
,
const
char
*
suffix
)
static
int
stringFoundInStringArray
(
const
char
*
const
*
array
,
const
char
*
suffix
)
{
{
...
@@ -68,28 +88,20 @@ static int stringFoundInStringArray(const char *const*array, const char *suffix)
...
@@ -68,28 +88,20 @@ static int stringFoundInStringArray(const char *const*array, const char *suffix)
const
struct
decoder_plugin
*
const
struct
decoder_plugin
*
decoder_plugin_from_suffix
(
const
char
*
suffix
,
unsigned
int
next
)
decoder_plugin_from_suffix
(
const
char
*
suffix
,
unsigned
int
next
)
{
{
static
ListNode
*
pos
;
static
unsigned
i
=
num_decoder_plugins
;
ListNode
*
node
;
const
struct
decoder_plugin
*
plugin
;
if
(
suffix
==
NULL
)
if
(
suffix
==
NULL
)
return
NULL
;
return
NULL
;
if
(
next
)
{
if
(
!
next
)
if
(
pos
)
i
=
0
;
node
=
pos
;
for
(;
i
<
num_decoder_plugins
;
++
i
)
{
else
const
struct
decoder_plugin
*
plugin
=
decoder_plugins
[
i
];
return
NULL
;
if
(
decoder_plugins_enabled
[
i
]
&&
}
else
stringFoundInStringArray
(
plugin
->
suffixes
,
suffix
))
{
node
=
inputPlugin_list
->
firstNode
;
++
i
;
while
(
node
!=
NULL
)
{
plugin
=
node
->
data
;
if
(
stringFoundInStringArray
(
plugin
->
suffixes
,
suffix
))
{
pos
=
node
->
nextNode
;
return
plugin
;
return
plugin
;
}
}
node
=
node
->
nextNode
;
}
}
return
NULL
;
return
NULL
;
...
@@ -98,22 +110,20 @@ decoder_plugin_from_suffix(const char *suffix, unsigned int next)
...
@@ -98,22 +110,20 @@ decoder_plugin_from_suffix(const char *suffix, unsigned int next)
const
struct
decoder_plugin
*
const
struct
decoder_plugin
*
decoder_plugin_from_mime_type
(
const
char
*
mimeType
,
unsigned
int
next
)
decoder_plugin_from_mime_type
(
const
char
*
mimeType
,
unsigned
int
next
)
{
{
static
ListNode
*
pos
;
static
unsigned
i
=
num_decoder_plugins
;
ListNode
*
node
;
struct
decoder_plugin
*
plugin
;
if
(
mimeType
==
NULL
)
if
(
mimeType
==
NULL
)
return
NULL
;
return
NULL
;
node
=
(
next
&&
pos
)
?
pos
:
inputPlugin_list
->
firstNode
;
if
(
!
next
)
i
=
0
;
while
(
node
!=
NULL
)
{
for
(;
i
<
num_decoder_plugins
;
++
i
)
{
plugin
=
node
->
data
;
const
struct
decoder_plugin
*
plugin
=
decoder_plugins
[
i
];
if
(
stringFoundInStringArray
(
plugin
->
mime_types
,
mimeType
))
{
if
(
decoder_plugins_enabled
[
i
]
&&
pos
=
node
->
nextNode
;
stringFoundInStringArray
(
plugin
->
mime_types
,
mimeType
))
{
++
i
;
return
plugin
;
return
plugin
;
}
}
node
=
node
->
nextNode
;
}
}
return
NULL
;
return
NULL
;
...
@@ -122,27 +132,30 @@ decoder_plugin_from_mime_type(const char *mimeType, unsigned int next)
...
@@ -122,27 +132,30 @@ decoder_plugin_from_mime_type(const char *mimeType, unsigned int next)
const
struct
decoder_plugin
*
const
struct
decoder_plugin
*
decoder_plugin_from_name
(
const
char
*
name
)
decoder_plugin_from_name
(
const
char
*
name
)
{
{
void
*
plugin
=
NULL
;
for
(
unsigned
i
=
0
;
i
<
num_decoder_plugins
;
++
i
)
{
const
struct
decoder_plugin
*
plugin
=
decoder_plugins
[
i
];
findInList
(
inputPlugin_list
,
name
,
&
plugin
);
if
(
decoder_plugins_enabled
[
i
]
&&
strcmp
(
plugin
->
name
,
name
)
==
0
)
return
plugin
;
}
return
(
const
struct
decoder_plugin
*
)
plugin
;
return
NULL
;
}
}
void
decoder_plugin_print_all_suffixes
(
FILE
*
fp
)
void
decoder_plugin_print_all_suffixes
(
FILE
*
fp
)
{
{
ListNode
*
node
=
inputPlugin_list
->
firstNode
;
struct
decoder_plugin
*
plugin
;
const
char
*
const
*
suffixes
;
const
char
*
const
*
suffixes
;
while
(
node
)
{
for
(
unsigned
i
=
0
;
i
<
num_decoder_plugins
;
++
i
)
{
plugin
=
(
struct
decoder_plugin
*
)
node
->
data
;
const
struct
decoder_plugin
*
plugin
=
decoder_plugins
[
i
];
if
(
!
decoder_plugins_enabled
[
i
])
continue
;
suffixes
=
plugin
->
suffixes
;
suffixes
=
plugin
->
suffixes
;
while
(
suffixes
&&
*
suffixes
)
{
while
(
suffixes
&&
*
suffixes
)
{
fprintf
(
fp
,
"%s "
,
*
suffixes
);
fprintf
(
fp
,
"%s "
,
*
suffixes
);
suffixes
++
;
suffixes
++
;
}
}
node
=
node
->
nextNode
;
}
}
fprintf
(
fp
,
"
\n
"
);
fprintf
(
fp
,
"
\n
"
);
fflush
(
fp
);
fflush
(
fp
);
...
@@ -150,43 +163,18 @@ void decoder_plugin_print_all_suffixes(FILE * fp)
...
@@ -150,43 +163,18 @@ void decoder_plugin_print_all_suffixes(FILE * fp)
void
decoder_plugin_init_all
(
void
)
void
decoder_plugin_init_all
(
void
)
{
{
inputPlugin_list
=
makeList
(
NULL
,
1
);
for
(
unsigned
i
=
0
;
i
<
num_decoder_plugins
;
++
i
)
{
const
struct
decoder_plugin
*
plugin
=
decoder_plugins
[
i
];
/* load plugins here */
if
(
plugin
->
init
!=
NULL
&&
decoder_plugins
[
i
]
->
init
())
#ifdef HAVE_MAD
decoder_plugins_enabled
[
i
]
=
true
;
decoder_plugin_load
(
&
mp3Plugin
);
}
#endif
#ifdef HAVE_OGGVORBIS
decoder_plugin_load
(
&
oggvorbisPlugin
);
#endif
#ifdef HAVE_FLAC_COMMON
decoder_plugin_load
(
&
oggflacPlugin
);
#endif
#ifdef HAVE_FLAC
decoder_plugin_load
(
&
flacPlugin
);
#endif
#ifdef HAVE_AUDIOFILE
decoder_plugin_load
(
&
audiofilePlugin
);
#endif
#ifdef HAVE_FAAD
decoder_plugin_load
(
&
mp4Plugin
);
decoder_plugin_load
(
&
aacPlugin
);
#endif
#ifdef HAVE_MPCDEC
decoder_plugin_load
(
&
mpcPlugin
);
#endif
#ifdef HAVE_WAVPACK
decoder_plugin_load
(
&
wavpackPlugin
);
#endif
#ifdef HAVE_MIKMOD
decoder_plugin_load
(
&
modPlugin
);
#endif
#ifdef HAVE_FFMPEG
decoder_plugin_load
(
&
ffmpegPlugin
);
#endif
}
}
void
decoder_plugin_deinit_all
(
void
)
void
decoder_plugin_deinit_all
(
void
)
{
{
freeList
(
inputPlugin_list
);
for
(
unsigned
i
=
0
;
i
<
num_decoder_plugins
;
++
i
)
{
const
struct
decoder_plugin
*
plugin
=
decoder_plugins
[
i
];
if
(
decoder_plugins_enabled
[
i
]
&&
plugin
->
finish
!=
NULL
)
decoder_plugins
[
i
]
->
finish
();
}
}
}
src/decoder_list.h
View file @
1a4a3e1f
...
@@ -23,10 +23,6 @@
...
@@ -23,10 +23,6 @@
struct
decoder_plugin
;
struct
decoder_plugin
;
/* individual functions to load/unload plugins */
void
decoder_plugin_load
(
struct
decoder_plugin
*
inputPlugin
);
void
decoder_plugin_unload
(
struct
decoder_plugin
*
inputPlugin
);
/* interface for using plugins */
/* interface for using plugins */
const
struct
decoder_plugin
*
const
struct
decoder_plugin
*
...
...
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