summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorritsuka <[email protected]>2009-08-30 11:50:00 +0000
committerritsuka <[email protected]>2009-08-30 11:50:00 +0000
commit959353ae4ae2259f387c202e6bb209495995d8cb (patch)
tree5e86e2150510d60eccb46bccc3d7b39442259268 /libhb
parent597cccbec64a40567337d81aed1797d389df2cc1 (diff)
Initialize the AudioConverter without a sample rate only if the first initialization fails.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2793 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/platform/macosx/encca_aac.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/libhb/platform/macosx/encca_aac.c b/libhb/platform/macosx/encca_aac.c
index 8c05ae3ef..5012104f1 100644
--- a/libhb/platform/macosx/encca_aac.c
+++ b/libhb/platform/macosx/encca_aac.c
@@ -29,6 +29,7 @@ struct hb_work_private_s
hb_list_t *list;
unsigned long isamples, isamplesiz, omaxpacket, nchannels;
uint64_t pts, ibytes;
+ Float64 osamplerate;
};
#define MP4ESDescrTag 0x03
@@ -122,6 +123,7 @@ int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job )
bzero( &output, sizeof( AudioStreamBasicDescription ) );
output.mFormatID = kAudioFormatMPEG4AAC;
+ output.mSampleRate = ( Float64 ) audio->config.out.samplerate;
output.mChannelsPerFrame = pv->nchannels;
// let CoreAudio decide the rest...
@@ -129,9 +131,19 @@ int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job )
err = AudioConverterNew( &input, &output, &pv->converter );
if( err != noErr)
{
- hb_log( "Error creating an AudioConverter err=%"PRId64" %"PRIu64, (int64_t)err, (uint64_t)output.mBytesPerFrame );
- *job->die = 1;
- return 0;
+ // Retry without the samplerate
+ bzero( &output, sizeof( AudioStreamBasicDescription ) );
+ output.mFormatID = kAudioFormatMPEG4AAC;
+ output.mChannelsPerFrame = pv->nchannels;
+
+ err = AudioConverterNew( &input, &output, &pv->converter );
+
+ if( err != noErr)
+ {
+ hb_log( "Error creating an AudioConverter err=%"PRId64" %"PRIu64, (int64_t)err, (uint64_t)output.mBytesPerFrame );
+ *job->die = 1;
+ return 0;
+ }
}
if( audio->config.out.mixdown == HB_AMIXDOWN_6CH && audio->config.in.codec == HB_ACODEC_AC3 )
@@ -183,8 +195,9 @@ int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job )
&tmpsiz, &output );
// set sizes
- pv->isamplesiz = input.mBytesPerPacket;
- pv->isamples = output.mFramesPerPacket;
+ pv->isamplesiz = input.mBytesPerPacket;
+ pv->isamples = output.mFramesPerPacket;
+ pv->osamplerate = output.mSampleRate;
// get maximum output size
AudioConverterGetProperty( pv->converter,
@@ -298,7 +311,7 @@ static hb_buffer_t * Encode( hb_work_object_t * w )
return NULL;
obuf->start = pv->pts;
- pv->pts += 90000LL * pv->isamples / w->audio->config.out.samplerate;
+ pv->pts += 90000LL * pv->isamples / pv->osamplerate;
obuf->stop = pv->pts;
obuf->size = odesc.mDataByteSize;
obuf->frametype = HB_FRAME_AUDIO;