• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            Cpper
            C/C++高級工程師 Android高級軟件工程師 IT集成工程師 音頻工程師 熟悉c,c++,java,c#,py,js,asp等多種語言 程序猿
            之前寫了一個dll,具體在這里
            http://www.shnenglu.com/gaimor/anarchive/2013/07/11/201711.html
            現在想增加一個c#綁定,上網搜了下
            很簡單就實現了

            實現后的cs代碼如下(當前只實現了一部分):
            using System;
            using System.Runtime.InteropServices;  

            namespace gaudio
            {   
                
            class GAudio
                {   
                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_init")]
                    
            public static extern void gaudio_init(string path);

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_deinit")]
                    
            public static extern void gaudio_deinit();

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_error_get")]
                    
            public static extern int gaudio_error_get();

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_is_support")]
                    
            public static extern int gaudio_is_support(int flag,int value);

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_set_float")]
                    
            public static extern void gaudio_set_float(int flag,float value);

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_get_float")]
                    
            public static extern void gaudio_get_float(int flag,ref float value);
                    
                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_set_int32")]
                    
            public static extern void gaudio_set_int32(int flag,int value);

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_get_int32")]
                    
            public static extern void gaudio_get_int32(int flag,ref int value);

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_set_string")]
                    
            public static extern void gaudio_set_string(int flag,string value);

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_get_string")]
                    
            public static extern int gaudio_get_string(int flag,ref string value);
                    
                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_listener_set_float3")]
                    
            public static extern void gaudio_listener_set_float3(int flag,float x,float y,float z);

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_listener_get_float3")]
                    
            public static extern void gaudio_listener_get_float3(int flag,ref float x,ref float y,ref float z);
                  
                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_source_create_from_file")]
                    
            public static extern IntPtr gaudio_source_create_from_file(string file,int flag);

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_source_destroy")]
                    
            public static extern void gaudio_source_destroy(IntPtr source);

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_source_start")]
                    
            public static extern void gaudio_source_start(IntPtr source,int flag);

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_source_start_3d")]
                    
            public static extern void gaudio_source_start_3d(IntPtr source,int flag);

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_source_pause")]
                    
            public static extern void gaudio_source_pause(IntPtr source);

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_source_stop")]
                    
            public static extern void gaudio_source_stop(IntPtr source);

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_source_seek")]
                    
            public static extern void gaudio_source_seek(IntPtr source,int seek);

                    
            public delegate int gposition(IntPtr source,int position);

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_source_set_position_callback")]
                    
            public static extern void gaudio_source_set_position_callback(IntPtr source,gposition cb);

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_source_set_float")]
                    
            public static extern void gaudio_source_set_float(IntPtr source,int flag,float value);

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_source_get_float")]
                    
            public static extern void gaudio_source_get_float(IntPtr source,int flag,ref float value);

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_source_set_int32")]
                    
            public static extern void gaudio_source_set_int32(IntPtr source,int flag,int value);

                    [DllImport(
            "gaudio.dll",EntryPoint = "gaudio_source_get_int32")]
                    
            public static extern void gaudio_source_get_int32(IntPtr source,int flag,ref int value);

                    
            public delegate int gread(IntPtr buffer,int size,int count,IntPtr ctx);
                    
            public delegate int gseek(IntPtr ctx,int offset,int mode);
                    
            public delegate int gtell(IntPtr ctx);
                    
            public delegate int gclose(IntPtr ctx);
                }
            }

            原始的c代碼如下:

            #if defined(__cplusplus)
            extern "C"
            {
            #endif /* __cplusplus */

            /*************************************************************************
             * Doxygen documentation
             ************************************************************************
            */

            /* ---------------- GAudio library related system specific defines ----------------- */
            #if !defined(WIN32) && !defined(__linux__)
               
            #error "gaudio library don't support this os at present"
            #endif

            #if defined(_WIN32)
             
            #define GAPIENTRY __cdecl
            #else
             
            #define GAPIENTRY
            #endif

            #if defined(BUILDING)
            #ifdef _WIN32
            # define GAPI __declspec(dllexport)
            #else
            # define GAPI
            #endif
            #else
            #ifdef _WIN32
            # define GAPI __declspec(dllimport)
            #else
            # define GAPI
            #endif
            #endif

            #ifndef NULL
               
            #define NULL 0
            #endif

            #ifndef FALSE
            #define FALSE   0
            #endif

            #ifndef TRUE
            #define TRUE    1
            #endif

            /*************************************************************************
             * GAudio library API tokens
             ************************************************************************
            */

            #define AUDIO_DRIVER_NULL      0
            #define AUDIO_DRIVER_WINMM     1
            #define AUDIO_DRIVER_DSOUND    2
            #define AUDIO_DRIVER_ALSA      3
            #define AUDIO_DRIVER_OSS       4
            #define AUDIO_DRIVER_PORTAUDIO 5

            #define AUDIO_PLUGIN_DECODER 1
            #define AUDIO_PLUGIN_EFFECT  2
            #define AUDIO_PLUGIN_DRIVER  3

            #define MAX_SOURCE  8
            #define MAX_DECODER 32
            #define MAX_EFFECT  8

            #define AUDIO_ENUM_POSITION    1
            #define AUDIO_ENUM_VELOCITY    2
            #define AUDIO_ENUM_FORWARD     3
            #define AUDIO_ENUM_UP          4
            #define AUDIO_ENUM_SAMPLERATE  5
            #define AUDIO_ENUM_CHANNEL     6
            #define AUDIO_ENUM_FORMAT      7
            #define AUDIO_ENUM_DURATION    8
            #define AUDIO_ENUM_LOOP        9
            #define AUDIO_ENUM_GAIN        10
            #define AUDIO_ENUM_GAIN_LEFT   11
            #define AUDIO_ENUM_GAIN_RIGHT  12
            #define AUDIO_ENUM_SILENCE     13
            #define AUDIO_ENUM_TITLE       14
            #define AUDIO_ENUM_TRACK       15
            #define AUDIO_ENUM_ALBUM       16
            #define AUDIO_ENUM_ARTIST      17
            #define AUDIO_ENUM_PUBLISHDATE 18
            #define AUDIO_ENUM_GENRE       19
            #define AUDIO_ENUM_COMMENT     20
            #define AUDIO_ENUM_AUDIO       21
            #define AUDIO_ENUM_BITERATE    22
            #define AUDIO_ENUM_VERSION     23
            #define AUDIO_ENUM_DRIVER      24
            #define AUDIO_ENUM_BALANCE     25
            #define AUDIO_ENUM_CROSSFEED   26
            #define AUDIO_ENUM_SOUNDFONT   27

            #define BALANCE_MIN     -10
            #define BALANCE_MAX      10
            #define BALANCE_DEFAULT   0

            #define AUDIO_CROSSEFED_NONE    -1
            #define AUDIO_CROSSFEED_MIN     0
            #define AUDIO_CROSSFEED_MAX     2
            #define AUDIO_CROSSFEED_DEFAULT 1

            typedef int32_t(GAPIENTRY
            * gread)(void*,int32_t,int32_t,void*);
            typedef int32_t(GAPIENTRY
            * gseek)(void*,int32_t,int32_t);
            typedef int32_t(GAPIENTRY
            * gtell)(void*);
            typedef int32_t(GAPIENTRY
            * gclose)(void*);

            typedef 
            struct gsource   gsource;
            typedef 
            struct geffect   geffect;
            typedef 
            struct grecorder grecorder;

            /*************************************************************************
             * GAudio API functions
             ************************************************************************
            */

            /*! @brief Initializes the GAudio library.
             *
             *  This function initializes the GAudio library. Before any GAudio functions can
             *  be used, GAudio must be initialized, and before a program terminates GAudio
             *  should be terminated in order to free any resources allocated during or
             *  after initialization.
             *
             *  If this function fails, it calls @ref gaudio_deinit before returning.  If it
             *  succeeds, you should call @ref gaudio_deinit before the program exits.
             *
             *  Additional calls to this function after successful initialization but before
             *  termination will succeed but will do nothing.
             *
             *  @param[in] add-ons Where to search and load plug-ins which GAudio needed.
             *
             *  @return `TRUE` if successful, or `FALSE` if an error occurred.
             *
             *  @note This function may only be called from the main thread.
             *
             *  @note This function may take several seconds to complete on some systems,
             *  while on other systems it may take only a fraction of a second to complete.
             *
             *  @sa gaudio_deinit
             *
             *  @ingroup init
             
            */
            extern GAPI void gaudio_init(const char* addons);

            /*! @brief Terminates the GAudio library.
             *
             *  This function frees any allocated resources and sets the library to an
             *  uninitialized state.  Once this is called, you must again call @ref gaudio_init
             *  successfully before you will be able to use most GAudio functions.
             *
             *  If GAudio has been successfully initialized, this function should be called
             *  before the program exits.  If initialization fails, there is no need to call
             *  this function, as it is called by @ref gaudio_init before it returns failure.
             *
             *  @remarks This function may be called before @ref gaudio_init.
             *
             *  @note This function may only be called from the main thread.
             *
             *  @sa gaudio_init
             *
             *  @ingroup init
             
            */
            extern GAPI void gaudio_deinit();

            /* Audio format type */
            #define AUDIO_FORMAT_TYPE_NONE      -1
            #define AUDIO_FORMAT_TYPE_INT4      0
            #define AUDIO_FORMAT_TYPE_INT8      1
            #define AUDIO_FORMAT_TYPE_UINT8     2
            #define AUDIO_FORMAT_TYPE_INT16     3
            #define AUDIO_FORMAT_TYPE_UINT16    4
            #define AUDIO_FORMAT_TYPE_INT24     5
            #define AUDIO_FORMAT_TYPE_INT32     6
            #define AUDIO_FORMAT_TYPE_UINT32    7
            #define AUDIO_FORMAT_TYPE_INT64     8
            #define AUDIO_FORMAT_TYPE_FLOAT     9
            #define AUDIO_FORMAT_TYPE_DOUBLE    10
            #define AUDIO_FORMAT_TYPE_ULAW      11
            #define AUDIO_FORMAT_TYPE_ALAW      12
            #define AUDIO_FORMAT_TYPE_VOX_ADPCM 13
            #define AUDIO_FORMAT_TYPE_MS_ADPCM  14
            #define AUDIO_FORMAT_TYPE_GSM610    15
            #define AUDIO_FORMAT_TYPE_IMA_ADPCM 16
            #define AUDIO_FORMAT_TYPE_DPCM8     17
            #define AUDIO_FORMAT_TYPE_DPCM16    18
            #define AUDIO_FORMAT_TYPE_G723_24   19
            #define AUDIO_FORMAT_TYPE_G723_32   20
            #define AUDIO_FORMAT_TYPE_G723_40   21
            #define AUDIO_FORMAT_TYPE_DWVW_12   22
            #define AUDIO_FORMAT_TYPE_DWVW_16   23
            #define AUDIO_FORMAT_TYPE_DWVW_24   24
            #define AUDIO_FORMAT_TYPE_DWVW_N    25
            #define AUDIO_FORMAT_TYPE_VORBIS    26
            #define AUDIO_FORMAT_TYPE_MPC       27
            #define AUDIO_FORMAT_TYPE_MAX       100

            /* Channel type */
            #define DEVICE_CHANNEL_MONO    1
            #define DEVICE_CHANNEL_STEREO  (DEVICE_CHANNEL_MONO+1)
            #define DEVICE_CHANNEL_QUAD    (DEVICE_CHANNEL_STEREO+1)
            #define DEVICE_CHANNEL_5POINT1 (DEVICE_CHANNEL_QUAD+1)
            #define DEVICE_CHANNEL_6POINT1 (DEVICE_CHANNEL_5POINT1+1)
            #define DEVICE_CHANNEL_7POINT1 (DEVICE_CHANNEL_6POINT1+1)

            #define AUDIO_VERSON       0
            #define AUDIO_PLAY_MODE    1
            #define AUDIO_RECORD_MODE  2

            /* GAudio plugin type */
            #define AUDIO_PLUGIN_AUDIO    1
            #define AUDIO_PLUGIN_EFFECT   2
            #define AUDIO_PLUGIN_DRIVER   3
            #define AUDIO_PLUGIN_RECORDER 4

            /* Audio file type */
            #define AUDIO_FORMAT_NONE   -1
            #define AUDIO_FORMAT_RAW     0
            #define AUDIO_FORMAT_WAV     1
            #define AUDIO_FORMAT_AU      2
            #define AUDIO_FORMAT_AIFF    3
            #define AUDIO_FORMAT_FLAC    4
            #define AUDIO_FORMAT_MP2     5
            #define AUDIO_FORMAT_MP3     6
            #define AUDIO_FORMAT_APE     7
            #define AUDIO_FORMAT_AAC     8
            #define AUDIO_FORMAT_CAF     9
            #define AUDIO_FORMAT_OGG     10
            #define AUDIO_FORMAT_VOC     11
            #define AUDIO_FORMAT_WV      12
            #define AUDIO_FORMAT_MIDI    13
            #define AUDIO_FORMAT_XM      14
            #define AUDIO_FORMAT_S3M     15
            #define AUDIO_FORMAT_MOD     16
            #define AUDIO_FORMAT_IT      17
            #define AUDIO_FORMAT_WMA     18
            #define AUDIO_FORMAT_WMV     19
            #define AUDIO_FORMAT_CD      20
            #define AUDIO_FORMAT_VQF     21
            #define AUDIO_FORMAT_MPC     22
            #define AUDIO_FORMAT_TTA     23
            #define AUDIO_FORMAT_AC3     24

            /* Audio effect type */
            #define AUDIO_EFFECT_NONE                  -1
            #define AUDIO_EFFECT_PHASER                 0
            #define AUDIO_EFFECT_INVERT                 1
            #define AUDIO_EFFECT_SWAP_CHANNEL           2
            #define AUDIO_EFFECT_MERGE_CHANNEL          3
            #define AUDIO_EFFECT_SPEED_CHANGER          4
            #define AUDIO_EFFECT_ECHO                   5
            #define AUDIO_EFFECT_REVERB                 6
            #define AUDIO_EFFECT_FFT                    7
            #define AUDIO_EFFECT_EQUALIZER              8
            #define AUDIO_EFFECT_BASSBOOST              9
            #define AUDIO_EFFECT_CHORUS                 10
            #define AUDIO_EFFECT_STEREO_ENHANCE         11
            #define AUDIO_EFFECT_DISTORTION             12
            #define AUDIO_EFFECT_FOLDBACK_DISTORTION    13
            #define AUDIO_EFFECT_FLANGER                14
            #define AUDIO_EFFECT_AUTOWAH                15
            #define AUDIO_EFFECT_COMPRESSER             16
            #define AUDIO_EFFECT_MODULATOR              17
            #define AUDIO_EFFECT_FADE_IN                18
            #define AUDIO_EFFECT_FADE_OUT               19
            #define AUDIO_EFFECT_LEVELLER               20
            #define AUDIO_EFFECT_ZIPPER                 21

            extern GAPI int32_t gaudio_is_support(int32_t,int32_t);

            extern GAPI void gaudio_set_float(int32_t,float);
            extern GAPI void gaudio_get_float(int32_t,float*);
            extern GAPI void gaudio_set_int32(int32_t,int32_t);
            extern GAPI void gaudio_get_int32(int32_t,int32_t*);
            extern GAPI void gaudio_set_string(int32_t,const char*);
            extern GAPI int32_t gaudio_get_string(int32_t,char*);

            /*! @defgroup errors Error codes
             *  @ingroup error
             *  @{ 
            */
            /*! @brief GAudio has not been initialized.
             
            */
            #define AUDIO_NO_ERROR      0
            /*! @brief GAudio has not been initialized.
             
            */
            #define AUDIO_NOT_INIT      1
            #define AUDIO_BAD_TAG       2
            #define AUDIO_BAD_VALUE     3
            /*! @brief GAudio could not support for the requested client API on the
             *  system.
             
            */
            #define AUDIO_NOT_SUPPORT   4
            #define AUDIO_BAD_OPERATION 5
            /*! @brief A memory allocation failed.
             
            */
            #define AUDIO_OUT_OF_MEMORY 6
            #define AUDIO_OVER_COUNT    7
            #define AUDIO_INNER_ERROR   8

            extern GAPI int32_t gaudio_error_get();
            extern GAPI void gaudio_source_set_float(gsource*,int32_t,float);
            extern GAPI void gaudio_source_get_float(gsource*,int32_t,float*);
            extern GAPI void gaudio_source_set_int32(gsource*,int32_t,int32_t);
            extern GAPI void gaudio_source_get_int32(gsource*,int32_t,int32_t*);
            extern GAPI int32_t gaudio_source_get_string(gsource*,int32_t,char*);
            extern GAPI void gaudio_listener_set_float3(int32_t,float,float,float);
            extern GAPI void gaudio_listener_get_float3(int32_t,float*,float*,float*);

            /*! @brief Create gsource from given audio file name.
             *
             *  This function create gsource from given audio file name,
             *
             *  @param[in] file The file that will be loaded.
             *  @param[in] flag A flag value which script the load mode
             *  @return An gsource instance pointer, or `NULL` if the error occur.
             *
             *  @note This function may only be called from the main thread.
             *
             *  @sa gaudio_source_create_from_buffer
             *  @sa gaudio_source_create_from_virtual_io
             *  @sa gaudio_source_create_from_buffer2
             *  @sa gaudio_source_destroy
             *
             *  @ingroup gsource
             
            */
            extern GAPI gsource* gaudio_source_create_from_file(const char* file,int32_t flag);
            /*! @brief Create gsource by given buffer
             *
             *  This function create gsource from given buffer, the buffer length is pointed by user.
             *
             *  @param[in] buffer The buffer that will be loaded.
             *  @param[in] length The length of buffer
             *  @return An gsource instance pointer, or `NULL` if the error occur.
             *
             *  @note This function may only be called from the main thread.
             *
             *  @sa gaudio_source_create_from_file
             *  @sa gaudio_source_create_from_virtual_io
             *  @sa gaudio_source_create_from_buffer2
             *  @sa gaudio_source_destroy
             *
             *  @ingroup gsource
             
            */
            extern GAPI gsource* gaudio_source_create_from_buffer(int8_t* buffer,uint32_t length);
            /*! @brief Create gsource by user io
             *
             *  This function create gsource from user io, the io operation is pointed by user.
             *
             *  @param[in] read The read callback function.
             *  @param[in] seek The seek callback function.
             *  @param[in] tell The tell callback function.
             *  @param[in] close The close callback function.
             *  @param[in] user The user client data pointer. 
             *  @return An gsource instance pointer, or `NULL` if the error occur.
             *
             *  @note This function may only be called from the main thread.
             *
             *  @sa gaudio_source_create_from_file
             *  @sa gaudio_source_create_from_buffer
             *  @sa gaudio_source_create_from_buffer2
             *  @sa gaudio_source_destroy
             *
             *  @ingroup gsource
             
            */
            extern GAPI gsource* gaudio_source_create_from_virtual_io(gread read,gseek seek,gtell tell,gclose close,void* user);
            /*! @brief Create gsource by given pcm data
             *
             *  This function create gsource from user io, the io operation is pointed by user.
             *
             *  @param[in] samplerate The given source's samplerate.
             *  @param[in] channels The given source's chgannels.
             *  @param[in] format The given source's format.
             *  @param[in] pcm The given source's data buffer.
             *  @param[in] length The length of given source data. 
             *  @return An gsource instance pointer, or `NULL` if the error occur.
             *
             *  @note This function may only be called from the main thread.
             *
             *  @sa gaudio_source_create_from_file
             *  @sa gaudio_source_create_from_buffer
             *  @sa gaudio_source_create_from_virtual_io
             *  @sa gaudio_source_destroy
             *
             *  @ingroup gsource
             
            */
            extern GAPI gsource* gaudio_source_create_from_buffer2(uint32_t samplerate,uint32_t channels,uint32_t format,int8_t* pcm,uint32_t length);
            /*! @brief Destroy gsource instance.
             *
             *  This function destroy given gsource instance,
             *
             *  @param[in] source A gsource instance which will be destroyed.
             *
             *  @note This function may only be called from the main thread.
             *
             *  @sa gaudio_source_create_from_file
             *  @sa gaudio_source_create_from_buffer
             *  @sa gaudio_source_create_from_virtual_io
             *  @sa gaudio_source_create_from_buffer2
             *
             *  @ingroup gsource
             
            */
            extern GAPI void GAPIENTRY gaudio_source_destroy(gsource* source);
            /*! @brief The function signature for source content finish callbacks.
             *
             *  This is the function signature for source finish callback functions.
             *
             *  @param[in] source The source whose content needs to be triggered.
             *
             *  @sa gaudio_source_set_finish_callback
             *
             *  @ingroup gsource
             
            */
            typedef 
            void(GAPIENTRY* gfinish)(gsource* source);
            /*! @brief Sets the gsource callback.
             *
             *  This function sets the playing finished callback of the specified gsource, which is
             *  called when source playing finished.
             *
             *  @param[in] source The source whose callback to set.
             *  @param[in] finish The new gfinish callback.
             *
             *  @ingroup gsource
             
            */
            extern GAPI void gaudio_source_set_finish_callback(gsource* source,gfinish finish);
            /*! @brief The function signature for gsource error callbacks.
             *
             *  This is the function signature for gsource error callback functions.
             *
             *  @param[in] source The source whose content needs to be triggered.
             *
             *  @sa gaudio_source_set_error_callback
             *
             *  @ingroup gsource
             
            */
            typedef 
            void(GAPIENTRY* gerror)(gsource*,int32_t,int32_t);
            /*! @brief Sets the gsource error callback.
             *
             *  This function sets the playing error callback of the specified gsource, which is
             *  called when error occur.
             *
             *  @param[in] source The source whose callback to set.
             *  @param[in] error The error callback function.
             *
             *  @ingroup gsource
             
            */
            extern GAPI void gaudio_source_set_error_callback(gsource* source,gerror error);
            extern GAPI void gaudio_source_set(gsource*,int32_t,float,float,float);
            extern GAPI void gaudio_source_get(gsource*,int32_t,float*,float*,float*);
            extern GAPI void gaudio_source_start(gsource* source,int32_t flag);
            extern GAPI void gaudio_source_start_3d(gsource*,int32_t);
            /*! @brief pause the specified audio source.
             *
             *  This function pause the specified audio source, if it was previously
             *  playing.
             *
             *  @param[in] source The audio source to pause.
             *
             *  @sa gaudio_source_start
             *  @sa gaudio_source_stop
             *
             *  @ingroup gsource
             
            */
            extern GAPI void gaudio_source_pause(gsource* source);
            /*! @brief stop the specified audio source.
             *
             *  This function stop the specified audio source, if it was previously
             *  playing or pause.
             *
             *  @param[in] source The audio source to stop.
             *
             *  @sa gaudio_source_start
             *  @sa gaudio_source_pause
             *
             *  @ingroup gsource
             
            */
            extern GAPI void gaudio_source_stop(gsource* source);
            /*! @brief seek the specified audio source to given position.
             *
             *  This function seek the specified audio source, if it was previously
             *  playing or pause.
             *
             *  @param[in] source The audio source to seek.
             *
             *  @sa gaudio_source_start
             *  @sa gaudio_source_stop
             *  @sa gaudio_source_seek
             *
             *  @ingroup gsource
             
            */
            extern GAPI void gaudio_source_seek(gsource* source,int32_t missecond);
            /*! @brief The function signature for gsource position callbacks.
             *
             *  This is the function signature for gsource position callback functions.
             *
             *  @param[in] source The source whose content needs to be triggered.
             *
             *  @sa gaudio_source_set_position_callback
             *
             *  @ingroup gsource
             
            */
            typedef 
            void(GAPIENTRY* gposition)(gsource*,int32_t);
            extern GAPI void gaudio_source_set_position_callback(gsource* source,gposition);

            /*! @brief Create geffect instance.
             *
             *  This function create given geffect instance,
             *
             *  @param[in] effect A effect id which will be created.
              * @param[out] A effect pointer instance, NULL for error occur.
             *
             *  @note This function may only be called from the main thread.
             *
             *  @sa gaudio_effect_create
             *
             *  @ingroup geffect
             
            */
            extern GAPI geffect* gaudio_effect_create(int32_t effect,int32_t flag);
            /*! @brief Destroy geffect instance.
             *
             *  This function destroy given geffect instance,
             *
             *  @param[in] effect A effect instance which will be destroyed.
             *
             *  @note This function may only be called from the main thread.
             *
             *  @sa gaudio_effect_create
             *
             *  @ingroup geffect
             
            */
            extern GAPI void gaudio_effect_destroy(geffect* effect);
            /*! @brief The function signature for geffect fft callbacks.
             *
             *  This is the function signature for geffect fft calc callback functions.
             *
             *  @param[in] source The source whose content needs to be triggered.
             *
             *  @ingroup geffect
             
            */
            typedef 
            void(GAPIENTRY* gefxcb)(geffect*,float*,int32_t,int32_t,int32_t);
            extern GAPI void gaudio_effect_set_callback(geffect*,gefxcb);
            extern GAPI void gaudio_effect_bind(geffect* effect,int32_t flag);
            /*! @brief bind effect with given source.
             *
             *  @param[in] effect An effect pointer which will be bind to source.
             *  @param[in] source A source pointer which will be bind to effect.
             *
             *  @note This function may only be called from the main thread.
             *
             *  @sa gaudio_effect_bind
             *  @sa gaudio_effect_unbind
             *  @sa gaudio_effect_unbind_from_source
             *
             *  @ingroup geffect
             
            */
            extern GAPI void gaudio_effect_bind_to_source(geffect* effect,gsource* source);
            /*! @brief unbind effect from global context.
             *
             *  @param[in] effect An effect pointer which will be unbind from global.
             *
             *  @note This function may only be called from the main thread.
             *
             *  @sa gaudio_effect_bind_to_source
             *  @sa gaudio_effect_unbind
             *  @sa gaudio_effect_unbind_from_source
             *
             *  @ingroup geffect
             
            */
            extern GAPI void gaudio_effect_unbind(geffect* effect);
            /*! @brief unbind effect with given source.
             *
             *  @param[in] effect An effect pointer which will be unbind to source.
             *  @param[in] source A source pointer which will be unbind to effect.
             *
             *  @note This function may only be called from the main thread.
             *
             *  @sa gaudio_effect_bind
             *  @sa gaudio_effect_unbind
             *  @sa gaudio_effect_bind_to_source
             *
             *  @ingroup geffect
             
            */
            extern GAPI void gaudio_effect_unbind_from_source(geffect* effect,gsource* source);
            extern GAPI void gaudio_effect_set_float(geffect*,int32_t,float);
            extern GAPI void gaudio_effect_get_float(geffect*,int32_t,float*);
            #define AUDIO_EFFECT_ENABLE  0
            extern GAPI void gaudio_effect_set_int32(geffect*,int32_t,int32_t);
            extern GAPI void gaudio_effect_get_int32(geffect*,int32_t,int32_t*);

            extern GAPI grecorder* gaudio_recorder_create(const char*,uint32_t,uint32_t,uint32_t,uint32_t);
            extern GAPI void gaudio_recorder_start(grecorder*);
            extern GAPI void gaudio_recorder_stop(grecorder*);
            /*! @brief Destroy grecorder instance.
             *
             *  This function destroy given grecorder instance,
             *
             *  @param[in] source A grecorder instance which will be destroyed.
             *
             *  @note This function may only be called from the main thread.
             *
             *  @sa gaudio_recorder_create
             *
             *  @ingroup grecorder
             
            */
            extern GAPI void gaudio_recorder_destroy(grecorder* recorder);

            /*! @brief Returns the address of the specified function for the current
             *  context.
             *
             *  This function returns the address of the specified
             *  [client API or extension function], if it is supported
             *  by the current context.
             *
             *  @param[in] name The ASCII encoded name of the function.
             *  @return The address of the function, or `NULL` if the function is
             *  unavailable.
             *
             *  @remarks This function may be called from secondary threads.
             *
             *  @note The addresses of these functions are not guaranteed to be the same for
             *  all contexts, especially if they use different client APIs or even different
             *  context creation hints.
             *
             *  @ingroup context
             
            */
            extern GAPI void* gaudio_address_get(const char* name);

            #if defined(__cplusplus)
            }
            #endif

            /*************************************************************************
             * Global definition cleanup
             ************************************************************************
            */

            #endif  /* _gaudio_h_ */

            需要說明的是使用IntPtr可以替換c語言中的udt類型,由于不熟悉c#以上c#代碼可能存在問題
            最終的測試代碼如下:
            using System;
            using gaudio;

            namespace Simple
            {
                
            class Simple
                {
                    
            static void Main(string[] args)
                    {
                        gaudio.GAudio.gaudio_init(
            "addons");
                        
            int error = gaudio.GAudio.gaudio_error_get();
                        
            if(error != 0)
                            
            return;

                        IntPtr source 
            = gaudio.GAudio.gaudio_source_create_from_file("azure.xm",0);
                        
            if(source == null)
                        {
                            Console.WriteLine(
            "create source failed.");
                            gaudio.GAudio.gaudio_deinit();
                            
            return;
                        }

                        gaudio.GAudio.gaudio_source_start(source,
            1);
                        
                        Console.WriteLine(
            "Press any key to exit!");
                        Console.ReadKey(
            true);
                        gaudio.GAudio.gaudio_source_destroy(source);
                        gaudio.GAudio.gaudio_deinit();
                    }
                }
            }
            posted on 2013-09-13 20:55 ccsdu2009 閱讀(3636) 評論(0)  編輯 收藏 引用 所屬分類: 雜項 、編程基礎
             
            久久99热狠狠色精品一区| 久久久精品2019免费观看| 亚洲va久久久噜噜噜久久男同| 99久久精品国产毛片| 2021久久国自产拍精品| 亚洲女久久久噜噜噜熟女| 一本大道久久香蕉成人网| 韩国三级中文字幕hd久久精品| 99久久精品国产高清一区二区| 久久久精品国产sm调教网站| 久久婷婷五月综合色奶水99啪| 亚洲AV日韩AV永久无码久久| 欧美黑人激情性久久| 色综合久久无码中文字幕| 久久精品国产亚洲AV电影| 久久99精品久久久久子伦| 久久午夜伦鲁片免费无码| 麻豆精品久久久一区二区| 狠狠久久综合伊人不卡| 国产精品99久久精品爆乳| 久久黄色视频| 亚洲精品tv久久久久久久久| 久久久噜噜噜久久中文福利| 青青草国产精品久久久久| 精品多毛少妇人妻AV免费久久 | 国产精品久久婷婷六月丁香| 亚洲国产小视频精品久久久三级 | 99久久精品久久久久久清纯| 久久综合欧美成人| 久久综合伊人77777麻豆| 亚洲乱码日产精品a级毛片久久| 久久AV无码精品人妻糸列| 成人综合伊人五月婷久久| 狠狠色综合久久久久尤物| 无码人妻久久久一区二区三区| 久久国产精品久久国产精品| 老男人久久青草av高清| 日本三级久久网| 日韩精品久久无码人妻中文字幕| 韩国三级中文字幕hd久久精品| 一本色道久久综合狠狠躁|