Skip to content

Commit 7a55b10

Browse files
author
xianing
committed
fix raw audio data sample
1 parent 18154ab commit 7a55b10

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/ProcessAudioRawData.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,6 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
110110
* The SDK uses this class to report to the app on SDK runtime events.*/
111111
String appId = getString(R.string.agora_app_id);
112112
engine = RtcEngine.create(getContext().getApplicationContext(), appId, iRtcEngineEventHandler);
113-
/** Registers the audio observer object.
114-
*
115-
* @param observer Audio observer object to be registered. See {@link IAudioFrameObserver IAudioFrameObserver}. Set the value as @p null to cancel registering, if necessary.
116-
* @return
117-
* - 0: Success.
118-
* - < 0: Failure.
119-
*/
120-
engine.registerAudioFrameObserver(audioFrameObserver);
121113
openAudioFile();
122114
}
123115
catch (Exception e) {
@@ -155,7 +147,7 @@ private void closeAudioFile(){
155147
}
156148

157149
private byte[] readBuffer(){
158-
int byteSize = SAMPLES_PER_CALL * BIT_PER_SAMPLE / 8 * SAMPLE_NUM_OF_CHANNEL;
150+
int byteSize = SAMPLES_PER_CALL * BIT_PER_SAMPLE / 8;
159151
byte[] buffer = new byte[byteSize];
160152
try {
161153
if(inputStream.read(buffer) < 0){
@@ -278,8 +270,14 @@ private void joinChannel(String channelId) {
278270
}
279271
// Prevent repeated entry
280272
join.setEnabled(false);
281-
282-
273+
/** Registers the audio observer object.
274+
*
275+
* @param observer Audio observer object to be registered. See {@link IAudioFrameObserver IAudioFrameObserver}. Set the value as @p null to cancel registering, if necessary.
276+
* @return
277+
* - 0: Success.
278+
* - < 0: Failure.
279+
*/
280+
engine.registerAudioFrameObserver(audioFrameObserver);
283281
}
284282

285283
/**
@@ -451,7 +449,7 @@ public boolean onPlaybackFrameBeforeMixingEx(AudioFrame audioFrame, int uid, Str
451449

452450
@Override
453451
public int getObservedAudioFramePosition() {
454-
return IAudioFrameObserver.POSITION_RECORD;
452+
return IAudioFrameObserver.POSITION_RECORD | IAudioFrameObserver.POSITION_MIXED;
455453
}
456454

457455
@Override

0 commit comments

Comments
 (0)