Subversion Repositories Kolibri OS

Rev

Rev 8645 | Rev 9213 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8645 Rev 9097
Line 40... Line 40...
40
#include "dynamic_ogg.h"
40
#include "dynamic_ogg.h"
Line 41... Line 41...
41
 
41
 
42
#define __MIX_INTERNAL_EFFECT__
42
#define __MIX_INTERNAL_EFFECT__
Line -... Line 43...
-
 
43
#include "effects_internal.h"
-
 
44
 
-
 
45
#ifdef _KOLIBRI
-
 
46
    void      uSDL_Delay(unsigned int time);
-
 
47
    unsigned  uSDL_GetTicks(); 
-
 
48
#else
-
 
49
    #define uSDL_Delay SDL_Delay
-
 
50
    #define  uSDL_GetTicks SDL_GetTicks
43
#include "effects_internal.h"
51
#endif
44
 
52
 
45
/* Magic numbers for various audio file formats */
53
/* Magic numbers for various audio file formats */
46
#define RIFF		0x46464952		/* "RIFF" */
54
#define RIFF		0x46464952		/* "RIFF" */
47
#define WAVE		0x45564157		/* "WAVE" */
55
#define WAVE		0x45564157		/* "WAVE" */
Line 298... Line 306...
298
	if ( music_active || (mix_music != music_mixer) ) {
306
	if ( music_active || (mix_music != music_mixer) ) {
299
		mix_music(music_data, stream, len);
307
		mix_music(music_data, stream, len);
300
	}
308
	}
Line 301... Line 309...
301
 
309
 
302
	/* Mix any playing channels... */
310
	/* Mix any playing channels... */
303
	sdl_ticks = SDL_GetTicks();
311
	sdl_ticks =  uSDL_GetTicks();
304
	for ( i=0; i
312
	for ( i=0; i
305
		if( ! mix_channel[i].paused ) {
313
		if( ! mix_channel[i].paused ) {
306
			if ( mix_channel[i].expire > 0 && mix_channel[i].expire < sdl_ticks ) {
314
			if ( mix_channel[i].expire > 0 && mix_channel[i].expire < sdl_ticks ) {
307
				/* Expiration delay for that channel is reached */
315
				/* Expiration delay for that channel is reached */
Line 855... Line 863...
855
			}
863
			}
856
		}
864
		}
Line 857... Line 865...
857
 
865
 
858
		/* Queue up the audio data for this channel */
866
		/* Queue up the audio data for this channel */
859
		if ( which >= 0 && which < num_channels ) {
867
		if ( which >= 0 && which < num_channels ) {
860
			Uint32 sdl_ticks = SDL_GetTicks();
868
			Uint32 sdl_ticks =  uSDL_GetTicks();
861
			if (Mix_Playing(which))
869
			if (Mix_Playing(which))
862
				_Mix_channel_done_playing(which);
870
				_Mix_channel_done_playing(which);
863
			mix_channel[which].samples = chunk->abuf;
871
			mix_channel[which].samples = chunk->abuf;
864
			mix_channel[which].playing = chunk->alen;
872
			mix_channel[which].playing = chunk->alen;
Line 886... Line 894...
886
		for ( i=0; i < num_channels; ++ i ) {
894
		for ( i=0; i < num_channels; ++ i ) {
887
			status += Mix_ExpireChannel(i, ticks);
895
			status += Mix_ExpireChannel(i, ticks);
888
		}
896
		}
889
	} else if ( which < num_channels ) {
897
	} else if ( which < num_channels ) {
890
		SDL_LockAudio();
898
		SDL_LockAudio();
891
		mix_channel[which].expire = (ticks>0) ? (SDL_GetTicks() + ticks) : 0;
899
		mix_channel[which].expire = (ticks>0) ? ( uSDL_GetTicks() + ticks) : 0;
892
		SDL_UnlockAudio();
900
		SDL_UnlockAudio();
893
		++ status;
901
		++ status;
894
	}
902
	}
895
	return(status);
903
	return(status);
896
}
904
}
Line 925... Line 933...
925
			}
933
			}
926
		}
934
		}
Line 927... Line 935...
927
 
935
 
928
		/* Queue up the audio data for this channel */
936
		/* Queue up the audio data for this channel */
929
		if ( which >= 0 && which < num_channels ) {
937
		if ( which >= 0 && which < num_channels ) {
930
			Uint32 sdl_ticks = SDL_GetTicks();
938
			Uint32 sdl_ticks =  uSDL_GetTicks();
931
			if (Mix_Playing(which))
939
			if (Mix_Playing(which))
932
				_Mix_channel_done_playing(which);
940
				_Mix_channel_done_playing(which);
933
			mix_channel[which].samples = chunk->abuf;
941
			mix_channel[which].samples = chunk->abuf;
934
			mix_channel[which].playing = chunk->alen;
942
			mix_channel[which].playing = chunk->alen;
Line 1044... Line 1052...
1044
			    (mix_channel[which].volume > 0) &&
1052
			    (mix_channel[which].volume > 0) &&
1045
			    (mix_channel[which].fading != MIX_FADING_OUT) ) {
1053
			    (mix_channel[which].fading != MIX_FADING_OUT) ) {
1046
				mix_channel[which].fade_volume = mix_channel[which].volume;
1054
				mix_channel[which].fade_volume = mix_channel[which].volume;
1047
				mix_channel[which].fading = MIX_FADING_OUT;
1055
				mix_channel[which].fading = MIX_FADING_OUT;
1048
				mix_channel[which].fade_length = ms;
1056
				mix_channel[which].fade_length = ms;
1049
				mix_channel[which].ticks_fade = SDL_GetTicks();
1057
				mix_channel[which].ticks_fade =  uSDL_GetTicks();
Line 1050... Line 1058...
1050
 
1058
 
1051
				/* only change fade_volume_reset if we're not fading. */
1059
				/* only change fade_volume_reset if we're not fading. */
1052
				if (mix_channel[which].fading == MIX_NO_FADING) {
1060
				if (mix_channel[which].fading == MIX_NO_FADING) {
1053
				    mix_channel[which].fade_volume_reset = mix_channel[which].volume;
1061
				    mix_channel[which].fade_volume_reset = mix_channel[which].volume;
Line 1149... Line 1157...
1149
}
1157
}
Line 1150... Line 1158...
1150
 
1158
 
1151
/* Pause a particular channel (or all) */
1159
/* Pause a particular channel (or all) */
1152
void Mix_Pause(int which)
1160
void Mix_Pause(int which)
1153
{
1161
{
1154
	Uint32 sdl_ticks = SDL_GetTicks();
1162
	Uint32 sdl_ticks =  uSDL_GetTicks();
1155
	if ( which == -1 ) {
1163
	if ( which == -1 ) {
Line 1156... Line 1164...
1156
		int i;
1164
		int i;
1157
 
1165
 
Line 1168... Line 1176...
1168
}
1176
}
Line 1169... Line 1177...
1169
 
1177
 
1170
/* Resume a paused channel */
1178
/* Resume a paused channel */
1171
void Mix_Resume(int which)
1179
void Mix_Resume(int which)
1172
{
1180
{
Line 1173... Line 1181...
1173
	Uint32 sdl_ticks = SDL_GetTicks();
1181
	Uint32 sdl_ticks =  uSDL_GetTicks();
1174
 
1182
 
1175
	SDL_LockAudio();
1183
	SDL_LockAudio();
Line 1258... Line 1266...
1258
 
1266
 
1259
/* Finds the "oldest" sample playing in a group of channels */
1267
/* Finds the "oldest" sample playing in a group of channels */
1260
int Mix_GroupOldest(int tag)
1268
int Mix_GroupOldest(int tag)
1261
{
1269
{
1262
	int chan = -1;
1270
	int chan = -1;
1263
	Uint32 mintime = SDL_GetTicks();
1271
	Uint32 mintime =  uSDL_GetTicks();
1264
	int i;
1272
	int i;
1265
	for( i=0; i < num_channels; i ++ ) {
1273
	for( i=0; i < num_channels; i ++ ) {
1266
		if ( (mix_channel[i].tag==tag || tag==-1) && mix_channel[i].playing > 0
1274
		if ( (mix_channel[i].tag==tag || tag==-1) && mix_channel[i].playing > 0
1267
			 && mix_channel[i].start_time <= mintime ) {
1275
			 && mix_channel[i].start_time <= mintime ) {