Fixed build by removing paste duplicates in fluid_filerenderer.c and some other misc stuff.

This commit is contained in:
Josh Green 2009-04-27 19:55:08 +00:00
parent 5fcedecdfd
commit 5394a4e81e
5 changed files with 31 additions and 303 deletions

View file

@ -1,3 +1,11 @@
2009-04-27 Josh Green <jgreen@users.sourceforge.net>
* include/fluidsynth/audio.h: Moved new filerenderer documentation to source file.
* src/config_win32.h.in: Added 'typedef int socklen_t;' to the correct place.
* src/fluid_filerenderer.c: Removed 2 extra pasted duplicates of the file, moved
Doxygen documentation from header file and added "API 1.1.0" designators.
* src/config_win32.h: Removed from subversion, since it is generated from
config_win32.h.in.
2009-04-26 Josh Green <jgreen@users.sourceforge.net>
* configure.ac: Added glib 2.10 as a dependency, added notes in output
for LASH, LADCCA and READLINE that they are GPL.

View file

@ -61,26 +61,9 @@ FLUIDSYNTH_API fluid_audio_driver_t* new_fluid_audio_driver2(fluid_settings_t* s
FLUIDSYNTH_API void delete_fluid_audio_driver(fluid_audio_driver_t* driver);
/**
* Create a new file renderer and open the file.
* @param synth The synth that creates audio data.
* @param filename Output filename
* @param period_size Sample count, amount of samples to write to the file at
* every call to fluid_file_renderer_process_block().
* @return the new object, or NULL on failure
*/
FLUIDSYNTH_API fluid_file_renderer_t* new_fluid_file_renderer(fluid_synth_t* synth,
char* filename, int period_size);
/**
* Write period_size samples to file.
* @return FLUID_OK or FLUID_FAILED if an error occurred
*/
FLUIDSYNTH_API int fluid_file_renderer_process_block(fluid_file_renderer_t* dev);
/**
* Close file and destroy the file renderer object.
*/
FLUIDSYNTH_API void delete_fluid_file_renderer(fluid_file_renderer_t* dev);
#ifdef __cplusplus

View file

@ -1,42 +0,0 @@
#define VERSION "1.0.9"
#define HAVE_STRING_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STDIO_H 1
#define HAVE_MATH_H 1
#define HAVE_STDARG_H 1
#define HAVE_FCNTL_H 1
#define HAVE_LIMITS_H 1
#define HAVE_IO_H 1
#define HAVE_WINDOWS_H 1
#define DSOUND_SUPPORT 1
#define WINMIDI_SUPPORT 1
#define WITH_FLOAT 1
#define snprintf _snprintf
#define strcasecmp _stricmp
#if _MSC_VER < 1500
#define vsnprintf _vsnprintf
#endif
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
#define WITH_PROFILING 0
#pragma warning(disable : 4244)
#pragma warning(disable : 4101)
#pragma warning(disable : 4305)
#pragma warning(disable : 4996)
#define WITHOUT_SERVER 1
#ifndef inline
#define inline __inline
#endif
typedef int socklen_t;

View file

@ -38,3 +38,5 @@
#ifndef inline
#define inline __inline
#endif
typedef int socklen_t;

View file

@ -33,6 +33,12 @@ struct _fluid_file_renderer_t {
int buf_size;
};
/**
* Close file and destroy a file renderer object.
* @param dev File renderer object.
*
* API: 1.1.0
*/
void delete_fluid_file_renderer(fluid_file_renderer_t* dev)
{
if (dev == NULL) {
@ -51,11 +57,16 @@ void delete_fluid_file_renderer(fluid_file_renderer_t* dev)
return;
}
/*
* Create a new file renderer object and open the file.
*/
/**
* Create a new file renderer and open the file.
* @param synth The synth that creates audio data.
* @param filename Output filename
* @param period_size Sample count, amount of samples to write to the file at
* every call to fluid_file_renderer_process_block().
* @return the new object, or NULL on failure
*
* API: 1.1.0
*/
fluid_file_renderer_t* new_fluid_file_renderer(fluid_synth_t* synth, char* filename, int period_size)
{
fluid_file_renderer_t* dev;
@ -96,246 +107,12 @@ fluid_file_renderer_t* new_fluid_file_renderer(fluid_synth_t* synth, char* filen
}
/*
* Write period_size samples to file.
*/
int fluid_file_renderer_process_block(fluid_file_renderer_t* dev)
{
int n, offset;
fluid_synth_write_s16(dev->synth, dev->period_size, dev->buf, 0, 2, dev->buf, 1, 2);
for (offset = 0; offset < dev->buf_size; offset += n) {
n = fwrite((char*) dev->buf + offset, 1, dev->buf_size - offset, dev->file);
if (n < 0) {
FLUID_LOG(FLUID_ERR, "Audio output file write error: %s",
strerror (errno));
return FLUID_FAILED;
}
}
return FLUID_OK;
}
/* FluidSynth - A Software Synthesizer
*
* Copyright (C) 2003 Peter Hanappe and others.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307, USA
*/
/*
* Low-level routines for file output.
*/
#include <stdio.h>
#include "fluidsynth_priv.h"
struct _fluid_file_renderer_t {
FILE* file;
fluid_synth_t* synth;
short* buf;
int period_size;
int buf_size;
};
void delete_fluid_file_renderer(fluid_file_renderer_t* dev)
{
if (dev == NULL) {
return;
}
if (dev->file != NULL) {
fclose(dev->file);
}
if (dev->buf != NULL) {
FLUID_FREE(dev->buf);
}
FLUID_FREE(dev);
return;
}
/*
* Create a new file renderer object and open the file.
*/
fluid_file_renderer_t* new_fluid_file_renderer(fluid_synth_t* synth, char* filename, int period_size)
{
fluid_file_renderer_t* dev;
dev = FLUID_NEW(fluid_file_renderer_t);
if (dev == NULL) {
FLUID_LOG(FLUID_ERR, "Out of memory");
return NULL;
}
FLUID_MEMSET(dev, 0, sizeof(fluid_file_renderer_t));
dev->synth = synth;
dev->period_size = period_size;
dev->buf_size = 2 * dev->period_size * sizeof(short);
dev->buf = FLUID_ARRAY(short, 2 * dev->period_size);
if (dev->buf == NULL) {
FLUID_LOG(FLUID_ERR, "Out of memory");
goto error_recovery;
}
if (filename == NULL) {
FLUID_LOG(FLUID_ERR, "No file name specified");
goto error_recovery;
}
dev->file = fopen(filename, "wb");
if (dev->file == NULL) {
FLUID_LOG(FLUID_ERR, "Failed to open the file '%s'", filename);
goto error_recovery;
}
return dev;
error_recovery:
delete_fluid_file_renderer(dev);
return NULL;
}
/*
* Write period_size samples to file.
*/
int fluid_file_renderer_process_block(fluid_file_renderer_t* dev)
{
int n, offset;
fluid_synth_write_s16(dev->synth, dev->period_size, dev->buf, 0, 2, dev->buf, 1, 2);
for (offset = 0; offset < dev->buf_size; offset += n) {
n = fwrite((char*) dev->buf + offset, 1, dev->buf_size - offset, dev->file);
if (n < 0) {
FLUID_LOG(FLUID_ERR, "Audio output file write error: %s",
strerror (errno));
return FLUID_FAILED;
}
}
return FLUID_OK;
}
/* FluidSynth - A Software Synthesizer
*
* Copyright (C) 2003 Peter Hanappe and others.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307, USA
*/
/*
* Low-level routines for file output.
*/
#include <stdio.h>
#include "fluidsynth_priv.h"
struct _fluid_file_renderer_t {
FILE* file;
fluid_synth_t* synth;
short* buf;
int period_size;
int buf_size;
};
void delete_fluid_file_renderer(fluid_file_renderer_t* dev)
{
if (dev == NULL) {
return;
}
if (dev->file != NULL) {
fclose(dev->file);
}
if (dev->buf != NULL) {
FLUID_FREE(dev->buf);
}
FLUID_FREE(dev);
return;
}
/*
* Create a new file renderer object and open the file.
*/
fluid_file_renderer_t* new_fluid_file_renderer(fluid_synth_t* synth, char* filename, int period_size)
{
fluid_file_renderer_t* dev;
dev = FLUID_NEW(fluid_file_renderer_t);
if (dev == NULL) {
FLUID_LOG(FLUID_ERR, "Out of memory");
return NULL;
}
FLUID_MEMSET(dev, 0, sizeof(fluid_file_renderer_t));
dev->synth = synth;
dev->period_size = period_size;
dev->buf_size = 2 * dev->period_size * sizeof(short);
dev->buf = FLUID_ARRAY(short, 2 * dev->period_size);
if (dev->buf == NULL) {
FLUID_LOG(FLUID_ERR, "Out of memory");
goto error_recovery;
}
if (filename == NULL) {
FLUID_LOG(FLUID_ERR, "No file name specified");
goto error_recovery;
}
dev->file = fopen(filename, "wb");
if (dev->file == NULL) {
FLUID_LOG(FLUID_ERR, "Failed to open the file '%s'", filename);
goto error_recovery;
}
return dev;
error_recovery:
delete_fluid_file_renderer(dev);
return NULL;
}
/*
/**
* Write period_size samples to file.
* @param dev File renderer instance
* @return FLUID_OK or FLUID_FAILED if an error occurred
*
* API: 1.1.0
*/
int fluid_file_renderer_process_block(fluid_file_renderer_t* dev)
{