Mercurial > hg > octave-nkf
changeset 19757:e75df9e43e63
disable Octave audio callback functions
* audiodevinfo.cc (F__recorder_audiorecorder__,
F__player_audioplayer__): Error if argument is a function.
* audioplayer.m, audiorecorder.m: Remove function callbacks from
documentation. Comment out callback tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 09 Jan 2015 15:03:01 -0500 |
parents | 701b43ce4467 |
children | 0d3e67f27d57 |
files | libinterp/dldfcn/audiodevinfo.cc scripts/audio/@audioplayer/audioplayer.m scripts/audio/@audiorecorder/audiorecorder.m |
diffstat | 3 files changed, 45 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/dldfcn/audiodevinfo.cc +++ b/libinterp/dldfcn/audiodevinfo.cc @@ -1832,8 +1832,11 @@ if (is_function) { - recorder->octave_callback_function = args(0).function_value (); - offset = 1; + error ("audioplayer: callbacks not yet implemented"); + return retval; + + // recorder->octave_callback_function = args(0).function_value (); + // offset = 1; } } @@ -2353,7 +2356,12 @@ bool is_function = args(0).is_string () || args(0).is_function_handle () || args(0).is_inline_function (); if (is_function) - recorder->set_y (args(0).function_value ()); + { + error ("audioplayer: callbacks not yet implemented"); + return retval; + + // recorder->set_y (args(0).function_value ()); + } else recorder->set_y (args(0));
--- a/scripts/audio/@audioplayer/audioplayer.m +++ b/scripts/audio/@audioplayer/audioplayer.m @@ -20,14 +20,12 @@ ## @deftypefn {Function File} {@var{player} =} audioplayer (@var{y}, @var{fs}) ## @deftypefnx {Function File} {@var{player} =} audioplayer (@var{y}, @var{fs}, @var{nbits}) ## @deftypefnx {Function File} {@var{player} =} audioplayer (@var{y}, @var{fs}, @var{nbits}, @var{id}) -## @deftypefnx {Function File} {@var{player} =} audioplayer (@var{function}, @dots{}) ## @deftypefnx {Function File} {@var{player} =} audioplayer (@var{recorder}) ## @deftypefnx {Function File} {@var{player} =} audioplayer (@var{recorder}, @var{id}) ## Create an audioplayer object that will play back data @var{y} at sample ## rate @var{fs}. The optional arguments @var{nbits}, and @var{id} ## specify the bit depth and player device id, respectively. Device IDs ## may be found using the audiodevinfo function. -## Given a function handle, use that function to process the audio. ## Given an audioplayer object, use the data from the object to ## initialize the player. ## @end deftypefn @@ -45,7 +43,16 @@ ## play (player); ## @end group ## @end example + +## FIXME: callbacks don't work properly, apparently because portaudio +## will execute the callbacks in a separate thread, and calling Octave +## functions in a separate thread which is likely to cause trouble with +## all of Octave's global data... ## +## @deftypefnx {Function File} {@var{player} =} audioplayer (@var{function}, @dots{}) +## +## Given a function handle, use that function to process the audio. +# ## The following example will create and register a callback that generates ## a sine wave on both channels. ## @@ -70,7 +77,6 @@ ## # play for as long as you want ## stop (player); ## @end group -## @end example function player = audioplayer (varargin) @@ -176,21 +182,21 @@ %! properties = get (player, {"SampleRate", "Tag", "UserData"}); %! assert (properties, {8000, "tag", [1, 2; 3, 4]}); -%!function [sound, status] = callback (samples) -%! sound = rand (samples, 2) - 0.5; -%! status = 0; -%!endfunction +#%!function [sound, status] = callback (samples) +#%! sound = rand (samples, 2) - 0.5; +#%! status = 0; +#%!endfunction -%!testif HAVE_PORTAUDIO -%! player = audioplayer (@callback, 44100); -%! play (player); -%! sleep (2); -%! stop (player); -%! assert (1); +#%!testif HAVE_PORTAUDIO +#%! player = audioplayer (@callback, 44100); +#%! play (player); +#%! sleep (2); +#%! stop (player); +#%! assert (1); -%!testif HAVE_PORTAUDIO -%! player = audioplayer ("callback", 44100, 16); -%! play (player); -%! sleep (2); -%! stop (player); -%! assert (1); +#%!testif HAVE_PORTAUDIO +#%! player = audioplayer ("callback", 44100, 16); +#%! play (player); +#%! sleep (2); +#%! stop (player); +#%! assert (1);
--- a/scripts/audio/@audiorecorder/audiorecorder.m +++ b/scripts/audio/@audiorecorder/audiorecorder.m @@ -20,14 +20,21 @@ ## @deftypefn {Function File} {@var{recorder} =} audiorecorder () ## @deftypefnx {Function File} {@var{recorder} =} audiorecorder (@var{fs}, @var{nbits}, @var{channels}) ## @deftypefnx {Function File} {@var{recorder} =} audiorecorder (@var{fs}, @var{nbits}, @var{channels}, @var{id}) -## @deftypefnx {Function File} {@var{recorder} =} audiorecorder (@var{function}, @dots{}) ## Create an audiorecorder object recording 8 bit mono audio at 8000 Hz ## sample rate. The optional arguments @var{fs}, @var{nbits}, ## @var{channels}, and @var{id} specify the sample rate, bit depth, ## number of channels and recording device id, respectively. Device IDs ## may be found using the audiodevinfo function. +## @end deftypefn + +## FIXME: callbacks don't work properly, apparently because portaudio +## will execute the callbacks in a separate thread, and calling Octave +## functions in a separate thread which is likely to cause trouble with +## all of Octave's global data... +## +## @deftypefnx {Function File} {@var{recorder} =} audiorecorder (@var{function}, @dots{}) +## ## Given a function handle, use that function to process the audio. -## @end deftypefn function recorder = audiorecorder (varargin)