# HG changeset patch # User John W. Eaton # Date 1420833781 18000 # Node ID e75df9e43e6303cacb78b24ede938e4cb0c6ab2c # Parent 701b43ce446730d4798e10ff85e1e04e6825df6d 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. diff -r 701b43ce4467 -r e75df9e43e63 libinterp/dldfcn/audiodevinfo.cc --- a/libinterp/dldfcn/audiodevinfo.cc Fri Jan 09 14:11:19 2015 -0500 +++ b/libinterp/dldfcn/audiodevinfo.cc Fri Jan 09 15:03:01 2015 -0500 @@ -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)); diff -r 701b43ce4467 -r e75df9e43e63 scripts/audio/@audioplayer/audioplayer.m --- a/scripts/audio/@audioplayer/audioplayer.m Fri Jan 09 14:11:19 2015 -0500 +++ b/scripts/audio/@audioplayer/audioplayer.m Fri Jan 09 15:03:01 2015 -0500 @@ -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); diff -r 701b43ce4467 -r e75df9e43e63 scripts/audio/@audiorecorder/audiorecorder.m --- a/scripts/audio/@audiorecorder/audiorecorder.m Fri Jan 09 14:11:19 2015 -0500 +++ b/scripts/audio/@audiorecorder/audiorecorder.m Fri Jan 09 15:03:01 2015 -0500 @@ -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)