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 - 2008 Christian Schoenebeck * |
* Copyright (C) 2005 - 2009 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
9 |
* 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 * |
189 |
} |
} |
190 |
|
|
191 |
/** |
/** |
192 |
|
* Tell the disk thread to do a program change on the specified |
193 |
|
* EngineChannel. |
194 |
|
*/ |
195 |
|
int DiskThread::OrderProgramChange(uint8_t Program, EngineChannel* pEngineChannel) { |
196 |
|
program_change_command_t cmd; |
197 |
|
cmd.Program = Program; |
198 |
|
cmd.pEngineChannel = pEngineChannel; |
199 |
|
|
200 |
|
dmsg(4,("Disk Thread: program change ordered\n")); |
201 |
|
if (ProgramChangeQueue.write_space() < 1) { |
202 |
|
dmsg(1,("DiskThread: ProgramChange queue full!\n")); |
203 |
|
return -1; |
204 |
|
} |
205 |
|
ProgramChangeQueue.push(&cmd); |
206 |
|
return 0; |
207 |
|
} |
208 |
|
|
209 |
|
/** |
210 |
* Returns the pointer to a disk stream if the ordered disk stream |
* Returns the pointer to a disk stream if the ordered disk stream |
211 |
* represented by the \a StreamOrderID was already activated by the disk |
* represented by the \a StreamOrderID was already activated by the disk |
212 |
* thread, returns NULL otherwise. If the call was successful, thus if it |
* thread, returns NULL otherwise. If the call was successful, thus if it |
257 |
DiskThread::DiskThread(int MaxStreams, uint BufferWrapElements, InstrumentResourceManager* pInstruments) : |
DiskThread::DiskThread(int MaxStreams, uint BufferWrapElements, InstrumentResourceManager* pInstruments) : |
258 |
Thread(true, false, 1, -2), |
Thread(true, false, 1, -2), |
259 |
pInstruments(pInstruments), |
pInstruments(pInstruments), |
260 |
DeletionNotificationQueue(4*MaxStreams) |
DeletionNotificationQueue(4*MaxStreams), |
261 |
|
ProgramChangeQueue(100) |
262 |
{ |
{ |
263 |
DecompressionBuffer = ::gig::Sample::CreateDecompressionBuffer(CONFIG_STREAM_MAX_REFILL_SIZE); |
DecompressionBuffer = ::gig::Sample::CreateDecompressionBuffer(CONFIG_STREAM_MAX_REFILL_SIZE); |
264 |
CreationQueue = new RingBuffer<create_command_t,false>(4*MaxStreams); |
CreationQueue = new RingBuffer<create_command_t,false>(4*MaxStreams); |
343 |
pInstruments->HandBackDimReg(dimreg); |
pInstruments->HandBackDimReg(dimreg); |
344 |
} |
} |
345 |
|
|
346 |
|
// perform MIDI program change commands |
347 |
|
while (ProgramChangeQueue.read_space() > 0) { |
348 |
|
program_change_command_t cmd; |
349 |
|
ProgramChangeQueue.pop(&cmd); |
350 |
|
cmd.pEngineChannel->ExecuteProgramChange(cmd.Program); |
351 |
|
} |
352 |
RefillStreams(); // refill the most empty streams |
RefillStreams(); // refill the most empty streams |
353 |
|
|
354 |
// if nothing was done during this iteration (eg no streambuffer |
// if nothing was done during this iteration (eg no streambuffer |