Commit b620bade authored by Felix Paul Kühne's avatar Felix Paul Kühne

audioqueue: fix potential p_block leak

parent d71133ac
/***************************************************************************** /*****************************************************************************
* audioqueue.c : AudioQueue audio output plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2013 VLC authors and VideoLAN * Copyright (C) 2000-2013 VLC authors and VideoLAN
* $Id$ * $Id$
* *
...@@ -29,12 +27,10 @@ ...@@ -29,12 +27,10 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# import "config.h" # import "config.h"
#endif #endif
#import <vlc_common.h> #import <vlc_common.h>
#import <vlc_plugin.h> #import <vlc_plugin.h>
#import <vlc_aout.h> #import <vlc_aout.h>
#import <AudioToolBox/AudioQueue.h> #import <AudioToolBox/AudioQueue.h>
#pragma mark - #pragma mark -
#pragma mark private declarations #pragma mark private declarations
...@@ -47,7 +43,6 @@ struct aout_sys_t ...@@ -47,7 +43,6 @@ struct aout_sys_t
int i_rate; int i_rate;
float f_volume; float f_volume;
}; };
static int Open (vlc_object_t *); static int Open (vlc_object_t *);
static void Close (vlc_object_t *); static void Close (vlc_object_t *);
static void Play (audio_output_t *, block_t *); static void Play (audio_output_t *, block_t *);
...@@ -55,11 +50,9 @@ static void Pause (audio_output_t *p_aout, bool pause, mtime_ ...@@ -55,11 +50,9 @@ static void Pause (audio_output_t *p_aout, bool pause, mtime_
static void Flush (audio_output_t *p_aout, bool wait); static void Flush (audio_output_t *p_aout, bool wait);
static int TimeGet (audio_output_t *aout, mtime_t *); static int TimeGet (audio_output_t *aout, mtime_t *);
static void UnusedAudioQueueCallback (void *, AudioQueueRef, AudioQueueBufferRef); static void UnusedAudioQueueCallback (void *, AudioQueueRef, AudioQueueBufferRef);
static int Start(audio_output_t *, audio_sample_format_t *); static int Start(audio_output_t *, audio_sample_format_t *);
static void Stop(audio_output_t *); static void Stop(audio_output_t *);
static int VolumeSet(audio_output_t *, float ); static int VolumeSet(audio_output_t *, float );
vlc_module_begin () vlc_module_begin ()
set_shortname("AudioQueue") set_shortname("AudioQueue")
set_description(N_("AudioQueue (iOS / Mac OS) audio output")) set_description(N_("AudioQueue (iOS / Mac OS) audio output"))
...@@ -69,7 +62,6 @@ set_subcategory(SUBCAT_AUDIO_AOUT) ...@@ -69,7 +62,6 @@ set_subcategory(SUBCAT_AUDIO_AOUT)
add_shortcut("audioqueue") add_shortcut("audioqueue")
set_callbacks(Open, Close) set_callbacks(Open, Close)
vlc_module_end () vlc_module_end ()
#pragma mark - #pragma mark -
#pragma mark initialization #pragma mark initialization
...@@ -139,7 +131,6 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt) ...@@ -139,7 +131,6 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
kCFRunLoopCommonModes, // RunLoop mode kCFRunLoopCommonModes, // RunLoop mode
0, // Flags ; must be zero (per documentation)... 0, // Flags ; must be zero (per documentation)...
&(p_sys->audioQueueRef)); // Output &(p_sys->audioQueueRef)); // Output
msg_Dbg(p_aout, "New AudioQueue instance created (status = %li)", error); msg_Dbg(p_aout, "New AudioQueue instance created (status = %li)", error);
if (error != noErr) if (error != noErr)
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -147,7 +138,6 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt) ...@@ -147,7 +138,6 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
fmt->i_format = VLC_CODEC_FL32; fmt->i_format = VLC_CODEC_FL32;
fmt->i_physical_channels = AOUT_CHANS_STEREO; fmt->i_physical_channels = AOUT_CHANS_STEREO;
aout_FormatPrepare(fmt); aout_FormatPrepare(fmt);
p_aout->sys->i_rate = fmt->i_rate; p_aout->sys->i_rate = fmt->i_rate;
// start queue // start queue
...@@ -157,7 +147,6 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt) ...@@ -157,7 +147,6 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
// start timeline for synchro // start timeline for synchro
error = AudioQueueCreateTimeline(p_sys->audioQueueRef, &p_sys->timelineRef); error = AudioQueueCreateTimeline(p_sys->audioQueueRef, &p_sys->timelineRef);
msg_Dbg(p_aout, "AudioQueue Timeline started (status = %li)", error); msg_Dbg(p_aout, "AudioQueue Timeline started (status = %li)", error);
if (error != noErr) if (error != noErr)
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -172,11 +161,9 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt) ...@@ -172,11 +161,9 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
static void Stop(audio_output_t *p_aout) static void Stop(audio_output_t *p_aout)
{ {
p_aout->sys->i_played_length = 0; p_aout->sys->i_played_length = 0;
AudioQueueDisposeTimeline(p_aout->sys->audioQueueRef, p_aout->sys->timelineRef); AudioQueueDisposeTimeline(p_aout->sys->audioQueueRef, p_aout->sys->timelineRef);
AudioQueueStop(p_aout->sys->audioQueueRef, true); AudioQueueStop(p_aout->sys->audioQueueRef, true);
AudioQueueDispose(p_aout->sys->audioQueueRef, true); AudioQueueDispose(p_aout->sys->audioQueueRef, true);
msg_Dbg(p_aout, "audioqueue stopped and disposed"); msg_Dbg(p_aout, "audioqueue stopped and disposed");
} }
...@@ -189,11 +176,7 @@ static void Play(audio_output_t *p_aout, block_t *p_block) ...@@ -189,11 +176,7 @@ static void Play(audio_output_t *p_aout, block_t *p_block)
OSStatus status; OSStatus status;
status = AudioQueueAllocateBuffer(p_aout->sys->audioQueueRef, p_block->i_buffer, &inBuffer); status = AudioQueueAllocateBuffer(p_aout->sys->audioQueueRef, p_block->i_buffer, &inBuffer);
if (status != noErr) { if (status == noErr) {
msg_Err(p_aout, "buffer alloction failed (%li)", status);
return;
}
memcpy(inBuffer->mAudioData, p_block->p_buffer, p_block->i_buffer); memcpy(inBuffer->mAudioData, p_block->p_buffer, p_block->i_buffer);
inBuffer->mAudioDataByteSize = p_block->i_buffer; inBuffer->mAudioDataByteSize = p_block->i_buffer;
...@@ -202,6 +185,8 @@ static void Play(audio_output_t *p_aout, block_t *p_block) ...@@ -202,6 +185,8 @@ static void Play(audio_output_t *p_aout, block_t *p_block)
p_aout->sys->i_played_length += p_block->i_length; p_aout->sys->i_played_length += p_block->i_length;
else else
msg_Err(p_aout, "enqueuing buffer failed (%li)", status); msg_Err(p_aout, "enqueuing buffer failed (%li)", status);
} else
msg_Err(p_aout, "buffer alloction failed (%li)", status);
block_Release(p_block); block_Release(p_block);
} }
......
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