char name[32]; /* only editable while allocated == 0 */
audio_clip *source; /* ... */
u32 flags; /* ... */
+ u32 colour; /* ... */
/* internal non-readable state
* -----------------------------*/
k_channel_activity_reset, /* will advance if allocated==1, to wake */
k_channel_activity_wake, /* will advance to either of next two */
k_channel_activity_alive,
+ k_channel_activity_end,
k_channel_activity_error
}
- activity;
+ activity,
+ readable_activity;
/*
* editable structure, can be modified inside _lock and _unlock
{
ch->source = clip;
ch->flags = flags;
+ ch->colour = 0x00333333;
strcpy( ch->name, clip->path );
ch->allocated = 1;
return NULL;
}
+static int audio_channel_finished( audio_channel *ch )
+{
+ if( ch->readable_activity == k_channel_activity_end )
+ return 1;
+ else
+ return 0;
+}
+
static audio_channel *audio_relinquish_channel( audio_channel *ch )
{
ch->editable_state.relinquished = 1;
if( ch->flags & AUDIO_FLAG_SPACIAL_3D )
{
v3_copy( co, ch->editable_state.spacial_falloff );
- ch->editable_state.spacial_falloff[3] = 1.0f/range;
+
+ if( range == 0.0f )
+ ch->editable_state.spacial_falloff[3] = 1.0f;
+ else
+ ch->editable_state.spacial_falloff[3] = 1.0f/range;
+
ch->editble_state_write_mask |= AUDIO_EDIT_SPACIAL;
}
else
if( !ch->allocated )
continue;
+ if( ch->activity == k_channel_activity_alive )
+ {
+ if( (ch->cursor >= ch->source_length) &&
+ !(ch->flags & AUDIO_FLAG_LOOP) )
+ {
+ ch->activity = k_channel_activity_end;
+ }
+ }
+
/* process relinquishments */
if( (ch->activity != k_channel_activity_reset) && ch->_.relinquished )
{
- if( (ch->cursor >= ch->source_length && !(ch->flags & AUDIO_FLAG_LOOP))
+ if( (ch->activity == k_channel_activity_end)
|| (ch->_.volume == 0.0f)
|| (ch->activity == k_channel_activity_error) )
{
vg_profile_end( &_vg_prof_dsp );
- /*
- * Relinquishing conditions
- * ------------------------------------------------------------------
- */
audio_lock();
+ for( int i=0; i<AUDIO_CHANNELS; i ++ )
+ {
+ audio_channel *ch = &vg_audio.channels[i];
+ ch->readable_activity = ch->activity;
+ }
+
/* Profiling information
* ----------------------------------------------- */
vg_profile_increment( &_vg_prof_audio_decode );
"Vorbis"
};
+ const char *activties[] =
+ {
+ "reset",
+ "wake ",
+ "alive",
+ "end ",
+ "error"
+ };
+
int format_index = 0;
if( ch->source->flags & AUDIO_FLAG_STEREO )
else
format_index = 1;
- snprintf( perf, 127, "%02d %c%c%cD %s %4.2fv'%s'",
+ snprintf( perf, 127, "%02d %c%c%cD %s [%s] %4.2fv'%s'",
i,
- (ch->editable_state.relinquished)? 'r': ' ',
- 0? 'r': ' ',
+ (ch->editable_state.relinquished)? 'r': '_',
+ 0? 'r': '_',
0? '3': '2',
formats[format_index],
+ activties[ch->readable_activity],
ch->editable_state.volume,
ch->name );
}
else
{
- ui_fill_rect( vg_uictx.cursor, 0xa0333333 );
+ ui_fill_rect( vg_uictx.cursor, 0xa0000000 | ch->colour );
}
vg_uictx.cursor[0] += 2;