/* Generated by Cython 0.10.2 on Thu Dec  4 19:57:25 2008 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#if PY_VERSION_HEX < 0x02040000
  #define METH_COEXIST 0
#endif
#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
  #define PyNumber_Index(o)    PyNumber_Int(o)
  #define PyIndex_Check(o)     PyNumber_Check(o)
#endif
#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)

  typedef struct {
       void *buf;
       PyObject *obj;
       Py_ssize_t len;
       Py_ssize_t itemsize;
       int readonly;
       int ndim;
       char *format;
       Py_ssize_t *shape;
       Py_ssize_t *strides;
       Py_ssize_t *suboffsets;
       void *internal;
  } Py_buffer;

  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_LOCK 0x0002
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)

#endif
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#endif
#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyString_Type                PyBytes_Type
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define PyBytes_Type                 PyString_Type
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) PyInstanceMethod_New(func)
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
#else
  #define _USE_MATH_DEFINES
#endif
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#include <math.h>
#define __PYX_HAVE_API___alsa_backend
#include "alsa/asoundlib.h"
#include "stdlib.h"
#include "numpy/arrayobject.h"


#ifdef __GNUC__
#define INLINE __inline__
#elif _WIN32
#define INLINE __inline
#else
#define INLINE 
#endif

typedef struct {PyObject **p; char *s; long n; char is_unicode; char intern; char is_identifier;} __Pyx_StringTabEntry; /*proto*/



static int __pyx_skip_dispatch = 0;


/* Type Conversion Predeclarations */

#if PY_MAJOR_VERSION < 3
#define __Pyx_PyBytes_FromString PyString_FromString
#define __Pyx_PyBytes_AsString   PyString_AsString
#else
#define __Pyx_PyBytes_FromString PyBytes_FromString
#define __Pyx_PyBytes_AsString   PyBytes_AsString
#endif

#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static INLINE int __Pyx_PyObject_IsTrue(PyObject* x);
static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x);
static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x);
static INLINE Py_ssize_t __pyx_PyIndex_AsSsize_t(PyObject* b);

#define __pyx_PyInt_AsLong(x) (PyInt_CheckExact(x) ? PyInt_AS_LONG(x) : PyInt_AsLong(x))
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))

static INLINE unsigned char __pyx_PyInt_unsigned_char(PyObject* x);
static INLINE unsigned short __pyx_PyInt_unsigned_short(PyObject* x);
static INLINE char __pyx_PyInt_char(PyObject* x);
static INLINE short __pyx_PyInt_short(PyObject* x);
static INLINE int __pyx_PyInt_int(PyObject* x);
static INLINE long __pyx_PyInt_long(PyObject* x);
static INLINE signed char __pyx_PyInt_signed_char(PyObject* x);
static INLINE signed short __pyx_PyInt_signed_short(PyObject* x);
static INLINE signed int __pyx_PyInt_signed_int(PyObject* x);
static INLINE signed long __pyx_PyInt_signed_long(PyObject* x);
static INLINE long double __pyx_PyInt_long_double(PyObject* x);
#ifdef __GNUC__
/* Test for GCC > 2.95 */
#if __GNUC__ > 2 ||               (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 
#define likely(x)   __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else /* __GNUC__ > 2 ... */
#define likely(x)   (x)
#define unlikely(x) (x)
#endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
#define likely(x)   (x)
#define unlikely(x) (x)
#endif /* __GNUC__ */
    
static PyObject *__pyx_m;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;
static const char **__pyx_f;

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name, PyObject* kw_name); /*proto*/

static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/

static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/
static INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
static INLINE void __Pyx_ZeroBuffer(Py_buffer* buf); /*proto*/
static INLINE const char* __Pyx_ConsumeWhitespace(const char* ts); /*proto*/
static void __Pyx_BufferNdimError(Py_buffer* buffer, int expected_ndim); /*proto*/
static const char* __Pyx_DescribeTokenInFormatString(const char* ts); /*proto*/
static const char* __Pyx_CheckTypestring_nn___pyx_t_5numpy_int16_t(const char* ts); /*proto*/

static int __Pyx_GetBuffer_nn___pyx_t_5numpy_int16_t(PyObject* obj, Py_buffer* buf, int flags, int nd, int cast); /*proto*/

static void __Pyx_RaiseBufferFallbackError(void); /*proto*/

static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static INLINE PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i, int is_unsigned) {
    PyObject *r;
    if (PyList_CheckExact(o) && 0 <= i && i < PyList_GET_SIZE(o)) {
        r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (PyTuple_CheckExact(o) && 0 <= i && i < PyTuple_GET_SIZE(o)) {
        r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0) || !is_unsigned))
        r = PySequence_GetItem(o, i);
    else {
        PyObject *j = (likely(i >= 0) || !is_unsigned) ? PyInt_FromLong(i) : PyLong_FromUnsignedLongLong((sizeof(unsigned long long) > sizeof(Py_ssize_t) ? (1ULL << (sizeof(Py_ssize_t)*8)) : 0) + i);
        if (!j)
            return 0;
        r = PyObject_GetItem(o, j);
        Py_DECREF(j);
    }
    return r;
}

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact); /*proto*/
#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
static void __Pyx_ReleaseBuffer(Py_buffer *view);
#else
#define __Pyx_GetBuffer PyObject_GetBuffer
#define __Pyx_ReleaseBuffer PyBuffer_Release
#endif

Py_ssize_t __Pyx_zeros[] = {0, 0};
Py_ssize_t __Pyx_minusones[] = {-1, -1};

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/

static INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (PyList_Append(L, x) < 0) return NULL;
        Py_INCREF(Py_None);
        return Py_None; // this is just to have an accurate signature
    }
    else {
        return PyObject_CallMethod(L, "append", "(O)", x);
    }
}

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static int __Pyx_Print(PyObject *, int); /*proto*/
#if PY_MAJOR_VERSION >= 3
static PyObject* __pyx_print = 0;
static PyObject* __pyx_print_kwargs = 0;
#endif

static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/

static INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/

static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size);  /*proto*/

static PyObject *__Pyx_ImportModule(const char *name); /*proto*/

static void __Pyx_AddTraceback(const char *funcname); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/

/* Type declarations */

typedef npy_int8 __pyx_t_5numpy_int8_t;

typedef npy_int16 __pyx_t_5numpy_int16_t;

typedef npy_int32 __pyx_t_5numpy_int32_t;

typedef npy_int64 __pyx_t_5numpy_int64_t;

typedef npy_uint8 __pyx_t_5numpy_uint8_t;

typedef npy_uint16 __pyx_t_5numpy_uint16_t;

typedef npy_uint32 __pyx_t_5numpy_uint32_t;

typedef npy_uint64 __pyx_t_5numpy_uint64_t;

typedef npy_float32 __pyx_t_5numpy_float32_t;

typedef npy_float64 __pyx_t_5numpy_float64_t;

typedef npy_long __pyx_t_5numpy_int_t;

typedef npy_longlong __pyx_t_5numpy_long_t;

typedef npy_ulong __pyx_t_5numpy_uint_t;

typedef npy_ulonglong __pyx_t_5numpy_ulong_t;

typedef npy_double __pyx_t_5numpy_float_t;

typedef npy_double __pyx_t_5numpy_double_t;

typedef npy_longdouble __pyx_t_5numpy_longdouble_t;

typedef npy_cfloat __pyx_t_5numpy_cfloat_t;

typedef npy_cdouble __pyx_t_5numpy_cdouble_t;

typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;

/* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":50
 *         return devices
 * 
 * cdef struct format_info:             # <<<<<<<<<<<<<<
 *         # number of channels
 *         int nchannels
 */

struct __pyx_t_13_alsa_backend_format_info {
  int nchannels;
  int rate;
  int nbits;
  int byte_fmt;
};

/* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":60
 *         int byte_fmt
 * 
 * cdef class AlsaDevice:             # <<<<<<<<<<<<<<
 *         cdef snd_pcm_t *handle
 *         cdef format_info format
 */

struct __pyx_obj_13_alsa_backend_AlsaDevice {
  PyObject_HEAD
  struct __pyx_vtabstruct_13_alsa_backend_AlsaDevice *__pyx_vtab;
  snd_pcm_t *handle;
  struct __pyx_t_13_alsa_backend_format_info format;
};


struct __pyx_vtabstruct_13_alsa_backend_AlsaDevice {
  int (*_play)(struct __pyx_obj_13_alsa_backend_AlsaDevice *, PyArrayObject *);
};
static struct __pyx_vtabstruct_13_alsa_backend_AlsaDevice *__pyx_vtabptr_13_alsa_backend_AlsaDevice;
/* Module declarations from python_buffer */

/* Module declarations from stdlib */

/* Module declarations from numpy */

/* Module declarations from numpy */

static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
/* Module declarations from python_exc */

/* Module declarations from alsa */

/* Module declarations from _alsa_backend */

static PyTypeObject *__pyx_ptype_13_alsa_backend_AlsaDevice = 0;
static int __pyx_v_13_alsa_backend_BUFFER_TIME;
static int __pyx_v_13_alsa_backend_PERIOD_TIME;
static PyObject *__pyx_f_13_alsa_backend_set_hw_params(snd_pcm_t *, struct __pyx_t_13_alsa_backend_format_info, snd_pcm_uframes_t *, snd_pcm_uframes_t *); /*proto*/
static PyObject *__pyx_f_13_alsa_backend_set_sw_params(snd_pcm_t *, unsigned int, unsigned int); /*proto*/


/* Implementation of _alsa_backend */
static PyObject *__pyx_int_32568;
static PyObject *__pyx_int_0;
static char __pyx_k___init__[] = "__init__";
static PyObject *__pyx_kp___init__;
static char __pyx_k_play[] = "play";
static PyObject *__pyx_kp_play;
static char __pyx_k___dealloc__[] = "__dealloc__";
static PyObject *__pyx_kp___dealloc__;
static char __pyx_k_fs[] = "fs";
static PyObject *__pyx_kp_fs;
static char __pyx_k_nchannels[] = "nchannels";
static PyObject *__pyx_kp_nchannels;
static char __pyx_k_input[] = "input";
static PyObject *__pyx_kp_input;
static char __pyx_k_numpy[] = "numpy";
static PyObject *__pyx_kp_numpy;
static char __pyx_k_np[] = "np";
static PyObject *__pyx_kp_np;
static char __pyx_k_AlsaException[] = "AlsaException";
static PyObject *__pyx_kp_AlsaException;
static char __pyx_k_Exception[] = "Exception";
static PyObject *__pyx_kp_Exception;
static char __pyx_k_append[] = "append";
static PyObject *__pyx_kp_append;
static char __pyx_k_ValueError[] = "ValueError";
static PyObject *__pyx_kp_ValueError;
static char __pyx_k_empty[] = "empty";
static PyObject *__pyx_kp_empty;
static char __pyx_k_dtype[] = "dtype";
static PyObject *__pyx_kp_dtype;
static char __pyx_k_31[] = "int16";
static PyObject *__pyx_kp_31;
static char __pyx_k_size[] = "size";
static PyObject *__pyx_kp_size;
static char __pyx_k_asfortranarray[] = "asfortranarray";
static PyObject *__pyx_kp_asfortranarray;
static PyObject *__pyx_builtin_Exception;
static PyObject *__pyx_builtin_ValueError;
static char __pyx_k_23[] = "pcm";
static PyObject *__pyx_kp_24;
static PyObject *__pyx_kp_26;
static PyObject *__pyx_kp_27;
static PyObject *__pyx_kp_28;
static char __pyx_k_24[] = "Only mono/stereo signals supported for now";
static char __pyx_k_25[] = "default";
static char __pyx_k_26[] = "Fail opening 'default'";
static char __pyx_k_27[] = "Period size is";
static char __pyx_k_28[] = ", Buffer size is";
static PyObject *__pyx_kp_29;
static PyObject *__pyx_kp_30;
static PyObject *__pyx_kp_32;
static PyObject *__pyx_kp_33;
static PyObject *__pyx_kp_34;
static char __pyx_k_29[] = "Only rank 2 for now";
static char __pyx_k_30[] = "AlsaDevice configured for %d channels, signal has %d channels";
static char __pyx_k_32[] = "Error while preparing the pcm device";
static char __pyx_k_33[] = "Error in writei";
static char __pyx_k_34[] = "Got SIGINT: draining the pcm device... ";
static PyObject *__pyx_kp_35;
static PyObject *__pyx_kp_36;
static PyObject *__pyx_kp_37;
static PyObject *__pyx_kp_38;
static PyObject *__pyx_kp_39;
static PyObject *__pyx_kp_40;
static PyObject *__pyx_kp_41;
static PyObject *__pyx_kp_42;
static PyObject *__pyx_kp_43;
static PyObject *__pyx_kp_44;
static PyObject *__pyx_kp_45;
static char __pyx_k_35[] = "Error in _any";
static char __pyx_k_36[] = "Error in _set_rate_resample";
static char __pyx_k_37[] = "Error in _set_access";
static char __pyx_k_38[] = "Error in _set_format";
static char __pyx_k_39[] = "Error in _set_channels";
static char __pyx_k_40[] = "Error in _set_rate_near";
static char __pyx_k_41[] = "Error in _set_buffer_near";
static char __pyx_k_42[] = "Error in _set_period_time_near";
static char __pyx_k_43[] = "Error in applying hw params";
static char __pyx_k_44[] = "Error in get_period_sizse";
static char __pyx_k_45[] = "Error in get_buffer_sizse";
static PyObject *__pyx_kp_46;
static PyObject *__pyx_kp_47;
static PyObject *__pyx_kp_48;
static PyObject *__pyx_kp_49;
static char __pyx_k_46[] = "Error in _current";
static char __pyx_k_47[] = "Error in _set_start_threshold";
static char __pyx_k_48[] = "Error in _set_avail_min";
static char __pyx_k_49[] = "Error in applying sw params";
static char __pyx_k___getbuffer__[] = "__getbuffer__";
static PyObject *__pyx_kp___getbuffer__;
static char __pyx_k___releasebuffer__[] = "__releasebuffer__";
static PyObject *__pyx_kp___releasebuffer__;
static char __pyx_k_info[] = "info";
static PyObject *__pyx_kp_info;
static char __pyx_k_flags[] = "flags";
static PyObject *__pyx_kp_flags;
static char __pyx_k_iteritems[] = "iteritems";
static PyObject *__pyx_kp_iteritems;
static char __pyx_k_next[] = "next";
static PyObject *__pyx_kp_next;
static char __pyx_k_StopIteration[] = "StopIteration";
static PyObject *__pyx_kp_StopIteration;
static char __pyx_k_pop[] = "pop";
static PyObject *__pyx_kp_pop;
static char __pyx_k_RuntimeError[] = "RuntimeError";
static PyObject *__pyx_kp_RuntimeError;
static PyObject *__pyx_kp_1;
static PyObject *__pyx_kp_2;
static PyObject *__pyx_kp_20;
static PyObject *__pyx_kp_21;
static PyObject *__pyx_kp_22;
static PyObject *__pyx_builtin_StopIteration;
static PyObject *__pyx_builtin_RuntimeError;
static char __pyx_k_1[] = "ndarray is not C contiguous";
static char __pyx_k_2[] = "ndarray is not Fortran contiguous";
static char __pyx_k_3[] = "b";
static char __pyx_k_4[] = "B";
static char __pyx_k_5[] = "h";
static char __pyx_k_6[] = "H";
static char __pyx_k_7[] = "i";
static char __pyx_k_8[] = "I";
static char __pyx_k_9[] = "l";
static char __pyx_k_10[] = "L";
static char __pyx_k_11[] = "q";
static char __pyx_k_12[] = "Q";
static char __pyx_k_13[] = "f";
static char __pyx_k_14[] = "d";
static char __pyx_k_15[] = "g";
static char __pyx_k_16[] = "Zf";
static char __pyx_k_17[] = "Zd";
static char __pyx_k_18[] = "Zg";
static char __pyx_k_19[] = "O";
static char __pyx_k_20[] = "unknown dtype code in numpy.pxd (%d)";
static char __pyx_k_21[] = "Format string allocated too short.";
static char __pyx_k_22[] = "unknown dtype code in numpy.pxd (%d)";

/* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":22
 *         pass
 * 
 * def alsa_version():             # <<<<<<<<<<<<<<
 *         """Return the version of libasound used by the alsa backend."""
 *         return snd_asoundlib_version()
 */

static PyObject *__pyx_pf_13_alsa_backend_alsa_version(PyObject *__pyx_self, PyObject *unused); /*proto*/
static char __pyx_doc_13_alsa_backend_alsa_version[] = "Return the version of libasound used by the alsa backend.";
static PyObject *__pyx_pf_13_alsa_backend_alsa_version(PyObject *__pyx_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  __pyx_self = __pyx_self;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":24
 * def alsa_version():
 *         """Return the version of libasound used by the alsa backend."""
 *         return snd_asoundlib_version()             # <<<<<<<<<<<<<<
 * 
 * def enumerate_devices():
 */
  __pyx_1 = __Pyx_PyBytes_FromString(snd_asoundlib_version()); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_alsa_backend.alsa_version");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":26
 *         return snd_asoundlib_version()
 * 
 * def enumerate_devices():             # <<<<<<<<<<<<<<
 *         """Return list of found devices (includes user-space ones)."""
 *         cdef int st, card
 */

static PyObject *__pyx_pf_13_alsa_backend_enumerate_devices(PyObject *__pyx_self, PyObject *unused); /*proto*/
static char __pyx_doc_13_alsa_backend_enumerate_devices[] = "Return list of found devices (includes user-space ones).";
static PyObject *__pyx_pf_13_alsa_backend_enumerate_devices(PyObject *__pyx_self, PyObject *unused) {
  int __pyx_v_st;
  int __pyx_v_card;
  char **__pyx_v_hints;
  PyObject *__pyx_v_devices;
  PyObject *__pyx_v_names;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  __pyx_self = __pyx_self;
  __pyx_v_devices = Py_None; Py_INCREF(Py_None);
  __pyx_v_names = Py_None; Py_INCREF(Py_None);

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":32
 *         cdef char* name
 * 
 *         devices = []             # <<<<<<<<<<<<<<
 *         names = []
 * 
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_devices);
  __pyx_v_devices = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":33
 * 
 *         devices = []
 *         names = []             # <<<<<<<<<<<<<<
 * 
 *         card = -1
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_names);
  __pyx_v_names = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":35
 *         names = []
 * 
 *         card = -1             # <<<<<<<<<<<<<<
 *         st = snd_device_name_hint(card, "pcm", <void***>&hints)
 *         card = 0
 */
  __pyx_v_card = -1;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":36
 * 
 *         card = -1
 *         st = snd_device_name_hint(card, "pcm", <void***>&hints)             # <<<<<<<<<<<<<<
 *         card = 0
 *         while(hints[card] != NULL):
 */
  __pyx_v_st = snd_device_name_hint(__pyx_v_card, __pyx_k_23, ((void ***)(&__pyx_v_hints)));

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":37
 *         card = -1
 *         st = snd_device_name_hint(card, "pcm", <void***>&hints)
 *         card = 0             # <<<<<<<<<<<<<<
 *         while(hints[card] != NULL):
 *                 #name = snd_device_name_get_hint(hints[card], "NAME")
 */
  __pyx_v_card = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":38
 *         st = snd_device_name_hint(card, "pcm", <void***>&hints)
 *         card = 0
 *         while(hints[card] != NULL):             # <<<<<<<<<<<<<<
 *                 #name = snd_device_name_get_hint(hints[card], "NAME")
 *                 #names.append(PyString_FromStringAndSize(name, stdlib.strlen(name)))
 */
  while (1) {
    __pyx_2 = ((__pyx_v_hints[__pyx_v_card]) != NULL);
    if (!__pyx_2) break;

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":44
 *                 #        stdlib.free(name)
 *                 devices.append(PyString_FromStringAndSize(hints[card],
 *                         stdlib.strlen(hints[card])))             # <<<<<<<<<<<<<<
 *                 card += 1
 *         snd_device_name_free_hint(<void**>hints)
 */
    __pyx_1 = PyString_FromStringAndSize((__pyx_v_hints[__pyx_v_card]), strlen((__pyx_v_hints[__pyx_v_card]))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __Pyx_PyObject_Append(__pyx_v_devices, __pyx_1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":45
 *                 devices.append(PyString_FromStringAndSize(hints[card],
 *                         stdlib.strlen(hints[card])))
 *                 card += 1             # <<<<<<<<<<<<<<
 *         snd_device_name_free_hint(<void**>hints)
 * 
 */
    __pyx_v_card += 1;
  }

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":46
 *                         stdlib.strlen(hints[card])))
 *                 card += 1
 *         snd_device_name_free_hint(<void**>hints)             # <<<<<<<<<<<<<<
 * 
 *         return devices
 */
  snd_device_name_free_hint(((void **)__pyx_v_hints));

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":48
 *         snd_device_name_free_hint(<void**>hints)
 * 
 *         return devices             # <<<<<<<<<<<<<<
 * 
 * cdef struct format_info:
 */
  Py_INCREF(__pyx_v_devices);
  __pyx_r = __pyx_v_devices;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_alsa_backend.enumerate_devices");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_devices);
  Py_DECREF(__pyx_v_names);
  return __pyx_r;
}

/* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":63
 *         cdef snd_pcm_t *handle
 *         cdef format_info format
 *         def __init__(AlsaDevice self, unsigned int fs=48000, int nchannels=1):             # <<<<<<<<<<<<<<
 *                 cdef int st
 *                 cdef snd_pcm_uframes_t psize, bsize
 */

static int __pyx_pf_13_alsa_backend_10AlsaDevice___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_13_alsa_backend_10AlsaDevice___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  unsigned int __pyx_v_fs;
  int __pyx_v_nchannels;
  int __pyx_v_st;
  snd_pcm_uframes_t __pyx_v_psize;
  snd_pcm_uframes_t __pyx_v_bsize;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_fs,&__pyx_kp_nchannels,0};
  __pyx_v_fs = 48000;
  __pyx_v_nchannels = 1;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_fs = PyInt_AsUnsignedLongMask(values[0]); if (unlikely((__pyx_v_fs == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[1]) {
      __pyx_v_nchannels = __pyx_PyInt_int(values[1]); if (unlikely((__pyx_v_nchannels == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_nchannels = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_nchannels == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case  1: __pyx_v_fs = PyInt_AsUnsignedLongMask(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_fs == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("_alsa_backend.AlsaDevice.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":67
 *                 cdef snd_pcm_uframes_t psize, bsize
 * 
 *                 self.format.rate = fs             # <<<<<<<<<<<<<<
 *                 self.format.nchannels = nchannels
 * 
 */
  ((struct __pyx_obj_13_alsa_backend_AlsaDevice *)__pyx_v_self)->format.rate = __pyx_v_fs;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":68
 * 
 *                 self.format.rate = fs
 *                 self.format.nchannels = nchannels             # <<<<<<<<<<<<<<
 * 
 *                 if not (nchannels > 0 and nchannels < 3):
 */
  ((struct __pyx_obj_13_alsa_backend_AlsaDevice *)__pyx_v_self)->format.nchannels = __pyx_v_nchannels;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":70
 *                 self.format.nchannels = nchannels
 * 
 *                 if not (nchannels > 0 and nchannels < 3):             # <<<<<<<<<<<<<<
 *                         raise ValueError,\
 *                               "Only mono/stereo signals supported for now"
 */
  __pyx_1 = (__pyx_v_nchannels > 0);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_nchannels < 3);
  }
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":72
 *                 if not (nchannels > 0 and nchannels < 3):
 *                         raise ValueError,\
 *                               "Only mono/stereo signals supported for now"             # <<<<<<<<<<<<<<
 * 
 *                 self.handle = <snd_pcm_t*>0
 */
    __Pyx_Raise(__pyx_builtin_ValueError, __pyx_kp_24, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":74
 *                               "Only mono/stereo signals supported for now"
 * 
 *                 self.handle = <snd_pcm_t*>0             # <<<<<<<<<<<<<<
 *                 st = snd_pcm_open(&self.handle, "default", SND_PCM_STREAM_PLAYBACK, 0)
 *                 if st < 0:
 */
  ((struct __pyx_obj_13_alsa_backend_AlsaDevice *)__pyx_v_self)->handle = ((snd_pcm_t *)0);

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":75
 * 
 *                 self.handle = <snd_pcm_t*>0
 *                 st = snd_pcm_open(&self.handle, "default", SND_PCM_STREAM_PLAYBACK, 0)             # <<<<<<<<<<<<<<
 *                 if st < 0:
 *                         raise AlsaException("Fail opening 'default'")
 */
  __pyx_v_st = snd_pcm_open((&((struct __pyx_obj_13_alsa_backend_AlsaDevice *)__pyx_v_self)->handle), __pyx_k_25, SND_PCM_STREAM_PLAYBACK, 0);

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":76
 *                 self.handle = <snd_pcm_t*>0
 *                 st = snd_pcm_open(&self.handle, "default", SND_PCM_STREAM_PLAYBACK, 0)
 *                 if st < 0:             # <<<<<<<<<<<<<<
 *                         raise AlsaException("Fail opening 'default'")
 * 
 */
  __pyx_1 = (__pyx_v_st < 0);
  if (__pyx_1) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":77
 *                 st = snd_pcm_open(&self.handle, "default", SND_PCM_STREAM_PLAYBACK, 0)
 *                 if st < 0:
 *                         raise AlsaException("Fail opening 'default'")             # <<<<<<<<<<<<<<
 * 
 *                 set_hw_params(self.handle, self.format, &psize, &bsize)
 */
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_AlsaException); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_26);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_kp_26);
    __pyx_5 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    __Pyx_Raise(__pyx_5, 0, 0);
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":79
 *                         raise AlsaException("Fail opening 'default'")
 * 
 *                 set_hw_params(self.handle, self.format, &psize, &bsize)             # <<<<<<<<<<<<<<
 *                 print "Period size is", psize, ", Buffer size is", bsize
 * 
 */
  __pyx_3 = __pyx_f_13_alsa_backend_set_hw_params(((struct __pyx_obj_13_alsa_backend_AlsaDevice *)__pyx_v_self)->handle, ((struct __pyx_obj_13_alsa_backend_AlsaDevice *)__pyx_v_self)->format, (&__pyx_v_psize), (&__pyx_v_bsize)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":80
 * 
 *                 set_hw_params(self.handle, self.format, &psize, &bsize)
 *                 print "Period size is", psize, ", Buffer size is", bsize             # <<<<<<<<<<<<<<
 * 
 *                 set_sw_params(self.handle, psize, bsize)
 */
  __pyx_4 = PyLong_FromUnsignedLong(__pyx_v_psize); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_5 = PyLong_FromUnsignedLong(__pyx_v_bsize); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(4); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_kp_27);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_kp_27);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);
  Py_INCREF(__pyx_kp_28);
  PyTuple_SET_ITEM(__pyx_3, 2, __pyx_kp_28);
  PyTuple_SET_ITEM(__pyx_3, 3, __pyx_5);
  __pyx_4 = 0;
  __pyx_5 = 0;
  if (__Pyx_Print(((PyObject *)__pyx_3), 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":82
 *                 print "Period size is", psize, ", Buffer size is", bsize
 * 
 *                 set_sw_params(self.handle, psize, bsize)             # <<<<<<<<<<<<<<
 * 
 *         def play(AlsaDevice self, cnp.ndarray input):
 */
  __pyx_4 = __pyx_f_13_alsa_backend_set_sw_params(((struct __pyx_obj_13_alsa_backend_AlsaDevice *)__pyx_v_self)->handle, __pyx_v_psize, __pyx_v_bsize); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_alsa_backend.AlsaDevice.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":84
 *                 set_sw_params(self.handle, psize, bsize)
 * 
 *         def play(AlsaDevice self, cnp.ndarray input):             # <<<<<<<<<<<<<<
 *                 self._play(input)
 * 
 */

static PyObject *__pyx_pf_13_alsa_backend_10AlsaDevice_play(PyObject *__pyx_v_self, PyObject *__pyx_v_input); /*proto*/
static PyObject *__pyx_pf_13_alsa_backend_10AlsaDevice_play(PyObject *__pyx_v_self, PyObject *__pyx_v_input) {
  PyObject *__pyx_r;
  int __pyx_1;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_input), __pyx_ptype_5numpy_ndarray, 1, "input", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":85
 * 
 *         def play(AlsaDevice self, cnp.ndarray input):
 *                 self._play(input)             # <<<<<<<<<<<<<<
 * 
 *         cdef int _play(AlsaDevice self, cnp.ndarray input) except -1:
 */
  __pyx_1 = ((struct __pyx_vtabstruct_13_alsa_backend_AlsaDevice *)((struct __pyx_obj_13_alsa_backend_AlsaDevice *)__pyx_v_self)->__pyx_vtab)->_play(((struct __pyx_obj_13_alsa_backend_AlsaDevice *)__pyx_v_self), ((PyArrayObject *)__pyx_v_input)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("_alsa_backend.AlsaDevice.play");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":87
 *                 self._play(input)
 * 
 *         cdef int _play(AlsaDevice self, cnp.ndarray input) except -1:             # <<<<<<<<<<<<<<
 *                 cdef cnp.ndarray[cnp.int16_t, ndim=2] tx
 *                 cdef int nr, i, nc
 */

static  int __pyx_f_13_alsa_backend_10AlsaDevice__play(struct __pyx_obj_13_alsa_backend_AlsaDevice *__pyx_v_self, PyArrayObject *__pyx_v_input) {
  PyArrayObject *__pyx_v_tx;
  int __pyx_v_nr;
  int __pyx_v_i;
  int __pyx_v_nc;
  int __pyx_v_bufsize;
  int __pyx_v_err;
  PyObject *__pyx_v_st;
  Py_buffer __pyx_bstruct_tx;
  Py_ssize_t __pyx_bstride_0_tx = 0;
  Py_ssize_t __pyx_bstride_1_tx = 0;
  Py_ssize_t __pyx_bshape_0_tx = 0;
  Py_ssize_t __pyx_bshape_1_tx = 0;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  int __pyx_7;
  PyObject *__pyx_t_1 = NULL;
  PyArrayObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __pyx_v_tx = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  __pyx_v_st = Py_None; Py_INCREF(Py_None);
  __pyx_bstruct_tx.buf = NULL;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":90
 *                 cdef cnp.ndarray[cnp.int16_t, ndim=2] tx
 *                 cdef int nr, i, nc
 *                 cdef int bufsize = 1024             # <<<<<<<<<<<<<<
 *                 cdef int err = 0
 * 
 */
  __pyx_v_bufsize = 1024;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":91
 *                 cdef int nr, i, nc
 *                 cdef int bufsize = 1024
 *                 cdef int err = 0             # <<<<<<<<<<<<<<
 * 
 *                 if not input.ndim == 2:
 */
  __pyx_v_err = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":93
 *                 cdef int err = 0
 * 
 *                 if not input.ndim == 2:             # <<<<<<<<<<<<<<
 *                         raise ValueError("Only rank 2 for now")
 * 
 */
  __pyx_1 = (!(__pyx_v_input->nd == 2));
  if (__pyx_1) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":94
 * 
 *                 if not input.ndim == 2:
 *                         raise ValueError("Only rank 2 for now")             # <<<<<<<<<<<<<<
 * 
 *                 nc = input.shape[0]
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_29);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_kp_29);
    __pyx_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":96
 *                         raise ValueError("Only rank 2 for now")
 * 
 *                 nc = input.shape[0]             # <<<<<<<<<<<<<<
 *                 if not nc == self.format.nchannels:
 *                         raise ValueError(
 */
  __pyx_v_nc = (__pyx_v_input->dimensions[0]);

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":97
 * 
 *                 nc = input.shape[0]
 *                 if not nc == self.format.nchannels:             # <<<<<<<<<<<<<<
 *                         raise ValueError(
 *                               "AlsaDevice configured for %d channels, "\
 */
  __pyx_1 = (!(__pyx_v_nc == __pyx_v_self->format.nchannels));
  if (__pyx_1) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":100
 *                         raise ValueError(
 *                               "AlsaDevice configured for %d channels, "\
 *                               "signal has %d channels" % (self.format.nchannels, nc))             # <<<<<<<<<<<<<<
 * 
 *                 tx = np.empty((nc, bufsize), dtype=np.int16)
 */
    __pyx_2 = PyInt_FromLong(__pyx_v_self->format.nchannels); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyInt_FromLong(__pyx_v_nc); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
    __pyx_2 = 0;
    __pyx_3 = 0;
    __pyx_t_1 = PyNumber_Remainder(__pyx_kp_30, ((PyObject *)__pyx_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":102
 *                               "signal has %d channels" % (self.format.nchannels, nc))
 * 
 *                 tx = np.empty((nc, bufsize), dtype=np.int16)             # <<<<<<<<<<<<<<
 *                 nr = input.size / nc / bufsize
 * 
 */
  __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_kp_empty); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_3 = PyInt_FromLong(__pyx_v_nc); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyInt_FromLong(__pyx_v_bufsize); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_5 = PyTuple_New(2); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_5));
  __pyx_5 = 0;
  __pyx_4 = PyDict_New(); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_kp_31); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (PyDict_SetItem(__pyx_4, __pyx_kp_dtype, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_2, ((PyObject *)__pyx_3), ((PyObject *)__pyx_4)); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
  if (!(__Pyx_TypeTest(__pyx_5, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((PyArrayObject *)__pyx_5);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_tx);
  __pyx_t_3 = __Pyx_GetBuffer_nn___pyx_t_5numpy_int16_t((PyObject*)__pyx_t_2, &__pyx_bstruct_tx, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0);
  if (unlikely(__pyx_t_3 < 0)) 
  {
      PyErr_Fetch(&__pyx_t_1, &__pyx_t_4, &__pyx_t_5);
      if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_int16_t((PyObject*)__pyx_v_tx, &__pyx_bstruct_tx, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0) == -1)) {
          Py_XDECREF(__pyx_t_1); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_5);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_1, __pyx_t_4, __pyx_t_5);
      }
  }
  __pyx_bstride_0_tx = __pyx_bstruct_tx.strides[0]; __pyx_bstride_1_tx = __pyx_bstruct_tx.strides[1];
  __pyx_bshape_0_tx = __pyx_bstruct_tx.shape[0]; __pyx_bshape_1_tx = __pyx_bstruct_tx.shape[1];
  if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = 0;
  Py_DECREF(((PyObject *)__pyx_v_tx));
  __pyx_v_tx = ((PyArrayObject *)__pyx_5);
  __pyx_5 = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":103
 * 
 *                 tx = np.empty((nc, bufsize), dtype=np.int16)
 *                 nr = input.size / nc / bufsize             # <<<<<<<<<<<<<<
 * 
 *                 st = snd_pcm_prepare(self.handle)
 */
  __pyx_6 = PyObject_GetAttr(((PyObject *)__pyx_v_input), __pyx_kp_size); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyInt_FromLong(__pyx_v_nc); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyNumber_Divide(__pyx_6, __pyx_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_3 = PyInt_FromLong(__pyx_v_bufsize); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_5, __pyx_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_7 = __pyx_PyInt_int(__pyx_t_4); if (unlikely((__pyx_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_nr = __pyx_7;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":105
 *                 nr = input.size / nc / bufsize
 * 
 *                 st = snd_pcm_prepare(self.handle)             # <<<<<<<<<<<<<<
 *                 if st:
 *                         raise AlsaException("Error while preparing the pcm device")
 */
  __pyx_4 = PyInt_FromLong(snd_pcm_prepare(__pyx_v_self->handle)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_st);
  __pyx_v_st = __pyx_4;
  __pyx_4 = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":106
 * 
 *                 st = snd_pcm_prepare(self.handle)
 *                 if st:             # <<<<<<<<<<<<<<
 *                         raise AlsaException("Error while preparing the pcm device")
 * 
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_st); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":107
 *                 st = snd_pcm_prepare(self.handle)
 *                 if st:
 *                         raise AlsaException("Error while preparing the pcm device")             # <<<<<<<<<<<<<<
 * 
 *                 for i in range(nr):
 */
    __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_AlsaException); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_6 = PyTuple_New(1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_32);
    PyTuple_SET_ITEM(__pyx_6, 0, __pyx_kp_32);
    __pyx_2 = PyObject_Call(__pyx_5, ((PyObject *)__pyx_6), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":109
 *                         raise AlsaException("Error while preparing the pcm device")
 * 
 *                 for i in range(nr):             # <<<<<<<<<<<<<<
 *                         err = python_exc.PyErr_CheckSignals()
 *                         if err != 0:
 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nr; __pyx_v_i+=1) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":110
 * 
 *                 for i in range(nr):
 *                         err = python_exc.PyErr_CheckSignals()             # <<<<<<<<<<<<<<
 *                         if err != 0:
 *                                 break
 */
    __pyx_v_err = PyErr_CheckSignals();

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":111
 *                 for i in range(nr):
 *                         err = python_exc.PyErr_CheckSignals()
 *                         if err != 0:             # <<<<<<<<<<<<<<
 *                                 break
 *                         # We make sure the buffer is in fortran order to deal
 */
    __pyx_1 = (__pyx_v_err != 0);
    if (__pyx_1) {

      /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":112
 *                         err = python_exc.PyErr_CheckSignals()
 *                         if err != 0:
 *                                 break             # <<<<<<<<<<<<<<
 *                         # We make sure the buffer is in fortran order to deal
 *                         # with interleaved data.
 */
      goto __pyx_L7;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":115
 *                         # We make sure the buffer is in fortran order to deal
 *                         # with interleaved data.
 *                         tx = np.asfortranarray(             # <<<<<<<<<<<<<<
 *                                 32568 * input[:, i * bufsize:
 *                                                  i * bufsize + bufsize],
 */
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_kp_asfortranarray); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":116
 *                         # with interleaved data.
 *                         tx = np.asfortranarray(
 *                                 32568 * input[:, i * bufsize:             # <<<<<<<<<<<<<<
 *                                                  i * bufsize + bufsize],
 *                                 np.int16)
 */
    __pyx_5 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_6 = PyInt_FromLong((__pyx_v_i * __pyx_v_bufsize)); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":117
 *                         tx = np.asfortranarray(
 *                                 32568 * input[:, i * bufsize:
 *                                                  i * bufsize + bufsize],             # <<<<<<<<<<<<<<
 *                                 np.int16)
 *                         st = snd_pcm_writei(self.handle, <void*>tx.data, bufsize)
 */
    __pyx_2 = PyInt_FromLong(((__pyx_v_i * __pyx_v_bufsize) + __pyx_v_bufsize)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":116
 *                         # with interleaved data.
 *                         tx = np.asfortranarray(
 *                                 32568 * input[:, i * bufsize:             # <<<<<<<<<<<<<<
 *                                                  i * bufsize + bufsize],
 *                                 np.int16)
 */
    __pyx_3 = PySlice_New(__pyx_6, __pyx_2, Py_None); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_6 = PyTuple_New(2); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5);
    PyTuple_SET_ITEM(__pyx_6, 1, __pyx_3);
    __pyx_5 = 0;
    __pyx_3 = 0;
    __pyx_2 = PyObject_GetItem(((PyObject *)__pyx_v_input), ((PyObject *)__pyx_6)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0;
    __pyx_t_4 = PyNumber_Multiply(__pyx_int_32568, __pyx_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":118
 *                                 32568 * input[:, i * bufsize:
 *                                                  i * bufsize + bufsize],
 *                                 np.int16)             # <<<<<<<<<<<<<<
 *                         st = snd_pcm_writei(self.handle, <void*>tx.data, bufsize)
 *                         if st < 0:
 */
    __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_kp_31); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_6 = PyTuple_New(2); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_6, 0, __pyx_t_4);
    PyTuple_SET_ITEM(__pyx_6, 1, __pyx_3);
    __pyx_t_4 = 0;
    __pyx_3 = 0;
    __pyx_2 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_6), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0;
    if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = ((PyArrayObject *)__pyx_2);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_tx);
    __pyx_t_3 = __Pyx_GetBuffer_nn___pyx_t_5numpy_int16_t((PyObject*)__pyx_t_2, &__pyx_bstruct_tx, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0);
    if (unlikely(__pyx_t_3 < 0)) 
    {
        PyErr_Fetch(&__pyx_t_4, &__pyx_t_5, &__pyx_t_1);
        if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_int16_t((PyObject*)__pyx_v_tx, &__pyx_bstruct_tx, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0) == -1)) {
            Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_1);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_4, __pyx_t_5, __pyx_t_1);
        }
    }
    __pyx_bstride_0_tx = __pyx_bstruct_tx.strides[0]; __pyx_bstride_1_tx = __pyx_bstruct_tx.strides[1];
    __pyx_bshape_0_tx = __pyx_bstruct_tx.shape[0]; __pyx_bshape_1_tx = __pyx_bstruct_tx.shape[1];
    if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = 0;
    Py_DECREF(((PyObject *)__pyx_v_tx));
    __pyx_v_tx = ((PyArrayObject *)__pyx_2);
    __pyx_2 = 0;

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":119
 *                                                  i * bufsize + bufsize],
 *                                 np.int16)
 *                         st = snd_pcm_writei(self.handle, <void*>tx.data, bufsize)             # <<<<<<<<<<<<<<
 *                         if st < 0:
 *                                 raise AlsaException("Error in writei")
 */
    __pyx_5 = PyInt_FromLong(snd_pcm_writei(__pyx_v_self->handle, ((void *)__pyx_v_tx->data), __pyx_v_bufsize)); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_st);
    __pyx_v_st = __pyx_5;
    __pyx_5 = 0;

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":120
 *                                 np.int16)
 *                         st = snd_pcm_writei(self.handle, <void*>tx.data, bufsize)
 *                         if st < 0:             # <<<<<<<<<<<<<<
 *                                 raise AlsaException("Error in writei")
 * 
 */
    __pyx_3 = PyObject_RichCompare(__pyx_v_st, __pyx_int_0, Py_LT); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_1) {

      /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":121
 *                         st = snd_pcm_writei(self.handle, <void*>tx.data, bufsize)
 *                         if st < 0:
 *                                 raise AlsaException("Error in writei")             # <<<<<<<<<<<<<<
 * 
 *                 if err:
 */
      __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_kp_AlsaException); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_6 = PyTuple_New(1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_kp_33);
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_kp_33);
      __pyx_2 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_6), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0;
      __Pyx_Raise(__pyx_2, 0, 0);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L9;
    }
    __pyx_L9:;
  }
  __pyx_L7:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":123
 *                                 raise AlsaException("Error in writei")
 * 
 *                 if err:             # <<<<<<<<<<<<<<
 *                         print "Got SIGINT: draining the pcm device... "
 *                         snd_pcm_drain(self.handle)
 */
  __pyx_7 = __pyx_v_err;
  if (__pyx_7) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":124
 * 
 *                 if err:
 *                         print "Got SIGINT: draining the pcm device... "             # <<<<<<<<<<<<<<
 *                         snd_pcm_drain(self.handle)
 *                         return -1
 */
    __pyx_5 = PyTuple_New(1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_34);
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_kp_34);
    if (__Pyx_Print(((PyObject *)__pyx_5), 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0;

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":125
 *                 if err:
 *                         print "Got SIGINT: draining the pcm device... "
 *                         snd_pcm_drain(self.handle)             # <<<<<<<<<<<<<<
 *                         return -1
 *                 snd_pcm_drain(self.handle)
 */
    snd_pcm_drain(__pyx_v_self->handle);

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":126
 *                         print "Got SIGINT: draining the pcm device... "
 *                         snd_pcm_drain(self.handle)
 *                         return -1             # <<<<<<<<<<<<<<
 *                 snd_pcm_drain(self.handle)
 *                 return 0
 */
    __pyx_r = -1;
    goto __pyx_L0;
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":127
 *                         snd_pcm_drain(self.handle)
 *                         return -1
 *                 snd_pcm_drain(self.handle)             # <<<<<<<<<<<<<<
 *                 return 0
 * 
 */
  snd_pcm_drain(__pyx_v_self->handle);

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":128
 *                         return -1
 *                 snd_pcm_drain(self.handle)
 *                 return 0             # <<<<<<<<<<<<<<
 * 
 *         def __dealloc__(AlsaDevice self):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_tx);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("_alsa_backend.AlsaDevice._play");
  __pyx_r = -1;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_tx);
  __pyx_L2:;
  Py_DECREF(__pyx_v_tx);
  Py_DECREF(__pyx_v_st);
  return __pyx_r;
}

/* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":130
 *                 return 0
 * 
 *         def __dealloc__(AlsaDevice self):             # <<<<<<<<<<<<<<
 *                 if self.handle:
 *                         snd_pcm_close(self.handle)
 */

static void __pyx_pf_13_alsa_backend_10AlsaDevice___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_13_alsa_backend_10AlsaDevice___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_1;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":131
 * 
 *         def __dealloc__(AlsaDevice self):
 *                 if self.handle:             # <<<<<<<<<<<<<<
 *                         snd_pcm_close(self.handle)
 * 
 */
  __pyx_1 = (((struct __pyx_obj_13_alsa_backend_AlsaDevice *)__pyx_v_self)->handle != 0);
  if (__pyx_1) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":132
 *         def __dealloc__(AlsaDevice self):
 *                 if self.handle:
 *                         snd_pcm_close(self.handle)             # <<<<<<<<<<<<<<
 * 
 * cdef set_hw_params(snd_pcm_t *hdl, format_info info, snd_pcm_uframes_t* period_size, snd_pcm_uframes_t *buffer_size):
 */
    snd_pcm_close(((struct __pyx_obj_13_alsa_backend_AlsaDevice *)__pyx_v_self)->handle);
    goto __pyx_L5;
  }
  __pyx_L5:;

}

/* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":134
 *                         snd_pcm_close(self.handle)
 * 
 * cdef set_hw_params(snd_pcm_t *hdl, format_info info, snd_pcm_uframes_t* period_size, snd_pcm_uframes_t *buffer_size):             # <<<<<<<<<<<<<<
 *         cdef unsigned int nchannels, buftime, pertime, samplerate
 *         cdef snd_pcm_hw_params_t *params
 */

static  PyObject *__pyx_f_13_alsa_backend_set_hw_params(snd_pcm_t *__pyx_v_hdl, struct __pyx_t_13_alsa_backend_format_info __pyx_v_info, snd_pcm_uframes_t *__pyx_v_period_size, snd_pcm_uframes_t *__pyx_v_buffer_size) {
  unsigned int __pyx_v_nchannels;
  unsigned int __pyx_v_buftime;
  unsigned int __pyx_v_pertime;
  unsigned int __pyx_v_samplerate;
  snd_pcm_hw_params_t *__pyx_v_params;
  int __pyx_v_st;
  int __pyx_v_dir;
  snd_pcm_access_t __pyx_v_access;
  snd_pcm_format_t __pyx_v_format;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":141
 *         cdef snd_pcm_format_t format
 * 
 *         access = SND_PCM_ACCESS_RW_INTERLEAVED             # <<<<<<<<<<<<<<
 *         buftime = BUFFER_TIME
 *         pertime = PERIOD_TIME
 */
  __pyx_v_access = SND_PCM_ACCESS_RW_INTERLEAVED;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":142
 * 
 *         access = SND_PCM_ACCESS_RW_INTERLEAVED
 *         buftime = BUFFER_TIME             # <<<<<<<<<<<<<<
 *         pertime = PERIOD_TIME
 * 
 */
  __pyx_v_buftime = __pyx_v_13_alsa_backend_BUFFER_TIME;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":143
 *         access = SND_PCM_ACCESS_RW_INTERLEAVED
 *         buftime = BUFFER_TIME
 *         pertime = PERIOD_TIME             # <<<<<<<<<<<<<<
 * 
 *         nchannels = info.nchannels
 */
  __pyx_v_pertime = __pyx_v_13_alsa_backend_PERIOD_TIME;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":145
 *         pertime = PERIOD_TIME
 * 
 *         nchannels = info.nchannels             # <<<<<<<<<<<<<<
 *         samplerate = info.rate
 *         format = SND_PCM_FORMAT_S16_LE
 */
  __pyx_v_nchannels = __pyx_v_info.nchannels;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":146
 * 
 *         nchannels = info.nchannels
 *         samplerate = info.rate             # <<<<<<<<<<<<<<
 *         format = SND_PCM_FORMAT_S16_LE
 * 
 */
  __pyx_v_samplerate = __pyx_v_info.rate;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":147
 *         nchannels = info.nchannels
 *         samplerate = info.rate
 *         format = SND_PCM_FORMAT_S16_LE             # <<<<<<<<<<<<<<
 * 
 *         snd_pcm_hw_params_alloca(&params)
 */
  __pyx_v_format = SND_PCM_FORMAT_S16_LE;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":149
 *         format = SND_PCM_FORMAT_S16_LE
 * 
 *         snd_pcm_hw_params_alloca(&params)             # <<<<<<<<<<<<<<
 *         st = snd_pcm_hw_params_any(hdl, params)
 *         if st < 0:
 */
  snd_pcm_hw_params_alloca((&__pyx_v_params));

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":150
 * 
 *         snd_pcm_hw_params_alloca(&params)
 *         st = snd_pcm_hw_params_any(hdl, params)             # <<<<<<<<<<<<<<
 *         if st < 0:
 *                 raise AlsaException("Error in _any")
 */
  __pyx_v_st = snd_pcm_hw_params_any(__pyx_v_hdl, __pyx_v_params);

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":151
 *         snd_pcm_hw_params_alloca(&params)
 *         st = snd_pcm_hw_params_any(hdl, params)
 *         if st < 0:             # <<<<<<<<<<<<<<
 *                 raise AlsaException("Error in _any")
 * 
 */
  __pyx_1 = (__pyx_v_st < 0);
  if (__pyx_1) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":152
 *         st = snd_pcm_hw_params_any(hdl, params)
 *         if st < 0:
 *                 raise AlsaException("Error in _any")             # <<<<<<<<<<<<<<
 * 
 *         # Restrict sampling rates to the ones supported by the hardware
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_AlsaException); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_35);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_kp_35);
    __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":155
 * 
 *         # Restrict sampling rates to the ones supported by the hardware
 *         st = snd_pcm_hw_params_set_rate_resample(hdl, params, 1)             # <<<<<<<<<<<<<<
 *         if st < 0:
 *                 raise AlsaException("Error in _set_rate_resample")
 */
  __pyx_v_st = snd_pcm_hw_params_set_rate_resample(__pyx_v_hdl, __pyx_v_params, 1);

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":156
 *         # Restrict sampling rates to the ones supported by the hardware
 *         st = snd_pcm_hw_params_set_rate_resample(hdl, params, 1)
 *         if st < 0:             # <<<<<<<<<<<<<<
 *                 raise AlsaException("Error in _set_rate_resample")
 * 
 */
  __pyx_1 = (__pyx_v_st < 0);
  if (__pyx_1) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":157
 *         st = snd_pcm_hw_params_set_rate_resample(hdl, params, 1)
 *         if st < 0:
 *                 raise AlsaException("Error in _set_rate_resample")             # <<<<<<<<<<<<<<
 * 
 *         st = snd_pcm_hw_params_set_access(hdl, params, access)
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_AlsaException); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_36);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_kp_36);
    __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":159
 *                 raise AlsaException("Error in _set_rate_resample")
 * 
 *         st = snd_pcm_hw_params_set_access(hdl, params, access)             # <<<<<<<<<<<<<<
 *         if st < 0:
 *                 raise AlsaException("Error in _set_access")
 */
  __pyx_v_st = snd_pcm_hw_params_set_access(__pyx_v_hdl, __pyx_v_params, __pyx_v_access);

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":160
 * 
 *         st = snd_pcm_hw_params_set_access(hdl, params, access)
 *         if st < 0:             # <<<<<<<<<<<<<<
 *                 raise AlsaException("Error in _set_access")
 * 
 */
  __pyx_1 = (__pyx_v_st < 0);
  if (__pyx_1) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":161
 *         st = snd_pcm_hw_params_set_access(hdl, params, access)
 *         if st < 0:
 *                 raise AlsaException("Error in _set_access")             # <<<<<<<<<<<<<<
 * 
 *         st = snd_pcm_hw_params_set_format(hdl, params, format)
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_AlsaException); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_37);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_kp_37);
    __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":163
 *                 raise AlsaException("Error in _set_access")
 * 
 *         st = snd_pcm_hw_params_set_format(hdl, params, format)             # <<<<<<<<<<<<<<
 *         if st < 0:
 *                 raise AlsaException("Error in _set_format")
 */
  __pyx_v_st = snd_pcm_hw_params_set_format(__pyx_v_hdl, __pyx_v_params, __pyx_v_format);

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":164
 * 
 *         st = snd_pcm_hw_params_set_format(hdl, params, format)
 *         if st < 0:             # <<<<<<<<<<<<<<
 *                 raise AlsaException("Error in _set_format")
 * 
 */
  __pyx_1 = (__pyx_v_st < 0);
  if (__pyx_1) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":165
 *         st = snd_pcm_hw_params_set_format(hdl, params, format)
 *         if st < 0:
 *                 raise AlsaException("Error in _set_format")             # <<<<<<<<<<<<<<
 * 
 *         st = snd_pcm_hw_params_set_channels(hdl, params, nchannels)
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_AlsaException); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_38);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_kp_38);
    __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":167
 *                 raise AlsaException("Error in _set_format")
 * 
 *         st = snd_pcm_hw_params_set_channels(hdl, params, nchannels)             # <<<<<<<<<<<<<<
 *         if st < 0:
 *                 raise AlsaException("Error in _set_channels")
 */
  __pyx_v_st = snd_pcm_hw_params_set_channels(__pyx_v_hdl, __pyx_v_params, __pyx_v_nchannels);

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":168
 * 
 *         st = snd_pcm_hw_params_set_channels(hdl, params, nchannels)
 *         if st < 0:             # <<<<<<<<<<<<<<
 *                 raise AlsaException("Error in _set_channels")
 * 
 */
  __pyx_1 = (__pyx_v_st < 0);
  if (__pyx_1) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":169
 *         st = snd_pcm_hw_params_set_channels(hdl, params, nchannels)
 *         if st < 0:
 *                 raise AlsaException("Error in _set_channels")             # <<<<<<<<<<<<<<
 * 
 *         dir = 0
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_AlsaException); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_39);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_kp_39);
    __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":171
 *                 raise AlsaException("Error in _set_channels")
 * 
 *         dir = 0             # <<<<<<<<<<<<<<
 *         st = snd_pcm_hw_params_set_rate_near(hdl, params, &samplerate, &dir)
 *         if st < 0:
 */
  __pyx_v_dir = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":172
 * 
 *         dir = 0
 *         st = snd_pcm_hw_params_set_rate_near(hdl, params, &samplerate, &dir)             # <<<<<<<<<<<<<<
 *         if st < 0:
 *                 raise AlsaException("Error in _set_rate_near")
 */
  __pyx_v_st = snd_pcm_hw_params_set_rate_near(__pyx_v_hdl, __pyx_v_params, (&__pyx_v_samplerate), (&__pyx_v_dir));

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":173
 *         dir = 0
 *         st = snd_pcm_hw_params_set_rate_near(hdl, params, &samplerate, &dir)
 *         if st < 0:             # <<<<<<<<<<<<<<
 *                 raise AlsaException("Error in _set_rate_near")
 * 
 */
  __pyx_1 = (__pyx_v_st < 0);
  if (__pyx_1) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":174
 *         st = snd_pcm_hw_params_set_rate_near(hdl, params, &samplerate, &dir)
 *         if st < 0:
 *                 raise AlsaException("Error in _set_rate_near")             # <<<<<<<<<<<<<<
 * 
 *         dir = 0
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_AlsaException); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_40);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_kp_40);
    __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":176
 *                 raise AlsaException("Error in _set_rate_near")
 * 
 *         dir = 0             # <<<<<<<<<<<<<<
 *         st = snd_pcm_hw_params_set_buffer_time_near(hdl, params, &buftime, &dir)
 *         if st < 0:
 */
  __pyx_v_dir = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":177
 * 
 *         dir = 0
 *         st = snd_pcm_hw_params_set_buffer_time_near(hdl, params, &buftime, &dir)             # <<<<<<<<<<<<<<
 *         if st < 0:
 *                 raise AlsaException("Error in _set_buffer_near")
 */
  __pyx_v_st = snd_pcm_hw_params_set_buffer_time_near(__pyx_v_hdl, __pyx_v_params, (&__pyx_v_buftime), (&__pyx_v_dir));

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":178
 *         dir = 0
 *         st = snd_pcm_hw_params_set_buffer_time_near(hdl, params, &buftime, &dir)
 *         if st < 0:             # <<<<<<<<<<<<<<
 *                 raise AlsaException("Error in _set_buffer_near")
 * 
 */
  __pyx_1 = (__pyx_v_st < 0);
  if (__pyx_1) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":179
 *         st = snd_pcm_hw_params_set_buffer_time_near(hdl, params, &buftime, &dir)
 *         if st < 0:
 *                 raise AlsaException("Error in _set_buffer_near")             # <<<<<<<<<<<<<<
 * 
 *         dir = 0
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_AlsaException); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_41);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_kp_41);
    __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":181
 *                 raise AlsaException("Error in _set_buffer_near")
 * 
 *         dir = 0             # <<<<<<<<<<<<<<
 *         st = snd_pcm_hw_params_set_period_time_near(hdl, params, &pertime, &dir)
 *         if st < 0:
 */
  __pyx_v_dir = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":182
 * 
 *         dir = 0
 *         st = snd_pcm_hw_params_set_period_time_near(hdl, params, &pertime, &dir)             # <<<<<<<<<<<<<<
 *         if st < 0:
 *                 raise AlsaException("Error in _set_period_time_near")
 */
  __pyx_v_st = snd_pcm_hw_params_set_period_time_near(__pyx_v_hdl, __pyx_v_params, (&__pyx_v_pertime), (&__pyx_v_dir));

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":183
 *         dir = 0
 *         st = snd_pcm_hw_params_set_period_time_near(hdl, params, &pertime, &dir)
 *         if st < 0:             # <<<<<<<<<<<<<<
 *                 raise AlsaException("Error in _set_period_time_near")
 * 
 */
  __pyx_1 = (__pyx_v_st < 0);
  if (__pyx_1) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":184
 *         st = snd_pcm_hw_params_set_period_time_near(hdl, params, &pertime, &dir)
 *         if st < 0:
 *                 raise AlsaException("Error in _set_period_time_near")             # <<<<<<<<<<<<<<
 * 
 *         st = snd_pcm_hw_params(hdl, params)
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_AlsaException); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_42);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_kp_42);
    __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":186
 *                 raise AlsaException("Error in _set_period_time_near")
 * 
 *         st = snd_pcm_hw_params(hdl, params)             # <<<<<<<<<<<<<<
 *         if st < 0:
 *                 raise AlsaException("Error in applying hw params")
 */
  __pyx_v_st = snd_pcm_hw_params(__pyx_v_hdl, __pyx_v_params);

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":187
 * 
 *         st = snd_pcm_hw_params(hdl, params)
 *         if st < 0:             # <<<<<<<<<<<<<<
 *                 raise AlsaException("Error in applying hw params")
 * 
 */
  __pyx_1 = (__pyx_v_st < 0);
  if (__pyx_1) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":188
 *         st = snd_pcm_hw_params(hdl, params)
 *         if st < 0:
 *                 raise AlsaException("Error in applying hw params")             # <<<<<<<<<<<<<<
 * 
 *         dir = 0
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_AlsaException); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_43);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_kp_43);
    __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":190
 *                 raise AlsaException("Error in applying hw params")
 * 
 *         dir = 0             # <<<<<<<<<<<<<<
 *         st = snd_pcm_hw_params_get_period_size(params, period_size, &dir)
 *         if st < 0:
 */
  __pyx_v_dir = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":191
 * 
 *         dir = 0
 *         st = snd_pcm_hw_params_get_period_size(params, period_size, &dir)             # <<<<<<<<<<<<<<
 *         if st < 0:
 *                 raise AlsaException("Error in get_period_sizse")
 */
  __pyx_v_st = snd_pcm_hw_params_get_period_size(__pyx_v_params, __pyx_v_period_size, (&__pyx_v_dir));

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":192
 *         dir = 0
 *         st = snd_pcm_hw_params_get_period_size(params, period_size, &dir)
 *         if st < 0:             # <<<<<<<<<<<<<<
 *                 raise AlsaException("Error in get_period_sizse")
 * 
 */
  __pyx_1 = (__pyx_v_st < 0);
  if (__pyx_1) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":193
 *         st = snd_pcm_hw_params_get_period_size(params, period_size, &dir)
 *         if st < 0:
 *                 raise AlsaException("Error in get_period_sizse")             # <<<<<<<<<<<<<<
 * 
 *         st = snd_pcm_hw_params_get_buffer_size(params, buffer_size)
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_AlsaException); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_44);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_kp_44);
    __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":195
 *                 raise AlsaException("Error in get_period_sizse")
 * 
 *         st = snd_pcm_hw_params_get_buffer_size(params, buffer_size)             # <<<<<<<<<<<<<<
 *         if st < 0:
 *                 raise AlsaException("Error in get_buffer_sizse")
 */
  __pyx_v_st = snd_pcm_hw_params_get_buffer_size(__pyx_v_params, __pyx_v_buffer_size);

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":196
 * 
 *         st = snd_pcm_hw_params_get_buffer_size(params, buffer_size)
 *         if st < 0:             # <<<<<<<<<<<<<<
 *                 raise AlsaException("Error in get_buffer_sizse")
 * 
 */
  __pyx_1 = (__pyx_v_st < 0);
  if (__pyx_1) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":197
 *         st = snd_pcm_hw_params_get_buffer_size(params, buffer_size)
 *         if st < 0:
 *                 raise AlsaException("Error in get_buffer_sizse")             # <<<<<<<<<<<<<<
 * 
 * cdef set_sw_params(snd_pcm_t *hdl, unsigned int period_size, unsigned int buffer_size):
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_AlsaException); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_45);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_kp_45);
    __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L13;
  }
  __pyx_L13:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_alsa_backend.set_hw_params");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":199
 *                 raise AlsaException("Error in get_buffer_sizse")
 * 
 * cdef set_sw_params(snd_pcm_t *hdl, unsigned int period_size, unsigned int buffer_size):             # <<<<<<<<<<<<<<
 *         cdef snd_pcm_sw_params_t *params
 * 
 */

static  PyObject *__pyx_f_13_alsa_backend_set_sw_params(snd_pcm_t *__pyx_v_hdl, unsigned int __pyx_v_period_size, unsigned int __pyx_v_buffer_size) {
  snd_pcm_sw_params_t *__pyx_v_params;
  PyObject *__pyx_v_st;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  __pyx_v_st = Py_None; Py_INCREF(Py_None);

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":202
 *         cdef snd_pcm_sw_params_t *params
 * 
 *         snd_pcm_sw_params_alloca(&params)             # <<<<<<<<<<<<<<
 * 
 *         st = snd_pcm_sw_params_current(hdl, params)
 */
  snd_pcm_sw_params_alloca((&__pyx_v_params));

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":204
 *         snd_pcm_sw_params_alloca(&params)
 * 
 *         st = snd_pcm_sw_params_current(hdl, params)             # <<<<<<<<<<<<<<
 *         if st < 0:
 *                 raise AlsaException("Error in _current")
 */
  __pyx_1 = PyInt_FromLong(snd_pcm_sw_params_current(__pyx_v_hdl, __pyx_v_params)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_st);
  __pyx_v_st = __pyx_1;
  __pyx_1 = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":205
 * 
 *         st = snd_pcm_sw_params_current(hdl, params)
 *         if st < 0:             # <<<<<<<<<<<<<<
 *                 raise AlsaException("Error in _current")
 * 
 */
  __pyx_1 = PyObject_RichCompare(__pyx_v_st, __pyx_int_0, Py_LT); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_1); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_2) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":206
 *         st = snd_pcm_sw_params_current(hdl, params)
 *         if st < 0:
 *                 raise AlsaException("Error in _current")             # <<<<<<<<<<<<<<
 * 
 *         st = snd_pcm_sw_params_set_start_threshold(hdl, params, period_size)
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_AlsaException); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_46);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_kp_46);
    __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":208
 *                 raise AlsaException("Error in _current")
 * 
 *         st = snd_pcm_sw_params_set_start_threshold(hdl, params, period_size)             # <<<<<<<<<<<<<<
 *         if st < 0:
 *                 raise AlsaException("Error in _set_start_threshold")
 */
  __pyx_1 = PyInt_FromLong(snd_pcm_sw_params_set_start_threshold(__pyx_v_hdl, __pyx_v_params, __pyx_v_period_size)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_st);
  __pyx_v_st = __pyx_1;
  __pyx_1 = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":209
 * 
 *         st = snd_pcm_sw_params_set_start_threshold(hdl, params, period_size)
 *         if st < 0:             # <<<<<<<<<<<<<<
 *                 raise AlsaException("Error in _set_start_threshold")
 * 
 */
  __pyx_3 = PyObject_RichCompare(__pyx_v_st, __pyx_int_0, Py_LT); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_2) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":210
 *         st = snd_pcm_sw_params_set_start_threshold(hdl, params, period_size)
 *         if st < 0:
 *                 raise AlsaException("Error in _set_start_threshold")             # <<<<<<<<<<<<<<
 * 
 *         st = snd_pcm_sw_params_set_avail_min(hdl, params, period_size)
 */
    __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_kp_AlsaException); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_47);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_kp_47);
    __pyx_3 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":212
 *                 raise AlsaException("Error in _set_start_threshold")
 * 
 *         st = snd_pcm_sw_params_set_avail_min(hdl, params, period_size)             # <<<<<<<<<<<<<<
 *         if st < 0:
 *                 raise AlsaException("Error in _set_avail_min")
 */
  __pyx_4 = PyInt_FromLong(snd_pcm_sw_params_set_avail_min(__pyx_v_hdl, __pyx_v_params, __pyx_v_period_size)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_st);
  __pyx_v_st = __pyx_4;
  __pyx_4 = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":213
 * 
 *         st = snd_pcm_sw_params_set_avail_min(hdl, params, period_size)
 *         if st < 0:             # <<<<<<<<<<<<<<
 *                 raise AlsaException("Error in _set_avail_min")
 * 
 */
  __pyx_1 = PyObject_RichCompare(__pyx_v_st, __pyx_int_0, Py_LT); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_1); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_2) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":214
 *         st = snd_pcm_sw_params_set_avail_min(hdl, params, period_size)
 *         if st < 0:
 *                 raise AlsaException("Error in _set_avail_min")             # <<<<<<<<<<<<<<
 * 
 *         st = snd_pcm_sw_params(hdl, params)
 */
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_AlsaException); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_48);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_kp_48);
    __pyx_1 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    __Pyx_Raise(__pyx_1, 0, 0);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":216
 *                 raise AlsaException("Error in _set_avail_min")
 * 
 *         st = snd_pcm_sw_params(hdl, params)             # <<<<<<<<<<<<<<
 *         if st < 0:
 *                 raise AlsaException("Error in applying sw params")
 */
  __pyx_3 = PyInt_FromLong(snd_pcm_sw_params(__pyx_v_hdl, __pyx_v_params)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_st);
  __pyx_v_st = __pyx_3;
  __pyx_3 = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":217
 * 
 *         st = snd_pcm_sw_params(hdl, params)
 *         if st < 0:             # <<<<<<<<<<<<<<
 *                 raise AlsaException("Error in applying sw params")
 */
  __pyx_4 = PyObject_RichCompare(__pyx_v_st, __pyx_int_0, Py_LT); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_4); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (__pyx_2) {

    /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":218
 *         st = snd_pcm_sw_params(hdl, params)
 *         if st < 0:
 *                 raise AlsaException("Error in applying sw params")             # <<<<<<<<<<<<<<
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_AlsaException); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_49);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_kp_49);
    __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_alsa_backend.set_sw_params");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_st);
  return __pyx_r;
}

/* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":50
 *         # experimental exception made for __getbuffer__ and __releasebuffer__
 *         # -- the details of this may change.
 *         def __getbuffer__(ndarray self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fullfill the PEP.
 */

static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_v_copy_shape;
  int __pyx_v_i;
  int __pyx_v_ndim;
  int __pyx_v_t;
  char *__pyx_v_f;
  PyArray_Descr *__pyx_v_descr = 0;
  PyObject *__pyx_v_stack;
  int __pyx_v_hasfields;
  PyObject *__pyx_v_iterator;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  Py_ssize_t __pyx_8 = 0;
  PyObject *__pyx_t_1 = NULL;
  if (__pyx_v_info == NULL) return 0;
  __pyx_v_info->obj = Py_None; Py_INCREF(Py_None);
  __pyx_v_stack = ((PyObject *)Py_None); Py_INCREF(Py_None);
  __pyx_v_iterator = Py_None; Py_INCREF(Py_None);

  /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":56
 *             # of flags
 *             cdef int copy_shape, i, ndim
 *             ndim = PyArray_NDIM(self)             # <<<<<<<<<<<<<<
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  __pyx_v_ndim = PyArray_NDIM(((PyArrayObject *)__pyx_v_self));

  /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":58
 *             ndim = PyArray_NDIM(self)
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 copy_shape = 1
 *             else:
 */
  __pyx_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t)));
  if (__pyx_1) {

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":59
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 copy_shape = 1             # <<<<<<<<<<<<<<
 *             else:
 *                 copy_shape = 0
 */
    __pyx_v_copy_shape = 1;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":61
 *                 copy_shape = 1
 *             else:
 *                 copy_shape = 0             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 */
    __pyx_v_copy_shape = 0;
  }
  __pyx_L5:;

  /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":63
 *                 copy_shape = 0
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError("ndarray is not C contiguous")
 */
  __pyx_1 = ((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS);
  if (__pyx_1) {

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":64
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):             # <<<<<<<<<<<<<<
 *                 raise ValueError("ndarray is not C contiguous")
 * 
 */
    __pyx_1 = (!PyArray_CHKFLAGS(((PyArrayObject *)__pyx_v_self), NPY_C_CONTIGUOUS));
  }
  if (__pyx_1) {

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":65
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError("ndarray is not C contiguous")             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_1);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_kp_1);
    __pyx_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":67
 *                 raise ValueError("ndarray is not C contiguous")
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError("ndarray is not Fortran contiguous")
 */
  __pyx_1 = ((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS);
  if (__pyx_1) {

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":68
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):             # <<<<<<<<<<<<<<
 *                 raise ValueError("ndarray is not Fortran contiguous")
 * 
 */
    __pyx_1 = (!PyArray_CHKFLAGS(((PyArrayObject *)__pyx_v_self), NPY_F_CONTIGUOUS));
  }
  if (__pyx_1) {

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":69
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError("ndarray is not Fortran contiguous")             # <<<<<<<<<<<<<<
 * 
 *             info.buf = PyArray_DATA(self)
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_2);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_kp_2);
    __pyx_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":71
 *                 raise ValueError("ndarray is not Fortran contiguous")
 * 
 *             info.buf = PyArray_DATA(self)             # <<<<<<<<<<<<<<
 *             info.ndim = ndim
 *             if copy_shape:
 */
  __pyx_v_info->buf = PyArray_DATA(((PyArrayObject *)__pyx_v_self));

  /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":72
 * 
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim             # <<<<<<<<<<<<<<
 *             if copy_shape:
 *                 # Allocate new buffer for strides and shape info. This is allocated
 */
  __pyx_v_info->ndim = __pyx_v_ndim;

  /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":73
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim
 *             if copy_shape:             # <<<<<<<<<<<<<<
 *                 # Allocate new buffer for strides and shape info. This is allocated
 *                 # as one block, strides first.
 */
  __pyx_4 = __pyx_v_copy_shape;
  if (__pyx_4) {

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":76
 *                 # Allocate new buffer for strides and shape info. This is allocated
 *                 # as one block, strides first.
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2)             # <<<<<<<<<<<<<<
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):
 */
    __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * __pyx_v_ndim) * 2)));

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":77
 *                 # as one block, strides first.
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2)
 *                 info.shape = info.strides + ndim             # <<<<<<<<<<<<<<
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 */
    __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim);

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":78
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2)
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):             # <<<<<<<<<<<<<<
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_ndim; __pyx_v_i+=1) {

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":79
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]             # <<<<<<<<<<<<<<
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 *             else:
 */
      (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(((PyArrayObject *)__pyx_v_self))[__pyx_v_i]);

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":80
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 *                     info.shape[i] = PyArray_DIMS(self)[i]             # <<<<<<<<<<<<<<
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 */
      (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(((PyArrayObject *)__pyx_v_self))[__pyx_v_i]);
    }
    goto __pyx_L8;
  }
  /*else*/ {

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":82
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)             # <<<<<<<<<<<<<<
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL
 */
    __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(((PyArrayObject *)__pyx_v_self)));

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":83
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)             # <<<<<<<<<<<<<<
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)
 */
    __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(((PyArrayObject *)__pyx_v_self)));
  }
  __pyx_L8:;

  /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":84
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
 *             info.itemsize = PyArray_ITEMSIZE(self)
 *             info.readonly = not PyArray_ISWRITEABLE(self)
 */
  __pyx_v_info->suboffsets = NULL;

  /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":85
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)             # <<<<<<<<<<<<<<
 *             info.readonly = not PyArray_ISWRITEABLE(self)
 * 
 */
  __pyx_v_info->itemsize = PyArray_ITEMSIZE(((PyArrayObject *)__pyx_v_self));

  /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":86
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)
 *             info.readonly = not PyArray_ISWRITEABLE(self)             # <<<<<<<<<<<<<<
 * 
 *             cdef int t
 */
  __pyx_v_info->readonly = (!PyArray_ISWRITEABLE(((PyArrayObject *)__pyx_v_self)));

  /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":89
 * 
 *             cdef int t
 *             cdef char* f = NULL             # <<<<<<<<<<<<<<
 *             cdef dtype descr = self.descr
 *             cdef list stack
 */
  __pyx_v_f = NULL;

  /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":90
 *             cdef int t
 *             cdef char* f = NULL
 *             cdef dtype descr = self.descr             # <<<<<<<<<<<<<<
 *             cdef list stack
 * 
 */
  Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self)->descr));
  __pyx_v_descr = ((PyArrayObject *)__pyx_v_self)->descr;

  /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":93
 *             cdef list stack
 * 
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)             # <<<<<<<<<<<<<<
 * 
 *             # Ugly hack warning:
 */
  __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr);

  /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":103
 *             # functions).
 * 
 *             if not hasfields and not copy_shape:             # <<<<<<<<<<<<<<
 *                 # do not call releasebuffer
 *                 info.obj = None
 */
  __pyx_1 = (!__pyx_v_hasfields);
  if (__pyx_1) {
    __pyx_1 = (!__pyx_v_copy_shape);
  }
  if (__pyx_1) {

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":105
 *             if not hasfields and not copy_shape:
 *                 # do not call releasebuffer
 *                 info.obj = None             # <<<<<<<<<<<<<<
 *             else:
 *                 # need to call releasebuffer
 */
    Py_INCREF(Py_None);
    Py_DECREF(__pyx_v_info->obj);
    __pyx_v_info->obj = Py_None;
    goto __pyx_L11;
  }
  /*else*/ {

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":108
 *             else:
 *                 # need to call releasebuffer
 *                 info.obj = self             # <<<<<<<<<<<<<<
 * 
 *             if not hasfields:
 */
    Py_INCREF(__pyx_v_self);
    Py_DECREF(__pyx_v_info->obj);
    __pyx_v_info->obj = __pyx_v_self;
  }
  __pyx_L11:;

  /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":110
 *                 info.obj = self
 * 
 *             if not hasfields:             # <<<<<<<<<<<<<<
 *                 t = descr.type_num
 *                 if   t == NPY_BYTE:        f = "b"
 */
  __pyx_1 = (!__pyx_v_hasfields);
  if (__pyx_1) {

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":111
 * 
 *             if not hasfields:
 *                 t = descr.type_num             # <<<<<<<<<<<<<<
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 */
    __pyx_v_t = __pyx_v_descr->type_num;

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":112
 *             if not hasfields:
 *                 t = descr.type_num
 *                 if   t == NPY_BYTE:        f = "b"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"
 */
    switch (__pyx_v_t) {
      case NPY_BYTE:
      __pyx_v_f = __pyx_k_3;
      break;
      case NPY_UBYTE:

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":113
 *                 t = descr.type_num
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"
 */
      __pyx_v_f = __pyx_k_4;
      break;
      case NPY_SHORT:

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":114
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"
 */
      __pyx_v_f = __pyx_k_5;
      break;
      case NPY_USHORT:

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":115
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"
 */
      __pyx_v_f = __pyx_k_6;
      break;
      case NPY_INT:

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":116
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"
 */
      __pyx_v_f = __pyx_k_7;
      break;
      case NPY_UINT:

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":117
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"
 */
      __pyx_v_f = __pyx_k_8;
      break;
      case NPY_LONG:

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":118
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"
 */
      __pyx_v_f = __pyx_k_9;
      break;
      case NPY_ULONG:

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":119
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 */
      __pyx_v_f = __pyx_k_10;
      break;
      case NPY_LONGLONG:

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":120
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"
 */
      __pyx_v_f = __pyx_k_11;
      break;
      case NPY_ULONGLONG:

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":121
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"
 */
      __pyx_v_f = __pyx_k_12;
      break;
      case NPY_FLOAT:

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":122
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 */
      __pyx_v_f = __pyx_k_13;
      break;
      case NPY_DOUBLE:

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":123
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 */
      __pyx_v_f = __pyx_k_14;
      break;
      case NPY_LONGDOUBLE:

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":124
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 */
      __pyx_v_f = __pyx_k_15;
      break;
      case NPY_CFLOAT:

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":125
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 */
      __pyx_v_f = __pyx_k_16;
      break;
      case NPY_CDOUBLE:

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":126
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 *                 elif t == NPY_OBJECT:      f = "O"
 */
      __pyx_v_f = __pyx_k_17;
      break;
      case NPY_CLONGDOUBLE:

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":127
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_OBJECT:      f = "O"
 *                 else:
 */
      __pyx_v_f = __pyx_k_18;
      break;
      case NPY_OBJECT:

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":128
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 *                 elif t == NPY_OBJECT:      f = "O"             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise ValueError("unknown dtype code in numpy.pxd (%d)" % t)
 */
      __pyx_v_f = __pyx_k_19;
      break;
      default:

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":130
 *                 elif t == NPY_OBJECT:      f = "O"
 *                 else:
 *                     raise ValueError("unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 *                 info.format = f
 *                 return
 */
      __pyx_2 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = PyNumber_Remainder(__pyx_kp_20, __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
      __Pyx_Raise(__pyx_2, 0, 0);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      break;
    }

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":131
 *                 else:
 *                     raise ValueError("unknown dtype code in numpy.pxd (%d)" % t)
 *                 info.format = f             # <<<<<<<<<<<<<<
 *                 return
 *             else:
 */
    __pyx_v_info->format = __pyx_v_f;

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":132
 *                     raise ValueError("unknown dtype code in numpy.pxd (%d)" % t)
 *                 info.format = f
 *                 return             # <<<<<<<<<<<<<<
 *             else:
 *                 info.format = <char*>stdlib.malloc(255) # static size
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L12;
  }
  /*else*/ {

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":134
 *                 return
 *             else:
 *                 info.format = <char*>stdlib.malloc(255) # static size             # <<<<<<<<<<<<<<
 *                 f = info.format
 *                 stack = [iter(descr.fields.iteritems())]
 */
    __pyx_v_info->format = ((char *)malloc(255));

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":135
 *             else:
 *                 info.format = <char*>stdlib.malloc(255) # static size
 *                 f = info.format             # <<<<<<<<<<<<<<
 *                 stack = [iter(descr.fields.iteritems())]
 * 
 */
    __pyx_v_f = __pyx_v_info->format;

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":136
 *                 info.format = <char*>stdlib.malloc(255) # static size
 *                 f = info.format
 *                 stack = [iter(descr.fields.iteritems())]             # <<<<<<<<<<<<<<
 * 
 *                 while True:
 */
    __pyx_3 = PyObject_GetAttr(__pyx_v_descr->fields, __pyx_kp_iteritems); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_3 = PyObject_GetIter(__pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_2 = PyList_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyList_SET_ITEM(__pyx_2, 0, __pyx_3);
    __pyx_3 = 0;
    Py_DECREF(((PyObject *)__pyx_v_stack));
    __pyx_v_stack = __pyx_2;
    __pyx_2 = 0;

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":138
 *                 stack = [iter(descr.fields.iteritems())]
 * 
 *                 while True:             # <<<<<<<<<<<<<<
 *                     iterator = stack[-1]
 *                     descr = None
 */
    while (1) {
      __pyx_1 = 1;
      if (!__pyx_1) break;

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":139
 * 
 *                 while True:
 *                     iterator = stack[-1]             # <<<<<<<<<<<<<<
 *                     descr = None
 *                     while descr is None:
 */
      __pyx_3 = __Pyx_GetItemInt(((PyObject *)__pyx_v_stack), -1, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_iterator);
      __pyx_v_iterator = __pyx_3;
      __pyx_3 = 0;

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":140
 *                 while True:
 *                     iterator = stack[-1]
 *                     descr = None             # <<<<<<<<<<<<<<
 *                     while descr is None:
 *                         try:
 */
      Py_INCREF(Py_None);
      Py_DECREF(((PyObject *)__pyx_v_descr));
      __pyx_v_descr = ((PyArray_Descr *)Py_None);

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":141
 *                     iterator = stack[-1]
 *                     descr = None
 *                     while descr is None:             # <<<<<<<<<<<<<<
 *                         try:
 *                             descr = iterator.next()[1][0]
 */
      while (1) {
        __pyx_1 = (((PyObject *)__pyx_v_descr) == Py_None);
        if (!__pyx_1) break;

        /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":142
 *                     descr = None
 *                     while descr is None:
 *                         try:             # <<<<<<<<<<<<<<
 *                             descr = iterator.next()[1][0]
 *                         except StopIteration:
 */
        {
          PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
          __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
          /*try:*/ {

            /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":143
 *                     while descr is None:
 *                         try:
 *                             descr = iterator.next()[1][0]             # <<<<<<<<<<<<<<
 *                         except StopIteration:
 *                             stack.pop()
 */
            __pyx_2 = PyObject_GetAttr(__pyx_v_iterator, __pyx_kp_next); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
            __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
            Py_DECREF(__pyx_2); __pyx_2 = 0;
            __pyx_2 = __Pyx_GetItemInt(__pyx_3, 1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
            Py_DECREF(__pyx_3); __pyx_3 = 0;
            __pyx_3 = __Pyx_GetItemInt(__pyx_2, 0, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
            Py_DECREF(__pyx_2); __pyx_2 = 0;
            if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_5numpy_dtype))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
            Py_DECREF(((PyObject *)__pyx_v_descr));
            __pyx_v_descr = ((PyArray_Descr *)__pyx_3);
            __pyx_3 = 0;
          }
          Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
          Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
          Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
          goto __pyx_L21_try;
          __pyx_L17_error:;
          Py_XDECREF(__pyx_2); __pyx_2 = 0;
          Py_XDECREF(__pyx_3); __pyx_3 = 0;

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":144
 *                         try:
 *                             descr = iterator.next()[1][0]
 *                         except StopIteration:             # <<<<<<<<<<<<<<
 *                             stack.pop()
 *                             if len(stack) > 0:
 */
          __pyx_4 = PyErr_ExceptionMatches(__pyx_builtin_StopIteration);
          if (__pyx_4) {
            __Pyx_AddTraceback("numpy.__getbuffer__");
            if (__Pyx_GetException(&__pyx_2, &__pyx_3, &__pyx_5) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}

            /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":145
 *                             descr = iterator.next()[1][0]
 *                         except StopIteration:
 *                             stack.pop()             # <<<<<<<<<<<<<<
 *                             if len(stack) > 0:
 *                                 f[0] = 125 #"}"
 */
            __pyx_6 = PyObject_GetAttr(((PyObject *)__pyx_v_stack), __pyx_kp_pop); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
            __pyx_7 = PyObject_Call(__pyx_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
            Py_DECREF(__pyx_6); __pyx_6 = 0;
            Py_DECREF(__pyx_7); __pyx_7 = 0;

            /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":146
 *                         except StopIteration:
 *                             stack.pop()
 *                             if len(stack) > 0:             # <<<<<<<<<<<<<<
 *                                 f[0] = 125 #"}"
 *                                 f += 1
 */
            __pyx_8 = PyObject_Length(((PyObject *)__pyx_v_stack)); if (unlikely(__pyx_8 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
            __pyx_1 = (__pyx_8 > 0);
            if (__pyx_1) {

              /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":147
 *                             stack.pop()
 *                             if len(stack) > 0:
 *                                 f[0] = 125 #"}"             # <<<<<<<<<<<<<<
 *                                 f += 1
 *                                 iterator = stack[-1]
 */
              (__pyx_v_f[0]) = 125;

              /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":148
 *                             if len(stack) > 0:
 *                                 f[0] = 125 #"}"
 *                                 f += 1             # <<<<<<<<<<<<<<
 *                                 iterator = stack[-1]
 *                             else:
 */
              __pyx_v_f += 1;

              /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":149
 *                                 f[0] = 125 #"}"
 *                                 f += 1
 *                                 iterator = stack[-1]             # <<<<<<<<<<<<<<
 *                             else:
 *                                 f[0] = 0 # Terminate string!
 */
              __pyx_6 = __Pyx_GetItemInt(((PyObject *)__pyx_v_stack), -1, 0); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
              Py_DECREF(__pyx_v_iterator);
              __pyx_v_iterator = __pyx_6;
              __pyx_6 = 0;
              goto __pyx_L22;
            }
            /*else*/ {

              /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":151
 *                                 iterator = stack[-1]
 *                             else:
 *                                 f[0] = 0 # Terminate string!             # <<<<<<<<<<<<<<
 *                                 return
 * 
 */
              (__pyx_v_f[0]) = 0;

              /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":152
 *                             else:
 *                                 f[0] = 0 # Terminate string!
 *                                 return             # <<<<<<<<<<<<<<
 * 
 *                     hasfields = PyDataType_HASFIELDS(descr)
 */
              __pyx_r = 0;
              Py_DECREF(__pyx_2); __pyx_2 = 0;
              Py_DECREF(__pyx_3); __pyx_3 = 0;
              Py_DECREF(__pyx_5); __pyx_5 = 0;
              goto __pyx_L20_except_return;
            }
            __pyx_L22:;
            Py_DECREF(__pyx_2); __pyx_2 = 0;
            Py_DECREF(__pyx_3); __pyx_3 = 0;
            Py_DECREF(__pyx_5); __pyx_5 = 0;
            goto __pyx_L18_exception_handled;
          }
          __pyx_L19_except_error:;
          Py_XDECREF(__pyx_save_exc_type);
          Py_XDECREF(__pyx_save_exc_value);
          Py_XDECREF(__pyx_save_exc_tb);
          goto __pyx_L1_error;
          __pyx_L20_except_return:;
          __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
          goto __pyx_L0;
          __pyx_L18_exception_handled:;
          __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
          __pyx_L21_try:;
        }
      }

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":154
 *                                 return
 * 
 *                     hasfields = PyDataType_HASFIELDS(descr)             # <<<<<<<<<<<<<<
 *                     if not hasfields:
 *                         t = descr.type_num
 */
      __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr);

      /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":155
 * 
 *                     hasfields = PyDataType_HASFIELDS(descr)
 *                     if not hasfields:             # <<<<<<<<<<<<<<
 *                         t = descr.type_num
 *                         if f - info.format > 240: # this should leave room for "T{" and "}" as well
 */
      __pyx_1 = (!__pyx_v_hasfields);
      if (__pyx_1) {

        /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":156
 *                     hasfields = PyDataType_HASFIELDS(descr)
 *                     if not hasfields:
 *                         t = descr.type_num             # <<<<<<<<<<<<<<
 *                         if f - info.format > 240: # this should leave room for "T{" and "}" as well
 *                             raise RuntimeError("Format string allocated too short.")
 */
        __pyx_v_t = __pyx_v_descr->type_num;

        /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":157
 *                     if not hasfields:
 *                         t = descr.type_num
 *                         if f - info.format > 240: # this should leave room for "T{" and "}" as well             # <<<<<<<<<<<<<<
 *                             raise RuntimeError("Format string allocated too short.")
 * 
 */
        __pyx_1 = ((__pyx_v_f - __pyx_v_info->format) > 240);
        if (__pyx_1) {

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":158
 *                         t = descr.type_num
 *                         if f - info.format > 240: # this should leave room for "T{" and "}" as well
 *                             raise RuntimeError("Format string allocated too short.")             # <<<<<<<<<<<<<<
 * 
 *                         # Until ticket #99 is fixed, use integers to avoid warnings
 */
          __pyx_7 = PyTuple_New(1); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_INCREF(__pyx_kp_21);
          PyTuple_SET_ITEM(__pyx_7, 0, __pyx_kp_21);
          __pyx_6 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_7), NULL); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(((PyObject *)__pyx_7)); __pyx_7 = 0;
          __Pyx_Raise(__pyx_6, 0, 0);
          Py_DECREF(__pyx_6); __pyx_6 = 0;
          {__pyx_filename = __pyx_f[1]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          goto __pyx_L24;
        }
        __pyx_L24:;

        /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":161
 * 
 *                         # Until ticket #99 is fixed, use integers to avoid warnings
 *                         if   t == NPY_BYTE:        f[0] =  98 #"b"             # <<<<<<<<<<<<<<
 *                         elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *                         elif t == NPY_SHORT:       f[0] = 104 #"h"
 */
        switch (__pyx_v_t) {
          case NPY_BYTE:
          (__pyx_v_f[0]) = 98;
          break;
          case NPY_UBYTE:

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":162
 *                         # Until ticket #99 is fixed, use integers to avoid warnings
 *                         if   t == NPY_BYTE:        f[0] =  98 #"b"
 *                         elif t == NPY_UBYTE:       f[0] =  66 #"B"             # <<<<<<<<<<<<<<
 *                         elif t == NPY_SHORT:       f[0] = 104 #"h"
 *                         elif t == NPY_USHORT:      f[0] =  72 #"H"
 */
          (__pyx_v_f[0]) = 66;
          break;
          case NPY_SHORT:

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":163
 *                         if   t == NPY_BYTE:        f[0] =  98 #"b"
 *                         elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *                         elif t == NPY_SHORT:       f[0] = 104 #"h"             # <<<<<<<<<<<<<<
 *                         elif t == NPY_USHORT:      f[0] =  72 #"H"
 *                         elif t == NPY_INT:         f[0] = 105 #"i"
 */
          (__pyx_v_f[0]) = 104;
          break;
          case NPY_USHORT:

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":164
 *                         elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *                         elif t == NPY_SHORT:       f[0] = 104 #"h"
 *                         elif t == NPY_USHORT:      f[0] =  72 #"H"             # <<<<<<<<<<<<<<
 *                         elif t == NPY_INT:         f[0] = 105 #"i"
 *                         elif t == NPY_UINT:        f[0] =  73 #"I"
 */
          (__pyx_v_f[0]) = 72;
          break;
          case NPY_INT:

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":165
 *                         elif t == NPY_SHORT:       f[0] = 104 #"h"
 *                         elif t == NPY_USHORT:      f[0] =  72 #"H"
 *                         elif t == NPY_INT:         f[0] = 105 #"i"             # <<<<<<<<<<<<<<
 *                         elif t == NPY_UINT:        f[0] =  73 #"I"
 *                         elif t == NPY_LONG:        f[0] = 108 #"l"
 */
          (__pyx_v_f[0]) = 105;
          break;
          case NPY_UINT:

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":166
 *                         elif t == NPY_USHORT:      f[0] =  72 #"H"
 *                         elif t == NPY_INT:         f[0] = 105 #"i"
 *                         elif t == NPY_UINT:        f[0] =  73 #"I"             # <<<<<<<<<<<<<<
 *                         elif t == NPY_LONG:        f[0] = 108 #"l"
 *                         elif t == NPY_ULONG:       f[0] = 76  #"L"
 */
          (__pyx_v_f[0]) = 73;
          break;
          case NPY_LONG:

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":167
 *                         elif t == NPY_INT:         f[0] = 105 #"i"
 *                         elif t == NPY_UINT:        f[0] =  73 #"I"
 *                         elif t == NPY_LONG:        f[0] = 108 #"l"             # <<<<<<<<<<<<<<
 *                         elif t == NPY_ULONG:       f[0] = 76  #"L"
 *                         elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 */
          (__pyx_v_f[0]) = 108;
          break;
          case NPY_ULONG:

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":168
 *                         elif t == NPY_UINT:        f[0] =  73 #"I"
 *                         elif t == NPY_LONG:        f[0] = 108 #"l"
 *                         elif t == NPY_ULONG:       f[0] = 76  #"L"             # <<<<<<<<<<<<<<
 *                         elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *                         elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 */
          (__pyx_v_f[0]) = 76;
          break;
          case NPY_LONGLONG:

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":169
 *                         elif t == NPY_LONG:        f[0] = 108 #"l"
 *                         elif t == NPY_ULONG:       f[0] = 76  #"L"
 *                         elif t == NPY_LONGLONG:    f[0] = 113 #"q"             # <<<<<<<<<<<<<<
 *                         elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *                         elif t == NPY_FLOAT:       f[0] = 102 #"f"
 */
          (__pyx_v_f[0]) = 113;
          break;
          case NPY_ULONGLONG:

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":170
 *                         elif t == NPY_ULONG:       f[0] = 76  #"L"
 *                         elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *                         elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"             # <<<<<<<<<<<<<<
 *                         elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *                         elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 */
          (__pyx_v_f[0]) = 81;
          break;
          case NPY_FLOAT:

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":171
 *                         elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *                         elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *                         elif t == NPY_FLOAT:       f[0] = 102 #"f"             # <<<<<<<<<<<<<<
 *                         elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *                         elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 */
          (__pyx_v_f[0]) = 102;
          break;
          case NPY_DOUBLE:

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":172
 *                         elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *                         elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *                         elif t == NPY_DOUBLE:      f[0] = 100 #"d"             # <<<<<<<<<<<<<<
 *                         elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *                         elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1
 */
          (__pyx_v_f[0]) = 100;
          break;
          case NPY_LONGDOUBLE:

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":173
 *                         elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *                         elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *                         elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"             # <<<<<<<<<<<<<<
 *                         elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1
 *                         elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1
 */
          (__pyx_v_f[0]) = 103;
          break;
          case NPY_CFLOAT:

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":174
 *                         elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *                         elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *                         elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1             # <<<<<<<<<<<<<<
 *                         elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1
 *                         elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1
 */
          (__pyx_v_f[0]) = 90;
          (__pyx_v_f[1]) = 102;
          __pyx_v_f += 1;
          break;
          case NPY_CDOUBLE:

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":175
 *                         elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *                         elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1
 *                         elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1             # <<<<<<<<<<<<<<
 *                         elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1
 *                         elif t == NPY_OBJECT:      f[0] = 79 #"O"
 */
          (__pyx_v_f[0]) = 90;
          (__pyx_v_f[1]) = 100;
          __pyx_v_f += 1;
          break;
          case NPY_CLONGDOUBLE:

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":176
 *                         elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1
 *                         elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1
 *                         elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1             # <<<<<<<<<<<<<<
 *                         elif t == NPY_OBJECT:      f[0] = 79 #"O"
 *                         else:
 */
          (__pyx_v_f[0]) = 90;
          (__pyx_v_f[1]) = 103;
          __pyx_v_f += 1;
          break;
          case NPY_OBJECT:

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":177
 *                         elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1
 *                         elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1
 *                         elif t == NPY_OBJECT:      f[0] = 79 #"O"             # <<<<<<<<<<<<<<
 *                         else:
 *                             raise ValueError("unknown dtype code in numpy.pxd (%d)" % t)
 */
          (__pyx_v_f[0]) = 79;
          break;
          default:

          /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":179
 *                         elif t == NPY_OBJECT:      f[0] = 79 #"O"
 *                         else:
 *                             raise ValueError("unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 *                         f += 1
 *                     else:
 */
          __pyx_2 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_1 = PyNumber_Remainder(__pyx_kp_22, __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          PyTuple_SET_ITEM(__pyx_3, 0, __pyx_t_1);
          __pyx_t_1 = 0;
          __pyx_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
          __Pyx_Raise(__pyx_5, 0, 0);
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          {__pyx_filename = __pyx_f[1]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }

        /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":180
 *                         else:
 *                             raise ValueError("unknown dtype code in numpy.pxd (%d)" % t)
 *                         f += 1             # <<<<<<<<<<<<<<
 *                     else:
 *                         f[0] = 84 #"T"
 */
        __pyx_v_f += 1;
        goto __pyx_L23;
      }
      /*else*/ {

        /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":182
 *                         f += 1
 *                     else:
 *                         f[0] = 84 #"T"             # <<<<<<<<<<<<<<
 *                         f[1] = 123 #"{"
 *                         f += 2
 */
        (__pyx_v_f[0]) = 84;

        /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":183
 *                     else:
 *                         f[0] = 84 #"T"
 *                         f[1] = 123 #"{"             # <<<<<<<<<<<<<<
 *                         f += 2
 *                         stack.append(iter(descr.fields.iteritems()))
 */
        (__pyx_v_f[1]) = 123;

        /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":184
 *                         f[0] = 84 #"T"
 *                         f[1] = 123 #"{"
 *                         f += 2             # <<<<<<<<<<<<<<
 *                         stack.append(iter(descr.fields.iteritems()))
 * 
 */
        __pyx_v_f += 2;

        /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":185
 *                         f[1] = 123 #"{"
 *                         f += 2
 *                         stack.append(iter(descr.fields.iteritems()))             # <<<<<<<<<<<<<<
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 */
        __pyx_7 = PyObject_GetAttr(__pyx_v_descr->fields, __pyx_kp_iteritems); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_6 = PyObject_Call(__pyx_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_7); __pyx_7 = 0;
        __pyx_2 = PyObject_GetIter(__pyx_6); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_6); __pyx_6 = 0;
        __pyx_4 = PyList_Append(((PyObject *)__pyx_v_stack), __pyx_2); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
      }
      __pyx_L23:;
    }
  }
  __pyx_L12:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("numpy.ndarray.__getbuffer__");
  __pyx_r = -1;
  Py_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  if (__pyx_v_info->obj == Py_None) { Py_DECREF(Py_None); __pyx_v_info->obj = NULL; }
  __pyx_L2:;
  Py_XDECREF(__pyx_v_descr);
  Py_DECREF(__pyx_v_stack);
  Py_DECREF(__pyx_v_iterator);
  return __pyx_r;
}

/* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":187
 *                         stack.append(iter(descr.fields.iteritems()))
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 */

static void __pyx_pf_5numpy_7ndarray___releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/
static void __pyx_pf_5numpy_7ndarray___releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  int __pyx_1;
  int __pyx_2;

  /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":188
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  __pyx_1 = PyArray_HASFIELDS(((PyArrayObject *)__pyx_v_self));
  if (__pyx_1) {

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":189
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)             # <<<<<<<<<<<<<<
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 stdlib.free(info.strides)
 */
    free(__pyx_v_info->format);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":190
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.strides)
 *                 # info.shape was stored after info.strides in the same block
 */
  __pyx_2 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t)));
  if (__pyx_2) {

    /* "/usr/media/misc/local/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":191
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 stdlib.free(info.strides)             # <<<<<<<<<<<<<<
 *                 # info.shape was stored after info.strides in the same block
 * 
 */
    free(__pyx_v_info->strides);
    goto __pyx_L6;
  }
  __pyx_L6:;

}
static struct __pyx_vtabstruct_13_alsa_backend_AlsaDevice __pyx_vtable_13_alsa_backend_AlsaDevice;

static PyObject *__pyx_tp_new_13_alsa_backend_AlsaDevice(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_13_alsa_backend_AlsaDevice *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_13_alsa_backend_AlsaDevice *)o);
  p->__pyx_vtab = __pyx_vtabptr_13_alsa_backend_AlsaDevice;
  return o;
}

static void __pyx_tp_dealloc_13_alsa_backend_AlsaDevice(PyObject *o) {
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_13_alsa_backend_10AlsaDevice___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static struct PyMethodDef __pyx_methods_13_alsa_backend_AlsaDevice[] = {
  {"play", (PyCFunction)__pyx_pf_13_alsa_backend_10AlsaDevice_play, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_AlsaDevice = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_AlsaDevice = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_AlsaDevice = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_AlsaDevice = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_13_alsa_backend_AlsaDevice = {
  PyVarObject_HEAD_INIT(0, 0)
  "_alsa_backend.AlsaDevice", /*tp_name*/
  sizeof(struct __pyx_obj_13_alsa_backend_AlsaDevice), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_13_alsa_backend_AlsaDevice, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_AlsaDevice, /*tp_as_number*/
  &__pyx_tp_as_sequence_AlsaDevice, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_AlsaDevice, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_AlsaDevice, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_13_alsa_backend_AlsaDevice, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_13_alsa_backend_10AlsaDevice___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_13_alsa_backend_AlsaDevice, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static struct PyMethodDef __pyx_methods[] = {
  {"alsa_version", (PyCFunction)__pyx_pf_13_alsa_backend_alsa_version, METH_NOARGS, __pyx_doc_13_alsa_backend_alsa_version},
  {"enumerate_devices", (PyCFunction)__pyx_pf_13_alsa_backend_enumerate_devices, METH_NOARGS, __pyx_doc_13_alsa_backend_enumerate_devices},
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "_alsa_backend",
    0, /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp___init__, __pyx_k___init__, sizeof(__pyx_k___init__), 1, 1, 1},
  {&__pyx_kp_play, __pyx_k_play, sizeof(__pyx_k_play), 1, 1, 1},
  {&__pyx_kp___dealloc__, __pyx_k___dealloc__, sizeof(__pyx_k___dealloc__), 1, 1, 1},
  {&__pyx_kp_fs, __pyx_k_fs, sizeof(__pyx_k_fs), 1, 1, 1},
  {&__pyx_kp_nchannels, __pyx_k_nchannels, sizeof(__pyx_k_nchannels), 1, 1, 1},
  {&__pyx_kp_input, __pyx_k_input, sizeof(__pyx_k_input), 1, 1, 1},
  {&__pyx_kp_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 1, 1, 1},
  {&__pyx_kp_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 1, 1},
  {&__pyx_kp_AlsaException, __pyx_k_AlsaException, sizeof(__pyx_k_AlsaException), 0, 1, 1},
  {&__pyx_kp_Exception, __pyx_k_Exception, sizeof(__pyx_k_Exception), 1, 1, 1},
  {&__pyx_kp_append, __pyx_k_append, sizeof(__pyx_k_append), 1, 1, 1},
  {&__pyx_kp_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 1, 1, 1},
  {&__pyx_kp_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 1, 1, 1},
  {&__pyx_kp_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 1, 1, 1},
  {&__pyx_kp_31, __pyx_k_31, sizeof(__pyx_k_31), 1, 1, 1},
  {&__pyx_kp_size, __pyx_k_size, sizeof(__pyx_k_size), 1, 1, 1},
  {&__pyx_kp_asfortranarray, __pyx_k_asfortranarray, sizeof(__pyx_k_asfortranarray), 1, 1, 1},
  {&__pyx_kp_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 0},
  {&__pyx_kp_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 0},
  {&__pyx_kp_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 0},
  {&__pyx_kp_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 0},
  {&__pyx_kp_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 0},
  {&__pyx_kp_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 0},
  {&__pyx_kp_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 0, 0},
  {&__pyx_kp_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 0},
  {&__pyx_kp_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 0, 0},
  {&__pyx_kp_35, __pyx_k_35, sizeof(__pyx_k_35), 0, 0, 0},
  {&__pyx_kp_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 0, 0},
  {&__pyx_kp_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 0, 0},
  {&__pyx_kp_38, __pyx_k_38, sizeof(__pyx_k_38), 0, 0, 0},
  {&__pyx_kp_39, __pyx_k_39, sizeof(__pyx_k_39), 0, 0, 0},
  {&__pyx_kp_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 0},
  {&__pyx_kp_41, __pyx_k_41, sizeof(__pyx_k_41), 0, 0, 0},
  {&__pyx_kp_42, __pyx_k_42, sizeof(__pyx_k_42), 0, 0, 0},
  {&__pyx_kp_43, __pyx_k_43, sizeof(__pyx_k_43), 0, 0, 0},
  {&__pyx_kp_44, __pyx_k_44, sizeof(__pyx_k_44), 0, 0, 0},
  {&__pyx_kp_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 0, 0},
  {&__pyx_kp_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 0, 0},
  {&__pyx_kp_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 0, 0},
  {&__pyx_kp_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 0, 0},
  {&__pyx_kp_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 0},
  {&__pyx_kp___getbuffer__, __pyx_k___getbuffer__, sizeof(__pyx_k___getbuffer__), 1, 1, 1},
  {&__pyx_kp___releasebuffer__, __pyx_k___releasebuffer__, sizeof(__pyx_k___releasebuffer__), 1, 1, 1},
  {&__pyx_kp_info, __pyx_k_info, sizeof(__pyx_k_info), 1, 1, 1},
  {&__pyx_kp_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 1, 1, 1},
  {&__pyx_kp_iteritems, __pyx_k_iteritems, sizeof(__pyx_k_iteritems), 1, 1, 1},
  {&__pyx_kp_next, __pyx_k_next, sizeof(__pyx_k_next), 1, 1, 1},
  {&__pyx_kp_StopIteration, __pyx_k_StopIteration, sizeof(__pyx_k_StopIteration), 1, 1, 1},
  {&__pyx_kp_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 1, 1, 1},
  {&__pyx_kp_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 1, 1, 1},
  {&__pyx_kp_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 0},
  {&__pyx_kp_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 0},
  {&__pyx_kp_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 0},
  {&__pyx_kp_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 0},
  {&__pyx_kp_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 0},
  {0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_Exception = __Pyx_GetName(__pyx_b, __pyx_kp_Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_kp_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_kp_StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_kp_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitGlobals(void) {
  __pyx_int_32568 = PyInt_FromLong(32568); if (unlikely(!__pyx_int_32568)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC init_alsa_backend(void); /*proto*/
PyMODINIT_FUNC init_alsa_backend(void)
#else
PyMODINIT_FUNC PyInit__alsa_backend(void); /*proto*/
PyMODINIT_FUNC PyInit__alsa_backend(void)
#endif
{
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Library function declarations ---*/
  __pyx_init_filenames();
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("_alsa_backend", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  #if PY_MAJOR_VERSION < 3
  Py_INCREF(__pyx_m);
  #endif
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME);
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_skip_dispatch = 0;
  /*--- Global init code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_13_alsa_backend_AlsaDevice = &__pyx_vtable_13_alsa_backend_AlsaDevice;
  *(void(**)(void))&__pyx_vtable_13_alsa_backend_AlsaDevice._play = (void(*)(void))__pyx_f_13_alsa_backend_10AlsaDevice__play;
  if (PyType_Ready(&__pyx_type_13_alsa_backend_AlsaDevice) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_13_alsa_backend_AlsaDevice.tp_dict, __pyx_vtabptr_13_alsa_backend_AlsaDevice) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "AlsaDevice", (PyObject *)&__pyx_type_13_alsa_backend_AlsaDevice) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_13_alsa_backend_AlsaDevice = &__pyx_type_13_alsa_backend_AlsaDevice;
  /*--- Type import code ---*/
  __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr)); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject)); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":1
 * import numpy as np             # <<<<<<<<<<<<<<
 * cimport numpy as cnp
 * cimport stdlib
 */
  __pyx_1 = __Pyx_Import(__pyx_kp_numpy, 0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_np, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":7
 * from alsa cimport *
 * 
 * cdef int BUFFER_TIME  = 500000             # <<<<<<<<<<<<<<
 * cdef int PERIOD_TIME  = 0
 * 
 */
  __pyx_v_13_alsa_backend_BUFFER_TIME = 500000;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":8
 * 
 * cdef int BUFFER_TIME  = 500000
 * cdef int PERIOD_TIME  = 0             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "alsa/asoundlib.h":
 */
  __pyx_v_13_alsa_backend_PERIOD_TIME = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/_alsa_backend.pyx":19
 *         object PyString_FromStringAndSize(char *v, int len)
 * 
 * class AlsaException(Exception):             # <<<<<<<<<<<<<<
 *         pass
 * 
 */
  __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_builtin_Exception);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_builtin_Exception);
  __pyx_3 = __Pyx_CreateClass(((PyObject *)__pyx_2), ((PyObject *)__pyx_1), __pyx_kp_AlsaException, "_alsa_backend"); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_AlsaException, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;

  /* "/usr/media/src/dsp/scikits/git/audiolab/scikits/audiolab/soundio/alsa/alsa.pxd":1
 * # This file was generated by cycodegenlib, DO NOT EDIT             # <<<<<<<<<<<<<<
 * # Generated by command /home/david/local/bin/xml2cython.py -l alsa -i input -o alsa.pxd alsa/asoundlib.h asoundlib.xml
 * # Codegenlib version 0.3dev
 */
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_alsa_backend");
  #if PY_MAJOR_VERSION >= 3
  return NULL;
  #endif
}

static const char *__pyx_filenames[] = {
  "_alsa_backend.pyx",
  "numpy.pxd",
};

/* Runtime support code */

static void __pyx_init_filenames(void) {
  __pyx_f = __pyx_filenames;
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AS_STRING(kw_name));
        #endif
}

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *number, *more_or_less;

    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    number = (num_expected == 1) ? "" : "s";
    PyErr_Format(PyExc_TypeError,
        #if PY_VERSION_HEX < 0x02050000
            "%s() takes %s %d positional argument%s (%d given)",
        #else
            "%s() takes %s %zd positional argument%s (%zd given)",
        #endif
        func_name, more_or_less, num_expected, number, num_found);
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;

    while (PyDict_Next(kwds, &pos, &key, &value)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
        #else
        if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
        #endif
            goto invalid_keyword_type;
        } else {
            name = argnames;
            while (*name && (**name != key)) name++;
            if (*name) {
                if (name < first_kw_arg) goto arg_passed_twice;
                values[name-argnames] = value;
            } else {
                for (name = first_kw_arg; *name; name++) {
                    #if PY_MAJOR_VERSION >= 3
                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                        PyUnicode_Compare(**name, key) == 0) break;
                    #else
                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                        strcmp(PyString_AS_STRING(**name),
                               PyString_AS_STRING(key)) == 0) break;
                    #endif
                }
                if (*name) {
                    values[name-argnames] = value;
                } else {
                    /* unexpected keyword found */
                    for (name=argnames; name != first_kw_arg; name++) {
                        if (**name == key) goto arg_passed_twice;
                        #if PY_MAJOR_VERSION >= 3
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
                        #else
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                            strcmp(PyString_AS_STRING(**name),
                                   PyString_AS_STRING(key)) == 0) goto arg_passed_twice;
                        #endif
                    }
                    if (kwds2) {
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
                    } else {
                        goto invalid_keyword;
                    }
                }
            }
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
  if (info->buf == NULL) return;
  if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
  __Pyx_ReleaseBuffer(info);
}

static INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) {
  buf->buf = NULL;
  buf->obj = NULL;
  buf->strides = __Pyx_zeros;
  buf->shape = __Pyx_zeros;
  buf->suboffsets = __Pyx_minusones;
}

static INLINE const char* __Pyx_ConsumeWhitespace(const char* ts) {
  while (1) {
    switch (*ts) {
      case '@':
      case 10:
      case 13:
      case ' ':
        ++ts;
        break;
      case '=':
      case '<':
      case '>':
      case '!':
        PyErr_SetString(PyExc_ValueError, "Buffer acquisition error: Only native byte order, size and alignment supported.");
        return NULL;               
      default:
        return ts;
    }
  }
}

static void __Pyx_BufferNdimError(Py_buffer* buffer, int expected_ndim) {
  PyErr_Format(PyExc_ValueError,
               "Buffer has wrong number of dimensions (expected %d, got %d)",
               expected_ndim, buffer->ndim);
}

static const char* __Pyx_DescribeTokenInFormatString(const char* ts) {
  switch (*ts) {
    case 'b': return "char";
    case 'B': return "unsigned char";
    case 'h': return "short";
    case 'H': return "unsigned short";
    case 'i': return "int";
    case 'I': return "unsigned int";
    case 'l': return "long";
    case 'L': return "unsigned long";
    case 'q': return "long long";
    case 'Q': return "unsigned long long";
    case 'f': return "float";
    case 'd': return "double";
    case 'g': return "long double";
    case 'Z': switch (*(ts+1)) {
        case 'f': return "complex float";
        case 'd': return "complex double";
        case 'g': return "complex long double";
        default: return "unparseable format string";
    }
    case 'T': return "a struct";
    case 'O': return "Python object";
    case 'P': return "a pointer";
    default: return "unparseable format string";
  }
}

static const char* __Pyx_CheckTypestring_nn___pyx_t_5numpy_int16_t(const char* ts) {
    int ok;
    ts = __Pyx_ConsumeWhitespace(ts); if (!ts) return NULL;
    if (*ts == '1') ++ts;
    switch (*ts) {
      case 'b': ok = (sizeof(__pyx_t_5numpy_int16_t) == sizeof(char) && (__pyx_t_5numpy_int16_t)-1 < 0); break;
      case 'h': ok = (sizeof(__pyx_t_5numpy_int16_t) == sizeof(short) && (__pyx_t_5numpy_int16_t)-1 < 0); break;
      case 'i': ok = (sizeof(__pyx_t_5numpy_int16_t) == sizeof(int) && (__pyx_t_5numpy_int16_t)-1 < 0); break;
      case 'l': ok = (sizeof(__pyx_t_5numpy_int16_t) == sizeof(long) && (__pyx_t_5numpy_int16_t)-1 < 0); break;
      case 'q': ok = (sizeof(__pyx_t_5numpy_int16_t) == sizeof(long long) && (__pyx_t_5numpy_int16_t)-1 < 0); break;
      default: ok = 0;
    }
    if (!(ok)) {
      PyErr_Format(PyExc_ValueError, "Buffer dtype mismatch (expected numpy.int16_t, got %s)", __Pyx_DescribeTokenInFormatString(ts));
      return NULL;
    }
    ++ts;
    return ts;
  }
  
static int __Pyx_GetBuffer_nn___pyx_t_5numpy_int16_t(PyObject* obj, Py_buffer* buf, int flags, int nd, int cast) {
  const char* ts;
  if (obj == Py_None) {
    __Pyx_ZeroBuffer(buf);
    return 0;
  }
  buf->buf = NULL;
  if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail;
  if (buf->ndim != nd) {
    __Pyx_BufferNdimError(buf, nd);
    goto fail;
  }
  if (!cast) {
    ts = buf->format;
    ts = __Pyx_ConsumeWhitespace(ts);
    if (!ts) goto fail;
    ts = __Pyx_CheckTypestring_nn___pyx_t_5numpy_int16_t(ts);
    if (!ts) goto fail;
    ts = __Pyx_ConsumeWhitespace(ts);
    if (!ts) goto fail;
    if (*ts != 0) {
      PyErr_Format(PyExc_ValueError,
        "Buffer dtype mismatch (expected end, got %s)",
        __Pyx_DescribeTokenInFormatString(ts));
      goto fail;
    }
  } else {
    if (buf->itemsize != sizeof(__pyx_t_5numpy_int16_t)) {
      PyErr_SetString(PyExc_ValueError,
        "Attempted cast of buffer to datatype of different size.");
      goto fail;
    }
  }
  if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
  return 0;
fail:;
  __Pyx_ZeroBuffer(buf);
  return -1;
}
static void __Pyx_RaiseBufferFallbackError(void) {
  PyErr_Format(PyExc_ValueError,
     "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!");
}


static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();

    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}

static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;

    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}



static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (Py_TYPE(obj) == type) return 1;
    }
    else {
        if (PyObject_TypeCheck(obj, type)) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%s' has incorrect type (expected %s, got %s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
  #if PY_VERSION_HEX >= 0x02060000
  if (Py_TYPE(obj)->tp_flags & Py_TPFLAGS_HAVE_NEWBUFFER)
      return PyObject_GetBuffer(obj, view, flags);
  #endif
  if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pf_5numpy_7ndarray___getbuffer__(obj, view, flags);
  else {
  PyErr_Format(PyExc_TypeError, "'%100s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
  return -1;
    }
}

static void __Pyx_ReleaseBuffer(Py_buffer *view) {
  PyObject* obj = view->obj;
  if (obj) {
if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) __pyx_pf_5numpy_7ndarray___releasebuffer__(obj, view);
    Py_DECREF(obj);
    view->obj = NULL;
  }
}

#endif

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
    PyObject *__import__ = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    __import__ = PyObject_GetAttrString(__pyx_b, "__import__");
    if (!__import__)
        goto bad;
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    module = PyObject_CallFunction(__import__, "OOOO",
        name, global_dict, empty_dict, list);
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(__import__);
    Py_XDECREF(empty_dict);
    return module;
}

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result)
        PyErr_SetObject(PyExc_NameError, name);
    return result;
}

static PyObject *__Pyx_CreateClass(
    PyObject *bases, PyObject *dict, PyObject *name, char *modname)
{
    PyObject *py_modname;
    PyObject *result = 0;

    #if PY_MAJOR_VERSION < 3
    py_modname = PyString_FromString(modname);
    #else
    py_modname = PyUnicode_FromString(modname);
    #endif
    if (!py_modname)
        goto bad;
    if (PyDict_SetItemString(dict, "__module__", py_modname) < 0)
        goto bad;
    #if PY_MAJOR_VERSION < 3
    result = PyClass_New(bases, dict, name);
    #else
    result = PyObject_CallFunctionObjArgs((PyObject *)&PyType_Type, name, bases, dict, NULL);
    #endif
bad:
    Py_XDECREF(py_modname);
    return result;
}

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    /* First, check the traceback argument, replacing None with NULL. */
    if (tb == Py_None) {
        Py_DECREF(tb);
        tb = 0;
    }
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto raise_error;
    }
    /* Next, replace a missing value with None */
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    #if PY_VERSION_HEX < 0x02050000
    if (!PyClass_Check(type))
    #else
    if (!PyType_Check(type))
    #endif
    {
        /* Raising an instance.  The value should be a dummy. */
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        /* Normalize to raise <class>, <instance> */
        Py_DECREF(value);
        value = type;
        #if PY_VERSION_HEX < 0x02050000
            if (PyInstance_Check(type)) {
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
                Py_INCREF(type);
            }
            else {
                type = 0;
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception must be an old-style class or instance");
                goto raise_error;
            }
        #else
            type = (PyObject*) Py_TYPE(type);
            Py_INCREF(type);
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception class must be a subclass of BaseException");
                goto raise_error;
            }
        #endif
    }
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}

#if PY_MAJOR_VERSION < 3
static PyObject *__Pyx_GetStdout(void) {
    PyObject *f = PySys_GetObject("stdout");
    if (!f) {
        PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
    }
    return f;
}

static int __Pyx_Print(PyObject *arg_tuple, int newline) {
    PyObject *f;
    PyObject* v;
    int i;
    
    if (!(f = __Pyx_GetStdout()))
        return -1;
    for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) {
        if (PyFile_SoftSpace(f, 1)) {
            if (PyFile_WriteString(" ", f) < 0)
                return -1;
        }
        v = PyTuple_GET_ITEM(arg_tuple, i);
        if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0)
            return -1;
        if (PyString_Check(v)) {
            char *s = PyString_AsString(v);
            Py_ssize_t len = PyString_Size(v);
            if (len > 0 &&
                isspace(Py_CHARMASK(s[len-1])) &&
                s[len-1] != ' ')
                    PyFile_SoftSpace(f, 0);
        }
    }
    if (newline) {
        if (PyFile_WriteString("\n", f) < 0)
            return -1;
        PyFile_SoftSpace(f, 0);
    }
    return 0;
}

#else /* Python 3 has a print function */
static int __Pyx_Print(PyObject *arg_tuple, int newline) {
    PyObject* kwargs = 0;
    PyObject* result = 0;
    PyObject* end_string;
    if (!__pyx_print) {
        __pyx_print = PyObject_GetAttrString(__pyx_b, "print");
        if (!__pyx_print)
            return -1;
    }
    if (!newline) {
        if (!__pyx_print_kwargs) {
            __pyx_print_kwargs = PyDict_New();
            if (!__pyx_print_kwargs)
                return -1;
            end_string = PyUnicode_FromStringAndSize(" ", 1);
            if (!end_string)
                return -1;
            if (PyDict_SetItemString(__pyx_print_kwargs, "end", end_string) < 0) {
                Py_DECREF(end_string);
                return -1;
            }
            Py_DECREF(end_string);
        }
        kwargs = __pyx_print_kwargs;
    }
    result = PyObject_Call(__pyx_print, arg_tuple, kwargs);
    if (!result)
        return -1;
    Py_DECREF(result);
    return 0;
}
#endif

static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (obj == Py_None || PyObject_TypeCheck(obj, type))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s",
        Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

static INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}

static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    __Pyx_ErrFetch(type, value, tb);
    PyErr_NormalizeException(type, value, tb);
    if (PyErr_Occurred())
        goto bad;
    Py_INCREF(*type);
    Py_INCREF(*value);
    Py_INCREF(*tb);
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = *type;
    tstate->exc_value = *value;
    tstate->exc_traceback = *tb;
    /* Make sure tstate is in a consistent state when we XDECREF
    these objects (XDECREF may run arbitrary code). */
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
    return 0;
bad:
    Py_XDECREF(*type);
    Py_XDECREF(*value);
    Py_XDECREF(*tb);
    return -1;
}


static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
    PyObject *pycobj = 0;
    int result;
    
    pycobj = PyCObject_FromVoidPtr(vtable, 0);
    if (!pycobj)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", pycobj) < 0)
        goto bad;
    result = 0;
    goto done;

bad:
    result = -1;
done:
    Py_XDECREF(pycobj);
    return result;
}

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    long size)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;

    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(class_name);
    #else
    py_name = PyUnicode_FromString(class_name);
    #endif
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError, 
            "%s.%s is not a type object",
            module_name, class_name);
        goto bad;
    }
    if (((PyTypeObject *)result)->tp_basicsize != size) {
        PyErr_Format(PyExc_ValueError, 
            "%s.%s does not appear to be the correct type object",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;

    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(name);
    #else
    py_name = PyUnicode_FromString(name);
    #endif
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(const char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyObject *empty_string = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;

    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(__pyx_filename);
    #else
    py_srcfile = PyUnicode_FromString(__pyx_filename);
    #endif
    if (!py_srcfile) goto bad;
    if (__pyx_clineno) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    #if PY_MAJOR_VERSION < 3
    empty_string = PyString_FromStringAndSize("", 0);
    #else
    empty_string = PyBytes_FromStringAndSize("", 0);
    #endif
    if (!empty_string) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        #if PY_MAJOR_VERSION >= 3
        0,            /*int kwonlyargcount,*/
        #endif
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        empty_string, /*PyObject *code,*/
        __pyx_empty_tuple,  /*PyObject *consts,*/
        __pyx_empty_tuple,  /*PyObject *names,*/
        __pyx_empty_tuple,  /*PyObject *varnames,*/
        __pyx_empty_tuple,  /*PyObject *freevars,*/
        __pyx_empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        empty_string  /*PyObject *lnotab*/
    );
    if (!py_code) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    Py_XDECREF(empty_string);
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode && (!t->is_identifier)) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else  /* Python 3+ has unicode identifiers */
        if (t->is_identifier || (t->is_unicode && t->intern)) {
            *t->p = PyUnicode_InternFromString(t->s);
        } else if (t->is_unicode) {
            *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

/* Type Conversion Functions */

static INLINE Py_ssize_t __pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject* x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}

static INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   if (x == Py_True) return 1;
   else if (x == Py_False) return 0;
   else return PyObject_IsTrue(x);
}

static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x) {
    if (PyInt_CheckExact(x)) {
        return PyInt_AS_LONG(x);
    }
    else if (PyLong_CheckExact(x)) {
        return PyLong_AsLongLong(x);
    }
    else {
        PY_LONG_LONG val;
        PyObject* tmp = PyNumber_Int(x); if (!tmp) return (PY_LONG_LONG)-1;
        val = __pyx_PyInt_AsLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
    if (PyInt_CheckExact(x)) {
        long val = PyInt_AS_LONG(x);
        if (unlikely(val < 0)) {
            PyErr_SetString(PyExc_TypeError, "Negative assignment to unsigned type.");
            return (unsigned PY_LONG_LONG)-1;
        }
        return val;
    }
    else if (PyLong_CheckExact(x)) {
        return PyLong_AsUnsignedLongLong(x);
    }
    else {
        PY_LONG_LONG val;
        PyObject* tmp = PyNumber_Int(x); if (!tmp) return (PY_LONG_LONG)-1;
        val = __pyx_PyInt_AsUnsignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}


static INLINE unsigned char __pyx_PyInt_unsigned_char(PyObject* x) {
    if (sizeof(unsigned char) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        unsigned char val = (unsigned char)long_val;
        if (unlikely((val != long_val)  || (long_val < 0))) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned char");
            return (unsigned char)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE unsigned short __pyx_PyInt_unsigned_short(PyObject* x) {
    if (sizeof(unsigned short) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        unsigned short val = (unsigned short)long_val;
        if (unlikely((val != long_val)  || (long_val < 0))) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned short");
            return (unsigned short)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE char __pyx_PyInt_char(PyObject* x) {
    if (sizeof(char) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        char val = (char)long_val;
        if (unlikely((val != long_val) )) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to char");
            return (char)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE short __pyx_PyInt_short(PyObject* x) {
    if (sizeof(short) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        short val = (short)long_val;
        if (unlikely((val != long_val) )) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to short");
            return (short)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE int __pyx_PyInt_int(PyObject* x) {
    if (sizeof(int) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        int val = (int)long_val;
        if (unlikely((val != long_val) )) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to int");
            return (int)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE long __pyx_PyInt_long(PyObject* x) {
    if (sizeof(long) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        long val = (long)long_val;
        if (unlikely((val != long_val) )) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to long");
            return (long)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE signed char __pyx_PyInt_signed_char(PyObject* x) {
    if (sizeof(signed char) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        signed char val = (signed char)long_val;
        if (unlikely((val != long_val) )) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed char");
            return (signed char)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE signed short __pyx_PyInt_signed_short(PyObject* x) {
    if (sizeof(signed short) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        signed short val = (signed short)long_val;
        if (unlikely((val != long_val) )) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed short");
            return (signed short)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE signed int __pyx_PyInt_signed_int(PyObject* x) {
    if (sizeof(signed int) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        signed int val = (signed int)long_val;
        if (unlikely((val != long_val) )) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed int");
            return (signed int)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE signed long __pyx_PyInt_signed_long(PyObject* x) {
    if (sizeof(signed long) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        signed long val = (signed long)long_val;
        if (unlikely((val != long_val) )) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed long");
            return (signed long)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE long double __pyx_PyInt_long_double(PyObject* x) {
    if (sizeof(long double) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        long double val = (long double)long_val;
        if (unlikely((val != long_val) )) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to long double");
            return (long double)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

