Fixed ATTA and DETA

Cleanup some code
Testet GRAB funktions
This commit is contained in:
jojo61 2019-10-20 14:48:28 +02:00
parent 40115f4fc6
commit f80d757704
4 changed files with 309 additions and 533 deletions

149
audio.c
View File

@ -1035,8 +1035,7 @@ static snd_pcm_t *AlsaOpenPCM(int passthrough)
}
// open none blocking; if device is already used, we don't want wait
if ((err =
snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK,
SND_PCM_NONBLOCK)) < 0) {
snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK,SND_PCM_NONBLOCK)) < 0) {
Error(_("audio/alsa: playback open '%s' error: %s\n"), device, snd_strerror(err));
return NULL;
}
@ -1247,20 +1246,20 @@ static int AlsaSetup(int *freq, int *channels, int passthrough)
SND_PCM_ACCESS_RW_INTERLEAVED, *channels, *freq, 1,
72 * 1000))) {
/*
if ( err == -EBADFD ) {
snd_pcm_close(AlsaPCMHandle);
AlsaPCMHandle = NULL;
continue;
}
*/
/*
if ( err == -EBADFD ) {
snd_pcm_close(AlsaPCMHandle);
AlsaPCMHandle = NULL;
continue;
}
*/
if (!AudioDoingInit) {
Error(_("audio/alsa: set params error: %s\n"),
snd_strerror(err));
}
// FIXME: must stop sound, AudioChannels ... invalid
return -1;
if (!AudioDoingInit) {
Error(_("audio/alsa: set params error: %s\n"),
snd_strerror(err));
}
// FIXME: must stop sound, AudioChannels ... invalid
return -1;
}
}
break;
@ -1303,12 +1302,12 @@ static int AlsaSetup(int *freq, int *channels, int passthrough)
snd_pcm_get_params(AlsaPCMHandle, &buffer_size, &period_size);
Debug(3, "audio/alsa: buffer size %lu %zdms, period size %lu %zdms\n",
buffer_size, snd_pcm_frames_to_bytes(AlsaPCMHandle,
buffer_size, snd_pcm_frames_to_bytes(AlsaPCMHandle,
buffer_size) * 1000 / (*freq * *channels * AudioBytesProSample),
period_size, snd_pcm_frames_to_bytes(AlsaPCMHandle,
period_size, snd_pcm_frames_to_bytes(AlsaPCMHandle,
period_size) * 1000 / (*freq * *channels * AudioBytesProSample));
Debug(3, "audio/alsa: state %s\n",
snd_pcm_state_name(snd_pcm_state(AlsaPCMHandle)));
snd_pcm_state_name(snd_pcm_state(AlsaPCMHandle)));
AudioStartThreshold = snd_pcm_frames_to_bytes(AlsaPCMHandle, period_size);
// buffer time/delay in ms
@ -1317,7 +1316,7 @@ static int AlsaSetup(int *freq, int *channels, int passthrough)
delay += VideoAudioDelay / 90;
}
if (AudioStartThreshold <
(*freq * *channels * AudioBytesProSample * delay) / 1000U) {
(*freq * *channels * AudioBytesProSample * delay) / 1000U) {
AudioStartThreshold = (*freq * *channels * AudioBytesProSample * delay) / 1000U;
}
// no bigger, than 1/3 the buffer
@ -2810,12 +2809,12 @@ void AudioSetStereoDescent(int delta)
void AudioSetDevice(const char *device)
{
if (!AudioModuleName) {
AudioModuleName = "alsa"; // detect alsa/OSS
if (!device[0]) {
AudioModuleName = "noop";
} else if (device[0] == '/') {
AudioModuleName = "oss";
}
AudioModuleName = "alsa"; // detect alsa/OSS
if (!device[0]) {
AudioModuleName = "noop";
} else if (device[0] == '/') {
AudioModuleName = "oss";
}
}
AudioPCMDevice = device;
}
@ -2830,12 +2829,12 @@ void AudioSetDevice(const char *device)
void AudioSetPassthroughDevice(const char *device)
{
if (!AudioModuleName) {
AudioModuleName = "alsa"; // detect alsa/OSS
if (!device[0]) {
AudioModuleName = "noop";
} else if (device[0] == '/') {
AudioModuleName = "oss";
}
AudioModuleName = "alsa"; // detect alsa/OSS
if (!device[0]) {
AudioModuleName = "noop";
} else if (device[0] == '/') {
AudioModuleName = "oss";
}
}
AudioPassthroughDevice = device;
}
@ -2860,9 +2859,9 @@ void AudioSetChannel(const char *channel)
void AudioSetAutoAES(int onoff)
{
if (onoff < 0) {
AudioAppendAES ^= 1;
AudioAppendAES ^= 1;
} else {
AudioAppendAES = onoff;
AudioAppendAES = onoff;
}
}
@ -2886,17 +2885,17 @@ void AudioInit(void)
name = "alsa";
#endif
if (AudioModuleName) {
name = AudioModuleName;
name = AudioModuleName;
}
//
// search selected audio module.
//
for (u = 0; u < sizeof(AudioModules) / sizeof(*AudioModules); ++u) {
if (!strcasecmp(name, AudioModules[u]->Name)) {
AudioUsedModule = AudioModules[u];
Info(_("audio: '%s' output module used\n"), AudioUsedModule->Name);
goto found;
}
if (!strcasecmp(name, AudioModules[u]->Name)) {
AudioUsedModule = AudioModules[u];
Info(_("audio: '%s' output module used\n"), AudioUsedModule->Name);
goto found;
}
}
Error(_("audio: '%s' output module isn't supported\n"), name);
AudioUsedModule = &NoopModule;
@ -2914,53 +2913,53 @@ void AudioInit(void)
freq = 44100;
AudioRatesInHw[Audio44100] = 0;
for (chan = 1; chan < 9; ++chan) {
int tchan;
int tfreq;
int tchan;
int tfreq;
tchan = chan;
tfreq = freq;
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
AudioChannelsInHw[chan] = 0;
} else {
AudioChannelsInHw[chan] = chan;
AudioRatesInHw[Audio44100] |= (1 << chan);
}
tchan = chan;
tfreq = freq;
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
AudioChannelsInHw[chan] = 0;
} else {
AudioChannelsInHw[chan] = chan;
AudioRatesInHw[Audio44100] |= (1 << chan);
}
}
freq = 48000;
AudioRatesInHw[Audio48000] = 0;
for (chan = 1; chan < 9; ++chan) {
int tchan;
int tfreq;
int tchan;
int tfreq;
if (!AudioChannelsInHw[chan]) {
continue;
}
tchan = chan;
tfreq = freq;
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
//AudioChannelsInHw[chan] = 0;
} else {
AudioChannelsInHw[chan] = chan;
AudioRatesInHw[Audio48000] |= (1 << chan);
}
if (!AudioChannelsInHw[chan]) {
continue;
}
tchan = chan;
tfreq = freq;
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
//AudioChannelsInHw[chan] = 0;
} else {
AudioChannelsInHw[chan] = chan;
AudioRatesInHw[Audio48000] |= (1 << chan);
}
}
freq = 192000;
AudioRatesInHw[Audio192000] = 0;
for (chan = 1; chan < 9; ++chan) {
int tchan;
int tfreq;
int tchan;
int tfreq;
if (!AudioChannelsInHw[chan]) {
continue;
}
tchan = chan;
tfreq = freq;
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
//AudioChannelsInHw[chan] = 0;
} else {
AudioChannelsInHw[chan] = chan;
AudioRatesInHw[Audio192000] |= (1 << chan);
}
if (!AudioChannelsInHw[chan]) {
continue;
}
tchan = chan;
tfreq = freq;
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
//AudioChannelsInHw[chan] = 0;
} else {
AudioChannelsInHw[chan] = chan;
AudioRatesInHw[Audio192000] |= (1 << chan);
}
}
// build channel support and conversion table
for (u = 0; u < AudioRatesMax; ++u) {

12
codec.c
View File

@ -439,17 +439,19 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
*/
void CodecVideoClose(VideoDecoder *video_decoder)
{
AVFrame *frame;
// FIXME: play buffered data
// av_frame_free(&video_decoder->Frame); // callee does checks
Debug(3,"CodecVideoClose\n");
if (video_decoder->VideoCtx) {
pthread_mutex_lock(&CodecLockMutex);
// avcodec_send_packet(video_ctx, NULL);
// while (avcodec_receive_frame(video_ctx,video_decoder->Frame) >= 0);
#if 1
frame = av_frame_alloc();
avcodec_send_packet(video_decoder->VideoCtx, NULL);
while (avcodec_receive_frame(video_decoder->VideoCtx,frame) >= 0);
av_frame_free(&frame);
#endif
avcodec_close(video_decoder->VideoCtx);
av_freep(&video_decoder->VideoCtx);
pthread_mutex_unlock(&CodecLockMutex);

View File

@ -1910,23 +1910,22 @@ int VideoDecodeInput(VideoStream * stream)
}
#if 0
// clearing for normal channel switch has no advantage
if (stream->ClearClose /*|| stream->ClosingStream */ ) {
if (stream->ClearClose || stream->ClosingStream ) {
int f;
// FIXME: during replay all packets are always checked
// flush buffers, if close is in the queue
for (f = 0; f < filled; ++f) {
if (stream->CodecIDRb[(stream->PacketRead + f) % VIDEO_PACKET_MAX]
== AV_CODEC_ID_NONE) {
if (f) {
Debug(3, "video: cleared upto close\n");
atomic_sub(f, &stream->PacketsFilled);
stream->PacketRead =
(stream->PacketRead + f) % VIDEO_PACKET_MAX;
stream->ClearClose = 0;
}
break;
if (stream->CodecIDRb[(stream->PacketRead + f) % VIDEO_PACKET_MAX] == AV_CODEC_ID_NONE) {
if (f) {
Debug(3, "video: cleared upto close\n");
atomic_sub(f, &stream->PacketsFilled);
stream->PacketRead =
(stream->PacketRead + f) % VIDEO_PACKET_MAX;
stream->ClearClose = 0;
}
break;
}
}
stream->ClosingStream = 0;

660
video.c

File diff suppressed because it is too large Load Diff