--- zapit.cpp.orig 2003-12-20 12:41:09.000000000 +0100 +++ zapit.cpp 2003-12-31 23:05:32.000000000 +0100 @@ -35,6 +35,8 @@ #include #endif +#define AUDIO_CONFIG_FILE "/var/tuxbox/config/zapit/audio.conf" + /* tuxbox headers */ #include #include @@ -80,6 +82,9 @@ CDemux *teletextDemux = NULL; CDemux *videoDemux = NULL; +map audio_map; + + /* current zapit mode */ enum { TV_MODE = 0x01, @@ -146,11 +151,36 @@ config.setInt32("diseqcRepeats", frontend->getDiseqcRepeats()); config.setInt32("diseqcType", frontend->getDiseqcType()); config.saveConfig(CONFIGFILE); + + FILE *audio_config_file = fopen(AUDIO_CONFIG_FILE, "w"); + if (audio_config_file) { + for (map::iterator + audio_map_it = audio_map.begin(); + audio_map_it != audio_map.end(); + audio_map_it++) { + fprintf(audio_config_file, "%d %d\n", + (int) audio_map_it->first, + (int) audio_map_it->second); + } + fclose(audio_config_file); + } } } CZapitClient::responseGetLastChannel load_settings(void) { + FILE *audio_config_file = fopen(AUDIO_CONFIG_FILE, "r"); + if (audio_config_file) { + int chan, apid; + char s[1000]; + while (fgets(s, 1000, audio_config_file)) { + sscanf(s, "%d %d", &chan, &apid); + //printf("**** Old channelinfo: %d %d\n", chan, apid); + audio_map[chan] = apid; + } + fclose(audio_config_file); + } + CZapitClient::responseGetLastChannel lastchannel; if (config.getInt32("lastChannelMode", 0)) @@ -187,6 +217,11 @@ tallchans_iterator cit; uint32_t current_transponder_id; + if (channel) { + audio_map[channel->getChannelID()] = channel->getAudioPid(); + DBG("*** Remembering apid = %d for channel = %d\n", channel->getAudioPid(), channel->getChannelID()); + } + DBG("tuned_transponder_id: %08x", tuned_transponder_id); /* usual zap */ @@ -345,6 +380,19 @@ else thisChannel->getCaPmt()->ca_pmt_list_management = 0x04; + DBG("***Now trying to get audio right: %d\t%d\t%d\t%d\n", + thisChannel->getAudioChannelCount(), + thisChannel->getAudioChannel(0)->pid, + thisChannel->getChannelID(), + audio_map[thisChannel->getChannelID()]); + for (int i = 0; i < thisChannel->getAudioChannelCount(); i++) { + if (thisChannel->getAudioChannel(i)->pid == audio_map[thisChannel->getChannelID()]) { + DBG("***** Setting audio!\n"); + thisChannel->setAudioChannel(i); + } + } + + startPlayBack(thisChannel); cam->setCaPmt(thisChannel->getCaPmt()); saveSettings(false);