Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
38e8d709
Commit
38e8d709
authored
16 years ago
by
Emmanuel Milou
Browse files
Options
Downloads
Patches
Plain Diff
remove async_pcm_handler; replaced by an extra thread
parent
d7195d17
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/audio/alsalayer.cpp
+36
-3
36 additions, 3 deletions
src/audio/alsalayer.cpp
src/audio/alsalayer.h
+12
-7
12 additions, 7 deletions
src/audio/alsalayer.h
with
48 additions
and
10 deletions
src/audio/alsalayer.cpp
+
36
−
3
View file @
38e8d709
...
@@ -21,6 +21,11 @@
...
@@ -21,6 +21,11 @@
#include
"alsalayer.h"
#include
"alsalayer.h"
void
*
ringtoneThreadEntry
(
void
*
ptr
);
static
pthread_t
ringtone_thread
;
bool
ringtone_thread_is_running
;
// Constructor
// Constructor
AlsaLayer
::
AlsaLayer
(
ManagerImpl
*
manager
)
AlsaLayer
::
AlsaLayer
(
ManagerImpl
*
manager
)
:
AudioLayer
(
manager
,
ALSA
)
:
AudioLayer
(
manager
,
ALSA
)
...
@@ -35,6 +40,9 @@
...
@@ -35,6 +40,9 @@
,
IDSoundCards
()
,
IDSoundCards
()
{
{
_debug
(
" Constructor of AlsaLayer called
\n
"
);
_debug
(
" Constructor of AlsaLayer called
\n
"
);
// The flag to stop the ringtone thread loop
ringtone_thread_is_running
=
false
;
}
}
// Destructor
// Destructor
...
@@ -44,6 +52,9 @@ AlsaLayer::~AlsaLayer (void)
...
@@ -44,6 +52,9 @@ AlsaLayer::~AlsaLayer (void)
closeCaptureStream
();
closeCaptureStream
();
closePlaybackStream
();
closePlaybackStream
();
deviceClosed
=
true
;
deviceClosed
=
true
;
ringtone_thread_is_running
=
false
;
pthread_join
(
ringtone_thread
,
NULL
);
}
}
void
void
...
@@ -53,6 +64,8 @@ AlsaLayer::closeLayer()
...
@@ -53,6 +64,8 @@ AlsaLayer::closeLayer()
closeCaptureStream
();
closeCaptureStream
();
closePlaybackStream
();
closePlaybackStream
();
deviceClosed
=
true
;
deviceClosed
=
true
;
ringtone_thread_is_running
=
false
;
}
}
bool
bool
...
@@ -132,11 +145,18 @@ AlsaLayer::stopStream(void)
...
@@ -132,11 +145,18 @@ AlsaLayer::stopStream(void)
}
}
}
}
void
AlsaLayer
::
AlsaCallBack
(
snd_async_handler_t
*
pcm_callback
)
void
*
ringtoneThreadEntry
(
void
*
ptr
)
{
{
(
(
AlsaLayer
*
)
snd_async_handler_get_callback_private
(
pcm_callback
))
->
playTones
();
while
(
ringtone_thread_is_running
)
{
(
(
AlsaLayer
*
)
ptr
)
->
playTones
();
}
return
0
;
}
}
void
void
AlsaLayer
::
fillHWBuffer
(
void
)
AlsaLayer
::
fillHWBuffer
(
void
)
{
{
...
@@ -248,6 +268,7 @@ void AlsaLayer::restorePulseAppsVolume( void ){}
...
@@ -248,6 +268,7 @@ void AlsaLayer::restorePulseAppsVolume( void ){}
void
void
AlsaLayer
::
playTones
(
void
)
AlsaLayer
::
playTones
(
void
)
{
{
int
frames
=
_periodSize
;
int
frames
=
_periodSize
;
int
maxBytes
=
frames
*
sizeof
(
SFLDataFormat
)
;
int
maxBytes
=
frames
*
sizeof
(
SFLDataFormat
)
;
SFLDataFormat
*
out
=
(
SFLDataFormat
*
)
malloc
(
maxBytes
*
sizeof
(
SFLDataFormat
));
SFLDataFormat
*
out
=
(
SFLDataFormat
*
)
malloc
(
maxBytes
*
sizeof
(
SFLDataFormat
));
...
@@ -268,6 +289,7 @@ AlsaLayer::playTones( void )
...
@@ -268,6 +289,7 @@ AlsaLayer::playTones( void )
free
(
out
);
out
=
0
;
free
(
out
);
out
=
0
;
}
}
bool
bool
AlsaLayer
::
isPlaybackActive
(
void
)
{
AlsaLayer
::
isPlaybackActive
(
void
)
{
ost
::
MutexLock
guard
(
_mutex
);
ost
::
MutexLock
guard
(
_mutex
);
...
@@ -383,10 +405,21 @@ bool AlsaLayer::alsa_set_params( snd_pcm_t *pcm_handle, int type, int rate ){
...
@@ -383,10 +405,21 @@ bool AlsaLayer::alsa_set_params( snd_pcm_t *pcm_handle, int type, int rate ){
return
false
;
return
false
;
}
}
if
(
type
==
1
){
if
(
type
==
1
){
if
(
(
err
=
snd_async_add_pcm_handler
(
&
_AsyncHandler
,
pcm_handle
,
AlsaCallBack
,
this
)
<
0
)){
/*
if( (err = snd_async_add_pcm_handler( &_AsyncHandler, pcm_handle , AlsaCallBack, this ) < 0)){
_debugAlsa(" Unable to install the async callback handler (%s)\n", snd_strerror(err));
_debugAlsa(" Unable to install the async callback handler (%s)\n", snd_strerror(err));
return false;
return false;
}*/
// So the loop could start when the ringtone thread entry function is reached
ringtone_thread_is_running
=
true
;
if
(
pthread_create
(
&
ringtone_thread
,
NULL
,
ringtoneThreadEntry
,
this
)
!=
0
)
{
_debug
(
"Unable to start the ringtone posix thread
\n
"
);
return
false
;
}
}
}
}
snd_pcm_sw_params_free
(
swparams
);
snd_pcm_sw_params_free
(
swparams
);
...
...
This diff is collapsed.
Click to expand it.
src/audio/alsalayer.h
+
12
−
7
View file @
38e8d709
...
@@ -22,6 +22,8 @@
...
@@ -22,6 +22,8 @@
#include
"audiolayer.h"
#include
"audiolayer.h"
#include
<pthread.h>
class
RingBuffer
;
class
RingBuffer
;
class
ManagerImpl
;
class
ManagerImpl
;
...
@@ -202,6 +204,15 @@ class AlsaLayer : public AudioLayer {
...
@@ -202,6 +204,15 @@ class AlsaLayer : public AudioLayer {
*/
*/
void
setPlaybackVolume
(
double
volume
);
void
setPlaybackVolume
(
double
volume
);
/**
* Callback used for asynchronous playback.
* Write tones buffer to the alsa internal ring buffer.
*/
void
playTones
(
void
);
private
:
private
:
// Copy Constructor
// Copy Constructor
...
@@ -232,13 +243,7 @@ class AlsaLayer : public AudioLayer {
...
@@ -232,13 +243,7 @@ class AlsaLayer : public AudioLayer {
* Called when a certain amount of data is written ot the device
* Called when a certain amount of data is written ot the device
* @param pcm_callback The callback pointer
* @param pcm_callback The callback pointer
*/
*/
static
void
AlsaCallBack
(
snd_async_handler_t
*
pcm_callback
);
//static void AlsaCallBack( snd_async_handler_t* pcm_callback);
/**
* Callback used for asynchronous playback.
* Write tones buffer to the alsa internal ring buffer.
*/
void
playTones
(
void
);
/**
/**
* Open the specified device.
* Open the specified device.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment