traverso-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Traverso-commit] traverso/src/engine CoreAudioDriver.cpp CoreAud...


From: Remon Sijrier
Subject: [Traverso-commit] traverso/src/engine CoreAudioDriver.cpp CoreAud...
Date: Fri, 28 Nov 2008 19:00:57 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       08/11/28 19:00:57

Modified files:
        src/engine     : CoreAudioDriver.cpp CoreAudioDriver.h 

Log message:
        * added attach() function

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/engine/CoreAudioDriver.cpp?cvsroot=traverso&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/traverso/src/engine/CoreAudioDriver.h?cvsroot=traverso&r1=1.4&r2=1.5

Patches:
Index: CoreAudioDriver.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/engine/CoreAudioDriver.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- CoreAudioDriver.cpp 24 Nov 2008 21:11:04 -0000      1.6
+++ CoreAudioDriver.cpp 28 Nov 2008 19:00:57 -0000      1.7
@@ -451,6 +451,86 @@
 
 
 
+int CoreAudioDriver::attach()
+{
+       int port_flags;
+       channel_t chn;
+       AudioChannel* chan;
+       char buf[32];
+       char channel_name[64];
+       OSStatus err;
+       UInt32 size;
+       UInt32 value1,value2;
+       Boolean isWritable;
+               
+       device->set_buffer_size (frames_per_cycle);
+       device->set_sample_rate (frame_rate);
+
+       port_flags = PortIsOutput|PortIsPhysical|PortIsTerminal;
+       
+       for (chn = 0; chn < capture_nchannels; chn++) {
+               err = AudioDeviceGetPropertyInfo(device_id, chn + 1, true, 
kAudioDevicePropertyChannelName, &size, &isWritable);
+               if (err == noErr && size > 0)  {
+                       err = AudioDeviceGetProperty(device_id, chn + 1, true, 
kAudioDevicePropertyChannelName, &size, channel_name);   
+                       if (err != noErr) 
+                               JCALog("AudioDeviceGetProperty 
kAudioDevicePropertyChannelName error \n");
+                       snprintf(buf, sizeof(buf) - 1, "%s:out_%s%lu", 
capture_driver_name, channel_name, chn + 1);
+               } else {
+                       snprintf(buf, sizeof(buf) - 1, "%s:out%lu", 
capture_driver_name, chn + 1);
+               }
+       
+               chan = device->register_capture_channel(buf, "32 bit float 
audio", port_flags, frames_per_cycle, chn);
+               chan->set_latency( frames_per_cycle + capture_frame_latency );
+               captureChannels.append(chan);
+               
+               size = sizeof(UInt32);
+               value1 = value2 = 0;
+               err = AudioDeviceGetProperty(device_id, 0, true, 
kAudioDevicePropertyLatency, &size, &value1);  
+               if (err != noErr) 
+                       JCALog("AudioDeviceGetProperty 
kAudioDevicePropertyLatency error \n");
+               err = AudioDeviceGetProperty(device_id, 0, true, 
kAudioDevicePropertySafetyOffset, &size, &value2);     
+               if (err != noErr) 
+                       JCALog("AudioDeviceGetProperty 
kAudioDevicePropertySafetyOffset error \n");
+               
+       }
+       
+       port_flags = PortIsInput|PortIsPhysical|PortIsTerminal;
+
+       for (chn = 0; chn < playback_nchannels; chn++) {
+               err = AudioDeviceGetPropertyInfo(device_id, chn + 1, false, 
kAudioDevicePropertyChannelName, &size, &isWritable);
+               if (err == noErr && size > 0)  {
+                       err = AudioDeviceGetProperty(device_id, chn + 1, false, 
kAudioDevicePropertyChannelName, &size, channel_name);  
+                       if (err != noErr) 
+                               JCALog("AudioDeviceGetProperty 
kAudioDevicePropertyChannelName error \n");
+                       snprintf(buf, sizeof(buf) - 1, "%s:in_%s%lu", 
playback_driver_name, channel_name, chn + 1);
+               } else {
+                       snprintf(buf, sizeof(buf) - 1, "%s:in%lu", 
playback_driver_name, chn + 1);
+               }
+
+               chan = device->register_playback_channel(buf, "32 bit float 
audio", port_flags, frames_per_cycle, chn);
+               chan->set_latency( frames_per_cycle + capture_frame_latency );
+               playbackChannels.append(chan);
+
+               size = sizeof(UInt32);
+               value1 = value2 = 0;
+               err = AudioDeviceGetProperty(device_id, 0, false, 
kAudioDevicePropertyLatency, &size, &value1); 
+               if (err != noErr) 
+                       JCALog("AudioDeviceGetProperty 
kAudioDevicePropertyLatency error \n");
+               err = AudioDeviceGetProperty(device_id, 0, false, 
kAudioDevicePropertySafetyOffset, &size, &value2);    
+               if (err != noErr) 
+                       JCALog("AudioDeviceGetProperty 
kAudioDevicePropertySafetyOffset error \n");
+       }
+       
+
+       // Input buffers do no change : prepare them only once
+       for (chn = 0; chn < capture_nchannels; chn++) {
+               input_list->mBuffers[chn].mData = 
(audio_sample_t*)(captureChannels.at(chn)->get_buffer(frames_per_cycle));
+       }
+       
+       return 1;
+}
+
+
 int CoreAudioDriver::setup(bool capture, bool playback, const QString & 
cardDevice)
 {
        return -1;
@@ -481,3 +561,4 @@
        CoreAudioDriver* driver = (CoreAudioDriver*)inClientData;
        return driver->notification(inDevice, inChannel, isInput, inPropertyID);
 }
+

Index: CoreAudioDriver.h
===================================================================
RCS file: /sources/traverso/traverso/src/engine/CoreAudioDriver.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- CoreAudioDriver.h   24 Nov 2008 19:27:16 -0000      1.4
+++ CoreAudioDriver.h   28 Nov 2008 19:00:57 -0000      1.5
@@ -54,7 +54,7 @@
 //     int _write(nframes_t nframes);
 //     int _null_cycle(nframes_t nframes);
 //     int _run_cycle();
-//     int attach();
+       int attach();
 //     int detach();
 //     int bufsize(nframes_t nframes);
 //     int restart();
@@ -69,6 +69,9 @@
        channel_t playback_nchannels;
        channel_t capture_nchannels;
 
+       char capture_driver_name[256];
+       char playback_driver_name[256];
+
        int xrun_detected;
        int null_cycle_occured;
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]