comparison PyPlugin.cpp @ 67:146d14ab15e7

Debug output: off by default, on with VAMPY_VERBOSE environment variable
author Chris Cannam
date Mon, 17 Nov 2014 10:03:44 +0000
parents 5664fe298af2
children 40a01bb24209 f92587bedb2c
comparison
equal deleted inserted replaced
66:5664fe298af2 67:146d14ab15e7
12 #include <Python.h> 12 #include <Python.h>
13 #include "PyPlugin.h" 13 #include "PyPlugin.h"
14 #include "PyTypeInterface.h" 14 #include "PyTypeInterface.h"
15 #include <stdlib.h> 15 #include <stdlib.h>
16 #include "PyExtensionModule.h" 16 #include "PyExtensionModule.h"
17 17 #include "Debug.h"
18 18
19 #ifdef _WIN32 19 #ifdef _WIN32
20 #define PATHSEP ('\\') 20 #define PATHSEP ('\\')
21 #else 21 #else
22 #define PATHSEP ('/') 22 #define PATHSEP ('/')
48 m_numpyInstalled(numpyInstalled), 48 m_numpyInstalled(numpyInstalled),
49 m_processFailure(false) 49 m_processFailure(false)
50 { 50 {
51 m_ti.setInputSampleRate(inputSampleRate); 51 m_ti.setInputSampleRate(inputSampleRate);
52 MutexLocker locker(&m_pythonInterpreterMutex); 52 MutexLocker locker(&m_pythonInterpreterMutex);
53 cerr << "Creating instance " << m_instcount << " of " << pluginKey << endl; 53 DSTREAM << "Creating instance " << m_instcount << " of " << pluginKey << endl;
54 54
55 // Create an instance 55 // Create an instance
56 Py_INCREF(m_pyClass); 56 Py_INCREF(m_pyClass);
57 PyObject *pyInputSampleRate = PyFloat_FromDouble(inputSampleRate); 57 PyObject *pyInputSampleRate = PyFloat_FromDouble(inputSampleRate);
58 PyObject *args = PyTuple_Pack(1, pyInputSampleRate); 58 PyObject *args = PyTuple_Pack(1, pyInputSampleRate);
80 m_quitOnErrorFlag = (bool) (m_vampyFlags & vf_QUIT); 80 m_quitOnErrorFlag = (bool) (m_vampyFlags & vf_QUIT);
81 bool st_flag = (bool) (m_vampyFlags & vf_STRICT); 81 bool st_flag = (bool) (m_vampyFlags & vf_STRICT);
82 m_useRealTimeFlag = (bool) (m_vampyFlags & vf_REALTIME); 82 m_useRealTimeFlag = (bool) (m_vampyFlags & vf_REALTIME);
83 83
84 if (m_debugFlag) cerr << "Debug messages ON for Vampy plugin: " << m_class << endl; 84 if (m_debugFlag) cerr << "Debug messages ON for Vampy plugin: " << m_class << endl;
85 else cerr << "Debug messages OFF for Vampy plugin: " << m_class << endl; 85 else DSTREAM << "Debug messages OFF for Vampy plugin: " << m_class << endl;
86 86
87 if (m_debugFlag && m_quitOnErrorFlag) cerr << "Quit on type error ON for: " << m_class << endl; 87 if (m_debugFlag && m_quitOnErrorFlag) cerr << "Quit on type error ON for: " << m_class << endl;
88 88
89 if (m_debugFlag && st_flag) cerr << "Strict type conversion ON for: " << m_class << endl; 89 if (m_debugFlag && st_flag) cerr << "Strict type conversion ON for: " << m_class << endl;
90 m_ti.setStrictTypingFlag(st_flag); 90 m_ti.setStrictTypingFlag(st_flag);
101 if (m_pyInstance) Py_DECREF(m_pyInstance); 101 if (m_pyInstance) Py_DECREF(m_pyInstance);
102 //we increase the class refcount before creating an instance 102 //we increase the class refcount before creating an instance
103 if (m_pyClass) Py_DECREF(m_pyClass); 103 if (m_pyClass) Py_DECREF(m_pyClass);
104 if (m_pyProcess) Py_CLEAR(m_pyProcess); 104 if (m_pyProcess) Py_CLEAR(m_pyProcess);
105 105
106 #ifdef _DEBUG 106 DSTREAM << "PyPlugin::PyPlugin:" << m_class << " instance " << m_instcount << " deleted." << endl;
107 cerr << "PyPlugin::PyPlugin:" << m_class << " instance " << m_instcount << " deleted." << endl;
108 #endif
109 } 107 }
110 108
111 string 109 string
112 PyPlugin::getIdentifier() const 110 PyPlugin::getIdentifier() const
113 { 111 {