ref: 3dbf360ea76223dc53385368441eb9685badf150
parent: 2750dae23aa7753b3e9cd9a54813fb9b59057b1c
author: menno <menno>
date: Sat Jun 7 07:06:38 EDT 2003
small updates in error handling
--- a/frontend/main.c
+++ b/frontend/main.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: main.c,v 1.31 2003/05/07 18:30:49 menno Exp $
+** $Id: main.c,v 1.32 2003/06/07 11:06:37 menno Exp $
**/
#ifdef _WIN32
@@ -296,9 +296,9 @@
/* find AAC track */
unsigned short i;
int rc;
- int numTracks = MP4GetNumberOfTracks(infile, NULL, /* subType */ 0);
+ int numTracks = MP4GetNumberOfTracks(infile, NULL, /* subType */ 0);
- for (i = 0; i < numTracks; i++)
+ for (i = 0; i < numTracks; i++)
{
MP4TrackId trackId = MP4FindTrackId(infile, i, NULL, /* subType */ 0);
const char* trackType = MP4GetTrackType(infile, trackId);
@@ -364,13 +364,13 @@
config->outputFormat = outputFormat;
faacDecSetConfiguration(hDecoder, config);
- infile = MP4Read(mp4file, 0);
- if (!infile)
+ infile = MP4Read(mp4file, 0);
+ if (!infile)
{
/* unable to open file */
fprintf(stderr, "Error opening file: %s\n", mp4file);
return 1;
- }
+ }
if ((track = GetAACTrack(infile)) < 0)
{
@@ -396,23 +396,23 @@
numSamples = MP4GetTrackNumberOfSamples(infile, track);
- for (sampleId = 1; sampleId <= numSamples; sampleId++)
+ for (sampleId = 1; sampleId <= numSamples; sampleId++)
{
int rc;
/* get acces unit from MP4 file */
- buffer = NULL;
- buffer_size = 0;
+ buffer = NULL;
+ buffer_size = 0;
- rc = MP4ReadSample(infile, track, sampleId, &buffer, &buffer_size,
+ rc = MP4ReadSample(infile, track, sampleId, &buffer, &buffer_size,
NULL, NULL, NULL, NULL);
- if (rc == 0)
+ if (rc == 0)
{
- fprintf(stderr, "Reading from MP4 file failed.\n");
+ fprintf(stderr, "Reading from MP4 file failed.\n");
faacDecClose(hDecoder);
MP4Close(infile);
return 1;
- }
+ }
sample_buffer = faacDecDecode(hDecoder, &frameInfo, buffer, buffer_size);
@@ -459,9 +459,8 @@
if (frameInfo.error > 0)
{
- fprintf(stderr, "Error: %s\n",
+ fprintf(stderr, "Warning: %s\n",
faacDecGetErrorMessage(frameInfo.error));
- break;
}
}
--- a/plugins/foo_mp4/foo_mp4.cpp
+++ b/plugins/foo_mp4/foo_mp4.cpp
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: foo_mp4.cpp,v 1.31 2003/05/29 19:56:49 menno Exp $
+** $Id: foo_mp4.cpp,v 1.32 2003/06/07 11:06:38 menno Exp $
**/
#include <mp4.h>
@@ -35,7 +35,7 @@
}
DECLARE_COMPONENT_VERSION ("MPEG-4 AAC decoder",
- STRIP_REVISION("$Revision: 1.31 $"),
+ STRIP_REVISION("$Revision: 1.32 $"),
"Based on FAAD2 v" FAAD2_VERSION "\nCopyright (C) 2002-2003 http://www.audiocoding.com" );
class input_mp4 : public input
@@ -173,15 +173,19 @@
} while ((frameInfo.error == 0) && (frameInfo.samples == 0));
- if (frameInfo.error || (sampleId > numSamples))
+ if (frameInfo.error)
{
- if (frameInfo.error)
- console::error(faacDecGetErrorMessage(frameInfo.error), "foo_mp4");
- return 0;
+ console::warning(faacDecGetErrorMessage(frameInfo.error), "foo_mp4");
+ console::warning("Skipping frame", "foo_mp4");
}
+ if (sampleId > numSamples)
+ return 0;
chunk->data = (audio_sample*)sample_buffer;
- chunk->samples = frameInfo.samples/frameInfo.channels;
+ if (frameInfo.channels == 0)
+ chunk->samples = 0;
+ else
+ chunk->samples = frameInfo.samples/frameInfo.channels;
chunk->nch = frameInfo.channels;
chunk->srate = frameInfo.samplerate;