console: fmod use extern class FFI
This commit is contained in:
@@ -61,6 +61,8 @@ class AudioBuffer {
|
||||
|
||||
#if lime_console
|
||||
|
||||
trace ("not implemented");
|
||||
/*
|
||||
var sound:Sound = Sound.fromBytes (bytes);
|
||||
|
||||
if (sound.valid) {
|
||||
@@ -74,6 +76,7 @@ class AudioBuffer {
|
||||
return audioBuffer;
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
#elseif (cpp || neko || nodejs)
|
||||
|
||||
|
||||
@@ -2,66 +2,34 @@ package lime.audio.fmod;
|
||||
#if lime_console
|
||||
|
||||
|
||||
import lime.ConsoleIncludePaths;
|
||||
import lime.system.System;
|
||||
import lime.utils.ByteArray;
|
||||
|
||||
|
||||
abstract Channel(Int) {
|
||||
@:include("ConsoleFmodAPI.h")
|
||||
@:native("lime::hxapi::ConsoleFmodChannel")
|
||||
extern class Channel {
|
||||
|
||||
|
||||
// valid is true if this represents a valid handle to a channel.
|
||||
public var valid (get, never):Bool;
|
||||
|
||||
|
||||
public static inline function fromHandle (handle:Int):Channel {
|
||||
|
||||
#if lime_console
|
||||
trace("not implemented");
|
||||
return cast (0, Channel);
|
||||
#end
|
||||
|
||||
}
|
||||
// pause sets channel to a paused state.
|
||||
public function pause ():Void;
|
||||
|
||||
|
||||
public inline function pause ():Void {
|
||||
|
||||
#if lime_console
|
||||
lime_fmod_channel_pause (this);
|
||||
#end
|
||||
|
||||
}
|
||||
// resume sets channel to an unpaused state.
|
||||
public function resume ():Void;
|
||||
|
||||
|
||||
public inline function resume ():Void {
|
||||
|
||||
#if lime_console
|
||||
lime_fmod_channel_resume (this);
|
||||
#end
|
||||
|
||||
}
|
||||
// stop stops the channel from playing, making it available for another
|
||||
// sound to use.
|
||||
public function stop ():Void;
|
||||
|
||||
|
||||
public inline function stop ():Void {
|
||||
|
||||
#if lime_console
|
||||
lime_fmod_channel_stop (this);
|
||||
this = 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
private inline function get_valid ():Bool {
|
||||
|
||||
return this != 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#if lime_console
|
||||
private static var lime_fmod_channel_pause:Dynamic = System.load ("lime", "lime_fmod_channel_pause", 1);
|
||||
private static var lime_fmod_channel_resume:Dynamic = System.load ("lime", "lime_fmod_channel_resume", 1);
|
||||
private static var lime_fmod_channel_stop:Dynamic = System.load ("lime", "lime_fmod_channel_stop", 1);
|
||||
#end
|
||||
private function get_valid ():Bool;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,70 +2,34 @@ package lime.audio.fmod;
|
||||
#if lime_console
|
||||
|
||||
|
||||
import lime.ConsoleIncludePaths;
|
||||
import lime.system.System;
|
||||
import lime.utils.ByteArray;
|
||||
|
||||
|
||||
abstract Sound(Int) {
|
||||
@:include("ConsoleFmodAPI.h")
|
||||
@:native("lime::hxapi::ConsoleFmodSound")
|
||||
extern class Sound {
|
||||
|
||||
|
||||
// valid returns true if this represents a valid handle to a sound.
|
||||
public var valid (get, never):Bool;
|
||||
|
||||
|
||||
public static inline function fromBytes (bytes:ByteArray):Sound {
|
||||
|
||||
// TODO(james4k): with FMOD_OPENMEMORY_POINT? We probably want to
|
||||
// discourage this, or even not support it. Should avoid using haxe's
|
||||
// heap when feasible.
|
||||
|
||||
#if lime_console
|
||||
trace("not implemented");
|
||||
return cast (0, Sound);
|
||||
#end
|
||||
|
||||
}
|
||||
// fromFile creates a sound from the named file.
|
||||
@:native("lime::ConsoleFmodSound::fromFile")
|
||||
public static function fromFile (name:String):Sound;
|
||||
|
||||
|
||||
public static inline function fromFile (name:String):Sound {
|
||||
|
||||
#if lime_console
|
||||
return lime_fmod_sound_create (name);
|
||||
#end
|
||||
|
||||
}
|
||||
// play plays the sound and returns the channel it was assigned.
|
||||
public function play ():Channel;
|
||||
|
||||
|
||||
public inline function play ():Channel {
|
||||
|
||||
#if lime_console
|
||||
return lime_fmod_sound_play (this);
|
||||
#end
|
||||
|
||||
}
|
||||
// release releases the sound.
|
||||
public function release ():Void;
|
||||
|
||||
|
||||
public inline function release ():Void {
|
||||
|
||||
#if lime_console
|
||||
lime_fmod_sound_release (this);
|
||||
this = 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
private inline function get_valid ():Bool {
|
||||
|
||||
return this != 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#if lime_console
|
||||
private static var lime_fmod_sound_create:Dynamic = System.load ("lime", "lime_fmod_sound_create", 1);
|
||||
private static var lime_fmod_sound_play:Dynamic = System.load ("lime", "lime_fmod_sound_play", 1);
|
||||
private static var lime_fmod_sound_release:Dynamic = System.load ("lime", "lime_fmod_sound_release", 1);
|
||||
#end
|
||||
private function get_valid ():Bool;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user