debug
This commit is contained in:
parent
c0330e46fd
commit
3d51fe5610
|
@ -1,6 +1,9 @@
|
||||||
import rtc_plugins
|
import rtc_plugins
|
||||||
import time
|
import time
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import mmap
|
||||||
|
import os
|
||||||
|
from ctypes import c_int16
|
||||||
|
|
||||||
srcUserId = "srcUser12"
|
srcUserId = "srcUser12"
|
||||||
destUserId = "destUser12"
|
destUserId = "destUser12"
|
||||||
|
@ -12,9 +15,19 @@ srcRoomId = "srcRoom12"
|
||||||
destRoomId = srcRoomId
|
destRoomId = srcRoomId
|
||||||
srcChannelIndex = 46
|
srcChannelIndex = 46
|
||||||
destChannelIndex = 47
|
destChannelIndex = 47
|
||||||
def my_callback(npData, dataSize, dataCount, sampleRate, numChannels, channelIndex):
|
def my_callback(shmName, dataSize, dataCount, sampleRate, numChannels, channelIndex):
|
||||||
print(f"dataSize:{dataSize}, dataCount:{dataCount}, sampleRate:{sampleRate}, numChannels:{numChannels}, channelIndex:{channelIndex}")
|
print(f"dataSize:{dataSize}, dataCount:{dataCount}, sampleRate:{sampleRate}, numChannels:{numChannels}, channelIndex:{channelIndex}")
|
||||||
print(npData)
|
print(shmName)
|
||||||
|
fd = os.open(shmName, os.O_RDONLY)
|
||||||
|
if fd == -1:
|
||||||
|
raise RuntimeError(f"无法打开共享内存 {shmName}")
|
||||||
|
|
||||||
|
# 2. 创建内存映射
|
||||||
|
shm = mmap.mmap(fd, dataSize, mmap.MAP_SHARED, mmap.PROT_READ)
|
||||||
|
|
||||||
|
# 3. 转换为numpy数组 (零拷贝)
|
||||||
|
audio_data = np.frombuffer(shm, dtype=c_int16, count=dataCount)
|
||||||
|
print(f" 前5个采样点: {audio_data[:5]}")
|
||||||
#audioData = np.array([0, 1, -1, 0], dtype=np.int16)
|
#audioData = np.array([0, 1, -1, 0], dtype=np.int16)
|
||||||
#ret = rtc_plugins.sendCustomAudioData(srcChannelIndex, audioData, 48000, 1, len(audioData))
|
#ret = rtc_plugins.sendCustomAudioData(srcChannelIndex, audioData, 48000, 1, len(audioData))
|
||||||
#if ret != 0:
|
#if ret != 0:
|
||||||
|
|
Loading…
Reference in New Issue