Hi

I'm sure that someone is already working on them... just so as to
minimise duplication of efforts, I attach my attempt. Transport control
is missing, but the rest should be complete. 

Any feedback is greatly appreciated, especially regarding:
 - how to define a method that takes an array of 2 structs and writes on
them
 - what exactly the difference is between struct, [Compact] class and
class...
 - where to find more documentation about the [directives]

thanks,
regards
alberto

-- 
Alberto Colombo, MSc

PhD student at Digital Imaging Research Centre
Kingston University, London

e-mail: a.colo...@kingston.ac.uk
 phone: +44 (0)20 8547 8642
  http://cism.kingston.ac.uk/people/details.php?AuthorID=925


This email has been scanned for all viruses by the MessageLabs Email
Security System.
[CCode (lower_case_cprefix = "jack_", cheader_filename="jack/jack.h")]
namespace Jack{
    // note: there are no bindings for deprecated methods
    
    public const int MAX_FRAMES;
    public const int LOAD_INIT_LIMIT;
    public const string DEFAULT_AUDIO_TYPE;
    public const string DEFAULT_MIDI_TYPE;
    [CCode (cname="JackOpenOptions")]
    public const Options OpenOptions;
    [CCode (cname="JackLoadOptions")]
    public const Options LoadOptions;

    [SimpleType]
    [CCode (cname="jack_shmsize_t")]
    public struct ShmSize : int32 {}    
    [SimpleType]
    [CCode (cname="jack_nframes_t")]
    public struct NFrames : uint32 {}
    [SimpleType]
    [CCode (cname="jack_time_t")]
    public struct Time : uint64 {}
    [SimpleType]
    [CCode (cname="jack_intclient_t", cprefix="jack_internal_client", 
cheader_filename="jack/intclient.h")]
    public struct InternalClient : uint64 {
        public static void close(string name);
    }
    [Compact]
    [CCode (cname="jack_port_t", cprefix="jack_port_")]
    public class Port {
        public void* get_buffer(NFrames nframes);
        public string name();
        public string short_name();
        public int flags();
        public string type();
        public bool connected();
        public bool connected_to(string name);
        [CCode (array_null_terminated = true)]
        [NoArrayLength]
        public string[] get_connections();
        public NFrames get_latency();
        public NFrames get_total_latency();
        public void set_latency(NFrames nframes);
        public int set_name(string name);
        public int set_alias(string alias);
        public int unset_alias(string alias);
        public int get_aliases(ref string[2] aliases);
        public int request_monitor(bool onoff);
        public int ensure_monitor(bool onoff);
        public int monitoring_input();
        public static int name_size();
        public static int type_size();

        [CCode (cprefix="JackPort", cname="enum JackPortFlags")]
        [Flags]
        public enum Flags{
           IsInput,
           IsOutput,
           IsPhysical,
           CanMonitor,
           IsTerminal
        }        
    }
    [Compact]
    [CCode (cname="jack_client_t", free_function="jack_client_close", 
cprefix="jack_")]
    public class Client{
        // creation and manipulation
        [CCode (cname="jack_client_open")]
        public static Client open(string name, Jack.Options options, out 
Jack.Status status, ...);
        [CCode (cname="jack_client_name_size")]
        public static int get_name_size();
        [CCode (cname="jack_get_client_name")]
        public string get_name();
        public int activate();
        public int deactivate();
        [CCode (cname="jack_client_thread_id")]
        public GLib.Thread get_thread_id();
        
        // setting callbacks 
        public int set_thread_init_callback(ThreadInitCallback cb);
        public void on_shutdown(ShutdownFunc f);
        public int set_process_callback(ProcessCallback cb);
        public int set_freewheel_callback(FreewheelCallback cb);
        public int set_buffer_size_callback(BufferSizeCallback cb);
        public int set_sample_rate_callback(SampleRateCallback cb);
        public int set_client_registration_callback(ClientRegistrationCallback 
cb);
        public int set_port_registration_callback(PortRegistrationCallback cb);
        public int set_port_connect_callback(PortConnectCallback cb);
        public int set_graph_order_callback(GraphOrderCallback cb);
        public int set_xrun_callback(XRunCallback cb);
        
        // controlling and querying server operations
        [CCode (cname="jack_client_create_thread")]
        public int create_thread(out GLib.Thread thread, int priority, bool 
realtime, ThreadCallback cb);
        [CCode (cname="jack_client_real_time_priority")]
        public int get_real_time_priority();
        [CCode (cname="jack_client_max_real_time_priority")]
        public int get_max_real_time_priority();
        public int set_freewheel(bool onoff);
        public int set_buffer_size(NFrames nframes);
        public NFrames get_sample_rate();
        public NFrames get_buffer_size();
        public float cpu_load();
        
        // creating and manipulating ports
        public Port port_register(string name, string type, Port.Flags flags, 
ulong buffer_size);
        public int port_unregister(Port p);
        public bool port_is_mine(Port p);
        [CCode (array_null_terminated = true)]
        [NoArrayLength]
        public string[] port_get_all_connections(Port p);
        public int recompute_total_latency(Port p);
        public int recompute_total_latencies();
        public int port_request_monitor_by_name(string port_name, bool onoff);
        public int connect(string source_port, string destination_port);
        public int disconnect(string source_port, string destination_port);
        public int port_disconnect(Port p);
        
        // looking up ports
        [CCode (array_null_terminated = true)]
        [NoArrayLength]
        public string[] get_ports(string name_pattern, string type_pattern, 
Port.Flags flags);
        public Port port_by_name(string name);
        public Port port_by_id(PortId id);
        
        // handling time
        public NFrames frames_since_cycle_start();
        public NFrames frame_time();
        public NFrames last_frame_time();
        public Time frames_to_time(NFrames nframes);
        public NFrames time_to_frames(Time t);
        public Time get_time();
        
        // non-callback API
        public NFrames cycle_wait();
        public void cycle_signal(bool should_exit);
        public int set_process_thread(ThreadCallback cb);
        
        // statistics
        [CCode (cheader_filename="jack/statistics.h")]
        public float get_max_delayed_usecs();
        [CCode (cheader_filename="jack/statistics.h")]
        public float get_xrun_delayed_usecs();
        [CCode (cheader_filename="jack/statistics.h")]
        public void reset_max_delayed_usecs();
        
        //internal clients
        [CCode (cheader_filename="jack/intclient.h")]
        public string get_internal_client_name(InternalClient intclient);
        [CCode (cheader_filename="jack/intclient.h")]
        public InternalClient internal_client_handle(string name, out Status s);
        public InternalClient internal_client_load(string name, Options opts, 
out Status s, ...);
        public Status internal_client_unload(InternalClient intclient);
    }
    [SimpleType]
    [CCode (cname="jack_port_id_t")]
    public struct PortId : uint32 {}
    
    public delegate void* ThreadCallback();
    public delegate void ThreadInitCallback();
    public delegate void ShutdownFunc();
    public delegate int ProcessCallback(NFrames nframes);
    public delegate void FreewheelCallback(bool starting);
    public delegate int BufferSizeCallback(NFrames nframes);
    public delegate int SampleRateCallback(NFrames nframes);
    public delegate void ClientRegistrationCallback(string name, bool register);
    public delegate void PortRegistrationCallback(PortId id, bool register);
    public delegate void PortConnectCallback(PortId a, PortId b, bool connect);
    public delegate int GraphOrderCallback();
    public delegate int XRunCallback();
    
    [SimpleType]
    [CCode (cname="jack_default_audio_sample_t")]
    public struct DefaultAudioSample : float {}
        
    [CCode (cprefix="Jack", cname="jack_options_t")]
    [Flags]
    public enum Options{
        NullOption, 
        NoStartServer, 
        UseExactName, 
        ServerName, 
        LoadName, 
        LoadInit
    }
    
    [CCode (cprefix="Jack", cname="jack_status_t")]
    [Flags]
    public enum Status{
        Failure, 
        InvalidOption, 
        NameNotUnique, 
        ServerStarted, 
        ServerFailed, 
        ServerError,
        NoSuchClient,
        LoadFailure,
        InitFailure,
        ShmFailure,
        VersionError
    }
    
    public int drop_real_time_scheduling(GLib.Thread t);
    public int acquire_real_time_scheduling(GLib.Thread t, int priority);
    
    // error / information output
    public static delegate void MessageFunc(string msg);
    void set_error_function(MessageFunc f);
    void set_info_function(MessageFunc f);    
    public MessageFunc error_callback;
    public MessageFunc info_callback;
    [CCode (cname="default_jack_error_callback")]
    public void default_error_callback(string msg);
    [CCode (cname="silent_jack_error_callback")]
    public void silent_error_callback(string msg);
    
    // MIDI
    [CCode (lower_case_cprefix="jack_midi_")]
    namespace Midi{
        [SimpleType]
        [CCode (cname="jack_midi_data_t")]
        public struct Data : uchar {}
        
        [CCode (cname="jack_midi_event_t", cprefix="jack_midi_event_")]
        public struct Event{
            public NFrames time;
            public size_t size;
            [NoArrayLength]
            public Data[] buffer;
            public static int get(void *port_buffer, Event e, NFrames 
event_index);
            [NoArrayLength]
            public static Data[] reserve(void *port_buffer, NFrames time, 
size_t data_size);
            public static int write(void *port_buffer, NFrames time, Data data, 
size_t data_size);
        }
        public NFrames get_event_count(void *port_buffer);
        public void clear_buffer(void *port_buffer);
        public size_t max_event_size(void *port_buffer);
        public NFrames get_lost_event_count(void *port_buffer);
    }
    
    [Compact]
    [CCode (cname="jack_ringbuffer_t", cprefix="jack_ringbuffer_", 
free_function="jack_ringbuffer_free")]
    public class Ringbuffer{
        [CCode (cname="jack_ringbuffer_data_t")]
        public struct Data {
            public char[] buf;
        }
        
        [NoArrayLength]
        public char[] buf;
        public size_t write_ptr;
        public size_t read_ptr;
        public size_t size;
        public size_t size_mask;
        public int mlocked;
        
        public static Ringbuffer create(size_t sz);
        public void get_read_vector(ref Data[2] vec);
        public void get_write_vector(ref Data[2] vec);
        public size_t read(char[] dest);
        public size_t peek(char[] dest);
        public void read_advance(size_t cnt);
        public size_t read_space();
        public int mlock();
        public void reset();
        public size_t write(char[] src);
        public void write_advance(size_t cnt);
        public size_t write_space();        
    }
    
}
_______________________________________________
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to