/[svn]/linuxsampler/trunk/src/engines/common/DiskThreadBase.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/common/DiskThreadBase.h

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

revision 2012 by iliev, Fri Oct 23 17:53:17 2009 UTC revision 3034 by schoenebeck, Mon Oct 31 00:05:00 2016 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *   Copyright (C) 2005 - 2009 Christian Schoenebeck                       *   *   Copyright (C) 2005 - 2008 Christian Schoenebeck                       *
7   *   Copyright (C) 2009 Grigor Iliev                                       *   *   Copyright (C) 2009 - 2012 Christian Schoenebeck and Grigor Iliev      *
8     *   Copyright (C) 2013 - 2016 Christian Schoenebeck and Andreas Persson   *
9   *                                                                         *   *                                                                         *
10   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
11   *   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 25  Line 26 
26  #ifndef __LS_DISKTHREADBASE_H__  #ifndef __LS_DISKTHREADBASE_H__
27  #define __LS_DISKTHREADBASE_H__  #define __LS_DISKTHREADBASE_H__
28    
29    #include <map>
30    
31  #include "StreamBase.h"  #include "StreamBase.h"
32  #include "../EngineChannel.h"  #include "../EngineChannel.h"
33  #include "../InstrumentManagerBase.h"  #include "../InstrumentManagerBase.h"
# Line 67  namespace LinuxSampler { Line 70  namespace LinuxSampler {
70                  bool              bNotify;                  bool              bNotify;
71              };              };
72              struct program_change_command_t {              struct program_change_command_t {
73                  uint8_t Program;                  uint32_t Program;
74                  EngineChannel* pEngineChannel;                  EngineChannel* pEngineChannel;
75              };              };
76              // Attributes              // Attributes
# Line 194  namespace LinuxSampler { Line 197  namespace LinuxSampler {
197              // Methods              // Methods
198              DiskThreadBase(int MaxStreams, uint BufferWrapElements, IM* pInstruments) :              DiskThreadBase(int MaxStreams, uint BufferWrapElements, IM* pInstruments) :
199                  Thread(true, false, 1, -2),                  Thread(true, false, 1, -2),
                 pInstruments(pInstruments),  
200                  DeletionNotificationQueue(4*MaxStreams),                  DeletionNotificationQueue(4*MaxStreams),
201                  ProgramChangeQueue(100)                  ProgramChangeQueue(512),
202                    pInstruments(pInstruments)
203              {              {
204                  CreationQueue       = new RingBuffer<create_command_t,false>(4*MaxStreams);                  CreationQueue       = new RingBuffer<create_command_t,false>(4*MaxStreams);
205                  DeletionQueue       = new RingBuffer<delete_command_t,false>(4*MaxStreams);                  DeletionQueue       = new RingBuffer<delete_command_t,false>(4*MaxStreams);
# Line 382  namespace LinuxSampler { Line 385  namespace LinuxSampler {
385               * Tell the disk thread to do a program change on the specified               * Tell the disk thread to do a program change on the specified
386               * EngineChannel.               * EngineChannel.
387               */               */
388              int OrderProgramChange(uint8_t Program, EngineChannel* pEngineChannel) {              int OrderProgramChange(uint32_t Program, EngineChannel* pEngineChannel) {
389                  program_change_command_t cmd;                  program_change_command_t cmd;
390                  cmd.Program = Program;                  cmd.Program = Program;
391                  cmd.pEngineChannel = pEngineChannel;                  cmd.pEngineChannel = pEngineChannel;
# Line 503  namespace LinuxSampler { Line 506  namespace LinuxSampler {
506                      }                      }
507    
508                      // perform MIDI program change commands                      // perform MIDI program change commands
509                      while (ProgramChangeQueue.read_space() > 0) {                      if (ProgramChangeQueue.read_space() > 0) {
510                          program_change_command_t cmd;                          program_change_command_t cmd;
511                          ProgramChangeQueue.pop(&cmd);                          std::map<EngineChannel*,uint32_t> cmds;
512                          cmd.pEngineChannel->ExecuteProgramChange(cmd.Program);                          // skip all old ones, only process the latest program
513                            // change command on each engine channel
514                            do {
515                                ProgramChangeQueue.pop(&cmd);
516                                cmds[cmd.pEngineChannel] = cmd.Program;
517                            } while (ProgramChangeQueue.read_space() > 0);
518                            // now execute those latest program change commands on
519                            // their respective engine channel
520                            for (std::map<EngineChannel*,uint32_t>::const_iterator it = cmds.begin();
521                                 it != cmds.end(); ++it)
522                            {
523                                it->first->ExecuteProgramChange(it->second);
524                            }
525                      }                      }
526    
527                      RefillStreams(); // refill the most empty streams                      RefillStreams(); // refill the most empty streams
528    
529                      // if nothing was done during this iteration (eg no streambuffer                      // if nothing was done during this iteration (eg no streambuffer

Legend:
Removed from v.2012  
changed lines
  Added in v.3034

  ViewVC Help
Powered by ViewVC