gephex--main--0.4--patch-1864
[email protected] Mon, 21 Mar 2005 19:17:56 +0100 (CET)
| Newsgroups | gmane.comp.video.gephex.devel |
|---|---|
| Message-ID | <[email protected]> |
Archive: [email protected] New revision: gephex--main--0.4--patch-1864 -- Revision: gephex--main--0.4--patch-1864 Archive: [email protected] Creator: The Gephex Source Archive <[email protected]> Date: Mon Mar 21 19:14:37 CET 2005 Standard-date: 2005-03-21 18:14:37 GMT New-files: modules/src/midiinmodule/.arch-ids/alsaseqmidiindriver.cpp.id modules/src/midiinmodule/.arch-ids/alsaseqmidiindriver.h.id modules/src/midiinmodule/alsaseqmidiindriver.cpp modules/src/midiinmodule/alsaseqmidiindriver.h Modified-files: modules/src/midiinmodule/Makefile.am modules/src/midiinmodule/alsamidiindriver.cpp modules/src/midiinmodule/midiinmodule.cpp modules/src/midiinmodule/midiinmodule.spec New-patches: [email protected]/gephex--main--0.4--patch-1864 [email protected]/gephex--alsaseq-midiin--0.4--base-0 [email protected]/gephex--alsaseq-midiin--0.4--patch-1 [email protected]/gephex--alsaseq-midiin--0.4--patch-2 [email protected]/gephex--alsaseq-midiin--0.4--patch-3 Summary: [MERGE-REQUEST] midi input changes Keywords: Patches applied: * [email protected]/gephex--alsaseq-midiin--0.4--base-0 tag of [email protected]/gephex--martin--0.4--patch-53 * [email protected]/gephex--alsaseq-midiin--0.4--patch-1 new linux alsa-sequencer midi input * [email protected]/gephex--alsaseq-midiin--0.4--patch-2 better error handling in midiin and bugfixes in alsaseq * [email protected]/gephex--alsaseq-midiin--0.4--patch-3 sync with main * added directories {arch}/gephex/gephex--alsaseq-midiin {arch}/gephex/gephex--alsaseq-midiin/gephex--alsaseq-midiin--0.4 {arch}/gephex/gephex--alsaseq-midiin/gephex--alsaseq-midiin--0.4/[email protected] {arch}/gephex/gephex--alsaseq-midiin/gephex--alsaseq-midiin--0.4/[email protected]/patch-log * added files modules/src/midiinmodule/.arch-ids/alsaseqmidiindriver.cpp.id modules/src/midiinmodule/.arch-ids/alsaseqmidiindriver.h.id modules/src/midiinmodule/alsaseqmidiindriver.cpp modules/src/midiinmodule/alsaseqmidiindriver.h {arch}/gephex/gephex--alsaseq-midiin/gephex--alsaseq-midiin--0.4/[email protected]/patch-log/base-0 {arch}/gephex/gephex--alsaseq-midiin/gephex--alsaseq-midiin--0.4/[email protected]/patch-log/patch-1 {arch}/gephex/gephex--alsaseq-midiin/gephex--alsaseq-midiin--0.4/[email protected]/patch-log/patch-2 {arch}/gephex/gephex--alsaseq-midiin/gephex--alsaseq-midiin--0.4/[email protected]/patch-log/patch-3 {arch}/gephex/gephex--main/gephex--main--0.4/[email protected]/patch-log/patch-1864 * modified files --- orig/modules/src/midiinmodule/Makefile.am +++ mod/modules/src/midiinmodule/Makefile.am @@ -13,7 +13,9 @@ if WITH_ASOUNDLIB ALSALIB_sOURCES = \ alsamidiindriver.cpp \ - alsamidiindriver.h + alsamidiindriver.h \ + alsaseqmidiindriver.cpp \ + alsaseqmidiindriver.h ALSALIB_lDFLAGS = -lasound endif --- orig/modules/src/midiinmodule/alsamidiindriver.cpp +++ mod/modules/src/midiinmodule/alsamidiindriver.cpp @@ -63,6 +63,7 @@ std::ostringstream error_msg; error_msg << "snd_rawmidi_open '" << device_name << "' failed: " << err; + m_impl->handle_in=0; throw std::runtime_error(error_msg.str().c_str()); } } --- orig/modules/src/midiinmodule/midiinmodule.cpp +++ mod/modules/src/midiinmodule/midiinmodule.cpp @@ -33,12 +33,14 @@ #endif #if defined(WITH_ASOUNDLIB) #include "alsamidiindriver.h" +#include "alsaseqmidiindriver.h" #endif #if defined(OS_WIN32) #include "wavemidiindriver.h" #endif +#include <cassert> typedef struct _MyInstance { @@ -111,97 +113,109 @@ int device = trim_int(inst->in_device->number, 0, 256); const char* driver_name = inst->in_driver->text; - if (my->driver_name == 0 || - my->drv == 0 || - strcmp(driver_name, my->driver_name) != 0) + try { - delete my->driver_name; - my->driver_name = strcopy(driver_name); - - if (my->drv) - { - my->drv->close(); - delete my->drv; - } + + if (my->driver_name == 0 || + my->drv == 0 || + strcmp(driver_name, my->driver_name) != 0) + { + delete[] my->driver_name; + my->driver_name = strcopy(driver_name); + delete my->drv; - if (strcmp(driver_name, "default") == 0) - { + if (strcmp(driver_name, "default") == 0) + { #if defined(WITH_OSS) - my->drv = new OSSMidiInDriver(); + my->drv = new OSSMidiInDriver(); #elif defined(WITH_ASOUNDLIB) - my->drv = new OSSMidiInDriver(); -#elif defined(OS_WIN32) - my->drv = new WaveMidiInDriver(); + my->drv = new AlsaSeqMidiInDriver(); +#elif defined(OS_WIN32) + my->drv = new WaveMidiInDriver(); #endif - } + } #if defined(WITH_OSS) - else if (strcmp(driver_name, "oss") == 0) - { - my->drv = new OSSMidiInDriver(); - } + else if (strcmp(driver_name, "oss") == 0) + { + my->drv = new OSSMidiInDriver(); + } #endif #if defined(WITH_ASOUNDLIB) - else if (strcmp(driver_name, "alsa") == 0) - { - my->drv = new AlsaMidiInDriver(); - } + else if (strcmp(driver_name, "alsa") == 0) + { + my->drv = new AlsaMidiInDriver(); + } + else if (strcmp(driver_name, "alsaseq") == 0) + { + my->drv = new AlsaSeqMidiInDriver(); + } #endif #if defined(OS_WIN32) - else if (strcmp(driver_name, "wavein") == 0) - { - my->drv = new WaveMidiInDriver(); - } + else if (strcmp(driver_name, "wavein") == 0) + { + my->drv = new WaveMidiInDriver(); + } #endif - else - { + else + { #if defined(OS_WIN32) - my->drv = new WaveMidiInDriver(); - s_log(2, "Unkown driver - using WaveIn driver"); + my->drv = new WaveMidiInDriver(); + s_log(2, "Unkown driver - using WaveIn driver"); #elif defined(WITH_OSS) - my->drv = new OSSMidiInDriver(); - s_log(2, "Unkown driver - using OSS driver"); -#elif defined(WITH_OSS) - my->drv = new AlsaMidiInDriver(); - s_log(2, "Unkown driver - using alsa driver"); -#endif - } - } - - if (device != my->device || !my->drv->is_open()) - { - my->device = device; + my->drv = new OSSMidiInDriver(); + s_log(2, "Unkown driver - using OSS driver"); +#elif defined(WITH_ALSA) + my->drv = new AlsaMidiInDriver(); + s_log(2, "Unkown driver - using alsa driver"); +#endif + } + } + + assert(my->drv != 0); + + if (device != my->device || !my->drv->is_open()) + { + my->device = device; - if (my->drv->is_open()) - my->drv->close(); + if (my->drv->is_open()) + my->drv->close(); + + assert(!my->drv->is_open()); - try - { - my->drv->open(device); - } - catch (std::exception& e) - { - char buf[128]; - snprintf(buf, sizeof(buf), "Error while opening: %s", e.what()); - s_log(0, buf); - } - } + try + { + my->drv->open(device); + } + catch (std::exception& e) + { + char buf[128]; + snprintf(buf, sizeof(buf), "Error while opening: %s", e.what()); + s_log(0, buf); + throw; + } + assert(my->drv->is_open()); + } - if (!my->drv->is_open()) - return; - - try - { - static const int MAX_MSG_LEN = 1024; - unsigned char buffer[MAX_MSG_LEN]; - int len = my->drv->read(buffer, sizeof(buffer)); + assert(my->drv->is_open()); - midi_set_buffer(inst->out_r, buffer, len); + try + { + static const int MAX_MSG_LEN = 1024; + unsigned char buffer[MAX_MSG_LEN]; + int len = my->drv->read(buffer, sizeof(buffer)); + + midi_set_buffer(inst->out_r, buffer, len); + } + catch (std::exception& e) + { + char buf[128]; + snprintf(buf, sizeof(buf), "Error while reading: %s", e.what()); + s_log(0, buf); + throw; + } } catch (std::exception& e) { - char buf[128]; - snprintf(buf, sizeof(buf), "Error while reading: %s", e.what()); - s_log(0, buf); + midi_set_buffer(inst->out_r, 0, 0); } - } --- orig/modules/src/midiinmodule/midiinmodule.spec +++ mod/modules/src/midiinmodule/midiinmodule.spec @@ -36,7 +36,7 @@ hidden = true default = default widget_type = combo_box - values = default,wavein,oss,alsa + values = default,wavein,oss,alsa,alsaseq } }