Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close #11 #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions anoggplayer/AnOggPlayer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ class AnMp3Player {
var playTimer: haxe.Timer;

function DoProgress(event:ProgressEvent):Void {
bytesLoaded = event.bytesLoaded;
bytesTotal = event.bytesTotal;
bytesLoaded = cast(event.bytesLoaded,Int);
bytesTotal = cast(event.bytesTotal,Int);
doOnProgress(Math.ceil(bytesLoaded*100/bytesTotal),bytesPlayed);
if(mp3Sound.isBuffering)doBuffer(50)
else {
Expand Down Expand Up @@ -350,7 +350,7 @@ class AnOggPlayer {
};
comment = System.fromBytes(ptr[j], 0, ptr[j].length - 1).split("=");
comments = comments+comment[0];
comments = comments +"=\""+StringTools.replace(comment[1],"\"","\"\"")+"\";";
comments = comments +"=\""+StringTools.htmlEscape(StringTools.replace(comment[1],"\"","\"\""))+"\";";
trace(System.fromBytes(ptr[j], 0, ptr[j].length - 1));
j++;
};
Expand Down Expand Up @@ -468,7 +468,7 @@ class AnOggPlayer {
target_pos=Math.ceil(bytesTotal*seek_pos);
target_step=Math.ceil(Math.max(Math.ceil(target_pos/16384),3));
target_pos=target_step*16384;
if(playBuffer.length>target_pos){
if(playBuffer.length > cast(target_pos,UInt)){
bytesPlayed=target_pos;
playBuffer.position=target_pos;
return 1;
Expand Down Expand Up @@ -661,15 +661,15 @@ class AnOggPlayer {

function _on_progress(e : flash.events.ProgressEvent) : Void {
//trace("on_progress: " + ul.bytesAvailable);
bytesLoaded = e.bytesLoaded;
bytesLoaded = cast(e.bytesLoaded,Int);
if(oldBytesTotal==0){
_bootstrap_pending=false;
read_started=false;
oldBytesTotal=bytesTotal;
if(adjustCount>3)adjustCount=0;
if(!streamDetected)trace("adjust "+adjustCount+": size "+bytesTotal);
}
bytesTotal = e.bytesTotal;
bytesTotal = cast(e.bytesTotal,Int);
if((bytesTotal==0)&&(!streamDetected))
{
adjustCount++;
Expand Down Expand Up @@ -773,11 +773,11 @@ class AnOggPlayer {
init_statics();

var fvs : Dynamic<String> = flash.Lib.current.loaderInfo.parameters;
var url = fvs.playUrl == null ? "http://anoma.ch:3210/low.ogg" : fvs.playUrl;
var url = fvs.playUrl == null ? "http://comodino.org:8001/null.ogg" : fvs.playUrl;

var foe = new AnOggPlayer(url);
foe.volume=100;
flash.system.Security.allowDomain("anoma.ch");
flash.system.Security.allowDomain("*");
flash.external.ExternalInterface.addCallback("playURL",foe._playURL);
flash.external.ExternalInterface.addCallback("stopPlaying",foe._stopPlay);
flash.external.ExternalInterface.addCallback("setVolume",foe._setVolume);
Expand Down
2 changes: 1 addition & 1 deletion anoggplayer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ HX_FILES = \
VectorTools.hx

AnOgg.swf: build.hxml AnOggPlayer.hx $(HX_FILES)
$(HAXE) -cp . build.hxml
$(HAXE) -cp . -swf-version 10 -swf-header 200:200:30:000000 build.hxml

clean:
rm -f AnOgg.swf
Expand Down
4 changes: 2 additions & 2 deletions anoggplayer/VectorTools.hx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class VectorTools {
b = src.slice(src_pos, src_end);
}

if (dst_pos + length < dst.length) {
if (cast(dst_pos + length,Int) < dst.length) {
b = b.concat(dst.slice(dst_pos + length));
}

Expand All @@ -118,7 +118,7 @@ class VectorTools {
b = src.slice(src_pos, src_end);
}

if (dst_pos + length < dst.length) {
if (cast(dst_pos + length,Int) < dst.length) {
b = b.concat(dst.slice(dst_pos + length));
}

Expand Down
2 changes: 1 addition & 1 deletion anoggplayer/build.hxml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-main AnOggPlayer
-swf-version 10
-swf-header 400:800:12:ffffff
-swf9 AnOgg.swf
-swf AnOgg.swf
28 changes: 15 additions & 13 deletions anoggplayer/org/xiph/fogg/Buffer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ class Buffer {
* generated source for Buffer
*/
inline static private var BUFFER_INCREMENT : Int = 256;
inline static private var _mask : Array<Int> =
[0x00000000, 0x00000001, 0x00000003, 0x00000007,
0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
0xffffffff];
inline static private function _mask(): Array<Int>{
return [0x00000000, 0x00000001, 0x00000003, 0x00000007,
0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
0xffffffff];
}

static private var _vmask : Vector<Int> = null;
private var mask : Vector<Int>;

Expand All @@ -44,7 +46,7 @@ class Buffer {
// modifiers: public
public function writeBytes(s : Bytes) : Void {
// for-while;
var i : Int = 0;
var i : UInt = 0;
while (i < s.length) {
if (s[i] == 0) {
break;
Expand Down Expand Up @@ -343,10 +345,10 @@ class Buffer {

private static function __static_init__() : Void {
var i : Int = 0;
var n : Int = Buffer._mask.length;
var n : Int = Buffer._mask().length;
Buffer._vmask = new Vector(n, true);
while (i < n) {
Buffer._vmask[i] = Buffer._mask[i];
Buffer._vmask[i] = Buffer._mask()[i];
i++;
}
}
Expand Down
2 changes: 1 addition & 1 deletion anoggplayer/org/xiph/fogg/StreamState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class StreamState {
}
else {
// for-while;
var i : Int = 0;
var i : UInt = 0;
while (i < body_data.length) {
body_data[i] = 0;
i++;
Expand Down
17 changes: 9 additions & 8 deletions anoggplayer/org/xiph/foggy/Demuxer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ class Demuxer {
var og : Page;
var op : Packet;

var streams : IntHash<StreamState>;
var streams : Map<Int,StreamState>;
var bos_done : Bool;

var page_cbs : IntHash<Page -> Int -> DemuxerStatus>;
var packet_cbs : IntHash<Packet -> Int -> DemuxerStatus>;
var page_cbs : Map<Int,Page -> Int -> DemuxerStatus>;
var packet_cbs : Map<Int,Packet -> Int -> DemuxerStatus>;

public function new() {
page_cbs = new IntHash();
packet_cbs = new IntHash();
streams = new IntHash();
page_cbs = new Map<Int,Page -> Int -> DemuxerStatus>();
packet_cbs = new Map<Int,Packet -> Int -> DemuxerStatus>();
streams = new Map<Int,StreamState>();

bos_done = false;

Expand Down Expand Up @@ -122,11 +122,12 @@ class Demuxer {

var os : StreamState = streams.get(sn);
if (os == null) {
if (bos_done) {
/*if (bos_done) {
// unexpected new stream
trace("unexpected end of stream");
return -1;
}
}*/
bos_done = false;
os = new StreamState();
os.init(sn);
streams.set(sn, os);
Expand Down
2 changes: 1 addition & 1 deletion anoggplayer/org/xiph/fvorbis/Block.hx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Block {
// for-while;
var i : Int = 0;
while (i < vi.channels) {
if ((pcm[i] == null) || (pcm[i].length < pcmend)) {
if ((pcm[i] == null) || (cast(pcm[i].length,UInt) < cast(pcmend,UInt))) {
//pcm[i] = new float[pcmend];
pcm[i] = new Vector(pcmend, true);
}
Expand Down
10 changes: 5 additions & 5 deletions anoggplayer/org/xiph/fvorbis/Floor0.hx
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ class Floor0 extends FuncFloor {
info.ampdB = opb.read(8);
info.numbooks = (opb.read(4) + 1);
if ((((info.order < 1) || (info.rate < 1)) || (info.barkmap < 1)) || (info.numbooks < 1)) {
return;
return null;
};
// for-while;
var j : Int = 0;
while (j < info.numbooks) {
info.books[j] = opb.read(8);
if ((info.books[j] < 0) || (info.books[j] >= vi.books)) {
return;
return null;
};
j++;
};
Expand Down Expand Up @@ -202,7 +202,7 @@ class Floor0 extends FuncFloor {
if ((booknum != -1) && (booknum < info.numbooks)) {
var b : CodeBook = vb.vd.fullbooks[info.books[booknum]];
var last : Float = 0.;
if ((lsp == null) || (lsp.length < (look.m + 1))) {
if ((lsp == null) || (lsp.length < look.m + 1)) {
//lsp = new float[look.m + 1];
lsp = new Vector(look.m + 1, true);
}
Expand All @@ -218,7 +218,7 @@ class Floor0 extends FuncFloor {
var j : Int = 0;
while (j < look.m) {
if (b.decodev_set(lsp, j, vb.opb, b.dim) == -1) {
return;
return null;
};
j += b.dim;
};
Expand All @@ -237,7 +237,7 @@ class Floor0 extends FuncFloor {
return lsp;
};
};
return;
return null;
}

// modifiers:
Expand Down
14 changes: 7 additions & 7 deletions anoggplayer/org/xiph/fvorbis/Floor1.hx
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,22 @@ class Floor1 extends FuncFloor {
info.class_subs[j] = opb.read(2);
if (info.class_subs[j] < 0) {
info.free();
return;
return null;
};
if (info.class_subs[j] != 0) {
info.class_book[j] = opb.read(8);
};
if ((info.class_book[j] < 0) || (info.class_book[j] >= vi.books)) {
info.free();
return;
return null;
};
// for-while;
var k : Int = 0;
while (k < (1 << info.class_subs[j])) {
info.class_subbook[j][k] = (opb.read(8) - 1);
if ((info.class_subbook[j][k] < -1) || (info.class_subbook[j][k] >= vi.books)) {
info.free();
return;
return null;
};
k++;
};
Expand All @@ -119,7 +119,7 @@ class Floor1 extends FuncFloor {
var t : Int = info.postlist[k + 2] = opb.read(rangebits);
if ((t < 0) || (t >= (1 << rangebits))) {
info.free();
return;
return null;
};
k++;
};
Expand Down Expand Up @@ -287,7 +287,7 @@ class Floor1 extends FuncFloor {
if (csubbits != 0) {
cval = books[info.class_book[clss]].decode(vb.opb);
if (cval == -1) {
return;
return null;
};
};
// for-while;
Expand All @@ -297,7 +297,7 @@ class Floor1 extends FuncFloor {
cval >>>= csubbits;
if (book >= 0) {
if ((fit_value[j + k] = books[book].decode(vb.opb)) == -1) {
return;
return null;
};
}
else {
Expand Down Expand Up @@ -344,7 +344,7 @@ class Floor1 extends FuncFloor {
};
return fit_value;
};
return;
return null;
}

// modifiers: static, private
Expand Down
3 changes: 3 additions & 0 deletions anoggplayer/org/xiph/fvorbis/FuncFloor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ class FuncFloor {
// modifiers: abstract
public function unpack(vi : Info, opb : Buffer) : Dynamic {
throw "UnimplementedAbstractMethod";
return null;
}

// modifiers: abstract
public function look(vd : DspState, mi : InfoMode, i : Dynamic) : Dynamic {
throw "UnimplementedAbstractMethod";
return null;
}

// modifiers: abstract
Expand All @@ -53,6 +55,7 @@ class FuncFloor {
// modifiers: abstract
public function inverse1(vb : Block, i : Dynamic, memo : Dynamic) : Dynamic {
throw "UnimplementedAbstractMethod";
return null;
}

// modifiers: abstract
Expand Down
2 changes: 2 additions & 0 deletions anoggplayer/org/xiph/fvorbis/FuncMapping.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ class FuncMapping {
// modifiers: abstract
public function unpack(info : Info, buffer : Buffer) : Dynamic {
throw "UnimplementedAbstractMethod";
return null;
}

// modifiers: abstract
public function look(vd : DspState, vm : InfoMode, m : Dynamic) : Dynamic {
throw "UnimplementedAbstractMethod";
return null;
}

// modifiers: abstract
Expand Down
2 changes: 2 additions & 0 deletions anoggplayer/org/xiph/fvorbis/FuncResidue.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ class FuncResidue {
// modifiers: abstract
public function unpack(vi : Info, opb : Buffer) : Dynamic {
throw "UnimplementedAbstractMethod";
return null;
}

// modifiers: abstract
public function look(vd : DspState, vm : InfoMode, vr : Dynamic) : Dynamic {
throw "UnimplementedAbstractMethod";
return null;
}

// modifiers: abstract
Expand Down
2 changes: 2 additions & 0 deletions anoggplayer/org/xiph/fvorbis/FuncTime.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ class FuncTime {
// modifiers: abstract
public function unpack(vi : Info, opb : Buffer) : Dynamic {
throw "UnimplementedAbstractMethod";
return null;
}

// modifiers: abstract
public function look(vd : DspState, vm : InfoMode, i : Dynamic) : Dynamic {
throw "UnimplementedAbstractMethod";
return null;
}

// modifiers: abstract
Expand Down
Loading