Commit 64a0715b authored by Michael Feurstein's avatar Michael Feurstein Committed by Felix Paul Kühne

qtsound: bug fixes

fix for selecting the device with the correct UID
GUI and qtsound now both reference the correct UID
Signed-off-by: default avatarFelix Paul Kühne <fkuehne@videolan.org>
(cherry picked from commit fd75aab3d6670f7404e1c3e741a87587481472f4)
parent 384feaeb
...@@ -74,6 +74,7 @@ vlc_module_end () ...@@ -74,6 +74,7 @@ vlc_module_end ()
{ {
demux_t *p_qtsound; demux_t *p_qtsound;
AudioBuffer *currentAudioBuffer; AudioBuffer *currentAudioBuffer;
block_t *rawAudioData;
UInt32 numberOfSamples; UInt32 numberOfSamples;
date_t date; date_t date;
mtime_t currentPts; mtime_t currentPts;
...@@ -82,6 +83,7 @@ vlc_module_end () ...@@ -82,6 +83,7 @@ vlc_module_end ()
- (id)initWithDemux:(demux_t *)p_demux; - (id)initWithDemux:(demux_t *)p_demux;
- (void)outputAudioSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection; - (void)outputAudioSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection;
- (BOOL)checkCurrentAudioBuffer; - (BOOL)checkCurrentAudioBuffer;
- (void)freeAudioMem;
- (mtime_t)getCurrentPts; - (mtime_t)getCurrentPts;
- (void *)getCurrentAudioBufferData; - (void *)getCurrentAudioBufferData;
- (UInt32)getCurrentTotalDataSize; - (UInt32)getCurrentTotalDataSize;
...@@ -105,18 +107,12 @@ vlc_module_end () ...@@ -105,18 +107,12 @@ vlc_module_end ()
} }
- (void)dealloc - (void)dealloc
{ {
@synchronized (self)
{
free(currentAudioBuffer);
currentAudioBuffer = nil;
}
[super dealloc]; [super dealloc];
} }
- (void)outputAudioSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection - (void)outputAudioSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection
{ {
AudioBufferList *tempAudioBufferList; AudioBufferList *tempAudioBufferList;
block_t *rawAudioData;
UInt32 totalDataSize = 0; UInt32 totalDataSize = 0;
UInt32 count = 0; UInt32 count = 0;
...@@ -190,7 +186,6 @@ vlc_module_end () ...@@ -190,7 +186,6 @@ vlc_module_end ()
currentAudioBuffer->mDataByteSize = totalDataSize; currentAudioBuffer->mDataByteSize = totalDataSize;
currentAudioBuffer->mData = rawAudioData; currentAudioBuffer->mData = rawAudioData;
} }
free(rawAudioData);
} }
} }
...@@ -199,6 +194,16 @@ vlc_module_end () ...@@ -199,6 +194,16 @@ vlc_module_end ()
return (currentAudioBuffer) ? 1 : 0; return (currentAudioBuffer) ? 1 : 0;
} }
- (void)freeAudioMem
{
@synchronized (self)
{
if (rawAudioData) {
free(rawAudioData);
}
}
}
- (mtime_t)getCurrentPts - (mtime_t)getCurrentPts
{ {
/* FIXME: can this getter be minimized? */ /* FIXME: can this getter be minimized? */
...@@ -293,7 +298,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -293,7 +298,7 @@ static int Open( vlc_object_t *p_this )
QTCaptureDevice *qtk_audioDevice; QTCaptureDevice *qtk_audioDevice;
qtk_audioDevice = [myAudioDevices objectAtIndex:iaudio]; qtk_audioDevice = [myAudioDevices objectAtIndex:iaudio];
msg_Dbg( p_demux, "qtsound audio %u/%lu localizedDisplayName: %s uniqueID: %s", iaudio, [myAudioDevices count], [[qtk_audioDevice localizedDisplayName] UTF8String], [[qtk_audioDevice uniqueID] UTF8String]); msg_Dbg( p_demux, "qtsound audio %u/%lu localizedDisplayName: %s uniqueID: %s", iaudio, [myAudioDevices count], [[qtk_audioDevice localizedDisplayName] UTF8String], [[qtk_audioDevice uniqueID] UTF8String]);
if([[[qtk_audioDevice localizedDisplayName]stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtk_curraudiodevice_uid]){ if([[[qtk_audioDevice uniqueID]stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtk_curraudiodevice_uid]){
msg_Dbg( p_demux, "Device found" ); msg_Dbg( p_demux, "Device found" );
break; break;
} }
...@@ -545,8 +550,6 @@ static int Demux( demux_t *p_demux ) ...@@ -545,8 +550,6 @@ static int Demux( demux_t *p_demux )
return 0; return 0;
} }
pool = [[NSAutoreleasePool alloc] init];
@synchronized (p_sys->audiooutput) @synchronized (p_sys->audiooutput)
{ {
if ( [p_sys->audiooutput checkCurrentAudioBuffer] ) if ( [p_sys->audiooutput checkCurrentAudioBuffer] )
...@@ -562,19 +565,28 @@ static int Demux( demux_t *p_demux ) ...@@ -562,19 +565,28 @@ static int Demux( demux_t *p_demux )
{ {
// Nothing to transfer yet, just forget // Nothing to transfer yet, just forget
block_Release( p_blocka ); block_Release( p_blocka );
[pool release];
msleep( 10000 ); msleep( 10000 );
return 1; return 1;
} }
[pool release];
if( p_blocka ) if( p_blocka )
{ {
es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_blocka->i_pts ); es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_blocka->i_pts );
es_out_Send( p_demux->out, p_sys->p_es_audio, p_blocka ); es_out_Send( p_demux->out, p_sys->p_es_audio, p_blocka );
} }
@synchronized (p_sys->audiooutput)
{
/*
* Free Memory
*
* Wait before freeing memory, so we don't get no crackling sound
* crackling sound artefacts start at 100 ms and below
*/
msleep( 200 );
[p_sys->audiooutput freeAudioMem];
}
return 1; return 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment