Ticket #3260: audio_track_final_fix_v2.diff
File audio_track_final_fix_v2.diff, 12.3 KB (added by , 18 years ago) |
---|
-
libs/libmythdvdnav/dvdnav.c
927 927 928 928 } 929 929 930 /* 931 * \brief get dvd audio format for provided stream 932 * \return 0 - AC3, 2-MP2, 4-LPCM, 6-DTS, 933 */ 934 unsigned char dvdnav_audio_get_format(dvdnav_t *this, uint8_t stream){ 935 audio_attr_t attr; 936 937 if(!this) { 938 printerr("Passed a NULL pointer."); 939 return 0xff; 940 } 941 if(!this->started) { 942 printerr("Virtual DVD machine not started."); 943 return 0xff; 944 } 945 946 pthread_mutex_lock(&this->vm_lock); 947 attr = vm_get_audio_attr(this->vm, stream); 948 pthread_mutex_unlock(&this->vm_lock); 949 950 return attr.audio_format; 951 } 952 953 /* 954 * \brief get total dvd audio stream count 955 */ 956 int dvdnav_audio_get_stream_count(dvdnav_t *this) { 957 int count = 0; 958 if (!this) { 959 printerr("Passed a NULL pointer."); 960 return 0; 961 } 962 if(!this->started) { 963 printerr("Virtual DVD machine not started."); 964 return 0; 965 } 966 967 pthread_mutex_lock(&this->vm_lock); 968 count = vm_get_audio_stream_count(this->vm); 969 pthread_mutex_unlock(&this->vm_lock); 970 971 return count; 972 } 973 930 974 uint16_t dvdnav_spu_stream_to_lang(dvdnav_t *this, uint8_t stream) { 931 975 subp_attr_t attr; 932 976 -
libs/libmythdvdnav/vm.c
812 812 } 813 813 } 814 814 815 #if 0 816 /* currently unused */ 817 void vm_get_audio_info(vm_t *vm, int *current, int *num_avail) { 815 int vm_get_audio_stream_count(vm_t *vm) { 816 int count = 0; 818 817 switch ((vm->state).domain) { 819 818 case VTS_DOMAIN: 820 *num_avail = vm->vtsi->vtsi_mat->nr_of_vts_audio_streams; 821 *current = (vm->state).AST_REG; 819 count = vm->vtsi->vtsi_mat->nr_of_vts_audio_streams; 822 820 break; 823 821 case VTSM_DOMAIN: 824 *num_avail = vm->vtsi->vtsi_mat->nr_of_vtsm_audio_streams; /* 1 */ 825 *current = 1; 822 count = vm->vtsi->vtsi_mat->nr_of_vtsm_audio_streams; /* 1 */ 826 823 break; 827 824 case VMGM_DOMAIN: 828 825 case FP_DOMAIN: 829 *num_avail = vm->vmgi->vmgi_mat->nr_of_vmgm_audio_streams; /* 1 */ 830 *current = 1; 826 count = vm->vmgi->vmgi_mat->nr_of_vmgm_audio_streams; /* 1 */ 831 827 break; 832 828 } 829 return count; 833 830 } 834 831 832 #if 0 835 833 /* currently unused */ 836 834 void vm_get_subp_info(vm_t *vm, int *current, int *num_avail) { 837 835 switch ((vm->state).domain) { -
libs/libmythdvdnav/dvdnav.h
573 573 */ 574 574 unsigned char dvdnav_audio_get_channels(dvdnav_t *self, uint8_t stream); 575 575 576 unsigned char dvdnav_audio_get_format(dvdnav_t *self, uint8_t stream); 577 578 int dvdnav_audio_get_stream_count(dvdnav_t *self); 576 579 /* 577 580 * Converts a *logical* subpicture stream id into country code 578 581 * (returns 0xffff if no such stream). -
libs/libmythdvdnav/vm.h
162 162 int vm_get_audio_active_stream(vm_t *vm); 163 163 int vm_get_subp_active_stream(vm_t *vm, int mode); 164 164 void vm_get_angle_info(vm_t *vm, int *current, int *num_avail); 165 int vm_get_audio_stream_count(vm_t *vm); 165 166 #if 0 166 167 /* currently unused */ 167 void vm_get_audio_info(vm_t *vm, int *current, int *num_avail);168 168 void vm_get_subp_info(vm_t *vm, int *current, int *num_avail); 169 169 void vm_get_video_res(vm_t *vm, int *width, int *height); 170 170 #endif -
libs/libmythtv/DVDRingBuffer.cpp
341 341 { 342 342 dvdnav_spu_stream_change_event_t* spu = 343 343 (dvdnav_spu_stream_change_event_t*)(blockBuf); 344 345 if (autoselectsubtitle) 346 curSubtitleTrack = dvdnav_get_active_spu_stream(dvdnav); 347 344 348 VERBOSE(VB_PLAYBACK, 345 349 QString("DVDNAV_SPU_STREAM_CHANGE: " 346 350 "physical_wide==%1, physical_letterbox==%2, " 347 "physical_pan_scan==%3, logical==%4")351 "physical_pan_scan==%3, current_track==%4") 348 352 .arg(spu->physical_wide).arg(spu->physical_letterbox) 349 .arg(spu->physical_pan_scan).arg( spu->logical));353 .arg(spu->physical_pan_scan).arg(curSubtitleTrack)); 350 354 351 355 ClearMenuSPUParameters(); 352 356 ClearSubtitlesOSD(); … … 359 363 buttonstreamid = spu->physical_wide + buttonstreamid; 360 364 } 361 365 362 if (autoselectsubtitle)363 curSubtitleTrack = dvdnav_get_active_spu_stream(dvdnav);364 365 366 if (parent) 366 367 { 367 368 if (IsInMenu() && parent->GetCaptionMode()) … … 376 377 break; 377 378 case DVDNAV_AUDIO_STREAM_CHANGE: 378 379 { 379 dvdnav_audio_stream_change_event_t* apu = 380 (dvdnav_audio_stream_change_event_t*)(blockBuf); 380 if (autoselectaudio) 381 curAudioTrack = dvdnav_get_active_audio_stream(dvdnav); 382 383 audioTrackMap.clear(); 384 uint count = dvdnav_audio_get_stream_count(dvdnav); 385 uint ac3StreamId = 128; 386 uint mp2StreamId = 448; 387 uint lpcmStreamId = 160; 388 uint dtsStreamId = 136; 389 381 390 VERBOSE(VB_PLAYBACK, 382 391 QString("DVDNAV_AUDIO_STREAM_CHANGE: " 383 "physical==%1, logical==%2") 384 .arg(apu->physical).arg(apu->logical)); 385 386 if (autoselectaudio) 387 curAudioTrack = dvdnav_get_active_audio_stream(dvdnav); 388 392 "Current Active Stream %1 Track Count %2") 393 .arg(curAudioTrack).arg(count)); 394 395 for (uint i = 0; i < count; i++) 396 { 397 int audio_format = dvdnav_audio_get_format(dvdnav, i); 398 switch (audio_format) 399 { 400 case 0: 401 audioTrackMap.insert(ac3StreamId, i); 402 ac3StreamId++; 403 break; 404 case 2: 405 audioTrackMap.insert(mp2StreamId, i); 406 mp2StreamId++; 407 break; 408 case 4: 409 audioTrackMap.insert(lpcmStreamId, i); 410 lpcmStreamId++; 411 break; 412 case 6: 413 audioTrackMap.insert(dtsStreamId, i); 414 dtsStreamId++; 415 break; 416 default: 417 VERBOSE(VB_PLAYBACK, LOC_ERR + 418 QString("AUDIO_STREAM_CHANGE: Unhandled audio format %1") 419 .arg(i)); 420 break; 421 } 422 } 423 389 424 if (blockBuf != dvdBlockWriteBuf) 390 425 { 391 426 dvdnav_free_cache_block(dvdnav, blockBuf); … … 1041 1076 */ 1042 1077 uint DVDRingBufferPriv::GetAudioLanguage(int id) 1043 1078 { 1044 int8_t channel = dvdnav_get_audio_logical_stream(dvdnav, id);1079 int8_t channel = dvdnav_get_audio_logical_stream(dvdnav, id); 1045 1080 uint16_t lang = 0; 1046 1081 if (channel != -1) 1047 1082 lang = dvdnav_audio_stream_to_lang(dvdnav,channel); 1048 1083 return ConvertLangCode(lang); 1049 1084 } 1050 1085 1086 /** \brief get dvd track audio number 1087 * \param key position in audioTrackMap. 1088 * \return -1 if track number not found 1089 */ 1090 int DVDRingBufferPriv::GetAudioTrackNum(uint key) 1091 { 1092 if (audioTrackMap.empty()) 1093 return -1; 1094 uint count = 0; 1095 QMapConstIterator<uint, uint> it = audioTrackMap.begin(); 1096 for (; it != audioTrackMap.end(); ++it) 1097 { 1098 if (count == key) 1099 break; 1100 ++count; 1101 } 1102 return (int)it.data(); 1103 } 1104 1051 1105 /** \brief get the subtitle language from the dvd 1052 1106 */ 1053 1107 uint DVDRingBufferPriv::GetSubtitleLanguage(int id) -
libs/libmythtv/DVDRingBuffer.h
57 57 uint ButtonWidth(void) { return hl_width; } 58 58 uint ButtonHeight(void) { return hl_height; } 59 59 uint GetAudioLanguage(int id); 60 uint GetSubtitleLanguage(int id); 60 int GetAudioTrackNum(uint stream_id); 61 uint GetSubtitleLanguage(int key); 61 62 void SetMenuPktPts(long long pts) { menupktpts = pts; } 62 63 long long GetMenuPktPts(void) { return menupktpts; } 63 64 bool DecodeSubtitles(AVSubtitle * sub, int * gotSubtitles, … … 167 168 uint64_t seektime; 168 169 uint currentTime; 169 170 QMap<uint, uint> seekSpeedMap; 171 QMap<uint, uint> audioTrackMap; 170 172 171 173 NuppelVideoPlayer *parent; 172 174 -
libs/libmythtv/avformatdecoder.cpp
1561 1561 { 1562 1562 if (tracks[kTrackTypeAudio].size() > 1) 1563 1563 { 1564 qBubbleSort(tracks[kTrackTypeAudio]); 1565 sinfo_vec_t::iterator it = tracks[kTrackTypeAudio].begin(); 1566 int count = 0; 1567 for (; it != tracks[kTrackTypeAudio].end(); ++it) 1568 { 1569 it->dvd_track_num = ringBuffer->DVD()->GetAudioTrackNum(count); 1570 VERBOSE(VB_PLAYBACK, LOC + 1571 QString("DVD Audio Track Map " 1572 "Stream id #%1 track #%2 ") 1573 .arg(it->stream_id).arg(it->dvd_track_num)); 1574 count++; 1575 } 1576 qBubbleSort(tracks[kTrackTypeAudio]); 1564 1577 int trackNo = ringBuffer->DVD()->GetTrack(kTrackTypeAudio); 1565 1578 if (trackNo >= (int)GetTrackCount(kTrackTypeAudio)) 1566 1579 trackNo = GetTrackCount(kTrackTypeAudio) - 1; … … 2730 2743 RemoveAudioStreams(); 2731 2744 storevideoframes = false; 2732 2745 dvdTitleChanged = false; 2746 ScanStreams(false); 2733 2747 } 2734 2748 else 2735 2749 storevideoframes = true; -
libs/libmythtv/decoderbase.h
20 20 StreamInfo() : 21 21 av_stream_index(-1), av_substream_index(-1), 22 22 language(-2), language_index(0), 23 stream_id(-1), easy_reader(false), wide_aspect_ratio(false) {} 23 stream_id(-1), easy_reader(false), 24 wide_aspect_ratio(false), dvd_track_num(-1) {} 24 25 StreamInfo(int a, int b, uint c, int d, bool e = false, bool f = false) : 25 26 av_stream_index(a), av_substream_index(-1), 26 27 language(b), language_index(c), stream_id(d), 27 easy_reader(e), wide_aspect_ratio(f) {} 28 easy_reader(e), wide_aspect_ratio(f), 29 dvd_track_num(-1) {} 28 30 StreamInfo(int a, int b, uint c, int d, int e, 29 31 bool f = false, bool g = false) : 30 32 av_stream_index(a), av_substream_index(e), 31 33 language(b), language_index(c), stream_id(d), 32 easy_reader(f), wide_aspect_ratio(g) {} 34 easy_reader(f), wide_aspect_ratio(g), 35 dvd_track_num(-1) {} 33 36 34 37 public: 35 38 int av_stream_index; … … 40 43 int stream_id; 41 44 bool easy_reader; 42 45 bool wide_aspect_ratio; 46 int dvd_track_num; 43 47 44 48 bool operator<(const StreamInfo& b) const 45 { return (this->stream_id < b.stream_id) ; } 46 }; 49 { 50 if (this->dvd_track_num >= 0) 51 return (this->dvd_track_num < b.dvd_track_num); 52 return (this->stream_id < b.stream_id); 53 } 54 }; 47 55 typedef vector<StreamInfo> sinfo_vec_t; 48 56 49 57 class DecoderBase