<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hi,</div><div><br></div><div>thx for the fast feedback. Just some questions concerning your points, as I'm not too familiar with parts of them.</div><div><br><blockquote type="cite"><div><blockquote type="cite">+ VLC_ADD_LIBS([qtsound], [-Wl,-framework,CoreAudio])<br></blockquote><blockquote type="cite">+ VLC_ADD_PLUGIN([qtsound])<br></blockquote><blockquote type="cite">fi<br></blockquote><br>There is not much point in cluttering configure with constant values. You<br>might as well pass them as _LIBADD or _LDFLAGS in the Makefile<br>(Modules.am).</div></blockquote><br></div><div>Ok. I'll look into that. I have no idea what the best practices are here, I'll try to find other examples in the src.</div><div><br></div><div><blockquote type="cite"><div>!=<br><blockquote type="cite">"no" &&<br></blockquote><blockquote type="cite">+ (test "${SYS}" = "darwin" || test "${enable_macosx_vlc_app}" =<br></blockquote>"yes")<br><blockquote type="cite">])<br></blockquote><blockquote type="cite">+<br></blockquote><br>This does not belong in this patch or I missed something.</div></blockquote><br></div><div>Yep, sorry for that, Jean-Baptiste Kempf already just highlighted this to me. Is fixed with next submission of patch. I mixed stuff up there; this shouldn't belong here or even come from my side.</div><div><br></div><div><blockquote type="cite"><div><blockquote type="cite">+ QTCaptureDevice * audiodevice;<br></blockquote><blockquote type="cite">+ VLCDecompressedAudioOutput * audiooutput;<br></blockquote><blockquote type="cite">+ block_t *p_block_audio;<br></blockquote><br>p_block_audio does not seem to be used anywhere</div></blockquote><br></div><div>Thx. removed.</div><div><br></div><div><blockquote type="cite"><div><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ /* Hack: if libvlc was killed, main interface thread was,<br></blockquote><blockquote type="cite">+ * and poor QTKit needs it, so don't tell him.<br></blockquote><blockquote type="cite">+ * Else we dead lock. */<br></blockquote><blockquote type="cite">+ if( vlc_object_alive(p_this->p_libvlc))<br></blockquote><br>No matter why you feel like you need to check the legacy b_die bit, it<br>certainly does not do whatever you wish it did.</div></blockquote><br></div><div>I just reused these elements from the qtcapture module so I'm not sure what the original intention was here. When compiling it tells me that vlc_object_alive is deprecated. Is there a replacement. I'll see if I can remove/replace this.</div><div><br></div><div><blockquote type="cite"><div><blockquote type="cite">+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ @synchronized (p_sys->audiooutput)<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ p_blocka->i_pts = [p_sys->audiooutput<br></blockquote><blockquote type="cite">copyCurrentAudioBytesToBuffer: p_blocka->p_buffer];<br></blockquote><br>It seems to me that you are copying the data twice.<br><br>There should be no need to copy blocks data at all since deinterleaving<br>does it on the fly.</div></blockquote><br></div><div>Yes I am copying twice. First I'm making use of the delegate method provided by QTKit which gets called automatically as soon as the QTCaptureSession is started (which happens in Open() -> <span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">[p_sys->session startRunning];</span>). From the delegate method I write to currentAudioBuffer which is then accessed by <span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">- (mtime_t)copyCurrentAudioBytesToBuffer:(</span><span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; "><span style="color: #bc319c">void</span></span><span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; "> *)buffer</span> into the given buffer. The concept is the same as in qtcapture module.</div><div><br></div><div>If I understand correctly I should eliminate this second step <span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">copyCurrentAudioBytesToBuffer </span>and directly access the currentAudioBuffer?</div><div><br></div><div>I'll look into that.</div><div><br></div><div><blockquote type="cite"><div><blockquote type="cite">+ case DEMUX_GET_PTS_DELAY:<br></blockquote><blockquote type="cite">+ pi64 = (int64_t*)va_arg( args, int64_t * );<br></blockquote><blockquote type="cite">+ *pi64 = (int64_t)DEFAULT_PTS_DELAY;<br></blockquote><blockquote type="cite">+ return VLC_SUCCESS;<br></blockquote><br>Should probably be live-caching value.</div></blockquote><br></div><div>This part is also reused from qtcapture. What exactly do I have to set here to a live-caching value?</div><div><br></div><div>Best Regards</div><div>Michael Feurstein</div><div><br></div><br><div><div>On Oct 5, 2011, at 3:11 PM, Rémi Denis-Courmont wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On Wed, 5 Oct 2011 14:10:07 +0200, Michael Feurstein<br><<a href="mailto:michael.feurstein@gmail.com">michael.feurstein@gmail.com</a>> wrote:<br><blockquote type="cite">Tested with Built-in Input, Built-in Microphone and Griffin iMic USB<br></blockquote>system<br><blockquote type="cite">Usage: qtsound://"Built-In Input" or qtsound://"iMic USB audio system"<br></blockquote><blockquote type="cite">---<br></blockquote><blockquote type="cite"> configure.ac | 30 ++-<br></blockquote><blockquote type="cite"> modules/access/Modules.am | 1 +<br></blockquote><blockquote type="cite"> modules/access/qtsound.m | 562<br></blockquote><blockquote type="cite"> +++++++++++++++++++++++++++++++++++++++++++++<br></blockquote><blockquote type="cite"> 3 files changed, 587 insertions(+), 6 deletions(-)<br></blockquote><blockquote type="cite"> create mode 100644 modules/access/qtsound.m<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">diff --git a/configure.ac b/configure.ac<br></blockquote><blockquote type="cite">index 02d7c72..a4e43be 100644<br></blockquote><blockquote type="cite">--- a/configure.ac<br></blockquote><blockquote type="cite">+++ b/configure.ac<br></blockquote><blockquote type="cite">@@ -2124,11 +2124,11 @@ then<br></blockquote><blockquote type="cite"> fi<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> dnl<br></blockquote><blockquote type="cite">-dnl QTCapture<br></blockquote><blockquote type="cite">-AC_ARG_ENABLE(macosx-qtcapture,<br></blockquote><blockquote type="cite">- [ --enable-macosx-qtcapture Mac OS X qtcapture (iSight) module<br></blockquote><blockquote type="cite">(default enabled on Mac OS X)])<br></blockquote><blockquote type="cite">-if test "x${enable_macosx_qtcapture}" != "xno" &&<br></blockquote><blockquote type="cite">- (test "${SYS}" = "darwin" || test "${enable_macosx_qtcapture}" =<br></blockquote>"yes")<br><blockquote type="cite">+dnl QTKit<br></blockquote><blockquote type="cite">+AC_ARG_ENABLE(macosx-qtkit,<br></blockquote><blockquote type="cite">+ [ --enable-macosx-qtkit Mac OS X qtkit framework for video and audio<br></blockquote><blockquote type="cite">(default enabled on Mac OS X)])<br></blockquote><blockquote type="cite">+if test "x${enable_macosx_qtkit}" != "xno" &&<br></blockquote><blockquote type="cite">+ (test "${SYS}" = "darwin" || test "${enable_macosx_qtkit}" = "yes")<br></blockquote><blockquote type="cite"> then<br></blockquote><blockquote type="cite"> VLC_ADD_LIBS([qtcapture], [-Wl,-framework,Cocoa])<br></blockquote><blockquote type="cite"> VLC_ADD_LIBS([qtcapture], [-Wl,-framework,QTKit])<br></blockquote><blockquote type="cite">@@ -2136,9 +2136,12 @@ then<br></blockquote><blockquote type="cite"> VLC_ADD_LIBS([qtcapture], [-Wl,-framework,QuartzCore])<br></blockquote><blockquote type="cite"> VLC_ADD_LIBS([qtcapture], [-Wl,-framework,CoreVideo])<br></blockquote><blockquote type="cite"> VLC_ADD_PLUGIN([qtcapture])<br></blockquote><blockquote type="cite">+ VLC_ADD_LIBS([qtsound], [-Wl,-framework,Cocoa])<br></blockquote><blockquote type="cite">+ VLC_ADD_LIBS([qtsound], [-Wl,-framework,QTKit])<br></blockquote><blockquote type="cite">+ VLC_ADD_LIBS([qtsound], [-Wl,-framework,CoreAudio])<br></blockquote><blockquote type="cite">+ VLC_ADD_PLUGIN([qtsound])<br></blockquote><blockquote type="cite"> fi<br></blockquote><br>There is not much point in cluttering configure with constant values. You<br>might as well pass them as _LIBADD or _LDFLAGS in the Makefile<br>(Modules.am).<br><br><blockquote type="cite"><br></blockquote><blockquote type="cite">-<br></blockquote><blockquote type="cite"> dnl<br></blockquote><blockquote type="cite"> dnl Demux plugins<br></blockquote><blockquote type="cite"> dnl<br></blockquote><blockquote type="cite">@@ -3766,6 +3769,21 @@ then<br></blockquote><blockquote type="cite"> VLC_ADD_PLUGIN([macosx_dialog_provider])<br></blockquote><blockquote type="cite"> fi<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+AC_ARG_ENABLE(macosx-eyetv,<br></blockquote><blockquote type="cite">+ [ --enable-macosx-eyetv Mac OS X EyeTV (TNT Tuner) module (default<br></blockquote><blockquote type="cite">enabled on Mac OS X)])<br></blockquote><blockquote type="cite">+if test "x${enable_macosx_eyetv}" != "xno" &&<br></blockquote><blockquote type="cite">+ (test "${SYS}" = "darwin" || test "${enable_macosx_eyetv}" = "yes")<br></blockquote><blockquote type="cite">+then<br></blockquote><blockquote type="cite">+ VLC_ADD_LIBS([access_eyetv], [-Wl,-framework,Foundation])<br></blockquote><blockquote type="cite">+ VLC_ADD_PLUGIN([access_eyetv])<br></blockquote><blockquote type="cite">+fi<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+AC_ARG_ENABLE(macosx-vlc-app,<br></blockquote><blockquote type="cite">+ [ --enable-macosx-vlc-app build the VLC media player (default<br></blockquote>enabled<br><blockquote type="cite">on Mac OS X)])<br></blockquote><blockquote type="cite">+AM_CONDITIONAL(BUILD_MACOSX_VLC_APP, [test "${enable_macosx_vlc_app}"<br></blockquote>!=<br><blockquote type="cite">"no" &&<br></blockquote><blockquote type="cite">+ (test "${SYS}" = "darwin" || test "${enable_macosx_vlc_app}" =<br></blockquote>"yes")<br><blockquote type="cite">])<br></blockquote><blockquote type="cite">+<br></blockquote><br>This does not belong in this patch or I missed something.<br><br><blockquote type="cite"> dnl<br></blockquote><blockquote type="cite"> dnl ncurses module<br></blockquote><blockquote type="cite"> dnl<br></blockquote><blockquote type="cite">diff --git a/modules/access/Modules.am b/modules/access/Modules.am<br></blockquote><blockquote type="cite">index 8b4d22d..b81b2dc 100644<br></blockquote><blockquote type="cite">--- a/modules/access/Modules.am<br></blockquote><blockquote type="cite">+++ b/modules/access/Modules.am<br></blockquote><blockquote type="cite">@@ -56,6 +56,7 @@ SOURCES_dvdread = dvdread.c<br></blockquote><blockquote type="cite"> SOURCES_dc1394 = dc1394.c<br></blockquote><blockquote type="cite"> SOURCES_pvr = pvr.c<br></blockquote><blockquote type="cite"> SOURCES_qtcapture = qtcapture.m<br></blockquote><blockquote type="cite">+SOURCES_qtsound = qtsound.m<br></blockquote><blockquote type="cite"> SOURCES_linsys_sdi = linsys/linsys_sdi.c linsys/linsys_sdi.h<br></blockquote><blockquote type="cite"> SOURCES_linsys_hdsdi = \<br></blockquote><blockquote type="cite"> linsys/linsys_hdsdi.c \<br></blockquote><blockquote type="cite">diff --git a/modules/access/qtsound.m b/modules/access/qtsound.m<br></blockquote><blockquote type="cite">new file mode 100644<br></blockquote><blockquote type="cite">index 0000000..d29c21c<br></blockquote><blockquote type="cite">--- /dev/null<br></blockquote><blockquote type="cite">+++ b/modules/access/qtsound.m<br></blockquote><blockquote type="cite">@@ -0,0 +1,562 @@<br></blockquote><blockquote type="cite"><br></blockquote>+/*****************************************************************************<br><blockquote type="cite">+* qtsound.m: qtkit (Mac OS X) based audio capture module<br></blockquote><blockquote type="cite"><br></blockquote>+*****************************************************************************<br><blockquote type="cite">+* Copyright (C) 2011 the VideoLAN team<br></blockquote><blockquote type="cite">+*<br></blockquote><blockquote type="cite">+* Authors: Pierre d'Herbemont <<a href="mailto:pdherbemont@videolan.org">pdherbemont@videolan.org</a>><br></blockquote><blockquote type="cite">+* Gustaf Neumann <<a href="mailto:neumann@wu.ac.at">neumann@wu.ac.at</a>><br></blockquote><blockquote type="cite">+* Michael Feurstein <<a href="mailto:michael.feurstein@wu.ac.at">michael.feurstein@wu.ac.at</a>><br></blockquote><blockquote type="cite">+*<br></blockquote><blockquote type="cite"><br></blockquote>+*****************************************************************************<br><blockquote type="cite">+* This library is free software; you can redistribute it and/or<br></blockquote><blockquote type="cite">+* modify it under the terms of the GNU Lesser General Public License<br></blockquote><blockquote type="cite">+* as published by the Free Software Foundation; either version 2.1<br></blockquote><blockquote type="cite">+* of the License, or (at your option) any later version.<br></blockquote><blockquote type="cite">+*<br></blockquote><blockquote type="cite">+* This library is distributed in the hope that it will be useful,<br></blockquote><blockquote type="cite">+* but WITHOUT ANY WARRANTY; without even the implied warranty of<br></blockquote><blockquote type="cite">+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU<br></blockquote><blockquote type="cite">+* Lesser General Public License for more details.<br></blockquote><blockquote type="cite">+*<br></blockquote><blockquote type="cite">+* You should have received a copy of the GNU Lesser General Public<br></blockquote><blockquote type="cite">+* License along with this library; if not, write to the Free Software<br></blockquote><blockquote type="cite">+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA<br></blockquote><blockquote type="cite">+*<br></blockquote><blockquote type="cite"><br></blockquote>+*****************************************************************************/<br><blockquote type="cite">+<br></blockquote><blockquote type="cite"><br></blockquote>+/*****************************************************************************<br><blockquote type="cite">+ * Preamble<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite"><br></blockquote>*****************************************************************************/<br><blockquote type="cite">+<br></blockquote><blockquote type="cite">+#ifdef HAVE_CONFIG_H<br></blockquote><blockquote type="cite">+# include "config.h"<br></blockquote><blockquote type="cite">+#endif<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+#include <vlc_common.h><br></blockquote><blockquote type="cite">+#include <vlc_plugin.h><br></blockquote><blockquote type="cite">+#include <vlc_aout.h><br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+#include <vlc_demux.h><br></blockquote><blockquote type="cite">+#include <vlc_dialog.h><br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+#import <QTKit/QTKit.h><br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite"><br></blockquote>+/*****************************************************************************<br><blockquote type="cite">+ * Local prototypes.<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite"><br></blockquote>*****************************************************************************/<br><blockquote type="cite">+static int Open( vlc_object_t *p_this );<br></blockquote><blockquote type="cite">+static void Close( vlc_object_t *p_this );<br></blockquote><blockquote type="cite">+static int Demux( demux_t *p_demux );<br></blockquote><blockquote type="cite">+static int Control( demux_t *, int, va_list );<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite"><br></blockquote>+/*****************************************************************************<br><blockquote type="cite">+ * Module descriptor<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite"><br></blockquote>*****************************************************************************/<br><blockquote type="cite">+<br></blockquote><blockquote type="cite">+vlc_module_begin()<br></blockquote><blockquote type="cite">+set_shortname( N_("QTSound") )<br></blockquote><blockquote type="cite">+set_description( N_("Quicktime Sound Capture") )<br></blockquote><blockquote type="cite">+set_category( CAT_INPUT )<br></blockquote><blockquote type="cite">+set_subcategory( SUBCAT_INPUT_ACCESS )<br></blockquote><blockquote type="cite">+add_shortcut( "qtsound" )<br></blockquote><blockquote type="cite">+set_capability( "access_demux", 0 )<br></blockquote><blockquote type="cite">+set_callbacks( Open, Close )<br></blockquote><blockquote type="cite">+vlc_module_end ()<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite"><br></blockquote>+/*****************************************************************************<br><blockquote type="cite">+ * QTKit Bridge<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite"><br></blockquote>*****************************************************************************/<br><blockquote type="cite">+@interface VLCDecompressedAudioOutput :<br></blockquote>QTCaptureDecompressedAudioOutput<br><blockquote type="cite">+{<br></blockquote><blockquote type="cite">+ AudioBuffer *currentAudioBuffer;<br></blockquote><blockquote type="cite">+ int lenghtForAllSamples, numberOfSamples;<br></blockquote><blockquote type="cite">+ date_t date;<br></blockquote><blockquote type="cite">+ mtime_t currentPts;<br></blockquote><blockquote type="cite">+ mtime_t previousPts;<br></blockquote><blockquote type="cite">+}<br></blockquote><blockquote type="cite">+- (id)init;<br></blockquote><blockquote type="cite">+- (void)outputAudioSampleBuffer:(QTSampleBuffer *)sampleBuffer<br></blockquote><blockquote type="cite">fromConnection:(QTCaptureConnection *)connection;<br></blockquote><blockquote type="cite">+- (mtime_t)copyCurrentAudioBytesToBuffer:(void *)buffer;<br></blockquote><blockquote type="cite">+@end<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+@implementation VLCDecompressedAudioOutput :<br></blockquote><blockquote type="cite">QTCaptureDecompressedAudioOutput<br></blockquote><blockquote type="cite">+- (id)init<br></blockquote><blockquote type="cite">+{<br></blockquote><blockquote type="cite">+ if( self = [super init] )<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ currentAudioBuffer = nil;<br></blockquote><blockquote type="cite">+ date_Init(&date, 44100, 1);<br></blockquote><blockquote type="cite">+ date_Set(&date,0);<br></blockquote><blockquote type="cite">+ currentPts = 0;<br></blockquote><blockquote type="cite">+ previousPts = 0;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+ return self;<br></blockquote><blockquote type="cite">+}<br></blockquote><blockquote type="cite">+- (void)dealloc<br></blockquote><blockquote type="cite">+{<br></blockquote><blockquote type="cite">+ @synchronized (self)<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ free(currentAudioBuffer);<br></blockquote><blockquote type="cite">+ currentAudioBuffer = nil;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+ [super dealloc];<br></blockquote><blockquote type="cite">+}<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+- (void)outputAudioSampleBuffer:(QTSampleBuffer *)sampleBuffer<br></blockquote><blockquote type="cite">fromConnection:(QTCaptureConnection *)connection<br></blockquote><blockquote type="cite">+{<br></blockquote><blockquote type="cite">+ AudioBufferList *tempAudioBufferList;<br></blockquote><blockquote type="cite">+ NSMutableData *rawAudioData;<br></blockquote><blockquote type="cite">+ int audioDataSize = 0;<br></blockquote><blockquote type="cite">+ UInt32 count = 0;<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ @synchronized (self)<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ date_Increment(&date,512);<br></blockquote><br>Where is 512 coming from?<br><br><blockquote type="cite">+ currentPts = date_Get(&date);<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ QTFormatDescription *audio_format = [sampleBuffer<br></blockquote><blockquote type="cite">formatDescription];<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ tempAudioBufferList = [sampleBuffer<br></blockquote>audioBufferListWithOptions:0];<br><blockquote type="cite">+ if (tempAudioBufferList->mNumberBuffers > 1)<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ for ( count = 0; count <<br></blockquote>tempAudioBufferList->mNumberBuffers;<br><blockquote type="cite">count++ )<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ audioDataSize +=<br></blockquote><blockquote type="cite">tempAudioBufferList->mBuffers[count].mDataByteSize;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+ rawAudioData = malloc(audioDataSize * 2);<br></blockquote><blockquote type="cite">+ if (NULL == rawAudioData)<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ free(rawAudioData);<br></blockquote><blockquote type="cite">+ return;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ /* Interleave raw data<br></blockquote><blockquote type="cite">+ * The provided data by QTKit is not interleaved according to<br></blockquote><blockquote type="cite">information from ASBD<br></blockquote><blockquote type="cite">+ * See Format Comment in Open for detailed info on what QTKit<br></blockquote><blockquote type="cite">provides us with<br></blockquote><blockquote type="cite">+ */<br></blockquote><blockquote type="cite">+ if ( audioDataSize )<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ unsigned short i;<br></blockquote><blockquote type="cite">+ const float *b1Ptr, *b2Ptr;<br></blockquote><blockquote type="cite">+ float *uPtr;<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ for (i = 0,<br></blockquote><blockquote type="cite">+ uPtr = (float *)rawAudioData,<br></blockquote><blockquote type="cite">+ b1Ptr = (const float *)<br></blockquote><blockquote type="cite">tempAudioBufferList->mBuffers[0].mData,<br></blockquote><blockquote type="cite">+ b2Ptr = (const float *)<br></blockquote><blockquote type="cite">tempAudioBufferList->mBuffers[1].mData;<br></blockquote><blockquote type="cite">+ i < 512; i++)<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ *uPtr = *b1Ptr;<br></blockquote><blockquote type="cite">+ uPtr ++;<br></blockquote><blockquote type="cite">+ b1Ptr ++;<br></blockquote><blockquote type="cite">+ *uPtr = *b2Ptr;<br></blockquote><blockquote type="cite">+ uPtr ++;<br></blockquote><blockquote type="cite">+ b2Ptr ++;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ if (currentAudioBuffer == nil)<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ currentAudioBuffer = (AudioBuffer<br></blockquote><blockquote type="cite">*)malloc(sizeof(AudioBuffer));<br></blockquote><blockquote type="cite">+ if (NULL == currentAudioBuffer)<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ free(rawAudioData);<br></blockquote><blockquote type="cite">+ return;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+ currentAudioBuffer->mNumberChannels = 2;<br></blockquote><blockquote type="cite">+ currentAudioBuffer->mDataByteSize = audioDataSize;<br></blockquote><blockquote type="cite">+ currentAudioBuffer->mData = rawAudioData;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+}<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+- (mtime_t)copyCurrentAudioBytesToBuffer:(void *)buffer<br></blockquote><blockquote type="cite">+{<br></blockquote><blockquote type="cite">+ AudioBuffer *audioBuffer;<br></blockquote><blockquote type="cite">+ mtime_t pts;<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ if( !currentAudioBuffer || currentPts == previousPts )<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ return 0;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ @synchronized (self)<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ pts = previousPts = currentPts;<br></blockquote><blockquote type="cite">+ /* copy raw data */<br></blockquote><blockquote type="cite">+ memcpy( buffer, currentAudioBuffer->mData,<br></blockquote><blockquote type="cite">currentAudioBuffer->mDataByteSize );<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ return (currentAudioBuffer->mData) ? currentPts : 0;<br></blockquote><blockquote type="cite">+}<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+@end<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite"><br></blockquote>+/*****************************************************************************<br><blockquote type="cite">+ * Struct<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite"><br></blockquote>*****************************************************************************/<br><blockquote type="cite">+<br></blockquote><blockquote type="cite">+struct demux_sys_t {<br></blockquote><blockquote type="cite">+ QTCaptureSession * session;<br></blockquote><blockquote type="cite">+ QTCaptureDevice * audiodevice;<br></blockquote><blockquote type="cite">+ VLCDecompressedAudioOutput * audiooutput;<br></blockquote><blockquote type="cite">+ block_t *p_block_audio;<br></blockquote><br>p_block_audio does not seem to be used anywhere<br><br><blockquote type="cite">+ es_out_id_t *p_es_audio;<br></blockquote><blockquote type="cite">+ int i_audio_max_buffer_size;<br></blockquote><blockquote type="cite">+};<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite"><br></blockquote>+/*****************************************************************************<br><blockquote type="cite">+ * Open: initialize interface<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite"><br></blockquote>*****************************************************************************/<br><blockquote type="cite">+static int Open( vlc_object_t *p_this )<br></blockquote><blockquote type="cite">+{<br></blockquote><blockquote type="cite">+ demux_t *p_demux = (demux_t*)p_this;<br></blockquote><blockquote type="cite">+ demux_sys_t *p_sys;<br></blockquote><blockquote type="cite">+ es_format_t audiofmt;<br></blockquote><blockquote type="cite">+ int result = 0;<br></blockquote><blockquote type="cite">+ char *psz_uid = NULL;<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ /* Only when selected */<br></blockquote><blockquote type="cite">+ if( *p_demux->psz_access == '\0' )<br></blockquote><blockquote type="cite">+ return VLC_EGENERIC;<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ if( p_demux->psz_location && *p_demux->psz_location )<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ psz_uid = p_demux->psz_location;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+ msg_Dbg( p_demux, "qtsound uid = %s", psz_uid );<br></blockquote><blockquote type="cite">+ NSString *qtk_curraudiodevice_uid = [[NSString alloc]<br></blockquote><blockquote type="cite">initWithFormat:@"%s", psz_uid];<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ p_demux->p_sys = p_sys = calloc( 1, sizeof( demux_sys_t ) );<br></blockquote><blockquote type="cite">+ if( !p_sys )<br></blockquote><blockquote type="cite">+ return VLC_ENOMEM;<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ msg_Dbg( p_demux, "qtsound : uid = %s", [qtk_curraudiodevice_uid<br></blockquote><blockquote type="cite">UTF8String]);<br></blockquote><blockquote type="cite">+ NSArray *myAudioDevices = [[[QTCaptureDevice<br></blockquote><blockquote type="cite">inputDevicesWithMediaType:QTMediaTypeSound]<br></blockquote><blockquote type="cite">arrayByAddingObjectsFromArray:[QTCaptureDevice<br></blockquote><blockquote type="cite">inputDevicesWithMediaType:QTMediaTypeMuxed]] retain];<br></blockquote><blockquote type="cite">+ if([myAudioDevices count] == 0)<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ dialog_FatalWait( p_demux, _("No Audio Input device found"),<br></blockquote><blockquote type="cite">+ _("Your Mac does not seem to be equipped with<br></blockquote>a<br><blockquote type="cite">suitable audio input device."<br></blockquote><blockquote type="cite">+ "Please check your connectors and drivers.") );<br></blockquote><blockquote type="cite">+ msg_Err( p_demux, "Can't find any Audio device" );<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ goto error;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+ int iaudio;<br></blockquote><blockquote type="cite">+ for(iaudio = 0; iaudio < [myAudioDevices count]; iaudio++){<br></blockquote><blockquote type="cite">+ QTCaptureDevice *qtk_audioDevice;<br></blockquote><blockquote type="cite">+ qtk_audioDevice = [myAudioDevices objectAtIndex:iaudio];<br></blockquote><blockquote type="cite">+ msg_Dbg( p_demux, "qtsound audio %d/%d localizedDisplayName: %s<br></blockquote><blockquote type="cite">uniqueID: %s", iaudio, [myAudioDevices count], [[qtk_audioDevice<br></blockquote><blockquote type="cite">localizedDisplayName] UTF8String], [[qtk_audioDevice uniqueID]<br></blockquote><blockquote type="cite">UTF8String]);<br></blockquote><blockquote type="cite">+ if([[[qtk_audioDevice<br></blockquote><blockquote type="cite">localizedDisplayName]stringByTrimmingCharactersInSet:[NSCharacterSet<br></blockquote><blockquote type="cite">whitespaceCharacterSet]] isEqualToString:qtk_curraudiodevice_uid]){<br></blockquote><blockquote type="cite">+ msg_Dbg( p_demux, "Device found" );<br></blockquote><blockquote type="cite">+ break;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ QTCaptureDeviceInput * audioInput = nil;<br></blockquote><blockquote type="cite">+ NSError *o_returnedAudioError;<br></blockquote><blockquote type="cite">+ if(iaudio < [myAudioDevices count]){<br></blockquote><blockquote type="cite">+ p_sys->audiodevice = [myAudioDevices objectAtIndex:iaudio];<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+ else<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ /* cannot find designated audio device, fall back to open<br></blockquote>default<br><blockquote type="cite">audio device */<br></blockquote><blockquote type="cite">+ msg_Dbg(p_demux, "Cannot find designated uid audio device as<br></blockquote>%s.<br><blockquote type="cite">Fall back to open default audio device.", [qtk_curraudiodevice_uid<br></blockquote><blockquote type="cite">UTF8String]);<br></blockquote><blockquote type="cite">+ p_sys->audiodevice = [QTCaptureDevice<br></blockquote><blockquote type="cite">defaultInputDeviceWithMediaType: QTMediaTypeSound];<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+ if( !p_sys->audiodevice )<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ dialog_FatalWait( p_demux, _("No audio input device found"),<br></blockquote><blockquote type="cite">+ _("Your Mac does not seem to be equipped with<br></blockquote>a<br><blockquote type="cite">suitable audio input device."<br></blockquote><blockquote type="cite">+ "Please check your connectors and drivers.") );<br></blockquote><blockquote type="cite">+ msg_Err( p_demux, "Can't find any Audio device" );<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ goto error;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ if( ![p_sys->audiodevice open: &o_returnedAudioError] )<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ msg_Err( p_demux, "Unable to open the audio capture device<br></blockquote>(%d)",<br><blockquote type="cite">[o_returnedAudioError code] );<br></blockquote><blockquote type="cite">+ goto error;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ if( [p_sys->audiodevice isInUseByAnotherApplication] == YES )<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ msg_Err( p_demux, "default audio capture device is exclusively<br></blockquote>in<br><blockquote type="cite">use by another application" );<br></blockquote><blockquote type="cite">+ goto error;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+ audioInput = [[QTCaptureDeviceInput alloc] initWithDevice:<br></blockquote><blockquote type="cite">p_sys->audiodevice];<br></blockquote><blockquote type="cite">+ if( !audioInput )<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ msg_Err( p_demux, "can't create a valid audio capture input<br></blockquote><blockquote type="cite">facility" );<br></blockquote><blockquote type="cite">+ goto error;<br></blockquote><blockquote type="cite">+ } else {<br></blockquote><blockquote type="cite">+ msg_Dbg( p_demux, "created valid audio capture input facility"<br></blockquote>);<br><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ p_sys->audiooutput = [[VLCDecompressedAudioOutput alloc] init];<br></blockquote><blockquote type="cite">+ msg_Dbg ( p_demux, "initialized audio output" );<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ /* Get the formats */<br></blockquote><blockquote type="cite">+ /*<br></blockquote><blockquote type="cite">+ FIXME: the format description gathered here does not seem to be<br></blockquote>the<br><blockquote type="cite">same<br></blockquote><blockquote type="cite">+ in comparison to the format description collected from the actual<br></blockquote><blockquote type="cite">sampleBuffer.<br></blockquote><blockquote type="cite">+ This information needs to be updated some other place. For the<br></blockquote>time<br><blockquote type="cite">being this shall suffice.<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ The following verbose output is an example of what is read from<br></blockquote>the<br><blockquote type="cite">input device during the below block<br></blockquote><blockquote type="cite">+ [0x3042138] qtsound demux debug: Audio localized format summary:<br></blockquote><blockquote type="cite">Linear PCM, 24 bit little-endian signed integer, 2 channels, 44100 Hz<br></blockquote><blockquote type="cite">+ [0x3042138] qtsound demux debug: Sample Rate: 44100; Format ID:<br></blockquote><blockquote type="cite">lpcm; Format Flags: 00000004; Bytes per Packet: 8; Frames per Packet: 1;<br></blockquote><blockquote type="cite">Bytes per Frame: 8; Channels per Frame: 2; Bits per Channel: 24<br></blockquote><blockquote type="cite">+ [0x3042138] qtsound demux debug: Flag float 0 bigEndian 0<br></blockquote>signedInt<br><blockquote type="cite">1 packed 0 alignedHigh 0 non interleaved 0 non mixable 0<br></blockquote><blockquote type="cite">+ canonical 0 nativeFloatPacked 0 nativeEndian 0<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ However when reading this information from the sampleBuffer during<br></blockquote><blockquote type="cite">the delegate call from<br></blockquote><blockquote type="cite">+ - (void)outputAudioSampleBuffer:(QTSampleBuffer *)sampleBuffer<br></blockquote><blockquote type="cite">fromConnection:(QTCaptureConnection *)connection;<br></blockquote><blockquote type="cite">+ the following data shows up<br></blockquote><blockquote type="cite">+ 2011-09-23 22:06:03.077 VLC[23070:f103] Audio localized format<br></blockquote><blockquote type="cite">summary: Linear PCM, 32 bit little-endian floating point, 2 channels,<br></blockquote>44100<br><blockquote type="cite">Hz<br></blockquote><blockquote type="cite">+ 2011-09-23 22:06:03.078 VLC[23070:f103] Sample Rate: 44100; Format<br></blockquote><blockquote type="cite">ID: lpcm; Format Flags: 00000029; Bytes per Packet: 4; Frames per<br></blockquote>Packet:<br><blockquote type="cite">1; Bytes per Frame: 4; Channels per Frame: 2; Bits per Channel: 32<br></blockquote><blockquote type="cite">+ 2011-09-23 22:06:03.078 VLC[23070:f103] Flag float 1 bigEndian 0<br></blockquote><blockquote type="cite">signedInt 0 packed 1 alignedHigh 0 non interleaved 1 non mixable 0<br></blockquote><blockquote type="cite">+ canonical 1 nativeFloatPacked 1 nativeEndian 0<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ Note the differences<br></blockquote><blockquote type="cite">+ 24bit vs. 32bit<br></blockquote><blockquote type="cite">+ little-endian signed integer vs. little-endian floating point<br></blockquote><blockquote type="cite">+ format flag 00000004 vs. 00000029<br></blockquote><blockquote type="cite">+ bytes per packet 8 vs. 4<br></blockquote><blockquote type="cite">+ packed 0 vs. 1<br></blockquote><blockquote type="cite">+ non interleaved 0 vs. 1 -> this makes a major difference when<br></blockquote><blockquote type="cite">filling our own buffer<br></blockquote><blockquote type="cite">+ canonical 0 vs. 1<br></blockquote><blockquote type="cite">+ nativeFloatPacked 0 vs. 1<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ One would assume we'd need to feed the (es_format_t)audiofmt with<br></blockquote><blockquote type="cite">the data collected here.<br></blockquote><blockquote type="cite">+ This is not the case. Audio will be transmitted in artefacts, due<br></blockquote>to<br><blockquote type="cite">wrong information.<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ At the moment this data is set manually, however one should<br></blockquote>consider<br><blockquote type="cite">trying to set this data dynamically<br></blockquote><blockquote type="cite">+ */<br></blockquote><blockquote type="cite">+ NSArray *audioformat_array = [p_sys->audiodevice<br></blockquote>formatDescriptions];<br><blockquote type="cite">+ QTFormatDescription* audio_format = NULL;<br></blockquote><blockquote type="cite">+ for( int k = 0; k < [audioformat_array count]; k++ )<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ audio_format = (QTFormatDescription *)[audioformat_array<br></blockquote><blockquote type="cite">objectAtIndex: k];<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ msg_Dbg( p_demux, "Audio localized format summary: %s",<br></blockquote><blockquote type="cite">[[audio_format localizedFormatSummary] UTF8String]);<br></blockquote><blockquote type="cite">+ msg_Dbg( p_demux, "Audio format description attributes:<br></blockquote><blockquote type="cite">%s",[[[audio_format formatDescriptionAttributes] description]<br></blockquote>UTF8String]);<br><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ AudioStreamBasicDescription asbd = {0};<br></blockquote><blockquote type="cite">+ NSValue *asbdValue = [audio_format<br></blockquote><blockquote type="cite"><br></blockquote>attributeForKey:QTFormatDescriptionAudioStreamBasicDescriptionAttribute];<br><blockquote type="cite">+ [asbdValue getValue:&asbd];<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ char formatIDString[5];<br></blockquote><blockquote type="cite">+ UInt32 formatID = CFSwapInt32HostToBig (asbd.mFormatID);<br></blockquote><blockquote type="cite">+ bcopy (&formatID, formatIDString, 4);<br></blockquote><blockquote type="cite">+ formatIDString[4] = '\0';<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ /* kept for development purposes */<br></blockquote><blockquote type="cite">+#if 0<br></blockquote><blockquote type="cite">+ msg_Dbg( p_demux, "Sample Rate: %.0lf; Format ID: %s; Format<br></blockquote><blockquote type="cite">Flags: %.8x; Bytes per Packet: %d; Frames per Packet: %d; Bytes per<br></blockquote>Frame:<br><blockquote type="cite">%d; Channels per Frame: %d; Bits per Channel: %d",<br></blockquote><blockquote type="cite">+ asbd.mSampleRate,<br></blockquote><blockquote type="cite">+ formatIDString,<br></blockquote><blockquote type="cite">+ asbd.mFormatFlags,<br></blockquote><blockquote type="cite">+ asbd.mBytesPerPacket,<br></blockquote><blockquote type="cite">+ asbd.mFramesPerPacket,<br></blockquote><blockquote type="cite">+ asbd.mBytesPerFrame,<br></blockquote><blockquote type="cite">+ asbd.mChannelsPerFrame,<br></blockquote><blockquote type="cite">+ asbd.mBitsPerChannel);<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ msg_Dbg( p_demux, "Flag float %d bigEndian %d signedInt %d<br></blockquote>packed<br><blockquote type="cite">%d alignedHigh %d non interleaved %d non mixable %d\ncanonical %d<br></blockquote><blockquote type="cite">nativeFloatPacked %d nativeEndian %d",<br></blockquote><blockquote type="cite">+ (asbd.mFormatFlags & kAudioFormatFlagIsFloat) != 0,<br></blockquote><blockquote type="cite">+ (asbd.mFormatFlags & kAudioFormatFlagIsBigEndian) != 0,<br></blockquote><blockquote type="cite">+ (asbd.mFormatFlags & kAudioFormatFlagIsSignedInteger)<br></blockquote>!=<br><blockquote type="cite">0,<br></blockquote><blockquote type="cite">+ (asbd.mFormatFlags & kAudioFormatFlagIsPacked) != 0,<br></blockquote><blockquote type="cite">+ (asbd.mFormatFlags & kAudioFormatFlagIsAlignedHigh) !=<br></blockquote>0,<br><blockquote type="cite">+ (asbd.mFormatFlags & kAudioFormatFlagIsNonInterleaved)<br></blockquote>!=<br><blockquote type="cite">0,<br></blockquote><blockquote type="cite">+ (asbd.mFormatFlags & kAudioFormatFlagIsNonMixable) !=<br></blockquote>0,<br><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ (asbd.mFormatFlags & kAudioFormatFlagsCanonical) != 0,<br></blockquote><blockquote type="cite">+ (asbd.mFormatFlags &<br></blockquote>kAudioFormatFlagsNativeFloatPacked)<br><blockquote type="cite">!= 0,<br></blockquote><blockquote type="cite">+ (asbd.mFormatFlags & kAudioFormatFlagsNativeEndian) !=<br></blockquote>0<br><blockquote type="cite">+ );<br></blockquote><blockquote type="cite">+#endif<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ if( [audioformat_array count] )<br></blockquote><blockquote type="cite">+ audio_format = [audioformat_array objectAtIndex: 0];<br></blockquote><blockquote type="cite">+ else goto error;<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ /* Now we can init */<br></blockquote><blockquote type="cite">+ int audiocodec = VLC_CODEC_FL32;<br></blockquote><blockquote type="cite">+ es_format_Init( &audiofmt, AUDIO_ES, audiocodec);<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ audiofmt.audio.i_format = audiocodec;<br></blockquote><blockquote type="cite">+ audiofmt.audio.i_rate = 44100;<br></blockquote><blockquote type="cite">+ /* i_physical_channels Describes the channels configuration of the<br></blockquote><blockquote type="cite">samples (ie. number of<br></blockquote><blockquote type="cite">+ * channels which are available in the buffer, and positions). */<br></blockquote><blockquote type="cite">+ audiofmt.audio.i_physical_channels = AOUT_CHAN_RIGHT |<br></blockquote>AOUT_CHAN_LEFT;<br><blockquote type="cite">+ /* i_original_channels Describes from which original channels,<br></blockquote>before<br><blockquote type="cite">downmixing, the<br></blockquote><blockquote type="cite">+ * buffer is derived. */<br></blockquote><blockquote type="cite">+ audiofmt.audio.i_original_channels = AOUT_CHAN_RIGHT |<br></blockquote>AOUT_CHAN_LEFT;<br><blockquote type="cite">+ /* i_bytes_per_frame Optional - for A/52, SPDIF and DTS types : */<br></blockquote><blockquote type="cite">+ /* Bytes used by one compressed frame, depends on bitrate. */<br></blockquote><blockquote type="cite">+ audiofmt.audio.i_bytes_per_frame = 4;<br></blockquote><blockquote type="cite">+ /* Number of sampleframes contained in one compressed frame. */<br></blockquote><blockquote type="cite">+ audiofmt.audio.i_frame_length = 1;<br></blockquote><blockquote type="cite">+ /* Please note that it may be completely arbitrary - buffers are<br></blockquote>not<br><blockquote type="cite">+ * obliged to contain a integral number of so-called "frames". It's<br></blockquote><blockquote type="cite">+ * just here for the division :<br></blockquote><blockquote type="cite">+ * buffer_size = i_nb_samples * i_bytes_per_frame / i_frame_length<br></blockquote><blockquote type="cite">+ */<br></blockquote><blockquote type="cite">+ audiofmt.audio.i_bitspersample = 32;<br></blockquote><blockquote type="cite">+ audiofmt.audio.i_channels = 2;<br></blockquote><blockquote type="cite">+ audiofmt.audio.i_blockalign = audiofmt.audio.i_channels *<br></blockquote><blockquote type="cite">audiofmt.audio.i_bitspersample / 16;<br></blockquote><blockquote type="cite">+ audiofmt.i_bitrate = audiofmt.audio.i_channels *<br></blockquote><blockquote type="cite">audiofmt.audio.i_rate * audiofmt.audio.i_bitspersample;<br></blockquote><blockquote type="cite">+ p_sys->i_audio_max_buffer_size = 4096;<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ p_sys->session = [[QTCaptureSession alloc] init];<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ bool retAudio = [p_sys->session addInput:audioInput error:<br></blockquote><blockquote type="cite">&o_returnedAudioError];<br></blockquote><blockquote type="cite">+ if( !retAudio )<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ msg_Err( p_demux, "the audio capture device could not be added<br></blockquote>to<br><blockquote type="cite">capture session (%d)", [o_returnedAudioError code] );<br></blockquote><blockquote type="cite">+ goto error;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ bool retAudioOutput = [p_sys->session addOutput:p_sys->audiooutput<br></blockquote><blockquote type="cite">error: &o_returnedAudioError];<br></blockquote><blockquote type="cite">+ if( !retAudioOutput )<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ msg_Err( p_demux, "audio output could not be added to capture<br></blockquote><blockquote type="cite">session (%d)", [o_returnedAudioError code] );<br></blockquote><blockquote type="cite">+ goto error;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ [p_sys->session startRunning];<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ /* Set up p_demux */<br></blockquote><blockquote type="cite">+ p_demux->pf_demux = Demux;<br></blockquote><blockquote type="cite">+ p_demux->pf_control = Control;<br></blockquote><blockquote type="cite">+ p_demux->info.i_update = 0;<br></blockquote><blockquote type="cite">+ p_demux->info.i_title = 0;<br></blockquote><blockquote type="cite">+ p_demux->info.i_seekpoint = 0;<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ msg_Dbg( p_demux, "New audio es %d channels %dHz",<br></blockquote><blockquote type="cite">+ audiofmt.audio.i_channels, audiofmt.audio.i_rate );<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ p_sys->p_es_audio = es_out_Add( p_demux->out, &audiofmt );<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ [audioInput release];<br></blockquote><blockquote type="cite">+ [pool release];<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ msg_Dbg( p_demux, "QTSound: We have an audio device ready!" );<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ return VLC_SUCCESS;<br></blockquote><blockquote type="cite">+error:<br></blockquote><blockquote type="cite">+ [audioInput release];<br></blockquote><blockquote type="cite">+ [pool release];<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ free( p_sys );<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ return VLC_EGENERIC;<br></blockquote><blockquote type="cite">+}<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite"><br></blockquote>+/*****************************************************************************<br><blockquote type="cite">+ * Close: destroy interface<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite"><br></blockquote>*****************************************************************************/<br><blockquote type="cite">+static void Close( vlc_object_t *p_this )<br></blockquote><blockquote type="cite">+{<br></blockquote><blockquote type="cite">+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ demux_t *p_demux = (demux_t*)p_this;<br></blockquote><blockquote type="cite">+ demux_sys_t *p_sys = p_demux->p_sys;<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ /* Hack: if libvlc was killed, main interface thread was,<br></blockquote><blockquote type="cite">+ * and poor QTKit needs it, so don't tell him.<br></blockquote><blockquote type="cite">+ * Else we dead lock. */<br></blockquote><blockquote type="cite">+ if( vlc_object_alive(p_this->p_libvlc))<br></blockquote><br>No matter why you feel like you need to check the legacy b_die bit, it<br>certainly does not do whatever you wish it did.<br><br><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ // Perform this on main thread, as the framework itself will<br></blockquote><blockquote type="cite">sometimes try to synchronously<br></blockquote><blockquote type="cite">+ // work on main thread. And this will create a dead lock.<br></blockquote><blockquote type="cite">+ [p_sys->session<br></blockquote><blockquote type="cite">performSelectorOnMainThread:@selector(stopRunning) withObject:nil<br></blockquote><blockquote type="cite">waitUntilDone:NO];<br></blockquote><blockquote type="cite">+ [p_sys->audiooutput<br></blockquote><blockquote type="cite">performSelectorOnMainThread:@selector(release) withObject:nil<br></blockquote><blockquote type="cite">waitUntilDone:NO];<br></blockquote><blockquote type="cite">+ [p_sys->session performSelectorOnMainThread:@selector(release)<br></blockquote><blockquote type="cite">withObject:nil waitUntilDone:NO];<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+ free( p_sys );<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ [pool release];<br></blockquote><blockquote type="cite">+}<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite"><br></blockquote>+/*****************************************************************************<br><blockquote type="cite">+ * Demux:<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite"><br></blockquote>*****************************************************************************/<br><blockquote type="cite">+static int Demux( demux_t *p_demux )<br></blockquote><blockquote type="cite">+{<br></blockquote><blockquote type="cite">+ demux_sys_t *p_sys = p_demux->p_sys;<br></blockquote><blockquote type="cite">+ block_t *p_blocka;<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ p_blocka = block_New( p_demux, p_sys->i_audio_max_buffer_size );<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ if( !p_blocka )<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ msg_Err( p_demux, "cannot get audio block" );<br></blockquote><blockquote type="cite">+ return 0;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ @synchronized (p_sys->audiooutput)<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ p_blocka->i_pts = [p_sys->audiooutput<br></blockquote><blockquote type="cite">copyCurrentAudioBytesToBuffer: p_blocka->p_buffer];<br></blockquote><br>It seems to me that you are copying the data twice.<br><br>There should be no need to copy blocks data at all since deinterleaving<br>does it on the fly.<br><br><blockquote type="cite">+ /* FIXME: set this dynamically */<br></blockquote><blockquote type="cite">+ p_blocka->i_nb_samples = 512;<br></blockquote><blockquote type="cite">+ p_blocka->i_buffer = 4096;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ if( !p_blocka->i_pts )<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ // Nothing to transfer yet, just forget<br></blockquote><blockquote type="cite">+ block_Release( p_blocka );<br></blockquote><blockquote type="cite">+ [pool release];<br></blockquote><blockquote type="cite">+ msleep( 10000 );<br></blockquote><blockquote type="cite">+ return 1;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ [pool release];<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ if( p_blocka )<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_blocka->i_pts<br></blockquote>);<br><blockquote type="cite">+ es_out_Send( p_demux->out, p_sys->p_es_audio, p_blocka );<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ return 1;<br></blockquote><blockquote type="cite">+}<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite"><br></blockquote>+/*****************************************************************************<br><blockquote type="cite">+ * Control:<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite"><br></blockquote>*****************************************************************************/<br><blockquote type="cite">+static int Control( demux_t *p_demux, int i_query, va_list args )<br></blockquote><blockquote type="cite">+{<br></blockquote><blockquote type="cite">+ bool *pb;<br></blockquote><blockquote type="cite">+ int64_t *pi64;<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ switch( i_query )<br></blockquote><blockquote type="cite">+ {<br></blockquote><blockquote type="cite">+ /* Special for access_demux */<br></blockquote><blockquote type="cite">+ case DEMUX_CAN_PAUSE:<br></blockquote><blockquote type="cite">+ case DEMUX_CAN_SEEK:<br></blockquote><blockquote type="cite">+ case DEMUX_SET_PAUSE_STATE:<br></blockquote><blockquote type="cite">+ case DEMUX_CAN_CONTROL_PACE:<br></blockquote><blockquote type="cite">+ pb = (bool*)va_arg( args, bool * );<br></blockquote><blockquote type="cite">+ *pb = false;<br></blockquote><blockquote type="cite">+ return VLC_SUCCESS;<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ case DEMUX_GET_PTS_DELAY:<br></blockquote><blockquote type="cite">+ pi64 = (int64_t*)va_arg( args, int64_t * );<br></blockquote><blockquote type="cite">+ *pi64 = (int64_t)DEFAULT_PTS_DELAY;<br></blockquote><blockquote type="cite">+ return VLC_SUCCESS;<br></blockquote><br>Should probably be live-caching value.<br><br><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ default:<br></blockquote><blockquote type="cite">+ return VLC_EGENERIC;<br></blockquote><blockquote type="cite">+ }<br></blockquote><blockquote type="cite">+ return VLC_EGENERIC;<br></blockquote><blockquote type="cite">+}<br></blockquote><br>--<br>Rémi Denis-Courmont<br><a href="http://www.remlab.net/">http://www.remlab.net/</a><br>_______________________________________________<br>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br>http://mailman.videolan.org/listinfo/vlc-devel<br></div></blockquote></div><br></body></html>