Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
LichKing-2234 committed Dec 2, 2023
1 parent c69a792 commit 7d750e5
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 25 deletions.
21 changes: 8 additions & 13 deletions ts/Private/internal/IrisApiEngine.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import EventEmitter from 'eventemitter3';
import JSON from 'json-bigint';

import { AgoraEnv } from '../../Utils';
import { AgoraEnv, logDebug, logError, logInfo, logWarn } from '../../Utils';
import { IAudioEncodedFrameObserver } from '../AgoraBase';
import {
AudioFrame,
Expand Down Expand Up @@ -355,7 +355,7 @@ export const EVENT_PROCESSORS: EventProcessors = {

function handleEvent(...[event, data, buffers]: any) {
if (isDebuggable()) {
console.info('onEvent', event, data, buffers);
logInfo('onEvent', event, data, buffers);
}

let _event: string = event;
Expand Down Expand Up @@ -508,35 +508,30 @@ export function callIrisApi(funcName: string, params: any): any {
const retObj = JSON.parse(ret);
if (isDebuggable()) {
if (typeof retObj.result === 'number' && retObj.result < 0) {
console.error('callApi', funcName, JSON.stringify(params), ret);
logError('callApi', funcName, JSON.stringify(params), ret);
} else {
console.debug('callApi', funcName, JSON.stringify(params), ret);
logDebug('callApi', funcName, JSON.stringify(params), ret);
}
}
return retObj;
} else {
if (isDebuggable()) {
console.error(
logError(
'callApi',
funcName,
JSON.stringify(params),
callApiReturnCode
);
} else {
console.warn(
'callApi',
funcName,
JSON.stringify(params),
callApiReturnCode
);
logWarn('callApi', funcName, JSON.stringify(params), callApiReturnCode);
}
return { result: callApiReturnCode };
}
} catch (e) {
if (isDebuggable()) {
console.error('callApi', funcName, JSON.stringify(params), e);
logError('callApi', funcName, JSON.stringify(params), e);
} else {
console.warn('callApi', funcName, JSON.stringify(params), e);
logWarn('callApi', funcName, JSON.stringify(params), e);
}
}
return {};
Expand Down
4 changes: 2 additions & 2 deletions ts/Private/internal/MediaPlayerInternal.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createCheckers } from 'ts-interface-checker';

import { AgoraEnv } from '../../Utils';
import { AgoraEnv, logError } from '../../Utils';
import { ErrorCodeType } from '../AgoraBase';
import {
IAudioPcmFrameSink,
Expand Down Expand Up @@ -104,7 +104,7 @@ export class MediaPlayerInternal extends IMediaPlayerImpl {
MediaPlayerInternal._audio_spectrum_observers.get(this._mediaPlayerId)
?.length === 0
) {
console.error(
logError(
'Please call `registerMediaPlayerAudioSpectrumObserver` before you want to receive event by `addListener`'
);
return false;
Expand Down
8 changes: 4 additions & 4 deletions ts/Private/internal/RtcEngineExInternal.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createCheckers } from 'ts-interface-checker';

import { AgoraEnv } from '../../Utils';
import { AgoraEnv, logError } from '../../Utils';
import {
AudioEncodedFrameObserverConfig,
AudioRecordingConfiguration,
Expand Down Expand Up @@ -143,7 +143,7 @@ export class RtcEngineExInternal extends IRtcEngineExImpl {
if (
RtcEngineExInternal._direct_cdn_streaming_event_handler.length === 0
) {
console.error(
logError(
'Please call `startDirectCdnStreaming` before you want to receive event by `addListener`'
);
return false;
Expand All @@ -155,7 +155,7 @@ export class RtcEngineExInternal extends IRtcEngineExImpl {
})
) {
if (RtcEngineExInternal._metadata_observer.length === 0) {
console.error(
logError(
'Please call `registerMediaMetadataObserver` before you want to receive event by `addListener`'
);
return false;
Expand All @@ -167,7 +167,7 @@ export class RtcEngineExInternal extends IRtcEngineExImpl {
})
) {
if (RtcEngineExInternal._audio_encoded_frame_observers.length === 0) {
console.error(
logError(
'Please call `registerAudioEncodedFrameObserver` before you want to receive event by `addListener`'
);
return false;
Expand Down
2 changes: 2 additions & 0 deletions ts/Renderer/IRendererManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ export abstract class IRendererManager {
rendererCache.removeRenderer(renderer);
} else {
rendererCache.removeRenderer();
}
if (rendererCache.renderers.length === 0) {
this._rendererCaches.splice(
this._rendererCaches.indexOf(rendererCache),
1
Expand Down
11 changes: 7 additions & 4 deletions ts/Renderer/RendererCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,13 @@ export class RendererCache {
renderMode,
mirrorMode,
}: RendererContext): boolean {
const renderer = this.findRenderer(view);
if (renderer) {
renderer.context = { renderMode, mirrorMode };
return true;
if (view) {
const renderer = this.findRenderer(view);
if (renderer) {
renderer.context = { renderMode, mirrorMode };
return true;
}
return false;
} else {
this._renderers.forEach((it) => {
it.context = { renderMode, mirrorMode };
Expand Down
5 changes: 3 additions & 2 deletions ts/Renderer/WebGLRenderer/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { VideoFrame } from '../../Private/AgoraMediaBase';
import { logWarn } from '../../Utils';
import { IRenderer } from '../IRenderer';

export type WebGLFallback = (renderer: WebGLRenderer, error: Error) => void;
Expand Down Expand Up @@ -427,7 +428,7 @@ export class WebGLRenderer extends IRenderer {

private handleContextLost = (event: Event) => {
event.preventDefault();
console.warn('webglcontextlost', event);
logWarn('webglcontextlost', event);

this.releaseTextures();

Expand All @@ -440,7 +441,7 @@ export class WebGLRenderer extends IRenderer {

private handleContextRestored = (event: Event) => {
event.preventDefault();
console.warn('webglcontextrestored', event);
logWarn('webglcontextrestored', event);

// Setup GLSL program
this.program = createProgramFromSources(this.gl, [
Expand Down

0 comments on commit 7d750e5

Please sign in to comment.