Commit 467f3a2a authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dmime: Simplify and rename channel_block_set to channel_block_init.

parent 0e73870e
...@@ -257,32 +257,31 @@ static struct channel *performance_get_channel(struct performance *This, DWORD c ...@@ -257,32 +257,31 @@ static struct channel *performance_get_channel(struct performance *This, DWORD c
return WINE_RB_ENTRY_VALUE(entry, struct channel_block, entry)->channels + channel_num % 16; return WINE_RB_ENTRY_VALUE(entry, struct channel_block, entry)->channels + channel_num % 16;
} }
static struct channel_block *channel_block_set(struct wine_rb_tree *tree, DWORD block_num, static HRESULT channel_block_init(struct performance *This, DWORD block_num,
IDirectMusicPort *port, DWORD midi_group, BOOL only_set_new) IDirectMusicPort *port, DWORD midi_group)
{ {
struct channel_block *block; struct channel_block *block;
struct wine_rb_entry *entry; struct wine_rb_entry *entry;
unsigned int i; UINT i;
entry = wine_rb_get(tree, &block_num); if ((entry = wine_rb_get(&This->channel_blocks, &block_num)))
if (entry) {
block = WINE_RB_ENTRY_VALUE(entry, struct channel_block, entry); block = WINE_RB_ENTRY_VALUE(entry, struct channel_block, entry);
if (only_set_new) else
return block; {
} else { if (!(block = calloc(1, sizeof(*block)))) return E_OUTOFMEMORY;
if (!(block = malloc(sizeof(*block)))) return NULL;
block->block_num = block_num; block->block_num = block_num;
wine_rb_put(&This->channel_blocks, &block_num, &block->entry);
} }
for (i = 0; i < 16; ++i) { for (i = 0; i < ARRAY_SIZE(block->channels); ++i)
block->channels[i].port = port; {
block->channels[i].midi_group = midi_group; struct channel *channel = block->channels + i;
block->channels[i].midi_channel = i; channel->midi_group = midi_group;
channel->midi_channel = i;
channel->port = port;
} }
if (!entry)
wine_rb_put(tree, &block->block_num, &block->entry);
return block; return S_OK;
} }
static inline struct performance *impl_from_IDirectMusicPerformance8(IDirectMusicPerformance8 *iface) static inline struct performance *impl_from_IDirectMusicPerformance8(IDirectMusicPerformance8 *iface)
...@@ -994,7 +993,10 @@ static HRESULT perf_dmport_create(struct performance *perf, DMUS_PORTPARAMS *par ...@@ -994,7 +993,10 @@ static HRESULT perf_dmport_create(struct performance *perf, DMUS_PORTPARAMS *par
} }
for (i = 0; i < params->dwChannelGroups; i++) for (i = 0; i < params->dwChannelGroups; i++)
channel_block_set(&perf->channel_blocks, i, port, i + 1, FALSE); {
if (FAILED(hr = channel_block_init(perf, i, port, i + 1)))
ERR("Failed to init channel block, hr %#lx\n", hr);
}
performance_update_latency_time(perf, port, NULL); performance_update_latency_time(perf, port, NULL);
return S_OK; return S_OK;
...@@ -1051,9 +1053,7 @@ static HRESULT WINAPI performance_AssignPChannelBlock(IDirectMusicPerformance8 * ...@@ -1051,9 +1053,7 @@ static HRESULT WINAPI performance_AssignPChannelBlock(IDirectMusicPerformance8 *
if (block_num > MAXDWORD / 16) return E_INVALIDARG; if (block_num > MAXDWORD / 16) return E_INVALIDARG;
if (This->audio_paths_enabled) return DMUS_E_AUDIOPATHS_IN_USE; if (This->audio_paths_enabled) return DMUS_E_AUDIOPATHS_IN_USE;
channel_block_set(&This->channel_blocks, block_num, port, midi_group, FALSE); return channel_block_init(This, block_num, port, midi_group);
return S_OK;
} }
static HRESULT WINAPI performance_AssignPChannel(IDirectMusicPerformance8 *iface, DWORD channel_num, static HRESULT WINAPI performance_AssignPChannel(IDirectMusicPerformance8 *iface, DWORD channel_num,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment