@@ -36,7 +36,10 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
3636
3737#include " globals.h"
3838
39- #if defined _WINDOWS_DESKTOP
39+ #if defined FEATURE_PLATFORM_AUDIO
40+ #include " platform.h"
41+ static MCPlatformSoundRef s_current_sound = nil;
42+ #elif defined _WINDOWS_DESKTOP
4043#include " w32prefix.h"
4144static HWAVEOUT hwaveout; // handle to audio device opened
4245static WAVEHDR wh; // wave header structure
@@ -151,7 +154,12 @@ const char *MCAudioClip::gettypestring()
151154void MCAudioClip::timer (MCNameRef mptr, MCParameter *params)
152155{
153156 if (play ())
157+ {
158+ #ifndef FEATURE_PLATFORM_AUDIO
154159 MCscreen->addtimer (this , MCM_internal, looping ? LOOP_RATE : PLAY_RATE );
160+ #else
161+ #endif
162+ }
155163 else
156164 {
157165 MCacptr = NULL ;
@@ -193,7 +201,11 @@ Exec_stat MCAudioClip::getprop(uint4 parid, Properties which, MCExecPoint &ep, B
193201 loudness = 0 ;
194202 else
195203 {
196- #if defined _WINDOWS
204+ #if defined FEATURE_PLATFORM_AUDIO
205+ double t_volume;
206+ MCPlatformGetSystemProperty (kMCPlatformSystemPropertyVolume , kMCPlatformPropertyTypeDouble , &t_volume);
207+ loudness = t_volume * 100.0 ;
208+ #elif defined _WINDOWS
197209 if (hwaveout == NULL )
198210 {
199211 WAVEFORMATEX pwfx;
@@ -288,7 +300,11 @@ Exec_stat MCAudioClip::setprop(uint4 parid, Properties p, MCExecPoint &ep, Boole
288300 tptr = tptr->getnextplayer ();
289301 }
290302 }
291- #if defined _WINDOWS
303+ #if defined FEATURE_PLATFORM_AUDIO
304+ double t_volume;
305+ t_volume = loudness / 100.0 ;
306+ MCPlatformSetSystemProperty (kMCPlatformSystemPropertyVolume , kMCPlatformPropertyTypeDouble , &t_volume);
307+ #elif defined _WINDOWS
292308 WORD v = loudness * MAXUINT2 / 100 ;
293309 if (hwaveout != NULL )
294310 waveOutSetVolume (hwaveout, v | (v << 16 ));
@@ -341,7 +357,9 @@ void MCAudioClip::paste(void)
341357
342358void MCAudioClip::init ()
343359{
344- #if defined _WINDOWS
360+ #if defined FEATURE_PLATFORM_AUDIO
361+ supported = True;
362+ #elif defined _WINDOWS
345363 supported = True;
346364#elif defined _MACOSX
347365 supported = True;
@@ -595,7 +613,36 @@ Boolean MCAudioClip::import(const char *fname, IO_handle stream)
595613 return True;
596614}
597615
598- #if defined _WINDOWS
616+ #if defined FEATURE_PLATFORM_AUDIO
617+
618+ void MCAudioClip::convert_tocontainer (void *& r_data, size_t & r_data_size)
619+ {
620+ }
621+
622+ Boolean MCAudioClip::open_audio (void )
623+ {
624+ if (s_current_sound != nil)
625+ return True;
626+
627+ void *t_data;
628+ size_t t_data_size;
629+ convert_tocontainer (t_data, t_data_size);
630+
631+ MCPlatformSoundCreateWithData (t_data, t_data_size, s_current_sound);
632+
633+ double t_volume;
634+ t_volume = loudness / 100.0 ;
635+ MCPlatformSoundSetProperty (s_current_sound, kMCPlatformSoundPropertyVolume , kMCPlatformPropertyTypeDouble , &t_volume);
636+
637+ bool t_looping;
638+ t_looping = looping == True;
639+ MCPlatformSoundSetProperty (s_current_sound, kMCPlatformSoundPropertyLooping , kMCPlatformPropertyTypeBool , &t_looping);
640+
641+ MCPlatformSoundPlay (s_current_sound);
642+
643+ return True;
644+ }
645+ #elif defined _WINDOWS
599646Boolean MCAudioClip::open_audio ()
600647{
601648 if (hwaveout == NULL )
@@ -736,7 +783,10 @@ Boolean MCAudioClip::play()
736783 if (mstack == NULL )
737784 mstack = MCdefaultstackptr;
738785#endif
739- #ifdef _WINDOWS
786+
787+ #if defined FEATURE_PLATFORM_AUDIO
788+ return MCPlatformSoundIsPlaying (s_current_sound);
789+ #elif defined _WINDOWS
740790 if (wh.dwFlags & WHDR_DONE )
741791 {
742792 stop (False);// check to see if it is done, call stop();
@@ -834,7 +884,14 @@ Boolean MCAudioClip::play()
834884void MCAudioClip::stop (Boolean abort)
835885{
836886 MCscreen->cancelmessageobject (this , NULL );
837- #if defined _WINDOWS
887+
888+ #if defined FEATURE_PLATFORM_AUDIO
889+ if (s_current_sound != nil)
890+ {
891+ MCPlatformSoundRelease (s_current_sound);
892+ s_current_sound = nil;
893+ }
894+ #elif defined _WINDOWS
838895 if (hwaveout != NULL )
839896 {
840897 waveOutReset (hwaveout);
0 commit comments