aboutsummaryrefslogtreecommitdiffstats
path: root/src/output
diff options
context:
space:
mode:
Diffstat (limited to 'src/output')
-rw-r--r--src/output/shout_mp3.c26
-rw-r--r--src/output/shout_ogg.c16
-rw-r--r--src/output/shout_plugin.c118
-rw-r--r--src/output/shout_plugin.h4
4 files changed, 82 insertions, 82 deletions
diff --git a/src/output/shout_mp3.c b/src/output/shout_mp3.c
index 804d3af12..c6b451953 100644
--- a/src/output/shout_mp3.c
+++ b/src/output/shout_mp3.c
@@ -17,9 +17,9 @@
*/
#include "shout_plugin.h"
-#include "../utils.h"
#include <lame/lame.h>
+#include <stdlib.h>
struct lame_data {
lame_global_flags *gfp;
@@ -28,10 +28,8 @@ struct lame_data {
static int shout_mp3_encoder_init(struct shout_data *sd)
{
- struct lame_data *ld;
+ struct lame_data *ld = g_new(struct lame_data, 1);
- if (NULL == (ld = xmalloc(sizeof(*ld))))
- FATAL("error initializing lame encoder data\n");
sd->encoder_data = ld;
return 0;
@@ -45,7 +43,7 @@ static int shout_mp3_encoder_clear_encoder(struct shout_data *sd)
if ((ret = lame_encode_flush(ld->gfp, buf->data + buf->len,
buf->len)) < 0)
- ERROR("error flushing lame buffers\n");
+ g_warning("error flushing lame buffers\n");
return (ret > 0);
}
@@ -63,40 +61,40 @@ static int shout_mp3_encoder_init_encoder(struct shout_data *sd)
struct lame_data *ld = (struct lame_data *)sd->encoder_data;
if (NULL == (ld->gfp = lame_init())) {
- ERROR("error initializing lame encoder for shout\n");
+ g_warning("error initializing lame encoder for shout\n");
return -1;
}
if (sd->quality >= -1.0) {
if (0 != lame_set_VBR(ld->gfp, vbr_rh)) {
- ERROR("error setting lame VBR mode\n");
+ g_warning("error setting lame VBR mode\n");
return -1;
}
if (0 != lame_set_VBR_q(ld->gfp, sd->quality)) {
- ERROR("error setting lame VBR quality\n");
+ g_warning("error setting lame VBR quality\n");
return -1;
}
} else {
if (0 != lame_set_brate(ld->gfp, sd->bitrate)) {
- ERROR("error setting lame bitrate\n");
+ g_warning("error setting lame bitrate\n");
return -1;
}
}
if (0 != lame_set_num_channels(ld->gfp,
sd->audio_format.channels)) {
- ERROR("error setting lame num channels\n");
+ g_warning("error setting lame num channels\n");
return -1;
}
if (0 != lame_set_in_samplerate(ld->gfp,
sd->audio_format.sample_rate)) {
- ERROR("error setting lame sample rate\n");
+ g_warning("error setting lame sample rate\n");
return -1;
}
if (0 > lame_init_params(ld->gfp))
- FATAL("error initializing lame params\n");
+ g_error("error initializing lame params\n");
return 0;
}
@@ -144,7 +142,7 @@ static int shout_mp3_encoder_encode(struct shout_data *sd,
samples = len / (bytes * sd->audio_format.channels);
/* rough estimate, from lame.h */
- lamebuf = xmalloc(sizeof(float) * (1.25 * samples + 7200));
+ lamebuf = g_malloc(sizeof(float) * (1.25 * samples + 7200));
/* this is for only 16-bit audio */
@@ -161,7 +159,7 @@ static int shout_mp3_encoder_encode(struct shout_data *sd,
free(lamebuf);
if (0 > bytes_out) {
- ERROR("error encoding lame buffer for shout\n");
+ g_warning("error encoding lame buffer for shout\n");
lame_close(ld->gfp);
ld->gfp = NULL;
return -1;
diff --git a/src/output/shout_ogg.c b/src/output/shout_ogg.c
index 441093e90..3ecfd3008 100644
--- a/src/output/shout_ogg.c
+++ b/src/output/shout_ogg.c
@@ -17,9 +17,9 @@
*/
#include "shout_plugin.h"
-#include "../utils.h"
#include <vorbis/vorbisenc.h>
+#include <stdlib.h>
struct ogg_vorbis_data {
ogg_stream_state os;
@@ -80,7 +80,7 @@ static int copy_ogg_buffer_to_shout_buffer(ogg_page *og,
og->header, og->header_len);
buf->len += og->header_len;
} else {
- ERROR("%s: not enough buffer space!\n", __func__);
+ g_warning("%s: not enough buffer space!\n", __func__);
return -1;
}
@@ -89,7 +89,7 @@ static int copy_ogg_buffer_to_shout_buffer(ogg_page *og,
og->body, og->body_len);
buf->len += og->body_len;
} else {
- ERROR("%s: not enough buffer space!\n", __func__);
+ g_warning("%s: not enough buffer space!\n", __func__);
return -1;
}
@@ -167,10 +167,8 @@ static void shout_ogg_encoder_finish(struct shout_data *sd)
static int shout_ogg_encoder_init(struct shout_data *sd)
{
- struct ogg_vorbis_data *od;
+ struct ogg_vorbis_data *od = g_new(struct ogg_vorbis_data, 1);
- if (NULL == (od = xmalloc(sizeof(*od))))
- FATAL("error initializing ogg vorbis encoder data\n");
sd->encoder_data = od;
return 0;
@@ -187,7 +185,7 @@ static int reinit_encoder(struct shout_data *sd)
sd->audio_format.channels,
sd->audio_format.sample_rate,
sd->quality * 0.1)) {
- ERROR("error initializing vorbis vbr\n");
+ g_warning("error initializing vorbis vbr\n");
vorbis_info_clear(&od->vi);
return -1;
}
@@ -196,7 +194,7 @@ static int reinit_encoder(struct shout_data *sd)
sd->audio_format.channels,
sd->audio_format.sample_rate, -1.0,
sd->bitrate * 1000, -1.0)) {
- ERROR("error initializing vorbis encoder\n");
+ g_warning("error initializing vorbis encoder\n");
vorbis_info_clear(&od->vi);
return -1;
}
@@ -216,7 +214,7 @@ static int shout_ogg_encoder_init_encoder(struct shout_data *sd)
return -1;
if (send_ogg_vorbis_header(sd)) {
- ERROR("error sending ogg vorbis header for shout\n");
+ g_warning("error sending ogg vorbis header for shout\n");
return -1;
}
diff --git a/src/output/shout_plugin.c b/src/output/shout_plugin.c
index a74dc6929..fe5fc9a16 100644
--- a/src/output/shout_plugin.c
+++ b/src/output/shout_plugin.c
@@ -18,9 +18,9 @@
#include "shout_plugin.h"
-#include "../utils.h"
-
#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
#define CONN_ATTEMPT_INTERVAL 60
#define DEFAULT_CONN_TIMEOUT 2
@@ -51,7 +51,7 @@ shout_encoder_plugin_get(const char *name)
static struct shout_data *new_shout_data(void)
{
- struct shout_data *ret = xmalloc(sizeof(*ret));
+ struct shout_data *ret = g_new(struct shout_data, 1);
ret->shout_conn = shout_new();
ret->shout_meta = shout_metadata_new();
@@ -86,8 +86,8 @@ static void free_shout_data(struct shout_data *sd)
#define check_block_param(name) { \
block_param = getBlockParam(param, name); \
if (!block_param) { \
- FATAL("no \"%s\" defined for shout device defined at line " \
- "%i\n", name, param->line); \
+ g_error("no \"%s\" defined for shout device defined at line " \
+ "%i\n", name, param->line); \
} \
}
@@ -127,8 +127,8 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
port = strtol(block_param->value, &test, 10);
if (*test != '\0' || port <= 0) {
- FATAL("shout port \"%s\" is not a positive integer, line %i\n",
- block_param->value, block_param->line);
+ g_error("shout port \"%s\" is not a positive integer, line %i\n",
+ block_param->value, block_param->line);
}
check_block_param("password");
@@ -155,31 +155,31 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
sd->quality = strtod(block_param->value, &test);
if (*test != '\0' || sd->quality < -1.0 || sd->quality > 10.0) {
- FATAL("shout quality \"%s\" is not a number in the "
- "range -1 to 10, line %i\n", block_param->value,
- block_param->line);
+ g_error("shout quality \"%s\" is not a number in the "
+ "range -1 to 10, line %i\n", block_param->value,
+ block_param->line);
}
block_param = getBlockParam(param, "bitrate");
if (block_param) {
- FATAL("quality (line %i) and bitrate (line %i) are "
- "both defined for shout output\n", line,
- block_param->line);
+ g_error("quality (line %i) and bitrate (line %i) are "
+ "both defined for shout output\n", line,
+ block_param->line);
}
} else {
block_param = getBlockParam(param, "bitrate");
if (!block_param) {
- FATAL("neither bitrate nor quality defined for shout "
- "output at line %i\n", param->line);
+ g_error("neither bitrate nor quality defined for shout "
+ "output at line %i\n", param->line);
}
sd->bitrate = strtol(block_param->value, &test, 10);
if (*test != '\0' || sd->bitrate <= 0) {
- FATAL("bitrate at line %i should be a positive integer "
- "\n", block_param->line);
+ g_error("bitrate at line %i should be a positive integer "
+ "\n", block_param->line);
}
}
@@ -195,24 +195,24 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
else if (0 == strcmp(block_param->value, "ogg"))
encoding = block_param->value;
else
- FATAL("shout encoding \"%s\" is not \"ogg\" or "
- "\"mp3\", line %i\n", block_param->value,
- block_param->line);
+ g_error("shout encoding \"%s\" is not \"ogg\" or "
+ "\"mp3\", line %i\n", block_param->value,
+ block_param->line);
} else {
encoding = "ogg";
}
sd->encoder = shout_encoder_plugin_get(encoding);
if (sd->encoder == NULL)
- FATAL("couldn't find shout encoder plugin for \"%s\" "
- "at line %i\n", encoding, block_param->line);
+ g_error("couldn't find shout encoder plugin for \"%s\" "
+ "at line %i\n", encoding, block_param->line);
block_param = getBlockParam(param, "protocol");
if (block_param) {
if (0 == strcmp(block_param->value, "shoutcast") &&
0 != strcmp(encoding, "mp3"))
- FATAL("you cannot stream \"%s\" to shoutcast, use mp3\n",
- encoding);
+ g_error("you cannot stream \"%s\" to shoutcast, use mp3\n",
+ encoding);
else if (0 == strcmp(block_param->value, "shoutcast"))
protocol = SHOUT_PROTOCOL_ICY;
else if (0 == strcmp(block_param->value, "icecast1"))
@@ -220,10 +220,10 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
else if (0 == strcmp(block_param->value, "icecast2"))
protocol = SHOUT_PROTOCOL_HTTP;
else
- FATAL("shout protocol \"%s\" is not \"shoutcast\" or "
- "\"icecast1\"or "
- "\"icecast2\", line %i\n", block_param->value,
- block_param->line);
+ g_error("shout protocol \"%s\" is not \"shoutcast\" or "
+ "\"icecast1\"or "
+ "\"icecast2\", line %i\n", block_param->value,
+ block_param->line);
} else {
protocol = SHOUT_PROTOCOL_HTTP;
}
@@ -240,8 +240,8 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
!= SHOUTERR_SUCCESS ||
shout_set_protocol(sd->shout_conn, protocol) != SHOUTERR_SUCCESS ||
shout_set_agent(sd->shout_conn, "MPD") != SHOUTERR_SUCCESS) {
- FATAL("error configuring shout defined at line %i: %s\n",
- param->line, shout_get_error(sd->shout_conn));
+ g_error("error configuring shout defined at line %i: %s\n",
+ param->line, shout_get_error(sd->shout_conn));
}
/* optional paramters */
@@ -249,22 +249,22 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
if (block_param) {
sd->timeout = (int)strtol(block_param->value, &test, 10);
if (*test != '\0' || sd->timeout <= 0) {
- FATAL("shout timeout is not a positive integer, "
- "line %i\n", block_param->line);
+ g_error("shout timeout is not a positive integer, "
+ "line %i\n", block_param->line);
}
}
block_param = getBlockParam(param, "genre");
if (block_param && shout_set_genre(sd->shout_conn, block_param->value)) {
- FATAL("error configuring shout defined at line %i: %s\n",
- param->line, shout_get_error(sd->shout_conn));
+ g_error("error configuring shout defined at line %i: %s\n",
+ param->line, shout_get_error(sd->shout_conn));
}
block_param = getBlockParam(param, "description");
if (block_param && shout_set_description(sd->shout_conn,
block_param->value)) {
- FATAL("error configuring shout defined at line %i: %s\n",
- param->line, shout_get_error(sd->shout_conn));
+ g_error("error configuring shout defined at line %i: %s\n",
+ param->line, shout_get_error(sd->shout_conn));
}
{
@@ -290,8 +290,8 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
}
if (sd->encoder->init_func(sd) != 0)
- FATAL("shout: encoder plugin '%s' failed to initialize\n",
- sd->encoder->name);
+ g_error("shout: encoder plugin '%s' failed to initialize\n",
+ sd->encoder->name);
return sd;
}
@@ -303,17 +303,17 @@ static int handle_shout_error(struct shout_data *sd, int err)
break;
case SHOUTERR_UNCONNECTED:
case SHOUTERR_SOCKET:
- ERROR("Lost shout connection to %s:%i: %s\n",
- shout_get_host(sd->shout_conn),
- shout_get_port(sd->shout_conn),
- shout_get_error(sd->shout_conn));
+ g_warning("Lost shout connection to %s:%i: %s\n",
+ shout_get_host(sd->shout_conn),
+ shout_get_port(sd->shout_conn),
+ shout_get_error(sd->shout_conn));
sd->shout_error = 1;
return -1;
default:
- ERROR("shout: connection to %s:%i error: %s\n",
- shout_get_host(sd->shout_conn),
- shout_get_port(sd->shout_conn),
- shout_get_error(sd->shout_conn));
+ g_warning("shout: connection to %s:%i error: %s\n",
+ shout_get_host(sd->shout_conn),
+ shout_get_port(sd->shout_conn),
+ shout_get_error(sd->shout_conn));
sd->shout_error = 1;
return -1;
}
@@ -346,8 +346,8 @@ static void close_shout_conn(struct shout_data * sd)
if (shout_get_connected(sd->shout_conn) != SHOUTERR_UNCONNECTED &&
shout_close(sd->shout_conn) != SHOUTERR_SUCCESS) {
- ERROR("problem closing connection to shout server: %s\n",
- shout_get_error(sd->shout_conn));
+ g_warning("problem closing connection to shout server: %s\n",
+ shout_get_error(sd->shout_conn));
}
sd->opened = false;
@@ -401,11 +401,11 @@ static int shout_connect(struct shout_data *sd)
if (state == SHOUTERR_BUSY && sd->conn_attempts != 0) {
/* timeout waiting to connect */
if ((t - sd->last_attempt) > sd->timeout) {
- ERROR("timeout connecting to shout server %s:%i "
- "(attempt %i)\n",
- shout_get_host(sd->shout_conn),
- shout_get_port(sd->shout_conn),
- sd->conn_attempts);
+ g_warning("timeout connecting to shout server %s:%i "
+ "(attempt %i)\n",
+ shout_get_host(sd->shout_conn),
+ shout_get_port(sd->shout_conn),
+ sd->conn_attempts);
return -1;
}
@@ -435,11 +435,11 @@ static int shout_connect(struct shout_data *sd)
case SHOUTERR_BUSY:
return 1;
default:
- ERROR("problem opening connection to shout server %s:%i "
- "(attempt %i): %s\n",
- shout_get_host(sd->shout_conn),
- shout_get_port(sd->shout_conn),
- sd->conn_attempts, shout_get_error(sd->shout_conn));
+ g_warning("problem opening connection to shout server %s:%i "
+ "(attempt %i): %s\n",
+ shout_get_host(sd->shout_conn),
+ shout_get_port(sd->shout_conn),
+ sd->conn_attempts, shout_get_error(sd->shout_conn));
return -1;
}
}
@@ -496,7 +496,7 @@ static void send_metadata(struct shout_data * sd)
shout_metadata_add(sd->shout_meta, "song", song);
if (SHOUTERR_SUCCESS != shout_set_metadata(sd->shout_conn,
sd->shout_meta)) {
- ERROR("error setting shout metadata\n");
+ g_warning("error setting shout metadata\n");
return;
}
}
diff --git a/src/output/shout_plugin.h b/src/output/shout_plugin.h
index aa084d988..46514fdc3 100644
--- a/src/output/shout_plugin.h
+++ b/src/output/shout_plugin.h
@@ -24,6 +24,10 @@
#include "../timer.h"
#include <shout/shout.h>
+#include <glib.h>
+
+#undef G_LOG_DOMAIN
+#define G_LOG_DOMAIN "shout"
struct shout_data;