Mercurial > mplayer.hg
comparison mplayer.c @ 6217:d2167f69a48b
Fix audio/video driver name parsing and remove 2 little memleaks
author | albeu |
---|---|
date | Tue, 28 May 2002 10:08:30 +0000 |
parents | e46b3bf16df5 |
children | 8cfddba867b4 |
comparison
equal
deleted
inserted
replaced
6216:c887475712ae | 6217:d2167f69a48b |
---|---|
881 sub_auto=0; // don't do autosub for textsubs if vobsub found | 881 sub_auto=0; // don't do autosub for textsubs if vobsub found |
882 | 882 |
883 //==================== Init Video Out ============================ | 883 //==================== Init Video Out ============================ |
884 | 884 |
885 // check video_out driver name: | 885 // check video_out driver name: |
886 { | |
887 char* vo = video_driver ? strdup(video_driver) : NULL; | |
888 if(vo_subdevice) { | |
889 free(vo_subdevice); | |
890 vo_subdevice = NULL; | |
891 } | |
886 if (video_driver) | 892 if (video_driver) |
887 if ((i = strcspn(video_driver, ":")) > 0) | 893 if ((i = strcspn(video_driver, ":")) > 0) |
888 { | 894 { |
889 size_t i2 = strlen(video_driver); | 895 size_t i2 = strlen(video_driver); |
890 | 896 |
891 if (video_driver[i] == ':') | 897 if (video_driver[i] == ':') |
892 { | 898 { |
893 vo_subdevice = malloc(i2-i); | 899 vo_subdevice = malloc(i2-i); |
894 if (vo_subdevice != NULL) | 900 if (vo_subdevice != NULL) |
895 strncpy(vo_subdevice, (char *)(video_driver+i+1), i2-i); | 901 strncpy(vo_subdevice, (char *)(video_driver+i+1), i2-i); |
896 video_driver[i] = '\0'; | 902 vo[i] = '\0'; |
897 } | 903 } |
898 // printf("video_driver: %s, subdevice: %s\n", video_driver, vo_subdevice); | 904 // printf("video_driver: %s, subdevice: %s\n", video_driver, vo_subdevice); |
899 } | 905 } |
900 if(!video_driver) | 906 if(!video_driver) |
901 video_out=video_out_drivers[0]; | 907 video_out=video_out_drivers[0]; |
902 else | 908 else |
903 for (i=0; video_out_drivers[i] != NULL; i++){ | 909 for (i=0; video_out_drivers[i] != NULL; i++){ |
904 const vo_info_t *info = video_out_drivers[i]->get_info (); | 910 const vo_info_t *info = video_out_drivers[i]->get_info (); |
905 if(strcmp(info->short_name,video_driver) == 0){ | 911 if(strcmp(info->short_name,vo) == 0){ |
906 video_out = video_out_drivers[i];break; | 912 video_out = video_out_drivers[i];break; |
907 } | 913 } |
908 } | 914 } |
909 | 915 |
910 if(!video_out){ | 916 if(!video_out){ |
911 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_InvalidVOdriver,video_driver?video_driver:"?"); | 917 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_InvalidVOdriver,vo?vo:"?"); |
912 exit_player(MSGTR_Exit_error); | 918 exit_player(MSGTR_Exit_error); |
913 } | 919 } |
920 if(vo) | |
921 free(vo); | |
922 } | |
914 | 923 |
915 //==================== Init Audio Out ============================ | 924 //==================== Init Audio Out ============================ |
916 | 925 |
917 // check audio_out driver name: | 926 // check audio_out driver name: |
927 { | |
928 char* ao = audio_driver ? strdup(audio_driver) : NULL; | |
929 if(ao_subdevice) { | |
930 free(ao_subdevice); | |
931 ao_subdevice = NULL; | |
932 } | |
918 if (audio_driver) | 933 if (audio_driver) |
919 if ((i = strcspn(audio_driver, ":")) > 0) | 934 if ((i = strcspn(audio_driver, ":")) > 0) |
920 { | 935 { |
921 size_t i2 = strlen(audio_driver); | 936 size_t i2 = strlen(audio_driver); |
922 | 937 |
923 if (audio_driver[i] == ':') | 938 if (audio_driver[i] == ':') |
924 { | 939 { |
925 ao_subdevice = malloc(i2-i); | 940 ao_subdevice = malloc(i2-i); |
926 if (ao_subdevice != NULL) | 941 if (ao_subdevice != NULL) |
927 strncpy(ao_subdevice, (char *)(audio_driver+i+1), i2-i); | 942 strncpy(ao_subdevice, (char *)(audio_driver+i+1), i2-i); |
928 audio_driver[i] = '\0'; | 943 ao[i] = '\0'; |
929 } | 944 } |
930 // printf("audio_driver: %s, subdevice: %s\n", audio_driver, ao_subdevice); | 945 // printf("audio_driver: %s, subdevice: %s\n", audio_driver, ao_subdevice); |
931 } | 946 } |
932 if(!audio_driver) | 947 if(!audio_driver) |
933 audio_out=audio_out_drivers[0]; | 948 audio_out=audio_out_drivers[0]; |
934 else | 949 else |
935 for (i=0; audio_out_drivers[i] != NULL; i++){ | 950 for (i=0; audio_out_drivers[i] != NULL; i++){ |
936 const ao_info_t *info = audio_out_drivers[i]->info; | 951 const ao_info_t *info = audio_out_drivers[i]->info; |
937 if(strcmp(info->short_name,audio_driver) == 0){ | 952 if(strcmp(info->short_name,ao) == 0){ |
938 audio_out = audio_out_drivers[i];break; | 953 audio_out = audio_out_drivers[i];break; |
939 } | 954 } |
940 } | 955 } |
941 if (!audio_out){ | 956 if (!audio_out){ |
942 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_InvalidAOdriver,audio_driver); | 957 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_InvalidAOdriver,ao?ao:"?"); |
943 exit_player(MSGTR_Exit_error); | 958 exit_player(MSGTR_Exit_error); |
944 } | 959 } |
960 if(ao) | |
961 free(ao); | |
945 /* Initailize audio plugin interface if used */ | 962 /* Initailize audio plugin interface if used */ |
946 if(ao_plugin_cfg.plugin_list){ | 963 if(ao_plugin_cfg.plugin_list){ |
947 for (i=0; audio_out_drivers[i] != NULL; i++){ | 964 for (i=0; audio_out_drivers[i] != NULL; i++){ |
948 const ao_info_t *info = audio_out_drivers[i]->info; | 965 const ao_info_t *info = audio_out_drivers[i]->info; |
949 if(strcmp(info->short_name,"plugin") == 0){ | 966 if(strcmp(info->short_name,"plugin") == 0){ |
951 audio_out = audio_out_drivers[i]; | 968 audio_out = audio_out_drivers[i]; |
952 break; | 969 break; |
953 } | 970 } |
954 } | 971 } |
955 } | 972 } |
956 | 973 } |
957 //============ Open & Sync STREAM --- fork cache2 ==================== | 974 //============ Open & Sync STREAM --- fork cache2 ==================== |
958 | 975 |
959 stream=NULL; | 976 stream=NULL; |
960 demuxer=NULL; | 977 demuxer=NULL; |
961 d_audio=NULL; | 978 d_audio=NULL; |