mirror of
https://github.com/jojo61/vdr-plugin-softhdcuvid.git
synced 2025-03-01 10:39:28 +00:00
Fixed ATTA and DETA
Cleanup some code Testet GRAB funktions
This commit is contained in:
parent
40115f4fc6
commit
f80d757704
149
audio.c
149
audio.c
@ -1035,8 +1035,7 @@ static snd_pcm_t *AlsaOpenPCM(int passthrough)
|
|||||||
}
|
}
|
||||||
// open none blocking; if device is already used, we don't want wait
|
// open none blocking; if device is already used, we don't want wait
|
||||||
if ((err =
|
if ((err =
|
||||||
snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK,
|
snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK,SND_PCM_NONBLOCK)) < 0) {
|
||||||
SND_PCM_NONBLOCK)) < 0) {
|
|
||||||
Error(_("audio/alsa: playback open '%s' error: %s\n"), device, snd_strerror(err));
|
Error(_("audio/alsa: playback open '%s' error: %s\n"), device, snd_strerror(err));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1247,20 +1246,20 @@ static int AlsaSetup(int *freq, int *channels, int passthrough)
|
|||||||
SND_PCM_ACCESS_RW_INTERLEAVED, *channels, *freq, 1,
|
SND_PCM_ACCESS_RW_INTERLEAVED, *channels, *freq, 1,
|
||||||
72 * 1000))) {
|
72 * 1000))) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if ( err == -EBADFD ) {
|
if ( err == -EBADFD ) {
|
||||||
snd_pcm_close(AlsaPCMHandle);
|
snd_pcm_close(AlsaPCMHandle);
|
||||||
AlsaPCMHandle = NULL;
|
AlsaPCMHandle = NULL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!AudioDoingInit) {
|
if (!AudioDoingInit) {
|
||||||
Error(_("audio/alsa: set params error: %s\n"),
|
Error(_("audio/alsa: set params error: %s\n"),
|
||||||
snd_strerror(err));
|
snd_strerror(err));
|
||||||
}
|
}
|
||||||
// FIXME: must stop sound, AudioChannels ... invalid
|
// FIXME: must stop sound, AudioChannels ... invalid
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1303,12 +1302,12 @@ static int AlsaSetup(int *freq, int *channels, int passthrough)
|
|||||||
|
|
||||||
snd_pcm_get_params(AlsaPCMHandle, &buffer_size, &period_size);
|
snd_pcm_get_params(AlsaPCMHandle, &buffer_size, &period_size);
|
||||||
Debug(3, "audio/alsa: buffer size %lu %zdms, period size %lu %zdms\n",
|
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),
|
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));
|
period_size) * 1000 / (*freq * *channels * AudioBytesProSample));
|
||||||
Debug(3, "audio/alsa: state %s\n",
|
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);
|
AudioStartThreshold = snd_pcm_frames_to_bytes(AlsaPCMHandle, period_size);
|
||||||
// buffer time/delay in ms
|
// buffer time/delay in ms
|
||||||
@ -1317,7 +1316,7 @@ static int AlsaSetup(int *freq, int *channels, int passthrough)
|
|||||||
delay += VideoAudioDelay / 90;
|
delay += VideoAudioDelay / 90;
|
||||||
}
|
}
|
||||||
if (AudioStartThreshold <
|
if (AudioStartThreshold <
|
||||||
(*freq * *channels * AudioBytesProSample * delay) / 1000U) {
|
(*freq * *channels * AudioBytesProSample * delay) / 1000U) {
|
||||||
AudioStartThreshold = (*freq * *channels * AudioBytesProSample * delay) / 1000U;
|
AudioStartThreshold = (*freq * *channels * AudioBytesProSample * delay) / 1000U;
|
||||||
}
|
}
|
||||||
// no bigger, than 1/3 the buffer
|
// no bigger, than 1/3 the buffer
|
||||||
@ -2810,12 +2809,12 @@ void AudioSetStereoDescent(int delta)
|
|||||||
void AudioSetDevice(const char *device)
|
void AudioSetDevice(const char *device)
|
||||||
{
|
{
|
||||||
if (!AudioModuleName) {
|
if (!AudioModuleName) {
|
||||||
AudioModuleName = "alsa"; // detect alsa/OSS
|
AudioModuleName = "alsa"; // detect alsa/OSS
|
||||||
if (!device[0]) {
|
if (!device[0]) {
|
||||||
AudioModuleName = "noop";
|
AudioModuleName = "noop";
|
||||||
} else if (device[0] == '/') {
|
} else if (device[0] == '/') {
|
||||||
AudioModuleName = "oss";
|
AudioModuleName = "oss";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AudioPCMDevice = device;
|
AudioPCMDevice = device;
|
||||||
}
|
}
|
||||||
@ -2830,12 +2829,12 @@ void AudioSetDevice(const char *device)
|
|||||||
void AudioSetPassthroughDevice(const char *device)
|
void AudioSetPassthroughDevice(const char *device)
|
||||||
{
|
{
|
||||||
if (!AudioModuleName) {
|
if (!AudioModuleName) {
|
||||||
AudioModuleName = "alsa"; // detect alsa/OSS
|
AudioModuleName = "alsa"; // detect alsa/OSS
|
||||||
if (!device[0]) {
|
if (!device[0]) {
|
||||||
AudioModuleName = "noop";
|
AudioModuleName = "noop";
|
||||||
} else if (device[0] == '/') {
|
} else if (device[0] == '/') {
|
||||||
AudioModuleName = "oss";
|
AudioModuleName = "oss";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AudioPassthroughDevice = device;
|
AudioPassthroughDevice = device;
|
||||||
}
|
}
|
||||||
@ -2860,9 +2859,9 @@ void AudioSetChannel(const char *channel)
|
|||||||
void AudioSetAutoAES(int onoff)
|
void AudioSetAutoAES(int onoff)
|
||||||
{
|
{
|
||||||
if (onoff < 0) {
|
if (onoff < 0) {
|
||||||
AudioAppendAES ^= 1;
|
AudioAppendAES ^= 1;
|
||||||
} else {
|
} else {
|
||||||
AudioAppendAES = onoff;
|
AudioAppendAES = onoff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2886,17 +2885,17 @@ void AudioInit(void)
|
|||||||
name = "alsa";
|
name = "alsa";
|
||||||
#endif
|
#endif
|
||||||
if (AudioModuleName) {
|
if (AudioModuleName) {
|
||||||
name = AudioModuleName;
|
name = AudioModuleName;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// search selected audio module.
|
// search selected audio module.
|
||||||
//
|
//
|
||||||
for (u = 0; u < sizeof(AudioModules) / sizeof(*AudioModules); ++u) {
|
for (u = 0; u < sizeof(AudioModules) / sizeof(*AudioModules); ++u) {
|
||||||
if (!strcasecmp(name, AudioModules[u]->Name)) {
|
if (!strcasecmp(name, AudioModules[u]->Name)) {
|
||||||
AudioUsedModule = AudioModules[u];
|
AudioUsedModule = AudioModules[u];
|
||||||
Info(_("audio: '%s' output module used\n"), AudioUsedModule->Name);
|
Info(_("audio: '%s' output module used\n"), AudioUsedModule->Name);
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Error(_("audio: '%s' output module isn't supported\n"), name);
|
Error(_("audio: '%s' output module isn't supported\n"), name);
|
||||||
AudioUsedModule = &NoopModule;
|
AudioUsedModule = &NoopModule;
|
||||||
@ -2914,53 +2913,53 @@ void AudioInit(void)
|
|||||||
freq = 44100;
|
freq = 44100;
|
||||||
AudioRatesInHw[Audio44100] = 0;
|
AudioRatesInHw[Audio44100] = 0;
|
||||||
for (chan = 1; chan < 9; ++chan) {
|
for (chan = 1; chan < 9; ++chan) {
|
||||||
int tchan;
|
int tchan;
|
||||||
int tfreq;
|
int tfreq;
|
||||||
|
|
||||||
tchan = chan;
|
tchan = chan;
|
||||||
tfreq = freq;
|
tfreq = freq;
|
||||||
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
|
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
|
||||||
AudioChannelsInHw[chan] = 0;
|
AudioChannelsInHw[chan] = 0;
|
||||||
} else {
|
} else {
|
||||||
AudioChannelsInHw[chan] = chan;
|
AudioChannelsInHw[chan] = chan;
|
||||||
AudioRatesInHw[Audio44100] |= (1 << chan);
|
AudioRatesInHw[Audio44100] |= (1 << chan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
freq = 48000;
|
freq = 48000;
|
||||||
AudioRatesInHw[Audio48000] = 0;
|
AudioRatesInHw[Audio48000] = 0;
|
||||||
for (chan = 1; chan < 9; ++chan) {
|
for (chan = 1; chan < 9; ++chan) {
|
||||||
int tchan;
|
int tchan;
|
||||||
int tfreq;
|
int tfreq;
|
||||||
|
|
||||||
if (!AudioChannelsInHw[chan]) {
|
if (!AudioChannelsInHw[chan]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tchan = chan;
|
tchan = chan;
|
||||||
tfreq = freq;
|
tfreq = freq;
|
||||||
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
|
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
|
||||||
//AudioChannelsInHw[chan] = 0;
|
//AudioChannelsInHw[chan] = 0;
|
||||||
} else {
|
} else {
|
||||||
AudioChannelsInHw[chan] = chan;
|
AudioChannelsInHw[chan] = chan;
|
||||||
AudioRatesInHw[Audio48000] |= (1 << chan);
|
AudioRatesInHw[Audio48000] |= (1 << chan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
freq = 192000;
|
freq = 192000;
|
||||||
AudioRatesInHw[Audio192000] = 0;
|
AudioRatesInHw[Audio192000] = 0;
|
||||||
for (chan = 1; chan < 9; ++chan) {
|
for (chan = 1; chan < 9; ++chan) {
|
||||||
int tchan;
|
int tchan;
|
||||||
int tfreq;
|
int tfreq;
|
||||||
|
|
||||||
if (!AudioChannelsInHw[chan]) {
|
if (!AudioChannelsInHw[chan]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tchan = chan;
|
tchan = chan;
|
||||||
tfreq = freq;
|
tfreq = freq;
|
||||||
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
|
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
|
||||||
//AudioChannelsInHw[chan] = 0;
|
//AudioChannelsInHw[chan] = 0;
|
||||||
} else {
|
} else {
|
||||||
AudioChannelsInHw[chan] = chan;
|
AudioChannelsInHw[chan] = chan;
|
||||||
AudioRatesInHw[Audio192000] |= (1 << chan);
|
AudioRatesInHw[Audio192000] |= (1 << chan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// build channel support and conversion table
|
// build channel support and conversion table
|
||||||
for (u = 0; u < AudioRatesMax; ++u) {
|
for (u = 0; u < AudioRatesMax; ++u) {
|
||||||
|
12
codec.c
12
codec.c
@ -439,17 +439,19 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
|
|||||||
*/
|
*/
|
||||||
void CodecVideoClose(VideoDecoder *video_decoder)
|
void CodecVideoClose(VideoDecoder *video_decoder)
|
||||||
{
|
{
|
||||||
|
AVFrame *frame;
|
||||||
// FIXME: play buffered data
|
// FIXME: play buffered data
|
||||||
// av_frame_free(&video_decoder->Frame); // callee does checks
|
// av_frame_free(&video_decoder->Frame); // callee does checks
|
||||||
|
|
||||||
Debug(3,"CodecVideoClose\n");
|
Debug(3,"CodecVideoClose\n");
|
||||||
if (video_decoder->VideoCtx) {
|
if (video_decoder->VideoCtx) {
|
||||||
pthread_mutex_lock(&CodecLockMutex);
|
pthread_mutex_lock(&CodecLockMutex);
|
||||||
|
#if 1
|
||||||
// avcodec_send_packet(video_ctx, NULL);
|
frame = av_frame_alloc();
|
||||||
// while (avcodec_receive_frame(video_ctx,video_decoder->Frame) >= 0);
|
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);
|
avcodec_close(video_decoder->VideoCtx);
|
||||||
av_freep(&video_decoder->VideoCtx);
|
av_freep(&video_decoder->VideoCtx);
|
||||||
pthread_mutex_unlock(&CodecLockMutex);
|
pthread_mutex_unlock(&CodecLockMutex);
|
||||||
|
21
softhddev.c
21
softhddev.c
@ -1910,23 +1910,22 @@ int VideoDecodeInput(VideoStream * stream)
|
|||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
// clearing for normal channel switch has no advantage
|
// clearing for normal channel switch has no advantage
|
||||||
if (stream->ClearClose /*|| stream->ClosingStream */ ) {
|
if (stream->ClearClose || stream->ClosingStream ) {
|
||||||
int f;
|
int f;
|
||||||
|
|
||||||
// FIXME: during replay all packets are always checked
|
// FIXME: during replay all packets are always checked
|
||||||
|
|
||||||
// flush buffers, if close is in the queue
|
// flush buffers, if close is in the queue
|
||||||
for (f = 0; f < filled; ++f) {
|
for (f = 0; f < filled; ++f) {
|
||||||
if (stream->CodecIDRb[(stream->PacketRead + f) % VIDEO_PACKET_MAX]
|
if (stream->CodecIDRb[(stream->PacketRead + f) % VIDEO_PACKET_MAX] == AV_CODEC_ID_NONE) {
|
||||||
== AV_CODEC_ID_NONE) {
|
if (f) {
|
||||||
if (f) {
|
Debug(3, "video: cleared upto close\n");
|
||||||
Debug(3, "video: cleared upto close\n");
|
atomic_sub(f, &stream->PacketsFilled);
|
||||||
atomic_sub(f, &stream->PacketsFilled);
|
stream->PacketRead =
|
||||||
stream->PacketRead =
|
(stream->PacketRead + f) % VIDEO_PACKET_MAX;
|
||||||
(stream->PacketRead + f) % VIDEO_PACKET_MAX;
|
stream->ClearClose = 0;
|
||||||
stream->ClearClose = 0;
|
}
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stream->ClosingStream = 0;
|
stream->ClosingStream = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user