~ubuntu-branches/ubuntu/utopic/python-pyo/utopic-proposed

« back to all changes in this revision

Viewing changes to src/engine/servermodule.c

  • Committer: Package Import Robot
  • Author(s): Tiago Bortoletto Vaz
  • Date: 2014-04-13 00:15:48 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20140413001548-yz0sd86hboij8exu
Tags: 0.6.9-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2136
2136
    return Py_None;
2137
2137
}
2138
2138
 
2139
 
/* Like the Server_boot() but without reinitializing the buffers */
2140
 
static PyObject *
2141
 
Server_flush(Server *self)
2142
 
{
2143
 
    int audioerr = 0;
2144
 
    int i;
2145
 
    if (self->server_booted == 1) {
2146
 
        Server_error(self, "Server already booted!\n");
2147
 
        Py_INCREF(Py_None);
2148
 
        return Py_None;
2149
 
    }
2150
 
    self->server_started = 0;
2151
 
    self->stream_count = 0;
2152
 
    self->elapsedSamples = 0;
2153
 
 
2154
 
    self->streams = PyList_New(0);
2155
 
    switch (self->audio_be_type) {
2156
 
        case PyoPortaudio:
2157
 
            audioerr = Server_pa_init(self);
2158
 
            break;
2159
 
        case PyoJack:
2160
 
#ifdef USE_JACK
2161
 
            audioerr = Server_jack_init(self);
2162
 
            if (audioerr < 0) {
2163
 
                Server_jack_deinit(self);
2164
 
            }
2165
 
#else
2166
 
            audioerr = -1;
2167
 
            Server_error(self, "Pyo built without Jack support\n");
2168
 
#endif
2169
 
            break;
2170
 
        case PyoCoreaudio:
2171
 
#ifdef USE_COREAUDIO
2172
 
            audioerr = Server_coreaudio_init(self);
2173
 
            if (audioerr < 0) {
2174
 
                Server_coreaudio_deinit(self);
2175
 
            }
2176
 
#else
2177
 
            audioerr = -1;
2178
 
            Server_error(self, "Pyo built without Coreaudio support\n");
2179
 
#endif
2180
 
            break;
2181
 
        case PyoOffline:
2182
 
            audioerr = Server_offline_init(self);
2183
 
            if (audioerr < 0) {
2184
 
                Server_offline_deinit(self);
2185
 
            }
2186
 
            break;
2187
 
        case PyoOfflineNB:
2188
 
            audioerr = Server_offline_init(self);
2189
 
            if (audioerr < 0) {
2190
 
                Server_offline_deinit(self);
2191
 
            }
2192
 
            break;
2193
 
        case PyoEmbedded:
2194
 
            audioerr = Server_embedded_init(self);
2195
 
            if (audioerr < 0) {
2196
 
                Server_embedded_deinit(self);
2197
 
            }
2198
 
            break;
2199
 
    }
2200
 
 
2201
 
    for (i=0; i<self->bufferSize*self->nchnls; i++) {
2202
 
        self->input_buffer[i] = 0.0;
2203
 
        self->output_buffer[i] = 0.0;
2204
 
    }
2205
 
    
2206
 
    if (audioerr == 0) {
2207
 
        self->server_booted = 1;
2208
 
    }
2209
 
    else {
2210
 
        self->server_booted = 0;
2211
 
        Server_error(self, "\nServer not booted.\n");
2212
 
    }    
2213
 
    
2214
 
    Py_INCREF(Py_None);
2215
 
    return Py_None;
2216
 
}
2217
 
 
2218
2139
static PyObject *
2219
2140
Server_start(Server *self)
2220
2141
{
2240
2161
    self->server_started = 1;
2241
2162
    self->timeStep = (int)(0.01 * self->samplingRate);
2242
2163
 
2243
 
    if (self->audio_be_type != PyoOffline && self->audio_be_type != PyoOfflineNB) {
 
2164
    if (self->audio_be_type != PyoOffline && self->audio_be_type != PyoOfflineNB && self->audio_be_type != PyoEmbedded) {
2244
2165
        midierr = Server_pm_init(self);
2245
2166
        Server_debug(self, "PortMidi initialization return code : %d.\n", midierr);
2246
2167
    }
2742
2663
    {"getMidiActive", (PyCFunction)Server_getMidiActive, METH_NOARGS, "Returns 1 if midi callback is active, otherwise returns 0."},
2743
2664
    {"_setDefaultRecPath", (PyCFunction)Server_setDefaultRecPath, METH_VARARGS|METH_KEYWORDS, "Sets the default recording path."},
2744
2665
    {"setServer", (PyCFunction)Server_setServer, METH_NOARGS, "Sets this server as the one to use for new objects when using the embedded device"},
2745
 
    {"flush", (PyCFunction)Server_flush, METH_NOARGS, "Flush the server objects"},
2746
2666
    {"getInputAddr", (PyCFunction)Server_getInputAddr, METH_NOARGS, "Get the embedded device input buffer memory address"},
2747
2667
    {"getOutputAddr", (PyCFunction)Server_getOutputAddr, METH_NOARGS, "Get the embedded device output buffer memory address"},
2748
2668
    {"getServerID", (PyCFunction)Server_getServerID, METH_NOARGS, "Get the embedded device server memory address"},