aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/decoder/aac_plugin.c5
-rw-r--r--src/decoder/audiofile_plugin.c15
-rw-r--r--src/decoder/ffmpeg_plugin.c7
-rw-r--r--src/decoder/flac_plugin.c8
-rw-r--r--src/decoder/mp4_plugin.c9
-rw-r--r--src/decoder/mpc_plugin.c8
-rw-r--r--src/decoder/oggflac_plugin.c8
-rw-r--r--src/decoder/oggvorbis_plugin.c9
-rw-r--r--src/decoder/wavpack_plugin.c8
-rw-r--r--src/decoder_api.c1
10 files changed, 71 insertions, 7 deletions
diff --git a/src/decoder/aac_plugin.c b/src/decoder/aac_plugin.c
index d372ce5b1..19a7d7c9c 100644
--- a/src/decoder/aac_plugin.c
+++ b/src/decoder/aac_plugin.c
@@ -405,6 +405,11 @@ aac_stream_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
.sample_rate = sample_rate,
};
+ if (!audio_format_valid(&audio_format)) {
+ g_warning("aac: invalid audio format\n");
+ break;
+ }
+
decoder_initialized(mpd_decoder, &audio_format,
false, totalTime);
initialized = true;
diff --git a/src/decoder/audiofile_plugin.c b/src/decoder/audiofile_plugin.c
index 95ae37dd7..c862074b5 100644
--- a/src/decoder/audiofile_plugin.c
+++ b/src/decoder/audiofile_plugin.c
@@ -77,19 +77,20 @@ audiofile_decode(struct decoder *decoder, const char *path)
audio_format.channels =
(uint8_t)afGetVirtualChannels(af_fp, AF_DEFAULT_TRACK);
+ if (!audio_format_valid(&audio_format)) {
+ g_warning("Invalid audio format: %u:%u:%u\n",
+ audio_format.sample_rate, audio_format.bits,
+ audio_format.channels);
+ afCloseFile(af_fp);
+ return;
+ }
+
frame_count = afGetFrameCount(af_fp, AF_DEFAULT_TRACK);
total_time = ((float)frame_count / (float)audio_format.sample_rate);
bitRate = (uint16_t)(st.st_size * 8.0 / total_time / 1000.0 + 0.5);
- if (audio_format.bits != 8 && audio_format.bits != 16) {
- g_warning("Only 8 and 16-bit files are supported. %s is %i-bit\n",
- path, audio_format.bits);
- afCloseFile(af_fp);
- return;
- }
-
fs = (int)afGetVirtualFrameSize(af_fp, AF_DEFAULT_TRACK, 1);
decoder_initialized(decoder, &audio_format, true, total_time);
diff --git a/src/decoder/ffmpeg_plugin.c b/src/decoder/ffmpeg_plugin.c
index 1d98f8051..f9e40e2f5 100644
--- a/src/decoder/ffmpeg_plugin.c
+++ b/src/decoder/ffmpeg_plugin.c
@@ -255,6 +255,13 @@ ffmpeg_decode_internal(struct ffmpeg_context *ctx)
audio_format.sample_rate = (unsigned int)codec_context->sample_rate;
audio_format.channels = codec_context->channels;
+ if (!audio_format_valid(&audio_format)) {
+ g_warning("Invalid audio format: %u:%u:%u\n",
+ audio_format.sample_rate, audio_format.bits,
+ audio_format.channels);
+ return false;
+ }
+
//there is some problem with this on some demux (mp3 at least)
if (format_context->duration != (int)AV_NOPTS_VALUE) {
total_time = format_context->duration / AV_TIME_BASE;
diff --git a/src/decoder/flac_plugin.c b/src/decoder/flac_plugin.c
index 4767e35b0..09757f091 100644
--- a/src/decoder/flac_plugin.c
+++ b/src/decoder/flac_plugin.c
@@ -343,6 +343,14 @@ flac_decode_internal(struct decoder * decoder, struct input_stream *inStream,
goto fail;
}
+ if (!audio_format_valid(&data.audio_format)) {
+ g_warning("Invalid audio format: %u:%u:%u\n",
+ data.audio_format.sample_rate,
+ data.audio_format.bits,
+ data.audio_format.channels);
+ goto fail;
+ }
+
decoder_initialized(decoder, &data.audio_format,
inStream->seekable, data.total_time);
diff --git a/src/decoder/mp4_plugin.c b/src/decoder/mp4_plugin.c
index f97ffe50a..67d85ba0b 100644
--- a/src/decoder/mp4_plugin.c
+++ b/src/decoder/mp4_plugin.c
@@ -275,6 +275,15 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
scale = frame_info.samplerate;
#endif
audio_format.sample_rate = scale;
+
+ if (!audio_format_valid(&audio_format)) {
+ g_warning("Invalid audio format: %u:%u:%u\n",
+ audio_format.sample_rate,
+ audio_format.bits,
+ audio_format.channels);
+ break;
+ }
+
decoder_initialized(mpd_decoder, &audio_format,
input_stream->seekable,
total_time);
diff --git a/src/decoder/mpc_plugin.c b/src/decoder/mpc_plugin.c
index 4d5f0b8b3..da49425fa 100644
--- a/src/decoder/mpc_plugin.c
+++ b/src/decoder/mpc_plugin.c
@@ -155,6 +155,14 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
audio_format.channels = info.channels;
audio_format.sample_rate = info.sample_freq;
+ if (!audio_format_valid(&audio_format)) {
+ g_warning("Invalid audio format: %u:%u:%u\n",
+ audio_format.sample_rate,
+ audio_format.bits,
+ audio_format.channels);
+ return;
+ }
+
replayGainInfo = replay_gain_info_new();
replayGainInfo->tuples[REPLAY_GAIN_ALBUM].gain = info.gain_album * 0.01;
replayGainInfo->tuples[REPLAY_GAIN_ALBUM].peak = info.peak_album / 32767.0;
diff --git a/src/decoder/oggflac_plugin.c b/src/decoder/oggflac_plugin.c
index 637a611a3..782cd361b 100644
--- a/src/decoder/oggflac_plugin.c
+++ b/src/decoder/oggflac_plugin.c
@@ -294,6 +294,14 @@ oggflac_decode(struct decoder * mpd_decoder, struct input_stream *inStream)
goto fail;
}
+ if (!audio_format_valid(&data.audio_format)) {
+ g_warning("Invalid audio format: %u:%u:%u\n",
+ data.audio_format.sample_rate,
+ data.audio_format.bits,
+ data.audio_format.channels);
+ goto fail;
+ }
+
decoder_initialized(mpd_decoder, &data.audio_format,
inStream->seekable, data.total_time);
diff --git a/src/decoder/oggvorbis_plugin.c b/src/decoder/oggvorbis_plugin.c
index 539a8e092..3a5614fd0 100644
--- a/src/decoder/oggvorbis_plugin.c
+++ b/src/decoder/oggvorbis_plugin.c
@@ -288,6 +288,15 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
audio_format.channels = vi->channels;
audio_format.sample_rate = vi->rate;
+
+ if (!audio_format_valid(&audio_format)) {
+ g_warning("Invalid audio format: %u:%u:%u\n",
+ audio_format.sample_rate,
+ audio_format.bits,
+ audio_format.channels);
+ break;
+ }
+
if (!initialized) {
float total_time = ov_time_total(&vf, -1);
if (total_time < 0)
diff --git a/src/decoder/wavpack_plugin.c b/src/decoder/wavpack_plugin.c
index 377174e51..2dcc35102 100644
--- a/src/decoder/wavpack_plugin.c
+++ b/src/decoder/wavpack_plugin.c
@@ -148,6 +148,14 @@ wavpack_decode(struct decoder *decoder, WavpackContext *wpc, bool can_seek,
audio_format.bits = 24;
}
+ if (!audio_format_valid(&audio_format)) {
+ g_warning("Invalid audio format: %u:%u:%u\n",
+ audio_format.sample_rate,
+ audio_format.bits,
+ audio_format.channels);
+ return;
+ }
+
if ((WavpackGetMode(wpc) & MODE_FLOAT) == MODE_FLOAT) {
format_samples = format_samples_float;
} else {
diff --git a/src/decoder_api.c b/src/decoder_api.c
index a85a52e71..fd3990786 100644
--- a/src/decoder_api.c
+++ b/src/decoder_api.c
@@ -40,6 +40,7 @@ void decoder_initialized(struct decoder * decoder,
assert(!decoder->seeking);
assert(audio_format != NULL);
assert(audio_format_defined(audio_format));
+ assert(audio_format_valid(audio_format));
pcm_convert_init(&decoder->conv_state);