libarmbox/libmipsbox: some manual code nicenings

Origin commit data
------------------
Branch: master
Commit: 6591fe32fc
Author: vanhofen <vanhofen@gmx.de>
Date: 2021-11-07 (Sun, 07 Nov 2021)

Origin message was:
------------------
- libarmbox/libmipsbox: some manual code nicenings

------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2021-11-07 00:57:01 +01:00
parent 1354bbca91
commit 502d002c21
8 changed files with 182 additions and 180 deletions

View File

@@ -17,16 +17,16 @@
#define hal_debug(args...) _hal_debug(HAL_DEBUG_AUDIO, this, args) #define hal_debug(args...) _hal_debug(HAL_DEBUG_AUDIO, this, args)
#define hal_info(args...) _hal_info(HAL_DEBUG_AUDIO, this, args) #define hal_info(args...) _hal_info(HAL_DEBUG_AUDIO, this, args)
#define fop(cmd, args...) ({ \ #define fop(cmd, args...) ({ \
int _r; \ int _r; \
if (fd >= 0) { \ if (fd >= 0) { \
if ((_r = ::cmd(fd, args)) < 0) \ if ((_r = ::cmd(fd, args)) < 0) \
hal_info(#cmd"(fd, "#args")\n");\ hal_info(#cmd"(fd, "#args")\n");\
else \ else \
hal_debug(#cmd"(fd, "#args")\n");\ hal_debug(#cmd"(fd, "#args")\n");\
} \ } \
else { _r = fd; } \ else { _r = fd; } \
_r; \ _r; \
}) })
#include <linux/soundcard.h> #include <linux/soundcard.h>
@@ -287,14 +287,14 @@ int cAudio::PrepareClipPlay(int ch, int srate, int bits, int little_endian)
{ {
if (dsp_dev) if (dsp_dev)
hal_info("%s: DSP_DEVICE is set (%s) but cannot be opened," hal_info("%s: DSP_DEVICE is set (%s) but cannot be opened,"
" fall back to /dev/dsp\n", __func__, dsp_dev); " fall back to /dev/dsp\n", __func__, dsp_dev);
dsp_dev = "/dev/dsp"; dsp_dev = "/dev/dsp";
} }
if ((!mix_dev) || (access(mix_dev, W_OK))) if ((!mix_dev) || (access(mix_dev, W_OK)))
{ {
if (mix_dev) if (mix_dev)
hal_info("%s: MIX_DEVICE is set (%s) but cannot be opened," hal_info("%s: MIX_DEVICE is set (%s) but cannot be opened,"
" fall back to /dev/mixer\n", __func__, dsp_dev); " fall back to /dev/mixer\n", __func__, dsp_dev);
mix_dev = "/dev/mixer"; mix_dev = "/dev/mixer";
} }
hal_info("cAudio::%s: dsp_dev %s mix_dev %s\n", __func__, dsp_dev, mix_dev); /* NULL mix_dev is ok */ hal_info("cAudio::%s: dsp_dev %s mix_dev %s\n", __func__, dsp_dev, mix_dev); /* NULL mix_dev is ok */
@@ -346,7 +346,7 @@ int cAudio::PrepareClipPlay(int ch, int srate, int bits, int little_endian)
if (usable == 0) if (usable == 0)
{ {
hal_info("%s: devmask: %08x stereo: %08x, no usable dev :-(\n", hal_info("%s: devmask: %08x stereo: %08x, no usable dev :-(\n",
__func__, devmask, stereo); __func__, devmask, stereo);
close(mixer_fd); close(mixer_fd);
mixer_fd = -1; mixer_fd = -1;
return 0; /* TODO: should we treat this as error? */ return 0; /* TODO: should we treat this as error? */
@@ -356,13 +356,13 @@ int cAudio::PrepareClipPlay(int ch, int srate, int bits, int little_endian)
{ {
/* TODO: this code is not yet tested as I have only single-mixer devices... */ /* TODO: this code is not yet tested as I have only single-mixer devices... */
hal_info("%s: more than one mixer control: devmask %08x stereo %08x\n" hal_info("%s: more than one mixer control: devmask %08x stereo %08x\n"
"%s: querying MIX_NUMBER environment variable...\n", "%s: querying MIX_NUMBER environment variable...\n",
__func__, devmask, stereo, __func__); __func__, devmask, stereo, __func__);
const char *tmp = getenv("MIX_NUMBER"); const char *tmp = getenv("MIX_NUMBER");
if (tmp) if (tmp)
mixer_num = atoi(tmp); mixer_num = atoi(tmp);
hal_info("%s: mixer_num is %d -> device %08x\n", hal_info("%s: mixer_num is %d -> device %08x\n",
__func__, mixer_num, (mixer_num >= 0) ? (1 << mixer_num) : 0); __func__, mixer_num, (mixer_num >= 0) ? (1 << mixer_num) : 0);
/* no error checking, you'd better know what you are doing... */ /* no error checking, you'd better know what you are doing... */
} }
else else
@@ -457,13 +457,13 @@ void cAudio::getAudioInfo(int &type, int &layer, int &freq, int &bitrate, int &m
/* this does not work, some of the values are negative?? */ /* this does not work, some of the values are negative?? */
AMPEGStatus A; AMPEGStatus A;
memcpy(&A, &i.word00, sizeof(i.word00)); memcpy(&A, &i.word00, sizeof(i.word00));
layer = A.audio_mpeg_layer; layer = A.audio_mpeg_layer;
mode = A.audio_mpeg_mode; mode = A.audio_mpeg_mode;
bitrate = A.audio_mpeg_bitrate; bitrate = A.audio_mpeg_bitrate;
switch (A.audio_mpeg_frequency) switch (A.audio_mpeg_frequency)
#endif #endif
/* layer and bitrate are not used anyway... */ /* layer and bitrate are not used anyway... */
layer = 0; //(i.word00 >> 17) & 3; layer = 0; //(i.word00 >> 17) & 3;
bitrate = 0; //(i.word00 >> 12) & 3; bitrate = 0; //(i.word00 >> 12) & 3;
switch (type) switch (type)
{ {
@@ -490,7 +490,7 @@ void cAudio::SetSRS(int /*iq_enable*/, int /*nmgr_enable*/, int /*iq_mode*/, int
void cAudio::SetHdmiDD(bool enable) void cAudio::SetHdmiDD(bool enable)
{ {
const char *opt[] = { "downmix", "passthrough" }; const char *opt[] = { "downmix", "passthrough" };
hal_debug("%s %d\n", __func__, enable); hal_debug("%s %d\n", __func__, enable);
proc_put("/proc/stb/audio/ac3", opt[enable], strlen(opt[enable])); proc_put("/proc/stb/audio/ac3", opt[enable], strlen(opt[enable]));
} }
@@ -498,7 +498,7 @@ void cAudio::SetHdmiDD(bool enable)
void cAudio::SetSpdifDD(bool enable) void cAudio::SetSpdifDD(bool enable)
{ {
//using this function for dts passthrough //using this function for dts passthrough
const char *opt[] = { "downmix", "passthrough" }; const char *opt[] = { "downmix", "passthrough" };
hal_debug("%s %d\n", __func__, enable); hal_debug("%s %d\n", __func__, enable);
proc_put("/proc/stb/audio/dts", opt[enable], strlen(opt[enable])); proc_put("/proc/stb/audio/dts", opt[enable], strlen(opt[enable]));
} }
@@ -513,7 +513,7 @@ void cAudio::EnableAnalogOut(bool enable)
hal_debug("%s %d\n", __FUNCTION__, enable); hal_debug("%s %d\n", __FUNCTION__, enable);
} }
#define AUDIO_BYPASS_ON 0 #define AUDIO_BYPASS_ON 0
#define AUDIO_BYPASS_OFF 1 #define AUDIO_BYPASS_OFF 1
void cAudio::setBypassMode(bool disable) void cAudio::setBypassMode(bool disable)
{ {

View File

@@ -51,7 +51,7 @@ extern cVideo *videoDecoder;
#define dmx_err(_errfmt, _errstr, _revents) do { \ #define dmx_err(_errfmt, _errstr, _revents) do { \
hal_info("%s " _errfmt " fd:%d, ev:0x%x %s pid:0x%04hx flt:0x%02hx\n", \ hal_info("%s " _errfmt " fd:%d, ev:0x%x %s pid:0x%04hx flt:0x%02hx\n", \
__func__, _errstr, fd, _revents, DMX_T[dmx_type], pid, flt); \ __func__, _errstr, fd, _revents, DMX_T[dmx_type], pid, flt); \
} while(0); } while(0);
cDemux *videoDemux = NULL; cDemux *videoDemux = NULL;
@@ -185,7 +185,7 @@ static bool _open(cDemux *thiz, int num, int &fd, int &last_source, DMX_CHANNEL_
{ {
/* we changed source -> close and reopen the fd */ /* we changed source -> close and reopen the fd */
hal_debug_z("%s #%d: FD ALREADY OPENED fd = %d lastsource %d devnum %d\n", hal_debug_z("%s #%d: FD ALREADY OPENED fd = %d lastsource %d devnum %d\n",
__func__, num, fd, last_source, devnum); __func__, num, fd, last_source, devnum);
close(fd); close(fd);
} }
@@ -198,8 +198,8 @@ static bool _open(cDemux *thiz, int num, int &fd, int &last_source, DMX_CHANNEL_
hal_info_z("%s %s: %m\n", __FUNCTION__, devname(0, devnum)); hal_info_z("%s %s: %m\n", __FUNCTION__, devname(0, devnum));
return false; return false;
} }
hal_debug_z("%s #%d pes_type: %s(%d), uBufferSize: %d fd: %d\n", __func__, hal_debug_z("%s #%d pes_type: %s(%d), uBufferSize: %d fd: %d\n",
num, DMX_T[dmx_type], dmx_type, buffersize, fd); __func__, num, DMX_T[dmx_type], dmx_type, buffersize, fd);
/* this would actually need locking, but the worst that weill happen is, that /* this would actually need locking, but the worst that weill happen is, that
* we'll DMX_SET_SOURCE twice per device, so don't bother... */ * we'll DMX_SET_SOURCE twice per device, so don't bother... */
@@ -214,7 +214,7 @@ static bool _open(cDemux *thiz, int num, int &fd, int &last_source, DMX_CHANNEL_
init[devnum] = true; init[devnum] = true;
} }
if (buffersize == 0) if (buffersize == 0)
buffersize = 0xffff; // may or may not be reasonable --martii buffersize = 0xffff; // may or may not be reasonable --martii
if (buffersize > 0) if (buffersize > 0)
{ {
/* probably uBufferSize == 0 means "use default size". TODO: find a reasonable default */ /* probably uBufferSize == 0 means "use default size". TODO: find a reasonable default */
@@ -270,7 +270,7 @@ int cDemux::Read(unsigned char *buff, int len, int timeout)
#if 0 #if 0
if (len != 4095 && timeout != 10) if (len != 4095 && timeout != 10)
fprintf(stderr, "cDemux::%s #%d fd: %d type: %s len: %d timeout: %d\n", fprintf(stderr, "cDemux::%s #%d fd: %d type: %s len: %d timeout: %d\n",
__FUNCTION__, num, fd, DMX_T[dmx_type], len, timeout); __FUNCTION__, num, fd, DMX_T[dmx_type], len, timeout);
#endif #endif
if (fd < 0) if (fd < 0)
{ {
@@ -339,7 +339,7 @@ retry:
return 0; return 0;
} }
} }
if (ufds.fd != fd) /* does this ever happen? and if, is it harmful? */ if (ufds.fd != fd) /* does this ever happen? and if, is it harmful? */
{ {
/* read(-1,...) will just return EBADF anyway... */ /* read(-1,...) will just return EBADF anyway... */
hal_info("%s:2 ========== fd has changed, %d->%d ==========\n", __func__, ufds.fd, fd); hal_info("%s:2 ========== fd has changed, %d->%d ==========\n", __func__, ufds.fd, fd);
@@ -355,8 +355,8 @@ retry:
} }
bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filter, bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filter,
const unsigned char *const mask, int len, int timeout, const unsigned char *const mask, int len, int timeout,
const unsigned char *const negmask) const unsigned char *const negmask)
{ {
struct dmx_sct_filter_params s_flt; struct dmx_sct_filter_params s_flt;
memset(&s_flt, 0, sizeof(s_flt)); memset(&s_flt, 0, sizeof(s_flt));
@@ -373,7 +373,7 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filte
s_flt.pid = pid; s_flt.pid = pid;
s_flt.timeout = timeout; s_flt.timeout = timeout;
memcpy(s_flt.filter.filter, filter, len); memcpy(s_flt.filter.filter, filter, len);
memcpy(s_flt.filter.mask, mask, len); memcpy(s_flt.filter.mask, mask, len);
if (negmask != NULL) if (negmask != NULL)
memcpy(s_flt.filter.mode, negmask, len); memcpy(s_flt.filter.mode, negmask, len);
@@ -424,7 +424,7 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filte
case 0x70: /* time_date_section */ case 0x70: /* time_date_section */
s_flt.flags &= ~DMX_CHECK_CRC; /* section has no CRC */ s_flt.flags &= ~DMX_CHECK_CRC; /* section has no CRC */
s_flt.flags |= DMX_ONESHOT; s_flt.flags |= DMX_ONESHOT;
//s_flt.pid = 0x0014; //s_flt.pid = 0x0014;
to = 30000; to = 30000;
break; break;
case 0x71: /* running_status_section */ case 0x71: /* running_status_section */
@@ -437,7 +437,7 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filte
break; break;
case 0x73: /* time_offset_section */ case 0x73: /* time_offset_section */
s_flt.flags |= DMX_ONESHOT; s_flt.flags |= DMX_ONESHOT;
//s_flt.pid = 0x0014; //s_flt.pid = 0x0014;
to = 30000; to = 30000;
break; break;
case 0x74: /* application_information_section */ case 0x74: /* application_information_section */
@@ -465,8 +465,8 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filte
if (timeout == 0 && negmask == NULL) if (timeout == 0 && negmask == NULL)
s_flt.timeout = to; s_flt.timeout = to;
hal_debug("%s #%d pid:0x%04hx fd:%d type:%s len:%d to:%d flags:%x flt[0]:%02x\n", __func__, num, hal_debug("%s #%d pid:0x%04hx fd:%d type:%s len:%d to:%d flags:%x flt[0]:%02x\n",
pid, fd, DMX_T[dmx_type], len, s_flt.timeout, s_flt.flags, s_flt.filter.filter[0]); __func__, num, pid, fd, DMX_T[dmx_type], len, s_flt.timeout, s_flt.flags, s_flt.filter.filter[0]);
if (debuglevel == 2) if (debuglevel == 2)
{ {
@@ -474,10 +474,10 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filte
for (int i = 0; i < len; i++) fprintf(stderr, "%02hhx ", s_flt.filter.filter[i]); for (int i = 0; i < len; i++) fprintf(stderr, "%02hhx ", s_flt.filter.filter[i]);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
fprintf(stderr, "mask: "); fprintf(stderr, "mask: ");
for (int i = 0; i < len; i++) fprintf(stderr, "%02hhx ", s_flt.filter.mask [i]); for (int i = 0; i < len; i++) fprintf(stderr, "%02hhx ", s_flt.filter.mask[i]);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
fprintf(stderr, "mode: "); fprintf(stderr, "mode: ");
for (int i = 0; i < len; i++) fprintf(stderr, "%02hhx ", s_flt.filter.mode [i]); for (int i = 0; i < len; i++) fprintf(stderr, "%02hhx ", s_flt.filter.mode[i]);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
@@ -497,7 +497,7 @@ bool cDemux::pesFilter(const unsigned short _pid)
* this check originally is from tuxbox cvs but I'm not sure * this check originally is from tuxbox cvs but I'm not sure
* what it is good for... * what it is good for...
if (pid <= 0x0001 && dmx_type != DMX_PCR_ONLY_CHANNEL) if (pid <= 0x0001 && dmx_type != DMX_PCR_ONLY_CHANNEL)
return false; return false;
*/ */
if ((pid >= 0x0002 && pid <= 0x000f) || pid >= 0x1fff) if ((pid >= 0x0002 && pid <= 0x000f) || pid >= 0x1fff)
return false; return false;
@@ -507,10 +507,10 @@ bool cDemux::pesFilter(const unsigned short _pid)
_open(this, num, fd, P->last_source, dmx_type, buffersize); _open(this, num, fd, P->last_source, dmx_type, buffersize);
memset(&p_flt, 0, sizeof(p_flt)); memset(&p_flt, 0, sizeof(p_flt));
p_flt.pid = pid; p_flt.pid = pid;
p_flt.input = DMX_IN_FRONTEND; p_flt.input = DMX_IN_FRONTEND;
p_flt.output = DMX_OUT_DECODER; p_flt.output = DMX_OUT_DECODER;
p_flt.flags = 0; p_flt.flags = 0;
switch (dmx_type) switch (dmx_type)
{ {
@@ -534,7 +534,7 @@ bool cDemux::pesFilter(const unsigned short _pid)
break; break;
case DMX_PES_CHANNEL: case DMX_PES_CHANNEL:
p_flt.pes_type = DMX_PES_OTHER; p_flt.pes_type = DMX_PES_OTHER;
p_flt.output = DMX_OUT_TAP; p_flt.output = DMX_OUT_TAP;
break; break;
#if 0 #if 0
case DMX_PSI_CHANNEL: case DMX_PSI_CHANNEL:
@@ -542,7 +542,7 @@ bool cDemux::pesFilter(const unsigned short _pid)
#endif #endif
case DMX_TP_CHANNEL: case DMX_TP_CHANNEL:
p_flt.pes_type = DMX_PES_OTHER; p_flt.pes_type = DMX_PES_OTHER;
p_flt.output = DMX_OUT_TSDEMUX_TAP; p_flt.output = DMX_OUT_TSDEMUX_TAP;
break; break;
case DMX_PCR_ONLY_CHANNEL: case DMX_PCR_ONLY_CHANNEL:
switch (num) switch (num)

View File

@@ -52,24 +52,24 @@
#define hal_debug_c(args...) _hal_debug(HAL_DEBUG_INIT, NULL, args) #define hal_debug_c(args...) _hal_debug(HAL_DEBUG_INIT, NULL, args)
#define hal_info_c(args...) _hal_info(HAL_DEBUG_INIT, NULL, args) #define hal_info_c(args...) _hal_info(HAL_DEBUG_INIT, NULL, args)
#define fop(cmd, args...) ({ \ #define fop(cmd, args...) ({ \
int _r; \ int _r; \
if (fd >= 0) { \ if (fd >= 0) { \
if ((_r = ::cmd(fd, args)) < 0) \ if ((_r = ::cmd(fd, args)) < 0) \
hal_info(#cmd"(fd, "#args")\n"); \ hal_info(#cmd"(fd, "#args")\n");\
else \ else \
hal_debug(#cmd"(fd, "#args")\n");\ hal_debug(#cmd"(fd, "#args")\n");\
} \ } \
else { _r = fd; } \ else { _r = fd; } \
_r; \ _r; \
}) })
#define CEC_FALLBACK_DEVICE "/dev/cec0" #define CEC_FALLBACK_DEVICE "/dev/cec0"
#define CEC_HDMIDEV "/dev/hdmi_cec" #define CEC_HDMIDEV "/dev/hdmi_cec"
#if BOXMODEL_H7 #if BOXMODEL_H7
#define RC_DEVICE "/dev/input/event2" #define RC_DEVICE "/dev/input/event2"
#else #else
#define RC_DEVICE "/dev/input/event1" #define RC_DEVICE "/dev/input/event1"
#endif #endif
hdmi_cec *hdmi_cec::hdmi_cec_instance = NULL; hdmi_cec *hdmi_cec::hdmi_cec_instance = NULL;
@@ -689,9 +689,7 @@ void hdmi_cec::Receive(int what)
case CEC_OPCODE_DEVICE_VENDOR_ID: case CEC_OPCODE_DEVICE_VENDOR_ID:
case CEC_OPCODE_VENDOR_COMMAND_WITH_ID: case CEC_OPCODE_VENDOR_COMMAND_WITH_ID:
{ {
uint64_t iVendorId = ((uint64_t)rxmessage.data[1] << 16) + uint64_t iVendorId = ((uint64_t)rxmessage.data[1] << 16) + ((uint64_t)rxmessage.data[2] << 8) + (uint64_t)rxmessage.data[3];
((uint64_t)rxmessage.data[2] << 8) +
(uint64_t)rxmessage.data[3];
hal_info(GREEN "[CEC] decoded message '%s' (%s)\n" NORMAL, ToString((cec_opcode)rxmessage.opcode), ToString((cec_vendor_id)iVendorId)); hal_info(GREEN "[CEC] decoded message '%s' (%s)\n" NORMAL, ToString((cec_opcode)rxmessage.opcode), ToString((cec_vendor_id)iVendorId));
break; break;
} }

View File

@@ -27,7 +27,7 @@ void hal_api_init()
if (!initialized) if (!initialized)
{ {
cCpuFreqManager f; cCpuFreqManager f;
f.SetCpuFreq(0); /* CPUFREQ == 0 is the trigger for leaving standby */ f.SetCpuFreq(0); /* CPUFREQ == 0 is the trigger for leaving standby */
char buffer[64]; char buffer[64];
sprintf(buffer, "%x", 0); sprintf(buffer, "%x", 0);
proc_put("/proc/stb/fb/dst_top", buffer, strlen(buffer)); proc_put("/proc/stb/fb/dst_top", buffer, strlen(buffer));

View File

@@ -11,10 +11,10 @@
extern "C" { extern "C" {
#include <common.h> #include <common.h>
extern OutputHandler_t OutputHandler; extern OutputHandler_t OutputHandler;
extern PlaybackHandler_t PlaybackHandler; extern PlaybackHandler_t PlaybackHandler;
extern ContainerHandler_t ContainerHandler; extern ContainerHandler_t ContainerHandler;
extern ManagerHandler_t ManagerHandler; extern ManagerHandler_t ManagerHandler;
extern int32_t ffmpeg_av_dict_set(const char *key, const char *value, int32_t flags); extern int32_t ffmpeg_av_dict_set(const char *key, const char *value, int32_t flags);
} }
@@ -63,10 +63,10 @@ bool cPlayback::Open(playmode_t PlayMode)
if (player) if (player)
{ {
player->playback = &PlaybackHandler; player->playback = &PlaybackHandler;
player->output = &OutputHandler; player->output = &OutputHandler;
player->container = &ContainerHandler; player->container = &ContainerHandler;
player->manager = &ManagerHandler; player->manager = &ManagerHandler;
hal_info("%s - player output name: %s PlayMode: %s\n", __func__, player->output->Name, aPLAYMODE[PlayMode]); hal_info("%s - player output name: %s PlayMode: %s\n", __func__, player->output->Name, aPLAYMODE[PlayMode]);
} }
@@ -129,7 +129,7 @@ bool cPlayback::Start(char *filename, int vpid, int vtype, int apid, int ac3, in
if (file.substr(0, 7) == "file://") if (file.substr(0, 7) == "file://")
{ {
if (file.substr(file.length() - 3) == ".ts") if (file.substr(file.length() - 3) == ".ts")
{ {
fn_ts = file.substr(7); fn_ts = file.substr(7);
fn_xml = file.substr(7, file.length() - 9); fn_xml = file.substr(7, file.length() - 9);
@@ -221,23 +221,23 @@ bool cPlayback::Start(char *filename, int vpid, int vtype, int apid, int ac3, in
//Teletext //Teletext
if (player && player->manager && player->manager->teletext) if (player && player->manager && player->manager->teletext)
{ {
char ** TrackList = NULL; char ** TrackList = NULL;
player->manager->teletext->Command(player, MANAGER_LIST, &TrackList); player->manager->teletext->Command(player, MANAGER_LIST, &TrackList);
if (TrackList != NULL) if (TrackList != NULL)
{ {
printf("TeletextTrack List\n"); printf("TeletextTrack List\n");
int i = 0; int i = 0;
for (i = 0; TrackList[i] != NULL; i += 2) for (i = 0; TrackList[i] != NULL; i += 2)
{ {
printf("\t%s - %s\n", TrackList[i], TrackList[i + 1]); printf("\t%s - %s\n", TrackList[i], TrackList[i + 1]);
free(TrackList[i]); free(TrackList[i]);
free(TrackList[i + 1]); free(TrackList[i + 1]);
} }
free(TrackList); free(TrackList);
} }
} }
*/ */
//Chapters //Chapters
if (player && player->manager && player->manager->chapter) if (player && player->manager && player->manager->chapter)
{ {
@@ -336,7 +336,7 @@ bool cPlayback::SetTeletextPid(int pid)
if (pid != mTeletextStream) if (pid != mTeletextStream)
{ {
//if (player && player->playback) //if (player && player->playback)
// player->playback->Command(player, PLAYBACK_SWITCH_TELETEXT, (void*)&i); // player->playback->Command(player, PLAYBACK_SWITCH_TELETEXT, (void*)&i);
mTeletextStream = pid; mTeletextStream = pid;
} }
return true; return true;
@@ -569,26 +569,26 @@ void cPlayback::FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t
{ {
apids[j] = _pid; apids[j] = _pid;
// atUnknown, atMPEG, atMP3, atAC3, atDTS, atAAC, atPCM, atOGG, atFLAC // atUnknown, atMPEG, atMP3, atAC3, atDTS, atAAC, atPCM, atOGG, atFLAC
if (!strncmp("A_MPEG/L3", TrackList[i + 1], 9)) if (!strncmp("A_MPEG/L3", TrackList[i + 1], 9))
ac3flags[j] = 3; ac3flags[j] = 3;
if (!strncmp("A_MP3", TrackList[i + 1], 5)) if (!strncmp("A_MP3", TrackList[i + 1], 5))
ac3flags[j] = 4; ac3flags[j] = 4;
else if (!strncmp("A_AC3", TrackList[i + 1], 5)) else if (!strncmp("A_AC3", TrackList[i + 1], 5))
ac3flags[j] = 1; ac3flags[j] = 1;
else if (!strncmp("A_EAC3", TrackList[i + 1], 6)) else if (!strncmp("A_EAC3", TrackList[i + 1], 6))
ac3flags[j] = 7; ac3flags[j] = 7;
else if (!strncmp("A_DTS", TrackList[i + 1], 5)) else if (!strncmp("A_DTS", TrackList[i + 1], 5))
ac3flags[j] = 6; ac3flags[j] = 6;
else if (!strncmp("A_AAC", TrackList[i + 1], 5)) else if (!strncmp("A_AAC", TrackList[i + 1], 5))
ac3flags[j] = 5; ac3flags[j] = 5;
else if (!strncmp("A_PCM", TrackList[i + 1], 5)) else if (!strncmp("A_PCM", TrackList[i + 1], 5))
ac3flags[j] = 0; //todo ac3flags[j] = 0; // todo
else if (!strncmp("A_VORBIS", TrackList[i + 1], 8)) else if (!strncmp("A_VORBIS", TrackList[i + 1], 8))
ac3flags[j] = 0; //todo ac3flags[j] = 0; // todo
else if (!strncmp("A_FLAC", TrackList[i + 1], 6)) else if (!strncmp("A_FLAC", TrackList[i + 1], 6))
ac3flags[j] = 0; //todo ac3flags[j] = 0; // todo
else else
ac3flags[j] = 0; //todo ac3flags[j] = 0; // todo
std::string _language = ""; std::string _language = "";
_language += std::string(_lang); _language += std::string(_lang);
if (_language.compare("und") == 0) if (_language.compare("und") == 0)
@@ -652,36 +652,38 @@ void cPlayback::FindAllTeletextsubtitlePids(int */*pids*/, unsigned int *numpids
//int max_numpids = *numpids; //int max_numpids = *numpids;
*numpids = 0; *numpids = 0;
/* if (player && player->manager && player->manager->teletext) /*
{ if (player && player->manager && player->manager->teletext)
char **TrackList = NULL; {
player->manager->teletext->Command(player, MANAGER_LIST, &TrackList); char **TrackList = NULL;
if (TrackList != NULL) player->manager->teletext->Command(player, MANAGER_LIST, &TrackList);
{ if (TrackList != NULL)
printf("Teletext List\n"); {
int i = 0, j = 0; printf("Teletext List\n");
for (i = 0, j = 0; TrackList[i] != NULL; i += 2) int i = 0, j = 0;
{ for (i = 0, j = 0; TrackList[i] != NULL; i += 2)
int type = 0; {
printf("\t%s - %s\n", TrackList[i], TrackList[i + 1]); int type = 0;
if (j < max_numpids) printf("\t%s - %s\n", TrackList[i], TrackList[i + 1]);
{ if (j < max_numpids)
int _pid; {
if (2 != sscanf(TrackList[i], "%d %*s %d %*d %*d", &_pid, &type)) int _pid;
continue; if (2 != sscanf(TrackList[i], "%d %*s %d %*d %*d", &_pid, &type))
if (type != 2 && type != 5) // return subtitles only continue;
continue; if (type != 2 && type != 5) // return subtitles only
pids[j] = _pid; continue;
language[j] = std::string(TrackList[i]); pids[j] = _pid;
j++; language[j] = std::string(TrackList[i]);
} j++;
free(TrackList[i]); }
free(TrackList[i + 1]); free(TrackList[i]);
} free(TrackList[i + 1]);
free(TrackList); }
*numpids = j; free(TrackList);
} *numpids = j;
} */ }
}
*/
} }
int cPlayback::GetTeletextPid(void) int cPlayback::GetTeletextPid(void)
@@ -689,31 +691,33 @@ int cPlayback::GetTeletextPid(void)
hal_info("%s\n", __func__); hal_info("%s\n", __func__);
int pid = -1; int pid = -1;
/* if (player && player->manager && player->manager->teletext) /*
{ if (player && player->manager && player->manager->teletext)
char **TrackList = NULL; {
player->manager->teletext->Command(player, MANAGER_LIST, &TrackList); char **TrackList = NULL;
if (TrackList != NULL) player->manager->teletext->Command(player, MANAGER_LIST, &TrackList);
{ if (TrackList != NULL)
printf("Teletext List\n"); {
int i = 0; printf("Teletext List\n");
for (i = 0; TrackList[i] != NULL; i += 2) int i = 0;
{ for (i = 0; TrackList[i] != NULL; i += 2)
int type = 0; {
printf("\t%s - %s\n", TrackList[i], TrackList[i+1]); int type = 0;
if (pid < 0) printf("\t%s - %s\n", TrackList[i], TrackList[i + 1]);
{ if (pid < 0)
if (2 != sscanf(TrackList[i], "%*d %d %*s %d %*d %*d", &pid, &type)) {
continue; if (2 != sscanf(TrackList[i], "%*d %d %*s %d %*d %*d", &pid, &type))
if (type != 1) continue;
pid = -1; if (type != 1)
} pid = -1;
free(TrackList[i]); }
free(TrackList[i + 1]); free(TrackList[i]);
} free(TrackList[i + 1]);
free(TrackList); }
} free(TrackList);
} */ }
}
*/
printf("teletext pid id %d (0x%x)\n", pid, pid); printf("teletext pid id %d (0x%x)\n", pid, pid);
return pid; return pid;

View File

@@ -286,8 +286,8 @@ void cRecord::RecordThread()
if (toread > readsize) if (toread > readsize)
toread = readsize; toread = readsize;
ssize_t s = dmx->Read(buf + buf_pos, toread, 50); ssize_t s = dmx->Read(buf + buf_pos, toread, 50);
hal_debug("%s: buf_pos %6d s %6d / %6d\n", __func__, hal_debug("%s: buf_pos %6d s %6d / %6d\n",
buf_pos, (int)s, bufsize - buf_pos); __func__, buf_pos, (int)s, bufsize - buf_pos);
if (s < 0) if (s < 0)
{ {
if (errno != EAGAIN && (errno != EOVERFLOW || !overflow)) if (errno != EAGAIN && (errno != EOVERFLOW || !overflow))
@@ -328,7 +328,7 @@ void cRecord::RecordThread()
hal_debug("%s: aio in progress, free: %d\n", __func__, bufsize - buf_pos); hal_debug("%s: aio in progress, free: %d\n", __func__, bufsize - buf_pos);
continue; continue;
} }
// not calling aio_return causes a memory leak --martii // not calling aio_return causes a memory leak --martii
r = aio_return(&a); r = aio_return(&a);
if (r < 0) if (r < 0)
{ {

View File

@@ -54,23 +54,23 @@ extern "C"
#define hal_debug_c(args...) _hal_debug(HAL_DEBUG_VIDEO, NULL, args) #define hal_debug_c(args...) _hal_debug(HAL_DEBUG_VIDEO, NULL, args)
#define hal_info_c(args...) _hal_info(HAL_DEBUG_VIDEO, NULL, args) #define hal_info_c(args...) _hal_info(HAL_DEBUG_VIDEO, NULL, args)
#define fop(cmd, args...) ({ \ #define fop(cmd, args...) ({ \
int _r; \ int _r; \
if (fd >= 0) { \ if (fd >= 0) { \
if ((_r = ::cmd(fd, args)) < 0) \ if ((_r = ::cmd(fd, args)) < 0) \
hal_info(#cmd"(fd, "#args")\n");\ hal_info(#cmd"(fd, "#args")\n");\
else \ else \
hal_debug(#cmd"(fd, "#args")\n");\ hal_debug(#cmd"(fd, "#args")\n");\
} \ } \
else { _r = fd; } \ else { _r = fd; } \
_r; \ _r; \
}) })
#ifndef VIDEO_GET_SIZE #ifndef VIDEO_GET_SIZE
#define VIDEO_GET_SIZE _IOR('o', 55, video_size_t) #define VIDEO_GET_SIZE _IOR('o', 55, video_size_t)
#endif #endif
#ifndef VIDEO_GET_FRAME_RATE #ifndef VIDEO_GET_FRAME_RATE
#define VIDEO_GET_FRAME_RATE _IOR('o', 56, unsigned int) #define VIDEO_GET_FRAME_RATE _IOR('o', 56, unsigned int)
#endif #endif
enum enum
@@ -189,8 +189,8 @@ static const char *vid_modes[] =
"1080p25", // VIDEO_STD_1080P25 "1080p25", // VIDEO_STD_1080P25
"1080p50", // VIDEO_STD_1080P50 "1080p50", // VIDEO_STD_1080P50
"1080p60", // VIDEO_STD_1080P60 "1080p60", // VIDEO_STD_1080P60
"1080p2397", // VIDEO_STD_1080P2397 "1080p2397",// VIDEO_STD_1080P2397
"1080p2997", // VIDEO_STD_1080P2997 "1080p2997",// VIDEO_STD_1080P2997
"2160p24", // VIDEO_STD_2160P24 "2160p24", // VIDEO_STD_2160P24
"2160p25", // VIDEO_STD_2160P25 "2160p25", // VIDEO_STD_2160P25
"2160p30", // VIDEO_STD_2160P30 "2160p30", // VIDEO_STD_2160P30
@@ -209,11 +209,11 @@ static const char *vid_modes[] =
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(58, 133, 100) #if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(58, 133, 100)
static void get_packet_defaults(AVPacket *pkt) static void get_packet_defaults(AVPacket *pkt)
{ {
memset(pkt, 0, sizeof(*pkt)); memset(pkt, 0, sizeof(*pkt));
pkt->pts = AV_NOPTS_VALUE; pkt->pts = AV_NOPTS_VALUE;
pkt->dts = AV_NOPTS_VALUE; pkt->dts = AV_NOPTS_VALUE;
pkt->pos = -1; pkt->pos = -1;
} }
#endif #endif
ssize_t write_all(int fd, const void *buf, size_t count) ssize_t write_all(int fd, const void *buf, size_t count)
@@ -607,7 +607,7 @@ int cVideo::setAspectRatio(int aspect, int mode)
int n; int n;
int mo = (mode < 0 || mode > 3) ? 4 : mode; int mo = (mode < 0 || mode > 3) ? 4 : mode;
hal_debug("%s: a:%d m:%d %s\n", __func__, aspect, mode, m[mo]); hal_debug("%s: a:%d m:%d %s\n", __func__, aspect, mode, m[mo]);
if (aspect > 3 || aspect == 0) if (aspect > 3 || aspect == 0)
hal_info("%s: invalid aspect: %d\n", __func__, aspect); hal_info("%s: invalid aspect: %d\n", __func__, aspect);
@@ -673,7 +673,7 @@ int cVideo::Start(void * /*PcrChannel*/, unsigned short /*PcrPid*/, unsigned sho
#if 0 #if 0
if (playstate == VIDEO_PLAYING) if (playstate == VIDEO_PLAYING)
return 0; return 0;
if (playstate == VIDEO_FREEZED) /* in theory better, but not in practice :-) */ if (playstate == VIDEO_FREEZED) /* in theory better, but not in practice :-) */
fop(ioctl, MPEG_VID_CONTINUE); fop(ioctl, MPEG_VID_CONTINUE);
#endif #endif
/* implicitly do StopPicture() on video->Start() */ /* implicitly do StopPicture() on video->Start() */
@@ -1048,9 +1048,9 @@ void cVideo::getPictureInfo(int &width, int &height, int &rate)
int n = proc_get(VMPEG_framerate[devnum], buf, 16); int n = proc_get(VMPEG_framerate[devnum], buf, 16);
if (n > 0) if (n > 0)
sscanf(buf, "%i", &r); sscanf(buf, "%i", &r);
width = proc_get_hex(VMPEG_xres[devnum]); width = proc_get_hex(VMPEG_xres[devnum]);
height = proc_get_hex(VMPEG_yres[devnum]); height = proc_get_hex(VMPEG_yres[devnum]);
rate = rate2csapi(r); rate = rate2csapi(r);
return; return;
} }
ioctl(fd, VIDEO_GET_SIZE, &s); ioctl(fd, VIDEO_GET_SIZE, &s);
@@ -1236,7 +1236,7 @@ void cVideo::SetColorFormat(COLOR_FORMAT color_format)
bool getvideo2(unsigned char *video, int xres, int yres) bool getvideo2(unsigned char *video, int xres, int yres)
{ {
bool ret = false; bool ret = false;
if (video == NULL) if (video == NULL)
return ret; return ret;
char videosnapshot[] = "/dev/dvb/adapter0/video0"; char videosnapshot[] = "/dev/dvb/adapter0/video0";
int fd_video = open(videosnapshot, O_RDONLY); int fd_video = open(videosnapshot, O_RDONLY);
@@ -1380,7 +1380,7 @@ void get_osd_buf(unsigned char *osd_data)
close(fb); close(fb);
} }
inline void rgb24torgb32(unsigned char *src, unsigned char *dest, int picsize) inline void rgb24torgb32(unsigned char *src, unsigned char *dest, int picsize)
{ {
for (int i = 0; i < picsize; i++) for (int i = 0; i < picsize; i++)
{ {
@@ -1397,7 +1397,7 @@ bool cVideo::GetScreenImage(unsigned char *&out_data, int &xres, int &yres, bool
#define VDEC_PIXFMT AV_PIX_FMT_BGR24 #define VDEC_PIXFMT AV_PIX_FMT_BGR24
hal_info("%s: out_data 0x%p xres %d yres %d vid %d osd %d scale %d\n", hal_info("%s: out_data 0x%p xres %d yres %d vid %d osd %d scale %d\n",
__func__, out_data, xres, yres, get_video, get_osd, scale_to_video); __func__, out_data, xres, yres, get_video, get_osd, scale_to_video);
int aspect = 0; int aspect = 0;
getPictureInfo(xres, yres, aspect); /* aspect is dummy here */ getPictureInfo(xres, yres, aspect); /* aspect is dummy here */
aspect = getAspectRatio(); aspect = getAspectRatio();
@@ -1440,7 +1440,7 @@ bool cVideo::GetScreenImage(unsigned char *&out_data, int &xres, int &yres, bool
free(video_src); free(video_src);
return false; return false;
} }
if (grab_w != xres || grab_h != yres) /* scale video into data... */ if (grab_w != xres || grab_h != yres) /* scale video into data... */
{ {
bool ret = swscale(video_src, out_data, grab_w, grab_h, xres, yres, VDEC_PIXFMT); bool ret = swscale(video_src, out_data, grab_w, grab_h, xres, yres, VDEC_PIXFMT);
if (!ret) if (!ret)
@@ -1450,7 +1450,7 @@ bool cVideo::GetScreenImage(unsigned char *&out_data, int &xres, int &yres, bool
return false; return false;
} }
} }
else /* get_video and no fancy scaling needed */ else /* get_video and no fancy scaling needed */
{ {
rgb24torgb32(video_src, out_data, grab_w * grab_h); rgb24torgb32(video_src, out_data, grab_w * grab_h);
} }
@@ -1506,7 +1506,7 @@ bool cVideo::GetScreenImage(unsigned char *&out_data, int &xres, int &yres, bool
{ {
uint8_t *in = (uint8_t *)(pixpos); uint8_t *in = (uint8_t *)(pixpos);
uint8_t *out = (uint8_t *)d; uint8_t *out = (uint8_t *)d;
int a = in[3]; /* TODO: big/little endian? */ int a = in[3]; /* TODO: big/little endian? */
*out = (*out + ((*in - *out) * a) / 256); *out = (*out + ((*in - *out) * a) / 256);
in++; in++;
out++; out++;

View File

@@ -43,7 +43,7 @@ hw_caps_t *get_hwcaps(void)
caps.display_type = HW_DISPLAY_LINE_TEXT; caps.display_type = HW_DISPLAY_LINE_TEXT;
caps.display_can_deepstandby = 1; caps.display_can_deepstandby = 1;
caps.display_can_set_brightness = 1; caps.display_can_set_brightness = 1;
caps.display_can_umlauts = 0; /* need test */ caps.display_can_umlauts = 0; /* need test */
caps.display_has_statusline = 0; caps.display_has_statusline = 0;
caps.display_has_colon = 0; caps.display_has_colon = 0;
caps.has_button_timer = 1; caps.has_button_timer = 1;