1 | void function (Sink) {
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * A Sink-specific error class.
|
---|
5 | *
|
---|
6 | * @class
|
---|
7 | * @static Sink
|
---|
8 | * @name Error
|
---|
9 | *
|
---|
10 | * @arg =code
|
---|
11 | *
|
---|
12 | * @param {Number} code The error code.
|
---|
13 | * @param {String} message A brief description of the error.
|
---|
14 | * @param {String} explanation A more verbose explanation of why the error occured and how to fix.
|
---|
15 | */
|
---|
16 |
|
---|
17 | function SinkError(code) {
|
---|
18 | if (!SinkError.hasOwnProperty(code)) throw SinkError(1);
|
---|
19 | if (!(this instanceof SinkError)) return new SinkError(code);
|
---|
20 |
|
---|
21 | var k;
|
---|
22 | for (k in SinkError[code]) {
|
---|
23 | if (SinkError[code].hasOwnProperty(k)) {
|
---|
24 | this[k] = SinkError[code][k];
|
---|
25 | }
|
---|
26 | }
|
---|
27 |
|
---|
28 | this.code = code;
|
---|
29 | }
|
---|
30 |
|
---|
31 | SinkError.prototype = new Error();
|
---|
32 |
|
---|
33 | SinkError.prototype.toString = function () {
|
---|
34 | return 'SinkError 0x' + this.code.toString(16) + ': ' + this.message;
|
---|
35 | };
|
---|
36 |
|
---|
37 | SinkError[0x01] = {
|
---|
38 | message: 'No such error code.',
|
---|
39 | explanation: 'The error code does not exist.'
|
---|
40 | };
|
---|
41 | SinkError[0x02] = {
|
---|
42 | message: 'No audio sink available.',
|
---|
43 | explanation: 'The audio device may be busy, or no supported output API is available for this browser.'
|
---|
44 | };
|
---|
45 |
|
---|
46 | SinkError[0x10] = {
|
---|
47 | message: 'Buffer underflow.',
|
---|
48 | explanation: 'Trying to recover...'
|
---|
49 | };
|
---|
50 | SinkError[0x11] = {
|
---|
51 | message: 'Critical recovery fail.',
|
---|
52 | explanation: 'The buffer underflow has reached a critical point, trying to recover, but will probably fail anyway.'
|
---|
53 | };
|
---|
54 | SinkError[0x12] = {
|
---|
55 | message: 'Buffer size too large.',
|
---|
56 | explanation: 'Unable to allocate the buffer due to excessive length, please try a smaller buffer. Buffer size should probably be smaller than the sample rate.'
|
---|
57 | };
|
---|
58 |
|
---|
59 | Sink.Error = SinkError;
|
---|
60 |
|
---|
61 | }(this.Sink);
|
---|