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