mirror of
https://github.com/holub/mame
synced 2025-06-08 05:44:09 +03:00
vector_t to std::vector in discrete (nw)
This commit is contained in:
parent
3ac71817d7
commit
ccf38aa73c
@ -39,9 +39,6 @@
|
|||||||
#include "sound/wavwrite.h"
|
#include "sound/wavwrite.h"
|
||||||
#include "discrete.h"
|
#include "discrete.h"
|
||||||
|
|
||||||
/* for_each collides with c++ standard libraries - include it here */
|
|
||||||
#define for_each(_T, _e, _l) for (_T _e = (_l)->begin_ptr() ; _e <= (_l)->end_ptr(); _e++)
|
|
||||||
|
|
||||||
// device type definition
|
// device type definition
|
||||||
const device_type DISCRETE = &device_creator<discrete_sound_device>;
|
const device_type DISCRETE = &device_creator<discrete_sound_device>;
|
||||||
|
|
||||||
@ -120,7 +117,7 @@ public:
|
|||||||
node_step_list_t step_list;
|
node_step_list_t step_list;
|
||||||
|
|
||||||
/* list of source nodes */
|
/* list of source nodes */
|
||||||
vector_t<input_buffer> source_list; /* discrete_source_node */
|
std::vector<input_buffer> source_list; /* discrete_source_node */
|
||||||
|
|
||||||
int task_group;
|
int task_group;
|
||||||
|
|
||||||
@ -140,7 +137,7 @@ protected:
|
|||||||
void check(discrete_task *dest_task);
|
void check(discrete_task *dest_task);
|
||||||
void prepare_for_queue(int samples);
|
void prepare_for_queue(int samples);
|
||||||
|
|
||||||
vector_t<output_buffer> m_buffers;
|
std::vector<output_buffer> m_buffers;
|
||||||
discrete_device & m_device;
|
discrete_device & m_device;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -179,26 +176,26 @@ private:
|
|||||||
|
|
||||||
inline void discrete_task::step_nodes(void)
|
inline void discrete_task::step_nodes(void)
|
||||||
{
|
{
|
||||||
for_each(input_buffer *, sn, &source_list)
|
for(input_buffer sn : source_list)
|
||||||
{
|
{
|
||||||
sn->buffer = *sn->ptr++;
|
sn.buffer = *sn.ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EXPECTED(!m_device.profiling()))
|
if (EXPECTED(!m_device.profiling()))
|
||||||
{
|
{
|
||||||
for_each(discrete_step_interface **, entry, &step_list)
|
for(discrete_step_interface * entry : step_list)
|
||||||
{
|
{
|
||||||
/* Now step the node */
|
/* Now step the node */
|
||||||
(*entry)->step();
|
entry->step();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
osd_ticks_t last = get_profile_ticks();
|
osd_ticks_t last = get_profile_ticks();
|
||||||
|
|
||||||
for_each(discrete_step_interface **, entry, &step_list)
|
for(discrete_step_interface * entry : step_list)
|
||||||
{
|
{
|
||||||
discrete_step_interface *node = *entry;
|
discrete_step_interface *node = entry;
|
||||||
|
|
||||||
node->run_time -= last;
|
node->run_time -= last;
|
||||||
node->step();
|
node->step();
|
||||||
@ -208,8 +205,8 @@ inline void discrete_task::step_nodes(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* buffer the outputs */
|
/* buffer the outputs */
|
||||||
for_each(output_buffer *, outbuf, &m_buffers)
|
for(output_buffer outbuf : m_buffers)
|
||||||
*(outbuf->ptr++) = *outbuf->source;
|
*(outbuf.ptr++) = *outbuf.source;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *discrete_task::task_callback(void *param, int threadid)
|
void *discrete_task::task_callback(void *param, int threadid)
|
||||||
@ -217,14 +214,14 @@ void *discrete_task::task_callback(void *param, int threadid)
|
|||||||
task_list_t *list = (task_list_t *) param;
|
task_list_t *list = (task_list_t *) param;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
for_each(discrete_task **, task, list)
|
for(discrete_task * task : *list)
|
||||||
{
|
{
|
||||||
/* try to lock */
|
/* try to lock */
|
||||||
if ((*task)->lock_threadid(threadid))
|
if (task->lock_threadid(threadid))
|
||||||
{
|
{
|
||||||
if (!(*task)->process())
|
if (!task->process())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
(*task)->unlock();
|
task->unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (1);
|
} while (1);
|
||||||
@ -237,11 +234,11 @@ bool discrete_task::process(void)
|
|||||||
int samples = MIN(m_samples, MAX_SAMPLES_PER_TASK_SLICE);
|
int samples = MIN(m_samples, MAX_SAMPLES_PER_TASK_SLICE);
|
||||||
|
|
||||||
/* check dependencies */
|
/* check dependencies */
|
||||||
for_each(input_buffer *, sn, &source_list)
|
for(input_buffer sn : source_list)
|
||||||
{
|
{
|
||||||
int avail;
|
int avail;
|
||||||
|
|
||||||
avail = sn->linked_outbuf->ptr - sn->ptr;
|
avail = sn.linked_outbuf->ptr - sn.ptr;
|
||||||
assert_always(avail >= 0, "task_callback: available samples are negative");
|
assert_always(avail >= 0, "task_callback: available samples are negative");
|
||||||
if (avail < samples)
|
if (avail < samples)
|
||||||
samples = avail;
|
samples = avail;
|
||||||
@ -267,13 +264,13 @@ void discrete_task::prepare_for_queue(int samples)
|
|||||||
{
|
{
|
||||||
m_samples = samples;
|
m_samples = samples;
|
||||||
/* set up task buffers */
|
/* set up task buffers */
|
||||||
for_each(output_buffer *, ob, &m_buffers)
|
for(output_buffer ob : m_buffers)
|
||||||
ob->ptr = ob->node_buf;
|
ob.ptr = ob.node_buf;
|
||||||
|
|
||||||
/* initialize sources */
|
/* initialize sources */
|
||||||
for_each(input_buffer *, sn, &source_list)
|
for(input_buffer sn : source_list)
|
||||||
{
|
{
|
||||||
sn->ptr = sn->linked_outbuf->node_buf;
|
sn.ptr = sn.linked_outbuf->node_buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,13 +281,13 @@ void discrete_task::check(discrete_task *dest_task)
|
|||||||
/* Determine, which nodes in the task are referenced by nodes in dest_task
|
/* Determine, which nodes in the task are referenced by nodes in dest_task
|
||||||
* and add them to the list of nodes to be buffered for further processing
|
* and add them to the list of nodes to be buffered for further processing
|
||||||
*/
|
*/
|
||||||
for_each(discrete_step_interface **, node_entry, &step_list)
|
for(discrete_step_interface * node_entry : step_list)
|
||||||
{
|
{
|
||||||
discrete_base_node *task_node = (*node_entry)->self;
|
discrete_base_node *task_node = node_entry->self;
|
||||||
|
|
||||||
for_each(discrete_step_interface **, step_entry, &dest_task->step_list)
|
for(discrete_step_interface *step_entry : dest_task->step_list)
|
||||||
{
|
{
|
||||||
discrete_base_node *dest_node = (*step_entry)->self;
|
discrete_base_node *dest_node = step_entry->self;
|
||||||
|
|
||||||
/* loop over all active inputs */
|
/* loop over all active inputs */
|
||||||
for (inputnum = 0; inputnum < dest_node->active_inputs(); inputnum++)
|
for (inputnum = 0; inputnum < dest_node->active_inputs(); inputnum++)
|
||||||
@ -305,7 +302,7 @@ void discrete_task::check(discrete_task *dest_task)
|
|||||||
int i, found = -1;
|
int i, found = -1;
|
||||||
output_buffer *pbuf = nullptr;
|
output_buffer *pbuf = nullptr;
|
||||||
|
|
||||||
for (i = 0; i < m_buffers.count(); i++)
|
for (i = 0; i < m_buffers.size(); i++)
|
||||||
// if (m_buffers[i].node->block_node() == inputnode_num)
|
// if (m_buffers[i].node->block_node() == inputnode_num)
|
||||||
if (m_buffers[i].node_num == inputnode_num)
|
if (m_buffers[i].node_num == inputnode_num)
|
||||||
{
|
{
|
||||||
@ -324,8 +321,9 @@ void discrete_task::check(discrete_task *dest_task)
|
|||||||
buf.source = dest_node->m_input[inputnum];
|
buf.source = dest_node->m_input[inputnum];
|
||||||
buf.node_num = inputnode_num;
|
buf.node_num = inputnode_num;
|
||||||
//buf.node = device->discrete_find_node(inputnode);
|
//buf.node = device->discrete_find_node(inputnode);
|
||||||
m_buffers.count();
|
m_buffers.size();
|
||||||
pbuf = m_buffers.add(buf);
|
m_buffers.push_back(buf);
|
||||||
|
pbuf = &m_buffers.back();
|
||||||
}
|
}
|
||||||
m_device.discrete_log("dso_task_start - buffering %d(%d) in task %p group %d referenced by %d group %d", NODE_INDEX(inputnode_num), NODE_CHILD_NODE_NUM(inputnode_num), this, task_group, dest_node->index(), dest_task->task_group);
|
m_device.discrete_log("dso_task_start - buffering %d(%d) in task %p group %d referenced by %d group %d", NODE_INDEX(inputnode_num), NODE_CHILD_NODE_NUM(inputnode_num), this, task_group, dest_node->index(), dest_task->task_group);
|
||||||
|
|
||||||
@ -336,10 +334,10 @@ void discrete_task::check(discrete_task *dest_task)
|
|||||||
source.linked_outbuf = pbuf;
|
source.linked_outbuf = pbuf;
|
||||||
source.buffer = 0.0; /* please compiler */
|
source.buffer = 0.0; /* please compiler */
|
||||||
source.ptr = nullptr;
|
source.ptr = nullptr;
|
||||||
dest_task->source_list.add(source);
|
dest_task->source_list.push_back(source);
|
||||||
|
|
||||||
/* point the input to a buffered location */
|
/* point the input to a buffered location */
|
||||||
dest_node->m_input[inputnum] = &dest_task->source_list[dest_task->source_list.count()-1].buffer; // was copied! &source.buffer;
|
dest_node->m_input[inputnum] = &dest_task->source_list[dest_task->source_list.size()-1].buffer; // was copied! &source.buffer;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -514,7 +512,7 @@ void discrete_device::discrete_build_list(const discrete_block *intf, sound_bloc
|
|||||||
if (intf[node_count].type == DSS_NULL)
|
if (intf[node_count].type == DSS_NULL)
|
||||||
fatalerror("discrete_build_list: DISCRETE_REPLACE at end of node_list\n");
|
fatalerror("discrete_build_list: DISCRETE_REPLACE at end of node_list\n");
|
||||||
|
|
||||||
for (int i=0; i < block_list.count(); i++)
|
for (int i=0; i < block_list.size(); i++)
|
||||||
{
|
{
|
||||||
const discrete_block *block = block_list[i];
|
const discrete_block *block = block_list[i];
|
||||||
|
|
||||||
@ -534,9 +532,9 @@ void discrete_device::discrete_build_list(const discrete_block *intf, sound_bloc
|
|||||||
}
|
}
|
||||||
else if (intf[node_count].type == DSO_DELETE)
|
else if (intf[node_count].type == DSO_DELETE)
|
||||||
{
|
{
|
||||||
vector_t<int> deletethem;
|
std::vector<int> deletethem;
|
||||||
|
|
||||||
for (int i=0; i<block_list.count(); i++)
|
for (int i=0; i<block_list.size(); i++)
|
||||||
{
|
{
|
||||||
const discrete_block *block = block_list[i];
|
const discrete_block *block = block_list[i];
|
||||||
|
|
||||||
@ -544,16 +542,16 @@ void discrete_device::discrete_build_list(const discrete_block *intf, sound_bloc
|
|||||||
(block->node <= intf[node_count].input_node[1]))
|
(block->node <= intf[node_count].input_node[1]))
|
||||||
{
|
{
|
||||||
discrete_log("discrete_build_list() - DISCRETE_DELETE deleted NODE_%02d", NODE_INDEX(block->node) );
|
discrete_log("discrete_build_list() - DISCRETE_DELETE deleted NODE_%02d", NODE_INDEX(block->node) );
|
||||||
deletethem.add(i);
|
deletethem.push_back(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for_each (int *, i, &deletethem)
|
for(int i : deletethem)
|
||||||
block_list.remove(*i);
|
block_list.erase(block_list.begin() + i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
discrete_log("discrete_build_list() - adding node %d\n", node_count);
|
discrete_log("discrete_build_list() - adding node %d\n", node_count);
|
||||||
block_list.add(&intf[node_count]);
|
block_list.push_back(&intf[node_count]);
|
||||||
}
|
}
|
||||||
|
|
||||||
node_count++;
|
node_count++;
|
||||||
@ -569,7 +567,7 @@ void discrete_device::discrete_sanity_check(const sound_block_list_t &block_list
|
|||||||
int node_count = 0;
|
int node_count = 0;
|
||||||
|
|
||||||
discrete_log("discrete_start() - Doing node list sanity check");
|
discrete_log("discrete_start() - Doing node list sanity check");
|
||||||
for (int i=0; i < block_list.count(); i++)
|
for (int i=0; i < block_list.size(); i++)
|
||||||
{
|
{
|
||||||
const discrete_block *block = block_list[i];
|
const discrete_block *block = block_list[i];
|
||||||
|
|
||||||
@ -616,10 +614,10 @@ static UINT64 list_run_time(const node_list_t &list)
|
|||||||
{
|
{
|
||||||
UINT64 total = 0;
|
UINT64 total = 0;
|
||||||
|
|
||||||
for_each(discrete_base_node **, node, &list)
|
for(discrete_base_node * node : list)
|
||||||
{
|
{
|
||||||
discrete_step_interface *step;
|
discrete_step_interface *step;
|
||||||
if ((*node)->interface(step))
|
if (node->interface(step))
|
||||||
total += step->run_time;
|
total += step->run_time;
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
@ -629,9 +627,9 @@ static UINT64 step_list_run_time(const node_step_list_t &list)
|
|||||||
{
|
{
|
||||||
UINT64 total = 0;
|
UINT64 total = 0;
|
||||||
|
|
||||||
for_each(discrete_step_interface **, node, &list)
|
for (discrete_step_interface * node : list)
|
||||||
{
|
{
|
||||||
total += (*node)->run_time;
|
total += node->run_time;
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
@ -645,25 +643,25 @@ void discrete_device::display_profiling(void)
|
|||||||
|
|
||||||
/* calculate total time */
|
/* calculate total time */
|
||||||
total = list_run_time(m_node_list);
|
total = list_run_time(m_node_list);
|
||||||
count = m_node_list.count();
|
count = m_node_list.size();
|
||||||
/* print statistics */
|
/* print statistics */
|
||||||
printf("Total Samples : %16" I64FMT "d\n", m_total_samples);
|
printf("Total Samples : %16" I64FMT "d\n", m_total_samples);
|
||||||
tresh = total / count;
|
tresh = total / count;
|
||||||
printf("Threshold (mean): %16" I64FMT "d\n", tresh / m_total_samples );
|
printf("Threshold (mean): %16" I64FMT "d\n", tresh / m_total_samples );
|
||||||
for_each(discrete_base_node **, node, &m_node_list)
|
for(discrete_base_node * node : m_node_list)
|
||||||
{
|
{
|
||||||
discrete_step_interface *step;
|
discrete_step_interface *step;
|
||||||
if ((*node)->interface(step))
|
if (node->interface(step))
|
||||||
if (step->run_time > tresh)
|
if (step->run_time > tresh)
|
||||||
printf("%3d: %20s %8.2f %10.2f\n", (*node)->index(), (*node)->module_name(), (double) step->run_time / (double) total * 100.0, ((double) step->run_time) / (double) m_total_samples);
|
printf("%3d: %20s %8.2f %10.2f\n", node->index(), node->module_name(), (double) step->run_time / (double) total * 100.0, ((double) step->run_time) / (double) m_total_samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Task information */
|
/* Task information */
|
||||||
for_each(discrete_task **, task, &task_list)
|
for(discrete_task * task : task_list)
|
||||||
{
|
{
|
||||||
tt = step_list_run_time((*task)->step_list);
|
tt = step_list_run_time(task->step_list);
|
||||||
|
|
||||||
printf("Task(%d): %8.2f %15.2f\n", (*task)->task_group, tt / (double) total * 100.0, tt / (double) m_total_samples);
|
printf("Task(%d): %8.2f %15.2f\n", task->task_group, tt / (double) total * 100.0, tt / (double) m_total_samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Average samples/double->update: %8.2f\n", (double) m_total_samples / (double) m_total_stream_updates);
|
printf("Average samples/double->update: %8.2f\n", (double) m_total_samples / (double) m_total_stream_updates);
|
||||||
@ -686,7 +684,7 @@ void discrete_device::init_nodes(const sound_block_list_t &block_list)
|
|||||||
/* check whether we have tasks ... */
|
/* check whether we have tasks ... */
|
||||||
if (USE_DISCRETE_TASKS)
|
if (USE_DISCRETE_TASKS)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < block_list.count(); i++)
|
for (int i = 0; i < block_list.size(); i++)
|
||||||
{
|
{
|
||||||
if (block_list[i]->type == DSO_TASK_START)
|
if (block_list[i]->type == DSO_TASK_START)
|
||||||
has_tasks = 1;
|
has_tasks = 1;
|
||||||
@ -699,11 +697,11 @@ void discrete_device::init_nodes(const sound_block_list_t &block_list)
|
|||||||
* No need to create a node since there are no dependencies.
|
* No need to create a node since there are no dependencies.
|
||||||
*/
|
*/
|
||||||
task = auto_alloc_clear(machine(), discrete_task(*this));
|
task = auto_alloc_clear(machine(), discrete_task(*this));
|
||||||
task_list.add(task);
|
task_list.push_back(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* loop over all nodes */
|
/* loop over all nodes */
|
||||||
for (int i = 0; i < block_list.count(); i++)
|
for (int i = 0; i < block_list.size(); i++)
|
||||||
{
|
{
|
||||||
const discrete_block *block = block_list[i];
|
const discrete_block *block = block_list[i];
|
||||||
|
|
||||||
@ -738,7 +736,7 @@ void discrete_device::init_nodes(const sound_block_list_t &block_list)
|
|||||||
if (task->task_group < 0 || task->task_group >= DISCRETE_MAX_TASK_GROUPS)
|
if (task->task_group < 0 || task->task_group >= DISCRETE_MAX_TASK_GROUPS)
|
||||||
fatalerror("discrete_dso_task: illegal task_group %d\n", task->task_group);
|
fatalerror("discrete_dso_task: illegal task_group %d\n", task->task_group);
|
||||||
//printf("task group %d\n", task->task_group);
|
//printf("task group %d\n", task->task_group);
|
||||||
task_list.add(task);
|
task_list.push_back(task);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -764,7 +762,7 @@ void discrete_device::init_nodes(const sound_block_list_t &block_list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* add to node list */
|
/* add to node list */
|
||||||
m_node_list.add(node);
|
m_node_list.push_back(node);
|
||||||
|
|
||||||
/* our running order just follows the order specified */
|
/* our running order just follows the order specified */
|
||||||
/* does the node step ? */
|
/* does the node step ? */
|
||||||
@ -775,7 +773,7 @@ void discrete_device::init_nodes(const sound_block_list_t &block_list)
|
|||||||
if (task == nullptr)
|
if (task == nullptr)
|
||||||
fatalerror("init_nodes() - found node outside of task: %s\n", node->module_name() );
|
fatalerror("init_nodes() - found node outside of task: %s\n", node->module_name() );
|
||||||
else
|
else
|
||||||
task->step_list.add(step);
|
task->step_list.push_back(step);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (USE_DISCRETE_TASKS && block->type == DSO_TASK_END)
|
if (USE_DISCRETE_TASKS && block->type == DSO_TASK_END)
|
||||||
@ -804,11 +802,11 @@ int discrete_device::same_module_index(const discrete_base_node &node)
|
|||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
for_each(discrete_base_node **, n, &m_node_list)
|
for(discrete_base_node *n : m_node_list)
|
||||||
{
|
{
|
||||||
if (*n == &node)
|
if (n == &node)
|
||||||
return index;
|
return index;
|
||||||
if ((*n)->module_type() == node.module_type())
|
if (n->module_type() == node.module_type())
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@ -910,27 +908,27 @@ void discrete_device::device_start()
|
|||||||
init_nodes(block_list);
|
init_nodes(block_list);
|
||||||
|
|
||||||
/* now go back and find pointers to all input nodes */
|
/* now go back and find pointers to all input nodes */
|
||||||
for_each(discrete_base_node **, node, &m_node_list)
|
for(discrete_base_node *node :m_node_list)
|
||||||
{
|
{
|
||||||
(*node)->resolve_input_nodes();
|
node->resolve_input_nodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate a queue */
|
/* allocate a queue */
|
||||||
m_queue = osd_work_queue_alloc(WORK_QUEUE_FLAG_MULTI | WORK_QUEUE_FLAG_HIGH_FREQ);
|
m_queue = osd_work_queue_alloc(WORK_QUEUE_FLAG_MULTI | WORK_QUEUE_FLAG_HIGH_FREQ);
|
||||||
|
|
||||||
/* Process nodes which have a start func */
|
/* Process nodes which have a start func */
|
||||||
for_each(discrete_base_node **, node, &m_node_list)
|
for(discrete_base_node * node :m_node_list)
|
||||||
{
|
{
|
||||||
(*node)->start();
|
node->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now set up tasks */
|
/* Now set up tasks */
|
||||||
for_each(discrete_task **, task, &task_list)
|
for(discrete_task *task : task_list)
|
||||||
{
|
{
|
||||||
for_each(discrete_task **, dest_task, &task_list)
|
for(discrete_task *dest_task :task_list)
|
||||||
{
|
{
|
||||||
if ((*task)->task_group > (*dest_task)->task_group)
|
if (task->task_group > dest_task->task_group)
|
||||||
(*dest_task)->check((*task));
|
dest_task->check(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -949,9 +947,9 @@ void discrete_device::device_stop()
|
|||||||
|
|
||||||
/* Process nodes which have a stop func */
|
/* Process nodes which have a stop func */
|
||||||
|
|
||||||
for_each(discrete_base_node **, node, &m_node_list)
|
for(discrete_base_node *node : m_node_list)
|
||||||
{
|
{
|
||||||
(*node)->stop();
|
node->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DISCRETE_DEBUGLOG)
|
if (DISCRETE_DEBUGLOG)
|
||||||
@ -976,31 +974,31 @@ void discrete_sound_device::device_start()
|
|||||||
discrete_device::device_start();
|
discrete_device::device_start();
|
||||||
|
|
||||||
/* look for input stream nodes */
|
/* look for input stream nodes */
|
||||||
for_each(discrete_base_node **, node, &m_node_list)
|
for(discrete_base_node *node : m_node_list)
|
||||||
{
|
{
|
||||||
/* if we are an stream input node, track that */
|
/* if we are an stream input node, track that */
|
||||||
discrete_dss_input_stream_node *input_stream = dynamic_cast<discrete_dss_input_stream_node *>(*node);
|
discrete_dss_input_stream_node *input_stream = dynamic_cast<discrete_dss_input_stream_node *>(node);
|
||||||
if (input_stream != nullptr)
|
if (input_stream != nullptr)
|
||||||
{
|
{
|
||||||
m_input_stream_list.add(input_stream);
|
m_input_stream_list.push_back(input_stream);
|
||||||
}
|
}
|
||||||
/* if this is an output interface, add it the output list */
|
/* if this is an output interface, add it the output list */
|
||||||
discrete_sound_output_interface *out;
|
discrete_sound_output_interface *out;
|
||||||
if ((*node)->interface(out))
|
if (node->interface(out))
|
||||||
m_output_list.add(out);
|
m_output_list.push_back(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if no outputs, give an error */
|
/* if no outputs, give an error */
|
||||||
if (m_output_list.count() == 0)
|
if (m_output_list.size() == 0)
|
||||||
fatalerror("init_nodes() - Couldn't find an output node\n");
|
fatalerror("init_nodes() - Couldn't find an output node\n");
|
||||||
|
|
||||||
/* initialize the stream(s) */
|
/* initialize the stream(s) */
|
||||||
m_stream = machine().sound().stream_alloc(*this,m_input_stream_list.count(), m_output_list.count(), m_sample_rate);
|
m_stream = machine().sound().stream_alloc(*this,m_input_stream_list.size(), m_output_list.size(), m_sample_rate);
|
||||||
|
|
||||||
/* Finalize stream_input_nodes */
|
/* Finalize stream_input_nodes */
|
||||||
for_each(discrete_dss_input_stream_node **, node, &m_input_stream_list)
|
for(discrete_dss_input_stream_node *node : m_input_stream_list)
|
||||||
{
|
{
|
||||||
(*node)->stream_start();
|
node->stream_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1015,12 +1013,12 @@ void discrete_device::device_reset()
|
|||||||
update_to_current_time();
|
update_to_current_time();
|
||||||
|
|
||||||
/* loop over all nodes */
|
/* loop over all nodes */
|
||||||
for_each (discrete_base_node **, node, &m_node_list)
|
for(discrete_base_node *node : m_node_list)
|
||||||
{
|
{
|
||||||
/* Fimxe : node_level */
|
/* Fimxe : node_level */
|
||||||
(*node)->m_output[0] = 0;
|
node->m_output[0] = 0;
|
||||||
|
|
||||||
(*node)->reset();
|
node->reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1044,19 +1042,17 @@ void discrete_device::process(int samples)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Setup tasks */
|
/* Setup tasks */
|
||||||
for_each(discrete_task **, task, &task_list)
|
for(discrete_task *task : task_list)
|
||||||
{
|
{
|
||||||
/* unlock the thread */
|
/* unlock the thread */
|
||||||
(*task)->unlock();
|
task->unlock();
|
||||||
|
|
||||||
(*task)->prepare_for_queue(samples);
|
task->prepare_for_queue(samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
for_each(discrete_task **, task, &task_list)
|
|
||||||
{
|
|
||||||
/* Fire a work item for each task */
|
/* Fire a work item for each task */
|
||||||
osd_work_item_queue(m_queue, discrete_task::task_callback, (void *) &task_list, WORK_ITEM_FLAG_AUTO_RELEASE);
|
osd_work_item_queue(m_queue, discrete_task::task_callback, (void *) &task_list, WORK_ITEM_FLAG_AUTO_RELEASE);
|
||||||
}
|
|
||||||
osd_work_queue_wait(m_queue, osd_ticks_per_second()*10);
|
osd_work_queue_wait(m_queue, osd_ticks_per_second()*10);
|
||||||
|
|
||||||
if (m_profiling)
|
if (m_profiling)
|
||||||
@ -1079,16 +1075,16 @@ void discrete_sound_device::sound_stream_update(sound_stream &stream, stream_sam
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Setup any output streams */
|
/* Setup any output streams */
|
||||||
for_each(discrete_sound_output_interface **, node, &m_output_list)
|
for(discrete_sound_output_interface *node : m_output_list)
|
||||||
{
|
{
|
||||||
(*node)->set_output_ptr(outputs[outputnum]);
|
node->set_output_ptr(outputs[outputnum]);
|
||||||
outputnum++;
|
outputnum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup any input streams */
|
/* Setup any input streams */
|
||||||
for_each(discrete_dss_input_stream_node **, node, &m_input_stream_list)
|
for(discrete_dss_input_stream_node * node : m_input_stream_list)
|
||||||
{
|
{
|
||||||
(*node)->m_ptr = (stream_sample_t *) inputs[(*node)->m_stream_in_number];
|
node->m_ptr = (stream_sample_t *) inputs[node->m_stream_in_number];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* just process it */
|
/* just process it */
|
||||||
|
@ -3740,93 +3740,6 @@ enum
|
|||||||
#define DISC_RC_INTEGRATE_TYPE2 0x01
|
#define DISC_RC_INTEGRATE_TYPE2 0x01
|
||||||
#define DISC_RC_INTEGRATE_TYPE3 0x02
|
#define DISC_RC_INTEGRATE_TYPE3 0x02
|
||||||
|
|
||||||
/*************************************
|
|
||||||
*
|
|
||||||
* Classes and structs to handle
|
|
||||||
* linked lists.
|
|
||||||
*
|
|
||||||
*************************************/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* add and delete may be slow - the focus is on access!
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TODO: replace with vector from utils
|
|
||||||
template<class _ElementType> struct vector_t
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
vector_t(int initial) {
|
|
||||||
m_count = 0;
|
|
||||||
m_allocated = initial;
|
|
||||||
m_arr = global_alloc_array_clear(_ElementType, m_allocated);
|
|
||||||
}
|
|
||||||
vector_t() {
|
|
||||||
m_count = 0;
|
|
||||||
m_allocated = 16;
|
|
||||||
m_arr = global_alloc_array_clear(_ElementType, m_allocated);
|
|
||||||
}
|
|
||||||
~vector_t() {
|
|
||||||
global_free_array(m_arr);
|
|
||||||
}
|
|
||||||
_ElementType& operator [] (unsigned int index) const // get array item
|
|
||||||
{
|
|
||||||
return m_arr[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
vector_t(const vector_t &a) // copy constructor
|
|
||||||
{
|
|
||||||
m_allocated = a.count();
|
|
||||||
if (m_allocated < 16)
|
|
||||||
m_allocated = 16;
|
|
||||||
m_count = a.count();
|
|
||||||
m_arr = global_alloc_array_clear(_ElementType, m_allocated);
|
|
||||||
for (int i=0; i < m_count; i++)
|
|
||||||
m_arr[i] = a[i];
|
|
||||||
}
|
|
||||||
vector_t& operator = (const vector_t &a) // assignment operator
|
|
||||||
{
|
|
||||||
if (this == &a) return *this;
|
|
||||||
m_allocated = a.count();
|
|
||||||
if (m_allocated < 16)
|
|
||||||
m_allocated = 16;
|
|
||||||
m_count = a.count();
|
|
||||||
m_arr = global_alloc_array_clear(_ElementType, m_allocated);
|
|
||||||
for (int i=0; i < m_count; i++)
|
|
||||||
m_arr[i] = a[i];
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline _ElementType* add(_ElementType object)
|
|
||||||
{
|
|
||||||
if (m_count >= m_allocated)
|
|
||||||
{
|
|
||||||
m_allocated *= 2;
|
|
||||||
auto newarr = global_alloc_array_clear(_ElementType, m_allocated);
|
|
||||||
for (int i=0; i < m_count; i++)
|
|
||||||
newarr[i] = m_arr[i];
|
|
||||||
global_free_array(m_arr);
|
|
||||||
m_arr = newarr;
|
|
||||||
}
|
|
||||||
m_arr[m_count] = object;
|
|
||||||
m_count++;
|
|
||||||
return &m_arr[m_count-1];
|
|
||||||
}
|
|
||||||
inline void remove(int index)
|
|
||||||
{
|
|
||||||
for (int i=index+1; i < m_count; i++)
|
|
||||||
m_arr[i-1] = m_arr[i];
|
|
||||||
m_count--;
|
|
||||||
}
|
|
||||||
inline void clear(void) { m_count = 0; }
|
|
||||||
inline int count(void) const { return m_count; }
|
|
||||||
inline _ElementType *begin_ptr(void) const { return m_arr; }
|
|
||||||
inline _ElementType *end_ptr(void) const { return m_arr + (m_count - 1); }
|
|
||||||
private:
|
|
||||||
_ElementType *m_arr;
|
|
||||||
int m_count;
|
|
||||||
int m_allocated;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*************************************
|
/*************************************
|
||||||
*
|
*
|
||||||
* Node-specific struct types
|
* Node-specific struct types
|
||||||
@ -4185,9 +4098,9 @@ class discrete_task;
|
|||||||
class discrete_base_node;
|
class discrete_base_node;
|
||||||
class discrete_dss_input_stream_node;
|
class discrete_dss_input_stream_node;
|
||||||
class discrete_device;
|
class discrete_device;
|
||||||
typedef vector_t<discrete_base_node *> node_list_t;
|
using node_list_t = std::vector<discrete_base_node *>;
|
||||||
typedef vector_t<discrete_dss_input_stream_node *> istream_node_list_t;
|
using istream_node_list_t = std::vector<discrete_dss_input_stream_node *>;
|
||||||
typedef vector_t<discrete_task *> task_list_t;
|
using task_list_t = std::vector<discrete_task *>;
|
||||||
|
|
||||||
|
|
||||||
/*************************************
|
/*************************************
|
||||||
@ -4216,7 +4129,7 @@ struct discrete_block
|
|||||||
const char * name; /* Node Name */
|
const char * name; /* Node Name */
|
||||||
const char * mod_name; /* Module / class name */
|
const char * mod_name; /* Module / class name */
|
||||||
};
|
};
|
||||||
typedef vector_t<const discrete_block *> sound_block_list_t;
|
typedef std::vector<const discrete_block *> sound_block_list_t;
|
||||||
|
|
||||||
/*************************************
|
/*************************************
|
||||||
*
|
*
|
||||||
@ -4233,7 +4146,7 @@ public:
|
|||||||
osd_ticks_t run_time;
|
osd_ticks_t run_time;
|
||||||
discrete_base_node * self;
|
discrete_base_node * self;
|
||||||
};
|
};
|
||||||
typedef vector_t<discrete_step_interface *> node_step_list_t;
|
typedef std::vector<discrete_step_interface *> node_step_list_t;
|
||||||
|
|
||||||
class discrete_input_interface
|
class discrete_input_interface
|
||||||
{
|
{
|
||||||
@ -4271,7 +4184,7 @@ public:
|
|||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
|
|
||||||
class discrete_sound_output_interface;
|
class discrete_sound_output_interface;
|
||||||
typedef vector_t<discrete_sound_output_interface *> node_output_list_t;
|
typedef std::vector<discrete_sound_output_interface *> node_output_list_t;
|
||||||
|
|
||||||
|
|
||||||
// ======================> discrete_device
|
// ======================> discrete_device
|
||||||
|
Loading…
Reference in New Issue
Block a user