aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
Diffstat (limited to 'src/decoder')
-rw-r--r--src/decoder/ffmpeg_plugin.c59
-rw-r--r--src/decoder/mp3_plugin.c8
2 files changed, 42 insertions, 25 deletions
diff --git a/src/decoder/ffmpeg_plugin.c b/src/decoder/ffmpeg_plugin.c
index f9e40e2f5..7f7978b9d 100644
--- a/src/decoder/ffmpeg_plugin.c
+++ b/src/decoder/ffmpeg_plugin.c
@@ -106,7 +106,7 @@ static int64_t mpd_ffmpeg_seek(URLContext *h, int64_t pos, int whence)
static int mpd_ffmpeg_close(URLContext *h)
{
- h->priv_data = 0;
+ h->priv_data = NULL;
return 0;
}
@@ -208,30 +208,46 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
AVCodecContext *codec_context,
const AVRational *time_base)
{
+ enum decoder_command cmd = DECODE_COMMAND_NONE;
int position;
uint8_t audio_buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2];
int len, audio_size;
+ uint8_t *packet_data;
+ int packet_size;
- position = av_rescale_q(packet->pts, *time_base,
- (AVRational){1, 1});
+ packet_data = packet->data;
+ packet_size = packet->size;
- audio_size = sizeof(audio_buf);
- len = avcodec_decode_audio2(codec_context,
- (int16_t *)audio_buf,
- &audio_size,
- packet->data, packet->size);
+ while ((packet_size > 0) && (cmd == DECODE_COMMAND_NONE)) {
+ audio_size = sizeof(audio_buf);
+ len = avcodec_decode_audio2(codec_context,
+ (int16_t *)audio_buf,
+ &audio_size,
+ packet_data, packet_size);
- if (len < 0) {
- g_message("skipping frame\n");
- return decoder_get_command(decoder);
- }
- assert(audio_size >= 0);
+ position = av_rescale_q(packet->pts, *time_base,
+ (AVRational){1, 1});
+
+ if (len < 0) {
+ /* if error, we skip the frame */
+ g_message("decoding failed\n");
+ break;
+ }
- return decoder_data(decoder, is,
- audio_buf, audio_size,
- position,
- codec_context->bit_rate / 1000, NULL);
+ packet_data += len;
+ packet_size -= len;
+
+ if (audio_size <= 0) {
+ g_message("no audio frame\n");
+ continue;
+ }
+ cmd = decoder_data(decoder, is,
+ audio_buf, audio_size,
+ position,
+ codec_context->bit_rate / 1000, NULL);
+ }
+ return cmd;
}
static bool
@@ -263,7 +279,7 @@ ffmpeg_decode_internal(struct ffmpeg_context *ctx)
}
//there is some problem with this on some demux (mp3 at least)
- if (format_context->duration != (int)AV_NOPTS_VALUE) {
+ if (format_context->duration != (int64_t)AV_NOPTS_VALUE) {
total_time = format_context->duration / AV_TIME_BASE;
}
@@ -314,7 +330,7 @@ static bool ffmpeg_tag_internal(struct ffmpeg_context *ctx)
const AVFormatContext *f = ctx->format_context;
tag->time = 0;
- if (f->duration != (int)AV_NOPTS_VALUE)
+ if (f->duration != (int64_t)AV_NOPTS_VALUE)
tag->time = f->duration / AV_TIME_BASE;
if (f->author[0])
tag_add_item(tag, TAG_ITEM_ARTIST, f->author);
@@ -368,8 +384,9 @@ static struct tag *ffmpeg_tag(const char *file)
*/
static const char *const ffmpeg_suffixes[] = {
- "wma", "asf", "wmv", "mpeg", "mpg", "avi", "vob", "mov", "qt", "swf", "rm", "swf",
- "mp1", "mp2", "mp3", "mp4", "m4a", "flac", "ogg", "wav", "au", "aiff", "aif", "ac3", "aac", "mpc",
+ "wma", "asf", "wmv", "mpeg", "mpg", "avi", "vob", "mov", "qt", "swf",
+ "rm", "swf", "mp1", "mp2", "mp3", "mp4", "m4a", "flac", "ogg", "wav",
+ "au", "aiff", "aif", "ac3", "aac", "mpc", "ape",
NULL
};
diff --git a/src/decoder/mp3_plugin.c b/src/decoder/mp3_plugin.c
index a3643b842..3a908299f 100644
--- a/src/decoder/mp3_plugin.c
+++ b/src/decoder/mp3_plugin.c
@@ -323,8 +323,8 @@ static void mp3_parse_id3(struct mp3_data *data, size_t tagsize,
#endif
static enum mp3_action
-decode_next_frame_header(struct mp3_data *data, struct tag **tag,
- struct replay_gain_info **replay_gain_info_r)
+decode_next_frame_header(struct mp3_data *data, G_GNUC_UNUSED struct tag **tag,
+ G_GNUC_UNUSED struct replay_gain_info **replay_gain_info_r)
{
enum mad_layer layer;
@@ -705,7 +705,7 @@ mp3_decode_first_frame(struct mp3_data *data, struct tag **tag,
struct lame lame;
struct mad_bitptr ptr;
int bitlen;
- int ret;
+ enum mp3_action ret;
/* stfu gcc */
memset(&xing, 0, sizeof(struct xing));
@@ -976,7 +976,7 @@ static bool
mp3_read(struct mp3_data *data, struct replay_gain_info **replay_gain_info_r)
{
struct decoder *decoder = data->decoder;
- int ret;
+ enum mp3_action ret;
enum decoder_command cmd;
mp3_update_timer_next_frame(data);