Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Technical Acoustics (ITA)
VACore
Commits
8b278934
Commit
8b278934
authored
May 15, 2017
by
Dipl.-Ing. Jonas Stienen
Browse files
Adding missing audio signal source manager methods (not implemented yet)
parent
03345c67
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Audiosignals/VAAudioSignalSourceManager.cpp
View file @
8b278934
...
...
@@ -11,6 +11,7 @@
#include "VASequencerSignalSource.h"
#include "VAEngineSignalSource.h"
#include "VAMachineSignalSource.h"
//#include "VATextToSpeechSignalSource.h"
#include <ITAException.h>
#include <ITAStringUtils.h>
...
...
@@ -22,27 +23,27 @@
#include <sstream>
CVAAudioSignalSourceManager
::
CVAAudioSignalSourceManager
(
CVACoreImpl
*
pParentCore
,
const
CVAAudioDriverConfig
&
oAudioDriverConfig
,
ITADatasource
*
pDeviceInputSource
)
:
m_pParentCore
(
pParentCore
),
m_dSamplerate
(
oAudioDriverConfig
.
dSampleRate
),
m_iBlocklength
(
oAudioDriverConfig
.
iBuffersize
),
m_iDeviceInputs
(
oAudioDriverConfig
.
iInputChannels
),
m_pDeviceInputSource
(
pDeviceInputSource
),
m_vsbDeviceInputBuffers
(
oAudioDriverConfig
.
iInputChannels
),
m_evStreamCounterInc
(
VistaThreadEvent
::
NON_WAITABLE_EVENT
),
m_iStreamCounter
(
0
)
CVAAudioSignalSourceManager
::
CVAAudioSignalSourceManager
(
CVACoreImpl
*
pParentCore
,
const
CVAAudioDriverConfig
&
oAudioDriverConfig
,
ITADatasource
*
pDeviceInputSource
)
:
m_pParentCore
(
pParentCore
),
m_dSamplerate
(
oAudioDriverConfig
.
dSampleRate
),
m_iBlocklength
(
oAudioDriverConfig
.
iBuffersize
),
m_iDeviceInputs
(
oAudioDriverConfig
.
iInputChannels
),
m_pDeviceInputSource
(
pDeviceInputSource
),
m_vsbDeviceInputBuffers
(
oAudioDriverConfig
.
iInputChannels
),
m_evStreamCounterInc
(
VistaThreadEvent
::
NON_WAITABLE_EVENT
),
m_iStreamCounter
(
0
)
{
m_sbSilence
.
Init
(
oAudioDriverConfig
.
iBuffersize
,
true
);
// Puffer und Signalquellen fr Audio-Eingnge anlegen
for
(
int
i
=
0
;
i
<
oAudioDriverConfig
.
iInputChannels
;
i
++
)
{
m_vsbDeviceInputBuffers
[
i
].
Init
(
oAudioDriverConfig
.
iBuffersize
,
false
);
for
(
int
i
=
0
;
i
<
oAudioDriverConfig
.
iInputChannels
;
i
++
)
{
m_vsbDeviceInputBuffers
[
i
].
Init
(
oAudioDriverConfig
.
iBuffersize
,
false
);
std
::
stringstream
ss
;
ss
<<
"Audio device input "
<<
(
i
+
1
);
IVAAudioSignalSource
*
pSource
=
new
CVADeviceInputSignalSource
(
&
m_vsbDeviceInputBuffers
[
i
],
ss
.
str
());
m_vsDeviceInputSourceIDs
.
push_back
(
RegisterSignalSource
(
pSource
,
ss
.
str
(),
true
,
false
)
);
ss
<<
"Audio device input "
<<
(
i
+
1
);
IVAAudioSignalSource
*
pSource
=
new
CVADeviceInputSignalSource
(
&
m_vsbDeviceInputBuffers
[
i
],
ss
.
str
()
);
m_vsDeviceInputSourceIDs
.
push_back
(
RegisterSignalSource
(
pSource
,
ss
.
str
(),
true
,
false
)
);
}
}
...
...
@@ -58,7 +59,7 @@ void CVAAudioSignalSourceManager::Reset() {
std
::
vector
<
IVAAudioSignalSource
*
>
vpDelayedRemoveList
;
// Alle gemanageten Quellen freigeben
for
(
RecordMapIt
it
=
m_mRecords
.
begin
();
it
!=
m_mRecords
.
end
();
)
for
(
RecordMapIt
it
=
m_mRecords
.
begin
();
it
!=
m_mRecords
.
end
();
)
{
// Forced reference count reset - OK here
it
->
second
.
iRefCount
=
0
;
...
...
@@ -89,7 +90,7 @@ void CVAAudioSignalSourceManager::Reset() {
SyncSignalSources
();
// Falls kein Streaming luft. Direkt die Queue leeren.
if
(
!
m_pParentCore
->
IsStreaming
()
)
if
(
!
m_pParentCore
->
IsStreaming
()
)
m_qpDelReqSources
.
clear
();
if
(
bFirstWaitTimeout
==
false
)
...
...
@@ -101,8 +102,8 @@ void CVAAudioSignalSourceManager::Reset() {
}
// Now delete signal source
for
(
size_t
i
=
0
;
i
<
vpDelayedRemoveList
.
size
();
i
++
)
delete
vpDelayedRemoveList
[
i
];
for
(
size_t
i
=
0
;
i
<
vpDelayedRemoveList
.
size
();
i
++
)
delete
vpDelayedRemoveList
[
i
];
m_mMnemonicCount
.
clear
();
...
...
@@ -121,7 +122,7 @@ std::string CVAAudioSignalSourceManager::RegisterSignalSource( IVAAudioSignalSou
if
(
FindSignalSource
(
pSource
)
!=
m_mRecords
.
end
()
)
{
m_csRecords
.
leave
();
ITA_EXCEPT1
(
INVALID_PARAMETER
,
"Audio signal source already contained"
);
ITA_EXCEPT1
(
INVALID_PARAMETER
,
"Audio signal source already contained"
);
}
// Neue ID (Mnemonic + Zahl) generieren
...
...
@@ -129,7 +130,7 @@ std::string CVAAudioSignalSourceManager::RegisterSignalSource( IVAAudioSignalSou
std
::
string
sMnemonic
=
toLowercase
(
pSource
->
GetTypeString
()
);
//std::string sMnemonic = "ss";
int
iNumber
;
std
::
map
<
std
::
string
,
int
>::
iterator
it
=
m_mMnemonicCount
.
find
(
sMnemonic
);
std
::
map
<
std
::
string
,
int
>::
iterator
it
=
m_mMnemonicCount
.
find
(
sMnemonic
);
if
(
it
==
m_mMnemonicCount
.
end
()
)
{
// Es wurde noch keine Quelle mit diesem Mnemonic hinzugefgt -> Zhler initialisieren
...
...
@@ -139,9 +140,9 @@ std::string CVAAudioSignalSourceManager::RegisterSignalSource( IVAAudioSignalSou
else
{
// Es wurden schon Quellen mit diesem Mnemonic hinzugefgt -> Zhler inkrementieren
iNumber
=
++
(
it
->
second
);
iNumber
=
++
(
it
->
second
);
}
std
::
string
sID
=
sMnemonic
+
IntToString
(
iNumber
);
std
::
string
sID
=
sMnemonic
+
IntToString
(
iNumber
);
// Quelle hinzufgen
RecordMapIt
jt
=
m_mRecords
.
insert
(
m_mRecords
.
begin
(),
RecordItem
(
sID
,
CAudioSignalSourceRecord
(
pSource
,
sName
,
m_iBlocklength
,
bManaged
,
bDynamic
)
)
);
...
...
@@ -149,10 +150,10 @@ std::string CVAAudioSignalSourceManager::RegisterSignalSource( IVAAudioSignalSou
m_csRecords
.
leave
();
// Quelle dem Audio-Streaming bergeben
m_qpNewSources
.
push
(
&
(
jt
->
second
)
);
m_qpNewSources
.
push
(
&
(
jt
->
second
)
);
// Quelle ber Registrierung informieren
pSource
->
HandleRegistration
(
m_pParentCore
);
pSource
->
HandleRegistration
(
m_pParentCore
);
return
sID
;
}
...
...
@@ -217,14 +218,24 @@ std::string CVAAudioSignalSourceManager::GetAudioDeviceInputSignalSource( int iI
return
m_vsDeviceInputSourceIDs
[
iInput
];
}
std
::
string
CVAAudioSignalSourceManager
::
CreateAudiofileSignalSource
(
const
std
::
string
&
sFilename
,
const
std
::
string
&
sName
)
std
::
string
CVAAudioSignalSourceManager
::
CreateAudiofileSignalSource
(
const
std
::
string
&
sFilename
,
const
std
::
string
&
sName
)
{
//
Datei-Quel
le
n
si
nd immer managed und dynamisch
//
Fi
le si
gnals are always dynamic and managed
CVAAudiofileSignalSource
*
pSource
=
new
CVAAudiofileSignalSource
(
sFilename
,
m_dSamplerate
,
m_iBlocklength
);
return
RegisterSignalSource
(
pSource
,
sName
,
true
,
true
);
return
RegisterSignalSource
(
pSource
,
sName
,
true
,
true
);
}
std
::
string
CVAAudioSignalSourceManager
::
CreateSequencerSignalSource
(
const
std
::
string
&
sName
)
std
::
string
CVAAudioSignalSourceManager
::
CreateTextToSpeechSignalSource
(
const
std
::
string
&
sName
)
{
VA_EXCEPT2
(
NOT_IMPLEMENTED
,
"TTS signal sources are not implemented yet, rejected to create source ''"
+
sName
+
"'"
);
/*
// TTS signals are always dynamic and managed
CVATextToSpeechSignalSource* pSource = new CVATextToSpeechSignalSource( m_dSamplerate, m_iBlocklength );
return RegisterSignalSource( pSource, sName, true, true );
*/
}
std
::
string
CVAAudioSignalSourceManager
::
CreateSequencerSignalSource
(
const
std
::
string
&
sName
)
{
// Sampler-Quellen sind immer managed und dynamisch
CVASequencerSignalSource
*
pSource
=
new
CVASequencerSignalSource
(
m_dSamplerate
,
m_iBlocklength
,
m_pParentCore
->
GetSamplePool
()
);
...
...
@@ -243,17 +254,17 @@ std::string CVAAudioSignalSourceManager::CreateEngineSignalSource( const std::st
// Engine-quellen sind immer managed und dynamisch
CVAEngineSignalSource
::
Config
oESSConfig
;
oESSConfig
.
pCore
=
m_pParentCore
;
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
153
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
27
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
277
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
32
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
301
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
23
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
458
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
24
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
584
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
4
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
922
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
29
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
1152
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
30
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
1552
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
14
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
2382
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
27
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
2883
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
18
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
3472
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
16
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
153
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
27
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
277
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
32
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
301
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
23
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
458
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
24
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
584
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
4
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
922
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
29
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
1152
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
30
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
1552
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
14
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
2382
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
27
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
2883
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
18
/
10
)
)
);
oESSConfig
.
lFreqModesSpectrum
.
insert
(
std
::
pair
<
double
,
double
>
(
3472
/
13.4
f
,
0.1
*
std
::
pow
(
10
,
-
16
/
10
)
)
);
CVAEngineSignalSource
*
pSource
=
new
CVAEngineSignalSource
(
oESSConfig
);
return
RegisterSignalSource
(
pSource
,
sName
,
true
,
true
);
}
...
...
@@ -271,7 +282,7 @@ void CVAAudioSignalSourceManager::DeleteSignalSource( const std::string& sID )
m_csRecords
.
enter
();
RecordMapIt
it
=
FindSignalSource
(
sID
);
if
(
it
==
m_mRecords
.
end
()
)
{
m_csRecords
.
leave
();
...
...
@@ -300,14 +311,14 @@ void CVAAudioSignalSourceManager::DeleteSignalSource( const std::string& sID )
}
// Audio-Stream das Lschen der Quelle melden
m_qpDelReqSources
.
push
(
&
(
it
->
second
)
);
m_qpDelReqSources
.
push
(
&
(
it
->
second
)
);
// Warten bis der Lschauftrag abgearbeitet wurden
while
(
!
m_qpDelReqSources
.
empty
())
SyncSignalSources
();
while
(
!
m_qpDelReqSources
.
empty
()
)
SyncSignalSources
();
// Quelle ber deregistrierung informieren
it
->
second
.
pSource
->
HandleUnregistration
(
m_pParentCore
);
// Quelle freigeben
delete
it
->
second
.
pSource
;
m_mRecords
.
erase
(
it
);
...
...
@@ -320,7 +331,7 @@ CVASignalSourceInfo CVAAudioSignalSourceManager::GetSignalSourceInfo( const std:
m_csRecords
.
enter
();
RecordMapCit
it
=
FindSignalSource
(
sID
);
if
(
it
==
m_mRecords
.
end
()
)
{
m_csRecords
.
leave
();
...
...
@@ -342,85 +353,85 @@ void CVAAudioSignalSourceManager::GetSignalSourceInfos( std::vector<CVASignalSou
// Alphabetisch sortierte Liste der IDs erzeugen
std
::
vector
<
std
::
string
>
vsIDs
;
for
(
RecordMapCit
cit
=
m_mRecords
.
begin
();
cit
!=
m_mRecords
.
end
();
++
cit
)
for
(
RecordMapCit
cit
=
m_mRecords
.
begin
();
cit
!=
m_mRecords
.
end
();
++
cit
)
vsIDs
.
push_back
(
cit
->
first
);
std
::
sort
(
vsIDs
.
begin
(),
vsIDs
.
end
()
);
std
::
sort
(
vsIDs
.
begin
(),
vsIDs
.
end
()
);
// Informationen zusammenstellen
vssiDest
.
clear
();
for
(
std
::
vector
<
std
::
string
>::
const_iterator
cit
=
vsIDs
.
begin
();
cit
!=
vsIDs
.
end
();
++
cit
)
for
(
std
::
vector
<
std
::
string
>::
const_iterator
cit
=
vsIDs
.
begin
();
cit
!=
vsIDs
.
end
();
++
cit
)
{
RecordMapCit
cit2
=
m_mRecords
.
find
(
*
cit
);
IVAAudioSignalSource
*
pSource
=
cit2
->
second
.
pSource
;
vssiDest
.
push_back
(
CVASignalSourceInfo
(
*
cit
,
pSource
->
GetTypeString
(),
cit2
->
second
.
sName
,
pSource
->
GetDesc
(),
pSource
->
GetStateString
(),
cit2
->
second
.
iRefCount
)
);
pSource
->
GetTypeString
(),
cit2
->
second
.
sName
,
pSource
->
GetDesc
(),
pSource
->
GetStateString
(),
cit2
->
second
.
iRefCount
)
);
}
m_csRecords
.
leave
();
}
std
::
string
CVAAudioSignalSourceManager
::
GetSignalSourceID
(
IVAAudioSignalSource
*
pSource
)
const
{
std
::
string
CVAAudioSignalSourceManager
::
GetSignalSourceID
(
IVAAudioSignalSource
*
pSource
)
const
{
m_csRecords
.
enter
();
for
(
RecordMapCit
cit
=
m_mRecords
.
begin
();
cit
!=
m_mRecords
.
end
();
++
cit
)
if
(
cit
->
second
.
pSource
==
pSource
)
{
m_csRecords
.
leave
();
return
cit
->
first
;
for
(
RecordMapCit
cit
=
m_mRecords
.
begin
();
cit
!=
m_mRecords
.
end
();
++
cit
)
if
(
cit
->
second
.
pSource
==
pSource
)
{
m_csRecords
.
leave
();
return
cit
->
first
;
}
m_csRecords
.
leave
();
// Methode wird extern benutzt. Exception falls nicht gefunden.
VA_EXCEPT2
(
INVALID_PARAMETER
,
"Invalid signal source ID"
);
VA_EXCEPT2
(
INVALID_PARAMETER
,
"Invalid signal source ID"
);
}
CVAAudioSignalSourceManager
::
RecordMapIt
CVAAudioSignalSourceManager
::
FindSignalSource
(
const
std
::
string
&
sID
)
CVAAudioSignalSourceManager
::
RecordMapIt
CVAAudioSignalSourceManager
::
FindSignalSource
(
const
std
::
string
&
sID
)
{
return
m_mRecords
.
find
(
toLowercase
(
sID
)
);
return
m_mRecords
.
find
(
toLowercase
(
sID
)
);
}
CVAAudioSignalSourceManager
::
RecordMapCit
CVAAudioSignalSourceManager
::
FindSignalSource
(
const
std
::
string
&
sID
)
const
CVAAudioSignalSourceManager
::
RecordMapCit
CVAAudioSignalSourceManager
::
FindSignalSource
(
const
std
::
string
&
sID
)
const
{
return
m_mRecords
.
find
(
toLowercase
(
sID
)
);
return
m_mRecords
.
find
(
toLowercase
(
sID
)
);
}
CVAAudioSignalSourceManager
::
RecordMapIt
CVAAudioSignalSourceManager
::
FindSignalSource
(
IVAAudioSignalSource
*
pSource
)
CVAAudioSignalSourceManager
::
RecordMapIt
CVAAudioSignalSourceManager
::
FindSignalSource
(
IVAAudioSignalSource
*
pSource
)
{
for
(
RecordMapIt
it
=
m_mRecords
.
begin
();
it
!=
m_mRecords
.
end
();
++
it
)
if
(
it
->
second
.
pSource
==
pSource
)
for
(
RecordMapIt
it
=
m_mRecords
.
begin
();
it
!=
m_mRecords
.
end
();
++
it
)
if
(
it
->
second
.
pSource
==
pSource
)
return
it
;
return
m_mRecords
.
end
();
}
IVAAudioSignalSource
*
CVAAudioSignalSourceManager
::
RequestSignalSource
(
const
std
::
string
&
sID
,
const
ITASampleBuffer
**
ppsbInputBuf
)
{
IVAAudioSignalSource
*
CVAAudioSignalSourceManager
::
RequestSignalSource
(
const
std
::
string
&
sID
,
const
ITASampleBuffer
**
ppsbInputBuf
)
{
m_csRecords
.
enter
();
RecordMapIt
it
=
m_mRecords
.
find
(
sID
);
RecordMapIt
it
=
m_mRecords
.
find
(
sID
);
// Wird von externen Methoden benutzt. Deshalb Exception.
if
(
it
==
m_mRecords
.
end
())
{
if
(
it
==
m_mRecords
.
end
()
)
{
m_csRecords
.
leave
();
VA_EXCEPT2
(
INVALID_PARAMETER
,
"Invalid signal source ID"
);
VA_EXCEPT2
(
INVALID_PARAMETER
,
"Invalid signal source ID"
);
}
it
->
second
.
iRefCount
++
;
IVAAudioSignalSource
*
pResult
=
it
->
second
.
pSource
;
ITASampleBuffer
*
psbInputBuffer
=
&
(
it
->
second
.
sbSampleBuffer
);
if
(
ppsbInputBuf
)
*
ppsbInputBuf
=
psbInputBuffer
;
ITASampleBuffer
*
psbInputBuffer
=
&
(
it
->
second
.
sbSampleBuffer
);
if
(
ppsbInputBuf
)
*
ppsbInputBuf
=
psbInputBuffer
;
m_csRecords
.
leave
();
return
pResult
;
}
void
CVAAudioSignalSourceManager
::
ReleaseSignalSource
(
IVAAudioSignalSource
*
pSource
)
{
RecordMapIt
it
=
FindSignalSource
(
pSource
);
void
CVAAudioSignalSourceManager
::
ReleaseSignalSource
(
IVAAudioSignalSource
*
pSource
)
{
RecordMapIt
it
=
FindSignalSource
(
pSource
);
// Ungltiger Zeiger (weil nicht registriert)
assert
(
it
!=
m_mRecords
.
end
());
assert
(
it
!=
m_mRecords
.
end
()
);
it
->
second
.
iRefCount
--
;
}
...
...
@@ -430,10 +441,10 @@ void CVAAudioSignalSourceManager::SyncSignalSources() {
// das alle nderung an den Signalquellen im Audio-Stream Kontext abgearbeitet wurden.
// Falls Streaming nicht im Gange => Nicht warten
if
(
!
m_pParentCore
->
IsStreaming
())
return
;
if
(
!
m_pParentCore
->
IsStreaming
()
)
return
;
// Keine Ketten => Nicht warten (sonst Deadlock)
if
(
m_mRecords
.
empty
())
return
;
if
(
m_mRecords
.
empty
()
)
return
;
// Aktuellen Stream-Counter ermitteln
int
iEntryCount
=
m_iStreamCounter
;
...
...
@@ -461,9 +472,9 @@ void CVAAudioSignalSourceManager::FetchInputData( const CVAAudiostreamState* pSt
CAudioSignalSourceRecord
*
pRecord
;
// Interne Liste aktualisieren
while
(
m_qpNewSources
.
try_pop
(
pRecord
)
)
while
(
m_qpNewSources
.
try_pop
(
pRecord
)
)
{
m_spIntSources
.
insert
(
pRecord
);
m_spIntSources
.
insert
(
pRecord
);
}
while
(
m_qpDelReqSources
.
try_pop
(
pRecord
)
)
...
...
@@ -474,14 +485,14 @@ void CVAAudioSignalSourceManager::FetchInputData( const CVAAudiostreamState* pSt
// Zunchst die Samples aller Audio-Eingnge vom Backend beziehen
if
(
m_pDeviceInputSource
)
{
for
(
int
i
=
0
;
i
<
m_iDeviceInputs
;
i
++
)
{
for
(
int
i
=
0
;
i
<
m_iDeviceInputs
;
i
++
)
{
// [fwe] Dieser Cast ist in Ordnung. VACore-intern wird immer CVAAudioStreamStateImpl weitergeleitet
const
float
*
pfInputData
=
m_pDeviceInputSource
->
GetBlockPointer
(
i
,
dynamic_cast
<
const
CVAAudiostreamStateImpl
*>
(
pStreamInfo
)
);
const
float
*
pfInputData
=
m_pDeviceInputSource
->
GetBlockPointer
(
i
,
dynamic_cast
<
const
CVAAudiostreamStateImpl
*
>
(
pStreamInfo
)
);
if
(
pfInputData
)
m_vsbDeviceInputBuffers
[
i
].
write
(
pfInputData
,
m_iBlocklength
);
if
(
pfInputData
)
m_vsbDeviceInputBuffers
[
i
].
write
(
pfInputData
,
m_iBlocklength
);
else
m_vsbDeviceInputBuffers
[
i
].
Zero
();
m_vsbDeviceInputBuffers
[
i
].
Zero
();
}
m_pDeviceInputSource
->
IncrementBlockPointer
();
}
...
...
@@ -490,13 +501,14 @@ void CVAAudioSignalSourceManager::FetchInputData( const CVAAudiostreamState* pSt
// Wichtig: Zwei Phasen! 1. GetBlockPointer auf allen Quellen, 2. danach erst IncrementBlockPointer
for
(
std
::
set
<
CAudioSignalSourceRecord
*>::
iterator
it
=
m_spIntSources
.
begin
();
it
!=
m_spIntSources
.
end
();
++
it
)
{
const
float
*
pfInputData
=
(
*
it
)
->
pSource
->
GetStreamBlock
(
pStreamInfo
);
const
float
*
pfInputData
=
(
*
it
)
->
pSource
->
GetStreamBlock
(
pStreamInfo
);
//DEBUG_PRINTF("Ptr = 0x%08Xh\n", pfInputData);
if
(
pfInputData
)
{
(
*
it
)
->
sbSampleBuffer
.
write
(
pfInputData
,
m_iBlocklength
);
}
else
{
(
*
it
)
->
sbSampleBuffer
.
Zero
();
if
(
pfInputData
)
{
(
*
it
)
->
sbSampleBuffer
.
write
(
pfInputData
,
m_iBlocklength
);
}
else
{
(
*
it
)
->
sbSampleBuffer
.
Zero
();
}
}
...
...
src/Audiosignals/VAAudioSignalSourceManager.h
View file @
8b278934
...
...
@@ -30,19 +30,18 @@ class CVACoreImpl;
- Diesen Signalquellen weit er auch ihre IDs zu
- Manche Signalquellen werden nicht vom Manager besessen (z.B. die vom Audiogert)
- Es gibt dynamische und statische Signalquellen:
- Eingnge vom Audiogert sind immer statisch (werden beim Start automatisch erzeugt und knnen nie entfernt werden)
- Alle anderen sind dynamisch: Sie knnen beliebig zur Laufzeit erzeugt und entfernt werden
- Eingnge vom Audiogert sind immer statisch (werden beim Start automatisch erzeugt und knnen nie entfernt werden)
- Alle anderen sind dynamisch: Sie knnen beliebig zur Laufzeit erzeugt und entfernt werden
- Warum Mnemonics (af001) => Weil einfacher anzusprechen
- Fetch Synchronisieren mit Register/Unreg.
*/
class
CVAAudioSignalSourceManager
{
class
CVAAudioSignalSourceManager
{
public:
CVAAudioSignalSourceManager
(
CVACoreImpl
*
pParentCore
,
const
CVAAudioDriverConfig
&
oAudioDriverConfig
,
ITADatasource
*
pDeviceInputSource
);
CVAAudioSignalSourceManager
(
CVACoreImpl
*
pParentCore
,
const
CVAAudioDriverConfig
&
oAudioDriverConfig
,
ITADatasource
*
pDeviceInputSource
);
virtual
~
CVAAudioSignalSourceManager
();
//! Alle Quellen entfernen
...
...
@@ -63,27 +62,27 @@ public:
*
* \return ID der hinzugefgten Quelle
*/
std
::
string
RegisterSignalSource
(
IVAAudioSignalSource
*
pSource
,
const
std
::
string
&
sName
,
bool
bManaged
,
bool
bDynamic
);
std
::
string
RegisterSignalSource
(
IVAAudioSignalSource
*
pSource
,
const
std
::
string
&
sName
,
bool
bManaged
,
bool
bDynamic
);
//! Deregistriert eine Audiosignalquelle, gibt diese aber nicht frei
/**
* Wichtig: Nur dynamische, ungemanagete Quellen knnen entfernt werden
*/
void
UnregisterSignalSource
(
const
std
::
string
&
sID
);
void
UnregisterSignalSource
(
const
std
::
string
&
sID
);
//! ID einer Gerte-Eingang-Signalquelle zurckgeben
std
::
string
GetAudioDeviceInputSignalSource
(
int
iInput
)
const
;
std
::
string
GetAudioDeviceInputSignalSource
(
int
iInput
)
const
;
//! Audiodatei-Signalquelle hinzufgen
std
::
string
CreateAudiofileSignalSource
(
const
std
::
string
&
sFilename
,
const
std
::
string
&
sName
);
std
::
string
CreateAudiofileSignalSource
(
const
std
::
string
&
sFilename
,
const
std
::
string
&
sName
);
std
::
string
CreateTextToSpeechSignalSource
(
const
std
::
string
&
sName
);
//! Sampler-Signalquelle hinzufgen
std
::
string
CreateSequencerSignalSource
(
const
std
::
string
&
sName
);
std
::
string
CreateSequencerSignalSource
(
const
std
::
string
&
sName
);
//! Netzwerkstream-Signalquelle hinzufgen
std
::
string
CreateNetstreamSignalSource
(
const
std
::
string
&
sBindAddress
,
int
iRecvPort
,
const
std
::
string
&
sName
);
std
::
string
CreateNetstreamSignalSource
(
const
std
::
string
&
sBindAddress
,
int
iRecvPort
,
const
std
::
string
&
sName
);
std
::
string
CreateEngineSignalSource
(
const
std
::
string
&
sName
);
...
...
@@ -93,14 +92,14 @@ public:
/**
* Wichtig: Nur dynamische, gemanagete Quellen knnen gelscht werden
*/
void
DeleteSignalSource
(
const
std
::
string
&
sID
);
void
DeleteSignalSource
(
const
std
::
string
&
sID
);
//! Datenquelle anfordern (fr Benutzung durch eine Schallquelle) und Referenzzhler erhhen
// Zustzlich wird der Puffer mit den Eingangsdaten der Quelle zurckgeben. Dies bleibt immer der selbe Zeiger!
IVAAudioSignalSource
*
RequestSignalSource
(
const
std
::
string
&
sID
,
const
ITASampleBuffer
**
ppsbInputBuf
=
nullptr
);
IVAAudioSignalSource
*
RequestSignalSource
(
const
std
::
string
&
sID
,
const
ITASampleBuffer
**
ppsbInputBuf
=
nullptr
);
//! Datenquelle freigeben (von Schallquelle) und deren Referenzzhler vermindern
void
ReleaseSignalSource
(
IVAAudioSignalSource
*
pSource
);
void
ReleaseSignalSource
(
IVAAudioSignalSource
*
pSource
);
//! Eingabensamples einer Datenquelle abrufen
//ITASampleBuffer* GetSignalSourceData(IVAAudioSignalSource* pSourc);
...
...
@@ -110,16 +109,16 @@ public:
* Hinweis: Diese Methode wird direkt aus dem Audio-Streaming-Kontrollfluss
* aufrufen.
*/
void
FetchInputData
(
const
CVAAudiostreamState
*
pStreamInfo
);
void
FetchInputData
(
const
CVAAudiostreamState
*
pStreamInfo
);
// Informationen zu einer Signalquelle zurckgeben
CVASignalSourceInfo
GetSignalSourceInfo
(
const
std
::
string
&
sSignalSourceID
)
const
;
CVASignalSourceInfo
GetSignalSourceInfo
(
const
std
::
string
&
sSignalSourceID
)
const
;
//! Lister aller (momentan) verfgbaren Signalquellen zurckgeben (Liste derer IDs)
void
GetSignalSourceInfos
(
std
::
vector
<
CVASignalSourceInfo
>&
vssiDest
)
const
;
void
GetSignalSourceInfos
(
std
::
vector
<
CVASignalSourceInfo
>&
vssiDest
)
const
;
//! ID zu einer Signalquellen-Instanz suchen
std
::
string
GetSignalSourceID
(
IVAAudioSignalSource
*
pSource
)
const
;
std
::
string
GetSignalSourceID
(
IVAAudioSignalSource
*
pSource
)
const
;
//! Stille zurckgeben
const
ITASampleBuffer
*
GetSilenceBuffer
()
const
;
...
...
@@ -146,7 +145,7 @@ private:
{};
};
typedef
std
::
map
<
std
::
string
,
CAudioSignalSourceRecord
>
RecordMap
;
typedef
std
::
map
<
std
::
string
,
CAudioSignalSourceRecord
>
RecordMap
;
typedef
std
::
pair
<
std
::
string
,
CAudioSignalSourceRecord
>
RecordItem
;
typedef
RecordMap
::
iterator
RecordMapIt
;
typedef
RecordMap
::
const_iterator
RecordMapCit
;
...
...
@@ -172,11 +171,11 @@ private:
VistaThreadEvent
m_evStreamCounterInc
;
//!< Event: Stream counter incremented
// Record anhand der ID suchen
RecordMapIt
FindSignalSource
(
const
std
::
string
&
sID
);
RecordMapCit
FindSignalSource
(
const
std
::
string
&
sID
)
const
;
RecordMapIt
FindSignalSource
(
const
std
::
string
&
sID
);
RecordMapCit
FindSignalSource
(
const
std
::
string
&
sID
)
const
;
// Record anhand des Instanzzeigers suchen
RecordMapIt
FindSignalSource
(
IVAAudioSignalSource
*
pSource
);
RecordMapIt
FindSignalSource
(
IVAAudioSignalSource
*
pSource
);
//! Warten bis im Streaming-Kontext die nderung an den Signalquellen bernommen wurde [blocking]
void
SyncSignalSources
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment