mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-04-07 09:05:18 +00:00
Parameter to specify number of input audio channels
This commit is contained in:
@@ -246,10 +246,10 @@ then
|
||||
fi
|
||||
|
||||
video_display_abi_version=2
|
||||
video_capture_abi_version=1
|
||||
video_capture_abi_version=2
|
||||
video_compress_abi_version=1
|
||||
video_decompress_abi_version=2
|
||||
audio_capture_abi_version=2
|
||||
audio_capture_abi_version=3
|
||||
audio_playback_abi_version=3
|
||||
vo_pp_abi_version=1
|
||||
AC_DEFINE_UNQUOTED([VIDEO_DISPLAY_ABI_VERSION], $video_display_abi_version, [Specifies ABI version for video displays])
|
||||
|
||||
@@ -47,6 +47,8 @@
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include "host.h"
|
||||
|
||||
#ifdef HAVE_ALSA
|
||||
|
||||
#include "audio/audio.h"
|
||||
@@ -85,7 +87,7 @@ void * audio_cap_alsa_init(char *cfg)
|
||||
|
||||
s->frame.bps = 2;
|
||||
s->frame.sample_rate = 48000;
|
||||
s->frame.ch_count = 2;
|
||||
s->frame.ch_count = audio_input_channels;
|
||||
|
||||
if(cfg && strlen(cfg) > 0) {
|
||||
name = cfg;
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "host.h"
|
||||
|
||||
#ifdef HAVE_COREAUDIO
|
||||
|
||||
@@ -257,7 +258,7 @@ void * audio_cap_ca_init(char *cfg)
|
||||
s->boss_waiting = FALSE;
|
||||
s->data_ready = FALSE;
|
||||
s->frame.bps = 2;
|
||||
s->frame.ch_count = 2;
|
||||
s->frame.ch_count = audio_input_channels;
|
||||
|
||||
double rate;
|
||||
size = sizeof(double);
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include "debug.h"
|
||||
|
||||
#include "host.h"
|
||||
|
||||
#include "audio/audio.h"
|
||||
#include "audio/utils.h"
|
||||
@@ -186,7 +186,14 @@ void * audio_cap_jack_init(char *cfg)
|
||||
i = 0;
|
||||
while(ports[i]) i++;
|
||||
|
||||
s->frame.ch_count = i;
|
||||
if(i < audio_input_channels) {
|
||||
fprintf(stderr, "[JACK capture] Requested channel count %d not found (matching pattern %s).\n",
|
||||
audio_input_channels, cfg);
|
||||
goto release_client;
|
||||
|
||||
}
|
||||
|
||||
s->frame.ch_count = audio_input_channels;
|
||||
s->frame.bps = 4;
|
||||
s->frame.sample_rate = jack_get_sample_rate (s->client);
|
||||
s->frame.max_size = s->frame.ch_count * s->frame.bps * s->frame.sample_rate;
|
||||
@@ -217,7 +224,7 @@ void * audio_cap_jack_init(char *cfg)
|
||||
int port;
|
||||
char name[32];
|
||||
|
||||
for(port = 0; port < i; port++) {
|
||||
for(port = 0; port < s->frame.ch_count; port++) {
|
||||
snprintf(name, 32, "capture_%02u", port);
|
||||
s->input_ports[port] = jack_port_register(s->client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
|
||||
/* attach ports */
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
#include "config.h"
|
||||
#include "config_unix.h"
|
||||
#include "debug.h"
|
||||
#include "host.h"
|
||||
#include "utils/fs_lock.h"
|
||||
|
||||
|
||||
@@ -65,7 +66,6 @@
|
||||
#define BPS 2 /* paInt16 */
|
||||
#define SAMPLE_RATE 48000
|
||||
#define SAMPLES_PER_FRAME 2048
|
||||
#define CHANNELS 2
|
||||
#define SECONDS 5
|
||||
|
||||
#define MODULE_NAME "[Portaudio capture] "
|
||||
@@ -241,10 +241,16 @@ void * portaudio_capture_init(char *cfg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(CHANNELS <= device_info->maxInputChannels)
|
||||
inputParameters.channelCount = CHANNELS;
|
||||
else
|
||||
inputParameters.channelCount = device_info->maxInputChannels;
|
||||
if(audio_input_channels <= device_info->maxInputChannels) {
|
||||
inputParameters.channelCount = audio_input_channels;
|
||||
} else {
|
||||
fprintf(stderr, MODULE_NAME "Requested %d input channels, devide offers only %d.\n",
|
||||
audio_input_channels,
|
||||
device_info->maxInputChannels);
|
||||
fs_lock_unlock(s->portaudio_lock); /* safer with multiple threads */
|
||||
free(s);
|
||||
return NULL;
|
||||
}
|
||||
inputParameters.sampleFormat = paInt16;
|
||||
inputParameters.suggestedLatency = Pa_GetDeviceInfo( inputParameters.device )->defaultHighInputLatency ;
|
||||
inputParameters.hostApiSpecificStreamInfo = NULL;
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#include "config_unix.h"
|
||||
#endif
|
||||
#include "debug.h"
|
||||
#include "host.h"
|
||||
#include "tv.h"
|
||||
|
||||
#include <assert.h>
|
||||
@@ -67,10 +68,9 @@
|
||||
|
||||
#define AUDIO_SAMPLE_RATE 48000
|
||||
#define AUDIO_BPS 2
|
||||
#define AUDIO_CHANNELS 2
|
||||
#define BUFFER_SEC 1
|
||||
#define AUDIO_BUFFER_SIZE (AUDIO_SAMPLE_RATE * AUDIO_BPS * \
|
||||
AUDIO_CHANNELS * BUFFER_SEC)
|
||||
audio_input_channels * BUFFER_SEC)
|
||||
|
||||
#define CHUNK 128 * 3 // has to be divisor of AUDIO_SAMLE_RATE
|
||||
|
||||
@@ -109,7 +109,7 @@ void * audio_cap_testcard_init(char *cfg)
|
||||
|
||||
s = (struct state_audio_capture_testcard *) malloc(sizeof(struct state_audio_capture_testcard));
|
||||
printf(MODULE_NAME "Generating %d sec tone (%d Hz) / %d sec silence ", BUFFER_SEC, FREQUENCY, BUFFER_SEC);
|
||||
printf("(channels: %d; bps: %d; sample rate: %d; frames per packet: %d).\n", AUDIO_CHANNELS,
|
||||
printf("(channels: %d; bps: %d; sample rate: %d; frames per packet: %d).\n", audio_input_channels,
|
||||
AUDIO_BPS, AUDIO_SAMPLE_RATE, CHUNK);
|
||||
s->magic = AUDIO_CAPTURE_TESTCARD_MAGIC;
|
||||
assert(s != 0);
|
||||
@@ -119,17 +119,17 @@ void * audio_cap_testcard_init(char *cfg)
|
||||
|
||||
s->audio_tone = calloc(1, AUDIO_BUFFER_SIZE /* 1 sec */);
|
||||
short int * data = (short int *) s->audio_tone;
|
||||
for( i=0; i < AUDIO_BUFFER_SIZE/2; i+=AUDIO_CHANNELS )
|
||||
for( i=0; i < AUDIO_BUFFER_SIZE/2; i+=audio_input_channels )
|
||||
{
|
||||
for (int channel = 0; channel < AUDIO_CHANNELS; ++channel)
|
||||
data[i + channel] = (float) sin( ((double)(i/AUDIO_CHANNELS)/((double)AUDIO_SAMPLE_RATE / FREQUENCY)) * M_PI * 2. ) * SHRT_MAX * VOLUME;
|
||||
for (int channel = 0; channel < audio_input_channels; ++channel)
|
||||
data[i + channel] = (float) sin( ((double)(i/audio_input_channels)/((double)AUDIO_SAMPLE_RATE / FREQUENCY)) * M_PI * 2. ) * SHRT_MAX * VOLUME;
|
||||
}
|
||||
|
||||
|
||||
s->audio.bps = AUDIO_BPS;
|
||||
s->audio.ch_count = AUDIO_CHANNELS;
|
||||
s->audio.ch_count = audio_input_channels;
|
||||
s->audio.sample_rate = AUDIO_SAMPLE_RATE;
|
||||
s->audio.data_len = CHUNK * AUDIO_BPS * AUDIO_CHANNELS;
|
||||
s->audio.data_len = CHUNK * AUDIO_BPS * audio_input_channels;
|
||||
|
||||
s->current_sample = SILENCE;
|
||||
s->samples_played = 0;
|
||||
@@ -160,9 +160,9 @@ struct audio_frame *audio_cap_testcard_read(void *state)
|
||||
tv_add_usec(&s->next_audio_time, 1000 * 1000 * CHUNK / 48000);
|
||||
|
||||
if(s->current_sample == TONE) {
|
||||
s->audio.data = (char* )(s->audio_tone + s->samples_played * AUDIO_CHANNELS); // it is short so _not_ (* 2)
|
||||
s->audio.data = (char* )(s->audio_tone + s->samples_played * audio_input_channels); // it is short so _not_ (* 2)
|
||||
} else {
|
||||
s->audio.data = (char *)(s->audio_silence + s->samples_played * AUDIO_CHANNELS);
|
||||
s->audio.data = (char *)(s->audio_silence + s->samples_played * audio_input_channels);
|
||||
}
|
||||
|
||||
s->samples_played += CHUNK;
|
||||
|
||||
@@ -61,4 +61,6 @@ extern volatile int should_exit;
|
||||
|
||||
extern void (*exit_uv)(int status);
|
||||
|
||||
extern unsigned int audio_input_channels;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -99,7 +99,9 @@
|
||||
#define DEFAULT_AUDIO_FEC "mult:3"
|
||||
|
||||
#define AUDIO_CHANNEL_MAP (('a' << 8) | 'm')
|
||||
#define AUDIO_INPUT_CHANNELS (('a' << 8) | 'i')
|
||||
#define AUDIO_SCALE (('a' << 8) | 's')
|
||||
|
||||
struct state_uv {
|
||||
int recv_port_number;
|
||||
int send_port_number;
|
||||
@@ -145,6 +147,8 @@ volatile int wait_to_finish = FALSE;
|
||||
volatile int threads_joined = FALSE;
|
||||
static int exit_status = EXIT_SUCCESS;
|
||||
|
||||
unsigned int audio_input_channels = 2;
|
||||
|
||||
uint32_t RTT = 0; /* this is computed by handle_rr in rtp_callback */
|
||||
struct video_frame *frame_buffer = NULL;
|
||||
uint32_t hd_color_spc = 0;
|
||||
@@ -250,6 +254,10 @@ static void usage(void)
|
||||
printf("\t \t\tnone - no scaling will be performed\n");
|
||||
printf("\t \t\n");
|
||||
printf("\n");
|
||||
printf("\t--audio-input-channels <count>\n");
|
||||
printf("\t \tHow many of input channels should be captured (default 2).\n");
|
||||
printf("\t \t\n");
|
||||
printf("\n");
|
||||
printf("\taddress(es) \tdestination address\n");
|
||||
printf("\n");
|
||||
printf("\t \tIf comma-separated list of addresses\n");
|
||||
@@ -772,8 +780,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
char *capture_cfg = NULL;
|
||||
char *display_cfg = NULL;
|
||||
char *audio_send = NULL;
|
||||
char *audio_recv = NULL;
|
||||
char *audio_send = NULL;
|
||||
char *jack_cfg = NULL;
|
||||
char *requested_fec = NULL;
|
||||
char *save_ptr = NULL;
|
||||
@@ -819,6 +827,7 @@ int main(int argc, char *argv[])
|
||||
{"limit-bitrate", required_argument, 0, 'l'},
|
||||
{"audio-channel-map", required_argument, 0, AUDIO_CHANNEL_MAP},
|
||||
{"audio-scale", required_argument, 0, AUDIO_SCALE},
|
||||
{"audio-input-channels", required_argument, 0, AUDIO_INPUT_CHANNELS},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
int option_index = 0;
|
||||
@@ -944,6 +953,9 @@ int main(int argc, char *argv[])
|
||||
case AUDIO_SCALE:
|
||||
audio_scale = optarg;
|
||||
break;
|
||||
case AUDIO_INPUT_CHANNELS:
|
||||
audio_input_channels = atoi(optarg);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
return EXIT_FAIL_USAGE;
|
||||
|
||||
@@ -127,7 +127,6 @@ struct vidcap_decklink_state {
|
||||
|
||||
int frames;
|
||||
unsigned int grab_audio:1; /* wheather we process audio or not */
|
||||
unsigned int audio_channels; /* count of audio channels used */
|
||||
unsigned int stereo:1; /* for eg. DeckLink HD Extreme, Quad doesn't set this !!! */
|
||||
unsigned int use_timecode:1; /* use timecode when grabbing from multiple inputs */
|
||||
unsigned int autodetect_mode:1;
|
||||
@@ -227,7 +226,7 @@ public:
|
||||
deckLinkInput->EnableAudioInput(
|
||||
bmdAudioSampleRate48kHz,
|
||||
bmdAudioSampleType16bitInteger,
|
||||
s->audio_channels == 1 ? 2 : s->audio_channels); // BMD isn't able to grab single channel
|
||||
audio_input_channels == 1 ? 2 : audio_input_channels); // BMD isn't able to grab single channel
|
||||
}
|
||||
//deckLinkInput->SetCallback(s->state[i].delegate);
|
||||
deckLinkInput->StartStreams();
|
||||
@@ -272,14 +271,14 @@ VideoDelegate::VideoInputFrameArrived (IDeckLinkVideoInputFrame *arrivedFrame, I
|
||||
|
||||
if(audioPacket) {
|
||||
audioPacket->GetBytes(&audioFrame);
|
||||
if(s->audio_channels == 1) { // ther are actually 2 channels grabbed
|
||||
demux_channel(s->audio.data, (char *) audioFrame, 2, audioPacket->GetSampleFrameCount() * s->audio_channels * 2,
|
||||
if(audio_input_channels == 1) { // ther are actually 2 channels grabbed
|
||||
demux_channel(s->audio.data, (char *) audioFrame, 2, audioPacket->GetSampleFrameCount() * audio_input_channels * 2,
|
||||
2, /* channels (originally( */
|
||||
0 /* we want first channel */
|
||||
);
|
||||
s->audio.data_len = audioPacket->GetSampleFrameCount() * 1 * 2;
|
||||
} else {
|
||||
s->audio.data_len = audioPacket->GetSampleFrameCount() * s->audio_channels * 2;
|
||||
s->audio.data_len = audioPacket->GetSampleFrameCount() * audio_input_channels * 2;
|
||||
memcpy(s->audio.data, audioFrame, s->audio.data_len);
|
||||
}
|
||||
} else {
|
||||
@@ -582,15 +581,6 @@ settings_init(void *state, char *fmt)
|
||||
fprintf(stderr, "[DeckLink] Unrecognized connection %s.\n", connection);
|
||||
return 0;
|
||||
}
|
||||
} else if(strncasecmp(tmp, "audio_channels=", strlen("audio_channels=")) == 0) {
|
||||
s->audio_channels = atoi(tmp + strlen("connection="));
|
||||
if(s->audio_channels != 1 &&
|
||||
s->audio_channels != 2 &&
|
||||
s->audio_channels != 8 &&
|
||||
s->audio_channels != 16) {
|
||||
fprintf(stderr, "[DeckLink] Decklink cannot grab %d audio channels. "
|
||||
"Only 1, 2, 8 or 16 are poosible.", s->audio_channels);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "[DeckLink] Warning, unrecognized trailing options in init string: %s", tmp);
|
||||
}
|
||||
@@ -761,9 +751,6 @@ vidcap_decklink_init(char *fmt, unsigned int flags)
|
||||
|
||||
gettimeofday(&t0, NULL);
|
||||
|
||||
s->audio_channels = 2; // default - stereo
|
||||
// may be overriden in settings_init
|
||||
|
||||
s->stereo = FALSE;
|
||||
s->use_timecode = FALSE;
|
||||
s->autodetect_mode = FALSE;
|
||||
@@ -794,8 +781,8 @@ vidcap_decklink_init(char *fmt, unsigned int flags)
|
||||
}
|
||||
s->audio.bps = 2;
|
||||
s->audio.sample_rate = 48000;
|
||||
s->audio.ch_count = s->audio_channels;
|
||||
s->audio.data = (char *) malloc (48000 * s->audio_channels * 2);
|
||||
s->audio.ch_count = audio_input_channels;
|
||||
s->audio.data = (char *) malloc (48000 * audio_input_channels * 2);
|
||||
} else {
|
||||
s->grab_audio = FALSE;
|
||||
}
|
||||
@@ -983,10 +970,18 @@ vidcap_decklink_init(char *fmt, unsigned int flags)
|
||||
fprintf(stderr, "[Decklink capture] Unable to set audio input!!! Please check if it is OK. Continuing anyway.\n");
|
||||
|
||||
}
|
||||
if(audio_input_channels != 1 &&
|
||||
audio_input_channels != 2 &&
|
||||
audio_input_channels != 8 &&
|
||||
audio_input_channels != 16) {
|
||||
fprintf(stderr, "[DeckLink] Decklink cannot grab %d audio channels. "
|
||||
"Only 1, 2, 8 or 16 are poosible.", audio_input_channels);
|
||||
goto error;
|
||||
}
|
||||
deckLinkInput->EnableAudioInput(
|
||||
bmdAudioSampleRate48kHz,
|
||||
bmdAudioSampleType16bitInteger,
|
||||
s->audio_channels == 1 ? 2 : s->audio_channels);
|
||||
audio_input_channels == 1 ? 2 : audio_input_channels);
|
||||
}
|
||||
|
||||
// set Callback which returns frames
|
||||
|
||||
@@ -377,12 +377,21 @@ vidcap_deltacast_init(char *init_fmt, unsigned int flags)
|
||||
}
|
||||
|
||||
if(flags & DISPLAY_FLAG_AUDIO_EMBEDDED) {
|
||||
if(audio_input_channels != 1 &&
|
||||
audio_input_channels != 2) {
|
||||
fprintf(stderr, "[DELTACAST capture] Unable to handle channel count other than 1 or 2.\n");
|
||||
goto no_audio;
|
||||
}
|
||||
s->audio_frame.bps = 3;
|
||||
s->audio_frame.sample_rate = 48000;
|
||||
s->audio_frame.ch_count = 2;
|
||||
s->audio_frame.ch_count = audio_input_channels;
|
||||
memset(&s->AudioInfo, 0, sizeof(VHD_AUDIOINFO));
|
||||
s->pAudioChn = &s->AudioInfo.pAudioGroups[0].pAudioChannels[0];
|
||||
s->pAudioChn->Mode = s->AudioInfo.pAudioGroups[0].pAudioChannels[1].Mode=VHD_AM_STEREO;
|
||||
if(audio_input_channels == 1) {
|
||||
s->pAudioChn->Mode = s->AudioInfo.pAudioGroups[0].pAudioChannels[1].Mode=VHD_AM_MONO;
|
||||
} else if(audio_input_channels == 2) {
|
||||
s->pAudioChn->Mode = s->AudioInfo.pAudioGroups[0].pAudioChannels[1].Mode=VHD_AM_STEREO;
|
||||
} else abort();
|
||||
s->pAudioChn->BufferFormat = s->AudioInfo.pAudioGroups[0].pAudioChannels[1].BufferFormat=VHD_AF_24;
|
||||
|
||||
/* Get the biggest audio frame size */
|
||||
@@ -408,6 +417,7 @@ vidcap_deltacast_init(char *init_fmt, unsigned int flags)
|
||||
}
|
||||
|
||||
return s;
|
||||
no_audio:
|
||||
stream_failed:
|
||||
no_pixfmt:
|
||||
no_format:
|
||||
|
||||
@@ -424,13 +424,15 @@ void *vidcap_dvs_init(char *fmt, unsigned int flags)
|
||||
if (res != SV_OK) {
|
||||
goto error;
|
||||
}
|
||||
/* TODO: figure out real channels number
|
||||
* for now it suffices stereo */
|
||||
res = sv_option(s->sv, SV_OPTION_AUDIOCHANNELS, 1);
|
||||
if(audio_channel_count != 2) {
|
||||
fprintf(stderr, "[DVS cap.] Invalid channel count %d. Currently only 2 channels are supported.\n");
|
||||
goto error;
|
||||
}
|
||||
res = sv_option(s->sv, SV_OPTION_AUDIOCHANNELS, audio_channel_count / 2); // in pairs
|
||||
if (res != SV_OK) {
|
||||
goto error;
|
||||
}
|
||||
s->audio.ch_count = 2;
|
||||
s->audio.ch_count = audio_input_channels;
|
||||
|
||||
sv_query(s->sv, SV_QUERY_AUDIOBITS, 0, &i);
|
||||
s->audio.bps = i / 8;
|
||||
|
||||
@@ -329,6 +329,16 @@ static int open_audio(struct vidcap_quad_state *s) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
unsigned long int channels;
|
||||
snprintf (name, sizeof (name), fmt, num, "channels");
|
||||
if (util_strtoul (name, &channels) < 0) {
|
||||
fprintf (stderr, "%s: ", audio_dev);
|
||||
perror ("unable to get the receiver buffer size");
|
||||
return -1;
|
||||
}
|
||||
|
||||
s->audio.ch_count = channels;
|
||||
|
||||
/* Allocate some memory */
|
||||
/*if ((s->audio.data = (char *)malloc (s->audio_bufsize)) == NULL) {
|
||||
fprintf (stderr, "%s: ", audio_dev);
|
||||
@@ -373,11 +383,17 @@ vidcap_quad_init(char *init_fmt, unsigned int flags)
|
||||
|
||||
s->audio.bps = QUAD_AUDIO_BPS;
|
||||
s->audio.sample_rate = QUAD_AUDIO_SAMPLE_RATE;
|
||||
s->audio.ch_count = QUAD_AUDIO_CHANNELS;
|
||||
//s->audio.ch_count = QUAD_AUDIO_CHANNELS;
|
||||
s->audio.data = (char *) malloc(QUAD_AUDIO_BUFSIZE);
|
||||
s->audio_bytes_read = 0u;
|
||||
if(open_audio(s) != 0)
|
||||
s->grab_audio = FALSE;
|
||||
if(s->audio.ch_count != audio_input_channels) {
|
||||
fprintf(stderr, "[Quad] Unable to grab %d channels. Current value provided by driver is %d. "
|
||||
"You can change this value by writing 2,4,6 or 8 to /sys/class/sdiaudio/sdiaudiotx1/bufsize.\n",
|
||||
audio_input_channels, s->audio.ch_count);
|
||||
s->grab_audio = FALSE;
|
||||
}
|
||||
} else {
|
||||
s->grab_audio = FALSE;
|
||||
}
|
||||
|
||||
@@ -784,6 +784,10 @@ static int qt_open_grabber(struct qt_grabber_state *s, char *fmt)
|
||||
&ch_count, &compression);
|
||||
s->audio.bps = bps;
|
||||
s->audio.ch_count = ch_count;
|
||||
if(audio_input_channels != ch_count) {
|
||||
fprintf(stderr, "[QuickTime cap.] Ignoring requested channel count. Capturing %d instead!!!\n",
|
||||
ch_count);
|
||||
}
|
||||
|
||||
if(ret != noErr) {
|
||||
fprintf(stderr, "Quicktime: failed to get audio properties");
|
||||
|
||||
@@ -55,11 +55,11 @@
|
||||
#include "config_win32.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "host.h"
|
||||
#include "tv.h"
|
||||
#include "video_codec.h"
|
||||
#include "video_capture.h"
|
||||
#include "video_capture/testcard.h"
|
||||
#include "host.h"
|
||||
#include "song1.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -71,10 +71,9 @@
|
||||
|
||||
#define AUDIO_SAMPLE_RATE 48000
|
||||
#define AUDIO_BPS 2
|
||||
#define AUDIO_CHANNELS 2
|
||||
#define BUFFER_SEC 1
|
||||
#define AUDIO_BUFFER_SIZE (AUDIO_SAMPLE_RATE * AUDIO_BPS * \
|
||||
AUDIO_CHANNELS * BUFFER_SEC)
|
||||
audio_input_channels * BUFFER_SEC)
|
||||
|
||||
struct testcard_rect {
|
||||
int x, y, w, h;
|
||||
@@ -342,7 +341,7 @@ static int configure_audio(struct testcard_state *s)
|
||||
SDL_Init(SDL_INIT_AUDIO);
|
||||
|
||||
if( Mix_OpenAudio( AUDIO_SAMPLE_RATE, AUDIO_S16LSB,
|
||||
AUDIO_CHANNELS, 4096 ) == -1 ) {
|
||||
audio_input_channels, 4096 ) == -1 ) {
|
||||
fprintf(stderr,"[testcard] error initalizing sound\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -364,7 +363,7 @@ static int configure_audio(struct testcard_state *s)
|
||||
s->audio_start = 0;
|
||||
s->audio_end = 0;
|
||||
s->audio.bps = AUDIO_BPS;
|
||||
s->audio.ch_count = AUDIO_CHANNELS;
|
||||
s->audio.ch_count = audio_input_channels;
|
||||
s->audio.sample_rate = AUDIO_SAMPLE_RATE;
|
||||
|
||||
// register grab as a postmix processor
|
||||
|
||||
@@ -76,10 +76,9 @@
|
||||
|
||||
#define AUDIO_SAMPLE_RATE 48000
|
||||
#define AUDIO_BPS 2
|
||||
#define AUDIO_CHANNELS 2
|
||||
#define BUFFER_SEC 1
|
||||
#define AUDIO_BUFFER_SIZE (AUDIO_SAMPLE_RATE * AUDIO_BPS * \
|
||||
AUDIO_CHANNELS * BUFFER_SEC)
|
||||
audio_input_channels * BUFFER_SEC)
|
||||
|
||||
void * vidcap_testcard2_thread(void *args);
|
||||
void rgb2yuv422(unsigned char *in, unsigned int width, unsigned int height);
|
||||
@@ -123,14 +122,14 @@ static int configure_audio(struct testcard_state2 *s)
|
||||
|
||||
s->audio_tone = calloc(1, AUDIO_BUFFER_SIZE /* 1 sec */);
|
||||
short int * data = (short int *) s->audio_tone;
|
||||
for( i=0; i < AUDIO_BUFFER_SIZE/2; i+=2 )
|
||||
for( i=0; i < (int) AUDIO_BUFFER_SIZE/2; i+=2 )
|
||||
{
|
||||
data[i] = data[i+1] = (float) sin( ((double)i/(double)200) * M_PI * 2. ) * SHRT_MAX;
|
||||
}
|
||||
|
||||
|
||||
s->audio.bps = AUDIO_BPS;
|
||||
s->audio.ch_count = AUDIO_CHANNELS;
|
||||
s->audio.ch_count = audio_input_channels;
|
||||
s->audio.sample_rate = AUDIO_SAMPLE_RATE;
|
||||
|
||||
printf("[testcard2] playing audio\n");
|
||||
@@ -519,7 +518,7 @@ static void grab_audio(struct testcard_state2 *s)
|
||||
|
||||
s->audio_remained = (seconds + s->audio_remained) * AUDIO_SAMPLE_RATE - s->audio.data_len;
|
||||
s->audio_remained /= AUDIO_SAMPLE_RATE;
|
||||
s->audio.data_len *= AUDIO_CHANNELS * AUDIO_BPS;
|
||||
s->audio.data_len *= audio_input_channels * AUDIO_BPS;
|
||||
|
||||
s->last_audio_time = curr_time;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user