aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-14 01:51:01 +0100
committerMax Kellermann <max@duempel.org>2009-11-14 02:07:41 +0100
commit2d236e281f7fa0a2e1a065c8735d7dbb7ae407f9 (patch)
treeb8125f64b584b0ff6895884cdfa3aeca1266358a
parenta6fd5819f9915dbd3a8c78ef25ce642f9e13e517 (diff)
downloadmpd-2d236e281f7fa0a2e1a065c8735d7dbb7ae407f9.tar.gz
mpd-2d236e281f7fa0a2e1a065c8735d7dbb7ae407f9.tar.xz
mpd-2d236e281f7fa0a2e1a065c8735d7dbb7ae407f9.zip
decoder/mikmod: static mod_Data object
Don't allocate this object, put it on the stack.
Diffstat (limited to '')
-rw-r--r--src/decoder/mikmod_plugin.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/decoder/mikmod_plugin.c b/src/decoder/mikmod_plugin.c
index c01395772..9b331aa9e 100644
--- a/src/decoder/mikmod_plugin.c
+++ b/src/decoder/mikmod_plugin.c
@@ -131,48 +131,46 @@ typedef struct _mod_Data {
SBYTE audio_buffer[MIKMOD_FRAME_SIZE];
} mod_Data;
-static mod_Data *mod_open(const char *path)
+static bool
+mod_open(mod_Data *data, const char *path)
{
char *path2;
MODULE *moduleHandle;
- mod_Data *data;
path2 = g_strdup(path);
moduleHandle = Player_Load(path2, 128, 0);
g_free(path2);
if (moduleHandle == NULL)
- return NULL;
+ return false;
/* Prevent module from looping forever */
moduleHandle->loop = 0;
- data = g_new(mod_Data, 1);
data->moduleHandle = moduleHandle;
Player_Start(data->moduleHandle);
- return data;
+ return true;
}
static void mod_close(mod_Data * data)
{
Player_Stop();
Player_Free(data->moduleHandle);
- g_free(data);
}
static void
mod_decode(struct decoder *decoder, const char *path)
{
- mod_Data *data;
+ mod_Data data;
struct audio_format audio_format;
float total_time = 0.0;
int ret;
float secPerByte;
enum decoder_command cmd = DECODE_COMMAND_NONE;
- if (!(data = mod_open(path))) {
+ if (!mod_open(&data, path)) {
g_warning("failed to open mod: %s\n", path);
return;
}
@@ -187,14 +185,14 @@ mod_decode(struct decoder *decoder, const char *path)
decoder_initialized(decoder, &audio_format, false, 0);
while (cmd == DECODE_COMMAND_NONE && Player_Active()) {
- ret = VC_WriteBytes(data->audio_buffer, MIKMOD_FRAME_SIZE);
+ ret = VC_WriteBytes(data.audio_buffer, MIKMOD_FRAME_SIZE);
total_time += ret * secPerByte;
cmd = decoder_data(decoder, NULL,
- data->audio_buffer, ret,
+ data.audio_buffer, ret,
total_time, 0, NULL);
}
- mod_close(data);
+ mod_close(&data);
}
static struct tag *modTagDup(const char *file)