Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
David MacDonald
purr-data
Commits
551a45ea
Commit
551a45ea
authored
Dec 27, 2007
by
Miller Puckette
Browse files
bug fixes in call back sched
parent
49f5b918
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/m_sched.c
View file @
551a45ea
...
...
@@ -30,7 +30,7 @@ int sys_sleepgrain;
void
sched_reopenmeplease
(
void
)
/* request from s_audio for deferred reopen */
{
sys_quit
=
SYS_QUIT_RESTART
;
sys_quit
=
SYS_QUIT_RESTART
;
}
typedef
void
(
*
t_clockmethod
)(
void
*
client
);
...
...
@@ -537,7 +537,7 @@ void sched_audio_callbackfn(void)
static
void
m_callbackscheduler
(
void
)
{
sys_initmidiqueue
();
while
(
1
)
while
(
!
sys_quit
)
{
#ifdef MSW
Sleep
(
1000
);
...
...
src/s_audio.c
View file @
551a45ea
...
...
@@ -67,6 +67,8 @@ static int audio_rate;
static
int
audio_advance
;
static
int
audio_callback
;
static
int
audio_callback_is_open
;
/* reflects true actual state */
static
int
audio_nextinchans
,
audio_nextoutchans
;
void
sched_audio_callbackfn
(
void
);
void
sched_reopenmeplease
(
void
);
...
...
@@ -194,9 +196,6 @@ void sys_set_audio_settings(int naudioindev, int *audioindev, int nchindev,
{
return
;
}
/* if we're already open close it */
if
(
sys_inchannels
||
sys_outchannels
)
sys_close_audio
();
if
(
rate
<
1
)
rate
=
DEFAULTSRATE
;
...
...
@@ -325,10 +324,11 @@ void sys_set_audio_settings(int naudioindev, int *audioindev, int nchindev,
nrealoutdev
++
;
}
sys_schedadvance
=
advance
*
1000
;
sys_setchsr
(
inchans
,
outchans
,
rate
);
sys_log_error
(
ERR_NOTHING
);
audio_nextinchans
=
inchans
;
audio_nextoutchans
=
outchans
;
sys_save_audio_params
(
nrealindev
,
realindev
,
realinchans
,
nrealoutdev
,
realoutdev
,
realoutchans
,
sys_dacsr
,
advance
,
callback
);
nrealoutdev
,
realoutdev
,
realoutchans
,
rate
,
advance
,
callback
);
}
void
sys_close_audio
(
void
)
...
...
@@ -369,6 +369,7 @@ void sys_close_audio(void)
sys_audioapiopened
=
-
1
;
sched_set_using_audio
(
SCHED_AUDIO_NONE
);
audio_state
=
0
;
audio_callback_is_open
=
0
;
}
/* open audio using whatever parameters were last used */
...
...
@@ -379,6 +380,7 @@ void sys_reopen_audio( void)
int
rate
,
advance
,
callback
,
outcome
=
0
;
sys_get_audio_params
(
&
naudioindev
,
audioindev
,
chindev
,
&
naudiooutdev
,
audiooutdev
,
choutdev
,
&
rate
,
&
advance
,
&
callback
);
sys_setchsr
(
audio_nextinchans
,
audio_nextoutchans
,
rate
);
if
(
!
naudioindev
&&
!
naudiooutdev
)
{
sched_set_using_audio
(
SCHED_AUDIO_NONE
);
...
...
@@ -430,14 +432,16 @@ void sys_reopen_audio( void)
audio_state
=
0
;
sched_set_using_audio
(
SCHED_AUDIO_NONE
);
sys_audioapiopened
=
-
1
;
audio_callback_is_open
=
0
;
}
else
{
/* fprintf(stderr, "started w/callback %d\n", callback); */
/* fprintf(stderr, "started w/callback %d\n", callback); */
audio_state
=
1
;
sched_set_using_audio
(
(
callback
?
SCHED_AUDIO_CALLBACK
:
SCHED_AUDIO_POLL
));
sys_audioapiopened
=
sys_audioapi
;
audio_callback_is_open
=
callback
;
}
sys_vgui
(
"set pd_whichapi %d
\n
"
,
(
outcome
==
0
?
sys_audioapi
:
0
));
}
...
...
@@ -690,6 +694,7 @@ void glob_audio_properties(t_pd *dummy, t_floatarg flongform)
gfxstub_new
(
&
glob_pdobject
,
(
void
*
)
glob_audio_properties
,
buf
);
}
extern
int
pa_foo
;
/* new values from dialog window */
void
glob_audio_dialog
(
t_pd
*
dummy
,
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
)
{
...
...
@@ -703,7 +708,6 @@ void glob_audio_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
int
newrate
=
atom_getintarg
(
16
,
argc
,
argv
);
int
newadvance
=
atom_getintarg
(
17
,
argc
,
argv
);
int
newcallback
=
atom_getintarg
(
18
,
argc
,
argv
);
int
statewas
;
for
(
i
=
0
;
i
<
4
;
i
++
)
{
...
...
@@ -738,12 +742,12 @@ void glob_audio_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
if
(
newcallback
<
0
)
newcallback
=
0
;
if
(
!
audio_callback
&&
!
newcallback
)
if
(
!
audio_callback
_is_open
&&
!
newcallback
)
sys_close_audio
();
sys_set_audio_settings
(
nindev
,
newaudioindev
,
nindev
,
newaudioinchan
,
noutdev
,
newaudiooutdev
,
noutdev
,
newaudiooutchan
,
newrate
,
newadvance
,
(
newcallback
>=
0
?
newcallback
:
0
));
if
(
!
audio_callback
&&
!
newcallback
)
if
(
!
audio_callback
_is_open
&&
!
newcallback
)
sys_reopen_audio
();
else
sched_reopenmeplease
();
}
...
...
src/s_audio_pa.c
View file @
551a45ea
...
...
@@ -28,6 +28,8 @@ static t_audiocallback pa_callback;
#define MAX_PA_CHANS 32
#define MAX_SAMPLES_PER_FRAME MAX_PA_CHANS * DEFDACBLKSIZE
int
pa_foo
;
static
int
pa_lowlevel_callback
(
const
void
*
inputBuffer
,
void
*
outputBuffer
,
unsigned
long
framesPerBuffer
,
const
PaStreamCallbackTimeInfo
*
outTime
,
PaStreamCallbackFlags
myflags
,
...
...
@@ -36,6 +38,8 @@ static int pa_lowlevel_callback(const void *inputBuffer,
int
i
;
unsigned
int
j
;
float
*
fbuf
,
*
fp2
,
*
fp3
,
*
soundiop
;
if
(
pa_foo
)
fprintf
(
stderr
,
"pa_lowlevel_callback
\n
"
);
if
(
framesPerBuffer
!=
DEFDACBLKSIZE
)
{
fprintf
(
stderr
,
"ignoring buffer size %d
\n
"
,
(
int
)
framesPerBuffer
);
...
...
@@ -62,6 +66,8 @@ static int pa_lowlevel_callback(const void *inputBuffer,
for
(
j
=
0
,
fp3
=
fp2
;
j
<
framesPerBuffer
;
j
++
,
fp3
+=
pa_outchans
)
*
fp3
=
*
soundiop
++
;
}
if
(
pa_foo
)
fprintf
(
stderr
,
"done pa_lowlevel_callback
\n
"
);
return
0
;
}
...
...
@@ -154,8 +160,7 @@ int pa_open_audio(int inchans, int outchans, int rate, t_sample *soundin,
int
j
,
devno
,
pa_indev
=
0
,
pa_outdev
=
0
;
pa_callback
=
callbackfn
;
if
(
callbackfn
)
fprintf
(
stderr
,
"callback enabled
\n
"
);
/* fprintf(stderr, "open callback %d\n", (callbackfn != 0)); */
if
(
!
initialized
)
{
/* Initialize PortAudio */
...
...
@@ -255,6 +260,7 @@ int pa_open_audio(int inchans, int outchans, int rate, t_sample *soundin,
void
pa_close_audio
(
void
)
{
/* fprintf(stderr, "close\n"); */
if
(
pa_inchans
||
pa_outchans
)
CloseAudioStream
(
pa_stream
);
pa_inchans
=
pa_outchans
=
0
;
...
...
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