summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
Diffstat (limited to 'stream')
-rw-r--r--stream/stream_pvr.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/stream/stream_pvr.c b/stream/stream_pvr.c
index 7acac4a6f5..d55c419b67 100644
--- a/stream/stream_pvr.c
+++ b/stream/stream_pvr.c
@@ -118,6 +118,7 @@ typedef struct station_elem_s {
int freq;
char station[PVR_STATION_NAME_SIZE];
int enabled;
+ int priority;
} station_elem_t;
typedef struct stationlist_s {
@@ -313,7 +314,7 @@ disable_all_stations (struct pvr_t *pvr)
*/
static int
set_station (struct pvr_t *pvr, const char *station,
- const char *channel, int freq)
+ const char *channel, int freq, int priority)
{
int i;
@@ -353,6 +354,8 @@ set_station (struct pvr_t *pvr, const char *station,
else
BUFPRINTF(pvr->stationlist.list[i].station, "F %d", freq);
+ pvr->stationlist.list[i].priority = priority;
+
MP_DBG(pvr, "%s Set user station channel: %8s - freq: %8d - station: %s\n",
LOG_LEVEL_V4L2, pvr->stationlist.list[i].name,
pvr->stationlist.list[i].freq,
@@ -395,6 +398,7 @@ set_station (struct pvr_t *pvr, const char *station,
/* here we go, our actual new entry */
pvr->stationlist.used++;
pvr->stationlist.list[i].enabled = 1;
+ pvr->stationlist.list[i].priority = priority;
pvr->stationlist.enabled++;
if (station)
@@ -414,6 +418,18 @@ set_station (struct pvr_t *pvr, const char *station,
return 0;
}
+static int compare_priority(const void *pa, const void *pb)
+{
+ const station_elem_t *a = pa;
+ const station_elem_t *b = pb;
+
+ if (a->priority < b->priority)
+ return -1;
+ if (a->priority > b->priority)
+ return 1;
+ return 0;
+}
+
/**
* Here we set our stationlist, as follow
* - choose the frequency channel table, e.g. ntsc-cable
@@ -477,6 +493,10 @@ parse_setup_stationlist (struct pvr_t *pvr)
disable_all_stations (pvr);
+ int prio = 0;
+ for (i = 0; i < pvr->stationlist.total; i++)
+ pvr->stationlist.list[i].priority = ++prio;
+
while (*channels)
{
char *tmp = *(channels++);
@@ -501,12 +521,15 @@ parse_setup_stationlist (struct pvr_t *pvr)
if ((freq = atoi (channel)) <= 1000)
freq = -1;
- if (set_station (pvr, station, (freq <= 0) ? channel : NULL, freq) < 0)
+ if (set_station (pvr, station, (freq <= 0) ? channel : NULL, freq, ++prio) < 0)
{
MP_ERR(pvr, "%s Unable to set user station channel: %8s - freq: %8d - station: %s\n", LOG_LEVEL_V4L2,
channel, freq, station);
}
}
+
+ qsort(pvr->stationlist.list, pvr->stationlist.total,
+ sizeof(station_elem_t), compare_priority);
}
return print_all_stations (pvr);