aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/mikmod_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-14 01:53:50 +0100
committerMax Kellermann <max@duempel.org>2009-11-14 02:07:41 +0100
commit0c5329aedc1a3ce838342c9fc92dededfb7627a1 (patch)
tree324e958f450e942fec851e6bdec617b6c905c457 /src/decoder/mikmod_plugin.c
parent2d236e281f7fa0a2e1a065c8735d7dbb7ae407f9 (diff)
downloadmpd-0c5329aedc1a3ce838342c9fc92dededfb7627a1.tar.gz
mpd-0c5329aedc1a3ce838342c9fc92dededfb7627a1.tar.xz
mpd-0c5329aedc1a3ce838342c9fc92dededfb7627a1.zip
decoder/mikmod: merged open()/close() into decode()
These functions are trivial, we don't need them separate.
Diffstat (limited to 'src/decoder/mikmod_plugin.c')
-rw-r--r--src/decoder/mikmod_plugin.c43
1 files changed, 12 insertions, 31 deletions
diff --git a/src/decoder/mikmod_plugin.c b/src/decoder/mikmod_plugin.c
index 9b331aa9e..4f79e0ad0 100644
--- a/src/decoder/mikmod_plugin.c
+++ b/src/decoder/mikmod_plugin.c
@@ -131,38 +131,10 @@ typedef struct _mod_Data {
SBYTE audio_buffer[MIKMOD_FRAME_SIZE];
} mod_Data;
-static bool
-mod_open(mod_Data *data, const char *path)
-{
- char *path2;
- MODULE *moduleHandle;
-
- path2 = g_strdup(path);
- moduleHandle = Player_Load(path2, 128, 0);
- g_free(path2);
-
- if (moduleHandle == NULL)
- return false;
-
- /* Prevent module from looping forever */
- moduleHandle->loop = 0;
-
- data->moduleHandle = moduleHandle;
-
- Player_Start(data->moduleHandle);
-
- return true;
-}
-
-static void mod_close(mod_Data * data)
-{
- Player_Stop();
- Player_Free(data->moduleHandle);
-}
-
static void
mod_decode(struct decoder *decoder, const char *path)
{
+ char *path2;
mod_Data data;
struct audio_format audio_format;
float total_time = 0.0;
@@ -170,11 +142,18 @@ mod_decode(struct decoder *decoder, const char *path)
float secPerByte;
enum decoder_command cmd = DECODE_COMMAND_NONE;
- if (!mod_open(&data, path)) {
+ path2 = g_strdup(path);
+ data.moduleHandle = Player_Load(path2, 128, 0);
+ g_free(path2);
+
+ if (data.moduleHandle == NULL) {
g_warning("failed to open mod: %s\n", path);
return;
}
+ /* Prevent module from looping forever */
+ data.moduleHandle->loop = 0;
+
audio_format_init(&audio_format, 44100, 16, 2);
assert(audio_format_valid(&audio_format));
@@ -184,6 +163,7 @@ mod_decode(struct decoder *decoder, const char *path)
decoder_initialized(decoder, &audio_format, false, 0);
+ Player_Start(data.moduleHandle);
while (cmd == DECODE_COMMAND_NONE && Player_Active()) {
ret = VC_WriteBytes(data.audio_buffer, MIKMOD_FRAME_SIZE);
total_time += ret * secPerByte;
@@ -192,7 +172,8 @@ mod_decode(struct decoder *decoder, const char *path)
total_time, 0, NULL);
}
- mod_close(&data);
+ Player_Stop();
+ Player_Free(data.moduleHandle);
}
static struct tag *modTagDup(const char *file)