Changeset 3932

Show
Ignore:
Timestamp:
03/02/10 06:27:53 (5 months ago)
Author:
sletz
Message:

More flexible handling of network audio buffers.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • jack2/branches/libjacknet/common/JackNetInterface.cpp

    r3926 r3932  
    116116        //bufsize = sync + audio + midi 
    117117        bufsize = MAX_LATENCY * (fParams.fMtu + ( int ) audio_size + ( int ) midi_size); 
     118        jack_info("SetNetBufferSize bufsize = %d", bufsize); 
    118119 
    119120        //tx buffer 
     
    299300 
    300301        //audio net buffers 
    301         fNetAudioCaptureBuffer = new NetAudioBuffer ( &fParams, fParams.fSendAudioChannels, fTxData ); 
    302         fNetAudioPlaybackBuffer = new NetAudioBuffer ( &fParams, fParams.fReturnAudioChannels, fRxData ); 
     302        fNetAudioCaptureBuffer = new NetSingleAudioBuffer ( &fParams, fParams.fSendAudioChannels, fTxData ); 
     303        fNetAudioPlaybackBuffer = new NetSingleAudioBuffer ( &fParams, fParams.fReturnAudioChannels, fRxData ); 
     304         
     305        //fNetAudioCaptureBuffer = new NetBufferedAudioBuffer ( &fParams, fParams.fSendAudioChannels, fTxData ); 
     306        //fNetAudioPlaybackBuffer = new NetBufferedAudioBuffer ( &fParams, fParams.fReturnAudioChannels, fRxData );      
     307      
    303308        assert ( fNetAudioCaptureBuffer ); 
    304309        assert ( fNetAudioPlaybackBuffer ); 
     
    388393    { 
    389394        if (fParams.fNetworkMode == 's') { 
    390             return (fCycleOffset < 3); 
     395            return (fCycleOffset < (CYCLE_OFFSET_SLOW + 1)); 
    391396        } else { 
    392397            return true; 
     
    465470                //  - this mode will skip the two first cycles, thus it lets time for data to be processed and queued on the socket rx buffer 
    466471                //the slow mode is the safest mode because it wait twice the bandwidth relative time (send/return + process) 
    467                 if (fCycleOffset < 2) { 
     472                if (fCycleOffset < CYCLE_OFFSET_SLOW) { 
    468473                    return 0; 
    469474                } else { 
    470475                    rx_bytes = Recv ( rx_head->fPacketSize, 0 ); 
    471476                } 
    472                      
    473                 if (fCycleOffset > 2) { 
     477                 
     478                if (fCycleOffset > CYCLE_OFFSET_SLOW) { 
    474479                    jack_info("Warning : '%s' runs in slow network mode, but data received too late (%d cycle(s) offset)", fParams.fName, fCycleOffset); 
    475480                } 
     
    515520        uint recvd_midi_pckt = 0; 
    516521        uint recvd_audio_pckt = 0; 
     522        int last_cycle = 0; 
     523          
    517524        packet_header_t* rx_head = reinterpret_cast<packet_header_t*> ( fRxBuffer ); 
    518525         
     
    554561                        fRxHeader.fSubCycle = rx_head->fSubCycle; 
    555562                        fRxHeader.fIsLastPckt = rx_head->fIsLastPckt; 
    556                         fNetAudioPlaybackBuffer->RenderToJackPorts ( rx_head->fSubCycle ); 
     563                        fNetAudioPlaybackBuffer->RenderToJackPorts ( rx_head->fCycle,  rx_head->fSubCycle); 
    557564                        jumpcnt = 0; 
     565                        last_cycle = rx_head->fCycle; 
    558566                        break; 
    559567 
    560568                    case 's':   //sync 
    561569                        jack_info("NetMaster : overloaded, skipping receive from '%s'", fParams.fName); 
     570                        // Finish rendering (copy to JACK ports) 
     571                        fNetAudioPlaybackBuffer->FinishRenderToJackPorts(last_cycle);  
    562572                        return 0; 
    563573                } 
    564574            } 
    565575        } 
     576         
     577        // Finish rendering (copy to JACK ports) 
     578        fNetAudioPlaybackBuffer->FinishRenderToJackPorts(last_cycle);  
    566579        return rx_bytes; 
    567580    } 
     
    791804 
    792805        //audio net buffers 
    793         fNetAudioCaptureBuffer = new NetAudioBuffer ( &fParams, fParams.fSendAudioChannels, fRxData ); 
    794         fNetAudioPlaybackBuffer = new NetAudioBuffer ( &fParams, fParams.fReturnAudioChannels, fTxData ); 
     806        fNetAudioCaptureBuffer = new NetSingleAudioBuffer ( &fParams, fParams.fSendAudioChannels, fRxData ); 
     807        fNetAudioPlaybackBuffer = new NetSingleAudioBuffer ( &fParams, fParams.fReturnAudioChannels, fTxData ); 
     808         
     809        //fNetAudioCaptureBuffer = new NetBufferedAudioBuffer ( &fParams, fParams.fSendAudioChannels, fRxData ); 
     810        //fNetAudioPlaybackBuffer = new NetBufferedAudioBuffer ( &fParams, fParams.fReturnAudioChannels, fTxData ); 
    795811 
    796812        //audio netbuffer length 
     
    868884        uint recvd_audio_pckt = 0; 
    869885        int rx_bytes = 0; 
     886        int last_cycle = 0; 
     887      
    870888        packet_header_t* rx_head = reinterpret_cast<packet_header_t*> ( fRxBuffer ); 
    871889 
     
    894912                        rx_bytes = Recv ( rx_head->fPacketSize, 0 ); 
    895913                        if (recvd_audio_pckt++ != rx_head->fSubCycle) { 
    896                             //jack_error("Packet(s) missing from '%s'...", fParams.fMasterNetName); 
    897                             jack_error("Packet(s) missing from '%s'... %d %d %d", fParams.fMasterNetName, rx_head->fCycle, recvd_audio_pckt, rx_head->fSubCycle); 
     914                            jack_error("Packet(s) missing from '%s'...", fParams.fMasterNetName); 
    898915                        } 
    899916                        fRxHeader.fCycle = rx_head->fCycle; 
    900917                        fRxHeader.fSubCycle = rx_head->fSubCycle; 
    901918                        fRxHeader.fIsLastPckt = rx_head->fIsLastPckt; 
    902                         fNetAudioCaptureBuffer->RenderToJackPorts ( rx_head->fSubCycle ); 
     919                        fNetAudioCaptureBuffer->RenderToJackPorts ( rx_head->fCycle, rx_head->fSubCycle); 
     920                        last_cycle = rx_head->fCycle; 
    903921                        break; 
    904922 
    905923                    case 's':   //sync 
    906924                        jack_info ( "NetSlave : overloaded, skipping receive." ); 
     925                        // Finish rendering (copy to JACK ports) 
     926                        fNetAudioCaptureBuffer->FinishRenderToJackPorts(last_cycle);  
    907927                        return 0; 
    908928                } 
    909929            } 
    910930        } 
     931         
     932        // Finish rendering (copy to JACK ports) 
     933        fNetAudioCaptureBuffer->FinishRenderToJackPorts(last_cycle);  
    911934        fRxHeader.fCycle = rx_head->fCycle; 
    912935        return 0; 
  • jack2/branches/libjacknet/common/JackNetInterface.h

    r3614 r3932  
    213213#define SLAVE_INIT_TIMEOUT 2000000      // in usec 
    214214 
    215 #define MAX_LATENCY 6 
     215#define CYCLE_OFFSET_SLOW 2 
     216#define MAX_LATENCY CYCLE_OFFSET_SLOW * 4 
    216217 
    217218#endif 
  • jack2/branches/libjacknet/common/JackNetTool.cpp

    r3931 r3932  
    128128// net audio buffer ********************************************************************************* 
    129129 
    130     NetAudioBuffer::NetAudioBuffer ( session_params_t* params, uint32_t nports, char* net_buffer ) 
    131     { 
    132         fNPorts = nports; 
    133         fPeriodSize = params->fPeriodSize; 
    134         fSubPeriodSize = params->fFramesPerPacket; 
    135         fSubPeriodBytesSize = fSubPeriodSize * sizeof ( sample_t ); 
    136         fPortBuffer = new sample_t* [fNPorts]; 
    137         for ( int port_index = 0; port_index < fNPorts; port_index++ ) 
    138             fPortBuffer[port_index] = NULL; 
     130 
     131    NetSingleAudioBuffer::NetSingleAudioBuffer ( session_params_t* params, uint32_t nports, char* net_buffer ) 
     132        : fPortBuffer(params, nports), fNetBuffer(net_buffer) 
     133    {} 
     134 
     135    NetSingleAudioBuffer::~NetSingleAudioBuffer() 
     136    {} 
     137 
     138    size_t NetSingleAudioBuffer::GetSize() 
     139    { 
     140        return fPortBuffer.GetSize(); 
     141    } 
     142 
     143    void NetSingleAudioBuffer::SetBuffer ( int index, sample_t* buffer ) 
     144    { 
     145        fPortBuffer.SetBuffer(index, buffer); 
     146    } 
     147 
     148    sample_t* NetSingleAudioBuffer::GetBuffer ( int index ) 
     149    { 
     150        return fPortBuffer.GetBuffer(index); 
     151    } 
     152 
     153    void NetSingleAudioBuffer::RenderFromJackPorts (int subcycle) 
     154    { 
     155        fPortBuffer.RenderFromJackPorts(fNetBuffer, subcycle); 
     156    } 
     157 
     158    void NetSingleAudioBuffer::RenderToJackPorts (int cycle, int subcycle) 
     159    { 
     160        fPortBuffer.RenderToJackPorts(fNetBuffer, subcycle); 
     161    } 
     162 
     163// Buffered 
     164 
     165    NetBufferedAudioBuffer::NetBufferedAudioBuffer ( session_params_t* params, uint32_t nports, char* net_buffer ) 
     166    { 
     167        fMaxCycle = 0; 
    139168        fNetBuffer = net_buffer; 
    140     } 
    141  
    142     NetAudioBuffer::~NetAudioBuffer() 
    143     { 
    144         delete[] fPortBuffer; 
    145     } 
    146  
    147     size_t NetAudioBuffer::GetSize() 
    148     { 
    149         return fNPorts * fSubPeriodBytesSize; 
    150     } 
    151  
    152     void NetAudioBuffer::SetBuffer ( int index, sample_t* buffer ) 
    153     { 
    154         fPortBuffer[index] = buffer; 
    155     } 
    156  
    157     sample_t* NetAudioBuffer::GetBuffer ( int index ) 
    158     { 
    159         return fPortBuffer[index]; 
    160     } 
    161  
    162 #ifdef __BIG_ENDIAN__ 
    163  
    164     static inline float SwapFloat(float f) 
    165     { 
    166           union 
    167           { 
    168             float f; 
    169             unsigned char b[4]; 
    170           } dat1, dat2; 
    171  
    172           dat1.f = f; 
    173           dat2.b[0] = dat1.b[3]; 
    174           dat2.b[1] = dat1.b[2]; 
    175           dat2.b[2] = dat1.b[1]; 
    176           dat2.b[3] = dat1.b[0]; 
    177           return dat2.f; 
    178     } 
    179  
    180     void NetAudioBuffer::RenderFromJackPorts ( int subcycle ) 
    181     { 
    182         for ( int port_index = 0; port_index < fNPorts; port_index++ ) { 
    183             float* src = (float*)(fPortBuffer[port_index] + subcycle * fSubPeriodSize); 
    184             float* dst = (float*)(fNetBuffer + port_index * fSubPeriodBytesSize); 
    185             for (unsigned int sample = 0; sample < fSubPeriodBytesSize / sizeof(float); sample++) { 
    186                 dst[sample] = SwapFloat(src[sample]); 
    187             } 
    188         } 
    189     } 
    190  
    191     void NetAudioBuffer::RenderToJackPorts ( int subcycle ) 
    192     { 
    193         for ( int port_index = 0; port_index < fNPorts; port_index++ ) { 
    194             float* src = (float*)(fNetBuffer + port_index * fSubPeriodBytesSize); 
    195             float* dst = (float*)(fPortBuffer[port_index] + subcycle * fSubPeriodSize); 
    196             for (unsigned int sample = 0; sample < fSubPeriodBytesSize / sizeof(float); sample++) { 
    197                 dst[sample] = SwapFloat(src[sample]); 
    198             } 
    199         }     
     169         
     170        for (int i = 0; i < AUDIO_BUFFER_SIZE; i++) { 
     171            fPortBuffer[i].Init(params, nports); 
     172        } 
     173         
     174        fJackPortBuffer = new sample_t* [nports]; 
     175        for ( int port_index = 0; port_index < nports; port_index++ ) 
     176            fJackPortBuffer[port_index] = NULL; 
     177    } 
     178 
     179    NetBufferedAudioBuffer::~NetBufferedAudioBuffer() 
     180    { 
     181        delete [] fJackPortBuffer; 
     182    } 
     183 
     184    size_t NetBufferedAudioBuffer::GetSize() 
     185    { 
     186        return fPortBuffer[0].GetSize(); 
     187    } 
     188 
     189    void NetBufferedAudioBuffer::SetBuffer ( int index, sample_t* buffer ) 
     190    { 
     191        fJackPortBuffer[index] = buffer; 
     192    } 
     193 
     194    sample_t* NetBufferedAudioBuffer::GetBuffer ( int index ) 
     195    { 
     196        return fJackPortBuffer[index]; 
    200197    } 
    201198     
    202 #else 
    203  
    204     void NetAudioBuffer::RenderFromJackPorts ( int subcycle ) 
    205     { 
    206         for ( int port_index = 0; port_index < fNPorts; port_index++ ) 
    207             memcpy ( fNetBuffer + port_index * fSubPeriodBytesSize, fPortBuffer[port_index] + subcycle * fSubPeriodSize, fSubPeriodBytesSize ); 
    208     } 
    209  
    210     void NetAudioBuffer::RenderToJackPorts ( int subcycle ) 
    211     { 
    212         for ( int port_index = 0; port_index < fNPorts; port_index++ ) 
    213             memcpy ( fPortBuffer[port_index] + subcycle * fSubPeriodSize, fNetBuffer + port_index * fSubPeriodBytesSize, fSubPeriodBytesSize ); 
    214     } 
    215  
    216 #endif 
     199    void NetBufferedAudioBuffer::RenderFromJackPorts (int subcycle ) 
     200    { 
     201        fPortBuffer[0].RenderFromJackPorts(fNetBuffer, subcycle);  // Always use first buffer... 
     202    } 
     203 
     204    void NetBufferedAudioBuffer::RenderToJackPorts (int cycle, int subcycle) 
     205    { 
     206        if (cycle < fMaxCycle) { 
     207            jack_info("Wrong order fCycle %d subcycle %d fMaxCycle %d", cycle, subcycle, fMaxCycle); 
     208        } 
     209        fPortBuffer[cycle % AUDIO_BUFFER_SIZE].RenderToJackPorts(fNetBuffer, subcycle); 
     210    } 
     211 
     212    void NetBufferedAudioBuffer::FinishRenderToJackPorts (int cycle) 
     213    { 
     214        fMaxCycle = std::max(fMaxCycle, cycle); 
     215        fPortBuffer[(cycle + 1) % AUDIO_BUFFER_SIZE].Copy(fJackPortBuffer);  // Copy internal buffer in JACK ports 
     216    } 
    217217 
    218218// SessionParams ************************************************************************************ 
  • jack2/branches/libjacknet/common/JackNetTool.h

    r3402 r3932  
    249249// audio data ********************************************************************************* 
    250250 
     251    class SERVER_EXPORT NetAudioBuffer  
     252    { 
     253     
     254        public: 
     255            NetAudioBuffer () 
     256            {} 
     257            ~NetAudioBuffer() 
     258            {} 
     259             
     260            virtual size_t GetSize() = 0; 
     261            //jack<->buffer 
     262            virtual void RenderFromJackPorts (int subcycle ) = 0; 
     263            virtual void RenderToJackPorts ( int cycle, int subcycle) = 0; 
     264            virtual void FinishRenderToJackPorts (int cycle) = 0; 
     265 
     266            virtual void SetBuffer ( int index, sample_t* buffer ) = 0; 
     267            virtual sample_t* GetBuffer ( int index ) = 0; 
     268   }; 
     269 
    251270    /** 
    252271    \Brief Audio buffer and operations class 
     
    258277 
    259278    */ 
    260  
    261     class SERVER_EXPORT NetAudioBuffer 
     279     
     280    struct JackPortList { 
     281     
     282        jack_nframes_t fPeriodSize; 
     283        jack_nframes_t fSubPeriodSize; 
     284        size_t fSubPeriodBytesSize; 
     285        sample_t** fPortBuffer; 
     286        int fNPorts; 
     287         
     288        JackPortList(session_params_t* params, uint32_t nports) 
     289        { 
     290            fNPorts = nports; 
     291            fPeriodSize = params->fPeriodSize; 
     292            fSubPeriodSize = params->fFramesPerPacket; 
     293            fSubPeriodBytesSize = fSubPeriodSize * sizeof ( sample_t ); 
     294            fPortBuffer = new sample_t* [fNPorts]; 
     295            for ( int port_index = 0; port_index < fNPorts; port_index++ ) 
     296                fPortBuffer[port_index] = NULL; 
     297        } 
     298         
     299        JackPortList() 
     300        { 
     301            fNPorts = 0; 
     302            fPeriodSize = 0; 
     303            fSubPeriodSize = 0; 
     304            fSubPeriodBytesSize = 0; 
     305            fPortBuffer = 0; 
     306        } 
     307      
     308        ~JackPortList() 
     309        { 
     310            delete [] fPortBuffer; 
     311        } 
     312         
     313        void SetBuffer( int index, sample_t* buffer ) 
     314        { 
     315            fPortBuffer[index] = buffer; 
     316        } 
     317         
     318        sample_t* GetBuffer ( int index )  
     319        { 
     320            return fPortBuffer[index]; 
     321        } 
     322         
     323        void Copy(sample_t** buffers) 
     324        { 
     325            for ( int port_index = 0; port_index < fNPorts; port_index++ ) 
     326                memcpy(buffers[port_index], fPortBuffer[port_index], fPeriodSize * sizeof(float)); 
     327        } 
     328         
     329        size_t GetSize() 
     330        { 
     331             return fNPorts * fSubPeriodBytesSize; 
     332        } 
     333          
     334    #ifdef __BIG_ENDIAN__ 
     335 
     336        static inline float SwapFloat(float f) 
     337        { 
     338              union 
     339              { 
     340                float f; 
     341                unsigned char b[4]; 
     342              } dat1, dat2; 
     343 
     344              dat1.f = f; 
     345              dat2.b[0] = dat1.b[3]; 
     346              dat2.b[1] = dat1.b[2]; 
     347              dat2.b[2] = dat1.b[1]; 
     348              dat2.b[3] = dat1.b[0]; 
     349              return dat2.f; 
     350        } 
     351 
     352        void RenderFromJackPorts (char* net_buffer, int subcycle ) 
     353        { 
     354            for ( int port_index = 0; port_index < fNPorts; port_index++ ) { 
     355                float* src = (float*)(fPortBuffer[port_index] + subcycle * fSubPeriodSize); 
     356                float* dst = (float*)(net_buffer + port_index * fSubPeriodBytesSize); 
     357                for (unsigned int sample = 0; sample < fSubPeriodBytesSize / sizeof(float); sample++) { 
     358                    dst[sample] = SwapFloat(src[sample]); 
     359                } 
     360            } 
     361        } 
     362 
     363        void RenderToJackPorts (char* net_buffer, int subcycle) 
     364        { 
     365            for ( int port_index = 0; port_index < fNPorts; port_index++ ) { 
     366                float* src = (float*)(net_buffer + port_index * fSubPeriodBytesSize); 
     367                float* dst = (float*)(fPortBuffer[port_index] + subcycle * fSubPeriodSize); 
     368                for (unsigned int sample = 0; sample < fSubPeriodBytesSize / sizeof(float); sample++) { 
     369                    dst[sample] = SwapFloat(src[sample]); 
     370                } 
     371            }     
     372        } 
     373         
     374    #else 
     375 
     376        void RenderFromJackPorts (char* net_buffer, int subcycle ) 
     377        { 
     378            for ( int port_index = 0; port_index < fNPorts; port_index++ ) 
     379                memcpy ( net_buffer + port_index * fSubPeriodBytesSize, fPortBuffer[port_index] + subcycle * fSubPeriodSize, fSubPeriodBytesSize ); 
     380        } 
     381 
     382        void RenderToJackPorts (char* net_buffer, int subcycle) 
     383        { 
     384            for ( int port_index = 0; port_index < fNPorts; port_index++ ) 
     385                memcpy ( fPortBuffer[port_index] + subcycle * fSubPeriodSize, net_buffer + port_index * fSubPeriodBytesSize, fSubPeriodBytesSize ); 
     386        } 
     387 
     388    #endif 
     389     
     390    }; 
     391     
     392    struct JackPortListAllocate : public JackPortList { 
     393      
     394        JackPortListAllocate() 
     395        { 
     396            fNPorts = 0; 
     397            fPeriodSize = 0; 
     398            fSubPeriodSize = 0; 
     399            fSubPeriodBytesSize = 0; 
     400            fPortBuffer = 0; 
     401        } 
     402         
     403        ~JackPortListAllocate() 
     404        { 
     405            for ( int port_index = 0; port_index < fNPorts; port_index++ ) 
     406                delete [] fPortBuffer[port_index]; 
     407            delete [] fPortBuffer; 
     408        } 
     409         
     410        void Init(session_params_t* params, uint32_t nports) 
     411        { 
     412            fNPorts = nports; 
     413            fPeriodSize = params->fPeriodSize; 
     414            fSubPeriodSize = params->fFramesPerPacket; 
     415            fSubPeriodBytesSize = fSubPeriodSize * sizeof ( sample_t ); 
     416            fPortBuffer = new sample_t* [fNPorts]; 
     417            for ( int port_index = 0; port_index < fNPorts; port_index++ ) 
     418                fPortBuffer[port_index] = new sample_t[fPeriodSize]; 
     419        } 
     420         
     421    }; 
     422 
     423    class SERVER_EXPORT NetSingleAudioBuffer : public NetAudioBuffer 
    262424    { 
    263425        private: 
    264             int fNPorts; 
    265             jack_nframes_t fPeriodSize; 
    266             jack_nframes_t fSubPeriodSize; 
    267             size_t fSubPeriodBytesSize; 
     426            JackPortList fPortBuffer; 
    268427            char* fNetBuffer; 
    269             sample_t** fPortBuffer; 
     428             
    270429        public: 
    271             NetAudioBuffer ( session_params_t* params, uint32_t nports, char* net_buffer ); 
    272             ~NetAudioBuffer(); 
     430            NetSingleAudioBuffer ( session_params_t* params, uint32_t nports, char* net_buffer ); 
     431            ~NetSingleAudioBuffer(); 
    273432 
    274433            size_t GetSize(); 
    275434            //jack<->buffer 
    276             void RenderFromJackPorts ( int subcycle ); 
    277             void RenderToJackPorts ( int subcycle ); 
     435            void RenderFromJackPorts (int subcycle ); 
     436            void RenderToJackPorts (int cycle, int subcycle); 
     437 
     438            void SetBuffer ( int index, sample_t* buffer ); 
     439            sample_t* GetBuffer ( int index ); 
     440             
     441            void FinishRenderToJackPorts (int cycle) {} 
     442    }; 
     443     
     444    #define AUDIO_BUFFER_SIZE 8 
     445     
     446    class SERVER_EXPORT NetBufferedAudioBuffer : public NetAudioBuffer 
     447    { 
     448     
     449        private: 
     450            char* fNetBuffer; 
     451            JackPortListAllocate fPortBuffer[AUDIO_BUFFER_SIZE]; 
     452            sample_t** fJackPortBuffer; 
     453            int fMaxCycle; 
     454             
     455        public: 
     456            NetBufferedAudioBuffer ( session_params_t* params, uint32_t nports, char* net_buffer ); 
     457            ~NetBufferedAudioBuffer(); 
     458 
     459            size_t GetSize(); 
     460            //jack<->buffer 
     461            void RenderFromJackPorts (int subcycle ); 
     462            void RenderToJackPorts ( int cycle, int subcycle); 
     463            void FinishRenderToJackPorts (int cycle); 
    278464 
    279465            void SetBuffer ( int index, sample_t* buffer ); 
  • jack2/branches/libjacknet/common/JackTools.h

    r3814 r3932  
    138138            T Add ( T measure_point ) 
    139139            { 
    140                                return fCurrentMeasure[fMeasureId++] = measure_point; 
     140                return fCurrentMeasure[fMeasureId++] = measure_point; 
    141141            } 
    142142 
  • jack2/branches/libjacknet/macosx/coreaudio/TiPhoneCoreAudioRenderer.cpp

    r3922 r3932  
    119119} 
    120120 
    121 int TiPhoneCoreAudioRenderer::OpenDefault(int bufferSize, int samplerate) 
     121int TiPhoneCoreAudioRenderer::Open(int bufferSize, int samplerate) 
    122122{ 
    123123    OSStatus err1; 
     
    126126        AudioStreamBasicDescription srcFormat, dstFormat; 
    127127     
    128     printf("OpenDefault fDevNumInChans = %ld fDevNumOutChans = %ld bufferSize = %ld samplerate = %ld\n", fDevNumInChans, fDevNumOutChans, bufferSize, samplerate); 
     128    printf("Open fDevNumInChans = %ld fDevNumOutChans = %ld bufferSize = %ld samplerate = %ld\n", fDevNumInChans, fDevNumOutChans, bufferSize, samplerate); 
    129129           
    130130    // Initialize and configure the audio session 
  • jack2/branches/libjacknet/macosx/coreaudio/TiPhoneCoreAudioRenderer.h

    r3922 r3932  
    7979        } 
    8080 
    81         int OpenDefault(int bufferSize, int sampleRate); 
     81        int Open(int bufferSize, int sampleRate); 
    8282        int Close(); 
    8383 
  • jack2/branches/libjacknet/macosx/iphone/main_master.mm

    r3924 r3932  
    7272    } 
    7373     
    74     if (audio_device.OpenDefault(buffer_size, sample_rate) < 0) { 
     74    if (audio_device.Open(buffer_size, sample_rate) < 0) { 
    7575        return -1; 
    7676    } 
  • jack2/branches/libjacknet/macosx/iphone/main_slave.mm

    r3924 r3932  
    1212#include "TiPhoneCoreAudioRenderer.h" 
    1313 
    14 #define NUM_INPUT 2 
    15 #define NUM_OUTPUT 2 
     14#define NUM_INPUT 1 
     15#define NUM_OUTPUT 1 
    1616 
    1717jack_net_slave_t* net; 
     
    3434{ 
    3535 
    36     jack_adapter_pull_and_push(adapter, audio_output_buffer, audio_input_buffer, buffer_size); 
     36    //jack_adapter_pull_and_push(adapter, audio_output_buffer, audio_input_buffer, buffer_size); 
     37     
     38    // Process input, produce output 
     39    if (audio_input == audio_output) { 
     40        // Copy input to output 
     41        for (int i = 0; i < audio_input; i++) { 
     42            memcpy(audio_output_buffer[i], audio_input_buffer[i], buffer_size * sizeof(float)); 
     43        } 
     44    } 
    3745    return 0; 
    3846} 
     
    4048static void SlaveAudioCallback(int frames, float** inputs, float** outputs, void* arg) 
    4149{ 
    42     jack_adapter_push_and_pull(adapter, inputs, outputs, frames); 
     50    //jack_adapter_push_and_pull(adapter, inputs, outputs, frames); 
    4351} 
     52 
     53//http://www.securityfocus.com/infocus/1884 
     54 
     55#define WIFI_MTU 1500 
     56 
    4457 
    4558int main(int argc, char *argv[]) { 
    4659     
    47     NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 
     60    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; 
    4861     
    49     jack_slave_t request = { NUM_INPUT, NUM_OUTPUT, 0, 0, DEFAULT_MTU, -1, JackSlowMode }; 
     62    jack_slave_t request = { NUM_INPUT, NUM_OUTPUT, 0, 0, WIFI_MTU, -1, JackSlowMode }; 
    5063    jack_master_t result; 
    5164 
    52     if ((net = jack_net_slave_open(DEFAULT_MULTICAST_IP, DEFAULT_PORT, "iPhone", &request, &result))  == 0) { 
     65    if ((net = jack_net_slave_open("169.254.136.64", DEFAULT_PORT, "iPhone", &request, &result))  == 0) { 
    5366        return -1; 
    5467    } 
     
    7083    } 
    7184     
    72     if (audio_device.OpenDefault(result.buffer_size, result.sample_rate) < 0) { 
     85    if (audio_device.Open(result.buffer_size, result.sample_rate) < 0) { 
    7386        return -1; 
    7487    }