Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mediastreamer2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
External Wiki
External Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BC
public
mediastreamer2
Commits
8282f57f
Commit
8282f57f
authored
Mar 21, 2011
by
Simon Morlat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start porting audio unit filter to mac
parent
6f0c042a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
4 deletions
+33
-4
msiounit.c
src/msiounit.c
+33
-4
No files found.
src/msiounit.c
View file @
8282f57f
...
...
@@ -128,6 +128,9 @@ static MSSndCard *au_duplicate(MSSndCard *obj){
}
#define check_auresult(au,method) \
if (au!=0) ms_error("AudioUnit error for %s: ret=%i",method,au)
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
static
void
au_interuption_listener
(
void
*
inClientData
,
UInt32
inInterruptionState
)
{
if
(((
MSSndCard
*
)
inClientData
)
->
data
==
NULL
)
return
;
...
...
@@ -153,21 +156,31 @@ static void au_interuption_listener(void* inClientData, UInt32 inInterruptionSta
}
}
#endif
static
MSSndCard
*
au_card_new
(
const
char
*
name
){
MSSndCard
*
card
=
ms_snd_card_new_with_name
(
&
au_card_desc
,
name
);
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
OSStatus
auresult
=
AudioSessionInitialize
(
NULL
,
NULL
,
au_interuption_listener
,
card
);
if
(
auresult
!=
kAudioSessionAlreadyInitialized
)
{
check_auresult
(
auresult
,
"AudioSessionInitialize"
);
}
#endif
return
card
;
}
static
void
au_detect
(
MSSndCardManager
*
m
){
MSSndCard
*
card
;
ms_debug
(
"au_detect"
);
MSSndCard
*
card
=
au_card_new
(
AU_CARD_RECEIVER
);
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
card
=
au_card_new
(
AU_CARD_RECEIVER
);
ms_snd_card_manager_add_card
(
m
,
card
);
card
=
au_card_new
(
AU_CARD_SPEAKER
);
ms_snd_card_manager_add_card
(
m
,
card
);
#else
card
=
au_card_new
(
"Audio Unit"
);
#endif
ms_snd_card_manager_add_card
(
m
,
card
);
}
static
OSStatus
au_read_cb
(
...
...
@@ -263,7 +276,7 @@ static void au_configure(AUData *d) {
UInt32
doNotSetProperty
=
0
;
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
auresult
=
AudioSessionSetActive
(
true
);
check_auresult
(
auresult
,
"AudioSessionSetActive"
);
...
...
@@ -280,13 +293,19 @@ static void au_configure(AUData *d) {
}
else
{
ms_message
(
"Configuring audio session default route to receiver"
);
}
#endif
if
(
d
->
started
==
TRUE
)
{
//nothing else to do
return
;
}
au_description
.
componentType
=
kAudioUnitType_Output
;
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
au_description
.
componentSubType
=
kAudioUnitSubType_VoiceProcessingIO
;
#else
au_description
.
componentSubType
=
kAudioUnitSubType_HALOutput
;
#endif
au_description
.
componentManufacturer
=
kAudioUnitManufacturer_Apple
;
au_description
.
componentFlags
=
0
;
au_description
.
componentFlagsMask
=
0
;
...
...
@@ -382,6 +401,7 @@ static void au_configure(AUData *d) {
);
check_auresult
(
auresult
,
"kAudioUnitProperty_SetRenderCallback,kAudioUnitScope_Input"
);
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
const
Float64
preferredSampleRate
=
d
->
rate
;
//PREFERRED_HW_SAMPLE_RATE; /*optimum to minimize delay, must put a software resampler to deal with 8khz*/
auresult
=
AudioSessionSetProperty
(
kAudioSessionProperty_PreferredHardwareSampleRate
...
...
@@ -406,6 +426,7 @@ static void au_configure(AUData *d) {
if
(
auresult
!=
0
)
ms_message
(
"kAudioSessionProperty_PreferredHardwareIOBufferDuration returns %i "
,
auresult
);
#endif
Float64
delay
;
UInt32
delaySize
=
sizeof
(
delay
);
...
...
@@ -428,6 +449,8 @@ static void au_configure(AUData *d) {
ms_message
(
"I/O unit latency [%f], quality [%i]"
,
delay
,
quality
);
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
Float32
hwoutputlatency
;
UInt32
hwoutputlatencySize
=
sizeof
(
hwoutputlatency
);
auresult
=
AudioSessionGetProperty
(
kAudioSessionProperty_CurrentHardwareOutputLatency
...
...
@@ -452,6 +475,11 @@ static void au_configure(AUData *d) {
,
&
hwsamplerate
);
ms_message
(
"current hw output latency [%f] input [%f] iobuf[%f] sample rate [%f]"
,
hwoutputlatency
,
hwinputlatency
,
hwiobuf
,
hwsamplerate
);
#else
auresult
=
AudioUnitInitialize
(
d
->
io_unit
);
check_auresult
(
auresult
,
"AudioUnitInitialize"
);
#endif
auresult
=
AudioOutputUnitStart
(
d
->
io_unit
);
check_auresult
(
auresult
,
"AudioOutputUnitStart"
);
d
->
started
=
TRUE
;
...
...
@@ -666,4 +694,5 @@ void ms_au_register_card() {
* register audio unit plugin should be move to linphone code
*/
ms_snd_card_manager_register_desc
(
ms_snd_card_manager_get
(),
&
au_card_desc
);
}
}
Write
Preview
Markdown
is supported
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