37 |
|
|
38 |
|
|
39 |
/** |
/** |
40 |
|
* Suspend disk thread, kill all active streams, clear all queues and the |
41 |
|
* pickup array and reset all streams. Call this method to bring everything |
42 |
|
* in the disk thread to day one. If the disk thread was running, it will be |
43 |
|
* respawned right after everything was reset. |
44 |
|
*/ |
45 |
|
void DiskThread::Reset() { |
46 |
|
bool running = this->IsRunning(); |
47 |
|
if (running) this->StopThread(); |
48 |
|
for (int i = 0; i < MAX_INPUT_STREAMS; i++) { |
49 |
|
pStreams[i]->Kill(); |
50 |
|
} |
51 |
|
for (int i = 1; i <= MAX_INPUT_STREAMS; i++) { |
52 |
|
pCreatedStreams[i] = NULL; |
53 |
|
} |
54 |
|
GhostQueue->init(); |
55 |
|
CreationQueue->init(); |
56 |
|
DeletionQueue->init(); |
57 |
|
ActiveStreamCount = 0; |
58 |
|
ActiveStreamCountMax = 0; |
59 |
|
if (running) this->StartThread(); // start thread only if it was running before |
60 |
|
} |
61 |
|
|
62 |
|
String DiskThread::GetBufferFillBytes() { |
63 |
|
bool activestreams = false; |
64 |
|
std::stringstream ss; |
65 |
|
for (uint i = 0; i < this->Streams; i++) { |
66 |
|
if (pStreams[i]->GetState() == Stream::state_unused) continue; |
67 |
|
uint bufferfill = pStreams[i]->GetReadSpace() * sizeof(sample_t); |
68 |
|
uint streamid = (uint) pStreams[i]->GetHandle(); |
69 |
|
if (!streamid) continue; |
70 |
|
|
71 |
|
if (activestreams) ss << ",[" << streamid << ']' << bufferfill; |
72 |
|
else { |
73 |
|
ss << '[' << streamid << ']' << bufferfill; |
74 |
|
activestreams = true; |
75 |
|
} |
76 |
|
} |
77 |
|
return ss.str(); |
78 |
|
} |
79 |
|
|
80 |
|
String DiskThread::GetBufferFillPercentage() { |
81 |
|
bool activestreams = false; |
82 |
|
std::stringstream ss; |
83 |
|
for (uint i = 0; i < this->Streams; i++) { |
84 |
|
if (pStreams[i]->GetState() == Stream::state_unused) continue; |
85 |
|
uint bufferfill = (uint) ((float) pStreams[i]->GetReadSpace() / (float) STREAM_BUFFER_SIZE * 100); |
86 |
|
uint streamid = (uint) pStreams[i]->GetHandle(); |
87 |
|
if (!streamid) continue; |
88 |
|
|
89 |
|
if (activestreams) ss << ",[" << streamid << ']' << bufferfill << '%'; |
90 |
|
else { |
91 |
|
ss << '[' << streamid << ']' << bufferfill; |
92 |
|
activestreams = true; |
93 |
|
} |
94 |
|
} |
95 |
|
return ss.str(); |
96 |
|
} |
97 |
|
|
98 |
|
/** |
99 |
* Returns -1 if command queue or pickup pool is full, 0 on success (will be |
* Returns -1 if command queue or pickup pool is full, 0 on success (will be |
100 |
* called by audio thread within the voice class). |
* called by audio thread within the voice class). |
101 |
*/ |
*/ |