mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-26 01:35:14 +02:00
movement to use AudioInjector classes in Operative code
This commit is contained in:
parent
4ebc381e40
commit
9834c10610
13 changed files with 25 additions and 11 deletions
|
@ -18,7 +18,7 @@ include_glm(${TARGET_NAME} ${ROOT_DIR})
|
|||
# link the shared hifi library
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR})
|
||||
link_hifi_library(audio ${TARGET_NAME} ${ROOT_DIR})
|
||||
# link_hifi_library(audio ${TARGET_NAME} ${ROOT_DIR})
|
||||
|
||||
# link the stk library
|
||||
set(STK_ROOT_DIR ${ROOT_DIR}/externals/stk)
|
||||
|
|
|
@ -374,7 +374,7 @@ int main(int argc, const char* argv[]) {
|
|||
|
||||
InjectedAudioRingBuffer* ringBuffer = (InjectedAudioRingBuffer*) node->getLinkedData();
|
||||
if (memcmp(ringBuffer->getStreamIdentifier(),
|
||||
packetData + 1,
|
||||
packetData + numBytesForPacketHeader(packetData),
|
||||
STREAM_IDENTIFIER_NUM_BYTES) == 0) {
|
||||
// this is the matching stream, assign to matchingInjector and stop looking
|
||||
matchingInjector = &*node;
|
||||
|
|
|
@ -39,12 +39,12 @@ Pod::Spec.new do |s|
|
|||
sp.public_header_files = "librares/shared/src"
|
||||
sp.exclude_files = "libraries/shared/src/UrlReader.*"
|
||||
sp.dependency 'glm'
|
||||
sp.xcconfig = { 'CLANG_CXX_LIBRARY' => "libc++" }
|
||||
end
|
||||
|
||||
s.subspec "audio" do |sp|
|
||||
sp.source_files = "libraries/audio/src"
|
||||
sp.public_header_files = "libraries/audio/src"
|
||||
sp.xcconfig = { 'CLANG_CXX_LIBRARY' => "libc++" }
|
||||
sp.dependency 'glm'
|
||||
end
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
|||
link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR})
|
||||
link_hifi_library(voxels ${TARGET_NAME} ${ROOT_DIR})
|
||||
link_hifi_library(avatars ${TARGET_NAME} ${ROOT_DIR})
|
||||
link_hifi_library(audio ${TARGET_NAME} ${ROOT_DIR})
|
||||
# link_hifi_library(audio ${TARGET_NAME} ${ROOT_DIR})
|
||||
|
||||
# find required libraries
|
||||
find_package(GLM REQUIRED)
|
||||
|
|
|
@ -61,6 +61,8 @@ void* AudioInjectionManager::injectAudioViaThread(void* args) {
|
|||
Node* audioMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
|
||||
if (audioMixer) {
|
||||
_destinationSocket = *audioMixer->getActiveSocket();
|
||||
} else {
|
||||
pthread_exit(0);
|
||||
}
|
||||
}
|
||||
|
|
@ -9,8 +9,8 @@
|
|||
#include <fstream>
|
||||
#include <cstring>
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
#include <SharedUtil.h>
|
||||
#include "PacketHeaders.h"
|
||||
#include "SharedUtil.h"
|
||||
|
||||
#include "AudioInjector.h"
|
||||
|
||||
|
@ -131,9 +131,10 @@ void AudioInjector::addSample(const int16_t sample) {
|
|||
}
|
||||
|
||||
void AudioInjector::addSamples(int16_t* sampleBuffer, int numSamples) {
|
||||
if (_audioSampleArray + _indexOfNextSlot + numSamples <= _audioSampleArray + (_numTotalSamples / sizeof(int16_t))) {
|
||||
if (_audioSampleArray + _indexOfNextSlot + numSamples <= _audioSampleArray + _numTotalSamples) {
|
||||
// only copy the audio from the sample buffer if there's space
|
||||
memcpy(_audioSampleArray + _indexOfNextSlot, sampleBuffer, numSamples * sizeof(int16_t));
|
||||
printf("Copied %d samples to the buffer\n", numSamples);
|
||||
_indexOfNextSlot += numSamples;
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@
|
|||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <glm/gtx/component_wise.hpp>
|
||||
|
||||
#include <UDPSocket.h>
|
||||
#include "UDPSocket.h"
|
||||
|
||||
#include "AudioRingBuffer.h"
|
||||
|
|
@ -30,7 +30,7 @@ const char SOLO_NODE_TYPES[3] = {
|
|||
};
|
||||
|
||||
char DOMAIN_HOSTNAME[] = "highfidelity.below92.com";
|
||||
char DOMAIN_IP[100] = ""; // IP Address will be re-set by lookup on startup
|
||||
char DOMAIN_IP[100] = "192.168.1.47"; // IP Address will be re-set by lookup on startup
|
||||
const int DOMAINSERVER_PORT = 40102;
|
||||
|
||||
bool silentNodeThreadStopFlag = false;
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#include "AudioInjectionManager.h"
|
||||
|
||||
#include "NodeList.h"
|
||||
#include "NodeTypes.h"
|
||||
#include "PacketHeaders.h"
|
||||
|
@ -210,7 +212,8 @@ void Operative::run() {
|
|||
|
||||
// change the owner type on our NodeList
|
||||
NodeList::getInstance()->setOwnerType(NODE_TYPE_AGENT);
|
||||
NodeList::getInstance()->setNodeTypesOfInterest(&NODE_TYPE_VOXEL_SERVER, 1);
|
||||
const char NODE_TYPES_OF_INTEREST[] = {NODE_TYPE_VOXEL_SERVER, NODE_TYPE_AUDIO_MIXER};
|
||||
NodeList::getInstance()->setNodeTypesOfInterest(NODE_TYPES_OF_INTEREST, 2);
|
||||
NodeList::getInstance()->getNodeSocket()->setBlocking(false);
|
||||
|
||||
while (!shouldStop) {
|
||||
|
@ -218,6 +221,10 @@ void Operative::run() {
|
|||
|
||||
renderMovingBug();
|
||||
|
||||
if (!injector->isInjectingAudio()) {
|
||||
AudioInjectionManager::threadInjector(injector);
|
||||
}
|
||||
|
||||
// send a check in packet to the domain server if DOMAIN_SERVER_CHECK_IN_USECS has elapsed
|
||||
if (usecTimestampNow() - usecTimestamp(&lastDomainServerCheckIn) >= DOMAIN_SERVER_CHECK_IN_USECS) {
|
||||
gettimeofday(&lastDomainServerCheckIn, NULL);
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#ifndef __hifi__Operative__
|
||||
#define __hifi__Operative__
|
||||
|
||||
#import "AudioInjector.h"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
|
@ -17,6 +19,8 @@ public:
|
|||
Operative();
|
||||
|
||||
bool volatile shouldStop;
|
||||
AudioInjector* injector;
|
||||
|
||||
void run();
|
||||
private:
|
||||
void renderMovingBug();
|
||||
|
|
Loading…
Reference in a new issue