pcm: use GLib instead of utils.h

This commit is contained in:
Max Kellermann 2009-01-03 14:52:13 +01:00
parent 962f2407d2
commit d342e338db
3 changed files with 14 additions and 17 deletions

View File

@ -17,7 +17,6 @@
*/ */
#include "pcm_channels.h" #include "pcm_channels.h"
#include "utils.h"
#include <glib.h> #include <glib.h>
@ -84,7 +83,7 @@ pcm_convert_channels_16(int8_t dest_channels,
if (dest_size > len) { if (dest_size > len) {
len = dest_size; len = dest_size;
buf = xrealloc(buf, len); buf = g_realloc(buf, len);
} }
*dest_size_r = dest_size; *dest_size_r = dest_size;
@ -163,7 +162,7 @@ pcm_convert_channels_24(int8_t dest_channels,
if (dest_size > len) { if (dest_size > len) {
len = dest_size; len = dest_size;
buf = xrealloc(buf, len); buf = g_realloc(buf, len);
} }
*dest_size_r = dest_size; *dest_size_r = dest_size;

View File

@ -19,7 +19,6 @@
#include "pcm_resample.h" #include "pcm_resample.h"
#include "conf.h" #include "conf.h"
#include "utils.h"
#include <glib.h> #include <glib.h>
@ -131,14 +130,14 @@ pcm_resample_16(uint8_t channels,
data_in_size = data->input_frames * sizeof(float) * channels; data_in_size = data->input_frames * sizeof(float) * channels;
if (data_in_size > state->data_in_size) { if (data_in_size > state->data_in_size) {
state->data_in_size = data_in_size; state->data_in_size = data_in_size;
data->data_in = xrealloc(data->data_in, data_in_size); data->data_in = g_realloc(data->data_in, data_in_size);
} }
data->output_frames = dest_size / sizeof(*dest_buffer) / channels; data->output_frames = dest_size / sizeof(*dest_buffer) / channels;
data_out_size = data->output_frames * sizeof(float) * channels; data_out_size = data->output_frames * sizeof(float) * channels;
if (data_out_size > state->data_out_size) { if (data_out_size > state->data_out_size) {
state->data_out_size = data_out_size; state->data_out_size = data_out_size;
data->data_out = xrealloc(data->data_out, data_out_size); data->data_out = g_realloc(data->data_out, data_out_size);
} }
src_short_to_float_array(src_buffer, data->data_in, src_short_to_float_array(src_buffer, data->data_in,
@ -204,14 +203,14 @@ pcm_resample_24(uint8_t channels,
data_in_size = data->input_frames * sizeof(float) * channels; data_in_size = data->input_frames * sizeof(float) * channels;
if (data_in_size > state->data_in_size) { if (data_in_size > state->data_in_size) {
state->data_in_size = data_in_size; state->data_in_size = data_in_size;
data->data_in = xrealloc(data->data_in, data_in_size); data->data_in = g_realloc(data->data_in, data_in_size);
} }
data->output_frames = dest_size / sizeof(*dest_buffer) / channels; data->output_frames = dest_size / sizeof(*dest_buffer) / channels;
data_out_size = data->output_frames * sizeof(float) * channels; data_out_size = data->output_frames * sizeof(float) * channels;
if (data_out_size > state->data_out_size) { if (data_out_size > state->data_out_size) {
state->data_out_size = data_out_size; state->data_out_size = data_out_size;
data->data_out = xrealloc(data->data_out, data_out_size); data->data_out = g_realloc(data->data_out, data_out_size);
} }
src_int_to_float_array(src_buffer, data->data_in, src_int_to_float_array(src_buffer, data->data_in,

View File

@ -19,7 +19,6 @@
#include "pcm_utils.h" #include "pcm_utils.h"
#include "pcm_channels.h" #include "pcm_channels.h"
#include "pcm_prng.h" #include "pcm_prng.h"
#include "utils.h"
#include "conf.h" #include "conf.h"
#include "audio_format.h" #include "audio_format.h"
@ -259,7 +258,7 @@ pcm_convert_to_16(struct pcm_convert_state *convert,
*dest_size_r = src_size << 1; *dest_size_r = src_size << 1;
if (*dest_size_r > len) { if (*dest_size_r > len) {
len = *dest_size_r; len = *dest_size_r;
buf = xrealloc(buf, len); buf = g_realloc(buf, len);
} }
pcm_convert_8_to_16((int16_t *)buf, pcm_convert_8_to_16((int16_t *)buf,
@ -276,7 +275,7 @@ pcm_convert_to_16(struct pcm_convert_state *convert,
*dest_size_r = num_samples * 2; *dest_size_r = num_samples * 2;
if (*dest_size_r > len) { if (*dest_size_r > len) {
len = *dest_size_r; len = *dest_size_r;
buf = xrealloc(buf, len); buf = g_realloc(buf, len);
} }
pcm_convert_24_to_16(&convert->dither, pcm_convert_24_to_16(&convert->dither,
@ -324,7 +323,7 @@ pcm_convert_to_24(uint8_t bits, const void *src,
*dest_size_r = src_size * 4; *dest_size_r = src_size * 4;
if (*dest_size_r > len) { if (*dest_size_r > len) {
len = *dest_size_r; len = *dest_size_r;
buf = xrealloc(buf, len); buf = g_realloc(buf, len);
} }
pcm_convert_8_to_24(buf, (const int8_t *)src, pcm_convert_8_to_24(buf, (const int8_t *)src,
@ -336,7 +335,7 @@ pcm_convert_to_24(uint8_t bits, const void *src,
*dest_size_r = num_samples * 4; *dest_size_r = num_samples * 4;
if (*dest_size_r > len) { if (*dest_size_r > len) {
len = *dest_size_r; len = *dest_size_r;
buf = xrealloc(buf, len); buf = g_realloc(buf, len);
} }
pcm_convert_16_to_24(buf, (const int16_t *)src, pcm_convert_16_to_24(buf, (const int16_t *)src,
@ -368,14 +367,14 @@ pcm_convert_16(const struct audio_format *src_format,
buf = pcm_convert_to_16(state, src_format->bits, buf = pcm_convert_to_16(state, src_format->bits,
src_buffer, src_size, &len); src_buffer, src_size, &len);
if (!buf) if (!buf)
exit(EXIT_FAILURE); g_error("pcm_convert_to_16() failed");
if (src_format->channels != dest_format->channels) { if (src_format->channels != dest_format->channels) {
buf = pcm_convert_channels_16(dest_format->channels, buf = pcm_convert_channels_16(dest_format->channels,
src_format->channels, src_format->channels,
buf, len, &len); buf, len, &len);
if (!buf) if (!buf)
exit(EXIT_FAILURE); g_error("pcm_convert_channels_16() failed");
} }
if (src_format->sample_rate == dest_format->sample_rate) { if (src_format->sample_rate == dest_format->sample_rate) {
@ -408,14 +407,14 @@ pcm_convert_24(const struct audio_format *src_format,
buf = pcm_convert_to_24(src_format->bits, buf = pcm_convert_to_24(src_format->bits,
src_buffer, src_size, &len); src_buffer, src_size, &len);
if (!buf) if (!buf)
exit(EXIT_FAILURE); g_error("pcm_convert_to_24() failed");
if (src_format->channels != dest_format->channels) { if (src_format->channels != dest_format->channels) {
buf = pcm_convert_channels_24(dest_format->channels, buf = pcm_convert_channels_24(dest_format->channels,
src_format->channels, src_format->channels,
buf, len, &len); buf, len, &len);
if (!buf) if (!buf)
exit(EXIT_FAILURE); g_error("pcm_convert_channels_24() failed");
} }
if (src_format->sample_rate == dest_format->sample_rate) { if (src_format->sample_rate == dest_format->sample_rate) {