<commit_before>/* RTcmix  - Copyright (C) 2000  The RTcmix Development Team
   See ``AUTHORS'' for a list of contributors. See ``LICENSE'' for
   the license to this software and for a DISCLAIMER OF ALL WARRANTIES.
*/
/* rev'd for v2.3, JGG, 20-Feb-00 */
/* rev'd for v3.7 (converted to C++ source), DS, April-04 */

#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <globals.h>
#include <prototypes.h>
#include <buffers.h>
#include "../rtstuff/rtdefs.h"
#include "AudioDevice.h"

extern AudioDevice *globalInputDevice;	// from audio_devices.cpp

/* local prototypes */

static int read_from_audio_device(void);


/* ----------------------------------------------- read_from_audio_device --- */
static int
read_from_audio_device(AudioDevice *inputDevice)
{
	int result;

	result = inputDevice->getFrames(audioin_buffer, RTBUFSAMPS);
	if (result == -1) {
		fprintf(stderr, "read_from_audio_device got error: %s\n",
				inputDevice->getLastError());
		return -1;
	}

   return 0;
}


/* ----------------------------------------------------------- rtgetsamps --- */
void
rtgetsamps(AudioDevice *inputDevice)
{
   int   err;

   assert(audio_on == 1);

	// This is a hack:  until I can create an AudioDevice which is guaranteed
	// to work in full duplex, we need to override the device handed to us to
	// point to the global input device.  Otherwise, we will be calling read on
	// a device possibly configured only for output (playback).

	if (!globalInputDevice || globalInputDevice == inputDevice)
	   err = read_from_audio_device(inputDevice);
	else
	   err = read_from_audio_device(globalInputDevice);

   if (err)
      fprintf(stderr, "rtgetsamps: bad read from audio device\n");
}

<commit_msg>Simplified considerably, but still has a hack.<commit_after>/* RTcmix  - Copyright (C) 2000  The RTcmix Development Team
   See ``AUTHORS'' for a list of contributors. See ``LICENSE'' for
   the license to this software and for a DISCLAIMER OF ALL WARRANTIES.
*/
/* rev'd for v2.3, JGG, 20-Feb-00 */
/* rev'd for v3.7 (converted to C++ source), DS, April-04 */

#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <globals.h>
#include <prototypes.h>
#include <buffers.h>
#include "../rtstuff/rtdefs.h"
#include "AudioDevice.h"

extern AudioDevice *globalAudioDevice;	// audio_devices.cpp

/* ----------------------------------------------------------- rtgetsamps --- */
void
rtgetsamps(AudioDevice *inputDevice)
{
	assert(audio_on == 1);
	// Sorrowful hack:  The dual AudioDevice run the callback on the playback
	// device, which means it cannot pass the record device to this function.
	if (globalAudioDevice->getFrames(audioin_buffer, RTBUFSAMPS) < 0)
	{
		fprintf(stderr, "rtgetsamps error: %s\n", globalAudioDevice->getLastError());
	}
}


{'fraction_non_alphanumeric': 0.1771058315334773, 'fraction_numerical': 0.012239020878329733, 'mean_word_length': 3.0333817126269955, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3712112', 'n_tokens_mistral': 920, 'n_tokens_neox': 862, 'n_words': 279}