/[svn]/linuxsampler/trunk/src/db/InstrumentsDb.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/db/InstrumentsDb.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1810 by iliev, Sun Dec 14 22:33:46 2008 UTC revision 1881 by iliev, Mon Mar 30 16:56:41 2009 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2   *                                                                         *   *                                                                         *
3   *   Copyright (C) 2007, 2008 Grigor Iliev                                 *   *   Copyright (C) 2007-2009 Grigor Iliev                                 *
4   *                                                                         *   *                                                                         *
5   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
6   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 1177  namespace LinuxSampler { Line 1177  namespace LinuxSampler {
1177              throw Exception(ss.str());              throw Exception(ss.str());
1178          }          }
1179    
1180            bool unlocked = false;
1181          RIFF::File* riff = NULL;          RIFF::File* riff = NULL;
1182          gig::File* gig = NULL;          gig::File* gig = NULL;
1183          try {          try {
# Line 1205  namespace LinuxSampler { Line 1206  namespace LinuxSampler {
1206    
1207              if (Index == -1) {              if (Index == -1) {
1208                  int instrIndex = 0;                  int instrIndex = 0;
1209                    // Assume that it's locked and should be unlocked at this point
1210                    // to be able to use the database from another threads
1211                    if (!InTransaction) {
1212                        DbInstrumentsMutex.Unlock();
1213                        unlocked = true;
1214                    } else {
1215                        std::cerr << "Shouldn't be in transaction when adding instruments." << std::endl;
1216                    }
1217    
1218                  if (pProgress != NULL) gig->GetInstrument(0, &(pProgress->GigFileProgress)); // TODO: this workaround should be fixed                  if (pProgress != NULL) gig->GetInstrument(0, &(pProgress->GigFileProgress)); // TODO: this workaround should be fixed
1219                  gig::Instrument* pInstrument = gig->GetFirstInstrument();                  gig::Instrument* pInstrument = gig->GetFirstInstrument();
1220    
1221                    if (!InTransaction) DbInstrumentsMutex.Lock();
1222                  while (pInstrument) {                  while (pInstrument) {
1223                      BindTextParam(pStmt, 7, gig->pInfo->Product);                      BindTextParam(pStmt, 7, gig->pInfo->Product);
1224                      BindTextParam(pStmt, 8, gig->pInfo->Artists);                      BindTextParam(pStmt, 8, gig->pInfo->Artists);
# Line 1234  namespace LinuxSampler { Line 1246  namespace LinuxSampler {
1246          } catch (RIFF::Exception e) {          } catch (RIFF::Exception e) {
1247              if (gig != NULL) delete gig;              if (gig != NULL) delete gig;
1248              if (riff != NULL) delete riff;              if (riff != NULL) delete riff;
1249                if (unlocked) DbInstrumentsMutex.Lock();
1250              std::stringstream ss;              std::stringstream ss;
1251              ss << "Failed to scan `" << FilePath << "`: " << e.Message;              ss << "Failed to scan `" << FilePath << "`: " << e.Message;
1252                            
# Line 1241  namespace LinuxSampler { Line 1254  namespace LinuxSampler {
1254          } catch (Exception e) {          } catch (Exception e) {
1255              if (gig != NULL) delete gig;              if (gig != NULL) delete gig;
1256              if (riff != NULL) delete riff;              if (riff != NULL) delete riff;
1257                if (unlocked) DbInstrumentsMutex.Lock();
1258              throw e;              throw e;
1259          } catch (...) {          } catch (...) {
1260              if (gig != NULL) delete gig;              if (gig != NULL) delete gig;
1261              if (riff != NULL) delete riff;              if (riff != NULL) delete riff;
1262                if (unlocked) DbInstrumentsMutex.Lock();
1263              throw Exception("Failed to scan `" + FilePath + "`");              throw Exception("Failed to scan `" + FilePath + "`");
1264          }          }
1265      }      }

Legend:
Removed from v.1810  
changed lines
  Added in v.1881

  ViewVC Help
Powered by ViewVC