Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
mediastreamer2
Commits
6711f8cf
Commit
6711f8cf
authored
Oct 11, 2012
by
Simon Morlat
Committed by
Ghislain MARY
Oct 15, 2012
Browse files
cleanups and code improvements
parent
7582931b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
7 deletions
+52
-7
src/android/AudioRecord.cpp
src/android/AudioRecord.cpp
+11
-1
src/android/AudioTrack.cpp
src/android/AudioTrack.cpp
+9
-1
src/android/androidsound.cpp
src/android/androidsound.cpp
+32
-5
No files found.
src/android/AudioRecord.cpp
View file @
6711f8cf
...
...
@@ -57,7 +57,14 @@ status_t AudioRecord::getMinFrameCount(int* frameCount,
audio_format_t
format
,
int
channelCount
)
{
return
AudioRecordImpl
::
get
()
->
mGetMinFrameCount
.
invoke
(
frameCount
,
sampleRate
,
format
,
channelCount
);
if
(
AudioRecordImpl
::
get
()
->
mGetMinFrameCount
.
isFound
()){
return
AudioRecordImpl
::
get
()
->
mGetMinFrameCount
.
invoke
(
frameCount
,
sampleRate
,
format
,
channelCount
);
}
else
{
//this method didn't existed in 2.2
//Use hardcoded values instead (1024 frames at 8khz)
*
frameCount
=
(
1024
*
channelCount
*
sampleRate
)
/
8000
;
return
0
;
}
}
audio_io_handle_t
AudioRecord
::
getInput
()
const
{
...
...
@@ -94,6 +101,9 @@ AudioRecordImpl::AudioRecordImpl(Library *lib) :
mGetMinFrameCount
(
lib
,
"_ZN7android11AudioRecord16getMinFrameCountEPijii"
)
//mGetInput(lib,"_ZN7android11AudioRecord8getInputEv")
{
//Android 2.2 symbol:
if
(
!
mCtor
.
isFound
())
mCtor
.
load
(
lib
,
"_ZN7android11AudioRecordC1EijijijPFviPvS1_ES1_i"
);
}
...
...
src/android/AudioTrack.cpp
View file @
6711f8cf
...
...
@@ -56,7 +56,14 @@ namespace fake_android{
status_t
AudioTrack
::
getMinFrameCount
(
int
*
frameCount
,
audio_stream_type_t
streamType
,
uint32_t
sampleRate
){
return
AudioTrackImpl
::
get
()
->
mGetMinFrameCount
.
invoke
(
frameCount
,
streamType
,
sampleRate
);
if
(
AudioTrackImpl
::
get
()
->
mGetMinFrameCount
.
isFound
()){
return
AudioTrackImpl
::
get
()
->
mGetMinFrameCount
.
invoke
(
frameCount
,
streamType
,
sampleRate
);
}
else
{
//this method didn't existed in 2.2
//Use hardcoded values instead (1024 frames at 8khz)
*
frameCount
=
(
1024
*
sampleRate
)
/
8000
;
return
0
;
}
}
uint32_t
AudioTrack
::
latency
()
const
{
...
...
@@ -79,6 +86,7 @@ namespace fake_android{
mLatency
(
lib
,
"_ZNK7android10AudioTrack7latencyEv"
),
mGetPosition
(
lib
,
"_ZN7android10AudioTrack11getPositionEPj"
)
{
}
bool
AudioTrackImpl
::
init
(
Library
*
lib
){
...
...
src/android/androidsound.cpp
View file @
6711f8cf
/*
* androidsound.cpp -Android Media plugin for Linphone, based on C++ sound apis.
*
*
* Copyright (C) 2009 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <mediastreamer2/msfilter.h>
#include <mediastreamer2/msticker.h>
#include <mediastreamer2/mssndcard.h>
...
...
@@ -16,8 +37,8 @@ static const float audio_buf_ms=0.01;
static
MSSndCard
*
android_snd_card_new
(
void
);
static
MSFilter
*
ms_android_snd_read_new
(
void
);
static
MSFilter
*
ms_android_snd_write_new
(
void
);
static
Library
*
libmedia
;
static
Library
*
libutils
;
static
Library
*
libmedia
=
0
;
static
Library
*
libutils
=
0
;
static
int
std_sample_rates
[]
=
{
48000
,
44100
,
32000
,
22050
,
16000
,
8000
,
-
1
...
...
@@ -169,10 +190,15 @@ static MSFilter *android_snd_card_create_writer(MSSndCard *card){
}
static
void
android_snd_card_detect
(
MSSndCardManager
*
m
){
libmedia
=
Library
::
load
(
"/system/lib/libmedia.so"
);
libutils
=
Library
::
load
(
"/system/lib/libutils.so"
);
if
(
!
libmedia
)
libmedia
=
Library
::
load
(
"/system/lib/libmedia.so"
);
if
(
!
libutils
)
libutils
=
Library
::
load
(
"/system/lib/libutils.so"
);
if
(
libmedia
&&
libutils
){
if
(
AudioRecordImpl
::
init
(
libmedia
)
&&
AudioTrackImpl
::
init
(
libmedia
)
&&
AudioSystemImpl
::
init
(
libmedia
)
&&
String8Impl
::
init
(
libutils
)){
/*perform initializations in order rather than in a if statement so that all missing symbols are shown in logs*/
bool
audio_record_loaded
=
AudioRecordImpl
::
init
(
libmedia
);
bool
audio_track_loaded
=
AudioTrackImpl
::
init
(
libmedia
);
bool
audio_system_loaded
=
AudioSystemImpl
::
init
(
libmedia
);
bool
string8_loaded
=
String8Impl
::
init
(
libutils
);
if
(
audio_record_loaded
&&
audio_track_loaded
&&
audio_system_loaded
&&
string8_loaded
){
ms_message
(
"Native android sound support available."
);
MSSndCard
*
card
=
android_snd_card_new
();
ms_snd_card_manager_add_card
(
m
,
card
);
...
...
@@ -184,6 +210,7 @@ static void android_snd_card_detect(MSSndCardManager *m){
}
static
void
android_native_snd_card_uninit
(
MSSndCard
*
card
){
delete
static_cast
<
AndroidNativeSndCardData
*>
(
card
->
data
);
}
...
...
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