Skip to content

Commit

Permalink
Fix can't play AAC audio in old OS.
Browse files Browse the repository at this point in the history
  • Loading branch information
kfstorm authored and Kai Yang committed Jun 12, 2015
1 parent 611d7f6 commit 1b452e3
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 6 deletions.
27 changes: 24 additions & 3 deletions DoubanFM.Bass/BassEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ enum PendingOperation

private static readonly Dictionary<string, IntPtr> stringHandles = new Dictionary<string, IntPtr>();
private Un4seen.Bass.BASSFlag openUrlConfig = (Un4seen.Bass.BASSFlag)Enum.Parse(typeof(Un4seen.Bass.BASSFlag), ConfigurationManager.AppSettings["Bass.OpenUrlConfig"]);
private static readonly List<int> pluginHandles;
#endregion

#region Constructor
Expand All @@ -122,10 +123,26 @@ static BassEngine()
//判断当前系统是32位系统还是64位系统,并加载对应版本的bass.dll
string exeFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().GetModules()[0].FullyQualifiedName);
string libraryPathSetting = Un4seen.Bass.Utils.Is64Bit ? "Bass.LibraryPathX64" : "Bass.LibraryPathX86";
string targetPath = Path.Combine(exeFolder, ConfigurationManager.AppSettings[libraryPathSetting]);
string bassDllBasePath = Path.Combine(exeFolder, ConfigurationManager.AppSettings[libraryPathSetting]);

// now load all libs manually
Un4seen.Bass.Bass.LoadMe(targetPath);
Un4seen.Bass.Bass.LoadMe(bassDllBasePath);
var loadedPlugins =
Un4seen.Bass.Bass.BASS_PluginLoadDirectory(
string.Format(ConfigurationManager.AppSettings["Bass.PluginPathFormat"], bassDllBasePath));
if (loadedPlugins != null)
{
foreach (var item in loadedPlugins)
{
Debug.WriteLine(string.Format("Plugin loaded: {0}", item.Value));
}
pluginHandles = loadedPlugins.Keys.ToList();
}
else
{
pluginHandles = new List<int>();
}

//BassMix.LoadMe(targetPath);
//...
//loadedPlugIns = Bass.BASS_PluginLoadDirectory(targetPath);
Expand Down Expand Up @@ -171,7 +188,11 @@ protected virtual void Dispose(bool disposing)
}
}
// at the end of your application call this!
Un4seen.Bass.Bass.BASS_Free();
foreach (var handle in pluginHandles)
{
Un4seen.Bass.Bass.BASS_PluginFree(handle);
}
Un4seen.Bass.Bass.BASS_Free();
Un4seen.Bass.Bass.FreeMe();
//BassMix.FreeMe(targetPath);
//...
Expand Down
8 changes: 8 additions & 0 deletions DoubanFM.Bass/DoubanFM.Bass.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="x64\plugins\bass_aac.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="x86\plugins\bass_aac.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
2 changes: 1 addition & 1 deletion DoubanFM.Bass/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.1.1")]
[assembly: AssemblyVersion("2.1.4.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
Binary file added DoubanFM.Bass/x64/plugins/bass_aac.dll
Binary file not shown.
Binary file added DoubanFM.Bass/x86/plugins/bass_aac.dll
Binary file not shown.
1 change: 1 addition & 0 deletions DoubanFM/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<add key="Bass.SampleFrequency" value="44100"/>
<add key="Bass.LibraryPathX86" value="x86"/>
<add key="Bass.LibraryPathX64" value="x64"/>
<add key="Bass.PluginPathFormat" value="{0}\plugins"/>
<add key="Bass.OpenFileConfig" value="BASS_DEFAULT"/>
<add key="Bass.OpenUrlConfig" value="BASS_DEFAULT"/>
<add key="Bass.InitFlags" value="BASS_DEVICE_DEFAULT"/>
Expand Down
8 changes: 8 additions & 0 deletions ScriptForInstaller/DoubanFM.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ Section "MainSection" SEC01
File "DoubanFM.exe"
SetOutPath "$INSTDIR\x86"
File "x86\bass.dll"
SetOutPath "$INSTDIR\x86\plugins"
File "x86\plugins\bass_aac.dll"
SetOutPath "$INSTDIR\x64"
File "x64\bass.dll"
SetOutPath "$INSTDIR\x64\plugins"
File "x64\plugins\bass_aac.dll"
SetOutPath "$INSTDIR\zh-CN"
File "zh-CN\DoubanFM.resources.dll"
File "zh-CN\DoubanFM.Core.resources.dll"
Expand Down Expand Up @@ -159,11 +163,15 @@ DeleteExe:
Delete "$INSTDIR\version.dat"
Delete "$INSTDIR\x86\bass.dll"
Delete "$INSTDIR\x64\bass.dll"
Delete "$INSTDIR\x86\plugins\bass_aac.dll"
Delete "$INSTDIR\x64\plugins\bass_aac.dll"
Delete "$INSTDIR\Bass.Net.dll"
Delete "$INSTDIR\DoubanFM.Bass.dll"
Delete "$INSTDIR\DwmHelper.dll"
Delete "$INSTDIR\zh-CN\DoubanFM.resources.dll"
Delete "$INSTDIR\zh-CN\DoubanFM.Core.resources.dll"
RMDir "$INSTDIR\x86\plugins"
RMDir "$INSTDIR\x64\plugins"
RMDir "$INSTDIR\x86"
RMDir "$INSTDIR\x64"
RMDir "$INSTDIR\zh-CN"
Expand Down
2 changes: 1 addition & 1 deletion ScriptForInstaller/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set version=%1
if "%1" == "" echo 必须输入版本号!
if "%1" == "" goto :eof
cd /d %~dp0
@call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat" x86
@call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86
@set "PATH=%WindowsSdkDir%bin;%PATH%"
set projectdir=..\DoubanFM\bin\Release
set imagedir=Images
Expand Down
2 changes: 1 addition & 1 deletion version.dat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.3.0
2.1.4.0

0 comments on commit 1b452e3

Please sign in to comment.